1
0

LLClientView.cs 569 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930
  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.Monitoring;
  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 RegionFlags = OpenMetaverse.RegionFlags;
  50. using System.IO;
  51. using PermissionMask = OpenSim.Framework.PermissionMask;
  52. namespace OpenSim.Region.ClientStack.LindenUDP
  53. {
  54. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  55. /// <summary>
  56. /// Handles new client connections
  57. /// Constructor takes a single Packet and authenticates everything
  58. /// </summary>
  59. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
  60. {
  61. /// <value>
  62. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  63. /// </value>
  64. public int DebugPacketLevel { get; set; }
  65. #region Events
  66. public event GenericMessage OnGenericMessage;
  67. public event BinaryGenericMessage OnBinaryGenericMessage;
  68. public event Action<IClientAPI> OnLogout;
  69. public event ObjectPermissions OnObjectPermissions;
  70. public event Action<IClientAPI> OnConnectionClosed;
  71. public event ViewerEffectEventHandler OnViewerEffect;
  72. public event ImprovedInstantMessage OnInstantMessage;
  73. public event ChatMessage OnChatFromClient;
  74. public event TextureRequest OnRequestTexture;
  75. public event RezObject OnRezObject;
  76. public event DeRezObject OnDeRezObject;
  77. public event ModifyTerrain OnModifyTerrain;
  78. public event Action<IClientAPI> OnRegionHandShakeReply;
  79. public event GenericCall1 OnRequestWearables;
  80. public event CachedTextureRequest OnCachedTextureRequest;
  81. public event SetAppearance OnSetAppearance;
  82. public event AvatarNowWearing OnAvatarNowWearing;
  83. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  84. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  85. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  86. public event ObjectAttach OnObjectAttach;
  87. public event ObjectDeselect OnObjectDetach;
  88. public event ObjectDrop OnObjectDrop;
  89. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  90. public event UpdateAgent OnPreAgentUpdate;
  91. public event UpdateAgent OnAgentUpdate;
  92. public event UpdateAgent OnAgentCameraUpdate;
  93. public event AgentRequestSit OnAgentRequestSit;
  94. public event AgentSit OnAgentSit;
  95. public event AvatarPickerRequest OnAvatarPickerRequest;
  96. public event StartAnim OnStartAnim;
  97. public event StopAnim OnStopAnim;
  98. public event Action<IClientAPI> OnRequestAvatarsData;
  99. public event LinkObjects OnLinkObjects;
  100. public event DelinkObjects OnDelinkObjects;
  101. public event GrabObject OnGrabObject;
  102. public event DeGrabObject OnDeGrabObject;
  103. public event SpinStart OnSpinStart;
  104. public event SpinStop OnSpinStop;
  105. public event ObjectDuplicate OnObjectDuplicate;
  106. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  107. public event MoveObject OnGrabUpdate;
  108. public event SpinObject OnSpinUpdate;
  109. public event AddNewPrim OnAddPrim;
  110. public event RequestGodlikePowers OnRequestGodlikePowers;
  111. public event GodKickUser OnGodKickUser;
  112. public event ObjectExtraParams OnUpdateExtraParams;
  113. public event UpdateShape OnUpdatePrimShape;
  114. public event ObjectRequest OnObjectRequest;
  115. public event ObjectSelect OnObjectSelect;
  116. public event ObjectDeselect OnObjectDeselect;
  117. public event GenericCall7 OnObjectDescription;
  118. public event GenericCall7 OnObjectName;
  119. public event GenericCall7 OnObjectClickAction;
  120. public event GenericCall7 OnObjectMaterial;
  121. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  122. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  123. public event UpdatePrimFlags OnUpdatePrimFlags;
  124. public event UpdatePrimTexture OnUpdatePrimTexture;
  125. public event UpdateVector OnUpdatePrimGroupPosition;
  126. public event UpdateVector OnUpdatePrimSinglePosition;
  127. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  128. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  129. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  130. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  131. public event UpdateVector OnUpdatePrimScale;
  132. public event UpdateVector OnUpdatePrimGroupScale;
  133. public event StatusChange OnChildAgentStatus;
  134. public event GenericCall2 OnStopMovement;
  135. public event Action<UUID> OnRemoveAvatar;
  136. public event RequestMapBlocks OnRequestMapBlocks;
  137. public event RequestMapName OnMapNameRequest;
  138. public event TeleportLocationRequest OnTeleportLocationRequest;
  139. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  140. public event TeleportCancel OnTeleportCancel;
  141. public event DisconnectUser OnDisconnectUser;
  142. public event RequestAvatarProperties OnRequestAvatarProperties;
  143. public event SetAlwaysRun OnSetAlwaysRun;
  144. public event FetchInventory OnAgentDataUpdateRequest;
  145. public event TeleportLocationRequest OnSetStartLocationRequest;
  146. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  147. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  148. public event LinkInventoryItem OnLinkInventoryItem;
  149. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  150. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  151. public event MoveInventoryFolder OnMoveInventoryFolder;
  152. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  153. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  154. public event FetchInventory OnFetchInventory;
  155. public event RequestTaskInventory OnRequestTaskInventory;
  156. public event UpdateInventoryItem OnUpdateInventoryItem;
  157. public event CopyInventoryItem OnCopyInventoryItem;
  158. public event MoveInventoryItem OnMoveInventoryItem;
  159. public event RemoveInventoryItem OnRemoveInventoryItem;
  160. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  161. public event UDPAssetUploadRequest OnAssetUploadRequest;
  162. public event XferReceive OnXferReceive;
  163. public event RequestXfer OnRequestXfer;
  164. public event ConfirmXfer OnConfirmXfer;
  165. public event AbortXfer OnAbortXfer;
  166. public event RequestTerrain OnRequestTerrain;
  167. public event RezScript OnRezScript;
  168. public event UpdateTaskInventory OnUpdateTaskInventory;
  169. public event MoveTaskInventory OnMoveTaskItem;
  170. public event RemoveTaskInventory OnRemoveTaskItem;
  171. public event RequestAsset OnRequestAsset;
  172. public event UUIDNameRequest OnNameFromUUIDRequest;
  173. public event ParcelAccessListRequest OnParcelAccessListRequest;
  174. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  175. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  176. public event ParcelDivideRequest OnParcelDivideRequest;
  177. public event ParcelJoinRequest OnParcelJoinRequest;
  178. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  179. public event ParcelSelectObjects OnParcelSelectObjects;
  180. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  181. public event ParcelAbandonRequest OnParcelAbandonRequest;
  182. public event ParcelGodForceOwner OnParcelGodForceOwner;
  183. public event ParcelReclaim OnParcelReclaim;
  184. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  185. public event ParcelDeedToGroup OnParcelDeedToGroup;
  186. public event RegionInfoRequest OnRegionInfoRequest;
  187. public event EstateCovenantRequest OnEstateCovenantRequest;
  188. public event FriendActionDelegate OnApproveFriendRequest;
  189. public event FriendActionDelegate OnDenyFriendRequest;
  190. public event FriendshipTermination OnTerminateFriendship;
  191. public event GrantUserFriendRights OnGrantUserRights;
  192. public event MoneyTransferRequest OnMoneyTransferRequest;
  193. public event EconomyDataRequest OnEconomyDataRequest;
  194. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  195. public event ParcelBuy OnParcelBuy;
  196. public event UUIDNameRequest OnTeleportHomeRequest;
  197. public event UUIDNameRequest OnUUIDGroupNameRequest;
  198. public event ScriptAnswer OnScriptAnswer;
  199. public event RequestPayPrice OnRequestPayPrice;
  200. public event ObjectSaleInfo OnObjectSaleInfo;
  201. public event ObjectBuy OnObjectBuy;
  202. public event BuyObjectInventory OnBuyObjectInventory;
  203. public event AgentSit OnUndo;
  204. public event AgentSit OnRedo;
  205. public event LandUndo OnLandUndo;
  206. public event ForceReleaseControls OnForceReleaseControls;
  207. public event GodLandStatRequest OnLandStatRequest;
  208. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  209. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  210. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  211. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  212. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  213. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  214. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  215. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  216. public event BakeTerrain OnBakeTerrain;
  217. public event RequestTerrain OnUploadTerrain;
  218. public event EstateChangeInfo OnEstateChangeInfo;
  219. public event EstateManageTelehub OnEstateManageTelehub;
  220. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  221. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  222. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  223. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  224. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  225. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  226. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  227. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  228. public event RegionHandleRequest OnRegionHandleRequest;
  229. public event ParcelInfoRequest OnParcelInfoRequest;
  230. public event ScriptReset OnScriptReset;
  231. public event GetScriptRunning OnGetScriptRunning;
  232. public event SetScriptRunning OnSetScriptRunning;
  233. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  234. public event TerrainUnacked OnUnackedTerrain;
  235. public event ActivateGesture OnActivateGesture;
  236. public event DeactivateGesture OnDeactivateGesture;
  237. public event ObjectOwner OnObjectOwner;
  238. public event DirPlacesQuery OnDirPlacesQuery;
  239. public event DirFindQuery OnDirFindQuery;
  240. public event DirLandQuery OnDirLandQuery;
  241. public event DirPopularQuery OnDirPopularQuery;
  242. public event DirClassifiedQuery OnDirClassifiedQuery;
  243. public event EventInfoRequest OnEventInfoRequest;
  244. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  245. public event MapItemRequest OnMapItemRequest;
  246. public event OfferCallingCard OnOfferCallingCard;
  247. public event AcceptCallingCard OnAcceptCallingCard;
  248. public event DeclineCallingCard OnDeclineCallingCard;
  249. public event SoundTrigger OnSoundTrigger;
  250. public event StartLure OnStartLure;
  251. public event TeleportLureRequest OnTeleportLureRequest;
  252. public event NetworkStats OnNetworkStatsUpdate;
  253. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  254. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  255. public event ClassifiedDelete OnClassifiedDelete;
  256. public event ClassifiedDelete OnClassifiedGodDelete;
  257. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  258. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  259. public event EventGodDelete OnEventGodDelete;
  260. public event ParcelDwellRequest OnParcelDwellRequest;
  261. public event UserInfoRequest OnUserInfoRequest;
  262. public event UpdateUserInfo OnUpdateUserInfo;
  263. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  264. public event PickDelete OnPickDelete;
  265. public event PickGodDelete OnPickGodDelete;
  266. public event PickInfoUpdate OnPickInfoUpdate;
  267. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  268. public event MuteListRequest OnMuteListRequest;
  269. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  270. public event PlacesQuery OnPlacesQuery;
  271. public event AgentFOV OnAgentFOV;
  272. public event FindAgentUpdate OnFindAgent;
  273. public event TrackAgentUpdate OnTrackAgent;
  274. public event NewUserReport OnUserReport;
  275. public event SaveStateHandler OnSaveState;
  276. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  277. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  278. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  279. public event FreezeUserUpdate OnParcelFreezeUser;
  280. public event EjectUserUpdate OnParcelEjectUser;
  281. public event ParcelBuyPass OnParcelBuyPass;
  282. public event ParcelGodMark OnParcelGodMark;
  283. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  284. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  285. public event SimWideDeletesDelegate OnSimWideDeletes;
  286. public event SendPostcard OnSendPostcard;
  287. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  288. public event MuteListEntryRemove OnRemoveMuteListEntry;
  289. public event GodlikeMessage onGodlikeMessage;
  290. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  291. #endregion Events
  292. #region Class Members
  293. // LLClientView Only
  294. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  295. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  296. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  297. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  298. private static string LogHeader = "[LLCLIENTVIEW]";
  299. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  300. /// <summary>
  301. /// Handles UDP texture download.
  302. /// </summary>
  303. public LLImageManager ImageManager { get; private set; }
  304. private readonly LLUDPServer m_udpServer;
  305. private readonly LLUDPClient m_udpClient;
  306. private readonly UUID m_sessionId;
  307. private readonly UUID m_secureSessionId;
  308. protected readonly UUID m_agentId;
  309. private readonly uint m_circuitCode;
  310. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  311. private readonly IGroupsModule m_GroupsModule;
  312. private PriorityQueue m_entityUpdates;
  313. private PriorityQueue m_entityProps;
  314. private Prioritizer m_prioritizer;
  315. private bool m_disableFacelights = false;
  316. private volatile bool m_justEditedTerrain = false;
  317. /// <value>
  318. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  319. /// continually recreate it.
  320. /// </value>
  321. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  322. /// <value>
  323. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  324. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  325. /// ownerless phantom.
  326. ///
  327. /// All manipulation of this set has to occur under a lock
  328. ///
  329. /// </value>
  330. protected HashSet<uint> m_killRecord;
  331. // protected HashSet<uint> m_attachmentsSent;
  332. private int m_animationSequenceNumber = 1;
  333. private bool m_SendLogoutPacketWhenClosing = true;
  334. /// <summary>
  335. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  336. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  337. /// is doing absolutely nothing.
  338. /// </summary>
  339. /// <remarks>
  340. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  341. /// cannot retain a reference to it outside of that method.
  342. /// </remarks>
  343. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  344. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  345. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  346. protected Scene m_scene;
  347. protected string m_firstName;
  348. protected string m_lastName;
  349. protected Thread m_clientThread;
  350. protected Vector3 m_startpos;
  351. protected UUID m_activeGroupID;
  352. protected string m_activeGroupName = String.Empty;
  353. protected ulong m_activeGroupPowers;
  354. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  355. protected int m_terrainCheckerCount;
  356. protected uint m_agentFOVCounter;
  357. protected IAssetService m_assetService;
  358. private const bool m_checkPackets = true;
  359. #endregion Class Members
  360. #region Properties
  361. public LLUDPClient UDPClient { get { return m_udpClient; } }
  362. public LLUDPServer UDPServer { get { return m_udpServer; } }
  363. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  364. public UUID SecureSessionId { get { return m_secureSessionId; } }
  365. public IScene Scene { get { return m_scene; } }
  366. public UUID SessionId { get { return m_sessionId; } }
  367. public Vector3 StartPos
  368. {
  369. get { return m_startpos; }
  370. set { m_startpos = value; }
  371. }
  372. public UUID AgentId { get { return m_agentId; } }
  373. public ISceneAgent SceneAgent { get; set; }
  374. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  375. public string ActiveGroupName { get { return m_activeGroupName; } }
  376. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  377. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  378. /// <summary>
  379. /// Entity update queues
  380. /// </summary>
  381. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  382. /// <summary>
  383. /// First name of the agent/avatar represented by the client
  384. /// </summary>
  385. public string FirstName { get { return m_firstName; } }
  386. /// <summary>
  387. /// Last name of the agent/avatar represented by the client
  388. /// </summary>
  389. public string LastName { get { return m_lastName; } }
  390. /// <summary>
  391. /// Full name of the client (first name and last name)
  392. /// </summary>
  393. public string Name { get { return FirstName + " " + LastName; } }
  394. public uint CircuitCode { get { return m_circuitCode; } }
  395. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  396. /// <summary>
  397. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  398. /// prevent race conditions by different threads calling Close().
  399. /// </summary>
  400. public bool IsActive { get; set; }
  401. /// <summary>
  402. /// Used to synchronise threads when client is being closed.
  403. /// </summary>
  404. public Object CloseSyncLock { get; private set; }
  405. public bool IsLoggingOut { get; set; }
  406. public bool DisableFacelights
  407. {
  408. get { return m_disableFacelights; }
  409. set { m_disableFacelights = value; }
  410. }
  411. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  412. #endregion Properties
  413. // ~LLClientView()
  414. // {
  415. // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode);
  416. // }
  417. /// <summary>
  418. /// Constructor
  419. /// </summary>
  420. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  421. UUID agentId, UUID sessionId, uint circuitCode)
  422. {
  423. // DebugPacketLevel = 1;
  424. CloseSyncLock = new Object();
  425. RegisterInterface<IClientIM>(this);
  426. RegisterInterface<IClientInventory>(this);
  427. RegisterInterface<IClientChat>(this);
  428. m_scene = scene;
  429. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  430. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  431. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  432. m_killRecord = new HashSet<uint>();
  433. // m_attachmentsSent = new HashSet<uint>();
  434. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  435. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  436. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  437. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  438. m_agentId = agentId;
  439. m_sessionId = sessionId;
  440. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  441. m_circuitCode = circuitCode;
  442. m_firstName = sessionInfo.LoginInfo.First;
  443. m_lastName = sessionInfo.LoginInfo.Last;
  444. m_startpos = sessionInfo.LoginInfo.StartPos;
  445. m_udpServer = udpServer;
  446. m_udpClient = udpClient;
  447. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  448. m_udpClient.HasUpdates += HandleHasUpdates;
  449. m_udpClient.OnPacketStats += PopulateStats;
  450. m_prioritizer = new Prioritizer(m_scene);
  451. RegisterLocalPacketHandlers();
  452. IsActive = true;
  453. }
  454. #region Client Methods
  455. public void Close()
  456. {
  457. Close(false);
  458. }
  459. public void Close(bool force)
  460. {
  461. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  462. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  463. lock (CloseSyncLock)
  464. {
  465. // We still perform a force close inside the sync lock since this is intended to attempt close where
  466. // there is some unidentified connection problem, not where we have issues due to deadlock
  467. if (!IsActive && !force)
  468. {
  469. m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set",
  470. LogHeader, Name, m_scene.Name);
  471. return;
  472. }
  473. IsActive = false;
  474. CloseWithoutChecks();
  475. }
  476. }
  477. /// <summary>
  478. /// Closes down the client view without first checking whether it is active.
  479. /// </summary>
  480. /// <remarks>
  481. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  482. /// CloseWithoutIsActiveCheck asynchronously.
  483. ///
  484. /// Callers must lock ClosingSyncLock before calling.
  485. /// </remarks>
  486. public void CloseWithoutChecks()
  487. {
  488. m_log.DebugFormat(
  489. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  490. Name, m_scene.RegionInfo.RegionName);
  491. // Shutdown the image manager
  492. ImageManager.Close();
  493. // Fire the callback for this connection closing
  494. if (OnConnectionClosed != null)
  495. OnConnectionClosed(this);
  496. // Flush all of the packets out of the UDP server for this client
  497. if (m_udpServer != null)
  498. m_udpServer.Flush(m_udpClient);
  499. // Remove ourselves from the scene
  500. m_scene.RemoveClient(AgentId, true);
  501. SceneAgent = null;
  502. // We can't reach into other scenes and close the connection
  503. // We need to do this over grid communications
  504. //m_scene.CloseAllAgents(CircuitCode);
  505. // Disable UDP handling for this client
  506. m_udpClient.Shutdown();
  507. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  508. //GC.Collect();
  509. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  510. }
  511. public void Kick(string message)
  512. {
  513. if (!SceneAgent.IsChildAgent)
  514. {
  515. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  516. kupack.UserInfo.AgentID = AgentId;
  517. kupack.UserInfo.SessionID = SessionId;
  518. kupack.TargetBlock.TargetIP = 0;
  519. kupack.TargetBlock.TargetPort = 0;
  520. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  521. OutPacket(kupack, ThrottleOutPacketType.Task);
  522. // You must sleep here or users get no message!
  523. Thread.Sleep(500);
  524. }
  525. }
  526. public void Stop()
  527. {
  528. }
  529. #endregion Client Methods
  530. #region Packet Handling
  531. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  532. {
  533. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  534. if (handlerNetworkStatsUpdate != null)
  535. {
  536. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  537. }
  538. }
  539. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  540. {
  541. bool result = false;
  542. lock (PacketHandlers)
  543. {
  544. if (!PacketHandlers.ContainsKey(packetType))
  545. {
  546. PacketHandlers.Add(packetType, handler);
  547. result = true;
  548. }
  549. }
  550. return result;
  551. }
  552. /// <summary>
  553. /// Add a handler for the given packet type.
  554. /// </summary>
  555. /// <remarks>
  556. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  557. /// are received then please use the synchronous version of this method.
  558. /// </remarks>
  559. /// <param name="packetType"></param>
  560. /// <param name="handler"></param>
  561. /// <returns>true if the handler was added. This is currently always the case.</returns>
  562. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  563. {
  564. return AddLocalPacketHandler(packetType, handler, true);
  565. }
  566. /// <summary>
  567. /// Add a handler for the given packet type.
  568. /// </summary>
  569. /// <param name="packetType"></param>
  570. /// <param name="handler"></param>
  571. /// <param name="doAsync">
  572. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  573. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  574. /// synchronously.
  575. /// </param>
  576. /// <returns>true if the handler was added. This is currently always the case.</returns>
  577. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  578. {
  579. bool result = false;
  580. lock (m_packetHandlers)
  581. {
  582. if (!m_packetHandlers.ContainsKey(packetType))
  583. {
  584. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  585. result = true;
  586. }
  587. }
  588. return result;
  589. }
  590. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  591. {
  592. MethodName = MethodName.ToLower().Trim();
  593. bool result = false;
  594. lock (m_genericPacketHandlers)
  595. {
  596. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  597. {
  598. m_genericPacketHandlers.Add(MethodName, handler);
  599. result = true;
  600. }
  601. }
  602. return result;
  603. }
  604. /// <summary>
  605. /// Try to process a packet using registered packet handlers
  606. /// </summary>
  607. /// <param name="packet"></param>
  608. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  609. protected virtual bool ProcessPacketMethod(Packet packet)
  610. {
  611. bool result = false;
  612. PacketProcessor pprocessor;
  613. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  614. {
  615. //there is a local handler for this packet type
  616. if (pprocessor.Async)
  617. {
  618. ClientInfo cinfo = UDPClient.GetClientInfo();
  619. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  620. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  621. cinfo.AsyncRequests[packet.Type.ToString()]++;
  622. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  623. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  624. result = true;
  625. }
  626. else
  627. {
  628. ClientInfo cinfo = UDPClient.GetClientInfo();
  629. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  630. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  631. cinfo.SyncRequests[packet.Type.ToString()]++;
  632. result = pprocessor.method(this, packet);
  633. }
  634. }
  635. else
  636. {
  637. //there is not a local handler so see if there is a Global handler
  638. PacketMethod method = null;
  639. bool found;
  640. lock (PacketHandlers)
  641. {
  642. found = PacketHandlers.TryGetValue(packet.Type, out method);
  643. }
  644. if (found)
  645. {
  646. ClientInfo cinfo = UDPClient.GetClientInfo();
  647. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  648. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  649. cinfo.GenericRequests[packet.Type.ToString()]++;
  650. result = method(this, packet);
  651. }
  652. }
  653. return result;
  654. }
  655. public void ProcessSpecificPacketAsync(object state)
  656. {
  657. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  658. try
  659. {
  660. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  661. }
  662. catch (Exception e)
  663. {
  664. // Make sure that we see any exception caused by the asynchronous operation.
  665. m_log.ErrorFormat(
  666. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  667. packetObject.Pack, Name, e.Message, e.StackTrace);
  668. }
  669. }
  670. #endregion Packet Handling
  671. # region Setup
  672. public virtual void Start()
  673. {
  674. m_scene.AddNewAgent(this, PresenceType.User);
  675. RefreshGroupMembership();
  676. }
  677. # endregion
  678. public void ActivateGesture(UUID assetId, UUID gestureId)
  679. {
  680. }
  681. public void DeactivateGesture(UUID assetId, UUID gestureId)
  682. {
  683. }
  684. // Sound
  685. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  686. {
  687. }
  688. #region Scene/Avatar to Client
  689. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  690. {
  691. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  692. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  693. handshake.RegionInfo.BillableFactor = args.billableFactor;
  694. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  695. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  696. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  697. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  698. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  699. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  700. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  701. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  702. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  703. handshake.RegionInfo.SimAccess = args.simAccess;
  704. handshake.RegionInfo.WaterHeight = args.waterHeight;
  705. handshake.RegionInfo.RegionFlags = args.regionFlags;
  706. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  707. handshake.RegionInfo.SimOwner = args.SimOwner;
  708. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  709. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  710. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  711. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  712. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  713. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  714. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  715. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  716. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  717. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  718. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  719. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  720. handshake.RegionInfo3.CPUClassID = 9;
  721. handshake.RegionInfo3.CPURatio = 1;
  722. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  723. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  724. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  725. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  726. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  727. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  728. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  729. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  730. }
  731. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  732. {
  733. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  734. mov.SimData.ChannelVersion = m_channelVersion;
  735. mov.AgentData.SessionID = m_sessionId;
  736. mov.AgentData.AgentID = AgentId;
  737. mov.Data.RegionHandle = regInfo.RegionHandle;
  738. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  739. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  740. {
  741. mov.Data.Position = m_startpos;
  742. }
  743. else
  744. {
  745. mov.Data.Position = pos;
  746. }
  747. mov.Data.LookAt = look;
  748. // Hack to get this out immediately and skip the throttles
  749. OutPacket(mov, ThrottleOutPacketType.Unknown);
  750. }
  751. public void SendChatMessage(
  752. string message, byte type, Vector3 fromPos, string fromName,
  753. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  754. {
  755. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  756. reply.ChatData.Audible = audible;
  757. reply.ChatData.Message = Util.StringToBytes1024(message);
  758. reply.ChatData.ChatType = type;
  759. reply.ChatData.SourceType = source;
  760. reply.ChatData.Position = fromPos;
  761. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  762. reply.ChatData.OwnerID = ownerID;
  763. reply.ChatData.SourceID = fromAgentID;
  764. OutPacket(reply, ThrottleOutPacketType.Task);
  765. }
  766. /// <summary>
  767. /// Send an instant message to this client
  768. /// </summary>
  769. //
  770. // Don't remove transaction ID! Groups and item gives need to set it!
  771. public void SendInstantMessage(GridInstantMessage im)
  772. {
  773. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  774. {
  775. ImprovedInstantMessagePacket msg
  776. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  777. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  778. msg.AgentData.SessionID = UUID.Zero;
  779. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  780. msg.MessageBlock.Dialog = im.dialog;
  781. msg.MessageBlock.FromGroup = im.fromGroup;
  782. if (im.imSessionID == UUID.Zero.Guid)
  783. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  784. else
  785. msg.MessageBlock.ID = new UUID(im.imSessionID);
  786. msg.MessageBlock.Offline = im.offline;
  787. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  788. msg.MessageBlock.Position = im.Position;
  789. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  790. msg.MessageBlock.Timestamp = im.timestamp;
  791. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  792. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  793. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  794. if (im.message.StartsWith("[grouptest]"))
  795. { // this block is test code for implementing group IM - delete when group IM is finished
  796. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  797. if (eq != null)
  798. {
  799. im.dialog = 17;
  800. //eq.ChatterboxInvitation(
  801. // new UUID("00000000-68f9-1111-024e-222222111123"),
  802. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  803. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  804. eq.ChatterboxInvitation(
  805. new UUID("00000000-68f9-1111-024e-222222111123"),
  806. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  807. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  808. eq.ChatterBoxSessionAgentListUpdates(
  809. new UUID("00000000-68f9-1111-024e-222222111123"),
  810. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  811. }
  812. Console.WriteLine("SendInstantMessage: " + msg);
  813. }
  814. else
  815. OutPacket(msg, ThrottleOutPacketType.Task);
  816. }
  817. }
  818. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  819. {
  820. GenericMessagePacket gmp = new GenericMessagePacket();
  821. gmp.AgentData.AgentID = AgentId;
  822. gmp.AgentData.SessionID = m_sessionId;
  823. gmp.AgentData.TransactionID = invoice;
  824. gmp.MethodData.Method = Util.StringToBytes256(method);
  825. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  826. int i = 0;
  827. foreach (string val in message)
  828. {
  829. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  830. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  831. }
  832. OutPacket(gmp, ThrottleOutPacketType.Task);
  833. }
  834. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  835. {
  836. GenericMessagePacket gmp = new GenericMessagePacket();
  837. gmp.AgentData.AgentID = AgentId;
  838. gmp.AgentData.SessionID = m_sessionId;
  839. gmp.AgentData.TransactionID = invoice;
  840. gmp.MethodData.Method = Util.StringToBytes256(method);
  841. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  842. int i = 0;
  843. foreach (byte[] val in message)
  844. {
  845. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  846. gmp.ParamList[i++].Parameter = val;
  847. }
  848. OutPacket(gmp, ThrottleOutPacketType.Task);
  849. }
  850. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  851. {
  852. int i = 0;
  853. foreach (GroupActiveProposals Proposal in Proposals)
  854. {
  855. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  856. GAPIRP.AgentData.AgentID = AgentId;
  857. GAPIRP.AgentData.GroupID = groupID;
  858. GAPIRP.TransactionData.TransactionID = transactionID;
  859. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  860. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  861. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  862. ProposalData.VoteCast = Utils.StringToBytes("false");
  863. ProposalData.VoteID = new UUID(Proposal.VoteID);
  864. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  865. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  866. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  867. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  868. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  869. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  870. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  871. ProposalData.AlreadyVoted = false;
  872. GAPIRP.ProposalData[i] = ProposalData;
  873. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  874. i++;
  875. }
  876. if (Proposals.Length == 0)
  877. {
  878. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  879. GAPIRP.AgentData.AgentID = AgentId;
  880. GAPIRP.AgentData.GroupID = groupID;
  881. GAPIRP.TransactionData.TransactionID = transactionID;
  882. GAPIRP.TransactionData.TotalNumItems = 1;
  883. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  884. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  885. ProposalData.VoteCast = Utils.StringToBytes("false");
  886. ProposalData.VoteID = UUID.Zero;
  887. ProposalData.VoteInitiator = UUID.Zero;
  888. ProposalData.Majority = 0;
  889. ProposalData.Quorum = 0;
  890. ProposalData.TerseDateID = Utils.StringToBytes("");
  891. ProposalData.StartDateTime = Utils.StringToBytes("");
  892. ProposalData.EndDateTime = Utils.StringToBytes("");
  893. ProposalData.ProposalText = Utils.StringToBytes("");
  894. ProposalData.AlreadyVoted = false;
  895. GAPIRP.ProposalData[0] = ProposalData;
  896. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  897. }
  898. }
  899. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  900. {
  901. int i = 0;
  902. foreach (GroupVoteHistory Vote in Votes)
  903. {
  904. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  905. GVHIRP.AgentData.AgentID = AgentId;
  906. GVHIRP.AgentData.GroupID = groupID;
  907. GVHIRP.TransactionData.TransactionID = transactionID;
  908. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  909. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  910. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  911. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  912. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  913. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  914. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  915. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  916. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  917. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  918. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  919. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  920. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  921. VoteItem.CandidateID = UUID.Zero;
  922. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  923. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  924. GVHIRP.VoteItem[i] = VoteItem;
  925. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  926. i++;
  927. }
  928. if (Votes.Length == 0)
  929. {
  930. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  931. GVHIRP.AgentData.AgentID = AgentId;
  932. GVHIRP.AgentData.GroupID = groupID;
  933. GVHIRP.TransactionData.TransactionID = transactionID;
  934. GVHIRP.TransactionData.TotalNumItems = 0;
  935. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  936. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  937. GVHIRP.HistoryItemData.Majority = 0;
  938. GVHIRP.HistoryItemData.Quorum = 0;
  939. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  940. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  941. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  942. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  943. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  944. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  945. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  946. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  947. VoteItem.CandidateID = UUID.Zero;
  948. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  949. VoteItem.VoteCast = Utils.StringToBytes("No");
  950. GVHIRP.VoteItem[0] = VoteItem;
  951. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  952. }
  953. }
  954. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  955. {
  956. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  957. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  958. GADRP.AgentData.AgentID = sender.AgentId;
  959. GADRP.AgentData.GroupID = groupID;
  960. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  961. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  962. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  963. GADRP.MoneyData.CurrentInterval = 0;
  964. GADRP.MoneyData.IntervalDays = 7;
  965. GADRP.MoneyData.RequestID = transactionID;
  966. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  967. History.Amount = amt;
  968. History.Description = Utils.StringToBytes("");
  969. GADRP.HistoryData[0] = History;
  970. OutPacket(GADRP, ThrottleOutPacketType.Task);
  971. }
  972. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  973. {
  974. GroupAccountSummaryReplyPacket GASRP =
  975. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  976. PacketType.GroupAccountSummaryReply);
  977. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  978. GASRP.AgentData.AgentID = sender.AgentId;
  979. GASRP.AgentData.GroupID = groupID;
  980. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  981. GASRP.MoneyData.Balance = (int)moneyAmt;
  982. GASRP.MoneyData.TotalCredits = totalTier;
  983. GASRP.MoneyData.TotalDebits = usedTier;
  984. GASRP.MoneyData.StartDate = new byte[1];
  985. GASRP.MoneyData.CurrentInterval = 1;
  986. GASRP.MoneyData.GroupTaxCurrent = 0;
  987. GASRP.MoneyData.GroupTaxEstimate = 0;
  988. GASRP.MoneyData.IntervalDays = 0;
  989. GASRP.MoneyData.LandTaxCurrent = 0;
  990. GASRP.MoneyData.LandTaxEstimate = 0;
  991. GASRP.MoneyData.LastTaxDate = new byte[1];
  992. GASRP.MoneyData.LightTaxCurrent = 0;
  993. GASRP.MoneyData.TaxDate = new byte[1];
  994. GASRP.MoneyData.RequestID = sender.AgentId;
  995. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  996. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  997. GASRP.MoneyData.ObjectTaxEstimate = 0;
  998. GASRP.MoneyData.NonExemptMembers = 0;
  999. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1000. GASRP.MoneyData.LightTaxEstimate = 0;
  1001. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1002. }
  1003. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1004. {
  1005. GroupAccountTransactionsReplyPacket GATRP =
  1006. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1007. PacketType.GroupAccountTransactionsReply);
  1008. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1009. GATRP.AgentData.AgentID = sender.AgentId;
  1010. GATRP.AgentData.GroupID = groupID;
  1011. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1012. GATRP.MoneyData.CurrentInterval = 0;
  1013. GATRP.MoneyData.IntervalDays = 7;
  1014. GATRP.MoneyData.RequestID = transactionID;
  1015. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1016. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1017. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1018. History.Amount = 0;
  1019. History.Item = Utils.StringToBytes("");
  1020. History.Time = Utils.StringToBytes("");
  1021. History.Type = 0;
  1022. History.User = Utils.StringToBytes("");
  1023. GATRP.HistoryData[0] = History;
  1024. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1025. }
  1026. /// <summary>
  1027. /// Send the region heightmap to the client
  1028. /// </summary>
  1029. /// <param name="map">heightmap</param>
  1030. public virtual void SendLayerData(float[] map)
  1031. {
  1032. Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData());
  1033. }
  1034. /// <summary>
  1035. /// Send terrain layer information to the client.
  1036. /// </summary>
  1037. /// <param name="o"></param>
  1038. private void DoSendLayerData(object o)
  1039. {
  1040. TerrainData map = (TerrainData)o;
  1041. try
  1042. {
  1043. // Send LayerData in typerwriter pattern
  1044. //for (int y = 0; y < 16; y++)
  1045. //{
  1046. // for (int x = 0; x < 16; x++)
  1047. // {
  1048. // SendLayerData(x, y, map);
  1049. // }
  1050. //}
  1051. // Send LayerData in a spiral pattern. Fun!
  1052. SendLayerTopRight(map, 0, 0, map.SizeX/Constants.TerrainPatchSize-1, map.SizeY/Constants.TerrainPatchSize-1);
  1053. }
  1054. catch (Exception e)
  1055. {
  1056. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1057. }
  1058. }
  1059. private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2)
  1060. {
  1061. // Row
  1062. for (int i = x1; i <= x2; i++)
  1063. SendLayerData(i, y1, map);
  1064. // Column
  1065. for (int j = y1 + 1; j <= y2; j++)
  1066. SendLayerData(x2, j, map);
  1067. if (x2 - x1 > 0 && y2 - y1 > 0)
  1068. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1069. }
  1070. void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2)
  1071. {
  1072. // Row in reverse
  1073. for (int i = x2; i >= x1; i--)
  1074. SendLayerData(i, y2, map);
  1075. // Column in reverse
  1076. for (int j = y2 - 1; j >= y1; j--)
  1077. SendLayerData(x1, j, map);
  1078. if (x2 - x1 > 0 && y2 - y1 > 0)
  1079. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1080. }
  1081. /// <summary>
  1082. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1083. /// </summary>
  1084. /// <param name="map">heightmap</param>
  1085. /// <param name="px">X coordinate for patches 0..12</param>
  1086. /// <param name="py">Y coordinate for patches 0..15</param>
  1087. // private void SendLayerPacket(float[] map, int y, int x)
  1088. // {
  1089. // int[] patches = new int[4];
  1090. // patches[0] = x + 0 + y * 16;
  1091. // patches[1] = x + 1 + y * 16;
  1092. // patches[2] = x + 2 + y * 16;
  1093. // patches[3] = x + 3 + y * 16;
  1094. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1095. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1096. // }
  1097. // Legacy form of invocation that passes around a bare data array.
  1098. // Just ignore what was passed and use the real terrain info that is part of the scene.
  1099. public void SendLayerData(int px, int py, float[] map)
  1100. {
  1101. SendLayerData(px, py, m_scene.Heightmap.GetTerrainData());
  1102. }
  1103. /// <summary>
  1104. /// Sends a terrain packet for the point specified.
  1105. /// This is a legacy call that has refarbed the terrain into a flat map of floats.
  1106. /// We just use the terrain from the region we know about.
  1107. /// </summary>
  1108. /// <param name="px">Patch coordinate (x) 0..15</param>
  1109. /// <param name="py">Patch coordinate (y) 0..15</param>
  1110. /// <param name="map">heightmap</param>
  1111. public void SendLayerData(int px, int py, TerrainData terrData)
  1112. {
  1113. try
  1114. {
  1115. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, px, py);
  1116. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
  1117. // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
  1118. // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
  1119. // invalidating previous packets for that area.
  1120. // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
  1121. // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
  1122. // One last note on this topic, by the time users are going to be editing the terrain, it's extremely likely that the sim will
  1123. // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
  1124. // patches.
  1125. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
  1126. if (m_justEditedTerrain)
  1127. {
  1128. layerpack.Header.Reliable = false;
  1129. OutPacket(layerpack, ThrottleOutPacketType.Unknown );
  1130. }
  1131. else
  1132. {
  1133. layerpack.Header.Reliable = true;
  1134. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1135. }
  1136. }
  1137. catch (Exception e)
  1138. {
  1139. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1140. }
  1141. }
  1142. /// <summary>
  1143. /// Send the wind matrix to the client
  1144. /// </summary>
  1145. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1146. public virtual void SendWindData(Vector2[] windSpeeds)
  1147. {
  1148. Util.FireAndForget(DoSendWindData, windSpeeds);
  1149. }
  1150. /// <summary>
  1151. /// Send the cloud matrix to the client
  1152. /// </summary>
  1153. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1154. public virtual void SendCloudData(float[] cloudDensity)
  1155. {
  1156. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1157. }
  1158. /// <summary>
  1159. /// Send wind layer information to the client.
  1160. /// </summary>
  1161. /// <param name="o"></param>
  1162. private void DoSendWindData(object o)
  1163. {
  1164. Vector2[] windSpeeds = (Vector2[])o;
  1165. TerrainPatch[] patches = new TerrainPatch[2];
  1166. patches[0] = new TerrainPatch();
  1167. patches[0].Data = new float[16 * 16];
  1168. patches[1] = new TerrainPatch();
  1169. patches[1].Data = new float[16 * 16];
  1170. for (int y = 0; y < 16; y++)
  1171. {
  1172. for (int x = 0; x < 16; x++)
  1173. {
  1174. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1175. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1176. }
  1177. }
  1178. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1179. layerpack.Header.Zerocoded = true;
  1180. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1181. }
  1182. /// <summary>
  1183. /// Send cloud layer information to the client.
  1184. /// </summary>
  1185. /// <param name="o"></param>
  1186. private void DoSendCloudData(object o)
  1187. {
  1188. float[] cloudCover = (float[])o;
  1189. TerrainPatch[] patches = new TerrainPatch[1];
  1190. patches[0] = new TerrainPatch();
  1191. patches[0].Data = new float[16 * 16];
  1192. for (int y = 0; y < 16; y++)
  1193. {
  1194. for (int x = 0; x < 16; x++)
  1195. {
  1196. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1197. }
  1198. }
  1199. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1200. layerpack.Header.Zerocoded = true;
  1201. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1202. }
  1203. /// <summary>
  1204. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1205. /// </summary>
  1206. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1207. {
  1208. IPAddress neighbourIP = neighbourEndPoint.Address;
  1209. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1210. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1211. // TODO: don't create new blocks if recycling an old packet
  1212. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1213. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1214. byte[] byteIP = neighbourIP.GetAddressBytes();
  1215. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1216. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1217. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1218. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1219. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1220. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1221. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1222. }
  1223. public AgentCircuitData RequestClientInfo()
  1224. {
  1225. AgentCircuitData agentData = new AgentCircuitData();
  1226. agentData.AgentID = AgentId;
  1227. agentData.SessionID = m_sessionId;
  1228. agentData.SecureSessionID = SecureSessionId;
  1229. agentData.circuitcode = m_circuitCode;
  1230. agentData.child = false;
  1231. agentData.firstname = m_firstName;
  1232. agentData.lastname = m_lastName;
  1233. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1234. if (capsModule == null) // can happen when shutting down.
  1235. return agentData;
  1236. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1237. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1238. return agentData;
  1239. }
  1240. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1241. string capsURL)
  1242. {
  1243. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1244. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1245. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1246. // TODO: don't create new blocks if recycling an old packet
  1247. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1248. newSimPack.AgentData.AgentID = AgentId;
  1249. newSimPack.AgentData.SessionID = m_sessionId;
  1250. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1251. newSimPack.Info.Position = pos;
  1252. newSimPack.Info.LookAt = look;
  1253. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1254. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1255. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1256. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1257. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1258. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1259. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1260. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1261. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1262. // Hack to get this out immediately and skip throttles
  1263. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1264. }
  1265. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1266. {
  1267. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1268. // TODO: don't create new blocks if recycling an old packet
  1269. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1270. mapReply.AgentData.AgentID = AgentId;
  1271. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1272. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1273. mapReply.AgentData.Flags = flag;
  1274. for (int i = 0; i < mapBlocks2.Length; i++)
  1275. {
  1276. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1277. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1278. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1279. mapReply.Data[i].X = mapBlocks2[i].X;
  1280. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1281. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1282. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1283. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1284. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1285. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1286. // TODO: hookup varregion sim size here
  1287. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1288. mapReply.Size[i].SizeX = 256;
  1289. mapReply.Size[i].SizeY = 256;
  1290. }
  1291. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1292. }
  1293. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1294. {
  1295. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1296. int maxsend = 10;
  1297. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1298. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1299. for (int i = 0; i < mapBlocks2.Length; i++)
  1300. {
  1301. sendingBlocks.Add(mapBlocks2[i]);
  1302. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1303. {
  1304. SendMapBlockSplit(sendingBlocks, flag);
  1305. sendingBlocks = new List<MapBlockData>();
  1306. }
  1307. }
  1308. }
  1309. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1310. {
  1311. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1312. tpLocal.Info.AgentID = AgentId;
  1313. tpLocal.Info.TeleportFlags = flags;
  1314. tpLocal.Info.LocationID = 2;
  1315. tpLocal.Info.LookAt = lookAt;
  1316. tpLocal.Info.Position = position;
  1317. // Hack to get this out immediately and skip throttles
  1318. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1319. }
  1320. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1321. uint flags, string capsURL)
  1322. {
  1323. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1324. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1325. teleport.Info.AgentID = AgentId;
  1326. teleport.Info.RegionHandle = regionHandle;
  1327. teleport.Info.SimAccess = simAccess;
  1328. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1329. IPAddress oIP = newRegionEndPoint.Address;
  1330. byte[] byteIP = oIP.GetAddressBytes();
  1331. uint ip = (uint)byteIP[3] << 24;
  1332. ip += (uint)byteIP[2] << 16;
  1333. ip += (uint)byteIP[1] << 8;
  1334. ip += (uint)byteIP[0];
  1335. teleport.Info.SimIP = ip;
  1336. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1337. teleport.Info.LocationID = 4;
  1338. teleport.Info.TeleportFlags = 1 << 4;
  1339. // Hack to get this out immediately and skip throttles.
  1340. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1341. }
  1342. /// <summary>
  1343. /// Inform the client that a teleport attempt has failed
  1344. /// </summary>
  1345. public void SendTeleportFailed(string reason)
  1346. {
  1347. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1348. tpFailed.Info.AgentID = AgentId;
  1349. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1350. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1351. // Hack to get this out immediately and skip throttles
  1352. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1353. }
  1354. /// <summary>
  1355. ///
  1356. /// </summary>
  1357. public void SendTeleportStart(uint flags)
  1358. {
  1359. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1360. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1361. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1362. // Hack to get this out immediately and skip throttles
  1363. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1364. }
  1365. public void SendTeleportProgress(uint flags, string message)
  1366. {
  1367. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1368. tpProgress.AgentData.AgentID = this.AgentId;
  1369. tpProgress.Info.TeleportFlags = flags;
  1370. tpProgress.Info.Message = Util.StringToBytes256(message);
  1371. // Hack to get this out immediately and skip throttles
  1372. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1373. }
  1374. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
  1375. {
  1376. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1377. money.MoneyData.AgentID = AgentId;
  1378. money.MoneyData.TransactionID = transaction;
  1379. money.MoneyData.TransactionSuccess = success;
  1380. money.MoneyData.Description = description;
  1381. money.MoneyData.MoneyBalance = balance;
  1382. money.TransactionInfo.TransactionType = transactionType;
  1383. money.TransactionInfo.SourceID = sourceID;
  1384. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1385. money.TransactionInfo.DestID = destID;
  1386. money.TransactionInfo.IsDestGroup = destIsGroup;
  1387. money.TransactionInfo.Amount = amount;
  1388. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1389. OutPacket(money, ThrottleOutPacketType.Task);
  1390. }
  1391. public void SendPayPrice(UUID objectID, int[] payPrice)
  1392. {
  1393. if (payPrice[0] == 0 &&
  1394. payPrice[1] == 0 &&
  1395. payPrice[2] == 0 &&
  1396. payPrice[3] == 0 &&
  1397. payPrice[4] == 0)
  1398. return;
  1399. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1400. payPriceReply.ObjectData.ObjectID = objectID;
  1401. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1402. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1403. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1404. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1405. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1406. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1407. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1408. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1409. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1410. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1411. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1412. }
  1413. public void SendStartPingCheck(byte seq)
  1414. {
  1415. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1416. pc.Header.Reliable = false;
  1417. pc.PingID.PingID = seq;
  1418. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1419. pc.PingID.OldestUnacked = 0;
  1420. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1421. }
  1422. public void SendKillObject(List<uint> localIDs)
  1423. {
  1424. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1425. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1426. // TODO: don't create new blocks if recycling an old packet
  1427. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1428. for (int i = 0 ; i < localIDs.Count ; i++ )
  1429. {
  1430. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1431. kill.ObjectData[i].ID = localIDs[i];
  1432. }
  1433. kill.Header.Reliable = true;
  1434. kill.Header.Zerocoded = true;
  1435. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1436. {
  1437. OutPacket(kill, ThrottleOutPacketType.Task);
  1438. }
  1439. else
  1440. {
  1441. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1442. // condition where a kill can be processed before an out-of-date update for the same object.
  1443. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1444. lock (m_killRecord)
  1445. {
  1446. foreach (uint localID in localIDs)
  1447. m_killRecord.Add(localID);
  1448. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1449. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1450. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1451. // scene objects in a viewer until that viewer is relogged in.
  1452. OutPacket(kill, ThrottleOutPacketType.Task);
  1453. }
  1454. }
  1455. }
  1456. /// <summary>
  1457. /// Send information about the items contained in a folder to the client.
  1458. /// </summary>
  1459. /// <remarks>
  1460. /// XXX This method needs some refactoring loving
  1461. /// </remarks>
  1462. /// <param name="ownerID">The owner of the folder</param>
  1463. /// <param name="folderID">The id of the folder</param>
  1464. /// <param name="items">The items contained in the folder identified by folderID</param>
  1465. /// <param name="folders"></param>
  1466. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1467. /// <param name="fetchItems">Do we need to send item information?</param>
  1468. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1469. List<InventoryFolderBase> folders, int version,
  1470. bool fetchFolders, bool fetchItems)
  1471. {
  1472. // An inventory descendents packet consists of a single agent section and an inventory details
  1473. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1474. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1475. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1476. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1477. //
  1478. // http://opensimulator.org/mantis/view.php?id=226
  1479. //
  1480. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1481. // 6 to 7 items at a time, so let's stick with 6
  1482. int MAX_ITEMS_PER_PACKET = 5;
  1483. int MAX_FOLDERS_PER_PACKET = 6;
  1484. int totalItems = fetchItems ? items.Count : 0;
  1485. int totalFolders = fetchFolders ? folders.Count : 0;
  1486. int itemsSent = 0;
  1487. int foldersSent = 0;
  1488. int foldersToSend = 0;
  1489. int itemsToSend = 0;
  1490. InventoryDescendentsPacket currentPacket = null;
  1491. // Handle empty folders
  1492. //
  1493. if (totalItems == 0 && totalFolders == 0)
  1494. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1495. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1496. //
  1497. while (itemsSent < totalItems || foldersSent < totalFolders)
  1498. {
  1499. if (currentPacket == null) // Start a new packet
  1500. {
  1501. foldersToSend = totalFolders - foldersSent;
  1502. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1503. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1504. if (foldersToSend == 0)
  1505. {
  1506. itemsToSend = totalItems - itemsSent;
  1507. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1508. itemsToSend = MAX_ITEMS_PER_PACKET;
  1509. }
  1510. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1511. }
  1512. if (foldersToSend-- > 0)
  1513. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1514. else if (itemsToSend-- > 0)
  1515. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1516. else
  1517. {
  1518. // m_log.DebugFormat(
  1519. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1520. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1521. currentPacket = null;
  1522. }
  1523. }
  1524. if (currentPacket != null)
  1525. {
  1526. // m_log.DebugFormat(
  1527. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1528. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1529. }
  1530. }
  1531. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1532. {
  1533. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1534. newBlock.FolderID = folder.ID;
  1535. newBlock.Name = Util.StringToBytes256(folder.Name);
  1536. newBlock.ParentID = folder.ParentID;
  1537. newBlock.Type = (sbyte)folder.Type;
  1538. return newBlock;
  1539. }
  1540. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1541. {
  1542. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1543. newBlock.ItemID = item.ID;
  1544. newBlock.AssetID = item.AssetID;
  1545. newBlock.CreatorID = item.CreatorIdAsUuid;
  1546. newBlock.BaseMask = item.BasePermissions;
  1547. newBlock.Description = Util.StringToBytes256(item.Description);
  1548. newBlock.EveryoneMask = item.EveryOnePermissions;
  1549. newBlock.OwnerMask = item.CurrentPermissions;
  1550. newBlock.FolderID = item.Folder;
  1551. newBlock.InvType = (sbyte)item.InvType;
  1552. newBlock.Name = Util.StringToBytes256(item.Name);
  1553. newBlock.NextOwnerMask = item.NextPermissions;
  1554. newBlock.OwnerID = item.Owner;
  1555. newBlock.Type = (sbyte)item.AssetType;
  1556. newBlock.GroupID = item.GroupID;
  1557. newBlock.GroupOwned = item.GroupOwned;
  1558. newBlock.GroupMask = item.GroupPermissions;
  1559. newBlock.CreationDate = item.CreationDate;
  1560. newBlock.SalePrice = item.SalePrice;
  1561. newBlock.SaleType = item.SaleType;
  1562. newBlock.Flags = item.Flags;
  1563. newBlock.CRC =
  1564. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1565. newBlock.InvType, newBlock.Type,
  1566. newBlock.AssetID, newBlock.GroupID,
  1567. newBlock.SalePrice,
  1568. newBlock.OwnerID, newBlock.CreatorID,
  1569. newBlock.ItemID, newBlock.FolderID,
  1570. newBlock.EveryoneMask,
  1571. newBlock.Flags, newBlock.OwnerMask,
  1572. newBlock.GroupMask, newBlock.NextOwnerMask);
  1573. return newBlock;
  1574. }
  1575. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1576. {
  1577. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1578. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1579. packet.FolderData[0].FolderID = UUID.Zero;
  1580. packet.FolderData[0].ParentID = UUID.Zero;
  1581. packet.FolderData[0].Type = -1;
  1582. packet.FolderData[0].Name = new byte[0];
  1583. }
  1584. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1585. {
  1586. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1587. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1588. packet.ItemData[0].ItemID = UUID.Zero;
  1589. packet.ItemData[0].AssetID = UUID.Zero;
  1590. packet.ItemData[0].CreatorID = UUID.Zero;
  1591. packet.ItemData[0].BaseMask = 0;
  1592. packet.ItemData[0].Description = new byte[0];
  1593. packet.ItemData[0].EveryoneMask = 0;
  1594. packet.ItemData[0].OwnerMask = 0;
  1595. packet.ItemData[0].FolderID = UUID.Zero;
  1596. packet.ItemData[0].InvType = (sbyte)0;
  1597. packet.ItemData[0].Name = new byte[0];
  1598. packet.ItemData[0].NextOwnerMask = 0;
  1599. packet.ItemData[0].OwnerID = UUID.Zero;
  1600. packet.ItemData[0].Type = -1;
  1601. packet.ItemData[0].GroupID = UUID.Zero;
  1602. packet.ItemData[0].GroupOwned = false;
  1603. packet.ItemData[0].GroupMask = 0;
  1604. packet.ItemData[0].CreationDate = 0;
  1605. packet.ItemData[0].SalePrice = 0;
  1606. packet.ItemData[0].SaleType = 0;
  1607. packet.ItemData[0].Flags = 0;
  1608. // No need to add CRC
  1609. }
  1610. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1611. {
  1612. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1613. descend.Header.Zerocoded = true;
  1614. descend.AgentData.AgentID = AgentId;
  1615. descend.AgentData.OwnerID = ownerID;
  1616. descend.AgentData.FolderID = folderID;
  1617. descend.AgentData.Version = version;
  1618. descend.AgentData.Descendents = descendents;
  1619. if (folders > 0)
  1620. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1621. else
  1622. AddNullFolderBlockToDecendentsPacket(ref descend);
  1623. if (items > 0)
  1624. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1625. else
  1626. AddNullItemBlockToDescendentsPacket(ref descend);
  1627. return descend;
  1628. }
  1629. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1630. {
  1631. // Fudge this value. It's only needed to make the CRC anyway
  1632. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1633. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1634. // TODO: don't create new blocks if recycling an old packet
  1635. inventoryReply.AgentData.AgentID = AgentId;
  1636. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1637. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1638. inventoryReply.InventoryData[0].ItemID = item.ID;
  1639. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1640. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1641. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1642. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1643. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1644. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1645. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1646. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1647. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1648. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1649. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1650. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1651. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1652. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1653. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1654. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1655. inventoryReply.InventoryData[0].Flags = item.Flags;
  1656. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1657. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1658. inventoryReply.InventoryData[0].CRC =
  1659. Helpers.InventoryCRC(
  1660. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1661. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1662. inventoryReply.InventoryData[0].GroupID, 100,
  1663. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1664. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1665. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1666. FULL_MASK_PERMISSIONS);
  1667. inventoryReply.Header.Zerocoded = true;
  1668. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1669. }
  1670. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1671. {
  1672. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1673. UUID transactionId = UUID.Random();
  1674. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1675. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1676. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1677. if (folderDataBlocks.Count > 0)
  1678. {
  1679. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1680. // Send these now
  1681. BulkUpdateInventoryPacket bulkUpdate
  1682. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1683. bulkUpdate.Header.Zerocoded = true;
  1684. bulkUpdate.AgentData.AgentID = AgentId;
  1685. bulkUpdate.AgentData.TransactionID = transactionId;
  1686. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1687. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1688. bulkUpdate.ItemData = foo.ToArray();
  1689. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1690. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1691. }
  1692. }
  1693. /// <summary>
  1694. /// Recursively construct bulk update packets to send folders and items
  1695. /// </summary>
  1696. /// <param name="folder"></param>
  1697. /// <param name="folderDataBlocks"></param>
  1698. /// <param name="transactionId"></param>
  1699. private void SendBulkUpdateInventoryFolderRecursive(
  1700. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1701. UUID transactionId)
  1702. {
  1703. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1704. const int MAX_ITEMS_PER_PACKET = 5;
  1705. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1706. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1707. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1708. // being used on the Linden grid at 20081203).
  1709. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1710. List<InventoryItemBase> items = contents.Items;
  1711. while (items.Count > 0)
  1712. {
  1713. BulkUpdateInventoryPacket bulkUpdate
  1714. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1715. bulkUpdate.Header.Zerocoded = true;
  1716. bulkUpdate.AgentData.AgentID = AgentId;
  1717. bulkUpdate.AgentData.TransactionID = transactionId;
  1718. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1719. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1720. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1721. for (int i = 0; i < itemsToSend; i++)
  1722. {
  1723. // Remove from the end of the list so that we don't incur a performance penalty
  1724. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1725. items.RemoveAt(items.Count - 1);
  1726. }
  1727. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1728. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1729. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1730. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1731. // items belong.
  1732. if (items.Count > 0)
  1733. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1734. }
  1735. List<InventoryFolderBase> subFolders = contents.Folders;
  1736. foreach (InventoryFolderBase subFolder in subFolders)
  1737. {
  1738. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1739. }
  1740. }
  1741. /// <summary>
  1742. /// Generate a bulk update inventory data block for the given folder
  1743. /// </summary>
  1744. /// <param name="folder"></param>
  1745. /// <returns></returns>
  1746. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1747. {
  1748. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1749. folderBlock.FolderID = folder.ID;
  1750. folderBlock.ParentID = folder.ParentID;
  1751. //folderBlock.Type = -1;
  1752. folderBlock.Type = (sbyte)folder.Type;
  1753. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1754. return folderBlock;
  1755. }
  1756. /// <summary>
  1757. /// Generate a bulk update inventory data block for the given item
  1758. /// </summary>
  1759. /// <param name="item"></param>
  1760. /// <returns></returns>
  1761. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1762. {
  1763. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1764. itemBlock.ItemID = item.ID;
  1765. itemBlock.AssetID = item.AssetID;
  1766. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1767. itemBlock.BaseMask = item.BasePermissions;
  1768. itemBlock.Description = Util.StringToBytes256(item.Description);
  1769. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1770. itemBlock.FolderID = item.Folder;
  1771. itemBlock.InvType = (sbyte)item.InvType;
  1772. itemBlock.Name = Util.StringToBytes256(item.Name);
  1773. itemBlock.NextOwnerMask = item.NextPermissions;
  1774. itemBlock.OwnerID = item.Owner;
  1775. itemBlock.OwnerMask = item.CurrentPermissions;
  1776. itemBlock.Type = (sbyte)item.AssetType;
  1777. itemBlock.GroupID = item.GroupID;
  1778. itemBlock.GroupOwned = item.GroupOwned;
  1779. itemBlock.GroupMask = item.GroupPermissions;
  1780. itemBlock.Flags = item.Flags;
  1781. itemBlock.SalePrice = item.SalePrice;
  1782. itemBlock.SaleType = item.SaleType;
  1783. itemBlock.CreationDate = item.CreationDate;
  1784. itemBlock.CRC =
  1785. Helpers.InventoryCRC(
  1786. 1000, 0, itemBlock.InvType,
  1787. itemBlock.Type, itemBlock.AssetID,
  1788. itemBlock.GroupID, 100,
  1789. itemBlock.OwnerID, itemBlock.CreatorID,
  1790. itemBlock.ItemID, itemBlock.FolderID,
  1791. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1792. (uint)PermissionMask.All);
  1793. return itemBlock;
  1794. }
  1795. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1796. {
  1797. if (node is InventoryItemBase)
  1798. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1799. else if (node is InventoryFolderBase)
  1800. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1801. else if (node != null)
  1802. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1803. else
  1804. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1805. }
  1806. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1807. {
  1808. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1809. BulkUpdateInventoryPacket bulkUpdate
  1810. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1811. bulkUpdate.AgentData.AgentID = AgentId;
  1812. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1813. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1814. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1815. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1816. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1817. bulkUpdate.FolderData[0].Type = -1;
  1818. bulkUpdate.FolderData[0].Name = new byte[0];
  1819. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1820. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1821. bulkUpdate.ItemData[0].ItemID = item.ID;
  1822. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1823. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1824. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1825. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1826. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1827. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1828. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1829. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1830. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1831. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1832. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1833. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1834. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1835. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1836. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1837. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1838. bulkUpdate.ItemData[0].Flags = item.Flags;
  1839. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1840. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1841. bulkUpdate.ItemData[0].CRC =
  1842. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1843. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1844. bulkUpdate.ItemData[0].GroupID, 100,
  1845. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1846. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1847. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1848. FULL_MASK_PERMISSIONS);
  1849. bulkUpdate.Header.Zerocoded = true;
  1850. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1851. }
  1852. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1853. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1854. {
  1855. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1856. UpdateCreateInventoryItemPacket InventoryReply
  1857. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1858. PacketType.UpdateCreateInventoryItem);
  1859. // TODO: don't create new blocks if recycling an old packet
  1860. InventoryReply.AgentData.AgentID = AgentId;
  1861. InventoryReply.AgentData.SimApproved = true;
  1862. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1863. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1864. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1865. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1866. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1867. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1868. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1869. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1870. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1871. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1872. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1873. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1874. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1875. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1876. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1877. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1878. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1879. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1880. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1881. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1882. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1883. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1884. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1885. InventoryReply.InventoryData[0].CRC =
  1886. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1887. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1888. InventoryReply.InventoryData[0].GroupID, 100,
  1889. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1890. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1891. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1892. FULL_MASK_PERMISSIONS);
  1893. InventoryReply.Header.Zerocoded = true;
  1894. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1895. }
  1896. public void SendRemoveInventoryItem(UUID itemID)
  1897. {
  1898. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1899. // TODO: don't create new blocks if recycling an old packet
  1900. remove.AgentData.AgentID = AgentId;
  1901. remove.AgentData.SessionID = m_sessionId;
  1902. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1903. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1904. remove.InventoryData[0].ItemID = itemID;
  1905. remove.Header.Zerocoded = true;
  1906. OutPacket(remove, ThrottleOutPacketType.Asset);
  1907. }
  1908. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1909. {
  1910. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1911. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1912. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1913. ddata.Controls = (uint)controls;
  1914. ddata.PassToAgent = passToAgent;
  1915. ddata.TakeControls = TakeControls;
  1916. data[0] = ddata;
  1917. scriptcontrol.Data = data;
  1918. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1919. }
  1920. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1921. {
  1922. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1923. replytask.InventoryData.TaskID = taskID;
  1924. replytask.InventoryData.Serial = serial;
  1925. replytask.InventoryData.Filename = fileName;
  1926. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1927. }
  1928. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1929. {
  1930. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1931. sendXfer.XferID.ID = xferID;
  1932. sendXfer.XferID.Packet = packet;
  1933. sendXfer.DataPacket.Data = data;
  1934. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1935. }
  1936. public void SendAbortXferPacket(ulong xferID)
  1937. {
  1938. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1939. xferItem.XferID.ID = xferID;
  1940. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1941. }
  1942. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1943. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1944. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1945. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1946. {
  1947. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1948. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1949. economyData.Info.ObjectCapacity = ObjectCapacity;
  1950. economyData.Info.ObjectCount = ObjectCount;
  1951. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1952. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1953. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1954. economyData.Info.PriceObjectRent = PriceObjectRent;
  1955. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1956. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1957. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1958. economyData.Info.PriceParcelRent = PriceParcelRent;
  1959. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1960. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1961. economyData.Info.PriceRentLight = PriceRentLight;
  1962. economyData.Info.PriceUpload = PriceUpload;
  1963. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1964. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1965. economyData.Header.Reliable = true;
  1966. OutPacket(economyData, ThrottleOutPacketType.Task);
  1967. }
  1968. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1969. {
  1970. //construct the AvatarPickerReply packet.
  1971. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1972. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1973. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1974. //int i = 0;
  1975. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1976. foreach (AvatarPickerReplyDataArgs arg in Data)
  1977. {
  1978. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1979. db.AvatarID = arg.AvatarID;
  1980. db.FirstName = arg.FirstName;
  1981. db.LastName = arg.LastName;
  1982. data_block.Add(db);
  1983. }
  1984. replyPacket.Data = data_block.ToArray();
  1985. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  1986. }
  1987. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  1988. {
  1989. m_activeGroupID = activegroupid;
  1990. m_activeGroupName = groupname;
  1991. m_activeGroupPowers = grouppowers;
  1992. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  1993. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  1994. sendAgentDataUpdate.AgentData.AgentID = agentid;
  1995. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  1996. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  1997. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  1998. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  1999. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2000. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2001. }
  2002. /// <summary>
  2003. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2004. /// blue information box in the bottom right hand corner.
  2005. /// </summary>
  2006. /// <param name="message"></param>
  2007. public void SendAlertMessage(string message)
  2008. {
  2009. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2010. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2011. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2012. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2013. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2014. }
  2015. /// <summary>
  2016. /// Send an agent alert message to the client.
  2017. /// </summary>
  2018. /// <param name="message"></param>
  2019. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2020. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2021. /// the AlertMessage packet).</param>
  2022. public void SendAgentAlertMessage(string message, bool modal)
  2023. {
  2024. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2025. }
  2026. /// <summary>
  2027. /// Construct an agent alert packet
  2028. /// </summary>
  2029. /// <param name="message"></param>
  2030. /// <param name="modal"></param>
  2031. /// <returns></returns>
  2032. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2033. {
  2034. // Prepend a slash to make the message come up in the top right
  2035. // again.
  2036. // Allow special formats to be sent from aware modules.
  2037. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2038. message = "/" + message;
  2039. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2040. alertPack.AgentData.AgentID = AgentId;
  2041. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2042. alertPack.AlertData.Modal = modal;
  2043. return alertPack;
  2044. }
  2045. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2046. string url)
  2047. {
  2048. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2049. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2050. loadURL.Data.ObjectID = objectID;
  2051. loadURL.Data.OwnerID = ownerID;
  2052. loadURL.Data.OwnerIsGroup = groupOwned;
  2053. loadURL.Data.Message = Util.StringToBytes256(message);
  2054. loadURL.Data.URL = Util.StringToBytes256(url);
  2055. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2056. }
  2057. public void SendDialog(
  2058. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2059. UUID textureID, int ch, string[] buttonlabels)
  2060. {
  2061. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2062. dialog.Data.ObjectID = objectID;
  2063. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2064. // this is the username of the *owner*
  2065. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2066. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2067. dialog.Data.Message = Util.StringToBytes1024(msg);
  2068. dialog.Data.ImageID = textureID;
  2069. dialog.Data.ChatChannel = ch;
  2070. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2071. for (int i = 0; i < buttonlabels.Length; i++)
  2072. {
  2073. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2074. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2075. }
  2076. dialog.Buttons = buttons;
  2077. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2078. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2079. dialog.OwnerData[0].OwnerID = ownerID;
  2080. OutPacket(dialog, ThrottleOutPacketType.Task);
  2081. }
  2082. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2083. {
  2084. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2085. // TODO: don't create new blocks if recycling an old packet
  2086. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2087. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2088. preSound.DataBlock[0].ObjectID = objectID;
  2089. preSound.DataBlock[0].OwnerID = ownerID;
  2090. preSound.DataBlock[0].SoundID = soundID;
  2091. preSound.Header.Zerocoded = true;
  2092. OutPacket(preSound, ThrottleOutPacketType.Task);
  2093. }
  2094. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2095. {
  2096. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2097. sound.DataBlock.SoundID = soundID;
  2098. sound.DataBlock.ObjectID = objectID;
  2099. sound.DataBlock.OwnerID = ownerID;
  2100. sound.DataBlock.Gain = gain;
  2101. sound.DataBlock.Flags = flags;
  2102. OutPacket(sound, ThrottleOutPacketType.Task);
  2103. }
  2104. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2105. {
  2106. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2107. sound.SoundData.SoundID = soundID;
  2108. sound.SoundData.OwnerID = ownerID;
  2109. sound.SoundData.ObjectID = objectID;
  2110. sound.SoundData.ParentID = parentID;
  2111. sound.SoundData.Handle = handle;
  2112. sound.SoundData.Position = position;
  2113. sound.SoundData.Gain = gain;
  2114. OutPacket(sound, ThrottleOutPacketType.Task);
  2115. }
  2116. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2117. {
  2118. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2119. sound.DataBlock.ObjectID = objectID;
  2120. sound.DataBlock.Gain = gain;
  2121. OutPacket(sound, ThrottleOutPacketType.Task);
  2122. }
  2123. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2124. {
  2125. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2126. // So adjust for that
  2127. // Contributed by: Godfrey
  2128. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2129. {
  2130. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2131. }
  2132. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2133. viewertime.TimeInfo.SunDirection = Position;
  2134. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2135. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2136. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2137. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2138. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2139. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2140. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2141. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2142. viewertime.Header.Reliable = false;
  2143. viewertime.Header.Zerocoded = true;
  2144. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2145. }
  2146. // Currently Deprecated
  2147. public void SendViewerTime(int phase)
  2148. {
  2149. /*
  2150. Console.WriteLine("SunPhase: {0}", phase);
  2151. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2152. //viewertime.TimeInfo.SecPerDay = 86400;
  2153. //viewertime.TimeInfo.SecPerYear = 31536000;
  2154. viewertime.TimeInfo.SecPerDay = 1000;
  2155. viewertime.TimeInfo.SecPerYear = 365000;
  2156. viewertime.TimeInfo.SunPhase = 1;
  2157. int sunPhase = (phase + 2) / 2;
  2158. if ((sunPhase < 6) || (sunPhase > 36))
  2159. {
  2160. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2161. Console.WriteLine("sending night");
  2162. }
  2163. else
  2164. {
  2165. if (sunPhase < 12)
  2166. {
  2167. sunPhase = 12;
  2168. }
  2169. sunPhase = sunPhase - 12;
  2170. float yValue = 0.1f * (sunPhase);
  2171. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2172. if (yValue > 1.2f)
  2173. {
  2174. yValue = yValue - 1.2f;
  2175. }
  2176. yValue = Util.Clip(yValue, 0, 1);
  2177. if (sunPhase < 14)
  2178. {
  2179. yValue = 1 - yValue;
  2180. }
  2181. if (sunPhase < 12)
  2182. {
  2183. yValue *= -1;
  2184. }
  2185. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2186. Console.WriteLine("sending sun update " + yValue);
  2187. }
  2188. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2189. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2190. viewertime.Header.Reliable = false;
  2191. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2192. */
  2193. }
  2194. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2195. {
  2196. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2197. packet.Header.Reliable = false;
  2198. packet.Header.Zerocoded = true;
  2199. packet.AgentData.AgentID = AgentId;
  2200. packet.AgentData.SessionID = SessionId;
  2201. packet.Effect = effectBlocks;
  2202. // OutPacket(packet, ThrottleOutPacketType.State);
  2203. OutPacket(packet, ThrottleOutPacketType.Task);
  2204. }
  2205. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2206. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2207. UUID partnerID)
  2208. {
  2209. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2210. avatarReply.AgentData.AgentID = AgentId;
  2211. avatarReply.AgentData.AvatarID = avatarID;
  2212. if (aboutText != null)
  2213. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2214. else
  2215. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2216. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2217. avatarReply.PropertiesData.CharterMember = charterMember;
  2218. if (flAbout != null)
  2219. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2220. else
  2221. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2222. avatarReply.PropertiesData.Flags = flags;
  2223. avatarReply.PropertiesData.FLImageID = flImageID;
  2224. avatarReply.PropertiesData.ImageID = imageID;
  2225. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2226. avatarReply.PropertiesData.PartnerID = partnerID;
  2227. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2228. }
  2229. /// <summary>
  2230. /// Send the client an Estate message blue box pop-down with a single OK button
  2231. /// </summary>
  2232. /// <param name="FromAvatarID"></param>
  2233. /// <param name="fromSessionID"></param>
  2234. /// <param name="FromAvatarName"></param>
  2235. /// <param name="Message"></param>
  2236. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2237. {
  2238. if (!SceneAgent.IsChildAgent)
  2239. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2240. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2241. }
  2242. public void SendLogoutPacket()
  2243. {
  2244. // I know this is a bit of a hack, however there are times when you don't
  2245. // want to send this, but still need to do the rest of the shutdown process
  2246. // this method gets called from the packet server.. which makes it practically
  2247. // impossible to do any other way.
  2248. if (m_SendLogoutPacketWhenClosing)
  2249. {
  2250. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2251. // TODO: don't create new blocks if recycling an old packet
  2252. logReply.AgentData.AgentID = AgentId;
  2253. logReply.AgentData.SessionID = SessionId;
  2254. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2255. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2256. logReply.InventoryData[0].ItemID = UUID.Zero;
  2257. OutPacket(logReply, ThrottleOutPacketType.Task);
  2258. }
  2259. }
  2260. public void SendHealth(float health)
  2261. {
  2262. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2263. healthpacket.HealthData.Health = health;
  2264. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2265. }
  2266. public void SendAgentOnline(UUID[] agentIDs)
  2267. {
  2268. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2269. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2270. for (int i = 0; i < agentIDs.Length; i++)
  2271. {
  2272. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2273. onpbl.AgentID = agentIDs[i];
  2274. onpb[i] = onpbl;
  2275. }
  2276. onp.AgentBlock = onpb;
  2277. onp.Header.Reliable = true;
  2278. OutPacket(onp, ThrottleOutPacketType.Task);
  2279. }
  2280. public void SendAgentOffline(UUID[] agentIDs)
  2281. {
  2282. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2283. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2284. for (int i = 0; i < agentIDs.Length; i++)
  2285. {
  2286. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2287. onpbl.AgentID = agentIDs[i];
  2288. offpb[i] = onpbl;
  2289. }
  2290. offp.AgentBlock = offpb;
  2291. offp.Header.Reliable = true;
  2292. OutPacket(offp, ThrottleOutPacketType.Task);
  2293. }
  2294. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2295. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2296. {
  2297. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2298. avatarSitResponse.SitObject.ID = TargetID;
  2299. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2300. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2301. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2302. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2303. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2304. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2305. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2306. }
  2307. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2308. {
  2309. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2310. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2311. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2312. adb.AgentID = AgentId;
  2313. adb.SessionID = SessionId; // More security
  2314. gdb.GodLevel = (byte)AdminLevel;
  2315. gdb.Token = Token;
  2316. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2317. respondPacket.GrantData = gdb;
  2318. respondPacket.AgentData = adb;
  2319. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2320. }
  2321. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2322. {
  2323. m_groupPowers.Clear();
  2324. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2325. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2326. for (int i = 0; i < GroupMembership.Length; i++)
  2327. {
  2328. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2329. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2330. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2331. Group.Contribution = GroupMembership[i].Contribution;
  2332. Group.GroupID = GroupMembership[i].GroupID;
  2333. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2334. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2335. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2336. Groups[i] = Group;
  2337. }
  2338. Groupupdate.GroupData = Groups;
  2339. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2340. Groupupdate.AgentData.AgentID = AgentId;
  2341. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2342. try
  2343. {
  2344. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2345. if (eq != null)
  2346. {
  2347. eq.GroupMembership(Groupupdate, this.AgentId);
  2348. }
  2349. }
  2350. catch (Exception ex)
  2351. {
  2352. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2353. m_log.Warn("sending group membership data via UDP");
  2354. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2355. }
  2356. }
  2357. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2358. {
  2359. SceneObjectPart part = (SceneObjectPart)entity;
  2360. if (part != null && AgentId != UUID.Zero)
  2361. {
  2362. try
  2363. {
  2364. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2365. if (eq != null)
  2366. {
  2367. uint localid = part.LocalId;
  2368. byte physshapetype = part.PhysicsShapeType;
  2369. float density = part.Density;
  2370. float friction = part.Friction;
  2371. float bounce = part.Restitution;
  2372. float gravmod = part.GravityModifier;
  2373. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2374. }
  2375. }
  2376. catch (Exception ex)
  2377. {
  2378. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2379. }
  2380. part.UpdatePhysRequired = false;
  2381. }
  2382. }
  2383. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2384. {
  2385. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2386. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2387. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2388. uidnamebloc.ID = groupLLUID;
  2389. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2390. uidnameblock[0] = uidnamebloc;
  2391. pack.UUIDNameBlock = uidnameblock;
  2392. OutPacket(pack, ThrottleOutPacketType.Task);
  2393. }
  2394. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2395. {
  2396. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2397. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2398. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2399. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2400. // lsrepdb.
  2401. lsrp.RequestData.ReportType = reportType;
  2402. lsrp.RequestData.RequestFlags = requestFlags;
  2403. lsrp.RequestData.TotalObjectCount = resultCount;
  2404. for (int i = 0; i < lsrpia.Length; i++)
  2405. {
  2406. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2407. lsrepdb.LocationX = lsrpia[i].LocationX;
  2408. lsrepdb.LocationY = lsrpia[i].LocationY;
  2409. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2410. lsrepdb.Score = lsrpia[i].Score;
  2411. lsrepdb.TaskID = lsrpia[i].TaskID;
  2412. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2413. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2414. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2415. lsrepdba[i] = lsrepdb;
  2416. }
  2417. lsrp.ReportData = lsrepdba;
  2418. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2419. }
  2420. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2421. {
  2422. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2423. scriptRunningReply.Script.ObjectID = objectID;
  2424. scriptRunningReply.Script.ItemID = itemID;
  2425. scriptRunningReply.Script.Running = running;
  2426. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2427. }
  2428. public void SendAsset(AssetRequestToClient req)
  2429. {
  2430. if (req.AssetInf.Data == null)
  2431. {
  2432. m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
  2433. LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2434. return;
  2435. }
  2436. //m_log.Debug("sending asset " + req.RequestAssetID);
  2437. TransferInfoPacket Transfer = new TransferInfoPacket();
  2438. Transfer.TransferInfo.ChannelType = 2;
  2439. Transfer.TransferInfo.Status = 0;
  2440. Transfer.TransferInfo.TargetType = 0;
  2441. if (req.AssetRequestSource == 2)
  2442. {
  2443. Transfer.TransferInfo.Params = new byte[20];
  2444. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2445. int assType = req.AssetInf.Type;
  2446. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2447. }
  2448. else if (req.AssetRequestSource == 3)
  2449. {
  2450. Transfer.TransferInfo.Params = req.Params;
  2451. // Transfer.TransferInfo.Params = new byte[100];
  2452. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2453. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2454. }
  2455. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2456. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2457. Transfer.Header.Zerocoded = true;
  2458. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2459. if (req.NumPackets == 1)
  2460. {
  2461. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2462. TransferPacket.TransferData.Packet = 0;
  2463. TransferPacket.TransferData.ChannelType = 2;
  2464. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2465. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2466. TransferPacket.TransferData.Status = 1;
  2467. TransferPacket.Header.Zerocoded = true;
  2468. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2469. }
  2470. else
  2471. {
  2472. int processedLength = 0;
  2473. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2474. int packetNumber = 0;
  2475. while (processedLength < req.AssetInf.Data.Length)
  2476. {
  2477. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2478. TransferPacket.TransferData.Packet = packetNumber;
  2479. TransferPacket.TransferData.ChannelType = 2;
  2480. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2481. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2482. byte[] chunk = new byte[chunkSize];
  2483. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2484. TransferPacket.TransferData.Data = chunk;
  2485. // 0 indicates more packets to come, 1 indicates last packet
  2486. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2487. {
  2488. TransferPacket.TransferData.Status = 0;
  2489. }
  2490. else
  2491. {
  2492. TransferPacket.TransferData.Status = 1;
  2493. }
  2494. TransferPacket.Header.Zerocoded = true;
  2495. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2496. processedLength += chunkSize;
  2497. packetNumber++;
  2498. }
  2499. }
  2500. }
  2501. public void SendAssetNotFound(AssetRequestToClient req)
  2502. {
  2503. TransferInfoPacket Transfer = new TransferInfoPacket();
  2504. Transfer.TransferInfo.ChannelType = 2;
  2505. Transfer.TransferInfo.Status = -2;
  2506. Transfer.TransferInfo.TargetType = 0;
  2507. Transfer.TransferInfo.Params = req.Params;
  2508. Transfer.TransferInfo.Size = 0;
  2509. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2510. Transfer.Header.Zerocoded = true;
  2511. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2512. }
  2513. public void SendTexture(AssetBase TextureAsset)
  2514. {
  2515. }
  2516. public void SendRegionHandle(UUID regionID, ulong handle)
  2517. {
  2518. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2519. reply.ReplyBlock.RegionID = regionID;
  2520. reply.ReplyBlock.RegionHandle = handle;
  2521. OutPacket(reply, ThrottleOutPacketType.Land);
  2522. }
  2523. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2524. {
  2525. float dwell = 0.0f;
  2526. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2527. if (dwellModule != null)
  2528. dwell = dwellModule.GetDwell(land.GlobalID);
  2529. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2530. reply.AgentData.AgentID = m_agentId;
  2531. reply.Data.ParcelID = parcelID;
  2532. reply.Data.OwnerID = land.OwnerID;
  2533. reply.Data.Name = Utils.StringToBytes(land.Name);
  2534. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2535. reply.Data.ActualArea = land.Area;
  2536. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2537. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2538. reply.Data.Flags = (byte)(
  2539. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2540. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2541. Vector3 pos = land.UserLocation;
  2542. if (pos.Equals(Vector3.Zero))
  2543. {
  2544. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2545. }
  2546. reply.Data.GlobalX = info.RegionLocX + x;
  2547. reply.Data.GlobalY = info.RegionLocY + y;
  2548. reply.Data.GlobalZ = pos.Z;
  2549. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2550. reply.Data.SnapshotID = land.SnapshotID;
  2551. reply.Data.Dwell = dwell;
  2552. reply.Data.SalePrice = land.SalePrice;
  2553. reply.Data.AuctionID = (int)land.AuctionID;
  2554. OutPacket(reply, ThrottleOutPacketType.Land);
  2555. }
  2556. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2557. {
  2558. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2559. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2560. packet.Data.SimName = Utils.StringToBytes(simName);
  2561. packet.Data.SimPosition = pos;
  2562. packet.Data.LookAt = lookAt;
  2563. OutPacket(packet, ThrottleOutPacketType.Task);
  2564. }
  2565. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2566. {
  2567. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2568. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2569. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2570. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2571. packet.AgentData.AgentID = AgentId;
  2572. packet.QueryData[0].QueryID = queryID;
  2573. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2574. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2575. DirPlacesReplyPacket.StatusDataBlock[] status =
  2576. new DirPlacesReplyPacket.StatusDataBlock[0];
  2577. packet.QueryReplies = replies;
  2578. packet.StatusData = status;
  2579. foreach (DirPlacesReplyData d in data)
  2580. {
  2581. int idx = replies.Length;
  2582. Array.Resize(ref replies, idx + 1);
  2583. Array.Resize(ref status, idx + 1);
  2584. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2585. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2586. replies[idx].ParcelID = d.parcelID;
  2587. replies[idx].Name = Utils.StringToBytes(d.name);
  2588. replies[idx].ForSale = d.forSale;
  2589. replies[idx].Auction = d.auction;
  2590. replies[idx].Dwell = d.dwell;
  2591. status[idx].Status = d.Status;
  2592. packet.QueryReplies = replies;
  2593. packet.StatusData = status;
  2594. if (packet.Length >= 1000)
  2595. {
  2596. OutPacket(packet, ThrottleOutPacketType.Task);
  2597. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2598. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2599. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2600. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2601. packet.AgentData.AgentID = AgentId;
  2602. packet.QueryData[0].QueryID = queryID;
  2603. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2604. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2605. }
  2606. }
  2607. if (replies.Length > 0 || data.Length == 0)
  2608. OutPacket(packet, ThrottleOutPacketType.Task);
  2609. }
  2610. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2611. {
  2612. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2613. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2614. packet.AgentData.AgentID = AgentId;
  2615. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2616. packet.QueryData.QueryID = queryID;
  2617. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2618. data.Length];
  2619. int i = 0;
  2620. foreach (DirPeopleReplyData d in data)
  2621. {
  2622. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2623. packet.QueryReplies[i].AgentID = d.agentID;
  2624. packet.QueryReplies[i].FirstName =
  2625. Utils.StringToBytes(d.firstName);
  2626. packet.QueryReplies[i].LastName =
  2627. Utils.StringToBytes(d.lastName);
  2628. packet.QueryReplies[i].Group =
  2629. Utils.StringToBytes(d.group);
  2630. packet.QueryReplies[i].Online = d.online;
  2631. packet.QueryReplies[i].Reputation = d.reputation;
  2632. i++;
  2633. }
  2634. OutPacket(packet, ThrottleOutPacketType.Task);
  2635. }
  2636. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2637. {
  2638. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2639. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2640. packet.AgentData.AgentID = AgentId;
  2641. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2642. packet.QueryData.QueryID = queryID;
  2643. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2644. data.Length];
  2645. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2646. data.Length];
  2647. int i = 0;
  2648. foreach (DirEventsReplyData d in data)
  2649. {
  2650. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2651. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2652. packet.QueryReplies[i].OwnerID = d.ownerID;
  2653. packet.QueryReplies[i].Name =
  2654. Utils.StringToBytes(d.name);
  2655. packet.QueryReplies[i].EventID = d.eventID;
  2656. packet.QueryReplies[i].Date =
  2657. Utils.StringToBytes(d.date);
  2658. packet.QueryReplies[i].UnixTime = d.unixTime;
  2659. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2660. packet.StatusData[i].Status = d.Status;
  2661. i++;
  2662. }
  2663. OutPacket(packet, ThrottleOutPacketType.Task);
  2664. }
  2665. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2666. {
  2667. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2668. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2669. packet.AgentData.AgentID = AgentId;
  2670. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2671. packet.QueryData.QueryID = queryID;
  2672. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2673. data.Length];
  2674. int i = 0;
  2675. foreach (DirGroupsReplyData d in data)
  2676. {
  2677. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2678. packet.QueryReplies[i].GroupID = d.groupID;
  2679. packet.QueryReplies[i].GroupName =
  2680. Utils.StringToBytes(d.groupName);
  2681. packet.QueryReplies[i].Members = d.members;
  2682. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2683. i++;
  2684. }
  2685. OutPacket(packet, ThrottleOutPacketType.Task);
  2686. }
  2687. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2688. {
  2689. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2690. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2691. packet.AgentData.AgentID = AgentId;
  2692. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2693. packet.QueryData.QueryID = queryID;
  2694. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2695. data.Length];
  2696. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2697. data.Length];
  2698. int i = 0;
  2699. foreach (DirClassifiedReplyData d in data)
  2700. {
  2701. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2702. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2703. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2704. packet.QueryReplies[i].Name =
  2705. Utils.StringToBytes(d.name);
  2706. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2707. packet.QueryReplies[i].CreationDate = d.creationDate;
  2708. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2709. packet.QueryReplies[i].PriceForListing = d.price;
  2710. packet.StatusData[i].Status = d.Status;
  2711. i++;
  2712. }
  2713. OutPacket(packet, ThrottleOutPacketType.Task);
  2714. }
  2715. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2716. {
  2717. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2718. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2719. packet.AgentData.AgentID = AgentId;
  2720. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2721. packet.QueryData.QueryID = queryID;
  2722. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2723. data.Length];
  2724. int i = 0;
  2725. foreach (DirLandReplyData d in data)
  2726. {
  2727. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2728. packet.QueryReplies[i].ParcelID = d.parcelID;
  2729. packet.QueryReplies[i].Name =
  2730. Utils.StringToBytes(d.name);
  2731. packet.QueryReplies[i].Auction = d.auction;
  2732. packet.QueryReplies[i].ForSale = d.forSale;
  2733. packet.QueryReplies[i].SalePrice = d.salePrice;
  2734. packet.QueryReplies[i].ActualArea = d.actualArea;
  2735. i++;
  2736. }
  2737. OutPacket(packet, ThrottleOutPacketType.Task);
  2738. }
  2739. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2740. {
  2741. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2742. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2743. packet.AgentData.AgentID = AgentId;
  2744. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2745. packet.QueryData.QueryID = queryID;
  2746. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2747. data.Length];
  2748. int i = 0;
  2749. foreach (DirPopularReplyData d in data)
  2750. {
  2751. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2752. packet.QueryReplies[i].ParcelID = d.parcelID;
  2753. packet.QueryReplies[i].Name =
  2754. Utils.StringToBytes(d.name);
  2755. packet.QueryReplies[i].Dwell = d.dwell;
  2756. i++;
  2757. }
  2758. OutPacket(packet, ThrottleOutPacketType.Task);
  2759. }
  2760. public void SendEventInfoReply(EventData data)
  2761. {
  2762. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2763. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2764. packet.AgentData.AgentID = AgentId;
  2765. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2766. packet.EventData.EventID = data.eventID;
  2767. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2768. packet.EventData.Name = Utils.StringToBytes(data.name);
  2769. packet.EventData.Category = Utils.StringToBytes(data.category);
  2770. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2771. packet.EventData.Date = Utils.StringToBytes(data.date);
  2772. packet.EventData.DateUTC = data.dateUTC;
  2773. packet.EventData.Duration = data.duration;
  2774. packet.EventData.Cover = data.cover;
  2775. packet.EventData.Amount = data.amount;
  2776. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2777. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2778. packet.EventData.EventFlags = data.eventFlags;
  2779. OutPacket(packet, ThrottleOutPacketType.Task);
  2780. }
  2781. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2782. {
  2783. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2784. mirplk.AgentData.AgentID = AgentId;
  2785. mirplk.RequestData.ItemType = mapitemtype;
  2786. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2787. for (int i = 0; i < replies.Length; i++)
  2788. {
  2789. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2790. mrdata.X = replies[i].x;
  2791. mrdata.Y = replies[i].y;
  2792. mrdata.ID = replies[i].id;
  2793. mrdata.Extra = replies[i].Extra;
  2794. mrdata.Extra2 = replies[i].Extra2;
  2795. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2796. mirplk.Data[i] = mrdata;
  2797. }
  2798. //m_log.Debug(mirplk.ToString());
  2799. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2800. }
  2801. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2802. {
  2803. // a bit special, as this uses AgentID to store the source instead
  2804. // of the destination. The destination (the receiver) goes into destID
  2805. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2806. p.AgentData.AgentID = srcID;
  2807. p.AgentData.SessionID = UUID.Zero;
  2808. p.AgentBlock.DestID = AgentId;
  2809. p.AgentBlock.TransactionID = transactionID;
  2810. OutPacket(p, ThrottleOutPacketType.Task);
  2811. }
  2812. public void SendAcceptCallingCard(UUID transactionID)
  2813. {
  2814. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2815. p.AgentData.AgentID = AgentId;
  2816. p.AgentData.SessionID = UUID.Zero;
  2817. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2818. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2819. p.FolderData[0].FolderID = UUID.Zero;
  2820. OutPacket(p, ThrottleOutPacketType.Task);
  2821. }
  2822. public void SendDeclineCallingCard(UUID transactionID)
  2823. {
  2824. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2825. p.AgentData.AgentID = AgentId;
  2826. p.AgentData.SessionID = UUID.Zero;
  2827. p.TransactionBlock.TransactionID = transactionID;
  2828. OutPacket(p, ThrottleOutPacketType.Task);
  2829. }
  2830. public void SendTerminateFriend(UUID exFriendID)
  2831. {
  2832. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2833. p.AgentData.AgentID = AgentId;
  2834. p.AgentData.SessionID = SessionId;
  2835. p.ExBlock.OtherID = exFriendID;
  2836. OutPacket(p, ThrottleOutPacketType.Task);
  2837. }
  2838. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2839. {
  2840. OSDMap llsd = new OSDMap(3);
  2841. OSDArray AgentData = new OSDArray(1);
  2842. OSDMap AgentDataMap = new OSDMap(1);
  2843. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2844. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2845. AgentData.Add(AgentDataMap);
  2846. llsd.Add("AgentData", AgentData);
  2847. OSDArray GroupData = new OSDArray(data.Length);
  2848. OSDArray NewGroupData = new OSDArray(data.Length);
  2849. foreach (GroupMembershipData m in data)
  2850. {
  2851. OSDMap GroupDataMap = new OSDMap(6);
  2852. OSDMap NewGroupDataMap = new OSDMap(1);
  2853. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2854. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2855. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2856. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2857. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2858. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2859. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2860. GroupData.Add(GroupDataMap);
  2861. NewGroupData.Add(NewGroupDataMap);
  2862. }
  2863. llsd.Add("GroupData", GroupData);
  2864. llsd.Add("NewGroupData", NewGroupData);
  2865. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2866. if (eq != null)
  2867. {
  2868. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2869. }
  2870. }
  2871. public void SendJoinGroupReply(UUID groupID, bool success)
  2872. {
  2873. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2874. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2875. p.AgentData.AgentID = AgentId;
  2876. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2877. p.GroupData.GroupID = groupID;
  2878. p.GroupData.Success = success;
  2879. OutPacket(p, ThrottleOutPacketType.Task);
  2880. }
  2881. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2882. {
  2883. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2884. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2885. p.AgentData.AgentID = agentID;
  2886. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2887. p.GroupData.GroupID = groupID;
  2888. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2889. p.EjectData.Success = success;
  2890. OutPacket(p, ThrottleOutPacketType.Task);
  2891. }
  2892. public void SendLeaveGroupReply(UUID groupID, bool success)
  2893. {
  2894. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2895. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2896. p.AgentData.AgentID = AgentId;
  2897. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2898. p.GroupData.GroupID = groupID;
  2899. p.GroupData.Success = success;
  2900. OutPacket(p, ThrottleOutPacketType.Task);
  2901. }
  2902. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2903. {
  2904. if (classifiedID.Length != name.Length)
  2905. return;
  2906. AvatarClassifiedReplyPacket ac =
  2907. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2908. PacketType.AvatarClassifiedReply);
  2909. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2910. ac.AgentData.AgentID = AgentId;
  2911. ac.AgentData.TargetID = targetID;
  2912. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2913. int i;
  2914. for (i = 0; i < classifiedID.Length; i++)
  2915. {
  2916. ac.Data[i].ClassifiedID = classifiedID[i];
  2917. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2918. }
  2919. OutPacket(ac, ThrottleOutPacketType.Task);
  2920. }
  2921. 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)
  2922. {
  2923. ClassifiedInfoReplyPacket cr =
  2924. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2925. PacketType.ClassifiedInfoReply);
  2926. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2927. cr.AgentData.AgentID = AgentId;
  2928. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2929. cr.Data.ClassifiedID = classifiedID;
  2930. cr.Data.CreatorID = creatorID;
  2931. cr.Data.CreationDate = creationDate;
  2932. cr.Data.ExpirationDate = expirationDate;
  2933. cr.Data.Category = category;
  2934. cr.Data.Name = Utils.StringToBytes(name);
  2935. cr.Data.Desc = Utils.StringToBytes(description);
  2936. cr.Data.ParcelID = parcelID;
  2937. cr.Data.ParentEstate = parentEstate;
  2938. cr.Data.SnapshotID = snapshotID;
  2939. cr.Data.SimName = Utils.StringToBytes(simName);
  2940. cr.Data.PosGlobal = new Vector3d(globalPos);
  2941. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2942. cr.Data.ClassifiedFlags = classifiedFlags;
  2943. cr.Data.PriceForListing = price;
  2944. OutPacket(cr, ThrottleOutPacketType.Task);
  2945. }
  2946. public void SendAgentDropGroup(UUID groupID)
  2947. {
  2948. AgentDropGroupPacket dg =
  2949. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2950. PacketType.AgentDropGroup);
  2951. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2952. dg.AgentData.AgentID = AgentId;
  2953. dg.AgentData.GroupID = groupID;
  2954. OutPacket(dg, ThrottleOutPacketType.Task);
  2955. }
  2956. public void SendAvatarNotesReply(UUID targetID, string text)
  2957. {
  2958. AvatarNotesReplyPacket an =
  2959. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2960. PacketType.AvatarNotesReply);
  2961. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2962. an.AgentData.AgentID = AgentId;
  2963. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2964. an.Data.TargetID = targetID;
  2965. an.Data.Notes = Utils.StringToBytes(text);
  2966. OutPacket(an, ThrottleOutPacketType.Task);
  2967. }
  2968. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2969. {
  2970. AvatarPicksReplyPacket ap =
  2971. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2972. PacketType.AvatarPicksReply);
  2973. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2974. ap.AgentData.AgentID = AgentId;
  2975. ap.AgentData.TargetID = targetID;
  2976. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  2977. int i = 0;
  2978. foreach (KeyValuePair<UUID, string> pick in picks)
  2979. {
  2980. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  2981. ap.Data[i].PickID = pick.Key;
  2982. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  2983. i++;
  2984. }
  2985. OutPacket(ap, ThrottleOutPacketType.Task);
  2986. }
  2987. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  2988. {
  2989. AvatarClassifiedReplyPacket ac =
  2990. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2991. PacketType.AvatarClassifiedReply);
  2992. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2993. ac.AgentData.AgentID = AgentId;
  2994. ac.AgentData.TargetID = targetID;
  2995. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  2996. int i = 0;
  2997. foreach (KeyValuePair<UUID, string> classified in classifieds)
  2998. {
  2999. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3000. ac.Data[i].ClassifiedID = classified.Key;
  3001. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3002. i++;
  3003. }
  3004. OutPacket(ac, ThrottleOutPacketType.Task);
  3005. }
  3006. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3007. {
  3008. ParcelDwellReplyPacket pd =
  3009. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3010. PacketType.ParcelDwellReply);
  3011. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3012. pd.AgentData.AgentID = AgentId;
  3013. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3014. pd.Data.LocalID = localID;
  3015. pd.Data.ParcelID = parcelID;
  3016. pd.Data.Dwell = dwell;
  3017. OutPacket(pd, ThrottleOutPacketType.Land);
  3018. }
  3019. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3020. {
  3021. UserInfoReplyPacket ur =
  3022. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3023. PacketType.UserInfoReply);
  3024. string Visible = "hidden";
  3025. if (visible)
  3026. Visible = "default";
  3027. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3028. ur.AgentData.AgentID = AgentId;
  3029. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3030. ur.UserData.IMViaEMail = imViaEmail;
  3031. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3032. ur.UserData.EMail = Utils.StringToBytes(email);
  3033. OutPacket(ur, ThrottleOutPacketType.Task);
  3034. }
  3035. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3036. {
  3037. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3038. createGroupReply.AgentData =
  3039. new CreateGroupReplyPacket.AgentDataBlock();
  3040. createGroupReply.ReplyData =
  3041. new CreateGroupReplyPacket.ReplyDataBlock();
  3042. createGroupReply.AgentData.AgentID = AgentId;
  3043. createGroupReply.ReplyData.GroupID = groupID;
  3044. createGroupReply.ReplyData.Success = success;
  3045. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3046. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3047. }
  3048. public void SendUseCachedMuteList()
  3049. {
  3050. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3051. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3052. useCachedMuteList.AgentData.AgentID = AgentId;
  3053. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3054. }
  3055. public void SendMuteListUpdate(string filename)
  3056. {
  3057. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3058. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3059. muteListUpdate.MuteData.AgentID = AgentId;
  3060. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3061. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3062. }
  3063. 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)
  3064. {
  3065. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3066. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3067. pickInfoReply.AgentData.AgentID = AgentId;
  3068. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3069. pickInfoReply.Data.PickID = pickID;
  3070. pickInfoReply.Data.CreatorID = creatorID;
  3071. pickInfoReply.Data.TopPick = topPick;
  3072. pickInfoReply.Data.ParcelID = parcelID;
  3073. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3074. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3075. pickInfoReply.Data.SnapshotID = snapshotID;
  3076. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3077. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3078. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3079. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3080. pickInfoReply.Data.SortOrder = sortOrder;
  3081. pickInfoReply.Data.Enabled = enabled;
  3082. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3083. }
  3084. #endregion Scene/Avatar to Client
  3085. // Gesture
  3086. #region Appearance/ Wearables Methods
  3087. public void SendWearables(AvatarWearable[] wearables, int serial)
  3088. {
  3089. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3090. aw.AgentData.AgentID = AgentId;
  3091. aw.AgentData.SerialNum = (uint)serial;
  3092. aw.AgentData.SessionID = m_sessionId;
  3093. int count = 0;
  3094. for (int i = 0; i < wearables.Length; i++)
  3095. count += wearables[i].Count;
  3096. // TODO: don't create new blocks if recycling an old packet
  3097. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3098. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3099. int idx = 0;
  3100. for (int i = 0; i < wearables.Length; i++)
  3101. {
  3102. for (int j = 0; j < wearables[i].Count; j++)
  3103. {
  3104. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3105. awb.WearableType = (byte)i;
  3106. awb.AssetID = wearables[i][j].AssetID;
  3107. awb.ItemID = wearables[i][j].ItemID;
  3108. aw.WearableData[idx] = awb;
  3109. idx++;
  3110. // m_log.DebugFormat(
  3111. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3112. // awb.ItemID, awb.AssetID, i, Name);
  3113. }
  3114. }
  3115. OutPacket(aw, ThrottleOutPacketType.Task);
  3116. }
  3117. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3118. {
  3119. // m_log.DebugFormat(
  3120. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3121. // agentID, textureEntry.Length, Name, AgentId);
  3122. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3123. // TODO: don't create new blocks if recycling an old packet
  3124. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
  3125. avp.ObjectData.TextureEntry = textureEntry;
  3126. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3127. for (int i = 0; i < visualParams.Length; i++)
  3128. {
  3129. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3130. avblock.ParamValue = visualParams[i];
  3131. avp.VisualParam[i] = avblock;
  3132. }
  3133. avp.Sender.IsTrial = false;
  3134. avp.Sender.ID = agentID;
  3135. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3136. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3137. OutPacket(avp, ThrottleOutPacketType.Task);
  3138. }
  3139. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3140. {
  3141. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3142. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3143. // TODO: don't create new blocks if recycling an old packet
  3144. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3145. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3146. ani.Sender.ID = sourceAgentId;
  3147. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3148. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3149. for (int i = 0; i < animations.Length; ++i)
  3150. {
  3151. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3152. ani.AnimationList[i].AnimID = animations[i];
  3153. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3154. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3155. if (objectIDs[i].Equals(sourceAgentId))
  3156. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3157. else
  3158. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3159. }
  3160. ani.Header.Reliable = false;
  3161. OutPacket(ani, ThrottleOutPacketType.Task);
  3162. }
  3163. #endregion
  3164. #region Avatar Packet/Data Sending Methods
  3165. /// <summary>
  3166. /// Send an ObjectUpdate packet with information about an avatar
  3167. /// </summary>
  3168. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3169. {
  3170. // m_log.DebugFormat(
  3171. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3172. // avatar.Name, avatar.UUID, Name, AgentId);
  3173. ScenePresence presence = avatar as ScenePresence;
  3174. if (presence == null)
  3175. return;
  3176. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3177. objupdate.Header.Zerocoded = true;
  3178. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3179. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3180. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3181. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3182. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3183. // We need to record the avatar local id since the root prim of an attachment points to this.
  3184. // m_attachmentsSent.Add(avatar.LocalId);
  3185. }
  3186. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3187. {
  3188. // We don't need to update inactive clients.
  3189. if (!IsActive)
  3190. return;
  3191. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3192. loc.Header.Reliable = false;
  3193. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3194. // a CoarseLocationUpdate packet is received. Oh well.
  3195. int total = Math.Min(CoarseLocations.Count, 60);
  3196. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3197. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3198. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3199. int selfindex = -1;
  3200. for (int i = 0; i < total; i++)
  3201. {
  3202. CoarseLocationUpdatePacket.LocationBlock lb =
  3203. new CoarseLocationUpdatePacket.LocationBlock();
  3204. lb.X = (byte)CoarseLocations[i].X;
  3205. lb.Y = (byte)CoarseLocations[i].Y;
  3206. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3207. loc.Location[i] = lb;
  3208. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3209. loc.AgentData[i].AgentID = users[i];
  3210. if (users[i] == AgentId)
  3211. selfindex = i;
  3212. }
  3213. ib.You = (short)selfindex;
  3214. ib.Prey = -1;
  3215. loc.Index = ib;
  3216. OutPacket(loc, ThrottleOutPacketType.Task);
  3217. }
  3218. #endregion Avatar Packet/Data Sending Methods
  3219. #region Primitive Packet/Data Sending Methods
  3220. /// <summary>
  3221. /// Generate one of the object update packets based on PrimUpdateFlags
  3222. /// and broadcast the packet to clients
  3223. /// </summary>
  3224. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3225. {
  3226. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3227. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3228. lock (m_entityUpdates.SyncRoot)
  3229. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3230. }
  3231. /// <summary>
  3232. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3233. /// We will update the priority and put it in the correct queue, merging update flags
  3234. /// with any other updates that may be queued for the same entity.
  3235. /// The original update time is used for the merged update.
  3236. /// </summary>
  3237. private void ResendPrimUpdate(EntityUpdate update)
  3238. {
  3239. // If the update exists in priority queue, it will be updated.
  3240. // If it does not exist then it will be added with the current (rather than its original) priority
  3241. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3242. lock (m_entityUpdates.SyncRoot)
  3243. m_entityUpdates.Enqueue(priority, update);
  3244. }
  3245. /// <summary>
  3246. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3247. /// We will update the priority and put it in the correct queue, merging update flags
  3248. /// with any other updates that may be queued for the same entity.
  3249. /// The original update time is used for the merged update.
  3250. /// </summary>
  3251. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3252. {
  3253. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3254. // Remove the update packet from the list of packets waiting for acknowledgement
  3255. // because we are requeuing the list of updates. They will be resent in new packets
  3256. // with the most recent state and priority.
  3257. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3258. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3259. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3260. // We're not going to worry about interlock yet since its not currently critical that this total count
  3261. // is 100% correct
  3262. m_udpServer.PacketsResentCount++;
  3263. foreach (EntityUpdate update in updates)
  3264. ResendPrimUpdate(update);
  3265. }
  3266. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3267. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3268. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3269. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3270. //
  3271. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3272. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3273. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3274. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3275. private void ProcessEntityUpdates(int maxUpdates)
  3276. {
  3277. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3278. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3279. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3280. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3281. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3282. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3283. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3284. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3285. // objectUpdateBlocks.Value.Clear();
  3286. // compressedUpdateBlocks.Value.Clear();
  3287. // terseUpdateBlocks.Value.Clear();
  3288. // terseAgentUpdateBlocks.Value.Clear();
  3289. // objectUpdates.Value.Clear();
  3290. // compressedUpdates.Value.Clear();
  3291. // terseUpdates.Value.Clear();
  3292. // terseAgentUpdates.Value.Clear();
  3293. // Check to see if this is a flush
  3294. if (maxUpdates <= 0)
  3295. {
  3296. maxUpdates = Int32.MaxValue;
  3297. }
  3298. int updatesThisCall = 0;
  3299. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3300. // condition where a kill can be processed before an out-of-date update for the same object.
  3301. lock (m_killRecord)
  3302. {
  3303. float avgTimeDilation = 1.0f;
  3304. IEntityUpdate iupdate;
  3305. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3306. while (updatesThisCall < maxUpdates)
  3307. {
  3308. lock (m_entityUpdates.SyncRoot)
  3309. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3310. break;
  3311. EntityUpdate update = (EntityUpdate)iupdate;
  3312. avgTimeDilation += update.TimeDilation;
  3313. avgTimeDilation *= 0.5f;
  3314. if (update.Entity is SceneObjectPart)
  3315. {
  3316. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3317. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3318. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3319. // safety measure.
  3320. //
  3321. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3322. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3323. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3324. //
  3325. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3326. // after the root prim has been deleted.
  3327. if (m_killRecord.Contains(part.LocalId))
  3328. {
  3329. // m_log.WarnFormat(
  3330. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3331. // part.LocalId, Name);
  3332. continue;
  3333. }
  3334. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3335. {
  3336. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3337. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3338. {
  3339. part.Shape.LightEntry = false;
  3340. }
  3341. }
  3342. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3343. {
  3344. // Ensure that mesh has at least 8 valid faces
  3345. part.Shape.ProfileBegin = 12500;
  3346. part.Shape.ProfileEnd = 0;
  3347. part.Shape.ProfileHollow = 27500;
  3348. }
  3349. }
  3350. #region UpdateFlags to packet type conversion
  3351. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3352. bool canUseCompressed = true;
  3353. bool canUseImproved = true;
  3354. // Compressed object updates only make sense for LL primitives
  3355. if (!(update.Entity is SceneObjectPart))
  3356. {
  3357. canUseCompressed = false;
  3358. }
  3359. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3360. {
  3361. canUseCompressed = false;
  3362. canUseImproved = false;
  3363. }
  3364. else
  3365. {
  3366. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3367. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3368. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3369. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3370. {
  3371. canUseCompressed = false;
  3372. }
  3373. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3374. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3375. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3376. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3377. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3378. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3379. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3380. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3381. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3382. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3383. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3384. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3385. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3386. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3387. {
  3388. canUseImproved = false;
  3389. }
  3390. }
  3391. #endregion UpdateFlags to packet type conversion
  3392. #region Block Construction
  3393. // TODO: Remove this once we can build compressed updates
  3394. canUseCompressed = false;
  3395. if (!canUseImproved && !canUseCompressed)
  3396. {
  3397. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3398. if (update.Entity is ScenePresence)
  3399. {
  3400. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3401. }
  3402. else
  3403. {
  3404. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3405. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3406. // If the part has become a private hud since the update was scheduled then we do not
  3407. // want to send it to other avatars.
  3408. if (part.ParentGroup.IsAttachment
  3409. && part.ParentGroup.HasPrivateAttachmentPoint
  3410. && part.ParentGroup.AttachedAvatar != AgentId)
  3411. continue;
  3412. // If the part has since been deleted, then drop the update. In the case of attachments,
  3413. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3414. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3415. // of the test above).
  3416. //
  3417. // Actual deletions (kills) happen in another method.
  3418. if (part.ParentGroup.IsDeleted)
  3419. continue;
  3420. }
  3421. objectUpdateBlocks.Value.Add(updateBlock);
  3422. objectUpdates.Value.Add(update);
  3423. }
  3424. else if (!canUseImproved)
  3425. {
  3426. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3427. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3428. = CreateCompressedUpdateBlock(part, updateFlags);
  3429. // If the part has since been deleted, then drop the update. In the case of attachments,
  3430. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3431. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3432. // of the test above).
  3433. //
  3434. // Actual deletions (kills) happen in another method.
  3435. if (part.ParentGroup.IsDeleted)
  3436. continue;
  3437. compressedUpdateBlocks.Value.Add(compressedBlock);
  3438. compressedUpdates.Value.Add(update);
  3439. }
  3440. else
  3441. {
  3442. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3443. {
  3444. // Self updates go into a special list
  3445. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3446. terseAgentUpdates.Value.Add(update);
  3447. }
  3448. else
  3449. {
  3450. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3451. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3452. // Everything else goes here
  3453. if (update.Entity is SceneObjectPart)
  3454. {
  3455. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3456. // If the part has become a private hud since the update was scheduled then we do not
  3457. // want to send it to other avatars.
  3458. if (part.ParentGroup.IsAttachment
  3459. && part.ParentGroup.HasPrivateAttachmentPoint
  3460. && part.ParentGroup.AttachedAvatar != AgentId)
  3461. continue;
  3462. // If the part has since been deleted, then drop the update. In the case of attachments,
  3463. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3464. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3465. // of the test above).
  3466. //
  3467. // Actual deletions (kills) happen in another method.
  3468. if (part.ParentGroup.IsDeleted)
  3469. continue;
  3470. }
  3471. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3472. terseUpdates.Value.Add(update);
  3473. }
  3474. }
  3475. ++updatesThisCall;
  3476. #endregion Block Construction
  3477. }
  3478. #region Packet Sending
  3479. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3480. if (terseAgentUpdateBlocks.IsValueCreated)
  3481. {
  3482. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3483. ImprovedTerseObjectUpdatePacket packet
  3484. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3485. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3486. packet.RegionData.TimeDilation = timeDilation;
  3487. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3488. for (int i = 0; i < blocks.Count; i++)
  3489. packet.ObjectData[i] = blocks[i];
  3490. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3491. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3492. }
  3493. if (objectUpdateBlocks.IsValueCreated)
  3494. {
  3495. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3496. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3497. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3498. packet.RegionData.TimeDilation = timeDilation;
  3499. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3500. for (int i = 0; i < blocks.Count; i++)
  3501. packet.ObjectData[i] = blocks[i];
  3502. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3503. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3504. }
  3505. if (compressedUpdateBlocks.IsValueCreated)
  3506. {
  3507. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3508. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3509. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3510. packet.RegionData.TimeDilation = timeDilation;
  3511. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3512. for (int i = 0; i < blocks.Count; i++)
  3513. packet.ObjectData[i] = blocks[i];
  3514. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3515. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3516. }
  3517. if (terseUpdateBlocks.IsValueCreated)
  3518. {
  3519. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3520. ImprovedTerseObjectUpdatePacket packet
  3521. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3522. PacketType.ImprovedTerseObjectUpdate);
  3523. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3524. packet.RegionData.TimeDilation = timeDilation;
  3525. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3526. for (int i = 0; i < blocks.Count; i++)
  3527. packet.ObjectData[i] = blocks[i];
  3528. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3529. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3530. }
  3531. }
  3532. #endregion Packet Sending
  3533. }
  3534. public void ReprioritizeUpdates()
  3535. {
  3536. lock (m_entityUpdates.SyncRoot)
  3537. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3538. }
  3539. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3540. {
  3541. if (entity != null)
  3542. {
  3543. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3544. return true;
  3545. }
  3546. return false;
  3547. }
  3548. public void FlushPrimUpdates()
  3549. {
  3550. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3551. while (m_entityUpdates.Count > 0)
  3552. ProcessEntityUpdates(-1);
  3553. }
  3554. #endregion Primitive Packet/Data Sending Methods
  3555. // These are used to implement an adaptive backoff in the number
  3556. // of updates converted to packets. Since we don't want packets
  3557. // to sit in the queue with old data, only convert enough updates
  3558. // to packets that can be sent in 200ms.
  3559. private Int32 m_LastQueueFill = 0;
  3560. private Int32 m_maxUpdates = 0;
  3561. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3562. {
  3563. // if (!m_udpServer.IsRunningOutbound)
  3564. // return;
  3565. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3566. {
  3567. // if (!m_udpServer.IsRunningOutbound)
  3568. // return;
  3569. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3570. {
  3571. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3572. }
  3573. else
  3574. {
  3575. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3576. m_maxUpdates += 5;
  3577. else
  3578. m_maxUpdates = m_maxUpdates >> 1;
  3579. }
  3580. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3581. m_LastQueueFill = Util.EnvironmentTickCount();
  3582. if (m_entityUpdates.Count > 0)
  3583. ProcessEntityUpdates(m_maxUpdates);
  3584. if (m_entityProps.Count > 0)
  3585. ProcessEntityPropertyRequests(m_maxUpdates);
  3586. }
  3587. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3588. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3589. }
  3590. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3591. {
  3592. bool hasUpdates = false;
  3593. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3594. {
  3595. if (m_entityUpdates.Count > 0)
  3596. hasUpdates = true;
  3597. else if (m_entityProps.Count > 0)
  3598. hasUpdates = true;
  3599. }
  3600. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3601. {
  3602. if (ImageManager.HasUpdates())
  3603. hasUpdates = true;
  3604. }
  3605. return hasUpdates;
  3606. }
  3607. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3608. {
  3609. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3610. newPack.AssetBlock.Type = AssetType;
  3611. newPack.AssetBlock.Success = Success;
  3612. newPack.AssetBlock.UUID = AssetFullID;
  3613. newPack.Header.Zerocoded = true;
  3614. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3615. }
  3616. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3617. {
  3618. RequestXferPacket newPack = new RequestXferPacket();
  3619. newPack.XferID.ID = XferID;
  3620. newPack.XferID.VFileType = AssetType;
  3621. newPack.XferID.VFileID = vFileID;
  3622. newPack.XferID.FilePath = FilePath;
  3623. newPack.XferID.Filename = FileName;
  3624. newPack.Header.Zerocoded = true;
  3625. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3626. }
  3627. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3628. {
  3629. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3630. newPack.XferID.ID = xferID;
  3631. newPack.XferID.Packet = PacketID;
  3632. newPack.Header.Zerocoded = true;
  3633. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3634. }
  3635. public void SendInitiateDownload(string simFileName, string clientFileName)
  3636. {
  3637. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3638. newPack.AgentData.AgentID = AgentId;
  3639. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3640. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3641. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3642. }
  3643. public void SendImageFirstPart(
  3644. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3645. {
  3646. ImageDataPacket im = new ImageDataPacket();
  3647. im.Header.Reliable = false;
  3648. im.ImageID.Packets = numParts;
  3649. im.ImageID.ID = ImageUUID;
  3650. if (ImageSize > 0)
  3651. im.ImageID.Size = ImageSize;
  3652. im.ImageData.Data = ImageData;
  3653. im.ImageID.Codec = imageCodec;
  3654. im.Header.Zerocoded = true;
  3655. OutPacket(im, ThrottleOutPacketType.Texture);
  3656. }
  3657. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3658. {
  3659. ImagePacketPacket im = new ImagePacketPacket();
  3660. im.Header.Reliable = false;
  3661. im.ImageID.Packet = partNumber;
  3662. im.ImageID.ID = imageUuid;
  3663. im.ImageData.Data = imageData;
  3664. OutPacket(im, ThrottleOutPacketType.Texture);
  3665. }
  3666. public void SendImageNotFound(UUID imageid)
  3667. {
  3668. ImageNotInDatabasePacket notFoundPacket
  3669. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3670. notFoundPacket.ImageID.ID = imageid;
  3671. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3672. }
  3673. public void SendShutdownConnectionNotice()
  3674. {
  3675. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3676. }
  3677. public void SendSimStats(SimStats stats)
  3678. {
  3679. SimStatsPacket pack = new SimStatsPacket();
  3680. pack.Region = new SimStatsPacket.RegionBlock();
  3681. pack.Region.RegionX = stats.RegionX;
  3682. pack.Region.RegionY = stats.RegionY;
  3683. pack.Region.RegionFlags = stats.RegionFlags;
  3684. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3685. //pack.Region = //stats.RegionBlock;
  3686. pack.Stat = stats.StatsBlock;
  3687. pack.Header.Reliable = false;
  3688. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3689. OutPacket(pack, ThrottleOutPacketType.Task);
  3690. }
  3691. private class ObjectPropertyUpdate : IEntityUpdate
  3692. {
  3693. internal bool SendFamilyProps;
  3694. internal bool SendObjectProps;
  3695. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3696. : base(entity,flags)
  3697. {
  3698. SendFamilyProps = sendfam;
  3699. SendObjectProps = sendobj;
  3700. }
  3701. public void Update(ObjectPropertyUpdate update)
  3702. {
  3703. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3704. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3705. // other properties may need to be updated by base class
  3706. base.Update(update);
  3707. }
  3708. }
  3709. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3710. {
  3711. uint priority = 0; // time based ordering only
  3712. lock (m_entityProps.SyncRoot)
  3713. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3714. }
  3715. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3716. {
  3717. uint priority = 0;
  3718. lock (m_entityProps.SyncRoot)
  3719. m_entityProps.Enqueue(priority, update);
  3720. }
  3721. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3722. {
  3723. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3724. // Remove the update packet from the list of packets waiting for acknowledgement
  3725. // because we are requeuing the list of updates. They will be resent in new packets
  3726. // with the most recent state.
  3727. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3728. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3729. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3730. // We're not going to worry about interlock yet since its not currently critical that this total count
  3731. // is 100% correct
  3732. m_udpServer.PacketsResentCount++;
  3733. foreach (ObjectPropertyUpdate update in updates)
  3734. ResendPropertyUpdate(update);
  3735. }
  3736. public void SendObjectPropertiesReply(ISceneEntity entity)
  3737. {
  3738. uint priority = 0; // time based ordering only
  3739. lock (m_entityProps.SyncRoot)
  3740. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3741. }
  3742. private void ProcessEntityPropertyRequests(int maxUpdates)
  3743. {
  3744. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3745. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3746. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3747. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3748. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3749. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3750. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3751. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3752. IEntityUpdate iupdate;
  3753. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3754. int updatesThisCall = 0;
  3755. while (updatesThisCall < m_maxUpdates)
  3756. {
  3757. lock (m_entityProps.SyncRoot)
  3758. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3759. break;
  3760. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3761. if (update.SendFamilyProps)
  3762. {
  3763. if (update.Entity is SceneObjectPart)
  3764. {
  3765. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3766. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3767. objectFamilyBlocks.Value.Add(objPropDB);
  3768. familyUpdates.Value.Add(update);
  3769. }
  3770. }
  3771. if (update.SendObjectProps)
  3772. {
  3773. if (update.Entity is SceneObjectPart)
  3774. {
  3775. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3776. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3777. objectPropertiesBlocks.Value.Add(objPropDB);
  3778. propertyUpdates.Value.Add(update);
  3779. }
  3780. }
  3781. updatesThisCall++;
  3782. }
  3783. // Int32 ppcnt = 0;
  3784. // Int32 pbcnt = 0;
  3785. if (objectPropertiesBlocks.IsValueCreated)
  3786. {
  3787. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3788. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3789. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3790. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3791. for (int i = 0; i < blocks.Count; i++)
  3792. packet.ObjectData[i] = blocks[i];
  3793. packet.Header.Zerocoded = true;
  3794. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3795. // of the object rather than the properties when the packet was created
  3796. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3797. delegate(OutgoingPacket oPacket)
  3798. {
  3799. ResendPropertyUpdates(updates, oPacket);
  3800. });
  3801. // pbcnt += blocks.Count;
  3802. // ppcnt++;
  3803. }
  3804. // Int32 fpcnt = 0;
  3805. // Int32 fbcnt = 0;
  3806. if (objectFamilyBlocks.IsValueCreated)
  3807. {
  3808. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3809. // one packet per object block... uggh...
  3810. for (int i = 0; i < blocks.Count; i++)
  3811. {
  3812. ObjectPropertiesFamilyPacket packet =
  3813. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3814. packet.ObjectData = blocks[i];
  3815. packet.Header.Zerocoded = true;
  3816. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3817. // of the object rather than the properties when the packet was created
  3818. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3819. updates.Add(familyUpdates.Value[i]);
  3820. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3821. delegate(OutgoingPacket oPacket)
  3822. {
  3823. ResendPropertyUpdates(updates, oPacket);
  3824. });
  3825. // fpcnt++;
  3826. // fbcnt++;
  3827. }
  3828. }
  3829. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3830. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3831. }
  3832. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3833. {
  3834. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3835. block.RequestFlags = requestFlags;
  3836. block.ObjectID = sop.UUID;
  3837. if (sop.OwnerID == sop.GroupID)
  3838. block.OwnerID = UUID.Zero;
  3839. else
  3840. block.OwnerID = sop.OwnerID;
  3841. block.GroupID = sop.GroupID;
  3842. block.BaseMask = sop.BaseMask;
  3843. block.OwnerMask = sop.OwnerMask;
  3844. block.GroupMask = sop.GroupMask;
  3845. block.EveryoneMask = sop.EveryoneMask;
  3846. block.NextOwnerMask = sop.NextOwnerMask;
  3847. // TODO: More properties are needed in SceneObjectPart!
  3848. block.OwnershipCost = sop.OwnershipCost;
  3849. block.SaleType = sop.ObjectSaleType;
  3850. block.SalePrice = sop.SalePrice;
  3851. block.Category = sop.Category;
  3852. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3853. block.Name = Util.StringToBytes256(sop.Name);
  3854. block.Description = Util.StringToBytes256(sop.Description);
  3855. return block;
  3856. }
  3857. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3858. {
  3859. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3860. // TODO: don't create new blocks if recycling an old packet
  3861. ObjectPropertiesPacket.ObjectDataBlock block =
  3862. new ObjectPropertiesPacket.ObjectDataBlock();
  3863. block.ObjectID = sop.UUID;
  3864. block.Name = Util.StringToBytes256(sop.Name);
  3865. block.Description = Util.StringToBytes256(sop.Description);
  3866. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3867. block.CreatorID = sop.CreatorID;
  3868. block.GroupID = sop.GroupID;
  3869. block.LastOwnerID = sop.LastOwnerID;
  3870. if (sop.OwnerID == sop.GroupID)
  3871. block.OwnerID = UUID.Zero;
  3872. else
  3873. block.OwnerID = sop.OwnerID;
  3874. block.ItemID = sop.FromUserInventoryItemID;
  3875. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3876. block.FromTaskID = UUID.Zero; // ???
  3877. block.InventorySerial = (short)sop.InventorySerial;
  3878. SceneObjectPart root = sop.ParentGroup.RootPart;
  3879. block.TouchName = Util.StringToBytes256(root.TouchName);
  3880. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  3881. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  3882. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  3883. // using (MemoryStream memStream = new MemoryStream())
  3884. // {
  3885. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  3886. // {
  3887. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  3888. // {
  3889. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  3890. //
  3891. // UUID textureID;
  3892. //
  3893. // if (teFace != null)
  3894. // textureID = teFace.TextureID;
  3895. // else
  3896. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  3897. //
  3898. // binWriter.Write(textureID.GetBytes());
  3899. // }
  3900. //
  3901. // block.TextureID = memStream.ToArray();
  3902. // }
  3903. // }
  3904. block.TextureID = new byte[0]; // TextureID ???
  3905. block.SitName = Util.StringToBytes256(root.SitName);
  3906. block.OwnerMask = root.OwnerMask;
  3907. block.NextOwnerMask = root.NextOwnerMask;
  3908. block.GroupMask = root.GroupMask;
  3909. block.EveryoneMask = root.EveryoneMask;
  3910. block.BaseMask = root.BaseMask;
  3911. block.SaleType = root.ObjectSaleType;
  3912. block.SalePrice = root.SalePrice;
  3913. return block;
  3914. }
  3915. #region Estate Data Sending Methods
  3916. private static bool convertParamStringToBool(byte[] field)
  3917. {
  3918. string s = Utils.BytesToString(field);
  3919. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3920. {
  3921. return true;
  3922. }
  3923. return false;
  3924. }
  3925. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3926. {
  3927. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3928. packet.AgentData.TransactionID = UUID.Random();
  3929. packet.AgentData.AgentID = AgentId;
  3930. packet.AgentData.SessionID = SessionId;
  3931. packet.MethodData.Invoice = invoice;
  3932. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3933. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3934. for (int i = 0; i < (6 + Data.Length); i++)
  3935. {
  3936. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3937. }
  3938. int j = 0;
  3939. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3940. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3941. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3942. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3943. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3944. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3945. j = 2; // Agents
  3946. if ((code & 2) != 0)
  3947. j = 3; // Groups
  3948. if ((code & 8) != 0)
  3949. j = 5; // Managers
  3950. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3951. j = 6;
  3952. for (int i = 0; i < Data.Length; i++)
  3953. {
  3954. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3955. }
  3956. packet.ParamList = returnblock;
  3957. packet.Header.Reliable = true;
  3958. OutPacket(packet, ThrottleOutPacketType.Task);
  3959. }
  3960. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3961. {
  3962. List<UUID> BannedUsers = new List<UUID>();
  3963. for (int i = 0; i < bl.Length; i++)
  3964. {
  3965. if (bl[i] == null)
  3966. continue;
  3967. if (bl[i].BannedUserID == UUID.Zero)
  3968. continue;
  3969. BannedUsers.Add(bl[i].BannedUserID);
  3970. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3971. {
  3972. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3973. packet.AgentData.TransactionID = UUID.Random();
  3974. packet.AgentData.AgentID = AgentId;
  3975. packet.AgentData.SessionID = SessionId;
  3976. packet.MethodData.Invoice = invoice;
  3977. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3978. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3979. int j;
  3980. for (j = 0; j < (6 + BannedUsers.Count); j++)
  3981. {
  3982. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  3983. }
  3984. j = 0;
  3985. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3986. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3987. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3988. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3989. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3990. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3991. foreach (UUID banned in BannedUsers)
  3992. {
  3993. returnblock[j].Parameter = banned.GetBytes(); j++;
  3994. }
  3995. packet.ParamList = returnblock;
  3996. packet.Header.Reliable = true;
  3997. OutPacket(packet, ThrottleOutPacketType.Task);
  3998. BannedUsers.Clear();
  3999. }
  4000. }
  4001. }
  4002. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4003. {
  4004. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4005. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4006. rinfopack.AgentData.AgentID = AgentId;
  4007. rinfopack.AgentData.SessionID = SessionId;
  4008. rinfoblk.BillableFactor = args.billableFactor;
  4009. rinfoblk.EstateID = args.estateID;
  4010. rinfoblk.MaxAgents = args.maxAgents;
  4011. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4012. rinfoblk.ParentEstateID = args.parentEstateID;
  4013. rinfoblk.PricePerMeter = args.pricePerMeter;
  4014. rinfoblk.RedirectGridX = args.redirectGridX;
  4015. rinfoblk.RedirectGridY = args.redirectGridY;
  4016. rinfoblk.RegionFlags = args.regionFlags;
  4017. rinfoblk.SimAccess = args.simAccess;
  4018. rinfoblk.SunHour = args.sunHour;
  4019. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4020. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4021. rinfoblk.UseEstateSun = args.useEstateSun;
  4022. rinfoblk.WaterHeight = args.waterHeight;
  4023. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4024. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4025. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4026. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4027. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4028. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4029. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4030. rinfopack.HasVariableBlocks = true;
  4031. rinfopack.RegionInfo = rinfoblk;
  4032. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4033. rinfopack.AgentData.AgentID = AgentId;
  4034. rinfopack.AgentData.SessionID = SessionId;
  4035. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4036. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4037. }
  4038. public void SendEstateCovenantInformation(UUID covenant)
  4039. {
  4040. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4041. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4042. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4043. edata.CovenantID = covenant;
  4044. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4045. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4046. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4047. einfopack.Data = edata;
  4048. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4049. }
  4050. public void SendDetailedEstateData(
  4051. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4052. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4053. {
  4054. // m_log.DebugFormat(
  4055. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4056. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4057. packet.MethodData.Invoice = invoice;
  4058. packet.AgentData.TransactionID = UUID.Random();
  4059. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4060. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4061. for (int i = 0; i < 10; i++)
  4062. {
  4063. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4064. }
  4065. //Sending Estate Settings
  4066. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4067. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4068. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4069. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4070. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4071. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4072. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4073. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4074. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4075. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4076. packet.ParamList = returnblock;
  4077. packet.Header.Reliable = false;
  4078. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4079. OutPacket(packet, ThrottleOutPacketType.Task);
  4080. }
  4081. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4082. {
  4083. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4084. packet.TelehubBlock.ObjectID = ObjectID;
  4085. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4086. packet.TelehubBlock.TelehubPos = ObjectPos;
  4087. packet.TelehubBlock.TelehubRot = ObjectRot;
  4088. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4089. for (int n = 0; n < SpawnPoint.Count; n++)
  4090. {
  4091. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4092. }
  4093. OutPacket(packet, ThrottleOutPacketType.Task);
  4094. }
  4095. #endregion
  4096. #region Land Data Sending Methods
  4097. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4098. {
  4099. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4100. packet.ParcelData.Data = data;
  4101. packet.ParcelData.SequenceID = sequence_id;
  4102. packet.Header.Zerocoded = true;
  4103. OutPacket(packet, ThrottleOutPacketType.Task);
  4104. }
  4105. public void SendLandProperties(
  4106. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4107. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4108. {
  4109. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4110. LandData landData = lo.LandData;
  4111. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4112. updateMessage.AABBMax = landData.AABBMax;
  4113. updateMessage.AABBMin = landData.AABBMin;
  4114. updateMessage.Area = landData.Area;
  4115. updateMessage.AuctionID = landData.AuctionID;
  4116. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4117. updateMessage.Bitmap = landData.Bitmap;
  4118. updateMessage.Desc = landData.Description;
  4119. updateMessage.Category = landData.Category;
  4120. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4121. updateMessage.ClaimPrice = landData.ClaimPrice;
  4122. updateMessage.GroupID = landData.GroupID;
  4123. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4124. updateMessage.LandingType = (LandingType) landData.LandingType;
  4125. updateMessage.LocalID = landData.LocalID;
  4126. if (landData.Area > 0)
  4127. {
  4128. updateMessage.MaxPrims = parcelObjectCapacity;
  4129. }
  4130. else
  4131. {
  4132. updateMessage.MaxPrims = 0;
  4133. }
  4134. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4135. updateMessage.MediaID = landData.MediaID;
  4136. updateMessage.MediaURL = landData.MediaURL;
  4137. updateMessage.MusicURL = landData.MusicURL;
  4138. updateMessage.Name = landData.Name;
  4139. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4140. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4141. updateMessage.OwnerID = landData.OwnerID;
  4142. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4143. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4144. updateMessage.PassHours = landData.PassHours;
  4145. updateMessage.PassPrice = landData.PassPrice;
  4146. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4147. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4148. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4149. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4150. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4151. updateMessage.RentPrice = 0;
  4152. updateMessage.RequestResult = (ParcelResult) request_result;
  4153. updateMessage.SalePrice = landData.SalePrice;
  4154. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4155. updateMessage.SequenceID = sequence_id;
  4156. if (landData.SimwideArea > 0)
  4157. {
  4158. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4159. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4160. }
  4161. else
  4162. {
  4163. updateMessage.SimWideMaxPrims = 0;
  4164. }
  4165. updateMessage.SnapSelection = snap_selection;
  4166. updateMessage.SnapshotID = landData.SnapshotID;
  4167. updateMessage.Status = (ParcelStatus) landData.Status;
  4168. updateMessage.UserLocation = landData.UserLocation;
  4169. updateMessage.UserLookAt = landData.UserLookAt;
  4170. updateMessage.MediaType = landData.MediaType;
  4171. updateMessage.MediaDesc = landData.MediaDescription;
  4172. updateMessage.MediaWidth = landData.MediaWidth;
  4173. updateMessage.MediaHeight = landData.MediaHeight;
  4174. updateMessage.MediaLoop = landData.MediaLoop;
  4175. updateMessage.ObscureMusic = landData.ObscureMusic;
  4176. updateMessage.ObscureMedia = landData.ObscureMedia;
  4177. IPrimCounts pc = lo.PrimCounts;
  4178. updateMessage.OwnerPrims = pc.Owner;
  4179. updateMessage.GroupPrims = pc.Group;
  4180. updateMessage.OtherPrims = pc.Others;
  4181. updateMessage.SelectedPrims = pc.Selected;
  4182. updateMessage.TotalPrims = pc.Total;
  4183. updateMessage.SimWideTotalPrims = pc.Simulator;
  4184. try
  4185. {
  4186. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4187. if (eq != null)
  4188. {
  4189. eq.ParcelProperties(updateMessage, this.AgentId);
  4190. }
  4191. else
  4192. {
  4193. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4194. }
  4195. }
  4196. catch (Exception ex)
  4197. {
  4198. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4199. }
  4200. }
  4201. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4202. {
  4203. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4204. replyPacket.Data.AgentID = AgentId;
  4205. replyPacket.Data.Flags = accessFlag;
  4206. replyPacket.Data.LocalID = localLandID;
  4207. replyPacket.Data.SequenceID = 0;
  4208. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4209. foreach (LandAccessEntry entry in accessList)
  4210. {
  4211. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4212. block.Flags = accessFlag;
  4213. block.ID = entry.AgentID;
  4214. block.Time = entry.Expires;
  4215. list.Add(block);
  4216. }
  4217. replyPacket.List = list.ToArray();
  4218. replyPacket.Header.Zerocoded = true;
  4219. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4220. }
  4221. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4222. {
  4223. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4224. bool firstCall = true;
  4225. const int MAX_OBJECTS_PER_PACKET = 251;
  4226. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4227. ForceObjectSelectPacket.DataBlock[] data;
  4228. while (ObjectIDs.Count > 0)
  4229. {
  4230. if (firstCall)
  4231. {
  4232. pack._Header.ResetList = true;
  4233. firstCall = false;
  4234. }
  4235. else
  4236. {
  4237. pack._Header.ResetList = false;
  4238. }
  4239. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4240. {
  4241. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4242. }
  4243. else
  4244. {
  4245. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4246. }
  4247. int i;
  4248. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4249. {
  4250. data[i] = new ForceObjectSelectPacket.DataBlock();
  4251. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4252. ObjectIDs.RemoveAt(0);
  4253. }
  4254. pack.Data = data;
  4255. pack.Header.Zerocoded = true;
  4256. OutPacket(pack, ThrottleOutPacketType.Task);
  4257. }
  4258. }
  4259. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4260. {
  4261. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4262. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4263. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4264. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4265. OutPacket(cpack, ThrottleOutPacketType.Task);
  4266. }
  4267. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4268. {
  4269. int notifyCount = ownersAndCount.Count;
  4270. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4271. if (notifyCount > 0)
  4272. {
  4273. if (notifyCount > 32)
  4274. {
  4275. m_log.InfoFormat(
  4276. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4277. + " - a developer might want to investigate whether this is a hard limit", 32);
  4278. notifyCount = 32;
  4279. }
  4280. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4281. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4282. int num = 0;
  4283. foreach (UUID owner in ownersAndCount.Keys)
  4284. {
  4285. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4286. dataBlock[num].Count = ownersAndCount[owner];
  4287. if (land.GroupID == owner || groups.Contains(owner))
  4288. dataBlock[num].IsGroupOwned = true;
  4289. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4290. dataBlock[num].OwnerID = owner;
  4291. num++;
  4292. if (num >= notifyCount)
  4293. {
  4294. break;
  4295. }
  4296. }
  4297. pack.Data = dataBlock;
  4298. }
  4299. else
  4300. {
  4301. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4302. }
  4303. pack.Header.Zerocoded = true;
  4304. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4305. }
  4306. #endregion
  4307. #region Helper Methods
  4308. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4309. {
  4310. #region ScenePresence/SOP Handling
  4311. bool avatar = (entity is ScenePresence);
  4312. uint localID = entity.LocalId;
  4313. uint attachPoint;
  4314. Vector4 collisionPlane;
  4315. Vector3 position, velocity, acceleration, angularVelocity;
  4316. Quaternion rotation;
  4317. byte[] textureEntry;
  4318. if (entity is ScenePresence)
  4319. {
  4320. ScenePresence presence = (ScenePresence)entity;
  4321. // m_log.DebugFormat(
  4322. // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
  4323. attachPoint = presence.State;
  4324. collisionPlane = presence.CollisionPlane;
  4325. position = presence.OffsetPosition;
  4326. velocity = presence.Velocity;
  4327. acceleration = Vector3.Zero;
  4328. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4329. // in that direction, even though we don't model this on the server. Implementing this in the future
  4330. // may improve movement smoothness.
  4331. // acceleration = new Vector3(1, 0, 0);
  4332. angularVelocity = presence.AngularVelocity;
  4333. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4334. // it rotates around.
  4335. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4336. // excessive up and down movements of the camera when looking up and down.
  4337. // See http://opensimulator.org/mantis/view.php?id=3274
  4338. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4339. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4340. // the rotation in this case.
  4341. rotation = presence.Rotation;
  4342. if (!presence.IsSatOnObject)
  4343. {
  4344. rotation.X = 0;
  4345. rotation.Y = 0;
  4346. }
  4347. if (sendTexture)
  4348. textureEntry = presence.Appearance.Texture.GetBytes();
  4349. else
  4350. textureEntry = null;
  4351. }
  4352. else
  4353. {
  4354. SceneObjectPart part = (SceneObjectPart)entity;
  4355. attachPoint = part.ParentGroup.AttachmentPoint;
  4356. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4357. // m_log.DebugFormat(
  4358. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4359. // attachPoint, part.Name, part.LocalId, Name);
  4360. collisionPlane = Vector4.Zero;
  4361. position = part.RelativePosition;
  4362. velocity = part.Velocity;
  4363. acceleration = part.Acceleration;
  4364. angularVelocity = part.AngularVelocity;
  4365. rotation = part.RotationOffset;
  4366. if (sendTexture)
  4367. textureEntry = part.Shape.TextureEntry;
  4368. else
  4369. textureEntry = null;
  4370. }
  4371. #endregion ScenePresence/SOP Handling
  4372. int pos = 0;
  4373. byte[] data = new byte[(avatar ? 60 : 44)];
  4374. // LocalID
  4375. Utils.UIntToBytes(localID, data, pos);
  4376. pos += 4;
  4377. // Avatar/CollisionPlane
  4378. data[pos++] = (byte) attachPoint;
  4379. if (avatar)
  4380. {
  4381. data[pos++] = 1;
  4382. if (collisionPlane == Vector4.Zero)
  4383. collisionPlane = Vector4.UnitW;
  4384. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4385. collisionPlane.ToBytes(data, pos);
  4386. pos += 16;
  4387. }
  4388. else
  4389. {
  4390. ++pos;
  4391. }
  4392. // Position
  4393. position.ToBytes(data, pos);
  4394. pos += 12;
  4395. // Velocity
  4396. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4397. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4398. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4399. // Acceleration
  4400. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4401. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4402. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4403. // Rotation
  4404. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4405. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4406. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4407. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4408. // Angular Velocity
  4409. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4410. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4411. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4412. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4413. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4414. block.Data = data;
  4415. if (textureEntry != null && textureEntry.Length > 0)
  4416. {
  4417. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4418. // Texture Length
  4419. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4420. // Texture
  4421. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4422. block.TextureEntry = teBytesFinal;
  4423. }
  4424. else
  4425. {
  4426. block.TextureEntry = Utils.EmptyBytes;
  4427. }
  4428. return block;
  4429. }
  4430. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4431. {
  4432. // m_log.DebugFormat(
  4433. // "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name);
  4434. byte[] objectData = new byte[76];
  4435. data.CollisionPlane.ToBytes(objectData, 0);
  4436. data.OffsetPosition.ToBytes(objectData, 16);
  4437. // data.Velocity.ToBytes(objectData, 28);
  4438. // data.Acceleration.ToBytes(objectData, 40);
  4439. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4440. // it rotates around.
  4441. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4442. // excessive up and down movements of the camera when looking up and down.
  4443. // See http://opensimulator.org/mantis/view.php?id=3274
  4444. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4445. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4446. // the rotation in this case.
  4447. Quaternion rot = data.Rotation;
  4448. if (!data.IsSatOnObject)
  4449. {
  4450. rot.X = 0;
  4451. rot.Y = 0;
  4452. }
  4453. rot.ToBytes(objectData, 52);
  4454. //data.AngularVelocity.ToBytes(objectData, 64);
  4455. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4456. update.Data = Utils.EmptyBytes;
  4457. update.ExtraParams = new byte[1];
  4458. update.FullID = data.UUID;
  4459. update.ID = data.LocalId;
  4460. update.Material = (byte)Material.Flesh;
  4461. update.MediaURL = Utils.EmptyBytes;
  4462. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4463. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4464. update.ObjectData = objectData;
  4465. SceneObjectPart parentPart = data.ParentPart;
  4466. if (parentPart != null)
  4467. update.ParentID = parentPart.ParentGroup.LocalId;
  4468. else
  4469. update.ParentID = 0;
  4470. update.PathCurve = 16;
  4471. update.PathScaleX = 100;
  4472. update.PathScaleY = 100;
  4473. update.PCode = (byte)PCode.Avatar;
  4474. update.ProfileCurve = 1;
  4475. update.PSBlock = Utils.EmptyBytes;
  4476. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4477. update.Text = Utils.EmptyBytes;
  4478. update.TextColor = new byte[4];
  4479. // Don't send texture anim for avatars - this has no meaning for them.
  4480. update.TextureAnim = Utils.EmptyBytes;
  4481. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4482. update.TextureEntry = Utils.EmptyBytes;
  4483. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4484. update.UpdateFlags = (uint)(
  4485. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4486. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4487. PrimFlags.ObjectOwnerModify);
  4488. return update;
  4489. }
  4490. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4491. {
  4492. byte[] objectData = new byte[60];
  4493. data.RelativePosition.ToBytes(objectData, 0);
  4494. data.Velocity.ToBytes(objectData, 12);
  4495. data.Acceleration.ToBytes(objectData, 24);
  4496. try
  4497. {
  4498. data.RotationOffset.ToBytes(objectData, 36);
  4499. }
  4500. catch (Exception e)
  4501. {
  4502. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4503. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4504. }
  4505. data.AngularVelocity.ToBytes(objectData, 48);
  4506. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4507. update.ClickAction = (byte)data.ClickAction;
  4508. update.CRC = 0;
  4509. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4510. update.FullID = data.UUID;
  4511. update.ID = data.LocalId;
  4512. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4513. //update.JointPivot = Vector3.Zero;
  4514. //update.JointType = 0;
  4515. update.Material = data.Material;
  4516. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4517. if (data.ParentGroup.IsAttachment)
  4518. {
  4519. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4520. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4521. }
  4522. else
  4523. {
  4524. update.NameValue = Utils.EmptyBytes;
  4525. // The root part state is the canonical state for all parts of the object. The other part states in the
  4526. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4527. update.State = data.ParentGroup.RootPart.Shape.State;
  4528. }
  4529. // m_log.DebugFormat(
  4530. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4531. // update.State, data.Name, data.LocalId, Name);
  4532. update.ObjectData = objectData;
  4533. update.ParentID = data.ParentID;
  4534. update.PathBegin = data.Shape.PathBegin;
  4535. update.PathCurve = data.Shape.PathCurve;
  4536. update.PathEnd = data.Shape.PathEnd;
  4537. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4538. update.PathRevolutions = data.Shape.PathRevolutions;
  4539. update.PathScaleX = data.Shape.PathScaleX;
  4540. update.PathScaleY = data.Shape.PathScaleY;
  4541. update.PathShearX = data.Shape.PathShearX;
  4542. update.PathShearY = data.Shape.PathShearY;
  4543. update.PathSkew = data.Shape.PathSkew;
  4544. update.PathTaperX = data.Shape.PathTaperX;
  4545. update.PathTaperY = data.Shape.PathTaperY;
  4546. update.PathTwist = data.Shape.PathTwist;
  4547. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4548. update.PCode = data.Shape.PCode;
  4549. update.ProfileBegin = data.Shape.ProfileBegin;
  4550. update.ProfileCurve = data.Shape.ProfileCurve;
  4551. update.ProfileEnd = data.Shape.ProfileEnd;
  4552. update.ProfileHollow = data.Shape.ProfileHollow;
  4553. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4554. update.TextColor = data.GetTextColor().GetBytes(false);
  4555. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4556. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4557. update.Scale = data.Shape.Scale;
  4558. update.Text = Util.StringToBytes256(data.Text);
  4559. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4560. #region PrimFlags
  4561. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4562. // Don't send the CreateSelected flag to everyone
  4563. flags &= ~PrimFlags.CreateSelected;
  4564. if (recipientID == data.OwnerID)
  4565. {
  4566. if (data.CreateSelected)
  4567. {
  4568. // Only send this flag once, then unset it
  4569. flags |= PrimFlags.CreateSelected;
  4570. data.CreateSelected = false;
  4571. }
  4572. }
  4573. // m_log.DebugFormat(
  4574. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4575. // data.Name, update.FullID, flags, update.ID);
  4576. update.UpdateFlags = (uint)flags;
  4577. #endregion PrimFlags
  4578. if (data.Sound != UUID.Zero)
  4579. {
  4580. update.Sound = data.Sound;
  4581. update.OwnerID = data.OwnerID;
  4582. update.Gain = (float)data.SoundGain;
  4583. update.Radius = (float)data.SoundRadius;
  4584. update.Flags = data.SoundFlags;
  4585. }
  4586. switch ((PCode)data.Shape.PCode)
  4587. {
  4588. case PCode.Grass:
  4589. case PCode.Tree:
  4590. case PCode.NewTree:
  4591. update.Data = new byte[] { data.Shape.State };
  4592. break;
  4593. default:
  4594. update.Data = Utils.EmptyBytes;
  4595. break;
  4596. }
  4597. return update;
  4598. }
  4599. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4600. {
  4601. // TODO: Implement this
  4602. return null;
  4603. }
  4604. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4605. {
  4606. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4607. // TODO: don't create new blocks if recycling an old packet
  4608. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4609. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4610. packet.UUIDNameBlock[0].ID = profileId;
  4611. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4612. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4613. OutPacket(packet, ThrottleOutPacketType.Task);
  4614. }
  4615. public ulong GetGroupPowers(UUID groupID)
  4616. {
  4617. if (groupID == m_activeGroupID)
  4618. return m_activeGroupPowers;
  4619. if (m_groupPowers.ContainsKey(groupID))
  4620. return m_groupPowers[groupID];
  4621. return 0;
  4622. }
  4623. #endregion
  4624. /// <summary>
  4625. /// This is a different way of processing packets then ProcessInPacket
  4626. /// </summary>
  4627. protected virtual void RegisterLocalPacketHandlers()
  4628. {
  4629. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4630. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4631. // for each AgentUpdate packet.
  4632. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4633. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4634. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4635. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4636. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4637. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4638. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4639. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4640. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4641. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4642. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4643. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4644. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4645. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4646. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4647. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4648. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4649. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4650. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4651. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4652. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4653. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4654. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4655. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4656. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4657. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4658. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4659. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4660. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4661. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4662. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4663. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4664. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4665. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4666. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4667. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4668. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4669. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4670. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4671. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4672. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4673. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4674. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4675. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4676. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4677. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4678. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4679. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4680. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4681. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4682. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4683. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4684. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4685. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4686. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4687. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4688. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4689. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4690. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4691. // some clients will send out a separate ObjectImage packet for each face
  4692. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4693. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4694. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4695. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4696. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4697. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4698. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4699. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4700. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4701. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4702. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4703. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4704. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4705. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4706. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4707. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4708. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4709. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4710. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4711. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4712. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4713. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4714. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4715. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4716. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4717. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4718. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4719. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4720. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4721. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4722. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4723. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4724. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4725. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4726. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4727. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4728. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4729. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4730. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4731. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4732. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4733. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4734. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4735. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4736. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4737. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4738. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4739. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4740. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4741. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4742. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4743. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4744. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4745. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4746. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4747. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4748. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4749. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4750. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4751. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4752. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4753. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4754. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4755. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4756. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4757. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4758. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4759. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4760. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4761. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4762. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4763. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4764. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4765. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4766. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4767. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4768. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4769. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4770. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4771. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4772. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4773. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4774. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4775. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4776. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4777. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4778. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4779. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4780. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4781. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4782. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4783. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4784. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4785. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4786. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4787. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4788. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4789. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4790. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4791. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4792. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4793. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4794. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4795. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4796. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4797. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4798. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4799. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4800. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4801. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4802. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4803. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4804. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4805. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4806. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4807. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4808. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4809. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4810. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4811. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4812. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4813. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4814. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4815. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4816. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4817. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4818. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4819. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4820. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4821. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4822. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4823. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4824. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4825. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4826. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4827. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4828. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4829. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4830. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4831. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4832. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4833. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4834. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4835. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4836. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4837. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4838. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4839. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4840. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4841. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4842. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4843. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4844. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4845. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4846. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4847. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4848. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4849. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4850. }
  4851. #region Packet Handlers
  4852. public int TotalAgentUpdates { get; set; }
  4853. #region Scene/Avatar
  4854. // Threshold for body rotation to be a significant agent update
  4855. private const float QDELTA = 0.000001f;
  4856. // Threshold for camera rotation to be a significant agent update
  4857. private const float VDELTA = 0.01f;
  4858. /// <summary>
  4859. /// This checks the update significance against the last update made.
  4860. /// </summary>
  4861. /// <remarks>Can only be called by one thread at a time</remarks>
  4862. /// <returns></returns>
  4863. /// <param name='x'></param>
  4864. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4865. {
  4866. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  4867. }
  4868. /// <summary>
  4869. /// This checks the movement/state update significance against the last update made.
  4870. /// </summary>
  4871. /// <remarks>Can only be called by one thread at a time</remarks>
  4872. /// <returns></returns>
  4873. /// <param name='x'></param>
  4874. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4875. {
  4876. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  4877. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  4878. bool movementSignificant =
  4879. (qdelta1 > QDELTA) // significant if body rotation above threshold
  4880. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  4881. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  4882. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  4883. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  4884. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  4885. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  4886. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  4887. ;
  4888. //if (movementSignificant)
  4889. //{
  4890. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  4891. // qdelta1, qdelta2);
  4892. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  4893. // x.ControlFlags, x.Flags, x.Far, x.State);
  4894. //}
  4895. return movementSignificant;
  4896. }
  4897. /// <summary>
  4898. /// This checks the camera update significance against the last update made.
  4899. /// </summary>
  4900. /// <remarks>Can only be called by one thread at a time</remarks>
  4901. /// <returns></returns>
  4902. /// <param name='x'></param>
  4903. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4904. {
  4905. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  4906. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  4907. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  4908. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  4909. bool cameraSignificant =
  4910. (vdelta1 > VDELTA) ||
  4911. (vdelta2 > VDELTA) ||
  4912. (vdelta3 > VDELTA) ||
  4913. (vdelta4 > VDELTA)
  4914. ;
  4915. //if (cameraSignificant)
  4916. //{
  4917. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  4918. // x.CameraAtAxis, x.CameraCenter);
  4919. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  4920. // x.CameraLeftAxis, x.CameraUpAxis);
  4921. //}
  4922. return cameraSignificant;
  4923. }
  4924. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4925. {
  4926. // We got here, which means that something in agent update was significant
  4927. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4928. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4929. if (x.AgentID != AgentId || x.SessionID != SessionId)
  4930. return false;
  4931. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  4932. // to see what exactly changed
  4933. bool movement = CheckAgentMovementUpdateSignificance(x);
  4934. bool camera = CheckAgentCameraUpdateSignificance(x);
  4935. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  4936. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4937. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4938. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4939. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4940. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4941. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4942. m_thisAgentUpdateArgs.Far = x.Far;
  4943. m_thisAgentUpdateArgs.Flags = x.Flags;
  4944. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4945. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  4946. m_thisAgentUpdateArgs.State = x.State;
  4947. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4948. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4949. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  4950. // Was there a significant movement/state change?
  4951. if (movement)
  4952. {
  4953. if (handlerPreAgentUpdate != null)
  4954. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  4955. if (handlerAgentUpdate != null)
  4956. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  4957. }
  4958. // Was there a significant camera(s) change?
  4959. if (camera)
  4960. if (handlerAgentCameraUpdate != null)
  4961. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  4962. handlerAgentUpdate = null;
  4963. handlerPreAgentUpdate = null;
  4964. handlerAgentCameraUpdate = null;
  4965. PacketPool.Instance.ReturnPacket(packet);
  4966. return true;
  4967. }
  4968. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4969. {
  4970. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4971. // validate the agent owns the agentID and sessionID
  4972. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4973. money.AgentData.SessionID == sender.SessionId)
  4974. {
  4975. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4976. if (handlerMoneyTransferRequest != null)
  4977. {
  4978. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4979. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4980. Util.FieldToString(money.MoneyData.Description));
  4981. }
  4982. return true;
  4983. }
  4984. return false;
  4985. }
  4986. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4987. {
  4988. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4989. (ParcelGodMarkAsContentPacket)Packet;
  4990. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4991. if (ParcelGodMarkAsContentHandler != null)
  4992. {
  4993. ParcelGodMarkAsContentHandler(this,
  4994. ParcelGodMarkAsContent.AgentData.AgentID,
  4995. ParcelGodMarkAsContent.ParcelData.LocalID);
  4996. return true;
  4997. }
  4998. return false;
  4999. }
  5000. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  5001. {
  5002. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5003. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5004. if (FreezeUserHandler != null)
  5005. {
  5006. FreezeUserHandler(this,
  5007. FreezeUser.AgentData.AgentID,
  5008. FreezeUser.Data.Flags,
  5009. FreezeUser.Data.TargetID);
  5010. return true;
  5011. }
  5012. return false;
  5013. }
  5014. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5015. {
  5016. EjectUserPacket EjectUser =
  5017. (EjectUserPacket)Packet;
  5018. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5019. if (EjectUserHandler != null)
  5020. {
  5021. EjectUserHandler(this,
  5022. EjectUser.AgentData.AgentID,
  5023. EjectUser.Data.Flags,
  5024. EjectUser.Data.TargetID);
  5025. return true;
  5026. }
  5027. return false;
  5028. }
  5029. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5030. {
  5031. ParcelBuyPassPacket ParcelBuyPass =
  5032. (ParcelBuyPassPacket)Packet;
  5033. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5034. if (ParcelBuyPassHandler != null)
  5035. {
  5036. ParcelBuyPassHandler(this,
  5037. ParcelBuyPass.AgentData.AgentID,
  5038. ParcelBuyPass.ParcelData.LocalID);
  5039. return true;
  5040. }
  5041. return false;
  5042. }
  5043. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5044. {
  5045. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5046. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5047. {
  5048. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5049. if (handlerParcelBuy != null)
  5050. {
  5051. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5052. parcel.Data.IsGroupOwned,
  5053. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5054. parcel.ParcelData.Price,
  5055. false);
  5056. }
  5057. return true;
  5058. }
  5059. return false;
  5060. }
  5061. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5062. {
  5063. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5064. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5065. {
  5066. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5067. if (handlerUUIDGroupNameRequest != null)
  5068. {
  5069. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5070. }
  5071. }
  5072. return true;
  5073. }
  5074. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5075. {
  5076. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5077. if (m_genericPacketHandlers.Count == 0) return false;
  5078. if (gmpack.AgentData.SessionID != SessionId) return false;
  5079. GenericMessage handlerGenericMessage = null;
  5080. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5081. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5082. {
  5083. List<string> msg = new List<string>();
  5084. List<byte[]> msgBytes = new List<byte[]>();
  5085. if (handlerGenericMessage != null)
  5086. {
  5087. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5088. {
  5089. msg.Add(Util.FieldToString(block.Parameter));
  5090. msgBytes.Add(block.Parameter);
  5091. }
  5092. try
  5093. {
  5094. if (OnBinaryGenericMessage != null)
  5095. {
  5096. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5097. }
  5098. handlerGenericMessage(sender, method, msg);
  5099. return true;
  5100. }
  5101. catch (Exception e)
  5102. {
  5103. m_log.ErrorFormat(
  5104. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5105. }
  5106. }
  5107. }
  5108. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5109. return false;
  5110. }
  5111. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5112. {
  5113. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5114. if (ogpack.AgentData.SessionID != SessionId) return false;
  5115. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5116. if (handlerObjectGroupRequest != null)
  5117. {
  5118. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5119. {
  5120. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5121. }
  5122. }
  5123. return true;
  5124. }
  5125. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5126. {
  5127. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5128. if (viewer.AgentData.SessionID != SessionId) return false;
  5129. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5130. if (handlerViewerEffect != null)
  5131. {
  5132. int length = viewer.Effect.Length;
  5133. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5134. for (int i = 0; i < length; i++)
  5135. {
  5136. //copy the effects block arguments into the event handler arg.
  5137. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5138. argument.AgentID = viewer.Effect[i].AgentID;
  5139. argument.Color = viewer.Effect[i].Color;
  5140. argument.Duration = viewer.Effect[i].Duration;
  5141. argument.ID = viewer.Effect[i].ID;
  5142. argument.Type = viewer.Effect[i].Type;
  5143. argument.TypeData = viewer.Effect[i].TypeData;
  5144. args.Add(argument);
  5145. }
  5146. handlerViewerEffect(sender, args);
  5147. }
  5148. return true;
  5149. }
  5150. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5151. {
  5152. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5153. #region Packet Session and User Check
  5154. if (m_checkPackets)
  5155. {
  5156. if (avatarProperties.AgentData.SessionID != SessionId ||
  5157. avatarProperties.AgentData.AgentID != AgentId)
  5158. return true;
  5159. }
  5160. #endregion
  5161. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5162. if (handlerRequestAvatarProperties != null)
  5163. {
  5164. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5165. }
  5166. return true;
  5167. }
  5168. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5169. {
  5170. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5171. #region Packet Session and User Check
  5172. if (m_checkPackets)
  5173. {
  5174. if (inchatpack.AgentData.SessionID != SessionId ||
  5175. inchatpack.AgentData.AgentID != AgentId)
  5176. return true;
  5177. }
  5178. #endregion
  5179. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5180. byte[] message = inchatpack.ChatData.Message;
  5181. byte type = inchatpack.ChatData.Type;
  5182. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5183. // UUID fromAgentID = AgentId;
  5184. int channel = inchatpack.ChatData.Channel;
  5185. if (OnChatFromClient != null)
  5186. {
  5187. OSChatMessage args = new OSChatMessage();
  5188. args.Channel = channel;
  5189. args.From = fromName;
  5190. args.Message = Utils.BytesToString(message);
  5191. args.Type = (ChatTypeEnum)type;
  5192. args.Position = fromPos;
  5193. args.Scene = Scene;
  5194. args.Sender = this;
  5195. args.SenderUUID = this.AgentId;
  5196. ChatMessage handlerChatFromClient = OnChatFromClient;
  5197. if (handlerChatFromClient != null)
  5198. handlerChatFromClient(this, args);
  5199. }
  5200. return true;
  5201. }
  5202. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5203. {
  5204. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5205. #region Packet Session and User Check
  5206. if (m_checkPackets)
  5207. {
  5208. if (avatarProps.AgentData.SessionID != SessionId ||
  5209. avatarProps.AgentData.AgentID != AgentId)
  5210. return true;
  5211. }
  5212. #endregion
  5213. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5214. if (handlerUpdateAvatarProperties != null)
  5215. {
  5216. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5217. UserProfileData UserProfile = new UserProfileData();
  5218. UserProfile.ID = AgentId;
  5219. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5220. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5221. UserProfile.FirstLifeImage = Properties.FLImageID;
  5222. UserProfile.Image = Properties.ImageID;
  5223. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5224. UserProfile.UserFlags &= ~3;
  5225. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5226. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5227. handlerUpdateAvatarProperties(this, UserProfile);
  5228. }
  5229. return true;
  5230. }
  5231. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5232. {
  5233. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5234. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5235. #region Packet Session and User Check
  5236. if (m_checkPackets)
  5237. {
  5238. if (rdialog.AgentData.SessionID != SessionId ||
  5239. rdialog.AgentData.AgentID != AgentId)
  5240. return true;
  5241. }
  5242. #endregion
  5243. int ch = rdialog.Data.ChatChannel;
  5244. byte[] msg = rdialog.Data.ButtonLabel;
  5245. if (OnChatFromClient != null)
  5246. {
  5247. OSChatMessage args = new OSChatMessage();
  5248. args.Channel = ch;
  5249. args.From = String.Empty;
  5250. args.Message = Utils.BytesToString(msg);
  5251. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5252. args.Position = new Vector3();
  5253. args.Scene = Scene;
  5254. args.Sender = this;
  5255. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5256. if (handlerChatFromClient2 != null)
  5257. handlerChatFromClient2(this, args);
  5258. }
  5259. return true;
  5260. }
  5261. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5262. {
  5263. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5264. #region Packet Session and User Check
  5265. if (m_checkPackets)
  5266. {
  5267. if (msgpack.AgentData.SessionID != SessionId ||
  5268. msgpack.AgentData.AgentID != AgentId)
  5269. return true;
  5270. }
  5271. #endregion
  5272. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5273. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5274. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5275. if (handlerInstantMessage != null)
  5276. {
  5277. GridInstantMessage im = new GridInstantMessage(Scene,
  5278. msgpack.AgentData.AgentID,
  5279. IMfromName,
  5280. msgpack.MessageBlock.ToAgentID,
  5281. msgpack.MessageBlock.Dialog,
  5282. msgpack.MessageBlock.FromGroup,
  5283. IMmessage,
  5284. msgpack.MessageBlock.ID,
  5285. msgpack.MessageBlock.Offline != 0 ? true : false,
  5286. msgpack.MessageBlock.Position,
  5287. msgpack.MessageBlock.BinaryBucket,
  5288. true);
  5289. handlerInstantMessage(this, im);
  5290. }
  5291. return true;
  5292. }
  5293. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5294. {
  5295. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5296. #region Packet Session and User Check
  5297. if (m_checkPackets)
  5298. {
  5299. if (afriendpack.AgentData.SessionID != SessionId ||
  5300. afriendpack.AgentData.AgentID != AgentId)
  5301. return true;
  5302. }
  5303. #endregion
  5304. // My guess is this is the folder to stick the calling card into
  5305. List<UUID> callingCardFolders = new List<UUID>();
  5306. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5307. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5308. {
  5309. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5310. }
  5311. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5312. if (handlerApproveFriendRequest != null)
  5313. {
  5314. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5315. }
  5316. return true;
  5317. }
  5318. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5319. {
  5320. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5321. #region Packet Session and User Check
  5322. if (m_checkPackets)
  5323. {
  5324. if (dfriendpack.AgentData.SessionID != SessionId ||
  5325. dfriendpack.AgentData.AgentID != AgentId)
  5326. return true;
  5327. }
  5328. #endregion
  5329. if (OnDenyFriendRequest != null)
  5330. {
  5331. OnDenyFriendRequest(this,
  5332. dfriendpack.TransactionBlock.TransactionID,
  5333. null);
  5334. }
  5335. return true;
  5336. }
  5337. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5338. {
  5339. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5340. #region Packet Session and User Check
  5341. if (m_checkPackets)
  5342. {
  5343. if (tfriendpack.AgentData.SessionID != SessionId ||
  5344. tfriendpack.AgentData.AgentID != AgentId)
  5345. return true;
  5346. }
  5347. #endregion
  5348. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5349. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5350. if (TerminateFriendshipHandler != null)
  5351. {
  5352. TerminateFriendshipHandler(this, exFriendID);
  5353. return true;
  5354. }
  5355. return false;
  5356. }
  5357. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5358. {
  5359. FindAgentPacket FindAgent =
  5360. (FindAgentPacket)Packet;
  5361. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5362. if (FindAgentHandler != null)
  5363. {
  5364. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5365. return true;
  5366. }
  5367. return false;
  5368. }
  5369. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5370. {
  5371. TrackAgentPacket TrackAgent =
  5372. (TrackAgentPacket)Packet;
  5373. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5374. if (TrackAgentHandler != null)
  5375. {
  5376. TrackAgentHandler(this,
  5377. TrackAgent.AgentData.AgentID,
  5378. TrackAgent.TargetData.PreyID);
  5379. return true;
  5380. }
  5381. return false;
  5382. }
  5383. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5384. {
  5385. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5386. #region Packet Session and User Check
  5387. if (m_checkPackets)
  5388. {
  5389. if (rezPacket.AgentData.SessionID != SessionId ||
  5390. rezPacket.AgentData.AgentID != AgentId)
  5391. return true;
  5392. }
  5393. #endregion
  5394. RezObject handlerRezObject = OnRezObject;
  5395. if (handlerRezObject != null)
  5396. {
  5397. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5398. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5399. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5400. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5401. rezPacket.RezData.FromTaskID);
  5402. }
  5403. return true;
  5404. }
  5405. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5406. {
  5407. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5408. #region Packet Session and User Check
  5409. if (m_checkPackets)
  5410. {
  5411. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5412. DeRezPacket.AgentData.AgentID != AgentId)
  5413. return true;
  5414. }
  5415. #endregion
  5416. DeRezObject handlerDeRezObject = OnDeRezObject;
  5417. if (handlerDeRezObject != null)
  5418. {
  5419. List<uint> deRezIDs = new List<uint>();
  5420. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5421. DeRezPacket.ObjectData)
  5422. {
  5423. deRezIDs.Add(data.ObjectLocalID);
  5424. }
  5425. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5426. // values given by a Second Life client
  5427. handlerDeRezObject(this, deRezIDs,
  5428. DeRezPacket.AgentBlock.GroupID,
  5429. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5430. DeRezPacket.AgentBlock.DestinationID);
  5431. }
  5432. return true;
  5433. }
  5434. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5435. {
  5436. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5437. #region Packet Session and User Check
  5438. if (m_checkPackets)
  5439. {
  5440. if (modify.AgentData.SessionID != SessionId ||
  5441. modify.AgentData.AgentID != AgentId)
  5442. return true;
  5443. }
  5444. #endregion
  5445. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5446. if (modify.ParcelData.Length > 0)
  5447. {
  5448. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5449. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5450. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5451. if (OnModifyTerrain != null)
  5452. {
  5453. for (int i = 0; i < modify.ParcelData.Length; i++)
  5454. {
  5455. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5456. if (handlerModifyTerrain != null)
  5457. {
  5458. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5459. modify.ModifyBlock.BrushSize,
  5460. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5461. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5462. modify.ParcelData[i].East, AgentId);
  5463. }
  5464. }
  5465. }
  5466. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5467. }
  5468. return true;
  5469. }
  5470. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5471. {
  5472. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5473. if (handlerRegionHandShakeReply != null)
  5474. {
  5475. handlerRegionHandShakeReply(this);
  5476. }
  5477. return true;
  5478. }
  5479. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5480. {
  5481. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5482. if (handlerRequestWearables != null)
  5483. {
  5484. handlerRequestWearables(sender);
  5485. }
  5486. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5487. if (handlerRequestAvatarsData != null)
  5488. {
  5489. handlerRequestAvatarsData(this);
  5490. }
  5491. return true;
  5492. }
  5493. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5494. {
  5495. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5496. #region Packet Session and User Check
  5497. if (m_checkPackets)
  5498. {
  5499. if (appear.AgentData.SessionID != SessionId ||
  5500. appear.AgentData.AgentID != AgentId)
  5501. return true;
  5502. }
  5503. #endregion
  5504. SetAppearance handlerSetAppearance = OnSetAppearance;
  5505. if (handlerSetAppearance != null)
  5506. {
  5507. // Temporarily protect ourselves from the mantis #951 failure.
  5508. // However, we could do this for several other handlers where a failure isn't terminal
  5509. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5510. Vector3 avSize = appear.AgentData.Size;
  5511. try
  5512. {
  5513. byte[] visualparams = new byte[appear.VisualParam.Length];
  5514. for (int i = 0; i < appear.VisualParam.Length; i++)
  5515. visualparams[i] = appear.VisualParam[i].ParamValue;
  5516. //var b = appear.WearableData[0];
  5517. Primitive.TextureEntry te = null;
  5518. if (appear.ObjectData.TextureEntry.Length > 1)
  5519. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5520. WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
  5521. for (int i=0; i<appear.WearableData.Length;i++)
  5522. cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)};
  5523. handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
  5524. }
  5525. catch (Exception e)
  5526. {
  5527. m_log.ErrorFormat(
  5528. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5529. e);
  5530. }
  5531. }
  5532. return true;
  5533. }
  5534. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5535. {
  5536. if (OnAvatarNowWearing != null)
  5537. {
  5538. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5539. #region Packet Session and User Check
  5540. if (m_checkPackets)
  5541. {
  5542. if (nowWearing.AgentData.SessionID != SessionId ||
  5543. nowWearing.AgentData.AgentID != AgentId)
  5544. return true;
  5545. }
  5546. #endregion
  5547. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5548. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5549. {
  5550. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5551. AvatarWearingArgs.Wearable wearable =
  5552. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5553. nowWearing.WearableData[i].WearableType);
  5554. wearingArgs.NowWearing.Add(wearable);
  5555. }
  5556. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5557. if (handlerAvatarNowWearing != null)
  5558. {
  5559. handlerAvatarNowWearing(this, wearingArgs);
  5560. }
  5561. }
  5562. return true;
  5563. }
  5564. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5565. {
  5566. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5567. if (handlerRezSingleAttachment != null)
  5568. {
  5569. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5570. #region Packet Session and User Check
  5571. if (m_checkPackets)
  5572. {
  5573. if (rez.AgentData.SessionID != SessionId ||
  5574. rez.AgentData.AgentID != AgentId)
  5575. return true;
  5576. }
  5577. #endregion
  5578. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5579. rez.ObjectData.AttachmentPt);
  5580. }
  5581. return true;
  5582. }
  5583. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5584. {
  5585. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5586. if (handlerRezMultipleAttachments != null)
  5587. {
  5588. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5589. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5590. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5591. handlerRezMultipleAttachments(this, rezlist);
  5592. }
  5593. return true;
  5594. }
  5595. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5596. {
  5597. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5598. if (handlerDetachAttachmentIntoInv != null)
  5599. {
  5600. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5601. #region Packet Session and User Check
  5602. // UNSUPPORTED ON THIS PACKET
  5603. #endregion
  5604. UUID itemID = detachtoInv.ObjectData.ItemID;
  5605. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5606. handlerDetachAttachmentIntoInv(itemID, this);
  5607. }
  5608. return true;
  5609. }
  5610. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5611. {
  5612. if (OnObjectAttach != null)
  5613. {
  5614. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5615. #region Packet Session and User Check
  5616. if (m_checkPackets)
  5617. {
  5618. if (att.AgentData.SessionID != SessionId ||
  5619. att.AgentData.AgentID != AgentId)
  5620. return true;
  5621. }
  5622. #endregion
  5623. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5624. if (handlerObjectAttach != null)
  5625. {
  5626. if (att.ObjectData.Length > 0)
  5627. {
  5628. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5629. }
  5630. }
  5631. }
  5632. return true;
  5633. }
  5634. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5635. {
  5636. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5637. #region Packet Session and User Check
  5638. if (m_checkPackets)
  5639. {
  5640. if (dett.AgentData.SessionID != SessionId ||
  5641. dett.AgentData.AgentID != AgentId)
  5642. return true;
  5643. }
  5644. #endregion
  5645. for (int j = 0; j < dett.ObjectData.Length; j++)
  5646. {
  5647. uint obj = dett.ObjectData[j].ObjectLocalID;
  5648. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5649. if (handlerObjectDetach != null)
  5650. {
  5651. handlerObjectDetach(obj, this);
  5652. }
  5653. }
  5654. return true;
  5655. }
  5656. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5657. {
  5658. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5659. #region Packet Session and User Check
  5660. if (m_checkPackets)
  5661. {
  5662. if (dropp.AgentData.SessionID != SessionId ||
  5663. dropp.AgentData.AgentID != AgentId)
  5664. return true;
  5665. }
  5666. #endregion
  5667. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5668. {
  5669. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5670. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5671. if (handlerObjectDrop != null)
  5672. {
  5673. handlerObjectDrop(obj, this);
  5674. }
  5675. }
  5676. return true;
  5677. }
  5678. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5679. {
  5680. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5681. #region Packet Session and User Check
  5682. if (m_checkPackets)
  5683. {
  5684. if (run.AgentData.SessionID != SessionId ||
  5685. run.AgentData.AgentID != AgentId)
  5686. return true;
  5687. }
  5688. #endregion
  5689. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5690. if (handlerSetAlwaysRun != null)
  5691. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5692. return true;
  5693. }
  5694. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5695. {
  5696. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5697. if (handlerCompleteMovementToRegion != null)
  5698. {
  5699. handlerCompleteMovementToRegion(sender, true);
  5700. }
  5701. handlerCompleteMovementToRegion = null;
  5702. return true;
  5703. }
  5704. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5705. {
  5706. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5707. #region Packet Session and User Check
  5708. if (m_checkPackets)
  5709. {
  5710. if (AgentAni.AgentData.SessionID != SessionId ||
  5711. AgentAni.AgentData.AgentID != AgentId)
  5712. return true;
  5713. }
  5714. #endregion
  5715. StartAnim handlerStartAnim = null;
  5716. StopAnim handlerStopAnim = null;
  5717. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5718. {
  5719. if (AgentAni.AnimationList[i].StartAnim)
  5720. {
  5721. handlerStartAnim = OnStartAnim;
  5722. if (handlerStartAnim != null)
  5723. {
  5724. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5725. }
  5726. }
  5727. else
  5728. {
  5729. handlerStopAnim = OnStopAnim;
  5730. if (handlerStopAnim != null)
  5731. {
  5732. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5733. }
  5734. }
  5735. }
  5736. return true;
  5737. }
  5738. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5739. {
  5740. if (OnAgentRequestSit != null)
  5741. {
  5742. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5743. #region Packet Session and User Check
  5744. if (m_checkPackets)
  5745. {
  5746. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5747. agentRequestSit.AgentData.AgentID != AgentId)
  5748. return true;
  5749. }
  5750. #endregion
  5751. if (SceneAgent.IsChildAgent)
  5752. {
  5753. SendCantSitBecauseChildAgentResponse();
  5754. return true;
  5755. }
  5756. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5757. if (handlerAgentRequestSit != null)
  5758. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5759. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5760. }
  5761. return true;
  5762. }
  5763. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5764. {
  5765. if (OnAgentSit != null)
  5766. {
  5767. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5768. #region Packet Session and User Check
  5769. if (m_checkPackets)
  5770. {
  5771. if (agentSit.AgentData.SessionID != SessionId ||
  5772. agentSit.AgentData.AgentID != AgentId)
  5773. return true;
  5774. }
  5775. #endregion
  5776. if (SceneAgent.IsChildAgent)
  5777. {
  5778. SendCantSitBecauseChildAgentResponse();
  5779. return true;
  5780. }
  5781. AgentSit handlerAgentSit = OnAgentSit;
  5782. if (handlerAgentSit != null)
  5783. {
  5784. OnAgentSit(this, agentSit.AgentData.AgentID);
  5785. }
  5786. }
  5787. return true;
  5788. }
  5789. /// <summary>
  5790. /// Used when a child agent gets a sit response which should not be fulfilled.
  5791. /// </summary>
  5792. private void SendCantSitBecauseChildAgentResponse()
  5793. {
  5794. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5795. }
  5796. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5797. {
  5798. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5799. #region Packet Session and User Check
  5800. if (m_checkPackets)
  5801. {
  5802. // UNSUPPORTED ON THIS PACKET
  5803. }
  5804. #endregion
  5805. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5806. if (handlerSoundTrigger != null)
  5807. {
  5808. // UUIDS are sent as zeroes by the client, substitute agent's id
  5809. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5810. AgentId, AgentId,
  5811. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5812. soundTriggerPacket.SoundData.Handle, 0);
  5813. }
  5814. return true;
  5815. }
  5816. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5817. {
  5818. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5819. #region Packet Session and User Check
  5820. if (m_checkPackets)
  5821. {
  5822. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5823. avRequestQuery.AgentData.AgentID != AgentId)
  5824. return true;
  5825. }
  5826. #endregion
  5827. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5828. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5829. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5830. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5831. if (handlerAvatarPickerRequest != null)
  5832. {
  5833. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5834. Utils.BytesToString(querydata.Name));
  5835. }
  5836. return true;
  5837. }
  5838. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5839. {
  5840. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5841. #region Packet Session and User Check
  5842. if (m_checkPackets)
  5843. {
  5844. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5845. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5846. return true;
  5847. }
  5848. #endregion
  5849. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5850. if (handlerAgentDataUpdateRequest != null)
  5851. {
  5852. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5853. }
  5854. return true;
  5855. }
  5856. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5857. {
  5858. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5859. if (handlerUserInfoRequest != null)
  5860. {
  5861. handlerUserInfoRequest(this);
  5862. }
  5863. else
  5864. {
  5865. SendUserInfoReply(false, true, "");
  5866. }
  5867. return true;
  5868. }
  5869. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5870. {
  5871. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5872. #region Packet Session and User Check
  5873. if (m_checkPackets)
  5874. {
  5875. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5876. updateUserInfo.AgentData.AgentID != AgentId)
  5877. return true;
  5878. }
  5879. #endregion
  5880. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5881. if (handlerUpdateUserInfo != null)
  5882. {
  5883. bool visible = true;
  5884. string DirectoryVisibility =
  5885. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5886. if (DirectoryVisibility == "hidden")
  5887. visible = false;
  5888. handlerUpdateUserInfo(
  5889. updateUserInfo.UserData.IMViaEMail,
  5890. visible, this);
  5891. }
  5892. return true;
  5893. }
  5894. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5895. {
  5896. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5897. #region Packet Session and User Check
  5898. if (m_checkPackets)
  5899. {
  5900. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5901. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5902. return true;
  5903. }
  5904. #endregion
  5905. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5906. {
  5907. // Linden Client limitation..
  5908. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5909. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5910. {
  5911. ScenePresence avatar = null;
  5912. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5913. {
  5914. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5915. {
  5916. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5917. }
  5918. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5919. {
  5920. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5921. }
  5922. }
  5923. }
  5924. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5925. if (handlerSetStartLocationRequest != null)
  5926. {
  5927. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5928. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5929. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5930. }
  5931. }
  5932. return true;
  5933. }
  5934. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5935. {
  5936. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5937. #region Packet Session and User Check
  5938. if (m_checkPackets)
  5939. {
  5940. if (atpack.AgentData.SessionID != SessionId ||
  5941. atpack.AgentData.AgentID != AgentId)
  5942. return true;
  5943. }
  5944. #endregion
  5945. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5946. return true;
  5947. }
  5948. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5949. {
  5950. m_udpClient.IsPaused = true;
  5951. return true;
  5952. }
  5953. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5954. {
  5955. m_udpClient.IsPaused = false;
  5956. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5957. return true;
  5958. }
  5959. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5960. {
  5961. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5962. if (handlerForceReleaseControls != null)
  5963. {
  5964. handlerForceReleaseControls(this, AgentId);
  5965. }
  5966. return true;
  5967. }
  5968. #endregion Scene/Avatar
  5969. #region Objects/m_sceneObjects
  5970. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5971. {
  5972. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5973. #region Packet Session and User Check
  5974. if (m_checkPackets)
  5975. {
  5976. if (link.AgentData.SessionID != SessionId ||
  5977. link.AgentData.AgentID != AgentId)
  5978. return true;
  5979. }
  5980. #endregion
  5981. uint parentprimid = 0;
  5982. List<uint> childrenprims = new List<uint>();
  5983. if (link.ObjectData.Length > 1)
  5984. {
  5985. parentprimid = link.ObjectData[0].ObjectLocalID;
  5986. for (int i = 1; i < link.ObjectData.Length; i++)
  5987. {
  5988. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5989. }
  5990. }
  5991. LinkObjects handlerLinkObjects = OnLinkObjects;
  5992. if (handlerLinkObjects != null)
  5993. {
  5994. handlerLinkObjects(this, parentprimid, childrenprims);
  5995. }
  5996. return true;
  5997. }
  5998. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  5999. {
  6000. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6001. #region Packet Session and User Check
  6002. if (m_checkPackets)
  6003. {
  6004. if (delink.AgentData.SessionID != SessionId ||
  6005. delink.AgentData.AgentID != AgentId)
  6006. return true;
  6007. }
  6008. #endregion
  6009. // It appears the prim at index 0 is not always the root prim (for
  6010. // instance, when one prim of a link set has been edited independently
  6011. // of the others). Therefore, we'll pass all the ids onto the delink
  6012. // method for it to decide which is the root.
  6013. List<uint> prims = new List<uint>();
  6014. for (int i = 0; i < delink.ObjectData.Length; i++)
  6015. {
  6016. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6017. }
  6018. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6019. if (handlerDelinkObjects != null)
  6020. {
  6021. handlerDelinkObjects(prims, this);
  6022. }
  6023. return true;
  6024. }
  6025. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6026. {
  6027. if (OnAddPrim != null)
  6028. {
  6029. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6030. #region Packet Session and User Check
  6031. if (m_checkPackets)
  6032. {
  6033. if (addPacket.AgentData.SessionID != SessionId ||
  6034. addPacket.AgentData.AgentID != AgentId)
  6035. return true;
  6036. }
  6037. #endregion
  6038. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6039. // m_log.Info("[REZData]: " + addPacket.ToString());
  6040. //BypassRaycast: 1
  6041. //RayStart: <69.79469, 158.2652, 98.40343>
  6042. //RayEnd: <61.97724, 141.995, 92.58341>
  6043. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6044. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6045. //object from rezing initially
  6046. AddNewPrim handlerAddPrim = OnAddPrim;
  6047. if (handlerAddPrim != null)
  6048. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6049. }
  6050. return true;
  6051. }
  6052. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6053. {
  6054. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6055. #region Packet Session and User Check
  6056. if (m_checkPackets)
  6057. {
  6058. if (shapePacket.AgentData.SessionID != SessionId ||
  6059. shapePacket.AgentData.AgentID != AgentId)
  6060. return true;
  6061. }
  6062. #endregion
  6063. UpdateShape handlerUpdatePrimShape = null;
  6064. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6065. {
  6066. handlerUpdatePrimShape = OnUpdatePrimShape;
  6067. if (handlerUpdatePrimShape != null)
  6068. {
  6069. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6070. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6071. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6072. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6073. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6074. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6075. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6076. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6077. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6078. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6079. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6080. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6081. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6082. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6083. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6084. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6085. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6086. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6087. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6088. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6089. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6090. shapeData);
  6091. }
  6092. }
  6093. return true;
  6094. }
  6095. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6096. {
  6097. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6098. #region Packet Session and User Check
  6099. if (m_checkPackets)
  6100. {
  6101. if (extraPar.AgentData.SessionID != SessionId ||
  6102. extraPar.AgentData.AgentID != AgentId)
  6103. return true;
  6104. }
  6105. #endregion
  6106. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6107. if (handlerUpdateExtraParams != null)
  6108. {
  6109. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6110. {
  6111. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6112. extraPar.ObjectData[i].ParamType,
  6113. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6114. }
  6115. }
  6116. return true;
  6117. }
  6118. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6119. {
  6120. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6121. #region Packet Session and User Check
  6122. if (m_checkPackets)
  6123. {
  6124. if (dupe.AgentData.SessionID != SessionId ||
  6125. dupe.AgentData.AgentID != AgentId)
  6126. return true;
  6127. }
  6128. #endregion
  6129. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6130. ObjectDuplicate handlerObjectDuplicate = null;
  6131. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6132. {
  6133. handlerObjectDuplicate = OnObjectDuplicate;
  6134. if (handlerObjectDuplicate != null)
  6135. {
  6136. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6137. dupe.SharedData.DuplicateFlags, AgentId,
  6138. m_activeGroupID);
  6139. }
  6140. }
  6141. return true;
  6142. }
  6143. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6144. {
  6145. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6146. #region Packet Session and User Check
  6147. if (m_checkPackets)
  6148. {
  6149. if (incomingRequest.AgentData.SessionID != SessionId ||
  6150. incomingRequest.AgentData.AgentID != AgentId)
  6151. return true;
  6152. }
  6153. #endregion
  6154. ObjectRequest handlerObjectRequest = null;
  6155. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6156. {
  6157. handlerObjectRequest = OnObjectRequest;
  6158. if (handlerObjectRequest != null)
  6159. {
  6160. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6161. }
  6162. }
  6163. return true;
  6164. }
  6165. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6166. {
  6167. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6168. #region Packet Session and User Check
  6169. if (m_checkPackets)
  6170. {
  6171. if (incomingselect.AgentData.SessionID != SessionId ||
  6172. incomingselect.AgentData.AgentID != AgentId)
  6173. return true;
  6174. }
  6175. #endregion
  6176. ObjectSelect handlerObjectSelect = null;
  6177. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6178. {
  6179. handlerObjectSelect = OnObjectSelect;
  6180. if (handlerObjectSelect != null)
  6181. {
  6182. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6183. }
  6184. }
  6185. return true;
  6186. }
  6187. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6188. {
  6189. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6190. #region Packet Session and User Check
  6191. if (m_checkPackets)
  6192. {
  6193. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6194. incomingdeselect.AgentData.AgentID != AgentId)
  6195. return true;
  6196. }
  6197. #endregion
  6198. ObjectDeselect handlerObjectDeselect = null;
  6199. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6200. {
  6201. handlerObjectDeselect = OnObjectDeselect;
  6202. if (handlerObjectDeselect != null)
  6203. {
  6204. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6205. }
  6206. }
  6207. return true;
  6208. }
  6209. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6210. {
  6211. // DEPRECATED: but till libsecondlife removes it, people will use it
  6212. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6213. #region Packet Session and User Check
  6214. if (m_checkPackets)
  6215. {
  6216. if (position.AgentData.SessionID != SessionId ||
  6217. position.AgentData.AgentID != AgentId)
  6218. return true;
  6219. }
  6220. #endregion
  6221. for (int i = 0; i < position.ObjectData.Length; i++)
  6222. {
  6223. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6224. if (handlerUpdateVector != null)
  6225. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6226. }
  6227. return true;
  6228. }
  6229. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6230. {
  6231. // DEPRECATED: but till libsecondlife removes it, people will use it
  6232. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6233. #region Packet Session and User Check
  6234. if (m_checkPackets)
  6235. {
  6236. if (scale.AgentData.SessionID != SessionId ||
  6237. scale.AgentData.AgentID != AgentId)
  6238. return true;
  6239. }
  6240. #endregion
  6241. for (int i = 0; i < scale.ObjectData.Length; i++)
  6242. {
  6243. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6244. if (handlerUpdatePrimGroupScale != null)
  6245. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6246. }
  6247. return true;
  6248. }
  6249. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6250. {
  6251. // DEPRECATED: but till libsecondlife removes it, people will use it
  6252. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6253. #region Packet Session and User Check
  6254. if (m_checkPackets)
  6255. {
  6256. if (rotation.AgentData.SessionID != SessionId ||
  6257. rotation.AgentData.AgentID != AgentId)
  6258. return true;
  6259. }
  6260. #endregion
  6261. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6262. {
  6263. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6264. if (handlerUpdatePrimRotation != null)
  6265. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6266. }
  6267. return true;
  6268. }
  6269. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6270. {
  6271. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6272. #region Packet Session and User Check
  6273. if (m_checkPackets)
  6274. {
  6275. if (flags.AgentData.SessionID != SessionId ||
  6276. flags.AgentData.AgentID != AgentId)
  6277. return true;
  6278. }
  6279. #endregion
  6280. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6281. if (handlerUpdatePrimFlags != null)
  6282. {
  6283. // byte[] data = Pack.ToBytes();
  6284. // 46,47,48 are special positions within the packet
  6285. // This may change so perhaps we need a better way
  6286. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6287. /*
  6288. bool UsePhysics = (data[46] != 0) ? true : false;
  6289. bool IsTemporary = (data[47] != 0) ? true : false;
  6290. bool IsPhantom = (data[48] != 0) ? true : false;
  6291. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6292. */
  6293. bool UsePhysics = flags.AgentData.UsePhysics;
  6294. bool IsPhantom = flags.AgentData.IsPhantom;
  6295. bool IsTemporary = flags.AgentData.IsTemporary;
  6296. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6297. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6298. if (blocks == null || blocks.Length == 0)
  6299. {
  6300. physdata.PhysShapeType = PhysShapeType.invalid;
  6301. }
  6302. else
  6303. {
  6304. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6305. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6306. physdata.Bounce = phsblock.Restitution;
  6307. physdata.Density = phsblock.Density;
  6308. physdata.Friction = phsblock.Friction;
  6309. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6310. }
  6311. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6312. }
  6313. return true;
  6314. }
  6315. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6316. {
  6317. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6318. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6319. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6320. {
  6321. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6322. if (handlerUpdatePrimTexture != null)
  6323. {
  6324. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6325. imagePack.ObjectData[i].TextureEntry, this);
  6326. }
  6327. }
  6328. return true;
  6329. }
  6330. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6331. {
  6332. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6333. #region Packet Session and User Check
  6334. if (m_checkPackets)
  6335. {
  6336. if (grab.AgentData.SessionID != SessionId ||
  6337. grab.AgentData.AgentID != AgentId)
  6338. return true;
  6339. }
  6340. #endregion
  6341. GrabObject handlerGrabObject = OnGrabObject;
  6342. if (handlerGrabObject != null)
  6343. {
  6344. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6345. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6346. {
  6347. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6348. {
  6349. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6350. arg.Binormal = surfaceInfo.Binormal;
  6351. arg.FaceIndex = surfaceInfo.FaceIndex;
  6352. arg.Normal = surfaceInfo.Normal;
  6353. arg.Position = surfaceInfo.Position;
  6354. arg.STCoord = surfaceInfo.STCoord;
  6355. arg.UVCoord = surfaceInfo.UVCoord;
  6356. touchArgs.Add(arg);
  6357. }
  6358. }
  6359. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6360. }
  6361. return true;
  6362. }
  6363. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6364. {
  6365. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6366. #region Packet Session and User Check
  6367. if (m_checkPackets)
  6368. {
  6369. if (grabUpdate.AgentData.SessionID != SessionId ||
  6370. grabUpdate.AgentData.AgentID != AgentId)
  6371. return true;
  6372. }
  6373. #endregion
  6374. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6375. if (handlerGrabUpdate != null)
  6376. {
  6377. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6378. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6379. {
  6380. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6381. {
  6382. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6383. arg.Binormal = surfaceInfo.Binormal;
  6384. arg.FaceIndex = surfaceInfo.FaceIndex;
  6385. arg.Normal = surfaceInfo.Normal;
  6386. arg.Position = surfaceInfo.Position;
  6387. arg.STCoord = surfaceInfo.STCoord;
  6388. arg.UVCoord = surfaceInfo.UVCoord;
  6389. touchArgs.Add(arg);
  6390. }
  6391. }
  6392. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6393. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6394. }
  6395. return true;
  6396. }
  6397. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6398. {
  6399. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6400. #region Packet Session and User Check
  6401. if (m_checkPackets)
  6402. {
  6403. if (deGrab.AgentData.SessionID != SessionId ||
  6404. deGrab.AgentData.AgentID != AgentId)
  6405. return true;
  6406. }
  6407. #endregion
  6408. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6409. if (handlerDeGrabObject != null)
  6410. {
  6411. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6412. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6413. {
  6414. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6415. {
  6416. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6417. arg.Binormal = surfaceInfo.Binormal;
  6418. arg.FaceIndex = surfaceInfo.FaceIndex;
  6419. arg.Normal = surfaceInfo.Normal;
  6420. arg.Position = surfaceInfo.Position;
  6421. arg.STCoord = surfaceInfo.STCoord;
  6422. arg.UVCoord = surfaceInfo.UVCoord;
  6423. touchArgs.Add(arg);
  6424. }
  6425. }
  6426. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6427. }
  6428. return true;
  6429. }
  6430. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6431. {
  6432. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6433. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6434. #region Packet Session and User Check
  6435. if (m_checkPackets)
  6436. {
  6437. if (spinStart.AgentData.SessionID != SessionId ||
  6438. spinStart.AgentData.AgentID != AgentId)
  6439. return true;
  6440. }
  6441. #endregion
  6442. SpinStart handlerSpinStart = OnSpinStart;
  6443. if (handlerSpinStart != null)
  6444. {
  6445. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6446. }
  6447. return true;
  6448. }
  6449. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6450. {
  6451. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6452. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6453. #region Packet Session and User Check
  6454. if (m_checkPackets)
  6455. {
  6456. if (spinUpdate.AgentData.SessionID != SessionId ||
  6457. spinUpdate.AgentData.AgentID != AgentId)
  6458. return true;
  6459. }
  6460. #endregion
  6461. Vector3 axis;
  6462. float angle;
  6463. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6464. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6465. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6466. if (handlerSpinUpdate != null)
  6467. {
  6468. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6469. }
  6470. return true;
  6471. }
  6472. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6473. {
  6474. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6475. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6476. #region Packet Session and User Check
  6477. if (m_checkPackets)
  6478. {
  6479. if (spinStop.AgentData.SessionID != SessionId ||
  6480. spinStop.AgentData.AgentID != AgentId)
  6481. return true;
  6482. }
  6483. #endregion
  6484. SpinStop handlerSpinStop = OnSpinStop;
  6485. if (handlerSpinStop != null)
  6486. {
  6487. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6488. }
  6489. return true;
  6490. }
  6491. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6492. {
  6493. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6494. #region Packet Session and User Check
  6495. if (m_checkPackets)
  6496. {
  6497. if (objDes.AgentData.SessionID != SessionId ||
  6498. objDes.AgentData.AgentID != AgentId)
  6499. return true;
  6500. }
  6501. #endregion
  6502. GenericCall7 handlerObjectDescription = null;
  6503. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6504. {
  6505. handlerObjectDescription = OnObjectDescription;
  6506. if (handlerObjectDescription != null)
  6507. {
  6508. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6509. Util.FieldToString(objDes.ObjectData[i].Description));
  6510. }
  6511. }
  6512. return true;
  6513. }
  6514. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6515. {
  6516. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6517. #region Packet Session and User Check
  6518. if (m_checkPackets)
  6519. {
  6520. if (objName.AgentData.SessionID != SessionId ||
  6521. objName.AgentData.AgentID != AgentId)
  6522. return true;
  6523. }
  6524. #endregion
  6525. GenericCall7 handlerObjectName = null;
  6526. for (int i = 0; i < objName.ObjectData.Length; i++)
  6527. {
  6528. handlerObjectName = OnObjectName;
  6529. if (handlerObjectName != null)
  6530. {
  6531. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6532. Util.FieldToString(objName.ObjectData[i].Name));
  6533. }
  6534. }
  6535. return true;
  6536. }
  6537. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6538. {
  6539. if (OnObjectPermissions != null)
  6540. {
  6541. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6542. #region Packet Session and User Check
  6543. if (m_checkPackets)
  6544. {
  6545. if (newobjPerms.AgentData.SessionID != SessionId ||
  6546. newobjPerms.AgentData.AgentID != AgentId)
  6547. return true;
  6548. }
  6549. #endregion
  6550. UUID AgentID = newobjPerms.AgentData.AgentID;
  6551. UUID SessionID = newobjPerms.AgentData.SessionID;
  6552. ObjectPermissions handlerObjectPermissions = null;
  6553. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6554. {
  6555. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6556. byte field = permChanges.Field;
  6557. uint localID = permChanges.ObjectLocalID;
  6558. uint mask = permChanges.Mask;
  6559. byte set = permChanges.Set;
  6560. handlerObjectPermissions = OnObjectPermissions;
  6561. if (handlerObjectPermissions != null)
  6562. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6563. }
  6564. }
  6565. // Here's our data,
  6566. // PermField contains the field the info goes into
  6567. // PermField determines which mask we're changing
  6568. //
  6569. // chmask is the mask of the change
  6570. // setTF is whether we're adding it or taking it away
  6571. //
  6572. // objLocalID is the localID of the object.
  6573. // Unfortunately, we have to pass the event the packet because objData is an array
  6574. // That means multiple object perms may be updated in a single packet.
  6575. return true;
  6576. }
  6577. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6578. {
  6579. UndoPacket undoitem = (UndoPacket)Pack;
  6580. #region Packet Session and User Check
  6581. if (m_checkPackets)
  6582. {
  6583. if (undoitem.AgentData.SessionID != SessionId ||
  6584. undoitem.AgentData.AgentID != AgentId)
  6585. return true;
  6586. }
  6587. #endregion
  6588. if (undoitem.ObjectData.Length > 0)
  6589. {
  6590. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6591. {
  6592. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6593. AgentSit handlerOnUndo = OnUndo;
  6594. if (handlerOnUndo != null)
  6595. {
  6596. handlerOnUndo(this, objiD);
  6597. }
  6598. }
  6599. }
  6600. return true;
  6601. }
  6602. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6603. {
  6604. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6605. #region Packet Session and User Check
  6606. if (m_checkPackets)
  6607. {
  6608. if (undolanditem.AgentData.SessionID != SessionId ||
  6609. undolanditem.AgentData.AgentID != AgentId)
  6610. return true;
  6611. }
  6612. #endregion
  6613. LandUndo handlerOnUndo = OnLandUndo;
  6614. if (handlerOnUndo != null)
  6615. {
  6616. handlerOnUndo(this);
  6617. }
  6618. return true;
  6619. }
  6620. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6621. {
  6622. RedoPacket redoitem = (RedoPacket)Pack;
  6623. #region Packet Session and User Check
  6624. if (m_checkPackets)
  6625. {
  6626. if (redoitem.AgentData.SessionID != SessionId ||
  6627. redoitem.AgentData.AgentID != AgentId)
  6628. return true;
  6629. }
  6630. #endregion
  6631. if (redoitem.ObjectData.Length > 0)
  6632. {
  6633. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6634. {
  6635. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6636. AgentSit handlerOnRedo = OnRedo;
  6637. if (handlerOnRedo != null)
  6638. {
  6639. handlerOnRedo(this, objiD);
  6640. }
  6641. }
  6642. }
  6643. return true;
  6644. }
  6645. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6646. {
  6647. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6648. #region Packet Session and User Check
  6649. if (m_checkPackets)
  6650. {
  6651. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6652. dupeOnRay.AgentData.AgentID != AgentId)
  6653. return true;
  6654. }
  6655. #endregion
  6656. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6657. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6658. {
  6659. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6660. if (handlerObjectDuplicateOnRay != null)
  6661. {
  6662. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6663. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6664. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6665. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6666. }
  6667. }
  6668. return true;
  6669. }
  6670. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6671. {
  6672. //This powers the little tooltip that appears when you move your mouse over an object
  6673. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6674. #region Packet Session and User Check
  6675. if (m_checkPackets)
  6676. {
  6677. if (packToolTip.AgentData.SessionID != SessionId ||
  6678. packToolTip.AgentData.AgentID != AgentId)
  6679. return true;
  6680. }
  6681. #endregion
  6682. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6683. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6684. if (handlerRequestObjectPropertiesFamily != null)
  6685. {
  6686. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6687. packObjBlock.ObjectID);
  6688. }
  6689. return true;
  6690. }
  6691. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6692. {
  6693. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6694. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6695. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6696. #region Packet Session and User Check
  6697. if (m_checkPackets)
  6698. {
  6699. if (packInSearch.AgentData.SessionID != SessionId ||
  6700. packInSearch.AgentData.AgentID != AgentId)
  6701. return true;
  6702. }
  6703. #endregion
  6704. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6705. {
  6706. bool inSearch = objData.IncludeInSearch;
  6707. uint localID = objData.ObjectLocalID;
  6708. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6709. if (handlerObjectIncludeInSearch != null)
  6710. {
  6711. handlerObjectIncludeInSearch(this, inSearch, localID);
  6712. }
  6713. }
  6714. return true;
  6715. }
  6716. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6717. {
  6718. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6719. #region Packet Session and User Check
  6720. if (m_checkPackets)
  6721. {
  6722. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6723. scriptAnswer.AgentData.AgentID != AgentId)
  6724. return true;
  6725. }
  6726. #endregion
  6727. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6728. if (handlerScriptAnswer != null)
  6729. {
  6730. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6731. }
  6732. return true;
  6733. }
  6734. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6735. {
  6736. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6737. #region Packet Session and User Check
  6738. if (m_checkPackets)
  6739. {
  6740. if (ocpacket.AgentData.SessionID != SessionId ||
  6741. ocpacket.AgentData.AgentID != AgentId)
  6742. return true;
  6743. }
  6744. #endregion
  6745. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6746. if (handlerObjectClickAction != null)
  6747. {
  6748. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6749. {
  6750. byte action = odata.ClickAction;
  6751. uint localID = odata.ObjectLocalID;
  6752. handlerObjectClickAction(this, localID, action.ToString());
  6753. }
  6754. }
  6755. return true;
  6756. }
  6757. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6758. {
  6759. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6760. #region Packet Session and User Check
  6761. if (m_checkPackets)
  6762. {
  6763. if (ompacket.AgentData.SessionID != SessionId ||
  6764. ompacket.AgentData.AgentID != AgentId)
  6765. return true;
  6766. }
  6767. #endregion
  6768. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6769. if (handlerObjectMaterial != null)
  6770. {
  6771. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6772. {
  6773. byte material = odata.Material;
  6774. uint localID = odata.ObjectLocalID;
  6775. handlerObjectMaterial(this, localID, material.ToString());
  6776. }
  6777. }
  6778. return true;
  6779. }
  6780. #endregion Objects/m_sceneObjects
  6781. #region Inventory/Asset/Other related packets
  6782. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6783. {
  6784. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6785. //m_log.Debug("image request: " + Pack.ToString());
  6786. #region Packet Session and User Check
  6787. if (m_checkPackets)
  6788. {
  6789. if (imageRequest.AgentData.SessionID != SessionId ||
  6790. imageRequest.AgentData.AgentID != AgentId)
  6791. return true;
  6792. }
  6793. #endregion
  6794. //handlerTextureRequest = null;
  6795. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6796. {
  6797. TextureRequestArgs args = new TextureRequestArgs();
  6798. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6799. args.RequestedAssetID = block.Image;
  6800. args.DiscardLevel = block.DiscardLevel;
  6801. args.PacketNumber = block.Packet;
  6802. args.Priority = block.DownloadPriority;
  6803. args.requestSequence = imageRequest.Header.Sequence;
  6804. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6805. // priority of avatar textures to get avatars rezzing in faster than the
  6806. // surrounding scene
  6807. if ((ImageType)block.Type == ImageType.Baked)
  6808. args.Priority *= 2.0f;
  6809. ImageManager.EnqueueReq(args);
  6810. }
  6811. return true;
  6812. }
  6813. /// <summary>
  6814. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6815. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6816. /// </summary>
  6817. /// <param name="sender"></param>
  6818. /// <param name="Pack"></param>
  6819. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6820. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6821. {
  6822. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6823. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6824. UUID taskID = UUID.Zero;
  6825. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6826. {
  6827. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6828. {
  6829. // We're spawning a thread because the permissions check can block this thread
  6830. Util.FireAndForget(delegate
  6831. {
  6832. // This requests the asset if needed
  6833. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6834. });
  6835. return true;
  6836. }
  6837. }
  6838. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6839. {
  6840. //TransferRequestPacket does not include covenant uuid?
  6841. //get scene covenant uuid
  6842. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6843. }
  6844. // This is non-blocking
  6845. MakeAssetRequest(transfer, taskID);
  6846. return true;
  6847. }
  6848. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6849. {
  6850. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6851. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6852. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6853. //m_log.DebugFormat(
  6854. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6855. // requestID, itemID, taskID, Name);
  6856. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6857. // Validate inventory transfers
  6858. // Has to be done here, because AssetCache can't do it
  6859. //
  6860. if (taskID != UUID.Zero) // Prim
  6861. {
  6862. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6863. if (part == null)
  6864. {
  6865. m_log.WarnFormat(
  6866. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6867. Name, requestID, itemID, taskID);
  6868. return;
  6869. }
  6870. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6871. if (tii == null)
  6872. {
  6873. m_log.WarnFormat(
  6874. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6875. Name, requestID, itemID, taskID);
  6876. return;
  6877. }
  6878. if (tii.Type == (int)AssetType.LSLText)
  6879. {
  6880. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6881. return;
  6882. }
  6883. else if (tii.Type == (int)AssetType.Notecard)
  6884. {
  6885. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6886. return;
  6887. }
  6888. else
  6889. {
  6890. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6891. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6892. if (part.OwnerID != AgentId)
  6893. {
  6894. m_log.WarnFormat(
  6895. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6896. Name, requestID, itemID, taskID, part.OwnerID);
  6897. return;
  6898. }
  6899. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6900. {
  6901. m_log.WarnFormat(
  6902. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6903. Name, requestID, itemID, taskID);
  6904. return;
  6905. }
  6906. if (tii.OwnerID != AgentId)
  6907. {
  6908. m_log.WarnFormat(
  6909. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6910. Name, requestID, itemID, taskID, tii.OwnerID);
  6911. return;
  6912. }
  6913. if ((
  6914. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6915. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6916. {
  6917. m_log.WarnFormat(
  6918. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6919. Name, requestID, itemID, taskID);
  6920. return;
  6921. }
  6922. if (tii.AssetID != requestID)
  6923. {
  6924. m_log.WarnFormat(
  6925. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6926. Name, requestID, itemID, taskID, tii.AssetID);
  6927. return;
  6928. }
  6929. }
  6930. }
  6931. else // Agent
  6932. {
  6933. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6934. if (invAccess != null)
  6935. {
  6936. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6937. return;
  6938. }
  6939. else
  6940. {
  6941. return;
  6942. }
  6943. }
  6944. // Permissions out of the way, let's request the asset
  6945. MakeAssetRequest(transfer, taskID);
  6946. }
  6947. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6948. {
  6949. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6950. // m_log.Debug("upload request " + request.ToString());
  6951. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6952. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6953. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6954. if (handlerAssetUploadRequest != null)
  6955. {
  6956. handlerAssetUploadRequest(this, temp,
  6957. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6958. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6959. request.AssetBlock.Tempfile);
  6960. }
  6961. return true;
  6962. }
  6963. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6964. {
  6965. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6966. RequestXfer handlerRequestXfer = OnRequestXfer;
  6967. if (handlerRequestXfer != null)
  6968. {
  6969. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6970. }
  6971. return true;
  6972. }
  6973. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6974. {
  6975. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6976. XferReceive handlerXferReceive = OnXferReceive;
  6977. if (handlerXferReceive != null)
  6978. {
  6979. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6980. }
  6981. return true;
  6982. }
  6983. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6984. {
  6985. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6986. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6987. if (handlerConfirmXfer != null)
  6988. {
  6989. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6990. }
  6991. return true;
  6992. }
  6993. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6994. {
  6995. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6996. AbortXfer handlerAbortXfer = OnAbortXfer;
  6997. if (handlerAbortXfer != null)
  6998. {
  6999. handlerAbortXfer(this, abortXfer.XferID.ID);
  7000. }
  7001. return true;
  7002. }
  7003. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7004. {
  7005. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7006. #region Packet Session and User Check
  7007. if (m_checkPackets)
  7008. {
  7009. if (invFolder.AgentData.SessionID != SessionId ||
  7010. invFolder.AgentData.AgentID != AgentId)
  7011. return true;
  7012. }
  7013. #endregion
  7014. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7015. if (handlerCreateInventoryFolder != null)
  7016. {
  7017. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7018. (ushort)invFolder.FolderData.Type,
  7019. Util.FieldToString(invFolder.FolderData.Name),
  7020. invFolder.FolderData.ParentID);
  7021. }
  7022. return true;
  7023. }
  7024. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7025. {
  7026. if (OnUpdateInventoryFolder != null)
  7027. {
  7028. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7029. #region Packet Session and User Check
  7030. if (m_checkPackets)
  7031. {
  7032. if (invFolderx.AgentData.SessionID != SessionId ||
  7033. invFolderx.AgentData.AgentID != AgentId)
  7034. return true;
  7035. }
  7036. #endregion
  7037. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7038. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7039. {
  7040. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7041. if (handlerUpdateInventoryFolder != null)
  7042. {
  7043. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7044. (ushort)invFolderx.FolderData[i].Type,
  7045. Util.FieldToString(invFolderx.FolderData[i].Name),
  7046. invFolderx.FolderData[i].ParentID);
  7047. }
  7048. }
  7049. }
  7050. return true;
  7051. }
  7052. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7053. {
  7054. if (OnMoveInventoryFolder != null)
  7055. {
  7056. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7057. #region Packet Session and User Check
  7058. if (m_checkPackets)
  7059. {
  7060. if (invFoldery.AgentData.SessionID != SessionId ||
  7061. invFoldery.AgentData.AgentID != AgentId)
  7062. return true;
  7063. }
  7064. #endregion
  7065. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7066. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7067. {
  7068. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7069. if (handlerMoveInventoryFolder != null)
  7070. {
  7071. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7072. invFoldery.InventoryData[i].ParentID);
  7073. }
  7074. }
  7075. }
  7076. return true;
  7077. }
  7078. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7079. {
  7080. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7081. #region Packet Session and User Check
  7082. if (m_checkPackets)
  7083. {
  7084. if (createItem.AgentData.SessionID != SessionId ||
  7085. createItem.AgentData.AgentID != AgentId)
  7086. return true;
  7087. }
  7088. #endregion
  7089. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7090. if (handlerCreateNewInventoryItem != null)
  7091. {
  7092. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7093. createItem.InventoryBlock.FolderID,
  7094. createItem.InventoryBlock.CallbackID,
  7095. Util.FieldToString(createItem.InventoryBlock.Description),
  7096. Util.FieldToString(createItem.InventoryBlock.Name),
  7097. createItem.InventoryBlock.InvType,
  7098. createItem.InventoryBlock.Type,
  7099. createItem.InventoryBlock.WearableType,
  7100. createItem.InventoryBlock.NextOwnerMask,
  7101. Util.UnixTimeSinceEpoch());
  7102. }
  7103. return true;
  7104. }
  7105. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7106. {
  7107. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7108. #region Packet Session and User Check
  7109. if (m_checkPackets)
  7110. {
  7111. if (createLink.AgentData.SessionID != SessionId ||
  7112. createLink.AgentData.AgentID != AgentId)
  7113. return true;
  7114. }
  7115. #endregion
  7116. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7117. if (linkInventoryItem != null)
  7118. {
  7119. linkInventoryItem(
  7120. this,
  7121. createLink.InventoryBlock.TransactionID,
  7122. createLink.InventoryBlock.FolderID,
  7123. createLink.InventoryBlock.CallbackID,
  7124. Util.FieldToString(createLink.InventoryBlock.Description),
  7125. Util.FieldToString(createLink.InventoryBlock.Name),
  7126. createLink.InventoryBlock.InvType,
  7127. createLink.InventoryBlock.Type,
  7128. createLink.InventoryBlock.OldItemID);
  7129. }
  7130. return true;
  7131. }
  7132. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7133. {
  7134. if (OnFetchInventory != null)
  7135. {
  7136. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7137. #region Packet Session and User Check
  7138. if (m_checkPackets)
  7139. {
  7140. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7141. FetchInventoryx.AgentData.AgentID != AgentId)
  7142. return true;
  7143. }
  7144. #endregion
  7145. FetchInventory handlerFetchInventory = null;
  7146. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7147. {
  7148. handlerFetchInventory = OnFetchInventory;
  7149. if (handlerFetchInventory != null)
  7150. {
  7151. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7152. FetchInventoryx.InventoryData[i].OwnerID);
  7153. }
  7154. }
  7155. }
  7156. return true;
  7157. }
  7158. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7159. {
  7160. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7161. #region Packet Session and User Check
  7162. if (m_checkPackets)
  7163. {
  7164. if (Fetch.AgentData.SessionID != SessionId ||
  7165. Fetch.AgentData.AgentID != AgentId)
  7166. return true;
  7167. }
  7168. #endregion
  7169. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7170. if (handlerFetchInventoryDescendents != null)
  7171. {
  7172. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7173. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7174. Fetch.InventoryData.SortOrder);
  7175. }
  7176. return true;
  7177. }
  7178. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7179. {
  7180. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7181. #region Packet Session and User Check
  7182. if (m_checkPackets)
  7183. {
  7184. if (Purge.AgentData.SessionID != SessionId ||
  7185. Purge.AgentData.AgentID != AgentId)
  7186. return true;
  7187. }
  7188. #endregion
  7189. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7190. if (handlerPurgeInventoryDescendents != null)
  7191. {
  7192. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7193. }
  7194. return true;
  7195. }
  7196. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7197. {
  7198. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7199. #region Packet Session and User Check
  7200. if (m_checkPackets)
  7201. {
  7202. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7203. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7204. return true;
  7205. }
  7206. #endregion
  7207. if (OnUpdateInventoryItem != null)
  7208. {
  7209. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7210. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7211. {
  7212. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7213. if (handlerUpdateInventoryItem != null)
  7214. {
  7215. InventoryItemBase itemUpd = new InventoryItemBase();
  7216. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7217. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7218. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7219. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7220. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7221. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7222. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7223. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7224. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7225. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7226. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7227. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7228. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7229. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7230. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7231. inventoryItemUpdate.InventoryData[i].ItemID,
  7232. itemUpd);
  7233. }
  7234. }
  7235. }
  7236. return true;
  7237. }
  7238. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7239. {
  7240. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7241. #region Packet Session and User Check
  7242. if (m_checkPackets)
  7243. {
  7244. if (copyitem.AgentData.SessionID != SessionId ||
  7245. copyitem.AgentData.AgentID != AgentId)
  7246. return true;
  7247. }
  7248. #endregion
  7249. CopyInventoryItem handlerCopyInventoryItem = null;
  7250. if (OnCopyInventoryItem != null)
  7251. {
  7252. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7253. {
  7254. handlerCopyInventoryItem = OnCopyInventoryItem;
  7255. if (handlerCopyInventoryItem != null)
  7256. {
  7257. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7258. datablock.OldItemID, datablock.NewFolderID,
  7259. Util.FieldToString(datablock.NewName));
  7260. }
  7261. }
  7262. }
  7263. return true;
  7264. }
  7265. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7266. {
  7267. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7268. #region Packet Session and User Check
  7269. if (m_checkPackets)
  7270. {
  7271. if (moveitem.AgentData.SessionID != SessionId ||
  7272. moveitem.AgentData.AgentID != AgentId)
  7273. return true;
  7274. }
  7275. #endregion
  7276. if (OnMoveInventoryItem != null)
  7277. {
  7278. MoveInventoryItem handlerMoveInventoryItem = null;
  7279. InventoryItemBase itm = null;
  7280. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7281. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7282. {
  7283. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7284. itm.Folder = datablock.FolderID;
  7285. itm.Name = Util.FieldToString(datablock.NewName);
  7286. // weird, comes out as empty string
  7287. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7288. items.Add(itm);
  7289. }
  7290. handlerMoveInventoryItem = OnMoveInventoryItem;
  7291. if (handlerMoveInventoryItem != null)
  7292. {
  7293. handlerMoveInventoryItem(this, items);
  7294. }
  7295. }
  7296. return true;
  7297. }
  7298. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7299. {
  7300. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7301. #region Packet Session and User Check
  7302. if (m_checkPackets)
  7303. {
  7304. if (removeItem.AgentData.SessionID != SessionId ||
  7305. removeItem.AgentData.AgentID != AgentId)
  7306. return true;
  7307. }
  7308. #endregion
  7309. if (OnRemoveInventoryItem != null)
  7310. {
  7311. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7312. List<UUID> uuids = new List<UUID>();
  7313. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7314. {
  7315. uuids.Add(datablock.ItemID);
  7316. }
  7317. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7318. if (handlerRemoveInventoryItem != null)
  7319. {
  7320. handlerRemoveInventoryItem(this, uuids);
  7321. }
  7322. }
  7323. return true;
  7324. }
  7325. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7326. {
  7327. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7328. #region Packet Session and User Check
  7329. if (m_checkPackets)
  7330. {
  7331. if (removeFolder.AgentData.SessionID != SessionId ||
  7332. removeFolder.AgentData.AgentID != AgentId)
  7333. return true;
  7334. }
  7335. #endregion
  7336. if (OnRemoveInventoryFolder != null)
  7337. {
  7338. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7339. List<UUID> uuids = new List<UUID>();
  7340. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7341. {
  7342. uuids.Add(datablock.FolderID);
  7343. }
  7344. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7345. if (handlerRemoveInventoryFolder != null)
  7346. {
  7347. handlerRemoveInventoryFolder(this, uuids);
  7348. }
  7349. }
  7350. return true;
  7351. }
  7352. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7353. {
  7354. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7355. #region Packet Session and User Check
  7356. if (m_checkPackets)
  7357. {
  7358. if (removeObject.AgentData.SessionID != SessionId ||
  7359. removeObject.AgentData.AgentID != AgentId)
  7360. return true;
  7361. }
  7362. #endregion
  7363. if (OnRemoveInventoryFolder != null)
  7364. {
  7365. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7366. List<UUID> uuids = new List<UUID>();
  7367. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7368. {
  7369. uuids.Add(datablock.FolderID);
  7370. }
  7371. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7372. if (handlerRemoveInventoryFolder != null)
  7373. {
  7374. handlerRemoveInventoryFolder(this, uuids);
  7375. }
  7376. }
  7377. if (OnRemoveInventoryItem != null)
  7378. {
  7379. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7380. List<UUID> uuids = new List<UUID>();
  7381. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7382. {
  7383. uuids.Add(datablock.ItemID);
  7384. }
  7385. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7386. if (handlerRemoveInventoryItem != null)
  7387. {
  7388. handlerRemoveInventoryItem(this, uuids);
  7389. }
  7390. }
  7391. return true;
  7392. }
  7393. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7394. {
  7395. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7396. #region Packet Session and User Check
  7397. if (m_checkPackets)
  7398. {
  7399. if (requesttask.AgentData.SessionID != SessionId ||
  7400. requesttask.AgentData.AgentID != AgentId)
  7401. return true;
  7402. }
  7403. #endregion
  7404. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7405. if (handlerRequestTaskInventory != null)
  7406. {
  7407. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7408. }
  7409. return true;
  7410. }
  7411. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7412. {
  7413. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7414. #region Packet Session and User Check
  7415. if (m_checkPackets)
  7416. {
  7417. if (updatetask.AgentData.SessionID != SessionId ||
  7418. updatetask.AgentData.AgentID != AgentId)
  7419. return true;
  7420. }
  7421. #endregion
  7422. if (OnUpdateTaskInventory != null)
  7423. {
  7424. if (updatetask.UpdateData.Key == 0)
  7425. {
  7426. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7427. if (handlerUpdateTaskInventory != null)
  7428. {
  7429. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7430. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7431. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7432. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7433. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7434. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7435. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7436. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7437. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7438. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7439. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7440. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7441. // different
  7442. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7443. newTaskItem.Type = updatetask.InventoryData.Type;
  7444. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7445. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7446. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7447. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7448. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7449. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7450. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7451. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7452. newTaskItem, updatetask.UpdateData.LocalID);
  7453. }
  7454. }
  7455. }
  7456. return true;
  7457. }
  7458. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7459. {
  7460. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7461. #region Packet Session and User Check
  7462. if (m_checkPackets)
  7463. {
  7464. if (removeTask.AgentData.SessionID != SessionId ||
  7465. removeTask.AgentData.AgentID != AgentId)
  7466. return true;
  7467. }
  7468. #endregion
  7469. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7470. if (handlerRemoveTaskItem != null)
  7471. {
  7472. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7473. }
  7474. return true;
  7475. }
  7476. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7477. {
  7478. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7479. #region Packet Session and User Check
  7480. if (m_checkPackets)
  7481. {
  7482. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7483. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7484. return true;
  7485. }
  7486. #endregion
  7487. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7488. if (handlerMoveTaskItem != null)
  7489. {
  7490. handlerMoveTaskItem(
  7491. this, moveTaskInventoryPacket.AgentData.FolderID,
  7492. moveTaskInventoryPacket.InventoryData.LocalID,
  7493. moveTaskInventoryPacket.InventoryData.ItemID);
  7494. }
  7495. return true;
  7496. }
  7497. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7498. {
  7499. //m_log.Debug(Pack.ToString());
  7500. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7501. #region Packet Session and User Check
  7502. if (m_checkPackets)
  7503. {
  7504. if (rezScriptx.AgentData.SessionID != SessionId ||
  7505. rezScriptx.AgentData.AgentID != AgentId)
  7506. return true;
  7507. }
  7508. #endregion
  7509. RezScript handlerRezScript = OnRezScript;
  7510. InventoryItemBase item = new InventoryItemBase();
  7511. item.ID = rezScriptx.InventoryBlock.ItemID;
  7512. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7513. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7514. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7515. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7516. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7517. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7518. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7519. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7520. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7521. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7522. item.AssetType = rezScriptx.InventoryBlock.Type;
  7523. item.InvType = rezScriptx.InventoryBlock.InvType;
  7524. item.Flags = rezScriptx.InventoryBlock.Flags;
  7525. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7526. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7527. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7528. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7529. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7530. if (handlerRezScript != null)
  7531. {
  7532. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7533. }
  7534. return true;
  7535. }
  7536. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7537. {
  7538. RequestMapLayer();
  7539. return true;
  7540. }
  7541. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7542. {
  7543. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7544. #region Packet Session and User Check
  7545. if (m_checkPackets)
  7546. {
  7547. if (MapRequest.AgentData.SessionID != SessionId ||
  7548. MapRequest.AgentData.AgentID != AgentId)
  7549. return true;
  7550. }
  7551. #endregion
  7552. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7553. if (handlerRequestMapBlocks != null)
  7554. {
  7555. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7556. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7557. }
  7558. return true;
  7559. }
  7560. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7561. {
  7562. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7563. #region Packet Session and User Check
  7564. if (m_checkPackets)
  7565. {
  7566. if (map.AgentData.SessionID != SessionId ||
  7567. map.AgentData.AgentID != AgentId)
  7568. return true;
  7569. }
  7570. #endregion
  7571. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7572. map.NameData.Name.Length - 1);
  7573. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7574. if (handlerMapNameRequest != null)
  7575. {
  7576. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7577. }
  7578. return true;
  7579. }
  7580. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7581. {
  7582. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7583. #region Packet Session and User Check
  7584. if (m_checkPackets)
  7585. {
  7586. if (tpReq.Info.SessionID != SessionId ||
  7587. tpReq.Info.AgentID != AgentId)
  7588. return true;
  7589. }
  7590. #endregion
  7591. UUID lmid = tpReq.Info.LandmarkID;
  7592. AssetLandmark lm;
  7593. if (lmid != UUID.Zero)
  7594. {
  7595. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7596. AssetBase lma = m_assetService.Get(lmid.ToString());
  7597. if (lma == null)
  7598. {
  7599. // Failed to find landmark
  7600. // Let's try to search in the user's home asset server
  7601. lma = FindAssetInUserAssetServer(lmid.ToString());
  7602. if (lma == null)
  7603. {
  7604. // Really doesn't exist
  7605. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7606. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7607. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7608. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7609. }
  7610. }
  7611. try
  7612. {
  7613. lm = new AssetLandmark(lma);
  7614. }
  7615. catch (NullReferenceException)
  7616. {
  7617. // asset not found generates null ref inside the assetlandmark constructor.
  7618. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7619. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7620. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7621. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7622. return true;
  7623. }
  7624. }
  7625. else
  7626. {
  7627. // Teleport home request
  7628. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7629. if (handlerTeleportHomeRequest != null)
  7630. {
  7631. handlerTeleportHomeRequest(AgentId, this);
  7632. }
  7633. return true;
  7634. }
  7635. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7636. if (handlerTeleportLandmarkRequest != null)
  7637. {
  7638. handlerTeleportLandmarkRequest(this, lm);
  7639. }
  7640. else
  7641. {
  7642. //no event handler so cancel request
  7643. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7644. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7645. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7646. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7647. }
  7648. return true;
  7649. }
  7650. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7651. {
  7652. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7653. if (handlerTeleportCancel != null)
  7654. {
  7655. handlerTeleportCancel(this);
  7656. }
  7657. return true;
  7658. }
  7659. private AssetBase FindAssetInUserAssetServer(string id)
  7660. {
  7661. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7662. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7663. {
  7664. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7665. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7666. }
  7667. return null;
  7668. }
  7669. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7670. {
  7671. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7672. // m_log.Debug(tpLocReq.ToString());
  7673. #region Packet Session and User Check
  7674. if (m_checkPackets)
  7675. {
  7676. if (tpLocReq.AgentData.SessionID != SessionId ||
  7677. tpLocReq.AgentData.AgentID != AgentId)
  7678. return true;
  7679. }
  7680. #endregion
  7681. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7682. if (handlerTeleportLocationRequest != null)
  7683. {
  7684. // Adjust teleport location to base of a larger region if requested to teleport to a sub-region
  7685. uint locX, locY;
  7686. Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out locX, out locY);
  7687. if ((locX >= m_scene.RegionInfo.WorldLocX)
  7688. && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX))
  7689. && (locY >= m_scene.RegionInfo.WorldLocY)
  7690. && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)) )
  7691. {
  7692. tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle;
  7693. tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX;
  7694. tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY;
  7695. }
  7696. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7697. tpLocReq.Info.LookAt, 16);
  7698. }
  7699. else
  7700. {
  7701. //no event handler so cancel request
  7702. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7703. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7704. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7705. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7706. }
  7707. return true;
  7708. }
  7709. #endregion Inventory/Asset/Other related packets
  7710. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7711. {
  7712. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7713. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7714. {
  7715. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7716. if (handlerNameRequest != null)
  7717. {
  7718. handlerNameRequest(UUIDBlock.ID, this);
  7719. }
  7720. }
  7721. return true;
  7722. }
  7723. #region Parcel related packets
  7724. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7725. {
  7726. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7727. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7728. if (handlerRegionHandleRequest != null)
  7729. {
  7730. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7731. }
  7732. return true;
  7733. }
  7734. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7735. {
  7736. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7737. #region Packet Session and User Check
  7738. if (m_checkPackets)
  7739. {
  7740. if (pirPack.AgentData.SessionID != SessionId ||
  7741. pirPack.AgentData.AgentID != AgentId)
  7742. return true;
  7743. }
  7744. #endregion
  7745. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7746. if (handlerParcelInfoRequest != null)
  7747. {
  7748. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7749. }
  7750. return true;
  7751. }
  7752. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7753. {
  7754. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7755. #region Packet Session and User Check
  7756. if (m_checkPackets)
  7757. {
  7758. if (requestPacket.AgentData.SessionID != SessionId ||
  7759. requestPacket.AgentData.AgentID != AgentId)
  7760. return true;
  7761. }
  7762. #endregion
  7763. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7764. if (handlerParcelAccessListRequest != null)
  7765. {
  7766. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7767. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7768. requestPacket.Data.LocalID, this);
  7769. }
  7770. return true;
  7771. }
  7772. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7773. {
  7774. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7775. #region Packet Session and User Check
  7776. if (m_checkPackets)
  7777. {
  7778. if (updatePacket.AgentData.SessionID != SessionId ||
  7779. updatePacket.AgentData.AgentID != AgentId)
  7780. return true;
  7781. }
  7782. #endregion
  7783. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7784. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7785. {
  7786. LandAccessEntry entry = new LandAccessEntry();
  7787. entry.AgentID = block.ID;
  7788. entry.Flags = (AccessList)block.Flags;
  7789. entry.Expires = block.Time;
  7790. entries.Add(entry);
  7791. }
  7792. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7793. if (handlerParcelAccessListUpdateRequest != null)
  7794. {
  7795. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7796. updatePacket.Data.Flags,
  7797. updatePacket.Data.LocalID,
  7798. updatePacket.Data.TransactionID,
  7799. updatePacket.Data.SequenceID,
  7800. updatePacket.Data.Sections,
  7801. entries, this);
  7802. }
  7803. return true;
  7804. }
  7805. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7806. {
  7807. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7808. #region Packet Session and User Check
  7809. if (m_checkPackets)
  7810. {
  7811. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7812. propertiesRequest.AgentData.AgentID != AgentId)
  7813. return true;
  7814. }
  7815. #endregion
  7816. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7817. if (handlerParcelPropertiesRequest != null)
  7818. {
  7819. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7820. (int)Math.Round(propertiesRequest.ParcelData.South),
  7821. (int)Math.Round(propertiesRequest.ParcelData.East),
  7822. (int)Math.Round(propertiesRequest.ParcelData.North),
  7823. propertiesRequest.ParcelData.SequenceID,
  7824. propertiesRequest.ParcelData.SnapSelection, this);
  7825. }
  7826. return true;
  7827. }
  7828. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7829. {
  7830. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7831. #region Packet Session and User Check
  7832. if (m_checkPackets)
  7833. {
  7834. if (landDivide.AgentData.SessionID != SessionId ||
  7835. landDivide.AgentData.AgentID != AgentId)
  7836. return true;
  7837. }
  7838. #endregion
  7839. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7840. if (handlerParcelDivideRequest != null)
  7841. {
  7842. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7843. (int)Math.Round(landDivide.ParcelData.South),
  7844. (int)Math.Round(landDivide.ParcelData.East),
  7845. (int)Math.Round(landDivide.ParcelData.North), this);
  7846. }
  7847. return true;
  7848. }
  7849. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7850. {
  7851. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7852. #region Packet Session and User Check
  7853. if (m_checkPackets)
  7854. {
  7855. if (landJoin.AgentData.SessionID != SessionId ||
  7856. landJoin.AgentData.AgentID != AgentId)
  7857. return true;
  7858. }
  7859. #endregion
  7860. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7861. if (handlerParcelJoinRequest != null)
  7862. {
  7863. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7864. (int)Math.Round(landJoin.ParcelData.South),
  7865. (int)Math.Round(landJoin.ParcelData.East),
  7866. (int)Math.Round(landJoin.ParcelData.North), this);
  7867. }
  7868. return true;
  7869. }
  7870. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7871. {
  7872. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7873. #region Packet Session and User Check
  7874. if (m_checkPackets)
  7875. {
  7876. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7877. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7878. return true;
  7879. }
  7880. #endregion
  7881. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7882. if (handlerParcelPropertiesUpdateRequest != null)
  7883. {
  7884. LandUpdateArgs args = new LandUpdateArgs();
  7885. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7886. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7887. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7888. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7889. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7890. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7891. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7892. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7893. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7894. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7895. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7896. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7897. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7898. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7899. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7900. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7901. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7902. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7903. }
  7904. return true;
  7905. }
  7906. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7907. {
  7908. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7909. #region Packet Session and User Check
  7910. if (m_checkPackets)
  7911. {
  7912. if (selectPacket.AgentData.SessionID != SessionId ||
  7913. selectPacket.AgentData.AgentID != AgentId)
  7914. return true;
  7915. }
  7916. #endregion
  7917. List<UUID> returnIDs = new List<UUID>();
  7918. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7919. selectPacket.ReturnIDs)
  7920. {
  7921. returnIDs.Add(rb.ReturnID);
  7922. }
  7923. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7924. if (handlerParcelSelectObjects != null)
  7925. {
  7926. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7927. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7928. }
  7929. return true;
  7930. }
  7931. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7932. {
  7933. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7934. #region Packet Session and User Check
  7935. if (m_checkPackets)
  7936. {
  7937. if (reqPacket.AgentData.SessionID != SessionId ||
  7938. reqPacket.AgentData.AgentID != AgentId)
  7939. return true;
  7940. }
  7941. #endregion
  7942. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7943. if (handlerParcelObjectOwnerRequest != null)
  7944. {
  7945. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7946. }
  7947. return true;
  7948. }
  7949. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7950. {
  7951. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7952. #region Packet Session and User Check
  7953. if (m_checkPackets)
  7954. {
  7955. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7956. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7957. return true;
  7958. }
  7959. #endregion
  7960. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7961. if (handlerParcelGodForceOwner != null)
  7962. {
  7963. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7964. }
  7965. return true;
  7966. }
  7967. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7968. {
  7969. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7970. #region Packet Session and User Check
  7971. if (m_checkPackets)
  7972. {
  7973. if (releasePacket.AgentData.SessionID != SessionId ||
  7974. releasePacket.AgentData.AgentID != AgentId)
  7975. return true;
  7976. }
  7977. #endregion
  7978. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7979. if (handlerParcelAbandonRequest != null)
  7980. {
  7981. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7982. }
  7983. return true;
  7984. }
  7985. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7986. {
  7987. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7988. #region Packet Session and User Check
  7989. if (m_checkPackets)
  7990. {
  7991. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7992. reclaimPacket.AgentData.AgentID != AgentId)
  7993. return true;
  7994. }
  7995. #endregion
  7996. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7997. if (handlerParcelReclaim != null)
  7998. {
  7999. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  8000. }
  8001. return true;
  8002. }
  8003. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  8004. {
  8005. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  8006. #region Packet Session and User Check
  8007. if (m_checkPackets)
  8008. {
  8009. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  8010. parcelReturnObjects.AgentData.AgentID != AgentId)
  8011. return true;
  8012. }
  8013. #endregion
  8014. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8015. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8016. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8017. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8018. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8019. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8020. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8021. if (handlerParcelReturnObjectsRequest != null)
  8022. {
  8023. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8024. }
  8025. return true;
  8026. }
  8027. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8028. {
  8029. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8030. #region Packet Session and User Check
  8031. if (m_checkPackets)
  8032. {
  8033. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8034. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8035. return true;
  8036. }
  8037. #endregion
  8038. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8039. if (handlerParcelSetOtherCleanTime != null)
  8040. {
  8041. handlerParcelSetOtherCleanTime(this,
  8042. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8043. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8044. }
  8045. return true;
  8046. }
  8047. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8048. {
  8049. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8050. #region Packet Session and User Check
  8051. if (m_checkPackets)
  8052. {
  8053. if (lsrp.AgentData.SessionID != SessionId ||
  8054. lsrp.AgentData.AgentID != AgentId)
  8055. return true;
  8056. }
  8057. #endregion
  8058. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8059. if (handlerLandStatRequest != null)
  8060. {
  8061. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8062. }
  8063. return true;
  8064. }
  8065. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8066. {
  8067. ParcelDwellRequestPacket dwellrq =
  8068. (ParcelDwellRequestPacket)Pack;
  8069. #region Packet Session and User Check
  8070. if (m_checkPackets)
  8071. {
  8072. if (dwellrq.AgentData.SessionID != SessionId ||
  8073. dwellrq.AgentData.AgentID != AgentId)
  8074. return true;
  8075. }
  8076. #endregion
  8077. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8078. if (handlerParcelDwellRequest != null)
  8079. {
  8080. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8081. }
  8082. return true;
  8083. }
  8084. #endregion Parcel related packets
  8085. #region Estate Packets
  8086. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8087. {
  8088. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8089. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8090. GodLandStatRequest handlerLandStatRequest;
  8091. #region Packet Session and User Check
  8092. if (m_checkPackets)
  8093. {
  8094. if (messagePacket.AgentData.SessionID != SessionId ||
  8095. messagePacket.AgentData.AgentID != AgentId)
  8096. return true;
  8097. }
  8098. #endregion
  8099. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8100. switch (method)
  8101. {
  8102. case "getinfo":
  8103. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8104. {
  8105. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8106. }
  8107. return true;
  8108. case "setregioninfo":
  8109. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8110. {
  8111. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8112. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8113. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8114. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8115. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8116. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8117. }
  8118. return true;
  8119. // case "texturebase":
  8120. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8121. // {
  8122. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8123. // {
  8124. // string s = Utils.BytesToString(block.Parameter);
  8125. // string[] splitField = s.Split(' ');
  8126. // if (splitField.Length == 2)
  8127. // {
  8128. // UUID tempUUID = new UUID(splitField[1]);
  8129. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8130. // }
  8131. // }
  8132. // }
  8133. // break;
  8134. case "texturedetail":
  8135. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8136. {
  8137. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8138. {
  8139. string s = Utils.BytesToString(block.Parameter);
  8140. string[] splitField = s.Split(' ');
  8141. if (splitField.Length == 2)
  8142. {
  8143. Int16 corner = Convert.ToInt16(splitField[0]);
  8144. UUID textureUUID = new UUID(splitField[1]);
  8145. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8146. }
  8147. }
  8148. }
  8149. return true;
  8150. case "textureheights":
  8151. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8152. {
  8153. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8154. {
  8155. string s = Utils.BytesToString(block.Parameter);
  8156. string[] splitField = s.Split(' ');
  8157. if (splitField.Length == 3)
  8158. {
  8159. Int16 corner = Convert.ToInt16(splitField[0]);
  8160. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8161. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8162. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8163. }
  8164. }
  8165. }
  8166. return true;
  8167. case "texturecommit":
  8168. OnCommitEstateTerrainTextureRequest(this);
  8169. return true;
  8170. case "setregionterrain":
  8171. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8172. {
  8173. if (messagePacket.ParamList.Length != 9)
  8174. {
  8175. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8176. }
  8177. else
  8178. {
  8179. try
  8180. {
  8181. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8182. if (!tmp.Contains(".")) tmp += ".00";
  8183. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8184. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8185. if (!tmp.Contains(".")) tmp += ".00";
  8186. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8187. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8188. if (!tmp.Contains(".")) tmp += ".00";
  8189. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8190. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8191. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8192. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8193. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8194. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8195. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8196. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8197. }
  8198. catch (Exception ex)
  8199. {
  8200. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8201. }
  8202. }
  8203. }
  8204. return true;
  8205. case "restart":
  8206. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8207. {
  8208. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8209. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8210. {
  8211. float timeSeconds;
  8212. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8213. timeSeconds = (int)timeSeconds;
  8214. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8215. }
  8216. }
  8217. return true;
  8218. case "estatechangecovenantid":
  8219. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8220. {
  8221. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8222. {
  8223. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8224. OnEstateChangeCovenantRequest(this, newCovenantID);
  8225. }
  8226. }
  8227. return true;
  8228. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8229. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8230. {
  8231. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8232. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8233. }
  8234. return true;
  8235. case "simulatormessage":
  8236. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8237. {
  8238. UUID invoice = messagePacket.MethodData.Invoice;
  8239. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8240. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8241. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8242. UUID sessionID = messagePacket.AgentData.SessionID;
  8243. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8244. }
  8245. return true;
  8246. case "instantmessage":
  8247. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8248. {
  8249. if (messagePacket.ParamList.Length < 2)
  8250. return true;
  8251. UUID invoice = messagePacket.MethodData.Invoice;
  8252. UUID sessionID = messagePacket.AgentData.SessionID;
  8253. UUID SenderID;
  8254. string SenderName;
  8255. string Message;
  8256. if (messagePacket.ParamList.Length < 5)
  8257. {
  8258. SenderID = AgentId;
  8259. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8260. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8261. }
  8262. else
  8263. {
  8264. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8265. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8266. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8267. }
  8268. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8269. }
  8270. return true;
  8271. case "setregiondebug":
  8272. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8273. {
  8274. UUID invoice = messagePacket.MethodData.Invoice;
  8275. UUID SenderID = messagePacket.AgentData.AgentID;
  8276. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8277. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8278. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8279. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8280. }
  8281. return true;
  8282. case "teleporthomeuser":
  8283. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8284. {
  8285. UUID invoice = messagePacket.MethodData.Invoice;
  8286. UUID SenderID = messagePacket.AgentData.AgentID;
  8287. UUID Prey;
  8288. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8289. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8290. }
  8291. return true;
  8292. case "teleporthomeallusers":
  8293. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8294. {
  8295. UUID invoice = messagePacket.MethodData.Invoice;
  8296. UUID SenderID = messagePacket.AgentData.AgentID;
  8297. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8298. }
  8299. return true;
  8300. case "colliders":
  8301. handlerLandStatRequest = OnLandStatRequest;
  8302. if (handlerLandStatRequest != null)
  8303. {
  8304. handlerLandStatRequest(0, 1, 0, "", this);
  8305. }
  8306. return true;
  8307. case "scripts":
  8308. handlerLandStatRequest = OnLandStatRequest;
  8309. if (handlerLandStatRequest != null)
  8310. {
  8311. handlerLandStatRequest(0, 0, 0, "", this);
  8312. }
  8313. return true;
  8314. case "terrain":
  8315. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8316. {
  8317. if (messagePacket.ParamList.Length > 0)
  8318. {
  8319. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8320. {
  8321. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8322. if (handlerBakeTerrain != null)
  8323. {
  8324. handlerBakeTerrain(this);
  8325. }
  8326. }
  8327. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8328. {
  8329. if (messagePacket.ParamList.Length > 1)
  8330. {
  8331. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8332. if (handlerRequestTerrain != null)
  8333. {
  8334. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8335. }
  8336. }
  8337. }
  8338. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8339. {
  8340. if (messagePacket.ParamList.Length > 1)
  8341. {
  8342. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8343. if (handlerUploadTerrain != null)
  8344. {
  8345. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8346. }
  8347. }
  8348. }
  8349. }
  8350. }
  8351. return true;
  8352. case "estatechangeinfo":
  8353. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8354. {
  8355. UUID invoice = messagePacket.MethodData.Invoice;
  8356. UUID SenderID = messagePacket.AgentData.AgentID;
  8357. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8358. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8359. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8360. if (handlerEstateChangeInfo != null)
  8361. {
  8362. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8363. }
  8364. }
  8365. return true;
  8366. case "telehub":
  8367. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8368. {
  8369. UUID invoice = messagePacket.MethodData.Invoice;
  8370. UUID SenderID = messagePacket.AgentData.AgentID;
  8371. UInt32 param1 = 0u;
  8372. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8373. if (command != "info ui")
  8374. {
  8375. try
  8376. {
  8377. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8378. }
  8379. catch
  8380. {
  8381. }
  8382. }
  8383. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8384. if (handlerEstateManageTelehub != null)
  8385. {
  8386. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8387. }
  8388. }
  8389. return true;
  8390. default:
  8391. m_log.WarnFormat(
  8392. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8393. method, Name, Scene.Name);
  8394. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8395. {
  8396. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8397. string data = (string)Utils.BytesToString(block.Parameter);
  8398. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8399. }
  8400. return true;
  8401. }
  8402. //int parcelID, uint reportType, uint requestflags, string filter
  8403. //lsrp.RequestData.ParcelLocalID;
  8404. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8405. //lsrp.RequestData.RequestFlags;
  8406. //lsrp.RequestData.Filter;
  8407. }
  8408. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8409. {
  8410. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8411. #region Packet Session and User Check
  8412. if (m_checkPackets)
  8413. {
  8414. if (mPacket.SessionID != SessionId ||
  8415. mPacket.AgentID != AgentId)
  8416. return true;
  8417. }
  8418. #endregion
  8419. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8420. if (handlerRegionInfoRequest != null)
  8421. {
  8422. handlerRegionInfoRequest(this);
  8423. }
  8424. return true;
  8425. }
  8426. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8427. {
  8428. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8429. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8430. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8431. if (handlerEstateCovenantRequest != null)
  8432. {
  8433. handlerEstateCovenantRequest(this);
  8434. }
  8435. return true;
  8436. }
  8437. #endregion Estate Packets
  8438. #region GodPackets
  8439. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8440. {
  8441. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8442. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8443. UUID token = rblock.Token;
  8444. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8445. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8446. if (handlerReqGodlikePowers != null)
  8447. {
  8448. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8449. }
  8450. return true;
  8451. }
  8452. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8453. {
  8454. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8455. (GodUpdateRegionInfoPacket)Packet;
  8456. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8457. if (handlerGodUpdateRegionInfo != null)
  8458. {
  8459. handlerGodUpdateRegionInfo(this,
  8460. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8461. GodUpdateRegionInfo.RegionInfo.EstateID,
  8462. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8463. GodUpdateRegionInfo.RegionInfo.SimName,
  8464. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8465. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8466. return true;
  8467. }
  8468. return false;
  8469. }
  8470. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8471. {
  8472. SimWideDeletesPacket SimWideDeletesRequest =
  8473. (SimWideDeletesPacket)Packet;
  8474. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8475. if (handlerSimWideDeletesRequest != null)
  8476. {
  8477. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8478. return true;
  8479. }
  8480. return false;
  8481. }
  8482. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8483. {
  8484. GodlikeMessagePacket GodlikeMessage =
  8485. (GodlikeMessagePacket)Packet;
  8486. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8487. if (handlerGodlikeMessage != null)
  8488. {
  8489. handlerGodlikeMessage(this,
  8490. GodlikeMessage.MethodData.Invoice,
  8491. GodlikeMessage.MethodData.Method,
  8492. GodlikeMessage.ParamList[0].Parameter);
  8493. return true;
  8494. }
  8495. return false;
  8496. }
  8497. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8498. {
  8499. StateSavePacket SaveStateMessage =
  8500. (StateSavePacket)Packet;
  8501. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8502. if (handlerSaveStatePacket != null)
  8503. {
  8504. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8505. return true;
  8506. }
  8507. return false;
  8508. }
  8509. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8510. {
  8511. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8512. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8513. {
  8514. GodKickUser handlerGodKickUser = OnGodKickUser;
  8515. if (handlerGodKickUser != null)
  8516. {
  8517. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8518. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8519. }
  8520. }
  8521. else
  8522. {
  8523. SendAgentAlertMessage("Kick request denied", false);
  8524. }
  8525. //KickUserPacket kupack = new KickUserPacket();
  8526. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8527. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8528. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8529. //kupack.TargetBlock.TargetIP = (uint)0;
  8530. //kupack.TargetBlock.TargetPort = (ushort)0;
  8531. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8532. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8533. return true;
  8534. }
  8535. #endregion GodPackets
  8536. #region Economy/Transaction Packets
  8537. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8538. {
  8539. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8540. #region Packet Session and User Check
  8541. if (m_checkPackets)
  8542. {
  8543. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8544. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8545. return true;
  8546. }
  8547. #endregion
  8548. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8549. if (handlerMoneyBalanceRequest != null)
  8550. {
  8551. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8552. }
  8553. return true;
  8554. }
  8555. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8556. {
  8557. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8558. if (handlerEconomoyDataRequest != null)
  8559. {
  8560. handlerEconomoyDataRequest(this);
  8561. }
  8562. return true;
  8563. }
  8564. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8565. {
  8566. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8567. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8568. if (handlerRequestPayPrice != null)
  8569. {
  8570. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8571. }
  8572. return true;
  8573. }
  8574. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8575. {
  8576. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8577. #region Packet Session and User Check
  8578. if (m_checkPackets)
  8579. {
  8580. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8581. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8582. return true;
  8583. }
  8584. #endregion
  8585. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8586. if (handlerObjectSaleInfo != null)
  8587. {
  8588. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8589. in objectSaleInfoPacket.ObjectData)
  8590. {
  8591. handlerObjectSaleInfo(this,
  8592. objectSaleInfoPacket.AgentData.AgentID,
  8593. objectSaleInfoPacket.AgentData.SessionID,
  8594. d.LocalID,
  8595. d.SaleType,
  8596. d.SalePrice);
  8597. }
  8598. }
  8599. return true;
  8600. }
  8601. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8602. {
  8603. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8604. #region Packet Session and User Check
  8605. if (m_checkPackets)
  8606. {
  8607. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8608. objectBuyPacket.AgentData.AgentID != AgentId)
  8609. return true;
  8610. }
  8611. #endregion
  8612. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8613. if (handlerObjectBuy != null)
  8614. {
  8615. foreach (ObjectBuyPacket.ObjectDataBlock d
  8616. in objectBuyPacket.ObjectData)
  8617. {
  8618. handlerObjectBuy(this,
  8619. objectBuyPacket.AgentData.AgentID,
  8620. objectBuyPacket.AgentData.SessionID,
  8621. objectBuyPacket.AgentData.GroupID,
  8622. objectBuyPacket.AgentData.CategoryID,
  8623. d.ObjectLocalID,
  8624. d.SaleType,
  8625. d.SalePrice);
  8626. }
  8627. }
  8628. return true;
  8629. }
  8630. #endregion Economy/Transaction Packets
  8631. #region Script Packets
  8632. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8633. {
  8634. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8635. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8636. if (handlerGetScriptRunning != null)
  8637. {
  8638. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8639. }
  8640. return true;
  8641. }
  8642. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8643. {
  8644. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8645. #region Packet Session and User Check
  8646. if (m_checkPackets)
  8647. {
  8648. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8649. setScriptRunning.AgentData.AgentID != AgentId)
  8650. return true;
  8651. }
  8652. #endregion
  8653. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8654. if (handlerSetScriptRunning != null)
  8655. {
  8656. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8657. }
  8658. return true;
  8659. }
  8660. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8661. {
  8662. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8663. #region Packet Session and User Check
  8664. if (m_checkPackets)
  8665. {
  8666. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8667. scriptResetPacket.AgentData.AgentID != AgentId)
  8668. return true;
  8669. }
  8670. #endregion
  8671. ScriptReset handlerScriptReset = OnScriptReset;
  8672. if (handlerScriptReset != null)
  8673. {
  8674. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8675. }
  8676. return true;
  8677. }
  8678. #endregion Script Packets
  8679. #region Gesture Managment
  8680. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8681. {
  8682. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8683. #region Packet Session and User Check
  8684. if (m_checkPackets)
  8685. {
  8686. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8687. activateGesturePacket.AgentData.AgentID != AgentId)
  8688. return true;
  8689. }
  8690. #endregion
  8691. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8692. if (handlerActivateGesture != null)
  8693. {
  8694. handlerActivateGesture(this,
  8695. activateGesturePacket.Data[0].AssetID,
  8696. activateGesturePacket.Data[0].ItemID);
  8697. }
  8698. else m_log.Error("Null pointer for activateGesture");
  8699. return true;
  8700. }
  8701. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8702. {
  8703. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8704. #region Packet Session and User Check
  8705. if (m_checkPackets)
  8706. {
  8707. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8708. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8709. return true;
  8710. }
  8711. #endregion
  8712. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8713. if (handlerDeactivateGesture != null)
  8714. {
  8715. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8716. }
  8717. return true;
  8718. }
  8719. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8720. {
  8721. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8722. #region Packet Session and User Check
  8723. if (m_checkPackets)
  8724. {
  8725. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8726. objectOwnerPacket.AgentData.AgentID != AgentId)
  8727. return true;
  8728. }
  8729. #endregion
  8730. List<uint> localIDs = new List<uint>();
  8731. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8732. localIDs.Add(d.ObjectLocalID);
  8733. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8734. if (handlerObjectOwner != null)
  8735. {
  8736. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8737. }
  8738. return true;
  8739. }
  8740. #endregion Gesture Managment
  8741. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8742. {
  8743. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8744. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8745. {
  8746. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8747. AgentFOV handlerAgentFOV = OnAgentFOV;
  8748. if (handlerAgentFOV != null)
  8749. {
  8750. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8751. }
  8752. }
  8753. return true;
  8754. }
  8755. #region unimplemented handlers
  8756. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8757. {
  8758. // TODO: handle this packet
  8759. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8760. return true;
  8761. }
  8762. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8763. {
  8764. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8765. #region Packet Session and User Check
  8766. if (m_checkPackets)
  8767. {
  8768. if (mirpk.AgentData.SessionID != SessionId ||
  8769. mirpk.AgentData.AgentID != AgentId)
  8770. return true;
  8771. }
  8772. #endregion
  8773. //m_log.Debug(mirpk.ToString());
  8774. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8775. if (handlerMapItemRequest != null)
  8776. {
  8777. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8778. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8779. mirpk.RequestData.RegionHandle);
  8780. }
  8781. return true;
  8782. }
  8783. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8784. {
  8785. return true;
  8786. }
  8787. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8788. {
  8789. MuteListRequestPacket muteListRequest =
  8790. (MuteListRequestPacket)Pack;
  8791. #region Packet Session and User Check
  8792. if (m_checkPackets)
  8793. {
  8794. if (muteListRequest.AgentData.SessionID != SessionId ||
  8795. muteListRequest.AgentData.AgentID != AgentId)
  8796. return true;
  8797. }
  8798. #endregion
  8799. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8800. if (handlerMuteListRequest != null)
  8801. {
  8802. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8803. }
  8804. else
  8805. {
  8806. SendUseCachedMuteList();
  8807. }
  8808. return true;
  8809. }
  8810. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8811. {
  8812. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8813. (UpdateMuteListEntryPacket)Packet;
  8814. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8815. if (handlerUpdateMuteListEntry != null)
  8816. {
  8817. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8818. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8819. UpdateMuteListEntry.MuteData.MuteType,
  8820. UpdateMuteListEntry.AgentData.AgentID);
  8821. return true;
  8822. }
  8823. return false;
  8824. }
  8825. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8826. {
  8827. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8828. (RemoveMuteListEntryPacket)Packet;
  8829. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8830. if (handlerRemoveMuteListEntry != null)
  8831. {
  8832. handlerRemoveMuteListEntry(this,
  8833. RemoveMuteListEntry.MuteData.MuteID,
  8834. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8835. RemoveMuteListEntry.AgentData.AgentID);
  8836. return true;
  8837. }
  8838. return false;
  8839. }
  8840. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8841. {
  8842. UserReportPacket UserReport =
  8843. (UserReportPacket)Packet;
  8844. NewUserReport handlerUserReport = OnUserReport;
  8845. if (handlerUserReport != null)
  8846. {
  8847. handlerUserReport(this,
  8848. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8849. UserReport.ReportData.AbuserID,
  8850. UserReport.ReportData.Category,
  8851. UserReport.ReportData.CheckFlags,
  8852. Utils.BytesToString(UserReport.ReportData.Details),
  8853. UserReport.ReportData.ObjectID,
  8854. UserReport.ReportData.Position,
  8855. UserReport.ReportData.ReportType,
  8856. UserReport.ReportData.ScreenshotID,
  8857. Utils.BytesToString(UserReport.ReportData.Summary),
  8858. UserReport.AgentData.AgentID);
  8859. return true;
  8860. }
  8861. return false;
  8862. }
  8863. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8864. {
  8865. // SendPostcardPacket SendPostcard =
  8866. // (SendPostcardPacket)packet;
  8867. SendPostcard handlerSendPostcard = OnSendPostcard;
  8868. if (handlerSendPostcard != null)
  8869. {
  8870. handlerSendPostcard(this);
  8871. return true;
  8872. }
  8873. return false;
  8874. }
  8875. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8876. {
  8877. return true;
  8878. }
  8879. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8880. {
  8881. return true;
  8882. }
  8883. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8884. {
  8885. return true;
  8886. }
  8887. #endregion unimplemented handlers
  8888. #region Dir handlers
  8889. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8890. {
  8891. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8892. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8893. #region Packet Session and User Check
  8894. if (m_checkPackets)
  8895. {
  8896. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8897. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8898. return true;
  8899. }
  8900. #endregion
  8901. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8902. if (handlerDirPlacesQuery != null)
  8903. {
  8904. handlerDirPlacesQuery(this,
  8905. dirPlacesQueryPacket.QueryData.QueryID,
  8906. Utils.BytesToString(
  8907. dirPlacesQueryPacket.QueryData.QueryText),
  8908. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8909. (int)dirPlacesQueryPacket.QueryData.Category,
  8910. Utils.BytesToString(
  8911. dirPlacesQueryPacket.QueryData.SimName),
  8912. dirPlacesQueryPacket.QueryData.QueryStart);
  8913. }
  8914. return true;
  8915. }
  8916. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8917. {
  8918. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8919. #region Packet Session and User Check
  8920. if (m_checkPackets)
  8921. {
  8922. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8923. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8924. return true;
  8925. }
  8926. #endregion
  8927. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8928. if (handlerDirFindQuery != null)
  8929. {
  8930. handlerDirFindQuery(this,
  8931. dirFindQueryPacket.QueryData.QueryID,
  8932. Utils.BytesToString(
  8933. dirFindQueryPacket.QueryData.QueryText),
  8934. dirFindQueryPacket.QueryData.QueryFlags,
  8935. dirFindQueryPacket.QueryData.QueryStart);
  8936. }
  8937. return true;
  8938. }
  8939. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8940. {
  8941. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8942. #region Packet Session and User Check
  8943. if (m_checkPackets)
  8944. {
  8945. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8946. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8947. return true;
  8948. }
  8949. #endregion
  8950. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8951. if (handlerDirLandQuery != null)
  8952. {
  8953. handlerDirLandQuery(this,
  8954. dirLandQueryPacket.QueryData.QueryID,
  8955. dirLandQueryPacket.QueryData.QueryFlags,
  8956. dirLandQueryPacket.QueryData.SearchType,
  8957. dirLandQueryPacket.QueryData.Price,
  8958. dirLandQueryPacket.QueryData.Area,
  8959. dirLandQueryPacket.QueryData.QueryStart);
  8960. }
  8961. return true;
  8962. }
  8963. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8964. {
  8965. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8966. #region Packet Session and User Check
  8967. if (m_checkPackets)
  8968. {
  8969. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8970. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8971. return true;
  8972. }
  8973. #endregion
  8974. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8975. if (handlerDirPopularQuery != null)
  8976. {
  8977. handlerDirPopularQuery(this,
  8978. dirPopularQueryPacket.QueryData.QueryID,
  8979. dirPopularQueryPacket.QueryData.QueryFlags);
  8980. }
  8981. return true;
  8982. }
  8983. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8984. {
  8985. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8986. #region Packet Session and User Check
  8987. if (m_checkPackets)
  8988. {
  8989. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8990. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8991. return true;
  8992. }
  8993. #endregion
  8994. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8995. if (handlerDirClassifiedQuery != null)
  8996. {
  8997. handlerDirClassifiedQuery(this,
  8998. dirClassifiedQueryPacket.QueryData.QueryID,
  8999. Utils.BytesToString(
  9000. dirClassifiedQueryPacket.QueryData.QueryText),
  9001. dirClassifiedQueryPacket.QueryData.QueryFlags,
  9002. dirClassifiedQueryPacket.QueryData.Category,
  9003. dirClassifiedQueryPacket.QueryData.QueryStart);
  9004. }
  9005. return true;
  9006. }
  9007. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  9008. {
  9009. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  9010. #region Packet Session and User Check
  9011. if (m_checkPackets)
  9012. {
  9013. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9014. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9015. return true;
  9016. }
  9017. #endregion
  9018. if (OnEventInfoRequest != null)
  9019. {
  9020. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9021. }
  9022. return true;
  9023. }
  9024. #endregion
  9025. #region Calling Card
  9026. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9027. {
  9028. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9029. #region Packet Session and User Check
  9030. if (m_checkPackets)
  9031. {
  9032. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9033. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9034. return true;
  9035. }
  9036. #endregion
  9037. if (OnOfferCallingCard != null)
  9038. {
  9039. OnOfferCallingCard(this,
  9040. offerCallingCardPacket.AgentBlock.DestID,
  9041. offerCallingCardPacket.AgentBlock.TransactionID);
  9042. }
  9043. return true;
  9044. }
  9045. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9046. {
  9047. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9048. #region Packet Session and User Check
  9049. if (m_checkPackets)
  9050. {
  9051. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9052. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9053. return true;
  9054. }
  9055. #endregion
  9056. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9057. // contain exactly one entry
  9058. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9059. {
  9060. OnAcceptCallingCard(this,
  9061. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9062. acceptCallingCardPacket.FolderData[0].FolderID);
  9063. }
  9064. return true;
  9065. }
  9066. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9067. {
  9068. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9069. #region Packet Session and User Check
  9070. if (m_checkPackets)
  9071. {
  9072. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9073. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9074. return true;
  9075. }
  9076. #endregion
  9077. if (OnDeclineCallingCard != null)
  9078. {
  9079. OnDeclineCallingCard(this,
  9080. declineCallingCardPacket.TransactionBlock.TransactionID);
  9081. }
  9082. return true;
  9083. }
  9084. #endregion Calling Card
  9085. #region Groups
  9086. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9087. {
  9088. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9089. #region Packet Session and User Check
  9090. if (m_checkPackets)
  9091. {
  9092. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9093. activateGroupPacket.AgentData.AgentID != AgentId)
  9094. return true;
  9095. }
  9096. #endregion
  9097. if (m_GroupsModule != null)
  9098. {
  9099. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9100. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9101. }
  9102. return true;
  9103. }
  9104. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9105. {
  9106. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9107. (GroupVoteHistoryRequestPacket)Packet;
  9108. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9109. if (handlerGroupVoteHistoryRequest != null)
  9110. {
  9111. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9112. return true;
  9113. }
  9114. return false;
  9115. }
  9116. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9117. {
  9118. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9119. (GroupActiveProposalsRequestPacket)Packet;
  9120. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9121. if (handlerGroupActiveProposalsRequest != null)
  9122. {
  9123. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9124. return true;
  9125. }
  9126. return false;
  9127. }
  9128. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9129. {
  9130. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9131. (GroupAccountDetailsRequestPacket)Packet;
  9132. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9133. if (handlerGroupAccountDetailsRequest != null)
  9134. {
  9135. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9136. return true;
  9137. }
  9138. return false;
  9139. }
  9140. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9141. {
  9142. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9143. (GroupAccountSummaryRequestPacket)Packet;
  9144. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9145. if (handlerGroupAccountSummaryRequest != null)
  9146. {
  9147. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9148. return true;
  9149. }
  9150. return false;
  9151. }
  9152. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9153. {
  9154. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9155. (GroupAccountTransactionsRequestPacket)Packet;
  9156. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9157. if (handlerGroupAccountTransactionsRequest != null)
  9158. {
  9159. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9160. return true;
  9161. }
  9162. return false;
  9163. }
  9164. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9165. {
  9166. GroupTitlesRequestPacket groupTitlesRequest =
  9167. (GroupTitlesRequestPacket)Pack;
  9168. #region Packet Session and User Check
  9169. if (m_checkPackets)
  9170. {
  9171. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9172. groupTitlesRequest.AgentData.AgentID != AgentId)
  9173. return true;
  9174. }
  9175. #endregion
  9176. if (m_GroupsModule != null)
  9177. {
  9178. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9179. groupTitlesReply.AgentData =
  9180. new GroupTitlesReplyPacket.AgentDataBlock();
  9181. groupTitlesReply.AgentData.AgentID = AgentId;
  9182. groupTitlesReply.AgentData.GroupID =
  9183. groupTitlesRequest.AgentData.GroupID;
  9184. groupTitlesReply.AgentData.RequestID =
  9185. groupTitlesRequest.AgentData.RequestID;
  9186. List<GroupTitlesData> titles =
  9187. m_GroupsModule.GroupTitlesRequest(this,
  9188. groupTitlesRequest.AgentData.GroupID);
  9189. groupTitlesReply.GroupData =
  9190. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9191. int i = 0;
  9192. foreach (GroupTitlesData d in titles)
  9193. {
  9194. groupTitlesReply.GroupData[i] =
  9195. new GroupTitlesReplyPacket.GroupDataBlock();
  9196. groupTitlesReply.GroupData[i].Title =
  9197. Util.StringToBytes256(d.Name);
  9198. groupTitlesReply.GroupData[i].RoleID =
  9199. d.UUID;
  9200. groupTitlesReply.GroupData[i].Selected =
  9201. d.Selected;
  9202. i++;
  9203. }
  9204. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9205. }
  9206. return true;
  9207. }
  9208. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9209. {
  9210. GroupProfileRequestPacket groupProfileRequest =
  9211. (GroupProfileRequestPacket)Pack;
  9212. #region Packet Session and User Check
  9213. if (m_checkPackets)
  9214. {
  9215. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9216. groupProfileRequest.AgentData.AgentID != AgentId)
  9217. return true;
  9218. }
  9219. #endregion
  9220. if (m_GroupsModule != null)
  9221. {
  9222. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9223. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9224. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9225. groupProfileReply.AgentData.AgentID = AgentId;
  9226. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9227. groupProfileRequest.GroupData.GroupID);
  9228. groupProfileReply.GroupData.GroupID = d.GroupID;
  9229. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9230. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9231. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9232. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9233. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9234. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9235. groupProfileReply.GroupData.FounderID = d.FounderID;
  9236. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9237. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9238. groupProfileReply.GroupData.Money = d.Money;
  9239. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9240. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9241. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9242. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9243. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9244. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9245. }
  9246. return true;
  9247. }
  9248. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9249. {
  9250. GroupMembersRequestPacket groupMembersRequestPacket =
  9251. (GroupMembersRequestPacket)Pack;
  9252. #region Packet Session and User Check
  9253. if (m_checkPackets)
  9254. {
  9255. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9256. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9257. return true;
  9258. }
  9259. #endregion
  9260. if (m_GroupsModule != null)
  9261. {
  9262. List<GroupMembersData> members =
  9263. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9264. int memberCount = members.Count;
  9265. while (true)
  9266. {
  9267. int blockCount = members.Count;
  9268. if (blockCount > 40)
  9269. blockCount = 40;
  9270. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9271. groupMembersReply.AgentData =
  9272. new GroupMembersReplyPacket.AgentDataBlock();
  9273. groupMembersReply.GroupData =
  9274. new GroupMembersReplyPacket.GroupDataBlock();
  9275. groupMembersReply.MemberData =
  9276. new GroupMembersReplyPacket.MemberDataBlock[
  9277. blockCount];
  9278. groupMembersReply.AgentData.AgentID = AgentId;
  9279. groupMembersReply.GroupData.GroupID =
  9280. groupMembersRequestPacket.GroupData.GroupID;
  9281. groupMembersReply.GroupData.RequestID =
  9282. groupMembersRequestPacket.GroupData.RequestID;
  9283. groupMembersReply.GroupData.MemberCount = memberCount;
  9284. for (int i = 0; i < blockCount; i++)
  9285. {
  9286. GroupMembersData m = members[0];
  9287. members.RemoveAt(0);
  9288. groupMembersReply.MemberData[i] =
  9289. new GroupMembersReplyPacket.MemberDataBlock();
  9290. groupMembersReply.MemberData[i].AgentID =
  9291. m.AgentID;
  9292. groupMembersReply.MemberData[i].Contribution =
  9293. m.Contribution;
  9294. groupMembersReply.MemberData[i].OnlineStatus =
  9295. Util.StringToBytes256(m.OnlineStatus);
  9296. groupMembersReply.MemberData[i].AgentPowers =
  9297. m.AgentPowers;
  9298. groupMembersReply.MemberData[i].Title =
  9299. Util.StringToBytes256(m.Title);
  9300. groupMembersReply.MemberData[i].IsOwner =
  9301. m.IsOwner;
  9302. }
  9303. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9304. if (members.Count == 0)
  9305. return true;
  9306. }
  9307. }
  9308. return true;
  9309. }
  9310. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9311. {
  9312. GroupRoleDataRequestPacket groupRolesRequest =
  9313. (GroupRoleDataRequestPacket)Pack;
  9314. #region Packet Session and User Check
  9315. if (m_checkPackets)
  9316. {
  9317. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9318. groupRolesRequest.AgentData.AgentID != AgentId)
  9319. return true;
  9320. }
  9321. #endregion
  9322. if (m_GroupsModule != null)
  9323. {
  9324. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9325. groupRolesReply.AgentData =
  9326. new GroupRoleDataReplyPacket.AgentDataBlock();
  9327. groupRolesReply.AgentData.AgentID = AgentId;
  9328. groupRolesReply.GroupData =
  9329. new GroupRoleDataReplyPacket.GroupDataBlock();
  9330. groupRolesReply.GroupData.GroupID =
  9331. groupRolesRequest.GroupData.GroupID;
  9332. groupRolesReply.GroupData.RequestID =
  9333. groupRolesRequest.GroupData.RequestID;
  9334. List<GroupRolesData> titles =
  9335. m_GroupsModule.GroupRoleDataRequest(this,
  9336. groupRolesRequest.GroupData.GroupID);
  9337. groupRolesReply.GroupData.RoleCount =
  9338. titles.Count;
  9339. groupRolesReply.RoleData =
  9340. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9341. int i = 0;
  9342. foreach (GroupRolesData d in titles)
  9343. {
  9344. groupRolesReply.RoleData[i] =
  9345. new GroupRoleDataReplyPacket.RoleDataBlock();
  9346. groupRolesReply.RoleData[i].RoleID =
  9347. d.RoleID;
  9348. groupRolesReply.RoleData[i].Name =
  9349. Util.StringToBytes256(d.Name);
  9350. groupRolesReply.RoleData[i].Title =
  9351. Util.StringToBytes256(d.Title);
  9352. groupRolesReply.RoleData[i].Description =
  9353. Util.StringToBytes1024(d.Description);
  9354. groupRolesReply.RoleData[i].Powers =
  9355. d.Powers;
  9356. groupRolesReply.RoleData[i].Members =
  9357. (uint)d.Members;
  9358. i++;
  9359. }
  9360. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9361. }
  9362. return true;
  9363. }
  9364. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9365. {
  9366. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9367. (GroupRoleMembersRequestPacket)Pack;
  9368. #region Packet Session and User Check
  9369. if (m_checkPackets)
  9370. {
  9371. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9372. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9373. return true;
  9374. }
  9375. #endregion
  9376. if (m_GroupsModule != null)
  9377. {
  9378. List<GroupRoleMembersData> mappings =
  9379. m_GroupsModule.GroupRoleMembersRequest(this,
  9380. groupRoleMembersRequest.GroupData.GroupID);
  9381. int mappingsCount = mappings.Count;
  9382. while (mappings.Count > 0)
  9383. {
  9384. int pairs = mappings.Count;
  9385. if (pairs > 32)
  9386. pairs = 32;
  9387. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9388. groupRoleMembersReply.AgentData =
  9389. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9390. groupRoleMembersReply.AgentData.AgentID =
  9391. AgentId;
  9392. groupRoleMembersReply.AgentData.GroupID =
  9393. groupRoleMembersRequest.GroupData.GroupID;
  9394. groupRoleMembersReply.AgentData.RequestID =
  9395. groupRoleMembersRequest.GroupData.RequestID;
  9396. groupRoleMembersReply.AgentData.TotalPairs =
  9397. (uint)mappingsCount;
  9398. groupRoleMembersReply.MemberData =
  9399. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9400. for (int i = 0; i < pairs; i++)
  9401. {
  9402. GroupRoleMembersData d = mappings[0];
  9403. mappings.RemoveAt(0);
  9404. groupRoleMembersReply.MemberData[i] =
  9405. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9406. groupRoleMembersReply.MemberData[i].RoleID =
  9407. d.RoleID;
  9408. groupRoleMembersReply.MemberData[i].MemberID =
  9409. d.MemberID;
  9410. }
  9411. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9412. }
  9413. }
  9414. return true;
  9415. }
  9416. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9417. {
  9418. CreateGroupRequestPacket createGroupRequest =
  9419. (CreateGroupRequestPacket)Pack;
  9420. #region Packet Session and User Check
  9421. if (m_checkPackets)
  9422. {
  9423. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9424. createGroupRequest.AgentData.AgentID != AgentId)
  9425. return true;
  9426. }
  9427. #endregion
  9428. if (m_GroupsModule != null)
  9429. {
  9430. m_GroupsModule.CreateGroup(this,
  9431. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9432. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9433. createGroupRequest.GroupData.ShowInList,
  9434. createGroupRequest.GroupData.InsigniaID,
  9435. createGroupRequest.GroupData.MembershipFee,
  9436. createGroupRequest.GroupData.OpenEnrollment,
  9437. createGroupRequest.GroupData.AllowPublish,
  9438. createGroupRequest.GroupData.MaturePublish);
  9439. }
  9440. return true;
  9441. }
  9442. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9443. {
  9444. UpdateGroupInfoPacket updateGroupInfo =
  9445. (UpdateGroupInfoPacket)Pack;
  9446. #region Packet Session and User Check
  9447. if (m_checkPackets)
  9448. {
  9449. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9450. updateGroupInfo.AgentData.AgentID != AgentId)
  9451. return true;
  9452. }
  9453. #endregion
  9454. if (m_GroupsModule != null)
  9455. {
  9456. m_GroupsModule.UpdateGroupInfo(this,
  9457. updateGroupInfo.GroupData.GroupID,
  9458. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9459. updateGroupInfo.GroupData.ShowInList,
  9460. updateGroupInfo.GroupData.InsigniaID,
  9461. updateGroupInfo.GroupData.MembershipFee,
  9462. updateGroupInfo.GroupData.OpenEnrollment,
  9463. updateGroupInfo.GroupData.AllowPublish,
  9464. updateGroupInfo.GroupData.MaturePublish);
  9465. }
  9466. return true;
  9467. }
  9468. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9469. {
  9470. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9471. (SetGroupAcceptNoticesPacket)Pack;
  9472. #region Packet Session and User Check
  9473. if (m_checkPackets)
  9474. {
  9475. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9476. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9477. return true;
  9478. }
  9479. #endregion
  9480. if (m_GroupsModule != null)
  9481. {
  9482. m_GroupsModule.SetGroupAcceptNotices(this,
  9483. setGroupAcceptNotices.Data.GroupID,
  9484. setGroupAcceptNotices.Data.AcceptNotices,
  9485. setGroupAcceptNotices.NewData.ListInProfile);
  9486. }
  9487. return true;
  9488. }
  9489. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9490. {
  9491. GroupTitleUpdatePacket groupTitleUpdate =
  9492. (GroupTitleUpdatePacket)Pack;
  9493. #region Packet Session and User Check
  9494. if (m_checkPackets)
  9495. {
  9496. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9497. groupTitleUpdate.AgentData.AgentID != AgentId)
  9498. return true;
  9499. }
  9500. #endregion
  9501. if (m_GroupsModule != null)
  9502. {
  9503. m_GroupsModule.GroupTitleUpdate(this,
  9504. groupTitleUpdate.AgentData.GroupID,
  9505. groupTitleUpdate.AgentData.TitleRoleID);
  9506. }
  9507. return true;
  9508. }
  9509. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9510. {
  9511. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9512. if (m_GroupsModule != null)
  9513. {
  9514. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9515. if (handlerParcelDeedToGroup != null)
  9516. {
  9517. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9518. }
  9519. }
  9520. return true;
  9521. }
  9522. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9523. {
  9524. GroupNoticesListRequestPacket groupNoticesListRequest =
  9525. (GroupNoticesListRequestPacket)Pack;
  9526. #region Packet Session and User Check
  9527. if (m_checkPackets)
  9528. {
  9529. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9530. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9531. return true;
  9532. }
  9533. #endregion
  9534. if (m_GroupsModule != null)
  9535. {
  9536. GroupNoticeData[] gn =
  9537. m_GroupsModule.GroupNoticesListRequest(this,
  9538. groupNoticesListRequest.Data.GroupID);
  9539. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9540. groupNoticesListReply.AgentData =
  9541. new GroupNoticesListReplyPacket.AgentDataBlock();
  9542. groupNoticesListReply.AgentData.AgentID = AgentId;
  9543. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9544. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9545. int i = 0;
  9546. foreach (GroupNoticeData g in gn)
  9547. {
  9548. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9549. groupNoticesListReply.Data[i].NoticeID =
  9550. g.NoticeID;
  9551. groupNoticesListReply.Data[i].Timestamp =
  9552. g.Timestamp;
  9553. groupNoticesListReply.Data[i].FromName =
  9554. Util.StringToBytes256(g.FromName);
  9555. groupNoticesListReply.Data[i].Subject =
  9556. Util.StringToBytes256(g.Subject);
  9557. groupNoticesListReply.Data[i].HasAttachment =
  9558. g.HasAttachment;
  9559. groupNoticesListReply.Data[i].AssetType =
  9560. g.AssetType;
  9561. i++;
  9562. }
  9563. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9564. }
  9565. return true;
  9566. }
  9567. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9568. {
  9569. GroupNoticeRequestPacket groupNoticeRequest =
  9570. (GroupNoticeRequestPacket)Pack;
  9571. #region Packet Session and User Check
  9572. if (m_checkPackets)
  9573. {
  9574. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9575. groupNoticeRequest.AgentData.AgentID != AgentId)
  9576. return true;
  9577. }
  9578. #endregion
  9579. if (m_GroupsModule != null)
  9580. {
  9581. m_GroupsModule.GroupNoticeRequest(this,
  9582. groupNoticeRequest.Data.GroupNoticeID);
  9583. }
  9584. return true;
  9585. }
  9586. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9587. {
  9588. GroupRoleUpdatePacket groupRoleUpdate =
  9589. (GroupRoleUpdatePacket)Pack;
  9590. #region Packet Session and User Check
  9591. if (m_checkPackets)
  9592. {
  9593. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9594. groupRoleUpdate.AgentData.AgentID != AgentId)
  9595. return true;
  9596. }
  9597. #endregion
  9598. if (m_GroupsModule != null)
  9599. {
  9600. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9601. groupRoleUpdate.RoleData)
  9602. {
  9603. m_GroupsModule.GroupRoleUpdate(this,
  9604. groupRoleUpdate.AgentData.GroupID,
  9605. d.RoleID,
  9606. Utils.BytesToString(d.Name),
  9607. Utils.BytesToString(d.Description),
  9608. Utils.BytesToString(d.Title),
  9609. d.Powers,
  9610. d.UpdateType);
  9611. }
  9612. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9613. }
  9614. return true;
  9615. }
  9616. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9617. {
  9618. GroupRoleChangesPacket groupRoleChanges =
  9619. (GroupRoleChangesPacket)Pack;
  9620. #region Packet Session and User Check
  9621. if (m_checkPackets)
  9622. {
  9623. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9624. groupRoleChanges.AgentData.AgentID != AgentId)
  9625. return true;
  9626. }
  9627. #endregion
  9628. if (m_GroupsModule != null)
  9629. {
  9630. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9631. groupRoleChanges.RoleChange)
  9632. {
  9633. m_GroupsModule.GroupRoleChanges(this,
  9634. groupRoleChanges.AgentData.GroupID,
  9635. d.RoleID,
  9636. d.MemberID,
  9637. d.Change);
  9638. }
  9639. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9640. }
  9641. return true;
  9642. }
  9643. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9644. {
  9645. JoinGroupRequestPacket joinGroupRequest =
  9646. (JoinGroupRequestPacket)Pack;
  9647. #region Packet Session and User Check
  9648. if (m_checkPackets)
  9649. {
  9650. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9651. joinGroupRequest.AgentData.AgentID != AgentId)
  9652. return true;
  9653. }
  9654. #endregion
  9655. if (m_GroupsModule != null)
  9656. {
  9657. m_GroupsModule.JoinGroupRequest(this,
  9658. joinGroupRequest.GroupData.GroupID);
  9659. }
  9660. return true;
  9661. }
  9662. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9663. {
  9664. LeaveGroupRequestPacket leaveGroupRequest =
  9665. (LeaveGroupRequestPacket)Pack;
  9666. #region Packet Session and User Check
  9667. if (m_checkPackets)
  9668. {
  9669. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9670. leaveGroupRequest.AgentData.AgentID != AgentId)
  9671. return true;
  9672. }
  9673. #endregion
  9674. if (m_GroupsModule != null)
  9675. {
  9676. m_GroupsModule.LeaveGroupRequest(this,
  9677. leaveGroupRequest.GroupData.GroupID);
  9678. }
  9679. return true;
  9680. }
  9681. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9682. {
  9683. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9684. (EjectGroupMemberRequestPacket)Pack;
  9685. #region Packet Session and User Check
  9686. if (m_checkPackets)
  9687. {
  9688. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9689. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9690. return true;
  9691. }
  9692. #endregion
  9693. if (m_GroupsModule != null)
  9694. {
  9695. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9696. in ejectGroupMemberRequest.EjectData)
  9697. {
  9698. m_GroupsModule.EjectGroupMemberRequest(this,
  9699. ejectGroupMemberRequest.GroupData.GroupID,
  9700. e.EjecteeID);
  9701. }
  9702. }
  9703. return true;
  9704. }
  9705. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9706. {
  9707. InviteGroupRequestPacket inviteGroupRequest =
  9708. (InviteGroupRequestPacket)Pack;
  9709. #region Packet Session and User Check
  9710. if (m_checkPackets)
  9711. {
  9712. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9713. inviteGroupRequest.AgentData.AgentID != AgentId)
  9714. return true;
  9715. }
  9716. #endregion
  9717. if (m_GroupsModule != null)
  9718. {
  9719. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9720. inviteGroupRequest.InviteData)
  9721. {
  9722. m_GroupsModule.InviteGroupRequest(this,
  9723. inviteGroupRequest.GroupData.GroupID,
  9724. b.InviteeID,
  9725. b.RoleID);
  9726. }
  9727. }
  9728. return true;
  9729. }
  9730. #endregion Groups
  9731. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9732. {
  9733. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9734. #region Packet Session and User Check
  9735. if (m_checkPackets)
  9736. {
  9737. if (startLureRequest.AgentData.SessionID != SessionId ||
  9738. startLureRequest.AgentData.AgentID != AgentId)
  9739. return true;
  9740. }
  9741. #endregion
  9742. StartLure handlerStartLure = OnStartLure;
  9743. if (handlerStartLure != null)
  9744. handlerStartLure(startLureRequest.Info.LureType,
  9745. Utils.BytesToString(
  9746. startLureRequest.Info.Message),
  9747. startLureRequest.TargetData[0].TargetID,
  9748. this);
  9749. return true;
  9750. }
  9751. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9752. {
  9753. TeleportLureRequestPacket teleportLureRequest =
  9754. (TeleportLureRequestPacket)Pack;
  9755. #region Packet Session and User Check
  9756. if (m_checkPackets)
  9757. {
  9758. if (teleportLureRequest.Info.SessionID != SessionId ||
  9759. teleportLureRequest.Info.AgentID != AgentId)
  9760. return true;
  9761. }
  9762. #endregion
  9763. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9764. if (handlerTeleportLureRequest != null)
  9765. handlerTeleportLureRequest(
  9766. teleportLureRequest.Info.LureID,
  9767. teleportLureRequest.Info.TeleportFlags,
  9768. this);
  9769. return true;
  9770. }
  9771. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9772. {
  9773. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9774. (ClassifiedInfoRequestPacket)Pack;
  9775. #region Packet Session and User Check
  9776. if (m_checkPackets)
  9777. {
  9778. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9779. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9780. return true;
  9781. }
  9782. #endregion
  9783. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9784. if (handlerClassifiedInfoRequest != null)
  9785. handlerClassifiedInfoRequest(
  9786. classifiedInfoRequest.Data.ClassifiedID,
  9787. this);
  9788. return true;
  9789. }
  9790. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9791. {
  9792. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9793. (ClassifiedInfoUpdatePacket)Pack;
  9794. #region Packet Session and User Check
  9795. if (m_checkPackets)
  9796. {
  9797. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9798. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9799. return true;
  9800. }
  9801. #endregion
  9802. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9803. if (handlerClassifiedInfoUpdate != null)
  9804. handlerClassifiedInfoUpdate(
  9805. classifiedInfoUpdate.Data.ClassifiedID,
  9806. classifiedInfoUpdate.Data.Category,
  9807. Utils.BytesToString(
  9808. classifiedInfoUpdate.Data.Name),
  9809. Utils.BytesToString(
  9810. classifiedInfoUpdate.Data.Desc),
  9811. classifiedInfoUpdate.Data.ParcelID,
  9812. classifiedInfoUpdate.Data.ParentEstate,
  9813. classifiedInfoUpdate.Data.SnapshotID,
  9814. new Vector3(
  9815. classifiedInfoUpdate.Data.PosGlobal),
  9816. classifiedInfoUpdate.Data.ClassifiedFlags,
  9817. classifiedInfoUpdate.Data.PriceForListing,
  9818. this);
  9819. return true;
  9820. }
  9821. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9822. {
  9823. ClassifiedDeletePacket classifiedDelete =
  9824. (ClassifiedDeletePacket)Pack;
  9825. #region Packet Session and User Check
  9826. if (m_checkPackets)
  9827. {
  9828. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9829. classifiedDelete.AgentData.AgentID != AgentId)
  9830. return true;
  9831. }
  9832. #endregion
  9833. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9834. if (handlerClassifiedDelete != null)
  9835. handlerClassifiedDelete(
  9836. classifiedDelete.Data.ClassifiedID,
  9837. this);
  9838. return true;
  9839. }
  9840. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9841. {
  9842. ClassifiedGodDeletePacket classifiedGodDelete =
  9843. (ClassifiedGodDeletePacket)Pack;
  9844. #region Packet Session and User Check
  9845. if (m_checkPackets)
  9846. {
  9847. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9848. classifiedGodDelete.AgentData.AgentID != AgentId)
  9849. return true;
  9850. }
  9851. #endregion
  9852. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9853. if (handlerClassifiedGodDelete != null)
  9854. handlerClassifiedGodDelete(
  9855. classifiedGodDelete.Data.ClassifiedID,
  9856. this);
  9857. return true;
  9858. }
  9859. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9860. {
  9861. EventGodDeletePacket eventGodDelete =
  9862. (EventGodDeletePacket)Pack;
  9863. #region Packet Session and User Check
  9864. if (m_checkPackets)
  9865. {
  9866. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9867. eventGodDelete.AgentData.AgentID != AgentId)
  9868. return true;
  9869. }
  9870. #endregion
  9871. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9872. if (handlerEventGodDelete != null)
  9873. handlerEventGodDelete(
  9874. eventGodDelete.EventData.EventID,
  9875. eventGodDelete.QueryData.QueryID,
  9876. Utils.BytesToString(
  9877. eventGodDelete.QueryData.QueryText),
  9878. eventGodDelete.QueryData.QueryFlags,
  9879. eventGodDelete.QueryData.QueryStart,
  9880. this);
  9881. return true;
  9882. }
  9883. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9884. {
  9885. EventNotificationAddRequestPacket eventNotificationAdd =
  9886. (EventNotificationAddRequestPacket)Pack;
  9887. #region Packet Session and User Check
  9888. if (m_checkPackets)
  9889. {
  9890. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9891. eventNotificationAdd.AgentData.AgentID != AgentId)
  9892. return true;
  9893. }
  9894. #endregion
  9895. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9896. if (handlerEventNotificationAddRequest != null)
  9897. handlerEventNotificationAddRequest(
  9898. eventNotificationAdd.EventData.EventID, this);
  9899. return true;
  9900. }
  9901. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9902. {
  9903. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9904. (EventNotificationRemoveRequestPacket)Pack;
  9905. #region Packet Session and User Check
  9906. if (m_checkPackets)
  9907. {
  9908. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9909. eventNotificationRemove.AgentData.AgentID != AgentId)
  9910. return true;
  9911. }
  9912. #endregion
  9913. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9914. if (handlerEventNotificationRemoveRequest != null)
  9915. handlerEventNotificationRemoveRequest(
  9916. eventNotificationRemove.EventData.EventID, this);
  9917. return true;
  9918. }
  9919. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9920. {
  9921. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9922. #region Packet Session and User Check
  9923. if (m_checkPackets)
  9924. {
  9925. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9926. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9927. return true;
  9928. }
  9929. #endregion
  9930. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9931. if (handlerRetrieveInstantMessages != null)
  9932. handlerRetrieveInstantMessages(this);
  9933. return true;
  9934. }
  9935. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9936. {
  9937. PickDeletePacket pickDelete =
  9938. (PickDeletePacket)Pack;
  9939. #region Packet Session and User Check
  9940. if (m_checkPackets)
  9941. {
  9942. if (pickDelete.AgentData.SessionID != SessionId ||
  9943. pickDelete.AgentData.AgentID != AgentId)
  9944. return true;
  9945. }
  9946. #endregion
  9947. PickDelete handlerPickDelete = OnPickDelete;
  9948. if (handlerPickDelete != null)
  9949. handlerPickDelete(this, pickDelete.Data.PickID);
  9950. return true;
  9951. }
  9952. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9953. {
  9954. PickGodDeletePacket pickGodDelete =
  9955. (PickGodDeletePacket)Pack;
  9956. #region Packet Session and User Check
  9957. if (m_checkPackets)
  9958. {
  9959. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9960. pickGodDelete.AgentData.AgentID != AgentId)
  9961. return true;
  9962. }
  9963. #endregion
  9964. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9965. if (handlerPickGodDelete != null)
  9966. handlerPickGodDelete(this,
  9967. pickGodDelete.AgentData.AgentID,
  9968. pickGodDelete.Data.PickID,
  9969. pickGodDelete.Data.QueryID);
  9970. return true;
  9971. }
  9972. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9973. {
  9974. PickInfoUpdatePacket pickInfoUpdate =
  9975. (PickInfoUpdatePacket)Pack;
  9976. #region Packet Session and User Check
  9977. if (m_checkPackets)
  9978. {
  9979. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9980. pickInfoUpdate.AgentData.AgentID != AgentId)
  9981. return true;
  9982. }
  9983. #endregion
  9984. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9985. if (handlerPickInfoUpdate != null)
  9986. handlerPickInfoUpdate(this,
  9987. pickInfoUpdate.Data.PickID,
  9988. pickInfoUpdate.Data.CreatorID,
  9989. pickInfoUpdate.Data.TopPick,
  9990. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9991. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9992. pickInfoUpdate.Data.SnapshotID,
  9993. pickInfoUpdate.Data.SortOrder,
  9994. pickInfoUpdate.Data.Enabled);
  9995. return true;
  9996. }
  9997. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9998. {
  9999. AvatarNotesUpdatePacket avatarNotesUpdate =
  10000. (AvatarNotesUpdatePacket)Pack;
  10001. #region Packet Session and User Check
  10002. if (m_checkPackets)
  10003. {
  10004. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  10005. avatarNotesUpdate.AgentData.AgentID != AgentId)
  10006. return true;
  10007. }
  10008. #endregion
  10009. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  10010. if (handlerAvatarNotesUpdate != null)
  10011. handlerAvatarNotesUpdate(this,
  10012. avatarNotesUpdate.Data.TargetID,
  10013. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10014. return true;
  10015. }
  10016. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10017. {
  10018. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10019. (AvatarInterestsUpdatePacket)Pack;
  10020. #region Packet Session and User Check
  10021. if (m_checkPackets)
  10022. {
  10023. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10024. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10025. return true;
  10026. }
  10027. #endregion
  10028. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10029. if (handlerAvatarInterestUpdate != null)
  10030. handlerAvatarInterestUpdate(this,
  10031. avatarInterestUpdate.PropertiesData.WantToMask,
  10032. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10033. avatarInterestUpdate.PropertiesData.SkillsMask,
  10034. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10035. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10036. return true;
  10037. }
  10038. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10039. {
  10040. GrantUserRightsPacket GrantUserRights =
  10041. (GrantUserRightsPacket)Pack;
  10042. #region Packet Session and User Check
  10043. if (m_checkPackets)
  10044. {
  10045. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10046. GrantUserRights.AgentData.AgentID != AgentId)
  10047. return true;
  10048. }
  10049. #endregion
  10050. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10051. if (GrantUserRightsHandler != null)
  10052. GrantUserRightsHandler(this,
  10053. GrantUserRights.Rights[0].AgentRelated,
  10054. GrantUserRights.Rights[0].RelatedRights);
  10055. return true;
  10056. }
  10057. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10058. {
  10059. PlacesQueryPacket placesQueryPacket =
  10060. (PlacesQueryPacket)Pack;
  10061. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10062. if (handlerPlacesQuery != null)
  10063. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10064. placesQueryPacket.TransactionData.TransactionID,
  10065. Utils.BytesToString(
  10066. placesQueryPacket.QueryData.QueryText),
  10067. placesQueryPacket.QueryData.QueryFlags,
  10068. (byte)placesQueryPacket.QueryData.Category,
  10069. Utils.BytesToString(
  10070. placesQueryPacket.QueryData.SimName),
  10071. this);
  10072. return true;
  10073. }
  10074. #endregion Packet Handlers
  10075. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10076. {
  10077. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10078. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10079. // TODO: don't create new blocks if recycling an old packet
  10080. scriptQuestion.Data.TaskID = taskID;
  10081. scriptQuestion.Data.ItemID = itemID;
  10082. scriptQuestion.Data.Questions = question;
  10083. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10084. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10085. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10086. }
  10087. /// <summary>
  10088. /// Handler called when we receive a logout packet.
  10089. /// </summary>
  10090. /// <param name="client"></param>
  10091. /// <param name="packet"></param>
  10092. /// <returns></returns>
  10093. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10094. {
  10095. if (packet.Type == PacketType.LogoutRequest)
  10096. {
  10097. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10098. }
  10099. return Logout(client);
  10100. }
  10101. /// <summary>
  10102. ///
  10103. /// </summary>
  10104. /// <param name="client"></param>
  10105. /// <returns></returns>
  10106. protected virtual bool Logout(IClientAPI client)
  10107. {
  10108. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10109. Action<IClientAPI> handlerLogout = OnLogout;
  10110. if (handlerLogout != null)
  10111. {
  10112. handlerLogout(client);
  10113. }
  10114. return true;
  10115. }
  10116. /// <summary>
  10117. /// </summary>
  10118. /// <remarks>
  10119. /// At the moment, we always reply that there is no cached texture.
  10120. /// </remarks>
  10121. /// <param name="simclient"></param>
  10122. /// <param name="packet"></param>
  10123. /// <returns></returns>
  10124. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10125. {
  10126. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10127. if (cachedtex.AgentData.SessionID != SessionId)
  10128. return false;
  10129. List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
  10130. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  10131. {
  10132. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  10133. arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
  10134. arg.WearableHashID = cachedtex.WearableData[i].ID;
  10135. requestArgs.Add(arg);
  10136. }
  10137. try
  10138. {
  10139. CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
  10140. if (handlerCachedTextureRequest != null)
  10141. {
  10142. handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
  10143. }
  10144. }
  10145. catch (Exception e)
  10146. {
  10147. m_log.ErrorFormat("[CLIENT VIEW]: AgentTextureCached packet handler threw an exception, {0}", e);
  10148. return false;
  10149. }
  10150. return true;
  10151. }
  10152. /// <summary>
  10153. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10154. /// its appearance texture cached.
  10155. /// </summary>
  10156. /// <param name="avatar"></param>
  10157. /// <param name="serial"></param>
  10158. /// <param name="cachedTextures"></param>
  10159. /// <returns></returns>
  10160. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10161. {
  10162. ScenePresence presence = avatar as ScenePresence;
  10163. if (presence == null)
  10164. return;
  10165. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10166. // TODO: don't create new blocks if recycling an old packet
  10167. cachedresp.AgentData.AgentID = m_agentId;
  10168. cachedresp.AgentData.SessionID = m_sessionId;
  10169. cachedresp.AgentData.SerialNum = serial;
  10170. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10171. for (int i = 0; i < cachedTextures.Count; i++)
  10172. {
  10173. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10174. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10175. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10176. cachedresp.WearableData[i].HostName = new byte[0];
  10177. }
  10178. cachedresp.Header.Zerocoded = true;
  10179. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10180. }
  10181. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10182. {
  10183. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10184. if (multipleupdate.AgentData.SessionID != SessionId)
  10185. return false;
  10186. // m_log.DebugFormat(
  10187. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10188. Scene tScene = (Scene)m_scene;
  10189. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10190. {
  10191. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10192. // Can't act on Null Data
  10193. if (block.Data != null)
  10194. {
  10195. uint localId = block.ObjectLocalID;
  10196. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10197. if (part == null)
  10198. {
  10199. // It's a ghost! tell the client to delete it from view.
  10200. simClient.SendKillObject(new List<uint> { localId });
  10201. }
  10202. else
  10203. {
  10204. // m_log.DebugFormat(
  10205. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10206. // i, block.Type, part.Name, part.LocalId);
  10207. // // Do this once since fetch parts creates a new array.
  10208. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10209. // for (int j = 0; j < parts.Length; j++)
  10210. // {
  10211. // part.StoreUndoState();
  10212. // parts[j].IgnoreUndoUpdate = true;
  10213. // }
  10214. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10215. switch (block.Type)
  10216. {
  10217. case 1:
  10218. Vector3 pos1 = new Vector3(block.Data, 0);
  10219. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10220. if (handlerUpdatePrimSinglePosition != null)
  10221. {
  10222. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10223. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10224. }
  10225. break;
  10226. case 2:
  10227. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10228. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10229. if (handlerUpdatePrimSingleRotation != null)
  10230. {
  10231. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10232. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10233. }
  10234. break;
  10235. case 3:
  10236. Vector3 rotPos = new Vector3(block.Data, 0);
  10237. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10238. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10239. if (handlerUpdatePrimSingleRotationPosition != null)
  10240. {
  10241. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10242. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10243. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10244. }
  10245. break;
  10246. case 4:
  10247. case 20:
  10248. Vector3 scale4 = new Vector3(block.Data, 0);
  10249. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10250. if (handlerUpdatePrimScale != null)
  10251. {
  10252. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10253. handlerUpdatePrimScale(localId, scale4, this);
  10254. }
  10255. break;
  10256. case 5:
  10257. Vector3 scale1 = new Vector3(block.Data, 12);
  10258. Vector3 pos11 = new Vector3(block.Data, 0);
  10259. handlerUpdatePrimScale = OnUpdatePrimScale;
  10260. if (handlerUpdatePrimScale != null)
  10261. {
  10262. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10263. handlerUpdatePrimScale(localId, scale1, this);
  10264. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10265. if (handlerUpdatePrimSinglePosition != null)
  10266. {
  10267. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10268. }
  10269. }
  10270. break;
  10271. case 9:
  10272. Vector3 pos2 = new Vector3(block.Data, 0);
  10273. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10274. if (handlerUpdateVector != null)
  10275. {
  10276. handlerUpdateVector(localId, pos2, this);
  10277. }
  10278. break;
  10279. case 10:
  10280. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10281. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10282. if (handlerUpdatePrimRotation != null)
  10283. {
  10284. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10285. handlerUpdatePrimRotation(localId, rot3, this);
  10286. }
  10287. break;
  10288. case 11:
  10289. Vector3 pos3 = new Vector3(block.Data, 0);
  10290. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10291. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10292. if (handlerUpdatePrimGroupRotation != null)
  10293. {
  10294. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10295. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10296. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10297. }
  10298. break;
  10299. case 12:
  10300. case 28:
  10301. Vector3 scale7 = new Vector3(block.Data, 0);
  10302. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10303. if (handlerUpdatePrimGroupScale != null)
  10304. {
  10305. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10306. handlerUpdatePrimGroupScale(localId, scale7, this);
  10307. }
  10308. break;
  10309. case 13:
  10310. Vector3 scale2 = new Vector3(block.Data, 12);
  10311. Vector3 pos4 = new Vector3(block.Data, 0);
  10312. handlerUpdatePrimScale = OnUpdatePrimScale;
  10313. if (handlerUpdatePrimScale != null)
  10314. {
  10315. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10316. handlerUpdatePrimScale(localId, scale2, this);
  10317. // Change the position based on scale (for bug number 246)
  10318. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10319. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10320. if (handlerUpdatePrimSinglePosition != null)
  10321. {
  10322. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10323. }
  10324. }
  10325. break;
  10326. case 29:
  10327. Vector3 scale5 = new Vector3(block.Data, 12);
  10328. Vector3 pos5 = new Vector3(block.Data, 0);
  10329. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10330. if (handlerUpdatePrimGroupScale != null)
  10331. {
  10332. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10333. part.StoreUndoState(true);
  10334. part.IgnoreUndoUpdate = true;
  10335. handlerUpdatePrimGroupScale(localId, scale5, this);
  10336. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10337. if (handlerUpdateVector != null)
  10338. {
  10339. handlerUpdateVector(localId, pos5, this);
  10340. }
  10341. part.IgnoreUndoUpdate = false;
  10342. }
  10343. break;
  10344. case 21:
  10345. Vector3 scale6 = new Vector3(block.Data, 12);
  10346. Vector3 pos6 = new Vector3(block.Data, 0);
  10347. handlerUpdatePrimScale = OnUpdatePrimScale;
  10348. if (handlerUpdatePrimScale != null)
  10349. {
  10350. part.StoreUndoState(false);
  10351. part.IgnoreUndoUpdate = true;
  10352. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10353. handlerUpdatePrimScale(localId, scale6, this);
  10354. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10355. if (handlerUpdatePrimSinglePosition != null)
  10356. {
  10357. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10358. }
  10359. part.IgnoreUndoUpdate = false;
  10360. }
  10361. break;
  10362. default:
  10363. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10364. break;
  10365. }
  10366. // for (int j = 0; j < parts.Length; j++)
  10367. // parts[j].IgnoreUndoUpdate = false;
  10368. }
  10369. }
  10370. }
  10371. return true;
  10372. }
  10373. public void RequestMapLayer()
  10374. {
  10375. //should be getting the map layer from the grid server
  10376. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10377. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10378. // TODO: don't create new blocks if recycling an old packet
  10379. mapReply.AgentData.AgentID = AgentId;
  10380. mapReply.AgentData.Flags = 0;
  10381. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10382. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10383. mapReply.LayerData[0].Bottom = 0;
  10384. mapReply.LayerData[0].Left = 0;
  10385. mapReply.LayerData[0].Top = 30000;
  10386. mapReply.LayerData[0].Right = 30000;
  10387. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10388. mapReply.Header.Zerocoded = true;
  10389. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10390. }
  10391. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10392. {
  10393. /*
  10394. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10395. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10396. mbReply.AgentData.AgentId = AgentId;
  10397. int len;
  10398. if (simMapProfiles == null)
  10399. len = 0;
  10400. else
  10401. len = simMapProfiles.Count;
  10402. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10403. int iii;
  10404. for (iii = 0; iii < len; iii++)
  10405. {
  10406. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10407. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10408. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10409. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10410. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10411. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10412. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10413. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10414. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10415. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10416. }
  10417. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10418. */
  10419. }
  10420. /// <summary>
  10421. /// Sets the throttles from values supplied by the client
  10422. /// </summary>
  10423. /// <param name="throttles"></param>
  10424. public void SetChildAgentThrottle(byte[] throttles)
  10425. {
  10426. m_udpClient.SetThrottles(throttles);
  10427. }
  10428. /// <summary>
  10429. /// Get the current throttles for this client as a packed byte array
  10430. /// </summary>
  10431. /// <param name="multiplier">Unused</param>
  10432. /// <returns></returns>
  10433. public byte[] GetThrottlesPacked(float multiplier)
  10434. {
  10435. return m_udpClient.GetThrottlesPacked(multiplier);
  10436. }
  10437. /// <summary>
  10438. /// Cruft?
  10439. /// </summary>
  10440. public virtual void InPacket(object NewPack)
  10441. {
  10442. throw new NotImplementedException();
  10443. }
  10444. /// <summary>
  10445. /// This is the starting point for sending a simulator packet out to the client
  10446. /// </summary>
  10447. /// <param name="packet">Packet to send</param>
  10448. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10449. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10450. {
  10451. #region BinaryStats
  10452. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10453. #endregion BinaryStats
  10454. OutPacket(packet, throttlePacketType, true);
  10455. }
  10456. /// <summary>
  10457. /// This is the starting point for sending a simulator packet out to the client
  10458. /// </summary>
  10459. /// <param name="packet">Packet to send</param>
  10460. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10461. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10462. /// packets (the default), or false to disable splitting if the calling code
  10463. /// handles splitting manually</param>
  10464. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10465. {
  10466. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10467. }
  10468. /// <summary>
  10469. /// This is the starting point for sending a simulator packet out to the client
  10470. /// </summary>
  10471. /// <param name="packet">Packet to send</param>
  10472. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10473. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10474. /// packets (the default), or false to disable splitting if the calling code
  10475. /// handles splitting manually</param>
  10476. /// <param name="method">The method to be called in the event this packet is reliable
  10477. /// and unacknowledged. The server will provide normal resend capability if you do not
  10478. /// provide your own method.</param>
  10479. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10480. {
  10481. if (DebugPacketLevel > 0)
  10482. {
  10483. bool logPacket = true;
  10484. if (DebugPacketLevel <= 255
  10485. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10486. logPacket = false;
  10487. if (DebugPacketLevel <= 200
  10488. && (packet.Type == PacketType.ImagePacket
  10489. || packet.Type == PacketType.ImageData
  10490. || packet.Type == PacketType.LayerData
  10491. || packet.Type == PacketType.CoarseLocationUpdate))
  10492. logPacket = false;
  10493. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10494. logPacket = false;
  10495. if (DebugPacketLevel <= 50
  10496. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10497. logPacket = false;
  10498. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10499. logPacket = false;
  10500. if (logPacket)
  10501. m_log.DebugFormat(
  10502. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10503. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10504. }
  10505. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10506. }
  10507. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10508. {
  10509. float locx = 0;
  10510. float locy = 0;
  10511. float locz = 0;
  10512. uint regionX = 0;
  10513. uint regionY = 0;
  10514. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10515. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10516. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10517. locz = Convert.ToSingle(args[2]);
  10518. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10519. if (handlerAutoPilotGo != null)
  10520. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10521. }
  10522. /// <summary>
  10523. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10524. /// </summary>
  10525. /// <param name="Pack">OpenMetaverse.packet</param>
  10526. public void ProcessInPacket(Packet packet)
  10527. {
  10528. if (DebugPacketLevel > 0)
  10529. {
  10530. bool logPacket = true;
  10531. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10532. logPacket = false;
  10533. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10534. logPacket = false;
  10535. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10536. logPacket = false;
  10537. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10538. logPacket = false;
  10539. if (logPacket)
  10540. m_log.DebugFormat(
  10541. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10542. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10543. }
  10544. if (!ProcessPacketMethod(packet))
  10545. m_log.WarnFormat(
  10546. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10547. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10548. }
  10549. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10550. {
  10551. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10552. shape.PCode = addPacket.ObjectData.PCode;
  10553. shape.State = addPacket.ObjectData.State;
  10554. shape.LastAttachPoint = addPacket.ObjectData.State;
  10555. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10556. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10557. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10558. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10559. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10560. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10561. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10562. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10563. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10564. shape.Scale = addPacket.ObjectData.Scale;
  10565. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10566. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10567. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10568. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10569. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10570. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10571. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10572. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10573. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10574. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10575. shape.TextureEntry = ntex.GetBytes();
  10576. //shape.Textures = ntex;
  10577. return shape;
  10578. }
  10579. public ClientInfo GetClientInfo()
  10580. {
  10581. ClientInfo info = m_udpClient.GetClientInfo();
  10582. info.proxyEP = null;
  10583. if (info.agentcircuit == null)
  10584. info.agentcircuit = RequestClientInfo();
  10585. return info;
  10586. }
  10587. public void SetClientInfo(ClientInfo info)
  10588. {
  10589. m_udpClient.SetClientInfo(info);
  10590. }
  10591. #region Media Parcel Members
  10592. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10593. {
  10594. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10595. commandMessagePacket.CommandBlock.Flags = flags;
  10596. commandMessagePacket.CommandBlock.Command = (uint)command;
  10597. commandMessagePacket.CommandBlock.Time = time;
  10598. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10599. }
  10600. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10601. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10602. byte mediaLoop)
  10603. {
  10604. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10605. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10606. updatePacket.DataBlock.MediaID = mediaTextureID;
  10607. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10608. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10609. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10610. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10611. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10612. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10613. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10614. }
  10615. #endregion
  10616. #region Camera
  10617. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10618. {
  10619. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10620. packet.ObjectData.ObjectID = objectID;
  10621. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10622. uint idx = 0;
  10623. foreach (KeyValuePair<int, float> pair in parameters)
  10624. {
  10625. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10626. block.Type = pair.Key;
  10627. block.Value = pair.Value;
  10628. camPropBlock[idx++] = block;
  10629. }
  10630. packet.CameraProperty = camPropBlock;
  10631. OutPacket(packet, ThrottleOutPacketType.Task);
  10632. }
  10633. public void SendClearFollowCamProperties(UUID objectID)
  10634. {
  10635. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10636. packet.ObjectData.ObjectID = objectID;
  10637. OutPacket(packet, ThrottleOutPacketType.Task);
  10638. }
  10639. #endregion
  10640. public void SetClientOption(string option, string value)
  10641. {
  10642. switch (option)
  10643. {
  10644. default:
  10645. break;
  10646. }
  10647. }
  10648. public string GetClientOption(string option)
  10649. {
  10650. switch (option)
  10651. {
  10652. default:
  10653. break;
  10654. }
  10655. return string.Empty;
  10656. }
  10657. #region IClientCore
  10658. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10659. /// <summary>
  10660. /// Register an interface on this client, should only be called in the constructor.
  10661. /// </summary>
  10662. /// <typeparam name="T"></typeparam>
  10663. /// <param name="iface"></param>
  10664. protected void RegisterInterface<T>(T iface)
  10665. {
  10666. lock (m_clientInterfaces)
  10667. {
  10668. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10669. {
  10670. m_clientInterfaces.Add(typeof(T), iface);
  10671. }
  10672. }
  10673. }
  10674. public bool TryGet<T>(out T iface)
  10675. {
  10676. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10677. {
  10678. iface = (T)m_clientInterfaces[typeof(T)];
  10679. return true;
  10680. }
  10681. iface = default(T);
  10682. return false;
  10683. }
  10684. public T Get<T>()
  10685. {
  10686. return (T)m_clientInterfaces[typeof(T)];
  10687. }
  10688. public void Disconnect(string reason)
  10689. {
  10690. Kick(reason);
  10691. Thread.Sleep(1000);
  10692. Disconnect();
  10693. }
  10694. public void Disconnect()
  10695. {
  10696. Close();
  10697. }
  10698. #endregion
  10699. public void RefreshGroupMembership()
  10700. {
  10701. if (m_GroupsModule != null)
  10702. {
  10703. GroupMembershipData[] GroupMembership =
  10704. m_GroupsModule.GetMembershipData(AgentId);
  10705. m_groupPowers.Clear();
  10706. if (GroupMembership != null)
  10707. {
  10708. for (int i = 0; i < GroupMembership.Length; i++)
  10709. {
  10710. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10711. }
  10712. }
  10713. }
  10714. }
  10715. public string Report()
  10716. {
  10717. return m_udpClient.GetStats();
  10718. }
  10719. public string XReport(string uptime, string version)
  10720. {
  10721. return String.Empty;
  10722. }
  10723. public OSDMap OReport(string uptime, string version)
  10724. {
  10725. return new OSDMap();
  10726. }
  10727. /// <summary>
  10728. /// Make an asset request to the asset service in response to a client request.
  10729. /// </summary>
  10730. /// <param name="transferRequest"></param>
  10731. /// <param name="taskID"></param>
  10732. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10733. {
  10734. UUID requestID = UUID.Zero;
  10735. int sourceType = transferRequest.TransferInfo.SourceType;
  10736. if (sourceType == (int)SourceType.Asset)
  10737. {
  10738. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10739. }
  10740. else if (sourceType == (int)SourceType.SimInventoryItem)
  10741. {
  10742. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10743. }
  10744. else if (sourceType == (int)SourceType.SimEstate)
  10745. {
  10746. requestID = taskID;
  10747. }
  10748. // m_log.DebugFormat(
  10749. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10750. // requestID, taskID, (SourceType)sourceType, Name);
  10751. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10752. }
  10753. /// <summary>
  10754. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10755. /// </summary>
  10756. /// <param name="id"></param>
  10757. /// <param name="sender"></param>
  10758. /// <param name="asset"></param>
  10759. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10760. {
  10761. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10762. UUID requestID = UUID.Zero;
  10763. byte source = (byte)SourceType.Asset;
  10764. AssetRequestToClient req = new AssetRequestToClient();
  10765. if (asset == null)
  10766. {
  10767. req.AssetInf = null;
  10768. req.AssetRequestSource = source;
  10769. req.IsTextureRequest = false;
  10770. req.NumPackets = 0;
  10771. req.Params = transferRequest.TransferInfo.Params;
  10772. req.RequestAssetID = requestID;
  10773. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10774. SendAssetNotFound(req);
  10775. return;
  10776. }
  10777. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10778. {
  10779. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10780. }
  10781. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10782. {
  10783. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10784. source = (byte)SourceType.SimInventoryItem;
  10785. //m_log.Debug("asset request " + requestID);
  10786. }
  10787. // Scripts cannot be retrieved by direct request
  10788. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10789. return;
  10790. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10791. req.AssetInf = asset;
  10792. req.AssetRequestSource = source;
  10793. req.IsTextureRequest = false;
  10794. req.NumPackets = CalculateNumPackets(asset.Data);
  10795. req.Params = transferRequest.TransferInfo.Params;
  10796. req.RequestAssetID = requestID;
  10797. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10798. SendAsset(req);
  10799. }
  10800. /// <summary>
  10801. /// Calculate the number of packets required to send the asset to the client.
  10802. /// </summary>
  10803. /// <param name="data"></param>
  10804. /// <returns></returns>
  10805. private static int CalculateNumPackets(byte[] data)
  10806. {
  10807. const uint m_maxPacketSize = 600;
  10808. int numPackets = 1;
  10809. if (data == null)
  10810. return 0;
  10811. if (data.LongLength > m_maxPacketSize)
  10812. {
  10813. // over max number of bytes so split up file
  10814. long restData = data.LongLength - m_maxPacketSize;
  10815. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10816. numPackets += restPackets;
  10817. }
  10818. return numPackets;
  10819. }
  10820. public void SendRebakeAvatarTextures(UUID textureID)
  10821. {
  10822. RebakeAvatarTexturesPacket pack =
  10823. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10824. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10825. pack.TextureData.TextureID = textureID;
  10826. OutPacket(pack, ThrottleOutPacketType.Task);
  10827. }
  10828. public struct PacketProcessor
  10829. {
  10830. public PacketMethod method;
  10831. public bool Async;
  10832. }
  10833. public class AsyncPacketProcess
  10834. {
  10835. public bool result = false;
  10836. public readonly LLClientView ClientView = null;
  10837. public readonly Packet Pack = null;
  10838. public readonly PacketMethod Method = null;
  10839. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10840. {
  10841. ClientView = pClientview;
  10842. Method = pMethod;
  10843. Pack = pPack;
  10844. }
  10845. }
  10846. public static OSD BuildEvent(string eventName, OSD eventBody)
  10847. {
  10848. OSDMap osdEvent = new OSDMap(2);
  10849. osdEvent.Add("message", new OSDString(eventName));
  10850. osdEvent.Add("body", eventBody);
  10851. return osdEvent;
  10852. }
  10853. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10854. {
  10855. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10856. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10857. packet.AgentData.AgentID = AgentId;
  10858. packet.AgentData.AvatarID = avatarID;
  10859. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10860. packet.PropertiesData.WantToMask = wantMask;
  10861. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10862. packet.PropertiesData.SkillsMask = skillsMask;
  10863. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10864. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10865. OutPacket(packet, ThrottleOutPacketType.Task);
  10866. }
  10867. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10868. {
  10869. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10870. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10871. packet.AgentData.AgentID = agentID;
  10872. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10873. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10874. packet.Rights[0].AgentRelated = friendID;
  10875. packet.Rights[0].RelatedRights = rights;
  10876. OutPacket(packet, ThrottleOutPacketType.Task);
  10877. }
  10878. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10879. {
  10880. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10881. dialog.Data.ObjectID = objectId;
  10882. dialog.Data.ChatChannel = chatChannel;
  10883. dialog.Data.ImageID = UUID.Zero;
  10884. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10885. // this is the username of the *owner*
  10886. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10887. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10888. dialog.Data.Message = Util.StringToBytes256(message);
  10889. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10890. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10891. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10892. dialog.Buttons = buttons;
  10893. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10894. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10895. dialog.OwnerData[0].OwnerID = ownerID;
  10896. OutPacket(dialog, ThrottleOutPacketType.Task);
  10897. }
  10898. public void SendAgentTerseUpdate(ISceneEntity p)
  10899. {
  10900. if (p is ScenePresence)
  10901. {
  10902. // m_log.DebugFormat(
  10903. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  10904. // p.Name, Name, Scene.Name);
  10905. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10906. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10907. // velocity, collision plane and avatar height
  10908. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10909. // when the avatar stands up
  10910. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10911. CreateImprovedTerseBlock(p, false);
  10912. const float TIME_DILATION = 1.0f;
  10913. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10914. ImprovedTerseObjectUpdatePacket packet
  10915. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  10916. PacketType.ImprovedTerseObjectUpdate);
  10917. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10918. packet.RegionData.TimeDilation = timeDilation;
  10919. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10920. packet.ObjectData[0] = block;
  10921. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10922. }
  10923. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10924. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10925. }
  10926. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10927. PlacesReplyData[] data)
  10928. {
  10929. PlacesReplyPacket reply = null;
  10930. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10931. new PlacesReplyPacket.QueryDataBlock[0];
  10932. for (int i = 0 ; i < data.Length ; i++)
  10933. {
  10934. PlacesReplyPacket.QueryDataBlock block =
  10935. new PlacesReplyPacket.QueryDataBlock();
  10936. block.OwnerID = data[i].OwnerID;
  10937. block.Name = Util.StringToBytes256(data[i].Name);
  10938. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10939. block.ActualArea = data[i].ActualArea;
  10940. block.BillableArea = data[i].BillableArea;
  10941. block.Flags = data[i].Flags;
  10942. block.GlobalX = data[i].GlobalX;
  10943. block.GlobalY = data[i].GlobalY;
  10944. block.GlobalZ = data[i].GlobalZ;
  10945. block.SimName = Util.StringToBytes256(data[i].SimName);
  10946. block.SnapshotID = data[i].SnapshotID;
  10947. block.Dwell = data[i].Dwell;
  10948. block.Price = data[i].Price;
  10949. if (reply != null && reply.Length + block.Length > 1400)
  10950. {
  10951. OutPacket(reply, ThrottleOutPacketType.Task);
  10952. reply = null;
  10953. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10954. }
  10955. if (reply == null)
  10956. {
  10957. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10958. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10959. reply.AgentData.AgentID = AgentId;
  10960. reply.AgentData.QueryID = queryID;
  10961. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10962. reply.TransactionData.TransactionID = transactionID;
  10963. reply.QueryData = dataBlocks;
  10964. }
  10965. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10966. dataBlocks[dataBlocks.Length - 1] = block;
  10967. reply.QueryData = dataBlocks;
  10968. }
  10969. if (reply != null)
  10970. OutPacket(reply, ThrottleOutPacketType.Task);
  10971. }
  10972. public void SendRemoveInventoryItems(UUID[] items)
  10973. {
  10974. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10975. if (eq == null)
  10976. {
  10977. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10978. return;
  10979. }
  10980. OSDMap llsd = new OSDMap(3);
  10981. OSDMap AgentDataMap = new OSDMap(1);
  10982. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10983. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10984. OSDArray AgentData = new OSDArray(1);
  10985. AgentData.Add(AgentDataMap);
  10986. llsd.Add("AgentData", AgentData);
  10987. OSDArray ItemData = new OSDArray();
  10988. foreach (UUID item in items)
  10989. {
  10990. OSDMap ItemDataMap = new OSDMap(2);
  10991. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  10992. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10993. ItemData.Add(ItemDataMap);
  10994. }
  10995. llsd.Add("InventoryData", ItemData);
  10996. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  10997. llsd), AgentId);
  10998. }
  10999. public void SendRemoveInventoryFolders(UUID[] folders)
  11000. {
  11001. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11002. if (eq == null)
  11003. {
  11004. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11005. return;
  11006. }
  11007. OSDMap llsd = new OSDMap(3);
  11008. OSDMap AgentDataMap = new OSDMap(1);
  11009. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11010. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11011. OSDArray AgentData = new OSDArray(1);
  11012. AgentData.Add(AgentDataMap);
  11013. llsd.Add("AgentData", AgentData);
  11014. OSDArray FolderData = new OSDArray();
  11015. foreach (UUID folder in folders)
  11016. {
  11017. OSDMap FolderDataMap = new OSDMap(2);
  11018. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11019. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11020. FolderData.Add(FolderDataMap);
  11021. }
  11022. llsd.Add("FolderData", FolderData);
  11023. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11024. llsd), AgentId);
  11025. }
  11026. private byte[] EncodeU32(uint val)
  11027. {
  11028. byte[] ret = BitConverter.GetBytes(val);
  11029. if (BitConverter.IsLittleEndian)
  11030. Array.Reverse(ret);
  11031. return ret;
  11032. }
  11033. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11034. {
  11035. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11036. if (eq == null)
  11037. {
  11038. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11039. return;
  11040. }
  11041. OSDMap llsd = new OSDMap(3);
  11042. OSDMap AgentDataMap = new OSDMap(1);
  11043. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11044. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11045. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11046. OSDArray AgentData = new OSDArray(1);
  11047. AgentData.Add(AgentDataMap);
  11048. llsd.Add("AgentData", AgentData);
  11049. OSDArray FolderData = new OSDArray();
  11050. foreach (InventoryFolderBase folder in folders)
  11051. {
  11052. OSDMap FolderDataMap = new OSDMap(5);
  11053. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11054. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11055. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11056. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11057. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11058. FolderData.Add(FolderDataMap);
  11059. }
  11060. llsd.Add("FolderData", FolderData);
  11061. OSDArray ItemData = new OSDArray();
  11062. foreach (InventoryItemBase item in items)
  11063. {
  11064. OSDMap ItemDataMap = new OSDMap();
  11065. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11066. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11067. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11068. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11069. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11070. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11071. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11072. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11073. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11074. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11075. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11076. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11077. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11078. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11079. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11080. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11081. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11082. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11083. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11084. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11085. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11086. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11087. (sbyte)item.AssetType, item.AssetID,
  11088. item.GroupID, 100,
  11089. item.Owner, item.CreatorIdAsUuid,
  11090. item.ID, item.Folder,
  11091. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11092. (uint)PermissionMask.All)
  11093. )));
  11094. ItemDataMap.Add("CallbackID", 0);
  11095. ItemData.Add(ItemDataMap);
  11096. }
  11097. llsd.Add("ItemData", ItemData);
  11098. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11099. llsd), AgentId);
  11100. }
  11101. }
  11102. }