LLClientView.cs 565 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864
  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 Nini.Config;
  51. using System.IO;
  52. using PermissionMask = OpenSim.Framework.PermissionMask;
  53. namespace OpenSim.Region.ClientStack.LindenUDP
  54. {
  55. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  56. /// <summary>
  57. /// Handles new client connections
  58. /// Constructor takes a single Packet and authenticates everything
  59. /// </summary>
  60. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
  61. {
  62. /// <value>
  63. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  64. /// </value>
  65. public int DebugPacketLevel { get; set; }
  66. #region Events
  67. public event GenericMessage OnGenericMessage;
  68. public event BinaryGenericMessage OnBinaryGenericMessage;
  69. public event Action<IClientAPI> OnLogout;
  70. public event ObjectPermissions OnObjectPermissions;
  71. public event Action<IClientAPI> OnConnectionClosed;
  72. public event ViewerEffectEventHandler OnViewerEffect;
  73. public event ImprovedInstantMessage OnInstantMessage;
  74. public event ChatMessage OnChatFromClient;
  75. public event TextureRequest OnRequestTexture;
  76. public event RezObject OnRezObject;
  77. public event DeRezObject OnDeRezObject;
  78. public event ModifyTerrain OnModifyTerrain;
  79. public event Action<IClientAPI> OnRegionHandShakeReply;
  80. public event GenericCall1 OnRequestWearables;
  81. public event CachedTextureRequest OnCachedTextureRequest;
  82. public event SetAppearance OnSetAppearance;
  83. public event AvatarNowWearing OnAvatarNowWearing;
  84. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  85. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  86. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  87. public event ObjectAttach OnObjectAttach;
  88. public event ObjectDeselect OnObjectDetach;
  89. public event ObjectDrop OnObjectDrop;
  90. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  91. public event UpdateAgent OnPreAgentUpdate;
  92. public event UpdateAgent OnAgentUpdate;
  93. public event UpdateAgent OnAgentCameraUpdate;
  94. public event AgentRequestSit OnAgentRequestSit;
  95. public event AgentSit OnAgentSit;
  96. public event AvatarPickerRequest OnAvatarPickerRequest;
  97. public event StartAnim OnStartAnim;
  98. public event StopAnim OnStopAnim;
  99. public event Action<IClientAPI> OnRequestAvatarsData;
  100. public event LinkObjects OnLinkObjects;
  101. public event DelinkObjects OnDelinkObjects;
  102. public event GrabObject OnGrabObject;
  103. public event DeGrabObject OnDeGrabObject;
  104. public event SpinStart OnSpinStart;
  105. public event SpinStop OnSpinStop;
  106. public event ObjectDuplicate OnObjectDuplicate;
  107. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  108. public event MoveObject OnGrabUpdate;
  109. public event SpinObject OnSpinUpdate;
  110. public event AddNewPrim OnAddPrim;
  111. public event RequestGodlikePowers OnRequestGodlikePowers;
  112. public event GodKickUser OnGodKickUser;
  113. public event ObjectExtraParams OnUpdateExtraParams;
  114. public event UpdateShape OnUpdatePrimShape;
  115. public event ObjectRequest OnObjectRequest;
  116. public event ObjectSelect OnObjectSelect;
  117. public event ObjectDeselect OnObjectDeselect;
  118. public event GenericCall7 OnObjectDescription;
  119. public event GenericCall7 OnObjectName;
  120. public event GenericCall7 OnObjectClickAction;
  121. public event GenericCall7 OnObjectMaterial;
  122. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  123. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  124. public event UpdatePrimFlags OnUpdatePrimFlags;
  125. public event UpdatePrimTexture OnUpdatePrimTexture;
  126. public event UpdateVector OnUpdatePrimGroupPosition;
  127. public event UpdateVector OnUpdatePrimSinglePosition;
  128. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  129. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  130. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  131. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  132. public event UpdateVector OnUpdatePrimScale;
  133. public event UpdateVector OnUpdatePrimGroupScale;
  134. public event StatusChange OnChildAgentStatus;
  135. public event GenericCall2 OnStopMovement;
  136. public event Action<UUID> OnRemoveAvatar;
  137. public event RequestMapBlocks OnRequestMapBlocks;
  138. public event RequestMapName OnMapNameRequest;
  139. public event TeleportLocationRequest OnTeleportLocationRequest;
  140. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  141. public event TeleportCancel OnTeleportCancel;
  142. public event DisconnectUser OnDisconnectUser;
  143. public event RequestAvatarProperties OnRequestAvatarProperties;
  144. public event SetAlwaysRun OnSetAlwaysRun;
  145. public event FetchInventory OnAgentDataUpdateRequest;
  146. public event TeleportLocationRequest OnSetStartLocationRequest;
  147. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  148. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  149. public event LinkInventoryItem OnLinkInventoryItem;
  150. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  151. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  152. public event MoveInventoryFolder OnMoveInventoryFolder;
  153. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  154. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  155. public event FetchInventory OnFetchInventory;
  156. public event RequestTaskInventory OnRequestTaskInventory;
  157. public event UpdateInventoryItem OnUpdateInventoryItem;
  158. public event CopyInventoryItem OnCopyInventoryItem;
  159. public event MoveInventoryItem OnMoveInventoryItem;
  160. public event RemoveInventoryItem OnRemoveInventoryItem;
  161. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  162. public event UDPAssetUploadRequest OnAssetUploadRequest;
  163. public event XferReceive OnXferReceive;
  164. public event RequestXfer OnRequestXfer;
  165. public event ConfirmXfer OnConfirmXfer;
  166. public event AbortXfer OnAbortXfer;
  167. public event RequestTerrain OnRequestTerrain;
  168. public event RezScript OnRezScript;
  169. public event UpdateTaskInventory OnUpdateTaskInventory;
  170. public event MoveTaskInventory OnMoveTaskItem;
  171. public event RemoveTaskInventory OnRemoveTaskItem;
  172. public event RequestAsset OnRequestAsset;
  173. public event UUIDNameRequest OnNameFromUUIDRequest;
  174. public event ParcelAccessListRequest OnParcelAccessListRequest;
  175. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  176. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  177. public event ParcelDivideRequest OnParcelDivideRequest;
  178. public event ParcelJoinRequest OnParcelJoinRequest;
  179. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  180. public event ParcelSelectObjects OnParcelSelectObjects;
  181. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  182. public event ParcelAbandonRequest OnParcelAbandonRequest;
  183. public event ParcelGodForceOwner OnParcelGodForceOwner;
  184. public event ParcelReclaim OnParcelReclaim;
  185. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  186. public event ParcelDeedToGroup OnParcelDeedToGroup;
  187. public event RegionInfoRequest OnRegionInfoRequest;
  188. public event EstateCovenantRequest OnEstateCovenantRequest;
  189. public event FriendActionDelegate OnApproveFriendRequest;
  190. public event FriendActionDelegate OnDenyFriendRequest;
  191. public event FriendshipTermination OnTerminateFriendship;
  192. public event GrantUserFriendRights OnGrantUserRights;
  193. public event MoneyTransferRequest OnMoneyTransferRequest;
  194. public event EconomyDataRequest OnEconomyDataRequest;
  195. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  196. public event ParcelBuy OnParcelBuy;
  197. public event UUIDNameRequest OnTeleportHomeRequest;
  198. public event UUIDNameRequest OnUUIDGroupNameRequest;
  199. public event ScriptAnswer OnScriptAnswer;
  200. public event RequestPayPrice OnRequestPayPrice;
  201. public event ObjectSaleInfo OnObjectSaleInfo;
  202. public event ObjectBuy OnObjectBuy;
  203. public event BuyObjectInventory OnBuyObjectInventory;
  204. public event AgentSit OnUndo;
  205. public event AgentSit OnRedo;
  206. public event LandUndo OnLandUndo;
  207. public event ForceReleaseControls OnForceReleaseControls;
  208. public event GodLandStatRequest OnLandStatRequest;
  209. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  210. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  211. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  212. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  213. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  214. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  215. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  216. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  217. public event BakeTerrain OnBakeTerrain;
  218. public event RequestTerrain OnUploadTerrain;
  219. public event EstateChangeInfo OnEstateChangeInfo;
  220. public event EstateManageTelehub OnEstateManageTelehub;
  221. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  222. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  223. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  224. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  225. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  226. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  227. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  228. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  229. public event RegionHandleRequest OnRegionHandleRequest;
  230. public event ParcelInfoRequest OnParcelInfoRequest;
  231. public event ScriptReset OnScriptReset;
  232. public event GetScriptRunning OnGetScriptRunning;
  233. public event SetScriptRunning OnSetScriptRunning;
  234. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  235. public event TerrainUnacked OnUnackedTerrain;
  236. public event ActivateGesture OnActivateGesture;
  237. public event DeactivateGesture OnDeactivateGesture;
  238. public event ObjectOwner OnObjectOwner;
  239. public event DirPlacesQuery OnDirPlacesQuery;
  240. public event DirFindQuery OnDirFindQuery;
  241. public event DirLandQuery OnDirLandQuery;
  242. public event DirPopularQuery OnDirPopularQuery;
  243. public event DirClassifiedQuery OnDirClassifiedQuery;
  244. public event EventInfoRequest OnEventInfoRequest;
  245. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  246. public event MapItemRequest OnMapItemRequest;
  247. public event OfferCallingCard OnOfferCallingCard;
  248. public event AcceptCallingCard OnAcceptCallingCard;
  249. public event DeclineCallingCard OnDeclineCallingCard;
  250. public event SoundTrigger OnSoundTrigger;
  251. public event StartLure OnStartLure;
  252. public event TeleportLureRequest OnTeleportLureRequest;
  253. public event NetworkStats OnNetworkStatsUpdate;
  254. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  255. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  256. public event ClassifiedDelete OnClassifiedDelete;
  257. public event ClassifiedDelete OnClassifiedGodDelete;
  258. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  259. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  260. public event EventGodDelete OnEventGodDelete;
  261. public event ParcelDwellRequest OnParcelDwellRequest;
  262. public event UserInfoRequest OnUserInfoRequest;
  263. public event UpdateUserInfo OnUpdateUserInfo;
  264. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  265. public event PickDelete OnPickDelete;
  266. public event PickGodDelete OnPickGodDelete;
  267. public event PickInfoUpdate OnPickInfoUpdate;
  268. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  269. public event MuteListRequest OnMuteListRequest;
  270. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  271. public event PlacesQuery OnPlacesQuery;
  272. public event AgentFOV OnAgentFOV;
  273. public event FindAgentUpdate OnFindAgent;
  274. public event TrackAgentUpdate OnTrackAgent;
  275. public event NewUserReport OnUserReport;
  276. public event SaveStateHandler OnSaveState;
  277. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  278. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  279. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  280. public event FreezeUserUpdate OnParcelFreezeUser;
  281. public event EjectUserUpdate OnParcelEjectUser;
  282. public event ParcelBuyPass OnParcelBuyPass;
  283. public event ParcelGodMark OnParcelGodMark;
  284. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  285. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  286. public event SimWideDeletesDelegate OnSimWideDeletes;
  287. public event SendPostcard OnSendPostcard;
  288. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  289. public event MuteListEntryRemove OnRemoveMuteListEntry;
  290. public event GodlikeMessage onGodlikeMessage;
  291. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  292. #endregion Events
  293. #region Class Members
  294. // LLClientView Only
  295. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  296. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  297. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  298. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  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("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", 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(
  470. "[CLIENT]: Not attempting to close inactive client {0} in {1} since force flag is not set",
  471. Name, m_scene.Name);
  472. return;
  473. }
  474. IsActive = false;
  475. CloseWithoutChecks();
  476. }
  477. }
  478. /// <summary>
  479. /// Closes down the client view without first checking whether it is active.
  480. /// </summary>
  481. /// <remarks>
  482. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  483. /// CloseWithoutIsActiveCheck asynchronously.
  484. ///
  485. /// Callers must lock ClosingSyncLock before calling.
  486. /// </remarks>
  487. public void CloseWithoutChecks()
  488. {
  489. m_log.DebugFormat(
  490. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  491. Name, m_scene.RegionInfo.RegionName);
  492. // Shutdown the image manager
  493. ImageManager.Close();
  494. // Fire the callback for this connection closing
  495. if (OnConnectionClosed != null)
  496. OnConnectionClosed(this);
  497. // Flush all of the packets out of the UDP server for this client
  498. if (m_udpServer != null)
  499. m_udpServer.Flush(m_udpClient);
  500. // Remove ourselves from the scene
  501. m_scene.RemoveClient(AgentId, true);
  502. SceneAgent = null;
  503. // We can't reach into other scenes and close the connection
  504. // We need to do this over grid communications
  505. //m_scene.CloseAllAgents(CircuitCode);
  506. // Disable UDP handling for this client
  507. m_udpClient.Shutdown();
  508. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  509. //GC.Collect();
  510. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  511. }
  512. public void Kick(string message)
  513. {
  514. if (!SceneAgent.IsChildAgent)
  515. {
  516. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  517. kupack.UserInfo.AgentID = AgentId;
  518. kupack.UserInfo.SessionID = SessionId;
  519. kupack.TargetBlock.TargetIP = 0;
  520. kupack.TargetBlock.TargetPort = 0;
  521. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  522. OutPacket(kupack, ThrottleOutPacketType.Task);
  523. // You must sleep here or users get no message!
  524. Thread.Sleep(500);
  525. }
  526. }
  527. public void Stop()
  528. {
  529. }
  530. #endregion Client Methods
  531. #region Packet Handling
  532. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  533. {
  534. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  535. if (handlerNetworkStatsUpdate != null)
  536. {
  537. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  538. }
  539. }
  540. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  541. {
  542. bool result = false;
  543. lock (PacketHandlers)
  544. {
  545. if (!PacketHandlers.ContainsKey(packetType))
  546. {
  547. PacketHandlers.Add(packetType, handler);
  548. result = true;
  549. }
  550. }
  551. return result;
  552. }
  553. /// <summary>
  554. /// Add a handler for the given packet type.
  555. /// </summary>
  556. /// <remarks>
  557. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  558. /// are received then please use the synchronous version of this method.
  559. /// </remarks>
  560. /// <param name="packetType"></param>
  561. /// <param name="handler"></param>
  562. /// <returns>true if the handler was added. This is currently always the case.</returns>
  563. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  564. {
  565. return AddLocalPacketHandler(packetType, handler, true);
  566. }
  567. /// <summary>
  568. /// Add a handler for the given packet type.
  569. /// </summary>
  570. /// <param name="packetType"></param>
  571. /// <param name="handler"></param>
  572. /// <param name="doAsync">
  573. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  574. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  575. /// synchronously.
  576. /// </param>
  577. /// <returns>true if the handler was added. This is currently always the case.</returns>
  578. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  579. {
  580. bool result = false;
  581. lock (m_packetHandlers)
  582. {
  583. if (!m_packetHandlers.ContainsKey(packetType))
  584. {
  585. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  586. result = true;
  587. }
  588. }
  589. return result;
  590. }
  591. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  592. {
  593. MethodName = MethodName.ToLower().Trim();
  594. bool result = false;
  595. lock (m_genericPacketHandlers)
  596. {
  597. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  598. {
  599. m_genericPacketHandlers.Add(MethodName, handler);
  600. result = true;
  601. }
  602. }
  603. return result;
  604. }
  605. /// <summary>
  606. /// Try to process a packet using registered packet handlers
  607. /// </summary>
  608. /// <param name="packet"></param>
  609. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  610. protected virtual bool ProcessPacketMethod(Packet packet)
  611. {
  612. bool result = false;
  613. PacketProcessor pprocessor;
  614. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  615. {
  616. //there is a local handler for this packet type
  617. if (pprocessor.Async)
  618. {
  619. ClientInfo cinfo = UDPClient.GetClientInfo();
  620. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  621. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  622. cinfo.AsyncRequests[packet.Type.ToString()]++;
  623. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  624. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  625. result = true;
  626. }
  627. else
  628. {
  629. ClientInfo cinfo = UDPClient.GetClientInfo();
  630. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  631. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  632. cinfo.SyncRequests[packet.Type.ToString()]++;
  633. result = pprocessor.method(this, packet);
  634. }
  635. }
  636. else
  637. {
  638. //there is not a local handler so see if there is a Global handler
  639. PacketMethod method = null;
  640. bool found;
  641. lock (PacketHandlers)
  642. {
  643. found = PacketHandlers.TryGetValue(packet.Type, out method);
  644. }
  645. if (found)
  646. {
  647. ClientInfo cinfo = UDPClient.GetClientInfo();
  648. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  649. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  650. cinfo.GenericRequests[packet.Type.ToString()]++;
  651. result = method(this, packet);
  652. }
  653. }
  654. return result;
  655. }
  656. public void ProcessSpecificPacketAsync(object state)
  657. {
  658. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  659. try
  660. {
  661. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  662. }
  663. catch (Exception e)
  664. {
  665. // Make sure that we see any exception caused by the asynchronous operation.
  666. m_log.ErrorFormat(
  667. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  668. packetObject.Pack, Name, e.Message, e.StackTrace);
  669. }
  670. }
  671. #endregion Packet Handling
  672. # region Setup
  673. public virtual void Start()
  674. {
  675. m_scene.AddNewClient(this, PresenceType.User);
  676. RefreshGroupMembership();
  677. }
  678. # endregion
  679. public void ActivateGesture(UUID assetId, UUID gestureId)
  680. {
  681. }
  682. public void DeactivateGesture(UUID assetId, UUID gestureId)
  683. {
  684. }
  685. // Sound
  686. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  687. {
  688. }
  689. #region Scene/Avatar to Client
  690. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  691. {
  692. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  693. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  694. handshake.RegionInfo.BillableFactor = args.billableFactor;
  695. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  696. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  697. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  698. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  699. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  700. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  701. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  702. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  703. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  704. handshake.RegionInfo.SimAccess = args.simAccess;
  705. handshake.RegionInfo.WaterHeight = args.waterHeight;
  706. handshake.RegionInfo.RegionFlags = args.regionFlags;
  707. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  708. handshake.RegionInfo.SimOwner = args.SimOwner;
  709. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  710. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  711. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  712. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  713. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  714. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  715. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  716. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  717. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  718. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  719. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  720. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  721. handshake.RegionInfo3.CPUClassID = 9;
  722. handshake.RegionInfo3.CPURatio = 1;
  723. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  724. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  725. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  726. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  727. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  728. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  729. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  730. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  731. }
  732. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  733. {
  734. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  735. mov.SimData.ChannelVersion = m_channelVersion;
  736. mov.AgentData.SessionID = m_sessionId;
  737. mov.AgentData.AgentID = AgentId;
  738. mov.Data.RegionHandle = regInfo.RegionHandle;
  739. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  740. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  741. {
  742. mov.Data.Position = m_startpos;
  743. }
  744. else
  745. {
  746. mov.Data.Position = pos;
  747. }
  748. mov.Data.LookAt = look;
  749. // Hack to get this out immediately and skip the throttles
  750. OutPacket(mov, ThrottleOutPacketType.Unknown);
  751. }
  752. public void SendChatMessage(
  753. string message, byte type, Vector3 fromPos, string fromName,
  754. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  755. {
  756. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  757. reply.ChatData.Audible = audible;
  758. reply.ChatData.Message = Util.StringToBytes1024(message);
  759. reply.ChatData.ChatType = type;
  760. reply.ChatData.SourceType = source;
  761. reply.ChatData.Position = fromPos;
  762. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  763. reply.ChatData.OwnerID = ownerID;
  764. reply.ChatData.SourceID = fromAgentID;
  765. OutPacket(reply, ThrottleOutPacketType.Task);
  766. }
  767. /// <summary>
  768. /// Send an instant message to this client
  769. /// </summary>
  770. //
  771. // Don't remove transaction ID! Groups and item gives need to set it!
  772. public void SendInstantMessage(GridInstantMessage im)
  773. {
  774. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  775. {
  776. ImprovedInstantMessagePacket msg
  777. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  778. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  779. msg.AgentData.SessionID = UUID.Zero;
  780. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  781. msg.MessageBlock.Dialog = im.dialog;
  782. msg.MessageBlock.FromGroup = im.fromGroup;
  783. if (im.imSessionID == UUID.Zero.Guid)
  784. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  785. else
  786. msg.MessageBlock.ID = new UUID(im.imSessionID);
  787. msg.MessageBlock.Offline = im.offline;
  788. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  789. msg.MessageBlock.Position = im.Position;
  790. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  791. msg.MessageBlock.Timestamp = im.timestamp;
  792. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  793. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  794. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  795. if (im.message.StartsWith("[grouptest]"))
  796. { // this block is test code for implementing group IM - delete when group IM is finished
  797. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  798. if (eq != null)
  799. {
  800. im.dialog = 17;
  801. //eq.ChatterboxInvitation(
  802. // new UUID("00000000-68f9-1111-024e-222222111123"),
  803. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  804. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  805. eq.ChatterboxInvitation(
  806. new UUID("00000000-68f9-1111-024e-222222111123"),
  807. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  808. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  809. eq.ChatterBoxSessionAgentListUpdates(
  810. new UUID("00000000-68f9-1111-024e-222222111123"),
  811. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  812. }
  813. Console.WriteLine("SendInstantMessage: " + msg);
  814. }
  815. else
  816. OutPacket(msg, ThrottleOutPacketType.Task);
  817. }
  818. }
  819. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  820. {
  821. GenericMessagePacket gmp = new GenericMessagePacket();
  822. gmp.AgentData.AgentID = AgentId;
  823. gmp.AgentData.SessionID = m_sessionId;
  824. gmp.AgentData.TransactionID = invoice;
  825. gmp.MethodData.Method = Util.StringToBytes256(method);
  826. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  827. int i = 0;
  828. foreach (string val in message)
  829. {
  830. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  831. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  832. }
  833. OutPacket(gmp, ThrottleOutPacketType.Task);
  834. }
  835. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  836. {
  837. GenericMessagePacket gmp = new GenericMessagePacket();
  838. gmp.AgentData.AgentID = AgentId;
  839. gmp.AgentData.SessionID = m_sessionId;
  840. gmp.AgentData.TransactionID = invoice;
  841. gmp.MethodData.Method = Util.StringToBytes256(method);
  842. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  843. int i = 0;
  844. foreach (byte[] val in message)
  845. {
  846. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  847. gmp.ParamList[i++].Parameter = val;
  848. }
  849. OutPacket(gmp, ThrottleOutPacketType.Task);
  850. }
  851. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  852. {
  853. int i = 0;
  854. foreach (GroupActiveProposals Proposal in Proposals)
  855. {
  856. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  857. GAPIRP.AgentData.AgentID = AgentId;
  858. GAPIRP.AgentData.GroupID = groupID;
  859. GAPIRP.TransactionData.TransactionID = transactionID;
  860. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  861. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  862. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  863. ProposalData.VoteCast = Utils.StringToBytes("false");
  864. ProposalData.VoteID = new UUID(Proposal.VoteID);
  865. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  866. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  867. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  868. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  869. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  870. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  871. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  872. ProposalData.AlreadyVoted = false;
  873. GAPIRP.ProposalData[i] = ProposalData;
  874. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  875. i++;
  876. }
  877. if (Proposals.Length == 0)
  878. {
  879. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  880. GAPIRP.AgentData.AgentID = AgentId;
  881. GAPIRP.AgentData.GroupID = groupID;
  882. GAPIRP.TransactionData.TransactionID = transactionID;
  883. GAPIRP.TransactionData.TotalNumItems = 1;
  884. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  885. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  886. ProposalData.VoteCast = Utils.StringToBytes("false");
  887. ProposalData.VoteID = UUID.Zero;
  888. ProposalData.VoteInitiator = UUID.Zero;
  889. ProposalData.Majority = 0;
  890. ProposalData.Quorum = 0;
  891. ProposalData.TerseDateID = Utils.StringToBytes("");
  892. ProposalData.StartDateTime = Utils.StringToBytes("");
  893. ProposalData.EndDateTime = Utils.StringToBytes("");
  894. ProposalData.ProposalText = Utils.StringToBytes("");
  895. ProposalData.AlreadyVoted = false;
  896. GAPIRP.ProposalData[0] = ProposalData;
  897. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  898. }
  899. }
  900. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  901. {
  902. int i = 0;
  903. foreach (GroupVoteHistory Vote in Votes)
  904. {
  905. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  906. GVHIRP.AgentData.AgentID = AgentId;
  907. GVHIRP.AgentData.GroupID = groupID;
  908. GVHIRP.TransactionData.TransactionID = transactionID;
  909. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  910. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  911. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  912. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  913. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  914. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  915. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  916. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  917. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  918. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  919. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  920. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  921. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  922. VoteItem.CandidateID = UUID.Zero;
  923. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  924. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  925. GVHIRP.VoteItem[i] = VoteItem;
  926. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  927. i++;
  928. }
  929. if (Votes.Length == 0)
  930. {
  931. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  932. GVHIRP.AgentData.AgentID = AgentId;
  933. GVHIRP.AgentData.GroupID = groupID;
  934. GVHIRP.TransactionData.TransactionID = transactionID;
  935. GVHIRP.TransactionData.TotalNumItems = 0;
  936. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  937. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  938. GVHIRP.HistoryItemData.Majority = 0;
  939. GVHIRP.HistoryItemData.Quorum = 0;
  940. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  941. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  942. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  943. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  944. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  945. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  946. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  947. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  948. VoteItem.CandidateID = UUID.Zero;
  949. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  950. VoteItem.VoteCast = Utils.StringToBytes("No");
  951. GVHIRP.VoteItem[0] = VoteItem;
  952. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  953. }
  954. }
  955. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  956. {
  957. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  958. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  959. GADRP.AgentData.AgentID = sender.AgentId;
  960. GADRP.AgentData.GroupID = groupID;
  961. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  962. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  963. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  964. GADRP.MoneyData.CurrentInterval = 0;
  965. GADRP.MoneyData.IntervalDays = 7;
  966. GADRP.MoneyData.RequestID = transactionID;
  967. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  968. History.Amount = amt;
  969. History.Description = Utils.StringToBytes("");
  970. GADRP.HistoryData[0] = History;
  971. OutPacket(GADRP, ThrottleOutPacketType.Task);
  972. }
  973. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  974. {
  975. GroupAccountSummaryReplyPacket GASRP =
  976. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  977. PacketType.GroupAccountSummaryReply);
  978. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  979. GASRP.AgentData.AgentID = sender.AgentId;
  980. GASRP.AgentData.GroupID = groupID;
  981. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  982. GASRP.MoneyData.Balance = (int)moneyAmt;
  983. GASRP.MoneyData.TotalCredits = totalTier;
  984. GASRP.MoneyData.TotalDebits = usedTier;
  985. GASRP.MoneyData.StartDate = new byte[1];
  986. GASRP.MoneyData.CurrentInterval = 1;
  987. GASRP.MoneyData.GroupTaxCurrent = 0;
  988. GASRP.MoneyData.GroupTaxEstimate = 0;
  989. GASRP.MoneyData.IntervalDays = 0;
  990. GASRP.MoneyData.LandTaxCurrent = 0;
  991. GASRP.MoneyData.LandTaxEstimate = 0;
  992. GASRP.MoneyData.LastTaxDate = new byte[1];
  993. GASRP.MoneyData.LightTaxCurrent = 0;
  994. GASRP.MoneyData.TaxDate = new byte[1];
  995. GASRP.MoneyData.RequestID = sender.AgentId;
  996. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  997. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  998. GASRP.MoneyData.ObjectTaxEstimate = 0;
  999. GASRP.MoneyData.NonExemptMembers = 0;
  1000. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1001. GASRP.MoneyData.LightTaxEstimate = 0;
  1002. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1003. }
  1004. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1005. {
  1006. GroupAccountTransactionsReplyPacket GATRP =
  1007. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1008. PacketType.GroupAccountTransactionsReply);
  1009. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1010. GATRP.AgentData.AgentID = sender.AgentId;
  1011. GATRP.AgentData.GroupID = groupID;
  1012. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1013. GATRP.MoneyData.CurrentInterval = 0;
  1014. GATRP.MoneyData.IntervalDays = 7;
  1015. GATRP.MoneyData.RequestID = transactionID;
  1016. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1017. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1018. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1019. History.Amount = 0;
  1020. History.Item = Utils.StringToBytes("");
  1021. History.Time = Utils.StringToBytes("");
  1022. History.Type = 0;
  1023. History.User = Utils.StringToBytes("");
  1024. GATRP.HistoryData[0] = History;
  1025. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1026. }
  1027. /// <summary>
  1028. /// Send the region heightmap to the client
  1029. /// </summary>
  1030. /// <param name="map">heightmap</param>
  1031. public virtual void SendLayerData(float[] map)
  1032. {
  1033. Util.FireAndForget(DoSendLayerData, map);
  1034. }
  1035. /// <summary>
  1036. /// Send terrain layer information to the client.
  1037. /// </summary>
  1038. /// <param name="o"></param>
  1039. private void DoSendLayerData(object o)
  1040. {
  1041. float[] map = LLHeightFieldMoronize((float[])o);
  1042. try
  1043. {
  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, 15, 15);
  1053. }
  1054. catch (Exception e)
  1055. {
  1056. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1057. }
  1058. }
  1059. private void SendLayerTopRight(float[] 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)
  1068. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1069. }
  1070. void SendLayerBottomLeft(float[] 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)
  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. /// <summary>
  1098. /// Sends a specified patch to a client
  1099. /// </summary>
  1100. /// <param name="px">Patch coordinate (x) 0..15</param>
  1101. /// <param name="py">Patch coordinate (y) 0..15</param>
  1102. /// <param name="map">heightmap</param>
  1103. public void SendLayerData(int px, int py, float[] map)
  1104. {
  1105. try
  1106. {
  1107. int[] patches = new int[] { py * 16 + px };
  1108. float[] heightmap = (map.Length == 65536) ?
  1109. map :
  1110. LLHeightFieldMoronize(map);
  1111. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1112. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
  1113. // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
  1114. // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
  1115. // invalidating previous packets for that area.
  1116. // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
  1117. // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
  1118. // 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
  1119. // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
  1120. // patches.
  1121. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
  1122. if (m_justEditedTerrain)
  1123. {
  1124. layerpack.Header.Reliable = false;
  1125. OutPacket(layerpack,
  1126. ThrottleOutPacketType.Unknown );
  1127. }
  1128. else
  1129. {
  1130. layerpack.Header.Reliable = true;
  1131. OutPacket(layerpack,
  1132. ThrottleOutPacketType.Land);
  1133. }
  1134. }
  1135. catch (Exception e)
  1136. {
  1137. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1142. /// </summary>
  1143. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1144. /// <returns>float array in the base 256</returns>
  1145. internal float[] LLHeightFieldMoronize(float[] map)
  1146. {
  1147. if (map.Length == 65536)
  1148. return map;
  1149. else
  1150. {
  1151. float[] returnmap = new float[65536];
  1152. if (map.Length < 65535)
  1153. {
  1154. // rebase the vector stride to 256
  1155. for (int i = 0; i < Constants.RegionSize; i++)
  1156. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1157. }
  1158. else
  1159. {
  1160. for (int i = 0; i < 256; i++)
  1161. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1162. }
  1163. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1164. return returnmap;
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// Send the wind matrix to the client
  1169. /// </summary>
  1170. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1171. public virtual void SendWindData(Vector2[] windSpeeds)
  1172. {
  1173. Util.FireAndForget(DoSendWindData, windSpeeds);
  1174. }
  1175. /// <summary>
  1176. /// Send the cloud matrix to the client
  1177. /// </summary>
  1178. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1179. public virtual void SendCloudData(float[] cloudDensity)
  1180. {
  1181. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1182. }
  1183. /// <summary>
  1184. /// Send wind layer information to the client.
  1185. /// </summary>
  1186. /// <param name="o"></param>
  1187. private void DoSendWindData(object o)
  1188. {
  1189. Vector2[] windSpeeds = (Vector2[])o;
  1190. TerrainPatch[] patches = new TerrainPatch[2];
  1191. patches[0] = new TerrainPatch();
  1192. patches[0].Data = new float[16 * 16];
  1193. patches[1] = new TerrainPatch();
  1194. patches[1].Data = new float[16 * 16];
  1195. for (int y = 0; y < 16; y++)
  1196. {
  1197. for (int x = 0; x < 16; x++)
  1198. {
  1199. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1200. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1201. }
  1202. }
  1203. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1204. layerpack.Header.Zerocoded = true;
  1205. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1206. }
  1207. /// <summary>
  1208. /// Send cloud layer information to the client.
  1209. /// </summary>
  1210. /// <param name="o"></param>
  1211. private void DoSendCloudData(object o)
  1212. {
  1213. float[] cloudCover = (float[])o;
  1214. TerrainPatch[] patches = new TerrainPatch[1];
  1215. patches[0] = new TerrainPatch();
  1216. patches[0].Data = new float[16 * 16];
  1217. for (int y = 0; y < 16; y++)
  1218. {
  1219. for (int x = 0; x < 16; x++)
  1220. {
  1221. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1222. }
  1223. }
  1224. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1225. layerpack.Header.Zerocoded = true;
  1226. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1227. }
  1228. /// <summary>
  1229. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1230. /// </summary>
  1231. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1232. {
  1233. IPAddress neighbourIP = neighbourEndPoint.Address;
  1234. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1235. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1236. // TODO: don't create new blocks if recycling an old packet
  1237. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1238. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1239. byte[] byteIP = neighbourIP.GetAddressBytes();
  1240. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1241. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1242. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1243. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1244. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1245. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1246. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1247. }
  1248. public AgentCircuitData RequestClientInfo()
  1249. {
  1250. AgentCircuitData agentData = new AgentCircuitData();
  1251. agentData.AgentID = AgentId;
  1252. agentData.SessionID = m_sessionId;
  1253. agentData.SecureSessionID = SecureSessionId;
  1254. agentData.circuitcode = m_circuitCode;
  1255. agentData.child = false;
  1256. agentData.firstname = m_firstName;
  1257. agentData.lastname = m_lastName;
  1258. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1259. if (capsModule == null) // can happen when shutting down.
  1260. return agentData;
  1261. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1262. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1263. return agentData;
  1264. }
  1265. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1266. string capsURL)
  1267. {
  1268. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1269. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1270. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1271. // TODO: don't create new blocks if recycling an old packet
  1272. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1273. newSimPack.AgentData.AgentID = AgentId;
  1274. newSimPack.AgentData.SessionID = m_sessionId;
  1275. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1276. newSimPack.Info.Position = pos;
  1277. newSimPack.Info.LookAt = look;
  1278. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1279. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1280. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1281. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1282. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1283. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1284. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1285. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1286. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1287. // Hack to get this out immediately and skip throttles
  1288. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1289. }
  1290. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1291. {
  1292. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1293. // TODO: don't create new blocks if recycling an old packet
  1294. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1295. mapReply.AgentData.AgentID = AgentId;
  1296. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1297. mapReply.AgentData.Flags = flag;
  1298. for (int i = 0; i < mapBlocks2.Length; i++)
  1299. {
  1300. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1301. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1302. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1303. mapReply.Data[i].X = mapBlocks2[i].X;
  1304. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1305. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1306. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1307. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1308. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1309. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1310. }
  1311. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1312. }
  1313. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1314. {
  1315. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1316. int maxsend = 10;
  1317. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1318. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1319. for (int i = 0; i < mapBlocks2.Length; i++)
  1320. {
  1321. sendingBlocks.Add(mapBlocks2[i]);
  1322. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1323. {
  1324. SendMapBlockSplit(sendingBlocks, flag);
  1325. sendingBlocks = new List<MapBlockData>();
  1326. }
  1327. }
  1328. }
  1329. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1330. {
  1331. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1332. tpLocal.Info.AgentID = AgentId;
  1333. tpLocal.Info.TeleportFlags = flags;
  1334. tpLocal.Info.LocationID = 2;
  1335. tpLocal.Info.LookAt = lookAt;
  1336. tpLocal.Info.Position = position;
  1337. // Hack to get this out immediately and skip throttles
  1338. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1339. }
  1340. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1341. uint flags, string capsURL)
  1342. {
  1343. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1344. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1345. teleport.Info.AgentID = AgentId;
  1346. teleport.Info.RegionHandle = regionHandle;
  1347. teleport.Info.SimAccess = simAccess;
  1348. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1349. IPAddress oIP = newRegionEndPoint.Address;
  1350. byte[] byteIP = oIP.GetAddressBytes();
  1351. uint ip = (uint)byteIP[3] << 24;
  1352. ip += (uint)byteIP[2] << 16;
  1353. ip += (uint)byteIP[1] << 8;
  1354. ip += (uint)byteIP[0];
  1355. teleport.Info.SimIP = ip;
  1356. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1357. teleport.Info.LocationID = 4;
  1358. teleport.Info.TeleportFlags = 1 << 4;
  1359. // Hack to get this out immediately and skip throttles.
  1360. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1361. }
  1362. /// <summary>
  1363. /// Inform the client that a teleport attempt has failed
  1364. /// </summary>
  1365. public void SendTeleportFailed(string reason)
  1366. {
  1367. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1368. tpFailed.Info.AgentID = AgentId;
  1369. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1370. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1371. // Hack to get this out immediately and skip throttles
  1372. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1373. }
  1374. /// <summary>
  1375. ///
  1376. /// </summary>
  1377. public void SendTeleportStart(uint flags)
  1378. {
  1379. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1380. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1381. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1382. // Hack to get this out immediately and skip throttles
  1383. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1384. }
  1385. public void SendTeleportProgress(uint flags, string message)
  1386. {
  1387. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1388. tpProgress.AgentData.AgentID = this.AgentId;
  1389. tpProgress.Info.TeleportFlags = flags;
  1390. tpProgress.Info.Message = Util.StringToBytes256(message);
  1391. // Hack to get this out immediately and skip throttles
  1392. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1393. }
  1394. 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)
  1395. {
  1396. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1397. money.MoneyData.AgentID = AgentId;
  1398. money.MoneyData.TransactionID = transaction;
  1399. money.MoneyData.TransactionSuccess = success;
  1400. money.MoneyData.Description = description;
  1401. money.MoneyData.MoneyBalance = balance;
  1402. money.TransactionInfo.TransactionType = transactionType;
  1403. money.TransactionInfo.SourceID = sourceID;
  1404. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1405. money.TransactionInfo.DestID = destID;
  1406. money.TransactionInfo.IsDestGroup = destIsGroup;
  1407. money.TransactionInfo.Amount = amount;
  1408. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1409. OutPacket(money, ThrottleOutPacketType.Task);
  1410. }
  1411. public void SendPayPrice(UUID objectID, int[] payPrice)
  1412. {
  1413. if (payPrice[0] == 0 &&
  1414. payPrice[1] == 0 &&
  1415. payPrice[2] == 0 &&
  1416. payPrice[3] == 0 &&
  1417. payPrice[4] == 0)
  1418. return;
  1419. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1420. payPriceReply.ObjectData.ObjectID = objectID;
  1421. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1422. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1423. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1424. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1425. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1426. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1427. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1428. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1429. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1430. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1431. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1432. }
  1433. public void SendStartPingCheck(byte seq)
  1434. {
  1435. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1436. pc.Header.Reliable = false;
  1437. pc.PingID.PingID = seq;
  1438. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1439. pc.PingID.OldestUnacked = 0;
  1440. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1441. }
  1442. public void SendKillObject(List<uint> localIDs)
  1443. {
  1444. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1445. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1446. // TODO: don't create new blocks if recycling an old packet
  1447. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1448. for (int i = 0 ; i < localIDs.Count ; i++ )
  1449. {
  1450. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1451. kill.ObjectData[i].ID = localIDs[i];
  1452. }
  1453. kill.Header.Reliable = true;
  1454. kill.Header.Zerocoded = true;
  1455. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1456. {
  1457. OutPacket(kill, ThrottleOutPacketType.Task);
  1458. }
  1459. else
  1460. {
  1461. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1462. // condition where a kill can be processed before an out-of-date update for the same object.
  1463. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1464. lock (m_killRecord)
  1465. {
  1466. foreach (uint localID in localIDs)
  1467. m_killRecord.Add(localID);
  1468. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1469. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1470. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1471. // scene objects in a viewer until that viewer is relogged in.
  1472. OutPacket(kill, ThrottleOutPacketType.Task);
  1473. }
  1474. }
  1475. }
  1476. /// <summary>
  1477. /// Send information about the items contained in a folder to the client.
  1478. /// </summary>
  1479. /// <remarks>
  1480. /// XXX This method needs some refactoring loving
  1481. /// </remarks>
  1482. /// <param name="ownerID">The owner of the folder</param>
  1483. /// <param name="folderID">The id of the folder</param>
  1484. /// <param name="items">The items contained in the folder identified by folderID</param>
  1485. /// <param name="folders"></param>
  1486. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1487. /// <param name="fetchItems">Do we need to send item information?</param>
  1488. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1489. List<InventoryFolderBase> folders, int version,
  1490. bool fetchFolders, bool fetchItems)
  1491. {
  1492. // An inventory descendents packet consists of a single agent section and an inventory details
  1493. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1494. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1495. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1496. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1497. //
  1498. // http://opensimulator.org/mantis/view.php?id=226
  1499. //
  1500. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1501. // 6 to 7 items at a time, so let's stick with 6
  1502. int MAX_ITEMS_PER_PACKET = 5;
  1503. int MAX_FOLDERS_PER_PACKET = 6;
  1504. int totalItems = fetchItems ? items.Count : 0;
  1505. int totalFolders = fetchFolders ? folders.Count : 0;
  1506. int itemsSent = 0;
  1507. int foldersSent = 0;
  1508. int foldersToSend = 0;
  1509. int itemsToSend = 0;
  1510. InventoryDescendentsPacket currentPacket = null;
  1511. // Handle empty folders
  1512. //
  1513. if (totalItems == 0 && totalFolders == 0)
  1514. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1515. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1516. //
  1517. while (itemsSent < totalItems || foldersSent < totalFolders)
  1518. {
  1519. if (currentPacket == null) // Start a new packet
  1520. {
  1521. foldersToSend = totalFolders - foldersSent;
  1522. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1523. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1524. if (foldersToSend == 0)
  1525. {
  1526. itemsToSend = totalItems - itemsSent;
  1527. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1528. itemsToSend = MAX_ITEMS_PER_PACKET;
  1529. }
  1530. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1531. }
  1532. if (foldersToSend-- > 0)
  1533. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1534. else if (itemsToSend-- > 0)
  1535. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1536. else
  1537. {
  1538. // m_log.DebugFormat(
  1539. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1540. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1541. currentPacket = null;
  1542. }
  1543. }
  1544. if (currentPacket != null)
  1545. {
  1546. // m_log.DebugFormat(
  1547. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1548. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1549. }
  1550. }
  1551. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1552. {
  1553. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1554. newBlock.FolderID = folder.ID;
  1555. newBlock.Name = Util.StringToBytes256(folder.Name);
  1556. newBlock.ParentID = folder.ParentID;
  1557. newBlock.Type = (sbyte)folder.Type;
  1558. return newBlock;
  1559. }
  1560. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1561. {
  1562. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1563. newBlock.ItemID = item.ID;
  1564. newBlock.AssetID = item.AssetID;
  1565. newBlock.CreatorID = item.CreatorIdAsUuid;
  1566. newBlock.BaseMask = item.BasePermissions;
  1567. newBlock.Description = Util.StringToBytes256(item.Description);
  1568. newBlock.EveryoneMask = item.EveryOnePermissions;
  1569. newBlock.OwnerMask = item.CurrentPermissions;
  1570. newBlock.FolderID = item.Folder;
  1571. newBlock.InvType = (sbyte)item.InvType;
  1572. newBlock.Name = Util.StringToBytes256(item.Name);
  1573. newBlock.NextOwnerMask = item.NextPermissions;
  1574. newBlock.OwnerID = item.Owner;
  1575. newBlock.Type = (sbyte)item.AssetType;
  1576. newBlock.GroupID = item.GroupID;
  1577. newBlock.GroupOwned = item.GroupOwned;
  1578. newBlock.GroupMask = item.GroupPermissions;
  1579. newBlock.CreationDate = item.CreationDate;
  1580. newBlock.SalePrice = item.SalePrice;
  1581. newBlock.SaleType = item.SaleType;
  1582. newBlock.Flags = item.Flags;
  1583. newBlock.CRC =
  1584. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1585. newBlock.InvType, newBlock.Type,
  1586. newBlock.AssetID, newBlock.GroupID,
  1587. newBlock.SalePrice,
  1588. newBlock.OwnerID, newBlock.CreatorID,
  1589. newBlock.ItemID, newBlock.FolderID,
  1590. newBlock.EveryoneMask,
  1591. newBlock.Flags, newBlock.OwnerMask,
  1592. newBlock.GroupMask, newBlock.NextOwnerMask);
  1593. return newBlock;
  1594. }
  1595. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1596. {
  1597. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1598. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1599. packet.FolderData[0].FolderID = UUID.Zero;
  1600. packet.FolderData[0].ParentID = UUID.Zero;
  1601. packet.FolderData[0].Type = -1;
  1602. packet.FolderData[0].Name = new byte[0];
  1603. }
  1604. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1605. {
  1606. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1607. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1608. packet.ItemData[0].ItemID = UUID.Zero;
  1609. packet.ItemData[0].AssetID = UUID.Zero;
  1610. packet.ItemData[0].CreatorID = UUID.Zero;
  1611. packet.ItemData[0].BaseMask = 0;
  1612. packet.ItemData[0].Description = new byte[0];
  1613. packet.ItemData[0].EveryoneMask = 0;
  1614. packet.ItemData[0].OwnerMask = 0;
  1615. packet.ItemData[0].FolderID = UUID.Zero;
  1616. packet.ItemData[0].InvType = (sbyte)0;
  1617. packet.ItemData[0].Name = new byte[0];
  1618. packet.ItemData[0].NextOwnerMask = 0;
  1619. packet.ItemData[0].OwnerID = UUID.Zero;
  1620. packet.ItemData[0].Type = -1;
  1621. packet.ItemData[0].GroupID = UUID.Zero;
  1622. packet.ItemData[0].GroupOwned = false;
  1623. packet.ItemData[0].GroupMask = 0;
  1624. packet.ItemData[0].CreationDate = 0;
  1625. packet.ItemData[0].SalePrice = 0;
  1626. packet.ItemData[0].SaleType = 0;
  1627. packet.ItemData[0].Flags = 0;
  1628. // No need to add CRC
  1629. }
  1630. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1631. {
  1632. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1633. descend.Header.Zerocoded = true;
  1634. descend.AgentData.AgentID = AgentId;
  1635. descend.AgentData.OwnerID = ownerID;
  1636. descend.AgentData.FolderID = folderID;
  1637. descend.AgentData.Version = version;
  1638. descend.AgentData.Descendents = descendents;
  1639. if (folders > 0)
  1640. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1641. else
  1642. AddNullFolderBlockToDecendentsPacket(ref descend);
  1643. if (items > 0)
  1644. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1645. else
  1646. AddNullItemBlockToDescendentsPacket(ref descend);
  1647. return descend;
  1648. }
  1649. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1650. {
  1651. // Fudge this value. It's only needed to make the CRC anyway
  1652. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1653. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1654. // TODO: don't create new blocks if recycling an old packet
  1655. inventoryReply.AgentData.AgentID = AgentId;
  1656. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1657. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1658. inventoryReply.InventoryData[0].ItemID = item.ID;
  1659. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1660. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1661. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1662. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1663. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1664. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1665. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1666. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1667. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1668. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1669. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1670. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1671. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1672. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1673. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1674. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1675. inventoryReply.InventoryData[0].Flags = item.Flags;
  1676. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1677. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1678. inventoryReply.InventoryData[0].CRC =
  1679. Helpers.InventoryCRC(
  1680. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1681. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1682. inventoryReply.InventoryData[0].GroupID, 100,
  1683. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1684. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1685. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1686. FULL_MASK_PERMISSIONS);
  1687. inventoryReply.Header.Zerocoded = true;
  1688. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1689. }
  1690. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1691. {
  1692. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1693. UUID transactionId = UUID.Random();
  1694. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1695. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1696. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1697. if (folderDataBlocks.Count > 0)
  1698. {
  1699. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1700. // Send these now
  1701. BulkUpdateInventoryPacket bulkUpdate
  1702. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1703. bulkUpdate.Header.Zerocoded = true;
  1704. bulkUpdate.AgentData.AgentID = AgentId;
  1705. bulkUpdate.AgentData.TransactionID = transactionId;
  1706. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1707. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1708. bulkUpdate.ItemData = foo.ToArray();
  1709. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1710. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1711. }
  1712. }
  1713. /// <summary>
  1714. /// Recursively construct bulk update packets to send folders and items
  1715. /// </summary>
  1716. /// <param name="folder"></param>
  1717. /// <param name="folderDataBlocks"></param>
  1718. /// <param name="transactionId"></param>
  1719. private void SendBulkUpdateInventoryFolderRecursive(
  1720. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1721. UUID transactionId)
  1722. {
  1723. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1724. const int MAX_ITEMS_PER_PACKET = 5;
  1725. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1726. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1727. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1728. // being used on the Linden grid at 20081203).
  1729. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1730. List<InventoryItemBase> items = contents.Items;
  1731. while (items.Count > 0)
  1732. {
  1733. BulkUpdateInventoryPacket bulkUpdate
  1734. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1735. bulkUpdate.Header.Zerocoded = true;
  1736. bulkUpdate.AgentData.AgentID = AgentId;
  1737. bulkUpdate.AgentData.TransactionID = transactionId;
  1738. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1739. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1740. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1741. for (int i = 0; i < itemsToSend; i++)
  1742. {
  1743. // Remove from the end of the list so that we don't incur a performance penalty
  1744. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1745. items.RemoveAt(items.Count - 1);
  1746. }
  1747. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1748. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1749. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1750. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1751. // items belong.
  1752. if (items.Count > 0)
  1753. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1754. }
  1755. List<InventoryFolderBase> subFolders = contents.Folders;
  1756. foreach (InventoryFolderBase subFolder in subFolders)
  1757. {
  1758. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1759. }
  1760. }
  1761. /// <summary>
  1762. /// Generate a bulk update inventory data block for the given folder
  1763. /// </summary>
  1764. /// <param name="folder"></param>
  1765. /// <returns></returns>
  1766. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1767. {
  1768. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1769. folderBlock.FolderID = folder.ID;
  1770. folderBlock.ParentID = folder.ParentID;
  1771. //folderBlock.Type = -1;
  1772. folderBlock.Type = (sbyte)folder.Type;
  1773. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1774. return folderBlock;
  1775. }
  1776. /// <summary>
  1777. /// Generate a bulk update inventory data block for the given item
  1778. /// </summary>
  1779. /// <param name="item"></param>
  1780. /// <returns></returns>
  1781. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1782. {
  1783. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1784. itemBlock.ItemID = item.ID;
  1785. itemBlock.AssetID = item.AssetID;
  1786. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1787. itemBlock.BaseMask = item.BasePermissions;
  1788. itemBlock.Description = Util.StringToBytes256(item.Description);
  1789. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1790. itemBlock.FolderID = item.Folder;
  1791. itemBlock.InvType = (sbyte)item.InvType;
  1792. itemBlock.Name = Util.StringToBytes256(item.Name);
  1793. itemBlock.NextOwnerMask = item.NextPermissions;
  1794. itemBlock.OwnerID = item.Owner;
  1795. itemBlock.OwnerMask = item.CurrentPermissions;
  1796. itemBlock.Type = (sbyte)item.AssetType;
  1797. itemBlock.GroupID = item.GroupID;
  1798. itemBlock.GroupOwned = item.GroupOwned;
  1799. itemBlock.GroupMask = item.GroupPermissions;
  1800. itemBlock.Flags = item.Flags;
  1801. itemBlock.SalePrice = item.SalePrice;
  1802. itemBlock.SaleType = item.SaleType;
  1803. itemBlock.CreationDate = item.CreationDate;
  1804. itemBlock.CRC =
  1805. Helpers.InventoryCRC(
  1806. 1000, 0, itemBlock.InvType,
  1807. itemBlock.Type, itemBlock.AssetID,
  1808. itemBlock.GroupID, 100,
  1809. itemBlock.OwnerID, itemBlock.CreatorID,
  1810. itemBlock.ItemID, itemBlock.FolderID,
  1811. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1812. (uint)PermissionMask.All);
  1813. return itemBlock;
  1814. }
  1815. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1816. {
  1817. if (node is InventoryItemBase)
  1818. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1819. else if (node is InventoryFolderBase)
  1820. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1821. else if (node != null)
  1822. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1823. else
  1824. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1825. }
  1826. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1827. {
  1828. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1829. BulkUpdateInventoryPacket bulkUpdate
  1830. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1831. bulkUpdate.AgentData.AgentID = AgentId;
  1832. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1833. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1834. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1835. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1836. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1837. bulkUpdate.FolderData[0].Type = -1;
  1838. bulkUpdate.FolderData[0].Name = new byte[0];
  1839. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1840. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1841. bulkUpdate.ItemData[0].ItemID = item.ID;
  1842. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1843. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1844. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1845. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1846. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1847. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1848. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1849. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1850. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1851. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1852. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1853. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1854. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1855. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1856. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1857. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1858. bulkUpdate.ItemData[0].Flags = item.Flags;
  1859. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1860. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1861. bulkUpdate.ItemData[0].CRC =
  1862. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1863. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1864. bulkUpdate.ItemData[0].GroupID, 100,
  1865. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1866. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1867. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1868. FULL_MASK_PERMISSIONS);
  1869. bulkUpdate.Header.Zerocoded = true;
  1870. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1871. }
  1872. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1873. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1874. {
  1875. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1876. UpdateCreateInventoryItemPacket InventoryReply
  1877. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1878. PacketType.UpdateCreateInventoryItem);
  1879. // TODO: don't create new blocks if recycling an old packet
  1880. InventoryReply.AgentData.AgentID = AgentId;
  1881. InventoryReply.AgentData.SimApproved = true;
  1882. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1883. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1884. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1885. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1886. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1887. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1888. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1889. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1890. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1891. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1892. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1893. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1894. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1895. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1896. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1897. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1898. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1899. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1900. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1901. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1902. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1903. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1904. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1905. InventoryReply.InventoryData[0].CRC =
  1906. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1907. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1908. InventoryReply.InventoryData[0].GroupID, 100,
  1909. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1910. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1911. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1912. FULL_MASK_PERMISSIONS);
  1913. InventoryReply.Header.Zerocoded = true;
  1914. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1915. }
  1916. public void SendRemoveInventoryItem(UUID itemID)
  1917. {
  1918. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1919. // TODO: don't create new blocks if recycling an old packet
  1920. remove.AgentData.AgentID = AgentId;
  1921. remove.AgentData.SessionID = m_sessionId;
  1922. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1923. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1924. remove.InventoryData[0].ItemID = itemID;
  1925. remove.Header.Zerocoded = true;
  1926. OutPacket(remove, ThrottleOutPacketType.Asset);
  1927. }
  1928. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1929. {
  1930. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1931. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1932. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1933. ddata.Controls = (uint)controls;
  1934. ddata.PassToAgent = passToAgent;
  1935. ddata.TakeControls = TakeControls;
  1936. data[0] = ddata;
  1937. scriptcontrol.Data = data;
  1938. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1939. }
  1940. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1941. {
  1942. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1943. replytask.InventoryData.TaskID = taskID;
  1944. replytask.InventoryData.Serial = serial;
  1945. replytask.InventoryData.Filename = fileName;
  1946. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1947. }
  1948. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1949. {
  1950. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1951. sendXfer.XferID.ID = xferID;
  1952. sendXfer.XferID.Packet = packet;
  1953. sendXfer.DataPacket.Data = data;
  1954. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1955. }
  1956. public void SendAbortXferPacket(ulong xferID)
  1957. {
  1958. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1959. xferItem.XferID.ID = xferID;
  1960. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1961. }
  1962. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1963. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1964. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1965. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1966. {
  1967. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1968. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1969. economyData.Info.ObjectCapacity = ObjectCapacity;
  1970. economyData.Info.ObjectCount = ObjectCount;
  1971. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1972. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1973. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1974. economyData.Info.PriceObjectRent = PriceObjectRent;
  1975. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1976. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1977. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1978. economyData.Info.PriceParcelRent = PriceParcelRent;
  1979. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1980. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1981. economyData.Info.PriceRentLight = PriceRentLight;
  1982. economyData.Info.PriceUpload = PriceUpload;
  1983. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1984. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1985. economyData.Header.Reliable = true;
  1986. OutPacket(economyData, ThrottleOutPacketType.Task);
  1987. }
  1988. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1989. {
  1990. //construct the AvatarPickerReply packet.
  1991. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1992. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1993. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1994. //int i = 0;
  1995. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1996. foreach (AvatarPickerReplyDataArgs arg in Data)
  1997. {
  1998. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1999. db.AvatarID = arg.AvatarID;
  2000. db.FirstName = arg.FirstName;
  2001. db.LastName = arg.LastName;
  2002. data_block.Add(db);
  2003. }
  2004. replyPacket.Data = data_block.ToArray();
  2005. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  2006. }
  2007. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  2008. {
  2009. m_activeGroupID = activegroupid;
  2010. m_activeGroupName = groupname;
  2011. m_activeGroupPowers = grouppowers;
  2012. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  2013. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  2014. sendAgentDataUpdate.AgentData.AgentID = agentid;
  2015. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2016. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2017. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2018. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2019. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2020. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2021. }
  2022. /// <summary>
  2023. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2024. /// blue information box in the bottom right hand corner.
  2025. /// </summary>
  2026. /// <param name="message"></param>
  2027. public void SendAlertMessage(string message)
  2028. {
  2029. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2030. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2031. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2032. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2033. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2034. }
  2035. /// <summary>
  2036. /// Send an agent alert message to the client.
  2037. /// </summary>
  2038. /// <param name="message"></param>
  2039. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2040. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2041. /// the AlertMessage packet).</param>
  2042. public void SendAgentAlertMessage(string message, bool modal)
  2043. {
  2044. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2045. }
  2046. /// <summary>
  2047. /// Construct an agent alert packet
  2048. /// </summary>
  2049. /// <param name="message"></param>
  2050. /// <param name="modal"></param>
  2051. /// <returns></returns>
  2052. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2053. {
  2054. // Prepend a slash to make the message come up in the top right
  2055. // again.
  2056. // Allow special formats to be sent from aware modules.
  2057. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2058. message = "/" + message;
  2059. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2060. alertPack.AgentData.AgentID = AgentId;
  2061. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2062. alertPack.AlertData.Modal = modal;
  2063. return alertPack;
  2064. }
  2065. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2066. string url)
  2067. {
  2068. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2069. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2070. loadURL.Data.ObjectID = objectID;
  2071. loadURL.Data.OwnerID = ownerID;
  2072. loadURL.Data.OwnerIsGroup = groupOwned;
  2073. loadURL.Data.Message = Util.StringToBytes256(message);
  2074. loadURL.Data.URL = Util.StringToBytes256(url);
  2075. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2076. }
  2077. public void SendDialog(
  2078. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2079. UUID textureID, int ch, string[] buttonlabels)
  2080. {
  2081. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2082. dialog.Data.ObjectID = objectID;
  2083. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2084. // this is the username of the *owner*
  2085. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2086. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2087. dialog.Data.Message = Util.StringToBytes1024(msg);
  2088. dialog.Data.ImageID = textureID;
  2089. dialog.Data.ChatChannel = ch;
  2090. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2091. for (int i = 0; i < buttonlabels.Length; i++)
  2092. {
  2093. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2094. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2095. }
  2096. dialog.Buttons = buttons;
  2097. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2098. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2099. dialog.OwnerData[0].OwnerID = ownerID;
  2100. OutPacket(dialog, ThrottleOutPacketType.Task);
  2101. }
  2102. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2103. {
  2104. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2105. // TODO: don't create new blocks if recycling an old packet
  2106. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2107. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2108. preSound.DataBlock[0].ObjectID = objectID;
  2109. preSound.DataBlock[0].OwnerID = ownerID;
  2110. preSound.DataBlock[0].SoundID = soundID;
  2111. preSound.Header.Zerocoded = true;
  2112. OutPacket(preSound, ThrottleOutPacketType.Task);
  2113. }
  2114. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2115. {
  2116. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2117. sound.DataBlock.SoundID = soundID;
  2118. sound.DataBlock.ObjectID = objectID;
  2119. sound.DataBlock.OwnerID = ownerID;
  2120. sound.DataBlock.Gain = gain;
  2121. sound.DataBlock.Flags = flags;
  2122. OutPacket(sound, ThrottleOutPacketType.Task);
  2123. }
  2124. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2125. {
  2126. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2127. sound.SoundData.SoundID = soundID;
  2128. sound.SoundData.OwnerID = ownerID;
  2129. sound.SoundData.ObjectID = objectID;
  2130. sound.SoundData.ParentID = parentID;
  2131. sound.SoundData.Handle = handle;
  2132. sound.SoundData.Position = position;
  2133. sound.SoundData.Gain = gain;
  2134. OutPacket(sound, ThrottleOutPacketType.Task);
  2135. }
  2136. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2137. {
  2138. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2139. sound.DataBlock.ObjectID = objectID;
  2140. sound.DataBlock.Gain = gain;
  2141. OutPacket(sound, ThrottleOutPacketType.Task);
  2142. }
  2143. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2144. {
  2145. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2146. // So adjust for that
  2147. // Contributed by: Godfrey
  2148. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2149. {
  2150. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2151. }
  2152. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2153. viewertime.TimeInfo.SunDirection = Position;
  2154. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2155. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2156. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2157. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2158. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2159. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2160. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2161. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2162. viewertime.Header.Reliable = false;
  2163. viewertime.Header.Zerocoded = true;
  2164. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2165. }
  2166. // Currently Deprecated
  2167. public void SendViewerTime(int phase)
  2168. {
  2169. /*
  2170. Console.WriteLine("SunPhase: {0}", phase);
  2171. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2172. //viewertime.TimeInfo.SecPerDay = 86400;
  2173. //viewertime.TimeInfo.SecPerYear = 31536000;
  2174. viewertime.TimeInfo.SecPerDay = 1000;
  2175. viewertime.TimeInfo.SecPerYear = 365000;
  2176. viewertime.TimeInfo.SunPhase = 1;
  2177. int sunPhase = (phase + 2) / 2;
  2178. if ((sunPhase < 6) || (sunPhase > 36))
  2179. {
  2180. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2181. Console.WriteLine("sending night");
  2182. }
  2183. else
  2184. {
  2185. if (sunPhase < 12)
  2186. {
  2187. sunPhase = 12;
  2188. }
  2189. sunPhase = sunPhase - 12;
  2190. float yValue = 0.1f * (sunPhase);
  2191. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2192. if (yValue > 1.2f)
  2193. {
  2194. yValue = yValue - 1.2f;
  2195. }
  2196. yValue = Util.Clip(yValue, 0, 1);
  2197. if (sunPhase < 14)
  2198. {
  2199. yValue = 1 - yValue;
  2200. }
  2201. if (sunPhase < 12)
  2202. {
  2203. yValue *= -1;
  2204. }
  2205. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2206. Console.WriteLine("sending sun update " + yValue);
  2207. }
  2208. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2209. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2210. viewertime.Header.Reliable = false;
  2211. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2212. */
  2213. }
  2214. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2215. {
  2216. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2217. packet.Header.Reliable = false;
  2218. packet.Header.Zerocoded = true;
  2219. packet.AgentData.AgentID = AgentId;
  2220. packet.AgentData.SessionID = SessionId;
  2221. packet.Effect = effectBlocks;
  2222. // OutPacket(packet, ThrottleOutPacketType.State);
  2223. OutPacket(packet, ThrottleOutPacketType.Task);
  2224. }
  2225. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2226. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2227. UUID partnerID)
  2228. {
  2229. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2230. avatarReply.AgentData.AgentID = AgentId;
  2231. avatarReply.AgentData.AvatarID = avatarID;
  2232. if (aboutText != null)
  2233. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2234. else
  2235. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2236. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2237. avatarReply.PropertiesData.CharterMember = charterMember;
  2238. if (flAbout != null)
  2239. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2240. else
  2241. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2242. avatarReply.PropertiesData.Flags = flags;
  2243. avatarReply.PropertiesData.FLImageID = flImageID;
  2244. avatarReply.PropertiesData.ImageID = imageID;
  2245. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2246. avatarReply.PropertiesData.PartnerID = partnerID;
  2247. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2248. }
  2249. /// <summary>
  2250. /// Send the client an Estate message blue box pop-down with a single OK button
  2251. /// </summary>
  2252. /// <param name="FromAvatarID"></param>
  2253. /// <param name="fromSessionID"></param>
  2254. /// <param name="FromAvatarName"></param>
  2255. /// <param name="Message"></param>
  2256. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2257. {
  2258. if (!SceneAgent.IsChildAgent)
  2259. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2260. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2261. }
  2262. public void SendLogoutPacket()
  2263. {
  2264. // I know this is a bit of a hack, however there are times when you don't
  2265. // want to send this, but still need to do the rest of the shutdown process
  2266. // this method gets called from the packet server.. which makes it practically
  2267. // impossible to do any other way.
  2268. if (m_SendLogoutPacketWhenClosing)
  2269. {
  2270. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2271. // TODO: don't create new blocks if recycling an old packet
  2272. logReply.AgentData.AgentID = AgentId;
  2273. logReply.AgentData.SessionID = SessionId;
  2274. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2275. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2276. logReply.InventoryData[0].ItemID = UUID.Zero;
  2277. OutPacket(logReply, ThrottleOutPacketType.Task);
  2278. }
  2279. }
  2280. public void SendHealth(float health)
  2281. {
  2282. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2283. healthpacket.HealthData.Health = health;
  2284. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2285. }
  2286. public void SendAgentOnline(UUID[] agentIDs)
  2287. {
  2288. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2289. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2290. for (int i = 0; i < agentIDs.Length; i++)
  2291. {
  2292. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2293. onpbl.AgentID = agentIDs[i];
  2294. onpb[i] = onpbl;
  2295. }
  2296. onp.AgentBlock = onpb;
  2297. onp.Header.Reliable = true;
  2298. OutPacket(onp, ThrottleOutPacketType.Task);
  2299. }
  2300. public void SendAgentOffline(UUID[] agentIDs)
  2301. {
  2302. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2303. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2304. for (int i = 0; i < agentIDs.Length; i++)
  2305. {
  2306. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2307. onpbl.AgentID = agentIDs[i];
  2308. offpb[i] = onpbl;
  2309. }
  2310. offp.AgentBlock = offpb;
  2311. offp.Header.Reliable = true;
  2312. OutPacket(offp, ThrottleOutPacketType.Task);
  2313. }
  2314. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2315. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2316. {
  2317. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2318. avatarSitResponse.SitObject.ID = TargetID;
  2319. if (CameraAtOffset != Vector3.Zero)
  2320. {
  2321. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2322. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2323. }
  2324. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2325. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2326. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2327. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2328. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2329. }
  2330. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2331. {
  2332. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2333. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2334. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2335. adb.AgentID = AgentId;
  2336. adb.SessionID = SessionId; // More security
  2337. gdb.GodLevel = (byte)AdminLevel;
  2338. gdb.Token = Token;
  2339. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2340. respondPacket.GrantData = gdb;
  2341. respondPacket.AgentData = adb;
  2342. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2343. }
  2344. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2345. {
  2346. m_groupPowers.Clear();
  2347. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2348. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2349. for (int i = 0; i < GroupMembership.Length; i++)
  2350. {
  2351. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2352. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2353. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2354. Group.Contribution = GroupMembership[i].Contribution;
  2355. Group.GroupID = GroupMembership[i].GroupID;
  2356. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2357. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2358. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2359. Groups[i] = Group;
  2360. }
  2361. Groupupdate.GroupData = Groups;
  2362. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2363. Groupupdate.AgentData.AgentID = AgentId;
  2364. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2365. try
  2366. {
  2367. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2368. if (eq != null)
  2369. {
  2370. eq.GroupMembership(Groupupdate, this.AgentId);
  2371. }
  2372. }
  2373. catch (Exception ex)
  2374. {
  2375. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2376. m_log.Warn("sending group membership data via UDP");
  2377. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2378. }
  2379. }
  2380. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2381. {
  2382. SceneObjectPart part = (SceneObjectPart)entity;
  2383. if (part != null && AgentId != UUID.Zero)
  2384. {
  2385. try
  2386. {
  2387. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2388. if (eq != null)
  2389. {
  2390. uint localid = part.LocalId;
  2391. byte physshapetype = part.PhysicsShapeType;
  2392. float density = part.Density;
  2393. float friction = part.Friction;
  2394. float bounce = part.Restitution;
  2395. float gravmod = part.GravityModifier;
  2396. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2397. }
  2398. }
  2399. catch (Exception ex)
  2400. {
  2401. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2402. }
  2403. part.UpdatePhysRequired = false;
  2404. }
  2405. }
  2406. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2407. {
  2408. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2409. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2410. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2411. uidnamebloc.ID = groupLLUID;
  2412. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2413. uidnameblock[0] = uidnamebloc;
  2414. pack.UUIDNameBlock = uidnameblock;
  2415. OutPacket(pack, ThrottleOutPacketType.Task);
  2416. }
  2417. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2418. {
  2419. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2420. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2421. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2422. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2423. // lsrepdb.
  2424. lsrp.RequestData.ReportType = reportType;
  2425. lsrp.RequestData.RequestFlags = requestFlags;
  2426. lsrp.RequestData.TotalObjectCount = resultCount;
  2427. for (int i = 0; i < lsrpia.Length; i++)
  2428. {
  2429. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2430. lsrepdb.LocationX = lsrpia[i].LocationX;
  2431. lsrepdb.LocationY = lsrpia[i].LocationY;
  2432. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2433. lsrepdb.Score = lsrpia[i].Score;
  2434. lsrepdb.TaskID = lsrpia[i].TaskID;
  2435. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2436. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2437. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2438. lsrepdba[i] = lsrepdb;
  2439. }
  2440. lsrp.ReportData = lsrepdba;
  2441. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2442. }
  2443. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2444. {
  2445. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2446. scriptRunningReply.Script.ObjectID = objectID;
  2447. scriptRunningReply.Script.ItemID = itemID;
  2448. scriptRunningReply.Script.Running = running;
  2449. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2450. }
  2451. public void SendAsset(AssetRequestToClient req)
  2452. {
  2453. if (req.AssetInf.Data == null)
  2454. {
  2455. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2456. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2457. return;
  2458. }
  2459. //m_log.Debug("sending asset " + req.RequestAssetID);
  2460. TransferInfoPacket Transfer = new TransferInfoPacket();
  2461. Transfer.TransferInfo.ChannelType = 2;
  2462. Transfer.TransferInfo.Status = 0;
  2463. Transfer.TransferInfo.TargetType = 0;
  2464. if (req.AssetRequestSource == 2)
  2465. {
  2466. Transfer.TransferInfo.Params = new byte[20];
  2467. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2468. int assType = req.AssetInf.Type;
  2469. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2470. }
  2471. else if (req.AssetRequestSource == 3)
  2472. {
  2473. Transfer.TransferInfo.Params = req.Params;
  2474. // Transfer.TransferInfo.Params = new byte[100];
  2475. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2476. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2477. }
  2478. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2479. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2480. Transfer.Header.Zerocoded = true;
  2481. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2482. if (req.NumPackets == 1)
  2483. {
  2484. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2485. TransferPacket.TransferData.Packet = 0;
  2486. TransferPacket.TransferData.ChannelType = 2;
  2487. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2488. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2489. TransferPacket.TransferData.Status = 1;
  2490. TransferPacket.Header.Zerocoded = true;
  2491. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2492. }
  2493. else
  2494. {
  2495. int processedLength = 0;
  2496. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2497. int packetNumber = 0;
  2498. while (processedLength < req.AssetInf.Data.Length)
  2499. {
  2500. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2501. TransferPacket.TransferData.Packet = packetNumber;
  2502. TransferPacket.TransferData.ChannelType = 2;
  2503. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2504. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2505. byte[] chunk = new byte[chunkSize];
  2506. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2507. TransferPacket.TransferData.Data = chunk;
  2508. // 0 indicates more packets to come, 1 indicates last packet
  2509. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2510. {
  2511. TransferPacket.TransferData.Status = 0;
  2512. }
  2513. else
  2514. {
  2515. TransferPacket.TransferData.Status = 1;
  2516. }
  2517. TransferPacket.Header.Zerocoded = true;
  2518. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2519. processedLength += chunkSize;
  2520. packetNumber++;
  2521. }
  2522. }
  2523. }
  2524. public void SendAssetNotFound(AssetRequestToClient req)
  2525. {
  2526. TransferInfoPacket Transfer = new TransferInfoPacket();
  2527. Transfer.TransferInfo.ChannelType = 2;
  2528. Transfer.TransferInfo.Status = -2;
  2529. Transfer.TransferInfo.TargetType = 0;
  2530. Transfer.TransferInfo.Params = req.Params;
  2531. Transfer.TransferInfo.Size = 0;
  2532. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2533. Transfer.Header.Zerocoded = true;
  2534. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2535. }
  2536. public void SendTexture(AssetBase TextureAsset)
  2537. {
  2538. }
  2539. public void SendRegionHandle(UUID regionID, ulong handle)
  2540. {
  2541. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2542. reply.ReplyBlock.RegionID = regionID;
  2543. reply.ReplyBlock.RegionHandle = handle;
  2544. OutPacket(reply, ThrottleOutPacketType.Land);
  2545. }
  2546. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2547. {
  2548. float dwell = 0.0f;
  2549. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2550. if (dwellModule != null)
  2551. dwell = dwellModule.GetDwell(land.GlobalID);
  2552. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2553. reply.AgentData.AgentID = m_agentId;
  2554. reply.Data.ParcelID = parcelID;
  2555. reply.Data.OwnerID = land.OwnerID;
  2556. reply.Data.Name = Utils.StringToBytes(land.Name);
  2557. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2558. reply.Data.ActualArea = land.Area;
  2559. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2560. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2561. reply.Data.Flags = (byte)(
  2562. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2563. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2564. Vector3 pos = land.UserLocation;
  2565. if (pos.Equals(Vector3.Zero))
  2566. {
  2567. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2568. }
  2569. reply.Data.GlobalX = info.RegionLocX + x;
  2570. reply.Data.GlobalY = info.RegionLocY + y;
  2571. reply.Data.GlobalZ = pos.Z;
  2572. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2573. reply.Data.SnapshotID = land.SnapshotID;
  2574. reply.Data.Dwell = dwell;
  2575. reply.Data.SalePrice = land.SalePrice;
  2576. reply.Data.AuctionID = (int)land.AuctionID;
  2577. OutPacket(reply, ThrottleOutPacketType.Land);
  2578. }
  2579. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2580. {
  2581. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2582. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2583. packet.Data.SimName = Utils.StringToBytes(simName);
  2584. packet.Data.SimPosition = pos;
  2585. packet.Data.LookAt = lookAt;
  2586. OutPacket(packet, ThrottleOutPacketType.Task);
  2587. }
  2588. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2589. {
  2590. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2591. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2592. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2593. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2594. packet.AgentData.AgentID = AgentId;
  2595. packet.QueryData[0].QueryID = queryID;
  2596. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2597. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2598. DirPlacesReplyPacket.StatusDataBlock[] status =
  2599. new DirPlacesReplyPacket.StatusDataBlock[0];
  2600. packet.QueryReplies = replies;
  2601. packet.StatusData = status;
  2602. foreach (DirPlacesReplyData d in data)
  2603. {
  2604. int idx = replies.Length;
  2605. Array.Resize(ref replies, idx + 1);
  2606. Array.Resize(ref status, idx + 1);
  2607. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2608. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2609. replies[idx].ParcelID = d.parcelID;
  2610. replies[idx].Name = Utils.StringToBytes(d.name);
  2611. replies[idx].ForSale = d.forSale;
  2612. replies[idx].Auction = d.auction;
  2613. replies[idx].Dwell = d.dwell;
  2614. status[idx].Status = d.Status;
  2615. packet.QueryReplies = replies;
  2616. packet.StatusData = status;
  2617. if (packet.Length >= 1000)
  2618. {
  2619. OutPacket(packet, ThrottleOutPacketType.Task);
  2620. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2621. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2622. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2623. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2624. packet.AgentData.AgentID = AgentId;
  2625. packet.QueryData[0].QueryID = queryID;
  2626. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2627. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2628. }
  2629. }
  2630. if (replies.Length > 0 || data.Length == 0)
  2631. OutPacket(packet, ThrottleOutPacketType.Task);
  2632. }
  2633. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2634. {
  2635. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2636. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2637. packet.AgentData.AgentID = AgentId;
  2638. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2639. packet.QueryData.QueryID = queryID;
  2640. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2641. data.Length];
  2642. int i = 0;
  2643. foreach (DirPeopleReplyData d in data)
  2644. {
  2645. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2646. packet.QueryReplies[i].AgentID = d.agentID;
  2647. packet.QueryReplies[i].FirstName =
  2648. Utils.StringToBytes(d.firstName);
  2649. packet.QueryReplies[i].LastName =
  2650. Utils.StringToBytes(d.lastName);
  2651. packet.QueryReplies[i].Group =
  2652. Utils.StringToBytes(d.group);
  2653. packet.QueryReplies[i].Online = d.online;
  2654. packet.QueryReplies[i].Reputation = d.reputation;
  2655. i++;
  2656. }
  2657. OutPacket(packet, ThrottleOutPacketType.Task);
  2658. }
  2659. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2660. {
  2661. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2662. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2663. packet.AgentData.AgentID = AgentId;
  2664. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2665. packet.QueryData.QueryID = queryID;
  2666. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2667. data.Length];
  2668. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2669. data.Length];
  2670. int i = 0;
  2671. foreach (DirEventsReplyData d in data)
  2672. {
  2673. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2674. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2675. packet.QueryReplies[i].OwnerID = d.ownerID;
  2676. packet.QueryReplies[i].Name =
  2677. Utils.StringToBytes(d.name);
  2678. packet.QueryReplies[i].EventID = d.eventID;
  2679. packet.QueryReplies[i].Date =
  2680. Utils.StringToBytes(d.date);
  2681. packet.QueryReplies[i].UnixTime = d.unixTime;
  2682. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2683. packet.StatusData[i].Status = d.Status;
  2684. i++;
  2685. }
  2686. OutPacket(packet, ThrottleOutPacketType.Task);
  2687. }
  2688. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2689. {
  2690. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2691. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2692. packet.AgentData.AgentID = AgentId;
  2693. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2694. packet.QueryData.QueryID = queryID;
  2695. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2696. data.Length];
  2697. int i = 0;
  2698. foreach (DirGroupsReplyData d in data)
  2699. {
  2700. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2701. packet.QueryReplies[i].GroupID = d.groupID;
  2702. packet.QueryReplies[i].GroupName =
  2703. Utils.StringToBytes(d.groupName);
  2704. packet.QueryReplies[i].Members = d.members;
  2705. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2706. i++;
  2707. }
  2708. OutPacket(packet, ThrottleOutPacketType.Task);
  2709. }
  2710. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2711. {
  2712. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2713. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2714. packet.AgentData.AgentID = AgentId;
  2715. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2716. packet.QueryData.QueryID = queryID;
  2717. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2718. data.Length];
  2719. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2720. data.Length];
  2721. int i = 0;
  2722. foreach (DirClassifiedReplyData d in data)
  2723. {
  2724. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2725. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2726. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2727. packet.QueryReplies[i].Name =
  2728. Utils.StringToBytes(d.name);
  2729. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2730. packet.QueryReplies[i].CreationDate = d.creationDate;
  2731. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2732. packet.QueryReplies[i].PriceForListing = d.price;
  2733. packet.StatusData[i].Status = d.Status;
  2734. i++;
  2735. }
  2736. OutPacket(packet, ThrottleOutPacketType.Task);
  2737. }
  2738. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2739. {
  2740. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2741. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2742. packet.AgentData.AgentID = AgentId;
  2743. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2744. packet.QueryData.QueryID = queryID;
  2745. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2746. data.Length];
  2747. int i = 0;
  2748. foreach (DirLandReplyData d in data)
  2749. {
  2750. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2751. packet.QueryReplies[i].ParcelID = d.parcelID;
  2752. packet.QueryReplies[i].Name =
  2753. Utils.StringToBytes(d.name);
  2754. packet.QueryReplies[i].Auction = d.auction;
  2755. packet.QueryReplies[i].ForSale = d.forSale;
  2756. packet.QueryReplies[i].SalePrice = d.salePrice;
  2757. packet.QueryReplies[i].ActualArea = d.actualArea;
  2758. i++;
  2759. }
  2760. OutPacket(packet, ThrottleOutPacketType.Task);
  2761. }
  2762. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2763. {
  2764. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2765. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2766. packet.AgentData.AgentID = AgentId;
  2767. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2768. packet.QueryData.QueryID = queryID;
  2769. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2770. data.Length];
  2771. int i = 0;
  2772. foreach (DirPopularReplyData d in data)
  2773. {
  2774. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2775. packet.QueryReplies[i].ParcelID = d.parcelID;
  2776. packet.QueryReplies[i].Name =
  2777. Utils.StringToBytes(d.name);
  2778. packet.QueryReplies[i].Dwell = d.dwell;
  2779. i++;
  2780. }
  2781. OutPacket(packet, ThrottleOutPacketType.Task);
  2782. }
  2783. public void SendEventInfoReply(EventData data)
  2784. {
  2785. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2786. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2787. packet.AgentData.AgentID = AgentId;
  2788. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2789. packet.EventData.EventID = data.eventID;
  2790. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2791. packet.EventData.Name = Utils.StringToBytes(data.name);
  2792. packet.EventData.Category = Utils.StringToBytes(data.category);
  2793. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2794. packet.EventData.Date = Utils.StringToBytes(data.date);
  2795. packet.EventData.DateUTC = data.dateUTC;
  2796. packet.EventData.Duration = data.duration;
  2797. packet.EventData.Cover = data.cover;
  2798. packet.EventData.Amount = data.amount;
  2799. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2800. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2801. packet.EventData.EventFlags = data.eventFlags;
  2802. OutPacket(packet, ThrottleOutPacketType.Task);
  2803. }
  2804. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2805. {
  2806. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2807. mirplk.AgentData.AgentID = AgentId;
  2808. mirplk.RequestData.ItemType = mapitemtype;
  2809. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2810. for (int i = 0; i < replies.Length; i++)
  2811. {
  2812. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2813. mrdata.X = replies[i].x;
  2814. mrdata.Y = replies[i].y;
  2815. mrdata.ID = replies[i].id;
  2816. mrdata.Extra = replies[i].Extra;
  2817. mrdata.Extra2 = replies[i].Extra2;
  2818. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2819. mirplk.Data[i] = mrdata;
  2820. }
  2821. //m_log.Debug(mirplk.ToString());
  2822. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2823. }
  2824. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2825. {
  2826. // a bit special, as this uses AgentID to store the source instead
  2827. // of the destination. The destination (the receiver) goes into destID
  2828. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2829. p.AgentData.AgentID = srcID;
  2830. p.AgentData.SessionID = UUID.Zero;
  2831. p.AgentBlock.DestID = AgentId;
  2832. p.AgentBlock.TransactionID = transactionID;
  2833. OutPacket(p, ThrottleOutPacketType.Task);
  2834. }
  2835. public void SendAcceptCallingCard(UUID transactionID)
  2836. {
  2837. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2838. p.AgentData.AgentID = AgentId;
  2839. p.AgentData.SessionID = UUID.Zero;
  2840. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2841. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2842. p.FolderData[0].FolderID = UUID.Zero;
  2843. OutPacket(p, ThrottleOutPacketType.Task);
  2844. }
  2845. public void SendDeclineCallingCard(UUID transactionID)
  2846. {
  2847. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2848. p.AgentData.AgentID = AgentId;
  2849. p.AgentData.SessionID = UUID.Zero;
  2850. p.TransactionBlock.TransactionID = transactionID;
  2851. OutPacket(p, ThrottleOutPacketType.Task);
  2852. }
  2853. public void SendTerminateFriend(UUID exFriendID)
  2854. {
  2855. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2856. p.AgentData.AgentID = AgentId;
  2857. p.AgentData.SessionID = SessionId;
  2858. p.ExBlock.OtherID = exFriendID;
  2859. OutPacket(p, ThrottleOutPacketType.Task);
  2860. }
  2861. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2862. {
  2863. OSDMap llsd = new OSDMap(3);
  2864. OSDArray AgentData = new OSDArray(1);
  2865. OSDMap AgentDataMap = new OSDMap(1);
  2866. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2867. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2868. AgentData.Add(AgentDataMap);
  2869. llsd.Add("AgentData", AgentData);
  2870. OSDArray GroupData = new OSDArray(data.Length);
  2871. OSDArray NewGroupData = new OSDArray(data.Length);
  2872. foreach (GroupMembershipData m in data)
  2873. {
  2874. OSDMap GroupDataMap = new OSDMap(6);
  2875. OSDMap NewGroupDataMap = new OSDMap(1);
  2876. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2877. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2878. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2879. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2880. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2881. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2882. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2883. GroupData.Add(GroupDataMap);
  2884. NewGroupData.Add(NewGroupDataMap);
  2885. }
  2886. llsd.Add("GroupData", GroupData);
  2887. llsd.Add("NewGroupData", NewGroupData);
  2888. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2889. if (eq != null)
  2890. {
  2891. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2892. }
  2893. }
  2894. public void SendJoinGroupReply(UUID groupID, bool success)
  2895. {
  2896. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2897. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2898. p.AgentData.AgentID = AgentId;
  2899. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2900. p.GroupData.GroupID = groupID;
  2901. p.GroupData.Success = success;
  2902. OutPacket(p, ThrottleOutPacketType.Task);
  2903. }
  2904. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2905. {
  2906. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2907. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2908. p.AgentData.AgentID = agentID;
  2909. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2910. p.GroupData.GroupID = groupID;
  2911. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2912. p.EjectData.Success = success;
  2913. OutPacket(p, ThrottleOutPacketType.Task);
  2914. }
  2915. public void SendLeaveGroupReply(UUID groupID, bool success)
  2916. {
  2917. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2918. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2919. p.AgentData.AgentID = AgentId;
  2920. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2921. p.GroupData.GroupID = groupID;
  2922. p.GroupData.Success = success;
  2923. OutPacket(p, ThrottleOutPacketType.Task);
  2924. }
  2925. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2926. {
  2927. if (classifiedID.Length != name.Length)
  2928. return;
  2929. AvatarClassifiedReplyPacket ac =
  2930. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2931. PacketType.AvatarClassifiedReply);
  2932. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2933. ac.AgentData.AgentID = AgentId;
  2934. ac.AgentData.TargetID = targetID;
  2935. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2936. int i;
  2937. for (i = 0; i < classifiedID.Length; i++)
  2938. {
  2939. ac.Data[i].ClassifiedID = classifiedID[i];
  2940. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2941. }
  2942. OutPacket(ac, ThrottleOutPacketType.Task);
  2943. }
  2944. 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)
  2945. {
  2946. ClassifiedInfoReplyPacket cr =
  2947. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2948. PacketType.ClassifiedInfoReply);
  2949. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2950. cr.AgentData.AgentID = AgentId;
  2951. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2952. cr.Data.ClassifiedID = classifiedID;
  2953. cr.Data.CreatorID = creatorID;
  2954. cr.Data.CreationDate = creationDate;
  2955. cr.Data.ExpirationDate = expirationDate;
  2956. cr.Data.Category = category;
  2957. cr.Data.Name = Utils.StringToBytes(name);
  2958. cr.Data.Desc = Utils.StringToBytes(description);
  2959. cr.Data.ParcelID = parcelID;
  2960. cr.Data.ParentEstate = parentEstate;
  2961. cr.Data.SnapshotID = snapshotID;
  2962. cr.Data.SimName = Utils.StringToBytes(simName);
  2963. cr.Data.PosGlobal = new Vector3d(globalPos);
  2964. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2965. cr.Data.ClassifiedFlags = classifiedFlags;
  2966. cr.Data.PriceForListing = price;
  2967. OutPacket(cr, ThrottleOutPacketType.Task);
  2968. }
  2969. public void SendAgentDropGroup(UUID groupID)
  2970. {
  2971. AgentDropGroupPacket dg =
  2972. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2973. PacketType.AgentDropGroup);
  2974. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2975. dg.AgentData.AgentID = AgentId;
  2976. dg.AgentData.GroupID = groupID;
  2977. OutPacket(dg, ThrottleOutPacketType.Task);
  2978. }
  2979. public void SendAvatarNotesReply(UUID targetID, string text)
  2980. {
  2981. AvatarNotesReplyPacket an =
  2982. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2983. PacketType.AvatarNotesReply);
  2984. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2985. an.AgentData.AgentID = AgentId;
  2986. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2987. an.Data.TargetID = targetID;
  2988. an.Data.Notes = Utils.StringToBytes(text);
  2989. OutPacket(an, ThrottleOutPacketType.Task);
  2990. }
  2991. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2992. {
  2993. AvatarPicksReplyPacket ap =
  2994. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2995. PacketType.AvatarPicksReply);
  2996. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2997. ap.AgentData.AgentID = AgentId;
  2998. ap.AgentData.TargetID = targetID;
  2999. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  3000. int i = 0;
  3001. foreach (KeyValuePair<UUID, string> pick in picks)
  3002. {
  3003. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  3004. ap.Data[i].PickID = pick.Key;
  3005. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  3006. i++;
  3007. }
  3008. OutPacket(ap, ThrottleOutPacketType.Task);
  3009. }
  3010. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  3011. {
  3012. AvatarClassifiedReplyPacket ac =
  3013. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3014. PacketType.AvatarClassifiedReply);
  3015. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3016. ac.AgentData.AgentID = AgentId;
  3017. ac.AgentData.TargetID = targetID;
  3018. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3019. int i = 0;
  3020. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3021. {
  3022. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3023. ac.Data[i].ClassifiedID = classified.Key;
  3024. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3025. i++;
  3026. }
  3027. OutPacket(ac, ThrottleOutPacketType.Task);
  3028. }
  3029. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3030. {
  3031. ParcelDwellReplyPacket pd =
  3032. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3033. PacketType.ParcelDwellReply);
  3034. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3035. pd.AgentData.AgentID = AgentId;
  3036. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3037. pd.Data.LocalID = localID;
  3038. pd.Data.ParcelID = parcelID;
  3039. pd.Data.Dwell = dwell;
  3040. OutPacket(pd, ThrottleOutPacketType.Land);
  3041. }
  3042. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3043. {
  3044. UserInfoReplyPacket ur =
  3045. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3046. PacketType.UserInfoReply);
  3047. string Visible = "hidden";
  3048. if (visible)
  3049. Visible = "default";
  3050. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3051. ur.AgentData.AgentID = AgentId;
  3052. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3053. ur.UserData.IMViaEMail = imViaEmail;
  3054. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3055. ur.UserData.EMail = Utils.StringToBytes(email);
  3056. OutPacket(ur, ThrottleOutPacketType.Task);
  3057. }
  3058. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3059. {
  3060. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3061. createGroupReply.AgentData =
  3062. new CreateGroupReplyPacket.AgentDataBlock();
  3063. createGroupReply.ReplyData =
  3064. new CreateGroupReplyPacket.ReplyDataBlock();
  3065. createGroupReply.AgentData.AgentID = AgentId;
  3066. createGroupReply.ReplyData.GroupID = groupID;
  3067. createGroupReply.ReplyData.Success = success;
  3068. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3069. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3070. }
  3071. public void SendUseCachedMuteList()
  3072. {
  3073. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3074. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3075. useCachedMuteList.AgentData.AgentID = AgentId;
  3076. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3077. }
  3078. public void SendMuteListUpdate(string filename)
  3079. {
  3080. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3081. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3082. muteListUpdate.MuteData.AgentID = AgentId;
  3083. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3084. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3085. }
  3086. 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)
  3087. {
  3088. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3089. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3090. pickInfoReply.AgentData.AgentID = AgentId;
  3091. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3092. pickInfoReply.Data.PickID = pickID;
  3093. pickInfoReply.Data.CreatorID = creatorID;
  3094. pickInfoReply.Data.TopPick = topPick;
  3095. pickInfoReply.Data.ParcelID = parcelID;
  3096. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3097. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3098. pickInfoReply.Data.SnapshotID = snapshotID;
  3099. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3100. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3101. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3102. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3103. pickInfoReply.Data.SortOrder = sortOrder;
  3104. pickInfoReply.Data.Enabled = enabled;
  3105. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3106. }
  3107. #endregion Scene/Avatar to Client
  3108. // Gesture
  3109. #region Appearance/ Wearables Methods
  3110. public void SendWearables(AvatarWearable[] wearables, int serial)
  3111. {
  3112. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3113. aw.AgentData.AgentID = AgentId;
  3114. aw.AgentData.SerialNum = (uint)serial;
  3115. aw.AgentData.SessionID = m_sessionId;
  3116. int count = 0;
  3117. for (int i = 0; i < wearables.Length; i++)
  3118. count += wearables[i].Count;
  3119. // TODO: don't create new blocks if recycling an old packet
  3120. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3121. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3122. int idx = 0;
  3123. for (int i = 0; i < wearables.Length; i++)
  3124. {
  3125. for (int j = 0; j < wearables[i].Count; j++)
  3126. {
  3127. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3128. awb.WearableType = (byte)i;
  3129. awb.AssetID = wearables[i][j].AssetID;
  3130. awb.ItemID = wearables[i][j].ItemID;
  3131. aw.WearableData[idx] = awb;
  3132. idx++;
  3133. // m_log.DebugFormat(
  3134. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3135. // awb.ItemID, awb.AssetID, i, Name);
  3136. }
  3137. }
  3138. OutPacket(aw, ThrottleOutPacketType.Task);
  3139. }
  3140. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3141. {
  3142. // m_log.DebugFormat(
  3143. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3144. // agentID, textureEntry.Length, Name, AgentId);
  3145. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3146. // TODO: don't create new blocks if recycling an old packet
  3147. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  3148. avp.ObjectData.TextureEntry = textureEntry;
  3149. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3150. for (int i = 0; i < visualParams.Length; i++)
  3151. {
  3152. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3153. avblock.ParamValue = visualParams[i];
  3154. avp.VisualParam[i] = avblock;
  3155. }
  3156. avp.Sender.IsTrial = false;
  3157. avp.Sender.ID = agentID;
  3158. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3159. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3160. OutPacket(avp, ThrottleOutPacketType.Task);
  3161. }
  3162. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3163. {
  3164. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3165. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3166. // TODO: don't create new blocks if recycling an old packet
  3167. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3168. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3169. ani.Sender.ID = sourceAgentId;
  3170. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3171. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3172. for (int i = 0; i < animations.Length; ++i)
  3173. {
  3174. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3175. ani.AnimationList[i].AnimID = animations[i];
  3176. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3177. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3178. if (objectIDs[i].Equals(sourceAgentId))
  3179. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3180. else
  3181. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3182. }
  3183. ani.Header.Reliable = false;
  3184. OutPacket(ani, ThrottleOutPacketType.Task);
  3185. }
  3186. #endregion
  3187. #region Avatar Packet/Data Sending Methods
  3188. /// <summary>
  3189. /// Send an ObjectUpdate packet with information about an avatar
  3190. /// </summary>
  3191. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3192. {
  3193. // m_log.DebugFormat(
  3194. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3195. // avatar.Name, avatar.UUID, Name, AgentId);
  3196. ScenePresence presence = avatar as ScenePresence;
  3197. if (presence == null)
  3198. return;
  3199. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3200. objupdate.Header.Zerocoded = true;
  3201. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3202. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3203. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3204. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3205. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3206. // We need to record the avatar local id since the root prim of an attachment points to this.
  3207. // m_attachmentsSent.Add(avatar.LocalId);
  3208. }
  3209. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3210. {
  3211. // We don't need to update inactive clients.
  3212. if (!IsActive)
  3213. return;
  3214. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3215. loc.Header.Reliable = false;
  3216. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3217. // a CoarseLocationUpdate packet is received. Oh well.
  3218. int total = Math.Min(CoarseLocations.Count, 60);
  3219. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3220. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3221. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3222. int selfindex = -1;
  3223. for (int i = 0; i < total; i++)
  3224. {
  3225. CoarseLocationUpdatePacket.LocationBlock lb =
  3226. new CoarseLocationUpdatePacket.LocationBlock();
  3227. lb.X = (byte)CoarseLocations[i].X;
  3228. lb.Y = (byte)CoarseLocations[i].Y;
  3229. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3230. loc.Location[i] = lb;
  3231. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3232. loc.AgentData[i].AgentID = users[i];
  3233. if (users[i] == AgentId)
  3234. selfindex = i;
  3235. }
  3236. ib.You = (short)selfindex;
  3237. ib.Prey = -1;
  3238. loc.Index = ib;
  3239. OutPacket(loc, ThrottleOutPacketType.Task);
  3240. }
  3241. #endregion Avatar Packet/Data Sending Methods
  3242. #region Primitive Packet/Data Sending Methods
  3243. /// <summary>
  3244. /// Generate one of the object update packets based on PrimUpdateFlags
  3245. /// and broadcast the packet to clients
  3246. /// </summary>
  3247. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3248. {
  3249. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3250. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3251. lock (m_entityUpdates.SyncRoot)
  3252. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3253. }
  3254. /// <summary>
  3255. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3256. /// We will update the priority and put it in the correct queue, merging update flags
  3257. /// with any other updates that may be queued for the same entity.
  3258. /// The original update time is used for the merged update.
  3259. /// </summary>
  3260. private void ResendPrimUpdate(EntityUpdate update)
  3261. {
  3262. // If the update exists in priority queue, it will be updated.
  3263. // If it does not exist then it will be added with the current (rather than its original) priority
  3264. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3265. lock (m_entityUpdates.SyncRoot)
  3266. m_entityUpdates.Enqueue(priority, update);
  3267. }
  3268. /// <summary>
  3269. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3270. /// We will update the priority and put it in the correct queue, merging update flags
  3271. /// with any other updates that may be queued for the same entity.
  3272. /// The original update time is used for the merged update.
  3273. /// </summary>
  3274. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3275. {
  3276. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3277. // Remove the update packet from the list of packets waiting for acknowledgement
  3278. // because we are requeuing the list of updates. They will be resent in new packets
  3279. // with the most recent state and priority.
  3280. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3281. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3282. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3283. foreach (EntityUpdate update in updates)
  3284. ResendPrimUpdate(update);
  3285. }
  3286. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3287. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3288. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3289. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3290. //
  3291. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3292. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3293. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3294. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3295. private void ProcessEntityUpdates(int maxUpdates)
  3296. {
  3297. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3298. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3299. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3300. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3301. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3302. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3303. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3304. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3305. // objectUpdateBlocks.Value.Clear();
  3306. // compressedUpdateBlocks.Value.Clear();
  3307. // terseUpdateBlocks.Value.Clear();
  3308. // terseAgentUpdateBlocks.Value.Clear();
  3309. // objectUpdates.Value.Clear();
  3310. // compressedUpdates.Value.Clear();
  3311. // terseUpdates.Value.Clear();
  3312. // terseAgentUpdates.Value.Clear();
  3313. // Check to see if this is a flush
  3314. if (maxUpdates <= 0)
  3315. {
  3316. maxUpdates = Int32.MaxValue;
  3317. }
  3318. int updatesThisCall = 0;
  3319. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3320. // condition where a kill can be processed before an out-of-date update for the same object.
  3321. lock (m_killRecord)
  3322. {
  3323. float avgTimeDilation = 1.0f;
  3324. IEntityUpdate iupdate;
  3325. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3326. while (updatesThisCall < maxUpdates)
  3327. {
  3328. lock (m_entityUpdates.SyncRoot)
  3329. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3330. break;
  3331. EntityUpdate update = (EntityUpdate)iupdate;
  3332. avgTimeDilation += update.TimeDilation;
  3333. avgTimeDilation *= 0.5f;
  3334. if (update.Entity is SceneObjectPart)
  3335. {
  3336. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3337. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3338. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3339. // safety measure.
  3340. //
  3341. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3342. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3343. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3344. //
  3345. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3346. // after the root prim has been deleted.
  3347. if (m_killRecord.Contains(part.LocalId))
  3348. {
  3349. // m_log.WarnFormat(
  3350. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3351. // part.LocalId, Name);
  3352. continue;
  3353. }
  3354. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3355. {
  3356. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3357. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3358. {
  3359. part.Shape.LightEntry = false;
  3360. }
  3361. }
  3362. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3363. {
  3364. // Ensure that mesh has at least 8 valid faces
  3365. part.Shape.ProfileBegin = 12500;
  3366. part.Shape.ProfileEnd = 0;
  3367. part.Shape.ProfileHollow = 27500;
  3368. }
  3369. }
  3370. #region UpdateFlags to packet type conversion
  3371. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3372. bool canUseCompressed = true;
  3373. bool canUseImproved = true;
  3374. // Compressed object updates only make sense for LL primitives
  3375. if (!(update.Entity is SceneObjectPart))
  3376. {
  3377. canUseCompressed = false;
  3378. }
  3379. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3380. {
  3381. canUseCompressed = false;
  3382. canUseImproved = false;
  3383. }
  3384. else
  3385. {
  3386. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3387. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3388. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3389. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3390. {
  3391. canUseCompressed = false;
  3392. }
  3393. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3394. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3395. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3396. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3397. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3398. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3399. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3400. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3401. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3402. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3403. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3404. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3405. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3406. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3407. {
  3408. canUseImproved = false;
  3409. }
  3410. }
  3411. #endregion UpdateFlags to packet type conversion
  3412. #region Block Construction
  3413. // TODO: Remove this once we can build compressed updates
  3414. canUseCompressed = false;
  3415. if (!canUseImproved && !canUseCompressed)
  3416. {
  3417. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3418. if (update.Entity is ScenePresence)
  3419. {
  3420. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3421. }
  3422. else
  3423. {
  3424. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3425. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3426. // If the part has become a private hud since the update was scheduled then we do not
  3427. // want to send it to other avatars.
  3428. if (part.ParentGroup.IsAttachment
  3429. && part.ParentGroup.HasPrivateAttachmentPoint
  3430. && part.ParentGroup.AttachedAvatar != AgentId)
  3431. continue;
  3432. // If the part has since been deleted, then drop the update. In the case of attachments,
  3433. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3434. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3435. // of the test above).
  3436. //
  3437. // Actual deletions (kills) happen in another method.
  3438. if (part.ParentGroup.IsDeleted)
  3439. continue;
  3440. }
  3441. objectUpdateBlocks.Value.Add(updateBlock);
  3442. objectUpdates.Value.Add(update);
  3443. }
  3444. else if (!canUseImproved)
  3445. {
  3446. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3447. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3448. = CreateCompressedUpdateBlock(part, updateFlags);
  3449. // If the part has since been deleted, then drop the update. In the case of attachments,
  3450. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3451. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3452. // of the test above).
  3453. //
  3454. // Actual deletions (kills) happen in another method.
  3455. if (part.ParentGroup.IsDeleted)
  3456. continue;
  3457. compressedUpdateBlocks.Value.Add(compressedBlock);
  3458. compressedUpdates.Value.Add(update);
  3459. }
  3460. else
  3461. {
  3462. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3463. {
  3464. // Self updates go into a special list
  3465. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3466. terseAgentUpdates.Value.Add(update);
  3467. }
  3468. else
  3469. {
  3470. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3471. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3472. // Everything else goes here
  3473. if (update.Entity is SceneObjectPart)
  3474. {
  3475. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3476. // If the part has become a private hud since the update was scheduled then we do not
  3477. // want to send it to other avatars.
  3478. if (part.ParentGroup.IsAttachment
  3479. && part.ParentGroup.HasPrivateAttachmentPoint
  3480. && part.ParentGroup.AttachedAvatar != AgentId)
  3481. continue;
  3482. // If the part has since been deleted, then drop the update. In the case of attachments,
  3483. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3484. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3485. // of the test above).
  3486. //
  3487. // Actual deletions (kills) happen in another method.
  3488. if (part.ParentGroup.IsDeleted)
  3489. continue;
  3490. }
  3491. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3492. terseUpdates.Value.Add(update);
  3493. }
  3494. }
  3495. ++updatesThisCall;
  3496. #endregion Block Construction
  3497. }
  3498. #region Packet Sending
  3499. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3500. if (terseAgentUpdateBlocks.IsValueCreated)
  3501. {
  3502. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3503. ImprovedTerseObjectUpdatePacket packet
  3504. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3505. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3506. packet.RegionData.TimeDilation = timeDilation;
  3507. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3508. for (int i = 0; i < blocks.Count; i++)
  3509. packet.ObjectData[i] = blocks[i];
  3510. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3511. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3512. }
  3513. if (objectUpdateBlocks.IsValueCreated)
  3514. {
  3515. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3516. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3517. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3518. packet.RegionData.TimeDilation = timeDilation;
  3519. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3520. for (int i = 0; i < blocks.Count; i++)
  3521. packet.ObjectData[i] = blocks[i];
  3522. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3523. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3524. }
  3525. if (compressedUpdateBlocks.IsValueCreated)
  3526. {
  3527. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3528. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3529. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3530. packet.RegionData.TimeDilation = timeDilation;
  3531. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3532. for (int i = 0; i < blocks.Count; i++)
  3533. packet.ObjectData[i] = blocks[i];
  3534. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3535. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3536. }
  3537. if (terseUpdateBlocks.IsValueCreated)
  3538. {
  3539. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3540. ImprovedTerseObjectUpdatePacket packet
  3541. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3542. PacketType.ImprovedTerseObjectUpdate);
  3543. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3544. packet.RegionData.TimeDilation = timeDilation;
  3545. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3546. for (int i = 0; i < blocks.Count; i++)
  3547. packet.ObjectData[i] = blocks[i];
  3548. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3549. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3550. }
  3551. }
  3552. #endregion Packet Sending
  3553. }
  3554. public void ReprioritizeUpdates()
  3555. {
  3556. lock (m_entityUpdates.SyncRoot)
  3557. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3558. }
  3559. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3560. {
  3561. if (entity != null)
  3562. {
  3563. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3564. return true;
  3565. }
  3566. return false;
  3567. }
  3568. public void FlushPrimUpdates()
  3569. {
  3570. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3571. while (m_entityUpdates.Count > 0)
  3572. ProcessEntityUpdates(-1);
  3573. }
  3574. #endregion Primitive Packet/Data Sending Methods
  3575. // These are used to implement an adaptive backoff in the number
  3576. // of updates converted to packets. Since we don't want packets
  3577. // to sit in the queue with old data, only convert enough updates
  3578. // to packets that can be sent in 200ms.
  3579. private Int32 m_LastQueueFill = 0;
  3580. private Int32 m_maxUpdates = 0;
  3581. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3582. {
  3583. // if (!m_udpServer.IsRunningOutbound)
  3584. // return;
  3585. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3586. {
  3587. // if (!m_udpServer.IsRunningOutbound)
  3588. // return;
  3589. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3590. {
  3591. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3592. }
  3593. else
  3594. {
  3595. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3596. m_maxUpdates += 5;
  3597. else
  3598. m_maxUpdates = m_maxUpdates >> 1;
  3599. }
  3600. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3601. m_LastQueueFill = Util.EnvironmentTickCount();
  3602. if (m_entityUpdates.Count > 0)
  3603. ProcessEntityUpdates(m_maxUpdates);
  3604. if (m_entityProps.Count > 0)
  3605. ProcessEntityPropertyRequests(m_maxUpdates);
  3606. }
  3607. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3608. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3609. }
  3610. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3611. {
  3612. bool hasUpdates = false;
  3613. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3614. {
  3615. if (m_entityUpdates.Count > 0)
  3616. hasUpdates = true;
  3617. else if (m_entityProps.Count > 0)
  3618. hasUpdates = true;
  3619. }
  3620. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3621. {
  3622. if (ImageManager.HasUpdates())
  3623. hasUpdates = true;
  3624. }
  3625. return hasUpdates;
  3626. }
  3627. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3628. {
  3629. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3630. newPack.AssetBlock.Type = AssetType;
  3631. newPack.AssetBlock.Success = Success;
  3632. newPack.AssetBlock.UUID = AssetFullID;
  3633. newPack.Header.Zerocoded = true;
  3634. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3635. }
  3636. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3637. {
  3638. RequestXferPacket newPack = new RequestXferPacket();
  3639. newPack.XferID.ID = XferID;
  3640. newPack.XferID.VFileType = AssetType;
  3641. newPack.XferID.VFileID = vFileID;
  3642. newPack.XferID.FilePath = FilePath;
  3643. newPack.XferID.Filename = FileName;
  3644. newPack.Header.Zerocoded = true;
  3645. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3646. }
  3647. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3648. {
  3649. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3650. newPack.XferID.ID = xferID;
  3651. newPack.XferID.Packet = PacketID;
  3652. newPack.Header.Zerocoded = true;
  3653. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3654. }
  3655. public void SendInitiateDownload(string simFileName, string clientFileName)
  3656. {
  3657. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3658. newPack.AgentData.AgentID = AgentId;
  3659. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3660. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3661. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3662. }
  3663. public void SendImageFirstPart(
  3664. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3665. {
  3666. ImageDataPacket im = new ImageDataPacket();
  3667. im.Header.Reliable = false;
  3668. im.ImageID.Packets = numParts;
  3669. im.ImageID.ID = ImageUUID;
  3670. if (ImageSize > 0)
  3671. im.ImageID.Size = ImageSize;
  3672. im.ImageData.Data = ImageData;
  3673. im.ImageID.Codec = imageCodec;
  3674. im.Header.Zerocoded = true;
  3675. OutPacket(im, ThrottleOutPacketType.Texture);
  3676. }
  3677. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3678. {
  3679. ImagePacketPacket im = new ImagePacketPacket();
  3680. im.Header.Reliable = false;
  3681. im.ImageID.Packet = partNumber;
  3682. im.ImageID.ID = imageUuid;
  3683. im.ImageData.Data = imageData;
  3684. OutPacket(im, ThrottleOutPacketType.Texture);
  3685. }
  3686. public void SendImageNotFound(UUID imageid)
  3687. {
  3688. ImageNotInDatabasePacket notFoundPacket
  3689. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3690. notFoundPacket.ImageID.ID = imageid;
  3691. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3692. }
  3693. public void SendShutdownConnectionNotice()
  3694. {
  3695. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3696. }
  3697. public void SendSimStats(SimStats stats)
  3698. {
  3699. SimStatsPacket pack = new SimStatsPacket();
  3700. pack.Region = new SimStatsPacket.RegionBlock();
  3701. pack.Region.RegionX = stats.RegionX;
  3702. pack.Region.RegionY = stats.RegionY;
  3703. pack.Region.RegionFlags = stats.RegionFlags;
  3704. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3705. //pack.Region = //stats.RegionBlock;
  3706. pack.Stat = stats.StatsBlock;
  3707. pack.Header.Reliable = false;
  3708. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3709. OutPacket(pack, ThrottleOutPacketType.Task);
  3710. }
  3711. private class ObjectPropertyUpdate : IEntityUpdate
  3712. {
  3713. internal bool SendFamilyProps;
  3714. internal bool SendObjectProps;
  3715. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3716. : base(entity,flags)
  3717. {
  3718. SendFamilyProps = sendfam;
  3719. SendObjectProps = sendobj;
  3720. }
  3721. public void Update(ObjectPropertyUpdate update)
  3722. {
  3723. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3724. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3725. // other properties may need to be updated by base class
  3726. base.Update(update);
  3727. }
  3728. }
  3729. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3730. {
  3731. uint priority = 0; // time based ordering only
  3732. lock (m_entityProps.SyncRoot)
  3733. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3734. }
  3735. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3736. {
  3737. uint priority = 0;
  3738. lock (m_entityProps.SyncRoot)
  3739. m_entityProps.Enqueue(priority, update);
  3740. }
  3741. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3742. {
  3743. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3744. // Remove the update packet from the list of packets waiting for acknowledgement
  3745. // because we are requeuing the list of updates. They will be resent in new packets
  3746. // with the most recent state.
  3747. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3748. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3749. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3750. foreach (ObjectPropertyUpdate update in updates)
  3751. ResendPropertyUpdate(update);
  3752. }
  3753. public void SendObjectPropertiesReply(ISceneEntity entity)
  3754. {
  3755. uint priority = 0; // time based ordering only
  3756. lock (m_entityProps.SyncRoot)
  3757. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3758. }
  3759. private void ProcessEntityPropertyRequests(int maxUpdates)
  3760. {
  3761. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3762. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3763. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3764. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3765. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3766. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3767. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3768. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3769. IEntityUpdate iupdate;
  3770. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3771. int updatesThisCall = 0;
  3772. while (updatesThisCall < m_maxUpdates)
  3773. {
  3774. lock (m_entityProps.SyncRoot)
  3775. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3776. break;
  3777. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3778. if (update.SendFamilyProps)
  3779. {
  3780. if (update.Entity is SceneObjectPart)
  3781. {
  3782. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3783. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3784. objectFamilyBlocks.Value.Add(objPropDB);
  3785. familyUpdates.Value.Add(update);
  3786. }
  3787. }
  3788. if (update.SendObjectProps)
  3789. {
  3790. if (update.Entity is SceneObjectPart)
  3791. {
  3792. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3793. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3794. objectPropertiesBlocks.Value.Add(objPropDB);
  3795. propertyUpdates.Value.Add(update);
  3796. }
  3797. }
  3798. updatesThisCall++;
  3799. }
  3800. // Int32 ppcnt = 0;
  3801. // Int32 pbcnt = 0;
  3802. if (objectPropertiesBlocks.IsValueCreated)
  3803. {
  3804. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3805. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3806. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3807. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3808. for (int i = 0; i < blocks.Count; i++)
  3809. packet.ObjectData[i] = blocks[i];
  3810. packet.Header.Zerocoded = true;
  3811. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3812. // of the object rather than the properties when the packet was created
  3813. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3814. delegate(OutgoingPacket oPacket)
  3815. {
  3816. ResendPropertyUpdates(updates, oPacket);
  3817. });
  3818. // pbcnt += blocks.Count;
  3819. // ppcnt++;
  3820. }
  3821. // Int32 fpcnt = 0;
  3822. // Int32 fbcnt = 0;
  3823. if (objectFamilyBlocks.IsValueCreated)
  3824. {
  3825. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3826. // one packet per object block... uggh...
  3827. for (int i = 0; i < blocks.Count; i++)
  3828. {
  3829. ObjectPropertiesFamilyPacket packet =
  3830. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3831. packet.ObjectData = blocks[i];
  3832. packet.Header.Zerocoded = true;
  3833. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3834. // of the object rather than the properties when the packet was created
  3835. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3836. updates.Add(familyUpdates.Value[i]);
  3837. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3838. delegate(OutgoingPacket oPacket)
  3839. {
  3840. ResendPropertyUpdates(updates, oPacket);
  3841. });
  3842. // fpcnt++;
  3843. // fbcnt++;
  3844. }
  3845. }
  3846. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3847. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3848. }
  3849. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3850. {
  3851. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3852. block.RequestFlags = requestFlags;
  3853. block.ObjectID = sop.UUID;
  3854. if (sop.OwnerID == sop.GroupID)
  3855. block.OwnerID = UUID.Zero;
  3856. else
  3857. block.OwnerID = sop.OwnerID;
  3858. block.GroupID = sop.GroupID;
  3859. block.BaseMask = sop.BaseMask;
  3860. block.OwnerMask = sop.OwnerMask;
  3861. block.GroupMask = sop.GroupMask;
  3862. block.EveryoneMask = sop.EveryoneMask;
  3863. block.NextOwnerMask = sop.NextOwnerMask;
  3864. // TODO: More properties are needed in SceneObjectPart!
  3865. block.OwnershipCost = sop.OwnershipCost;
  3866. block.SaleType = sop.ObjectSaleType;
  3867. block.SalePrice = sop.SalePrice;
  3868. block.Category = sop.Category;
  3869. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3870. block.Name = Util.StringToBytes256(sop.Name);
  3871. block.Description = Util.StringToBytes256(sop.Description);
  3872. return block;
  3873. }
  3874. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3875. {
  3876. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3877. // TODO: don't create new blocks if recycling an old packet
  3878. ObjectPropertiesPacket.ObjectDataBlock block =
  3879. new ObjectPropertiesPacket.ObjectDataBlock();
  3880. block.ObjectID = sop.UUID;
  3881. block.Name = Util.StringToBytes256(sop.Name);
  3882. block.Description = Util.StringToBytes256(sop.Description);
  3883. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3884. block.CreatorID = sop.CreatorID;
  3885. block.GroupID = sop.GroupID;
  3886. block.LastOwnerID = sop.LastOwnerID;
  3887. if (sop.OwnerID == sop.GroupID)
  3888. block.OwnerID = UUID.Zero;
  3889. else
  3890. block.OwnerID = sop.OwnerID;
  3891. block.ItemID = sop.FromUserInventoryItemID;
  3892. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3893. block.FromTaskID = UUID.Zero; // ???
  3894. block.InventorySerial = (short)sop.InventorySerial;
  3895. SceneObjectPart root = sop.ParentGroup.RootPart;
  3896. block.TouchName = Util.StringToBytes256(root.TouchName);
  3897. block.TextureID = new byte[0]; // TextureID ???
  3898. block.SitName = Util.StringToBytes256(root.SitName);
  3899. block.OwnerMask = root.OwnerMask;
  3900. block.NextOwnerMask = root.NextOwnerMask;
  3901. block.GroupMask = root.GroupMask;
  3902. block.EveryoneMask = root.EveryoneMask;
  3903. block.BaseMask = root.BaseMask;
  3904. block.SaleType = root.ObjectSaleType;
  3905. block.SalePrice = root.SalePrice;
  3906. return block;
  3907. }
  3908. #region Estate Data Sending Methods
  3909. private static bool convertParamStringToBool(byte[] field)
  3910. {
  3911. string s = Utils.BytesToString(field);
  3912. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3913. {
  3914. return true;
  3915. }
  3916. return false;
  3917. }
  3918. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3919. {
  3920. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3921. packet.AgentData.TransactionID = UUID.Random();
  3922. packet.AgentData.AgentID = AgentId;
  3923. packet.AgentData.SessionID = SessionId;
  3924. packet.MethodData.Invoice = invoice;
  3925. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3926. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3927. for (int i = 0; i < (6 + Data.Length); i++)
  3928. {
  3929. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3930. }
  3931. int j = 0;
  3932. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3933. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3934. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3935. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3936. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3937. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3938. j = 2; // Agents
  3939. if ((code & 2) != 0)
  3940. j = 3; // Groups
  3941. if ((code & 8) != 0)
  3942. j = 5; // Managers
  3943. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3944. j = 6;
  3945. for (int i = 0; i < Data.Length; i++)
  3946. {
  3947. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3948. }
  3949. packet.ParamList = returnblock;
  3950. packet.Header.Reliable = true;
  3951. OutPacket(packet, ThrottleOutPacketType.Task);
  3952. }
  3953. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3954. {
  3955. List<UUID> BannedUsers = new List<UUID>();
  3956. for (int i = 0; i < bl.Length; i++)
  3957. {
  3958. if (bl[i] == null)
  3959. continue;
  3960. if (bl[i].BannedUserID == UUID.Zero)
  3961. continue;
  3962. BannedUsers.Add(bl[i].BannedUserID);
  3963. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3964. {
  3965. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3966. packet.AgentData.TransactionID = UUID.Random();
  3967. packet.AgentData.AgentID = AgentId;
  3968. packet.AgentData.SessionID = SessionId;
  3969. packet.MethodData.Invoice = invoice;
  3970. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3971. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3972. int j;
  3973. for (j = 0; j < (6 + BannedUsers.Count); j++)
  3974. {
  3975. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  3976. }
  3977. j = 0;
  3978. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3979. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3980. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3981. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3982. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3983. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3984. foreach (UUID banned in BannedUsers)
  3985. {
  3986. returnblock[j].Parameter = banned.GetBytes(); j++;
  3987. }
  3988. packet.ParamList = returnblock;
  3989. packet.Header.Reliable = true;
  3990. OutPacket(packet, ThrottleOutPacketType.Task);
  3991. BannedUsers.Clear();
  3992. }
  3993. }
  3994. }
  3995. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  3996. {
  3997. RegionInfoPacket rinfopack = new RegionInfoPacket();
  3998. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  3999. rinfopack.AgentData.AgentID = AgentId;
  4000. rinfopack.AgentData.SessionID = SessionId;
  4001. rinfoblk.BillableFactor = args.billableFactor;
  4002. rinfoblk.EstateID = args.estateID;
  4003. rinfoblk.MaxAgents = args.maxAgents;
  4004. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4005. rinfoblk.ParentEstateID = args.parentEstateID;
  4006. rinfoblk.PricePerMeter = args.pricePerMeter;
  4007. rinfoblk.RedirectGridX = args.redirectGridX;
  4008. rinfoblk.RedirectGridY = args.redirectGridY;
  4009. rinfoblk.RegionFlags = args.regionFlags;
  4010. rinfoblk.SimAccess = args.simAccess;
  4011. rinfoblk.SunHour = args.sunHour;
  4012. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4013. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4014. rinfoblk.UseEstateSun = args.useEstateSun;
  4015. rinfoblk.WaterHeight = args.waterHeight;
  4016. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4017. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4018. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4019. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4020. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4021. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4022. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4023. rinfopack.HasVariableBlocks = true;
  4024. rinfopack.RegionInfo = rinfoblk;
  4025. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4026. rinfopack.AgentData.AgentID = AgentId;
  4027. rinfopack.AgentData.SessionID = SessionId;
  4028. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4029. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4030. }
  4031. public void SendEstateCovenantInformation(UUID covenant)
  4032. {
  4033. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4034. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4035. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4036. edata.CovenantID = covenant;
  4037. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4038. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4039. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4040. einfopack.Data = edata;
  4041. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4042. }
  4043. public void SendDetailedEstateData(
  4044. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4045. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4046. {
  4047. // m_log.DebugFormat(
  4048. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4049. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4050. packet.MethodData.Invoice = invoice;
  4051. packet.AgentData.TransactionID = UUID.Random();
  4052. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4053. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4054. for (int i = 0; i < 10; i++)
  4055. {
  4056. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4057. }
  4058. //Sending Estate Settings
  4059. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4060. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4061. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4062. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4063. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4064. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4065. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4066. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4067. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4068. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4069. packet.ParamList = returnblock;
  4070. packet.Header.Reliable = false;
  4071. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4072. OutPacket(packet, ThrottleOutPacketType.Task);
  4073. }
  4074. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4075. {
  4076. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4077. packet.TelehubBlock.ObjectID = ObjectID;
  4078. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4079. packet.TelehubBlock.TelehubPos = ObjectPos;
  4080. packet.TelehubBlock.TelehubRot = ObjectRot;
  4081. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4082. for (int n = 0; n < SpawnPoint.Count; n++)
  4083. {
  4084. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4085. }
  4086. OutPacket(packet, ThrottleOutPacketType.Task);
  4087. }
  4088. #endregion
  4089. #region Land Data Sending Methods
  4090. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4091. {
  4092. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4093. packet.ParcelData.Data = data;
  4094. packet.ParcelData.SequenceID = sequence_id;
  4095. packet.Header.Zerocoded = true;
  4096. OutPacket(packet, ThrottleOutPacketType.Task);
  4097. }
  4098. public void SendLandProperties(
  4099. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4100. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4101. {
  4102. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4103. LandData landData = lo.LandData;
  4104. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4105. updateMessage.AABBMax = landData.AABBMax;
  4106. updateMessage.AABBMin = landData.AABBMin;
  4107. updateMessage.Area = landData.Area;
  4108. updateMessage.AuctionID = landData.AuctionID;
  4109. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4110. updateMessage.Bitmap = landData.Bitmap;
  4111. updateMessage.Desc = landData.Description;
  4112. updateMessage.Category = landData.Category;
  4113. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4114. updateMessage.ClaimPrice = landData.ClaimPrice;
  4115. updateMessage.GroupID = landData.GroupID;
  4116. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4117. updateMessage.LandingType = (LandingType) landData.LandingType;
  4118. updateMessage.LocalID = landData.LocalID;
  4119. if (landData.Area > 0)
  4120. {
  4121. updateMessage.MaxPrims = parcelObjectCapacity;
  4122. }
  4123. else
  4124. {
  4125. updateMessage.MaxPrims = 0;
  4126. }
  4127. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4128. updateMessage.MediaID = landData.MediaID;
  4129. updateMessage.MediaURL = landData.MediaURL;
  4130. updateMessage.MusicURL = landData.MusicURL;
  4131. updateMessage.Name = landData.Name;
  4132. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4133. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4134. updateMessage.OwnerID = landData.OwnerID;
  4135. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4136. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4137. updateMessage.PassHours = landData.PassHours;
  4138. updateMessage.PassPrice = landData.PassPrice;
  4139. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4140. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4141. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4142. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4143. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4144. updateMessage.RentPrice = 0;
  4145. updateMessage.RequestResult = (ParcelResult) request_result;
  4146. updateMessage.SalePrice = landData.SalePrice;
  4147. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4148. updateMessage.SequenceID = sequence_id;
  4149. if (landData.SimwideArea > 0)
  4150. {
  4151. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4152. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4153. }
  4154. else
  4155. {
  4156. updateMessage.SimWideMaxPrims = 0;
  4157. }
  4158. updateMessage.SnapSelection = snap_selection;
  4159. updateMessage.SnapshotID = landData.SnapshotID;
  4160. updateMessage.Status = (ParcelStatus) landData.Status;
  4161. updateMessage.UserLocation = landData.UserLocation;
  4162. updateMessage.UserLookAt = landData.UserLookAt;
  4163. updateMessage.MediaType = landData.MediaType;
  4164. updateMessage.MediaDesc = landData.MediaDescription;
  4165. updateMessage.MediaWidth = landData.MediaWidth;
  4166. updateMessage.MediaHeight = landData.MediaHeight;
  4167. updateMessage.MediaLoop = landData.MediaLoop;
  4168. updateMessage.ObscureMusic = landData.ObscureMusic;
  4169. updateMessage.ObscureMedia = landData.ObscureMedia;
  4170. IPrimCounts pc = lo.PrimCounts;
  4171. updateMessage.OwnerPrims = pc.Owner;
  4172. updateMessage.GroupPrims = pc.Group;
  4173. updateMessage.OtherPrims = pc.Others;
  4174. updateMessage.SelectedPrims = pc.Selected;
  4175. updateMessage.TotalPrims = pc.Total;
  4176. updateMessage.SimWideTotalPrims = pc.Simulator;
  4177. try
  4178. {
  4179. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4180. if (eq != null)
  4181. {
  4182. eq.ParcelProperties(updateMessage, this.AgentId);
  4183. }
  4184. else
  4185. {
  4186. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4187. }
  4188. }
  4189. catch (Exception ex)
  4190. {
  4191. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4192. }
  4193. }
  4194. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4195. {
  4196. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4197. replyPacket.Data.AgentID = AgentId;
  4198. replyPacket.Data.Flags = accessFlag;
  4199. replyPacket.Data.LocalID = localLandID;
  4200. replyPacket.Data.SequenceID = 0;
  4201. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4202. foreach (LandAccessEntry entry in accessList)
  4203. {
  4204. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4205. block.Flags = accessFlag;
  4206. block.ID = entry.AgentID;
  4207. block.Time = entry.Expires;
  4208. list.Add(block);
  4209. }
  4210. replyPacket.List = list.ToArray();
  4211. replyPacket.Header.Zerocoded = true;
  4212. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4213. }
  4214. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4215. {
  4216. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4217. bool firstCall = true;
  4218. const int MAX_OBJECTS_PER_PACKET = 251;
  4219. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4220. ForceObjectSelectPacket.DataBlock[] data;
  4221. while (ObjectIDs.Count > 0)
  4222. {
  4223. if (firstCall)
  4224. {
  4225. pack._Header.ResetList = true;
  4226. firstCall = false;
  4227. }
  4228. else
  4229. {
  4230. pack._Header.ResetList = false;
  4231. }
  4232. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4233. {
  4234. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4235. }
  4236. else
  4237. {
  4238. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4239. }
  4240. int i;
  4241. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4242. {
  4243. data[i] = new ForceObjectSelectPacket.DataBlock();
  4244. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4245. ObjectIDs.RemoveAt(0);
  4246. }
  4247. pack.Data = data;
  4248. pack.Header.Zerocoded = true;
  4249. OutPacket(pack, ThrottleOutPacketType.Task);
  4250. }
  4251. }
  4252. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4253. {
  4254. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4255. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4256. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4257. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4258. OutPacket(cpack, ThrottleOutPacketType.Task);
  4259. }
  4260. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4261. {
  4262. int notifyCount = ownersAndCount.Count;
  4263. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4264. if (notifyCount > 0)
  4265. {
  4266. if (notifyCount > 32)
  4267. {
  4268. m_log.InfoFormat(
  4269. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4270. + " - a developer might want to investigate whether this is a hard limit", 32);
  4271. notifyCount = 32;
  4272. }
  4273. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4274. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4275. int num = 0;
  4276. foreach (UUID owner in ownersAndCount.Keys)
  4277. {
  4278. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4279. dataBlock[num].Count = ownersAndCount[owner];
  4280. if (land.GroupID == owner || groups.Contains(owner))
  4281. dataBlock[num].IsGroupOwned = true;
  4282. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4283. dataBlock[num].OwnerID = owner;
  4284. num++;
  4285. if (num >= notifyCount)
  4286. {
  4287. break;
  4288. }
  4289. }
  4290. pack.Data = dataBlock;
  4291. }
  4292. else
  4293. {
  4294. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4295. }
  4296. pack.Header.Zerocoded = true;
  4297. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4298. }
  4299. #endregion
  4300. #region Helper Methods
  4301. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4302. {
  4303. #region ScenePresence/SOP Handling
  4304. bool avatar = (entity is ScenePresence);
  4305. uint localID = entity.LocalId;
  4306. uint attachPoint;
  4307. Vector4 collisionPlane;
  4308. Vector3 position, velocity, acceleration, angularVelocity;
  4309. Quaternion rotation;
  4310. byte[] textureEntry;
  4311. if (entity is ScenePresence)
  4312. {
  4313. ScenePresence presence = (ScenePresence)entity;
  4314. attachPoint = presence.State;
  4315. collisionPlane = presence.CollisionPlane;
  4316. position = presence.OffsetPosition;
  4317. velocity = presence.Velocity;
  4318. acceleration = Vector3.Zero;
  4319. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4320. // in that direction, even though we don't model this on the server. Implementing this in the future
  4321. // may improve movement smoothness.
  4322. // acceleration = new Vector3(1, 0, 0);
  4323. angularVelocity = presence.AngularVelocity;
  4324. rotation = presence.Rotation;
  4325. if (sendTexture)
  4326. textureEntry = presence.Appearance.Texture.GetBytes();
  4327. else
  4328. textureEntry = null;
  4329. }
  4330. else
  4331. {
  4332. SceneObjectPart part = (SceneObjectPart)entity;
  4333. attachPoint = part.ParentGroup.AttachmentPoint;
  4334. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4335. // m_log.DebugFormat(
  4336. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4337. // attachPoint, part.Name, part.LocalId, Name);
  4338. collisionPlane = Vector4.Zero;
  4339. position = part.RelativePosition;
  4340. velocity = part.Velocity;
  4341. acceleration = part.Acceleration;
  4342. angularVelocity = part.AngularVelocity;
  4343. rotation = part.RotationOffset;
  4344. if (sendTexture)
  4345. textureEntry = part.Shape.TextureEntry;
  4346. else
  4347. textureEntry = null;
  4348. }
  4349. #endregion ScenePresence/SOP Handling
  4350. int pos = 0;
  4351. byte[] data = new byte[(avatar ? 60 : 44)];
  4352. // LocalID
  4353. Utils.UIntToBytes(localID, data, pos);
  4354. pos += 4;
  4355. // Avatar/CollisionPlane
  4356. data[pos++] = (byte) attachPoint;
  4357. if (avatar)
  4358. {
  4359. data[pos++] = 1;
  4360. if (collisionPlane == Vector4.Zero)
  4361. collisionPlane = Vector4.UnitW;
  4362. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4363. collisionPlane.ToBytes(data, pos);
  4364. pos += 16;
  4365. }
  4366. else
  4367. {
  4368. ++pos;
  4369. }
  4370. // Position
  4371. position.ToBytes(data, pos);
  4372. pos += 12;
  4373. // Velocity
  4374. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4375. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4376. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4377. // Acceleration
  4378. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4379. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4380. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4381. // Rotation
  4382. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4383. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4384. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4385. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4386. // Angular Velocity
  4387. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4388. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4389. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4390. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4391. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4392. block.Data = data;
  4393. if (textureEntry != null && textureEntry.Length > 0)
  4394. {
  4395. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4396. // Texture Length
  4397. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4398. // Texture
  4399. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4400. block.TextureEntry = teBytesFinal;
  4401. }
  4402. else
  4403. {
  4404. block.TextureEntry = Utils.EmptyBytes;
  4405. }
  4406. return block;
  4407. }
  4408. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4409. {
  4410. byte[] objectData = new byte[76];
  4411. data.CollisionPlane.ToBytes(objectData, 0);
  4412. data.OffsetPosition.ToBytes(objectData, 16);
  4413. // data.Velocity.ToBytes(objectData, 28);
  4414. // data.Acceleration.ToBytes(objectData, 40);
  4415. data.Rotation.ToBytes(objectData, 52);
  4416. //data.AngularVelocity.ToBytes(objectData, 64);
  4417. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4418. update.Data = Utils.EmptyBytes;
  4419. update.ExtraParams = new byte[1];
  4420. update.FullID = data.UUID;
  4421. update.ID = data.LocalId;
  4422. update.Material = (byte)Material.Flesh;
  4423. update.MediaURL = Utils.EmptyBytes;
  4424. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4425. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4426. update.ObjectData = objectData;
  4427. update.ParentID = data.ParentID;
  4428. update.PathCurve = 16;
  4429. update.PathScaleX = 100;
  4430. update.PathScaleY = 100;
  4431. update.PCode = (byte)PCode.Avatar;
  4432. update.ProfileCurve = 1;
  4433. update.PSBlock = Utils.EmptyBytes;
  4434. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4435. update.Text = Utils.EmptyBytes;
  4436. update.TextColor = new byte[4];
  4437. // Don't send texture anim for avatars - this has no meaning for them.
  4438. update.TextureAnim = Utils.EmptyBytes;
  4439. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4440. update.TextureEntry = Utils.EmptyBytes;
  4441. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4442. update.UpdateFlags = (uint)(
  4443. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4444. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4445. PrimFlags.ObjectOwnerModify);
  4446. return update;
  4447. }
  4448. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4449. {
  4450. byte[] objectData = new byte[60];
  4451. data.RelativePosition.ToBytes(objectData, 0);
  4452. data.Velocity.ToBytes(objectData, 12);
  4453. data.Acceleration.ToBytes(objectData, 24);
  4454. try
  4455. {
  4456. data.RotationOffset.ToBytes(objectData, 36);
  4457. }
  4458. catch (Exception e)
  4459. {
  4460. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4461. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4462. }
  4463. data.AngularVelocity.ToBytes(objectData, 48);
  4464. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4465. update.ClickAction = (byte)data.ClickAction;
  4466. update.CRC = 0;
  4467. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4468. update.FullID = data.UUID;
  4469. update.ID = data.LocalId;
  4470. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4471. //update.JointPivot = Vector3.Zero;
  4472. //update.JointType = 0;
  4473. update.Material = data.Material;
  4474. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4475. if (data.ParentGroup.IsAttachment)
  4476. {
  4477. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4478. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4479. }
  4480. else
  4481. {
  4482. update.NameValue = Utils.EmptyBytes;
  4483. // The root part state is the canonical state for all parts of the object. The other part states in the
  4484. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4485. update.State = data.ParentGroup.RootPart.Shape.State;
  4486. }
  4487. // m_log.DebugFormat(
  4488. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4489. // update.State, data.Name, data.LocalId, Name);
  4490. update.ObjectData = objectData;
  4491. update.ParentID = data.ParentID;
  4492. update.PathBegin = data.Shape.PathBegin;
  4493. update.PathCurve = data.Shape.PathCurve;
  4494. update.PathEnd = data.Shape.PathEnd;
  4495. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4496. update.PathRevolutions = data.Shape.PathRevolutions;
  4497. update.PathScaleX = data.Shape.PathScaleX;
  4498. update.PathScaleY = data.Shape.PathScaleY;
  4499. update.PathShearX = data.Shape.PathShearX;
  4500. update.PathShearY = data.Shape.PathShearY;
  4501. update.PathSkew = data.Shape.PathSkew;
  4502. update.PathTaperX = data.Shape.PathTaperX;
  4503. update.PathTaperY = data.Shape.PathTaperY;
  4504. update.PathTwist = data.Shape.PathTwist;
  4505. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4506. update.PCode = data.Shape.PCode;
  4507. update.ProfileBegin = data.Shape.ProfileBegin;
  4508. update.ProfileCurve = data.Shape.ProfileCurve;
  4509. update.ProfileEnd = data.Shape.ProfileEnd;
  4510. update.ProfileHollow = data.Shape.ProfileHollow;
  4511. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4512. update.TextColor = data.GetTextColor().GetBytes(false);
  4513. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4514. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4515. update.Scale = data.Shape.Scale;
  4516. update.Text = Util.StringToBytes256(data.Text);
  4517. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4518. #region PrimFlags
  4519. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4520. // Don't send the CreateSelected flag to everyone
  4521. flags &= ~PrimFlags.CreateSelected;
  4522. if (recipientID == data.OwnerID)
  4523. {
  4524. if (data.CreateSelected)
  4525. {
  4526. // Only send this flag once, then unset it
  4527. flags |= PrimFlags.CreateSelected;
  4528. data.CreateSelected = false;
  4529. }
  4530. }
  4531. // m_log.DebugFormat(
  4532. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4533. // data.Name, update.FullID, flags, update.ID);
  4534. update.UpdateFlags = (uint)flags;
  4535. #endregion PrimFlags
  4536. if (data.Sound != UUID.Zero)
  4537. {
  4538. update.Sound = data.Sound;
  4539. update.OwnerID = data.OwnerID;
  4540. update.Gain = (float)data.SoundGain;
  4541. update.Radius = (float)data.SoundRadius;
  4542. update.Flags = data.SoundFlags;
  4543. }
  4544. switch ((PCode)data.Shape.PCode)
  4545. {
  4546. case PCode.Grass:
  4547. case PCode.Tree:
  4548. case PCode.NewTree:
  4549. update.Data = new byte[] { data.Shape.State };
  4550. break;
  4551. default:
  4552. update.Data = Utils.EmptyBytes;
  4553. break;
  4554. }
  4555. return update;
  4556. }
  4557. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4558. {
  4559. // TODO: Implement this
  4560. return null;
  4561. }
  4562. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4563. {
  4564. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4565. // TODO: don't create new blocks if recycling an old packet
  4566. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4567. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4568. packet.UUIDNameBlock[0].ID = profileId;
  4569. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4570. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4571. OutPacket(packet, ThrottleOutPacketType.Task);
  4572. }
  4573. public ulong GetGroupPowers(UUID groupID)
  4574. {
  4575. if (groupID == m_activeGroupID)
  4576. return m_activeGroupPowers;
  4577. if (m_groupPowers.ContainsKey(groupID))
  4578. return m_groupPowers[groupID];
  4579. return 0;
  4580. }
  4581. #endregion
  4582. /// <summary>
  4583. /// This is a different way of processing packets then ProcessInPacket
  4584. /// </summary>
  4585. protected virtual void RegisterLocalPacketHandlers()
  4586. {
  4587. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4588. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4589. // for each AgentUpdate packet.
  4590. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4591. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4592. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4593. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4594. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4595. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4596. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4597. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4598. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4599. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4600. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4601. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4602. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4603. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4604. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4605. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4606. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4607. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4608. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4609. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4610. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4611. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4612. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4613. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4614. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4615. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4616. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4617. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4618. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4619. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4620. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4621. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4622. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4623. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4624. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4625. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4626. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4627. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4628. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4629. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4630. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4631. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4632. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4633. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4634. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4635. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4636. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4637. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4638. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4639. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4640. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4641. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4642. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4643. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4644. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4645. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4646. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4647. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4648. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4649. // some clients will send out a separate ObjectImage packet for each face
  4650. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4651. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4652. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4653. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4654. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4655. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4656. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4657. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4658. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4659. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4660. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4661. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4662. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4663. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4664. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4665. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4666. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4667. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4668. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4669. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4670. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4671. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4672. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4673. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4674. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4675. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4676. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4677. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4678. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4679. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4680. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4681. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4682. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4683. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4684. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4685. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4686. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4687. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4688. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4689. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4690. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4691. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4692. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4693. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4694. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4695. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4696. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4697. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4698. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4699. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4700. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4701. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4702. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4703. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4704. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4705. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4706. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4707. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4708. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4709. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4710. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4711. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4712. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4713. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4714. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4715. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4716. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4717. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4718. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4719. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4720. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4721. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4722. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4723. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4724. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4725. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4726. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4727. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4728. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4729. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4730. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4731. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4732. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4733. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4734. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4735. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4736. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4737. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4738. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4739. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4740. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4741. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4742. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4743. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4744. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4745. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4746. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4747. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4748. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4749. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4750. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4751. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4752. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4753. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4754. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4755. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4756. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4757. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4758. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4759. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4760. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4761. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4762. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4763. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4764. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4765. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4766. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4767. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4768. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4769. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4770. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4771. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4772. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4773. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4774. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4775. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4776. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4777. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4778. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4779. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4780. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4781. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4782. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4783. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4784. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4785. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4786. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4787. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4788. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4789. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4790. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4791. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4792. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4793. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4794. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4795. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4796. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4797. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4798. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4799. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4800. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4801. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4802. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4803. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4804. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4805. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4806. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4807. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4808. }
  4809. #region Packet Handlers
  4810. public int TotalAgentUpdates { get; set; }
  4811. #region Scene/Avatar
  4812. // Threshold for body rotation to be a significant agent update
  4813. private const float QDELTA = 0.000001f;
  4814. // Threshold for camera rotation to be a significant agent update
  4815. private const float VDELTA = 0.01f;
  4816. /// <summary>
  4817. /// This checks the update significance against the last update made.
  4818. /// </summary>
  4819. /// <remarks>Can only be called by one thread at a time</remarks>
  4820. /// <returns></returns>
  4821. /// <param name='x'></param>
  4822. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4823. {
  4824. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  4825. }
  4826. /// <summary>
  4827. /// This checks the movement/state update significance against the last update made.
  4828. /// </summary>
  4829. /// <remarks>Can only be called by one thread at a time</remarks>
  4830. /// <returns></returns>
  4831. /// <param name='x'></param>
  4832. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4833. {
  4834. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  4835. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  4836. bool movementSignificant =
  4837. (qdelta1 > QDELTA) // significant if body rotation above threshold
  4838. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  4839. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  4840. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  4841. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  4842. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  4843. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  4844. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  4845. ;
  4846. //if (movementSignificant)
  4847. //{
  4848. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  4849. // qdelta1, qdelta2);
  4850. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  4851. // x.ControlFlags, x.Flags, x.Far, x.State);
  4852. //}
  4853. return movementSignificant;
  4854. }
  4855. /// <summary>
  4856. /// This checks the camera update significance against the last update made.
  4857. /// </summary>
  4858. /// <remarks>Can only be called by one thread at a time</remarks>
  4859. /// <returns></returns>
  4860. /// <param name='x'></param>
  4861. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4862. {
  4863. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  4864. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  4865. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  4866. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  4867. bool cameraSignificant =
  4868. (vdelta1 > VDELTA) ||
  4869. (vdelta2 > VDELTA) ||
  4870. (vdelta3 > VDELTA) ||
  4871. (vdelta4 > VDELTA)
  4872. ;
  4873. //if (cameraSignificant)
  4874. //{
  4875. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  4876. // x.CameraAtAxis, x.CameraCenter);
  4877. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  4878. // x.CameraLeftAxis, x.CameraUpAxis);
  4879. //}
  4880. return cameraSignificant;
  4881. }
  4882. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4883. {
  4884. // We got here, which means that something in agent update was significant
  4885. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4886. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4887. if (x.AgentID != AgentId || x.SessionID != SessionId)
  4888. return false;
  4889. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  4890. // to see what exactly changed
  4891. bool movement = CheckAgentMovementUpdateSignificance(x);
  4892. bool camera = CheckAgentCameraUpdateSignificance(x);
  4893. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  4894. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4895. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4896. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4897. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4898. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4899. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4900. m_thisAgentUpdateArgs.Far = x.Far;
  4901. m_thisAgentUpdateArgs.Flags = x.Flags;
  4902. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4903. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  4904. m_thisAgentUpdateArgs.State = x.State;
  4905. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4906. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4907. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  4908. // Was there a significant movement/state change?
  4909. if (movement)
  4910. {
  4911. if (handlerPreAgentUpdate != null)
  4912. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  4913. if (handlerAgentUpdate != null)
  4914. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  4915. }
  4916. // Was there a significant camera(s) change?
  4917. if (camera)
  4918. if (handlerAgentCameraUpdate != null)
  4919. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  4920. handlerAgentUpdate = null;
  4921. handlerPreAgentUpdate = null;
  4922. handlerAgentCameraUpdate = null;
  4923. PacketPool.Instance.ReturnPacket(packet);
  4924. return true;
  4925. }
  4926. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4927. {
  4928. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4929. // validate the agent owns the agentID and sessionID
  4930. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4931. money.AgentData.SessionID == sender.SessionId)
  4932. {
  4933. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4934. if (handlerMoneyTransferRequest != null)
  4935. {
  4936. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4937. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4938. Util.FieldToString(money.MoneyData.Description));
  4939. }
  4940. return true;
  4941. }
  4942. return false;
  4943. }
  4944. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4945. {
  4946. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4947. (ParcelGodMarkAsContentPacket)Packet;
  4948. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4949. if (ParcelGodMarkAsContentHandler != null)
  4950. {
  4951. ParcelGodMarkAsContentHandler(this,
  4952. ParcelGodMarkAsContent.AgentData.AgentID,
  4953. ParcelGodMarkAsContent.ParcelData.LocalID);
  4954. return true;
  4955. }
  4956. return false;
  4957. }
  4958. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  4959. {
  4960. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  4961. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  4962. if (FreezeUserHandler != null)
  4963. {
  4964. FreezeUserHandler(this,
  4965. FreezeUser.AgentData.AgentID,
  4966. FreezeUser.Data.Flags,
  4967. FreezeUser.Data.TargetID);
  4968. return true;
  4969. }
  4970. return false;
  4971. }
  4972. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  4973. {
  4974. EjectUserPacket EjectUser =
  4975. (EjectUserPacket)Packet;
  4976. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  4977. if (EjectUserHandler != null)
  4978. {
  4979. EjectUserHandler(this,
  4980. EjectUser.AgentData.AgentID,
  4981. EjectUser.Data.Flags,
  4982. EjectUser.Data.TargetID);
  4983. return true;
  4984. }
  4985. return false;
  4986. }
  4987. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  4988. {
  4989. ParcelBuyPassPacket ParcelBuyPass =
  4990. (ParcelBuyPassPacket)Packet;
  4991. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  4992. if (ParcelBuyPassHandler != null)
  4993. {
  4994. ParcelBuyPassHandler(this,
  4995. ParcelBuyPass.AgentData.AgentID,
  4996. ParcelBuyPass.ParcelData.LocalID);
  4997. return true;
  4998. }
  4999. return false;
  5000. }
  5001. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5002. {
  5003. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5004. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5005. {
  5006. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5007. if (handlerParcelBuy != null)
  5008. {
  5009. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5010. parcel.Data.IsGroupOwned,
  5011. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5012. parcel.ParcelData.Price,
  5013. false);
  5014. }
  5015. return true;
  5016. }
  5017. return false;
  5018. }
  5019. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5020. {
  5021. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5022. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5023. {
  5024. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5025. if (handlerUUIDGroupNameRequest != null)
  5026. {
  5027. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5028. }
  5029. }
  5030. return true;
  5031. }
  5032. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5033. {
  5034. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5035. if (m_genericPacketHandlers.Count == 0) return false;
  5036. if (gmpack.AgentData.SessionID != SessionId) return false;
  5037. GenericMessage handlerGenericMessage = null;
  5038. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5039. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5040. {
  5041. List<string> msg = new List<string>();
  5042. List<byte[]> msgBytes = new List<byte[]>();
  5043. if (handlerGenericMessage != null)
  5044. {
  5045. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5046. {
  5047. msg.Add(Util.FieldToString(block.Parameter));
  5048. msgBytes.Add(block.Parameter);
  5049. }
  5050. try
  5051. {
  5052. if (OnBinaryGenericMessage != null)
  5053. {
  5054. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5055. }
  5056. handlerGenericMessage(sender, method, msg);
  5057. return true;
  5058. }
  5059. catch (Exception e)
  5060. {
  5061. m_log.ErrorFormat(
  5062. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5063. }
  5064. }
  5065. }
  5066. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5067. return false;
  5068. }
  5069. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5070. {
  5071. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5072. if (ogpack.AgentData.SessionID != SessionId) return false;
  5073. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5074. if (handlerObjectGroupRequest != null)
  5075. {
  5076. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5077. {
  5078. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5079. }
  5080. }
  5081. return true;
  5082. }
  5083. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5084. {
  5085. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5086. if (viewer.AgentData.SessionID != SessionId) return false;
  5087. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5088. if (handlerViewerEffect != null)
  5089. {
  5090. int length = viewer.Effect.Length;
  5091. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5092. for (int i = 0; i < length; i++)
  5093. {
  5094. //copy the effects block arguments into the event handler arg.
  5095. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5096. argument.AgentID = viewer.Effect[i].AgentID;
  5097. argument.Color = viewer.Effect[i].Color;
  5098. argument.Duration = viewer.Effect[i].Duration;
  5099. argument.ID = viewer.Effect[i].ID;
  5100. argument.Type = viewer.Effect[i].Type;
  5101. argument.TypeData = viewer.Effect[i].TypeData;
  5102. args.Add(argument);
  5103. }
  5104. handlerViewerEffect(sender, args);
  5105. }
  5106. return true;
  5107. }
  5108. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5109. {
  5110. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5111. #region Packet Session and User Check
  5112. if (m_checkPackets)
  5113. {
  5114. if (avatarProperties.AgentData.SessionID != SessionId ||
  5115. avatarProperties.AgentData.AgentID != AgentId)
  5116. return true;
  5117. }
  5118. #endregion
  5119. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5120. if (handlerRequestAvatarProperties != null)
  5121. {
  5122. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5123. }
  5124. return true;
  5125. }
  5126. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5127. {
  5128. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5129. #region Packet Session and User Check
  5130. if (m_checkPackets)
  5131. {
  5132. if (inchatpack.AgentData.SessionID != SessionId ||
  5133. inchatpack.AgentData.AgentID != AgentId)
  5134. return true;
  5135. }
  5136. #endregion
  5137. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5138. byte[] message = inchatpack.ChatData.Message;
  5139. byte type = inchatpack.ChatData.Type;
  5140. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5141. // UUID fromAgentID = AgentId;
  5142. int channel = inchatpack.ChatData.Channel;
  5143. if (OnChatFromClient != null)
  5144. {
  5145. OSChatMessage args = new OSChatMessage();
  5146. args.Channel = channel;
  5147. args.From = fromName;
  5148. args.Message = Utils.BytesToString(message);
  5149. args.Type = (ChatTypeEnum)type;
  5150. args.Position = fromPos;
  5151. args.Scene = Scene;
  5152. args.Sender = this;
  5153. args.SenderUUID = this.AgentId;
  5154. ChatMessage handlerChatFromClient = OnChatFromClient;
  5155. if (handlerChatFromClient != null)
  5156. handlerChatFromClient(this, args);
  5157. }
  5158. return true;
  5159. }
  5160. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5161. {
  5162. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5163. #region Packet Session and User Check
  5164. if (m_checkPackets)
  5165. {
  5166. if (avatarProps.AgentData.SessionID != SessionId ||
  5167. avatarProps.AgentData.AgentID != AgentId)
  5168. return true;
  5169. }
  5170. #endregion
  5171. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5172. if (handlerUpdateAvatarProperties != null)
  5173. {
  5174. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5175. UserProfileData UserProfile = new UserProfileData();
  5176. UserProfile.ID = AgentId;
  5177. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5178. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5179. UserProfile.FirstLifeImage = Properties.FLImageID;
  5180. UserProfile.Image = Properties.ImageID;
  5181. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5182. UserProfile.UserFlags &= ~3;
  5183. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5184. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5185. handlerUpdateAvatarProperties(this, UserProfile);
  5186. }
  5187. return true;
  5188. }
  5189. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5190. {
  5191. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5192. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5193. #region Packet Session and User Check
  5194. if (m_checkPackets)
  5195. {
  5196. if (rdialog.AgentData.SessionID != SessionId ||
  5197. rdialog.AgentData.AgentID != AgentId)
  5198. return true;
  5199. }
  5200. #endregion
  5201. int ch = rdialog.Data.ChatChannel;
  5202. byte[] msg = rdialog.Data.ButtonLabel;
  5203. if (OnChatFromClient != null)
  5204. {
  5205. OSChatMessage args = new OSChatMessage();
  5206. args.Channel = ch;
  5207. args.From = String.Empty;
  5208. args.Message = Utils.BytesToString(msg);
  5209. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5210. args.Position = new Vector3();
  5211. args.Scene = Scene;
  5212. args.Sender = this;
  5213. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5214. if (handlerChatFromClient2 != null)
  5215. handlerChatFromClient2(this, args);
  5216. }
  5217. return true;
  5218. }
  5219. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5220. {
  5221. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5222. #region Packet Session and User Check
  5223. if (m_checkPackets)
  5224. {
  5225. if (msgpack.AgentData.SessionID != SessionId ||
  5226. msgpack.AgentData.AgentID != AgentId)
  5227. return true;
  5228. }
  5229. #endregion
  5230. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5231. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5232. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5233. if (handlerInstantMessage != null)
  5234. {
  5235. GridInstantMessage im = new GridInstantMessage(Scene,
  5236. msgpack.AgentData.AgentID,
  5237. IMfromName,
  5238. msgpack.MessageBlock.ToAgentID,
  5239. msgpack.MessageBlock.Dialog,
  5240. msgpack.MessageBlock.FromGroup,
  5241. IMmessage,
  5242. msgpack.MessageBlock.ID,
  5243. msgpack.MessageBlock.Offline != 0 ? true : false,
  5244. msgpack.MessageBlock.Position,
  5245. msgpack.MessageBlock.BinaryBucket,
  5246. true);
  5247. handlerInstantMessage(this, im);
  5248. }
  5249. return true;
  5250. }
  5251. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5252. {
  5253. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5254. #region Packet Session and User Check
  5255. if (m_checkPackets)
  5256. {
  5257. if (afriendpack.AgentData.SessionID != SessionId ||
  5258. afriendpack.AgentData.AgentID != AgentId)
  5259. return true;
  5260. }
  5261. #endregion
  5262. // My guess is this is the folder to stick the calling card into
  5263. List<UUID> callingCardFolders = new List<UUID>();
  5264. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5265. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5266. {
  5267. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5268. }
  5269. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5270. if (handlerApproveFriendRequest != null)
  5271. {
  5272. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5273. }
  5274. return true;
  5275. }
  5276. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5277. {
  5278. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5279. #region Packet Session and User Check
  5280. if (m_checkPackets)
  5281. {
  5282. if (dfriendpack.AgentData.SessionID != SessionId ||
  5283. dfriendpack.AgentData.AgentID != AgentId)
  5284. return true;
  5285. }
  5286. #endregion
  5287. if (OnDenyFriendRequest != null)
  5288. {
  5289. OnDenyFriendRequest(this,
  5290. dfriendpack.TransactionBlock.TransactionID,
  5291. null);
  5292. }
  5293. return true;
  5294. }
  5295. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5296. {
  5297. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5298. #region Packet Session and User Check
  5299. if (m_checkPackets)
  5300. {
  5301. if (tfriendpack.AgentData.SessionID != SessionId ||
  5302. tfriendpack.AgentData.AgentID != AgentId)
  5303. return true;
  5304. }
  5305. #endregion
  5306. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5307. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5308. if (TerminateFriendshipHandler != null)
  5309. {
  5310. TerminateFriendshipHandler(this, exFriendID);
  5311. return true;
  5312. }
  5313. return false;
  5314. }
  5315. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5316. {
  5317. FindAgentPacket FindAgent =
  5318. (FindAgentPacket)Packet;
  5319. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5320. if (FindAgentHandler != null)
  5321. {
  5322. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5323. return true;
  5324. }
  5325. return false;
  5326. }
  5327. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5328. {
  5329. TrackAgentPacket TrackAgent =
  5330. (TrackAgentPacket)Packet;
  5331. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5332. if (TrackAgentHandler != null)
  5333. {
  5334. TrackAgentHandler(this,
  5335. TrackAgent.AgentData.AgentID,
  5336. TrackAgent.TargetData.PreyID);
  5337. return true;
  5338. }
  5339. return false;
  5340. }
  5341. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5342. {
  5343. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5344. #region Packet Session and User Check
  5345. if (m_checkPackets)
  5346. {
  5347. if (rezPacket.AgentData.SessionID != SessionId ||
  5348. rezPacket.AgentData.AgentID != AgentId)
  5349. return true;
  5350. }
  5351. #endregion
  5352. RezObject handlerRezObject = OnRezObject;
  5353. if (handlerRezObject != null)
  5354. {
  5355. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5356. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5357. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5358. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5359. rezPacket.RezData.FromTaskID);
  5360. }
  5361. return true;
  5362. }
  5363. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5364. {
  5365. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5366. #region Packet Session and User Check
  5367. if (m_checkPackets)
  5368. {
  5369. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5370. DeRezPacket.AgentData.AgentID != AgentId)
  5371. return true;
  5372. }
  5373. #endregion
  5374. DeRezObject handlerDeRezObject = OnDeRezObject;
  5375. if (handlerDeRezObject != null)
  5376. {
  5377. List<uint> deRezIDs = new List<uint>();
  5378. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5379. DeRezPacket.ObjectData)
  5380. {
  5381. deRezIDs.Add(data.ObjectLocalID);
  5382. }
  5383. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5384. // values given by a Second Life client
  5385. handlerDeRezObject(this, deRezIDs,
  5386. DeRezPacket.AgentBlock.GroupID,
  5387. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5388. DeRezPacket.AgentBlock.DestinationID);
  5389. }
  5390. return true;
  5391. }
  5392. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5393. {
  5394. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5395. #region Packet Session and User Check
  5396. if (m_checkPackets)
  5397. {
  5398. if (modify.AgentData.SessionID != SessionId ||
  5399. modify.AgentData.AgentID != AgentId)
  5400. return true;
  5401. }
  5402. #endregion
  5403. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5404. if (modify.ParcelData.Length > 0)
  5405. {
  5406. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5407. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5408. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5409. if (OnModifyTerrain != null)
  5410. {
  5411. for (int i = 0; i < modify.ParcelData.Length; i++)
  5412. {
  5413. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5414. if (handlerModifyTerrain != null)
  5415. {
  5416. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5417. modify.ModifyBlock.BrushSize,
  5418. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5419. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5420. modify.ParcelData[i].East, AgentId);
  5421. }
  5422. }
  5423. }
  5424. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5425. }
  5426. return true;
  5427. }
  5428. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5429. {
  5430. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5431. if (handlerRegionHandShakeReply != null)
  5432. {
  5433. handlerRegionHandShakeReply(this);
  5434. }
  5435. return true;
  5436. }
  5437. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5438. {
  5439. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5440. if (handlerRequestWearables != null)
  5441. {
  5442. handlerRequestWearables(sender);
  5443. }
  5444. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5445. if (handlerRequestAvatarsData != null)
  5446. {
  5447. handlerRequestAvatarsData(this);
  5448. }
  5449. return true;
  5450. }
  5451. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5452. {
  5453. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5454. #region Packet Session and User Check
  5455. if (m_checkPackets)
  5456. {
  5457. if (appear.AgentData.SessionID != SessionId ||
  5458. appear.AgentData.AgentID != AgentId)
  5459. return true;
  5460. }
  5461. #endregion
  5462. SetAppearance handlerSetAppearance = OnSetAppearance;
  5463. if (handlerSetAppearance != null)
  5464. {
  5465. // Temporarily protect ourselves from the mantis #951 failure.
  5466. // However, we could do this for several other handlers where a failure isn't terminal
  5467. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5468. try
  5469. {
  5470. byte[] visualparams = new byte[appear.VisualParam.Length];
  5471. for (int i = 0; i < appear.VisualParam.Length; i++)
  5472. visualparams[i] = appear.VisualParam[i].ParamValue;
  5473. Primitive.TextureEntry te = null;
  5474. if (appear.ObjectData.TextureEntry.Length > 1)
  5475. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5476. List<CachedTextureRequestArg> hashes = new List<CachedTextureRequestArg>();
  5477. for (int i = 0; i < appear.WearableData.Length; i++)
  5478. {
  5479. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  5480. arg.BakedTextureIndex = appear.WearableData[i].TextureIndex;
  5481. arg.WearableHashID = appear.WearableData[i].CacheID;
  5482. hashes.Add(arg);
  5483. }
  5484. handlerSetAppearance(sender, te, visualparams, hashes);
  5485. }
  5486. catch (Exception e)
  5487. {
  5488. m_log.ErrorFormat(
  5489. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5490. e);
  5491. }
  5492. }
  5493. return true;
  5494. }
  5495. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5496. {
  5497. if (OnAvatarNowWearing != null)
  5498. {
  5499. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5500. #region Packet Session and User Check
  5501. if (m_checkPackets)
  5502. {
  5503. if (nowWearing.AgentData.SessionID != SessionId ||
  5504. nowWearing.AgentData.AgentID != AgentId)
  5505. return true;
  5506. }
  5507. #endregion
  5508. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5509. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5510. {
  5511. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5512. AvatarWearingArgs.Wearable wearable =
  5513. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5514. nowWearing.WearableData[i].WearableType);
  5515. wearingArgs.NowWearing.Add(wearable);
  5516. }
  5517. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5518. if (handlerAvatarNowWearing != null)
  5519. {
  5520. handlerAvatarNowWearing(this, wearingArgs);
  5521. }
  5522. }
  5523. return true;
  5524. }
  5525. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5526. {
  5527. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5528. if (handlerRezSingleAttachment != null)
  5529. {
  5530. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5531. #region Packet Session and User Check
  5532. if (m_checkPackets)
  5533. {
  5534. if (rez.AgentData.SessionID != SessionId ||
  5535. rez.AgentData.AgentID != AgentId)
  5536. return true;
  5537. }
  5538. #endregion
  5539. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5540. rez.ObjectData.AttachmentPt);
  5541. }
  5542. return true;
  5543. }
  5544. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5545. {
  5546. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5547. if (handlerRezMultipleAttachments != null)
  5548. {
  5549. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5550. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5551. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5552. handlerRezMultipleAttachments(this, rezlist);
  5553. }
  5554. return true;
  5555. }
  5556. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5557. {
  5558. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5559. if (handlerDetachAttachmentIntoInv != null)
  5560. {
  5561. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5562. #region Packet Session and User Check
  5563. // UNSUPPORTED ON THIS PACKET
  5564. #endregion
  5565. UUID itemID = detachtoInv.ObjectData.ItemID;
  5566. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5567. handlerDetachAttachmentIntoInv(itemID, this);
  5568. }
  5569. return true;
  5570. }
  5571. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5572. {
  5573. if (OnObjectAttach != null)
  5574. {
  5575. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5576. #region Packet Session and User Check
  5577. if (m_checkPackets)
  5578. {
  5579. if (att.AgentData.SessionID != SessionId ||
  5580. att.AgentData.AgentID != AgentId)
  5581. return true;
  5582. }
  5583. #endregion
  5584. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5585. if (handlerObjectAttach != null)
  5586. {
  5587. if (att.ObjectData.Length > 0)
  5588. {
  5589. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5590. }
  5591. }
  5592. }
  5593. return true;
  5594. }
  5595. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5596. {
  5597. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5598. #region Packet Session and User Check
  5599. if (m_checkPackets)
  5600. {
  5601. if (dett.AgentData.SessionID != SessionId ||
  5602. dett.AgentData.AgentID != AgentId)
  5603. return true;
  5604. }
  5605. #endregion
  5606. for (int j = 0; j < dett.ObjectData.Length; j++)
  5607. {
  5608. uint obj = dett.ObjectData[j].ObjectLocalID;
  5609. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5610. if (handlerObjectDetach != null)
  5611. {
  5612. handlerObjectDetach(obj, this);
  5613. }
  5614. }
  5615. return true;
  5616. }
  5617. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5618. {
  5619. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5620. #region Packet Session and User Check
  5621. if (m_checkPackets)
  5622. {
  5623. if (dropp.AgentData.SessionID != SessionId ||
  5624. dropp.AgentData.AgentID != AgentId)
  5625. return true;
  5626. }
  5627. #endregion
  5628. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5629. {
  5630. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5631. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5632. if (handlerObjectDrop != null)
  5633. {
  5634. handlerObjectDrop(obj, this);
  5635. }
  5636. }
  5637. return true;
  5638. }
  5639. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5640. {
  5641. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5642. #region Packet Session and User Check
  5643. if (m_checkPackets)
  5644. {
  5645. if (run.AgentData.SessionID != SessionId ||
  5646. run.AgentData.AgentID != AgentId)
  5647. return true;
  5648. }
  5649. #endregion
  5650. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5651. if (handlerSetAlwaysRun != null)
  5652. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5653. return true;
  5654. }
  5655. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5656. {
  5657. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5658. if (handlerCompleteMovementToRegion != null)
  5659. {
  5660. handlerCompleteMovementToRegion(sender, true);
  5661. }
  5662. handlerCompleteMovementToRegion = null;
  5663. return true;
  5664. }
  5665. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5666. {
  5667. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5668. #region Packet Session and User Check
  5669. if (m_checkPackets)
  5670. {
  5671. if (AgentAni.AgentData.SessionID != SessionId ||
  5672. AgentAni.AgentData.AgentID != AgentId)
  5673. return true;
  5674. }
  5675. #endregion
  5676. StartAnim handlerStartAnim = null;
  5677. StopAnim handlerStopAnim = null;
  5678. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5679. {
  5680. if (AgentAni.AnimationList[i].StartAnim)
  5681. {
  5682. handlerStartAnim = OnStartAnim;
  5683. if (handlerStartAnim != null)
  5684. {
  5685. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5686. }
  5687. }
  5688. else
  5689. {
  5690. handlerStopAnim = OnStopAnim;
  5691. if (handlerStopAnim != null)
  5692. {
  5693. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5694. }
  5695. }
  5696. }
  5697. return true;
  5698. }
  5699. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5700. {
  5701. if (OnAgentRequestSit != null)
  5702. {
  5703. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5704. #region Packet Session and User Check
  5705. if (m_checkPackets)
  5706. {
  5707. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5708. agentRequestSit.AgentData.AgentID != AgentId)
  5709. return true;
  5710. }
  5711. #endregion
  5712. if (SceneAgent.IsChildAgent)
  5713. {
  5714. SendCantSitBecauseChildAgentResponse();
  5715. return true;
  5716. }
  5717. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5718. if (handlerAgentRequestSit != null)
  5719. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5720. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5721. }
  5722. return true;
  5723. }
  5724. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5725. {
  5726. if (OnAgentSit != null)
  5727. {
  5728. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5729. #region Packet Session and User Check
  5730. if (m_checkPackets)
  5731. {
  5732. if (agentSit.AgentData.SessionID != SessionId ||
  5733. agentSit.AgentData.AgentID != AgentId)
  5734. return true;
  5735. }
  5736. #endregion
  5737. if (SceneAgent.IsChildAgent)
  5738. {
  5739. SendCantSitBecauseChildAgentResponse();
  5740. return true;
  5741. }
  5742. AgentSit handlerAgentSit = OnAgentSit;
  5743. if (handlerAgentSit != null)
  5744. {
  5745. OnAgentSit(this, agentSit.AgentData.AgentID);
  5746. }
  5747. }
  5748. return true;
  5749. }
  5750. /// <summary>
  5751. /// Used when a child agent gets a sit response which should not be fulfilled.
  5752. /// </summary>
  5753. private void SendCantSitBecauseChildAgentResponse()
  5754. {
  5755. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5756. }
  5757. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5758. {
  5759. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5760. #region Packet Session and User Check
  5761. if (m_checkPackets)
  5762. {
  5763. // UNSUPPORTED ON THIS PACKET
  5764. }
  5765. #endregion
  5766. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5767. if (handlerSoundTrigger != null)
  5768. {
  5769. // UUIDS are sent as zeroes by the client, substitute agent's id
  5770. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5771. AgentId, AgentId,
  5772. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5773. soundTriggerPacket.SoundData.Handle, 0);
  5774. }
  5775. return true;
  5776. }
  5777. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5778. {
  5779. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5780. #region Packet Session and User Check
  5781. if (m_checkPackets)
  5782. {
  5783. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5784. avRequestQuery.AgentData.AgentID != AgentId)
  5785. return true;
  5786. }
  5787. #endregion
  5788. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5789. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5790. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5791. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5792. if (handlerAvatarPickerRequest != null)
  5793. {
  5794. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5795. Utils.BytesToString(querydata.Name));
  5796. }
  5797. return true;
  5798. }
  5799. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5800. {
  5801. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5802. #region Packet Session and User Check
  5803. if (m_checkPackets)
  5804. {
  5805. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5806. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5807. return true;
  5808. }
  5809. #endregion
  5810. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5811. if (handlerAgentDataUpdateRequest != null)
  5812. {
  5813. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5814. }
  5815. return true;
  5816. }
  5817. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5818. {
  5819. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5820. if (handlerUserInfoRequest != null)
  5821. {
  5822. handlerUserInfoRequest(this);
  5823. }
  5824. else
  5825. {
  5826. SendUserInfoReply(false, true, "");
  5827. }
  5828. return true;
  5829. }
  5830. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5831. {
  5832. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5833. #region Packet Session and User Check
  5834. if (m_checkPackets)
  5835. {
  5836. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5837. updateUserInfo.AgentData.AgentID != AgentId)
  5838. return true;
  5839. }
  5840. #endregion
  5841. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5842. if (handlerUpdateUserInfo != null)
  5843. {
  5844. bool visible = true;
  5845. string DirectoryVisibility =
  5846. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5847. if (DirectoryVisibility == "hidden")
  5848. visible = false;
  5849. handlerUpdateUserInfo(
  5850. updateUserInfo.UserData.IMViaEMail,
  5851. visible, this);
  5852. }
  5853. return true;
  5854. }
  5855. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5856. {
  5857. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5858. #region Packet Session and User Check
  5859. if (m_checkPackets)
  5860. {
  5861. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5862. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5863. return true;
  5864. }
  5865. #endregion
  5866. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5867. {
  5868. // Linden Client limitation..
  5869. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5870. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5871. {
  5872. ScenePresence avatar = null;
  5873. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5874. {
  5875. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5876. {
  5877. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5878. }
  5879. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5880. {
  5881. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5882. }
  5883. }
  5884. }
  5885. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5886. if (handlerSetStartLocationRequest != null)
  5887. {
  5888. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5889. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5890. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5891. }
  5892. }
  5893. return true;
  5894. }
  5895. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5896. {
  5897. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5898. #region Packet Session and User Check
  5899. if (m_checkPackets)
  5900. {
  5901. if (atpack.AgentData.SessionID != SessionId ||
  5902. atpack.AgentData.AgentID != AgentId)
  5903. return true;
  5904. }
  5905. #endregion
  5906. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5907. return true;
  5908. }
  5909. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5910. {
  5911. m_udpClient.IsPaused = true;
  5912. return true;
  5913. }
  5914. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5915. {
  5916. m_udpClient.IsPaused = false;
  5917. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5918. return true;
  5919. }
  5920. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5921. {
  5922. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5923. if (handlerForceReleaseControls != null)
  5924. {
  5925. handlerForceReleaseControls(this, AgentId);
  5926. }
  5927. return true;
  5928. }
  5929. #endregion Scene/Avatar
  5930. #region Objects/m_sceneObjects
  5931. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5932. {
  5933. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5934. #region Packet Session and User Check
  5935. if (m_checkPackets)
  5936. {
  5937. if (link.AgentData.SessionID != SessionId ||
  5938. link.AgentData.AgentID != AgentId)
  5939. return true;
  5940. }
  5941. #endregion
  5942. uint parentprimid = 0;
  5943. List<uint> childrenprims = new List<uint>();
  5944. if (link.ObjectData.Length > 1)
  5945. {
  5946. parentprimid = link.ObjectData[0].ObjectLocalID;
  5947. for (int i = 1; i < link.ObjectData.Length; i++)
  5948. {
  5949. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5950. }
  5951. }
  5952. LinkObjects handlerLinkObjects = OnLinkObjects;
  5953. if (handlerLinkObjects != null)
  5954. {
  5955. handlerLinkObjects(this, parentprimid, childrenprims);
  5956. }
  5957. return true;
  5958. }
  5959. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  5960. {
  5961. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  5962. #region Packet Session and User Check
  5963. if (m_checkPackets)
  5964. {
  5965. if (delink.AgentData.SessionID != SessionId ||
  5966. delink.AgentData.AgentID != AgentId)
  5967. return true;
  5968. }
  5969. #endregion
  5970. // It appears the prim at index 0 is not always the root prim (for
  5971. // instance, when one prim of a link set has been edited independently
  5972. // of the others). Therefore, we'll pass all the ids onto the delink
  5973. // method for it to decide which is the root.
  5974. List<uint> prims = new List<uint>();
  5975. for (int i = 0; i < delink.ObjectData.Length; i++)
  5976. {
  5977. prims.Add(delink.ObjectData[i].ObjectLocalID);
  5978. }
  5979. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  5980. if (handlerDelinkObjects != null)
  5981. {
  5982. handlerDelinkObjects(prims, this);
  5983. }
  5984. return true;
  5985. }
  5986. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  5987. {
  5988. if (OnAddPrim != null)
  5989. {
  5990. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  5991. #region Packet Session and User Check
  5992. if (m_checkPackets)
  5993. {
  5994. if (addPacket.AgentData.SessionID != SessionId ||
  5995. addPacket.AgentData.AgentID != AgentId)
  5996. return true;
  5997. }
  5998. #endregion
  5999. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6000. // m_log.Info("[REZData]: " + addPacket.ToString());
  6001. //BypassRaycast: 1
  6002. //RayStart: <69.79469, 158.2652, 98.40343>
  6003. //RayEnd: <61.97724, 141.995, 92.58341>
  6004. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6005. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6006. //object from rezing initially
  6007. AddNewPrim handlerAddPrim = OnAddPrim;
  6008. if (handlerAddPrim != null)
  6009. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6010. }
  6011. return true;
  6012. }
  6013. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6014. {
  6015. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6016. #region Packet Session and User Check
  6017. if (m_checkPackets)
  6018. {
  6019. if (shapePacket.AgentData.SessionID != SessionId ||
  6020. shapePacket.AgentData.AgentID != AgentId)
  6021. return true;
  6022. }
  6023. #endregion
  6024. UpdateShape handlerUpdatePrimShape = null;
  6025. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6026. {
  6027. handlerUpdatePrimShape = OnUpdatePrimShape;
  6028. if (handlerUpdatePrimShape != null)
  6029. {
  6030. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6031. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6032. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6033. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6034. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6035. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6036. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6037. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6038. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6039. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6040. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6041. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6042. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6043. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6044. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6045. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6046. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6047. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6048. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6049. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6050. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6051. shapeData);
  6052. }
  6053. }
  6054. return true;
  6055. }
  6056. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6057. {
  6058. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6059. #region Packet Session and User Check
  6060. if (m_checkPackets)
  6061. {
  6062. if (extraPar.AgentData.SessionID != SessionId ||
  6063. extraPar.AgentData.AgentID != AgentId)
  6064. return true;
  6065. }
  6066. #endregion
  6067. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6068. if (handlerUpdateExtraParams != null)
  6069. {
  6070. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6071. {
  6072. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6073. extraPar.ObjectData[i].ParamType,
  6074. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6075. }
  6076. }
  6077. return true;
  6078. }
  6079. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6080. {
  6081. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6082. #region Packet Session and User Check
  6083. if (m_checkPackets)
  6084. {
  6085. if (dupe.AgentData.SessionID != SessionId ||
  6086. dupe.AgentData.AgentID != AgentId)
  6087. return true;
  6088. }
  6089. #endregion
  6090. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6091. ObjectDuplicate handlerObjectDuplicate = null;
  6092. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6093. {
  6094. handlerObjectDuplicate = OnObjectDuplicate;
  6095. if (handlerObjectDuplicate != null)
  6096. {
  6097. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6098. dupe.SharedData.DuplicateFlags, AgentId,
  6099. m_activeGroupID);
  6100. }
  6101. }
  6102. return true;
  6103. }
  6104. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6105. {
  6106. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6107. #region Packet Session and User Check
  6108. if (m_checkPackets)
  6109. {
  6110. if (incomingRequest.AgentData.SessionID != SessionId ||
  6111. incomingRequest.AgentData.AgentID != AgentId)
  6112. return true;
  6113. }
  6114. #endregion
  6115. ObjectRequest handlerObjectRequest = null;
  6116. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6117. {
  6118. handlerObjectRequest = OnObjectRequest;
  6119. if (handlerObjectRequest != null)
  6120. {
  6121. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6122. }
  6123. }
  6124. return true;
  6125. }
  6126. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6127. {
  6128. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6129. #region Packet Session and User Check
  6130. if (m_checkPackets)
  6131. {
  6132. if (incomingselect.AgentData.SessionID != SessionId ||
  6133. incomingselect.AgentData.AgentID != AgentId)
  6134. return true;
  6135. }
  6136. #endregion
  6137. ObjectSelect handlerObjectSelect = null;
  6138. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6139. {
  6140. handlerObjectSelect = OnObjectSelect;
  6141. if (handlerObjectSelect != null)
  6142. {
  6143. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6144. }
  6145. }
  6146. return true;
  6147. }
  6148. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6149. {
  6150. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6151. #region Packet Session and User Check
  6152. if (m_checkPackets)
  6153. {
  6154. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6155. incomingdeselect.AgentData.AgentID != AgentId)
  6156. return true;
  6157. }
  6158. #endregion
  6159. ObjectDeselect handlerObjectDeselect = null;
  6160. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6161. {
  6162. handlerObjectDeselect = OnObjectDeselect;
  6163. if (handlerObjectDeselect != null)
  6164. {
  6165. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6166. }
  6167. }
  6168. return true;
  6169. }
  6170. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6171. {
  6172. // DEPRECATED: but till libsecondlife removes it, people will use it
  6173. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6174. #region Packet Session and User Check
  6175. if (m_checkPackets)
  6176. {
  6177. if (position.AgentData.SessionID != SessionId ||
  6178. position.AgentData.AgentID != AgentId)
  6179. return true;
  6180. }
  6181. #endregion
  6182. for (int i = 0; i < position.ObjectData.Length; i++)
  6183. {
  6184. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6185. if (handlerUpdateVector != null)
  6186. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6187. }
  6188. return true;
  6189. }
  6190. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6191. {
  6192. // DEPRECATED: but till libsecondlife removes it, people will use it
  6193. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6194. #region Packet Session and User Check
  6195. if (m_checkPackets)
  6196. {
  6197. if (scale.AgentData.SessionID != SessionId ||
  6198. scale.AgentData.AgentID != AgentId)
  6199. return true;
  6200. }
  6201. #endregion
  6202. for (int i = 0; i < scale.ObjectData.Length; i++)
  6203. {
  6204. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6205. if (handlerUpdatePrimGroupScale != null)
  6206. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6207. }
  6208. return true;
  6209. }
  6210. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6211. {
  6212. // DEPRECATED: but till libsecondlife removes it, people will use it
  6213. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6214. #region Packet Session and User Check
  6215. if (m_checkPackets)
  6216. {
  6217. if (rotation.AgentData.SessionID != SessionId ||
  6218. rotation.AgentData.AgentID != AgentId)
  6219. return true;
  6220. }
  6221. #endregion
  6222. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6223. {
  6224. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6225. if (handlerUpdatePrimRotation != null)
  6226. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6227. }
  6228. return true;
  6229. }
  6230. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6231. {
  6232. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6233. #region Packet Session and User Check
  6234. if (m_checkPackets)
  6235. {
  6236. if (flags.AgentData.SessionID != SessionId ||
  6237. flags.AgentData.AgentID != AgentId)
  6238. return true;
  6239. }
  6240. #endregion
  6241. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6242. if (handlerUpdatePrimFlags != null)
  6243. {
  6244. // byte[] data = Pack.ToBytes();
  6245. // 46,47,48 are special positions within the packet
  6246. // This may change so perhaps we need a better way
  6247. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6248. /*
  6249. bool UsePhysics = (data[46] != 0) ? true : false;
  6250. bool IsTemporary = (data[47] != 0) ? true : false;
  6251. bool IsPhantom = (data[48] != 0) ? true : false;
  6252. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6253. */
  6254. bool UsePhysics = flags.AgentData.UsePhysics;
  6255. bool IsPhantom = flags.AgentData.IsPhantom;
  6256. bool IsTemporary = flags.AgentData.IsTemporary;
  6257. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6258. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6259. if (blocks == null || blocks.Length == 0)
  6260. {
  6261. physdata.PhysShapeType = PhysShapeType.invalid;
  6262. }
  6263. else
  6264. {
  6265. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6266. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6267. physdata.Bounce = phsblock.Restitution;
  6268. physdata.Density = phsblock.Density;
  6269. physdata.Friction = phsblock.Friction;
  6270. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6271. }
  6272. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6273. }
  6274. return true;
  6275. }
  6276. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6277. {
  6278. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6279. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6280. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6281. {
  6282. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6283. if (handlerUpdatePrimTexture != null)
  6284. {
  6285. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6286. imagePack.ObjectData[i].TextureEntry, this);
  6287. }
  6288. }
  6289. return true;
  6290. }
  6291. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6292. {
  6293. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6294. #region Packet Session and User Check
  6295. if (m_checkPackets)
  6296. {
  6297. if (grab.AgentData.SessionID != SessionId ||
  6298. grab.AgentData.AgentID != AgentId)
  6299. return true;
  6300. }
  6301. #endregion
  6302. GrabObject handlerGrabObject = OnGrabObject;
  6303. if (handlerGrabObject != null)
  6304. {
  6305. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6306. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6307. {
  6308. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6309. {
  6310. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6311. arg.Binormal = surfaceInfo.Binormal;
  6312. arg.FaceIndex = surfaceInfo.FaceIndex;
  6313. arg.Normal = surfaceInfo.Normal;
  6314. arg.Position = surfaceInfo.Position;
  6315. arg.STCoord = surfaceInfo.STCoord;
  6316. arg.UVCoord = surfaceInfo.UVCoord;
  6317. touchArgs.Add(arg);
  6318. }
  6319. }
  6320. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6321. }
  6322. return true;
  6323. }
  6324. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6325. {
  6326. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6327. #region Packet Session and User Check
  6328. if (m_checkPackets)
  6329. {
  6330. if (grabUpdate.AgentData.SessionID != SessionId ||
  6331. grabUpdate.AgentData.AgentID != AgentId)
  6332. return true;
  6333. }
  6334. #endregion
  6335. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6336. if (handlerGrabUpdate != null)
  6337. {
  6338. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6339. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6340. {
  6341. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6342. {
  6343. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6344. arg.Binormal = surfaceInfo.Binormal;
  6345. arg.FaceIndex = surfaceInfo.FaceIndex;
  6346. arg.Normal = surfaceInfo.Normal;
  6347. arg.Position = surfaceInfo.Position;
  6348. arg.STCoord = surfaceInfo.STCoord;
  6349. arg.UVCoord = surfaceInfo.UVCoord;
  6350. touchArgs.Add(arg);
  6351. }
  6352. }
  6353. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6354. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6355. }
  6356. return true;
  6357. }
  6358. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6359. {
  6360. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6361. #region Packet Session and User Check
  6362. if (m_checkPackets)
  6363. {
  6364. if (deGrab.AgentData.SessionID != SessionId ||
  6365. deGrab.AgentData.AgentID != AgentId)
  6366. return true;
  6367. }
  6368. #endregion
  6369. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6370. if (handlerDeGrabObject != null)
  6371. {
  6372. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6373. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6374. {
  6375. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6376. {
  6377. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6378. arg.Binormal = surfaceInfo.Binormal;
  6379. arg.FaceIndex = surfaceInfo.FaceIndex;
  6380. arg.Normal = surfaceInfo.Normal;
  6381. arg.Position = surfaceInfo.Position;
  6382. arg.STCoord = surfaceInfo.STCoord;
  6383. arg.UVCoord = surfaceInfo.UVCoord;
  6384. touchArgs.Add(arg);
  6385. }
  6386. }
  6387. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6388. }
  6389. return true;
  6390. }
  6391. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6392. {
  6393. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6394. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6395. #region Packet Session and User Check
  6396. if (m_checkPackets)
  6397. {
  6398. if (spinStart.AgentData.SessionID != SessionId ||
  6399. spinStart.AgentData.AgentID != AgentId)
  6400. return true;
  6401. }
  6402. #endregion
  6403. SpinStart handlerSpinStart = OnSpinStart;
  6404. if (handlerSpinStart != null)
  6405. {
  6406. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6407. }
  6408. return true;
  6409. }
  6410. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6411. {
  6412. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6413. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6414. #region Packet Session and User Check
  6415. if (m_checkPackets)
  6416. {
  6417. if (spinUpdate.AgentData.SessionID != SessionId ||
  6418. spinUpdate.AgentData.AgentID != AgentId)
  6419. return true;
  6420. }
  6421. #endregion
  6422. Vector3 axis;
  6423. float angle;
  6424. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6425. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6426. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6427. if (handlerSpinUpdate != null)
  6428. {
  6429. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6430. }
  6431. return true;
  6432. }
  6433. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6434. {
  6435. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6436. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6437. #region Packet Session and User Check
  6438. if (m_checkPackets)
  6439. {
  6440. if (spinStop.AgentData.SessionID != SessionId ||
  6441. spinStop.AgentData.AgentID != AgentId)
  6442. return true;
  6443. }
  6444. #endregion
  6445. SpinStop handlerSpinStop = OnSpinStop;
  6446. if (handlerSpinStop != null)
  6447. {
  6448. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6449. }
  6450. return true;
  6451. }
  6452. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6453. {
  6454. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6455. #region Packet Session and User Check
  6456. if (m_checkPackets)
  6457. {
  6458. if (objDes.AgentData.SessionID != SessionId ||
  6459. objDes.AgentData.AgentID != AgentId)
  6460. return true;
  6461. }
  6462. #endregion
  6463. GenericCall7 handlerObjectDescription = null;
  6464. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6465. {
  6466. handlerObjectDescription = OnObjectDescription;
  6467. if (handlerObjectDescription != null)
  6468. {
  6469. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6470. Util.FieldToString(objDes.ObjectData[i].Description));
  6471. }
  6472. }
  6473. return true;
  6474. }
  6475. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6476. {
  6477. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6478. #region Packet Session and User Check
  6479. if (m_checkPackets)
  6480. {
  6481. if (objName.AgentData.SessionID != SessionId ||
  6482. objName.AgentData.AgentID != AgentId)
  6483. return true;
  6484. }
  6485. #endregion
  6486. GenericCall7 handlerObjectName = null;
  6487. for (int i = 0; i < objName.ObjectData.Length; i++)
  6488. {
  6489. handlerObjectName = OnObjectName;
  6490. if (handlerObjectName != null)
  6491. {
  6492. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6493. Util.FieldToString(objName.ObjectData[i].Name));
  6494. }
  6495. }
  6496. return true;
  6497. }
  6498. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6499. {
  6500. if (OnObjectPermissions != null)
  6501. {
  6502. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6503. #region Packet Session and User Check
  6504. if (m_checkPackets)
  6505. {
  6506. if (newobjPerms.AgentData.SessionID != SessionId ||
  6507. newobjPerms.AgentData.AgentID != AgentId)
  6508. return true;
  6509. }
  6510. #endregion
  6511. UUID AgentID = newobjPerms.AgentData.AgentID;
  6512. UUID SessionID = newobjPerms.AgentData.SessionID;
  6513. ObjectPermissions handlerObjectPermissions = null;
  6514. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6515. {
  6516. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6517. byte field = permChanges.Field;
  6518. uint localID = permChanges.ObjectLocalID;
  6519. uint mask = permChanges.Mask;
  6520. byte set = permChanges.Set;
  6521. handlerObjectPermissions = OnObjectPermissions;
  6522. if (handlerObjectPermissions != null)
  6523. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6524. }
  6525. }
  6526. // Here's our data,
  6527. // PermField contains the field the info goes into
  6528. // PermField determines which mask we're changing
  6529. //
  6530. // chmask is the mask of the change
  6531. // setTF is whether we're adding it or taking it away
  6532. //
  6533. // objLocalID is the localID of the object.
  6534. // Unfortunately, we have to pass the event the packet because objData is an array
  6535. // That means multiple object perms may be updated in a single packet.
  6536. return true;
  6537. }
  6538. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6539. {
  6540. UndoPacket undoitem = (UndoPacket)Pack;
  6541. #region Packet Session and User Check
  6542. if (m_checkPackets)
  6543. {
  6544. if (undoitem.AgentData.SessionID != SessionId ||
  6545. undoitem.AgentData.AgentID != AgentId)
  6546. return true;
  6547. }
  6548. #endregion
  6549. if (undoitem.ObjectData.Length > 0)
  6550. {
  6551. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6552. {
  6553. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6554. AgentSit handlerOnUndo = OnUndo;
  6555. if (handlerOnUndo != null)
  6556. {
  6557. handlerOnUndo(this, objiD);
  6558. }
  6559. }
  6560. }
  6561. return true;
  6562. }
  6563. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6564. {
  6565. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6566. #region Packet Session and User Check
  6567. if (m_checkPackets)
  6568. {
  6569. if (undolanditem.AgentData.SessionID != SessionId ||
  6570. undolanditem.AgentData.AgentID != AgentId)
  6571. return true;
  6572. }
  6573. #endregion
  6574. LandUndo handlerOnUndo = OnLandUndo;
  6575. if (handlerOnUndo != null)
  6576. {
  6577. handlerOnUndo(this);
  6578. }
  6579. return true;
  6580. }
  6581. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6582. {
  6583. RedoPacket redoitem = (RedoPacket)Pack;
  6584. #region Packet Session and User Check
  6585. if (m_checkPackets)
  6586. {
  6587. if (redoitem.AgentData.SessionID != SessionId ||
  6588. redoitem.AgentData.AgentID != AgentId)
  6589. return true;
  6590. }
  6591. #endregion
  6592. if (redoitem.ObjectData.Length > 0)
  6593. {
  6594. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6595. {
  6596. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6597. AgentSit handlerOnRedo = OnRedo;
  6598. if (handlerOnRedo != null)
  6599. {
  6600. handlerOnRedo(this, objiD);
  6601. }
  6602. }
  6603. }
  6604. return true;
  6605. }
  6606. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6607. {
  6608. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6609. #region Packet Session and User Check
  6610. if (m_checkPackets)
  6611. {
  6612. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6613. dupeOnRay.AgentData.AgentID != AgentId)
  6614. return true;
  6615. }
  6616. #endregion
  6617. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6618. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6619. {
  6620. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6621. if (handlerObjectDuplicateOnRay != null)
  6622. {
  6623. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6624. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6625. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6626. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6627. }
  6628. }
  6629. return true;
  6630. }
  6631. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6632. {
  6633. //This powers the little tooltip that appears when you move your mouse over an object
  6634. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6635. #region Packet Session and User Check
  6636. if (m_checkPackets)
  6637. {
  6638. if (packToolTip.AgentData.SessionID != SessionId ||
  6639. packToolTip.AgentData.AgentID != AgentId)
  6640. return true;
  6641. }
  6642. #endregion
  6643. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6644. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6645. if (handlerRequestObjectPropertiesFamily != null)
  6646. {
  6647. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6648. packObjBlock.ObjectID);
  6649. }
  6650. return true;
  6651. }
  6652. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6653. {
  6654. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6655. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6656. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6657. #region Packet Session and User Check
  6658. if (m_checkPackets)
  6659. {
  6660. if (packInSearch.AgentData.SessionID != SessionId ||
  6661. packInSearch.AgentData.AgentID != AgentId)
  6662. return true;
  6663. }
  6664. #endregion
  6665. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6666. {
  6667. bool inSearch = objData.IncludeInSearch;
  6668. uint localID = objData.ObjectLocalID;
  6669. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6670. if (handlerObjectIncludeInSearch != null)
  6671. {
  6672. handlerObjectIncludeInSearch(this, inSearch, localID);
  6673. }
  6674. }
  6675. return true;
  6676. }
  6677. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6678. {
  6679. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6680. #region Packet Session and User Check
  6681. if (m_checkPackets)
  6682. {
  6683. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6684. scriptAnswer.AgentData.AgentID != AgentId)
  6685. return true;
  6686. }
  6687. #endregion
  6688. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6689. if (handlerScriptAnswer != null)
  6690. {
  6691. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6692. }
  6693. return true;
  6694. }
  6695. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6696. {
  6697. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6698. #region Packet Session and User Check
  6699. if (m_checkPackets)
  6700. {
  6701. if (ocpacket.AgentData.SessionID != SessionId ||
  6702. ocpacket.AgentData.AgentID != AgentId)
  6703. return true;
  6704. }
  6705. #endregion
  6706. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6707. if (handlerObjectClickAction != null)
  6708. {
  6709. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6710. {
  6711. byte action = odata.ClickAction;
  6712. uint localID = odata.ObjectLocalID;
  6713. handlerObjectClickAction(this, localID, action.ToString());
  6714. }
  6715. }
  6716. return true;
  6717. }
  6718. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6719. {
  6720. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6721. #region Packet Session and User Check
  6722. if (m_checkPackets)
  6723. {
  6724. if (ompacket.AgentData.SessionID != SessionId ||
  6725. ompacket.AgentData.AgentID != AgentId)
  6726. return true;
  6727. }
  6728. #endregion
  6729. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6730. if (handlerObjectMaterial != null)
  6731. {
  6732. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6733. {
  6734. byte material = odata.Material;
  6735. uint localID = odata.ObjectLocalID;
  6736. handlerObjectMaterial(this, localID, material.ToString());
  6737. }
  6738. }
  6739. return true;
  6740. }
  6741. #endregion Objects/m_sceneObjects
  6742. #region Inventory/Asset/Other related packets
  6743. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6744. {
  6745. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6746. //m_log.Debug("image request: " + Pack.ToString());
  6747. #region Packet Session and User Check
  6748. if (m_checkPackets)
  6749. {
  6750. if (imageRequest.AgentData.SessionID != SessionId ||
  6751. imageRequest.AgentData.AgentID != AgentId)
  6752. return true;
  6753. }
  6754. #endregion
  6755. //handlerTextureRequest = null;
  6756. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6757. {
  6758. TextureRequestArgs args = new TextureRequestArgs();
  6759. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6760. args.RequestedAssetID = block.Image;
  6761. args.DiscardLevel = block.DiscardLevel;
  6762. args.PacketNumber = block.Packet;
  6763. args.Priority = block.DownloadPriority;
  6764. args.requestSequence = imageRequest.Header.Sequence;
  6765. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6766. // priority of avatar textures to get avatars rezzing in faster than the
  6767. // surrounding scene
  6768. if ((ImageType)block.Type == ImageType.Baked)
  6769. args.Priority *= 2.0f;
  6770. ImageManager.EnqueueReq(args);
  6771. }
  6772. return true;
  6773. }
  6774. /// <summary>
  6775. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6776. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6777. /// </summary>
  6778. /// <param name="sender"></param>
  6779. /// <param name="Pack"></param>
  6780. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6781. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6782. {
  6783. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6784. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6785. UUID taskID = UUID.Zero;
  6786. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6787. {
  6788. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6789. {
  6790. // We're spawning a thread because the permissions check can block this thread
  6791. Util.FireAndForget(delegate
  6792. {
  6793. // This requests the asset if needed
  6794. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6795. });
  6796. return true;
  6797. }
  6798. }
  6799. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6800. {
  6801. //TransferRequestPacket does not include covenant uuid?
  6802. //get scene covenant uuid
  6803. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6804. }
  6805. // This is non-blocking
  6806. MakeAssetRequest(transfer, taskID);
  6807. return true;
  6808. }
  6809. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6810. {
  6811. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6812. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6813. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6814. //m_log.DebugFormat(
  6815. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6816. // requestID, itemID, taskID, Name);
  6817. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6818. // Validate inventory transfers
  6819. // Has to be done here, because AssetCache can't do it
  6820. //
  6821. if (taskID != UUID.Zero) // Prim
  6822. {
  6823. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6824. if (part == null)
  6825. {
  6826. m_log.WarnFormat(
  6827. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6828. Name, requestID, itemID, taskID);
  6829. return;
  6830. }
  6831. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6832. if (tii == null)
  6833. {
  6834. m_log.WarnFormat(
  6835. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6836. Name, requestID, itemID, taskID);
  6837. return;
  6838. }
  6839. if (tii.Type == (int)AssetType.LSLText)
  6840. {
  6841. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6842. return;
  6843. }
  6844. else if (tii.Type == (int)AssetType.Notecard)
  6845. {
  6846. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6847. return;
  6848. }
  6849. else
  6850. {
  6851. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6852. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6853. if (part.OwnerID != AgentId)
  6854. {
  6855. m_log.WarnFormat(
  6856. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6857. Name, requestID, itemID, taskID, part.OwnerID);
  6858. return;
  6859. }
  6860. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6861. {
  6862. m_log.WarnFormat(
  6863. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6864. Name, requestID, itemID, taskID);
  6865. return;
  6866. }
  6867. if (tii.OwnerID != AgentId)
  6868. {
  6869. m_log.WarnFormat(
  6870. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6871. Name, requestID, itemID, taskID, tii.OwnerID);
  6872. return;
  6873. }
  6874. if ((
  6875. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6876. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6877. {
  6878. m_log.WarnFormat(
  6879. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6880. Name, requestID, itemID, taskID);
  6881. return;
  6882. }
  6883. if (tii.AssetID != requestID)
  6884. {
  6885. m_log.WarnFormat(
  6886. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6887. Name, requestID, itemID, taskID, tii.AssetID);
  6888. return;
  6889. }
  6890. }
  6891. }
  6892. else // Agent
  6893. {
  6894. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6895. if (invAccess != null)
  6896. {
  6897. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6898. return;
  6899. }
  6900. else
  6901. {
  6902. return;
  6903. }
  6904. }
  6905. // Permissions out of the way, let's request the asset
  6906. MakeAssetRequest(transfer, taskID);
  6907. }
  6908. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6909. {
  6910. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6911. // m_log.Debug("upload request " + request.ToString());
  6912. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6913. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6914. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6915. if (handlerAssetUploadRequest != null)
  6916. {
  6917. handlerAssetUploadRequest(this, temp,
  6918. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6919. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6920. request.AssetBlock.Tempfile);
  6921. }
  6922. return true;
  6923. }
  6924. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6925. {
  6926. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6927. RequestXfer handlerRequestXfer = OnRequestXfer;
  6928. if (handlerRequestXfer != null)
  6929. {
  6930. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6931. }
  6932. return true;
  6933. }
  6934. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6935. {
  6936. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6937. XferReceive handlerXferReceive = OnXferReceive;
  6938. if (handlerXferReceive != null)
  6939. {
  6940. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6941. }
  6942. return true;
  6943. }
  6944. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6945. {
  6946. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6947. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6948. if (handlerConfirmXfer != null)
  6949. {
  6950. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6951. }
  6952. return true;
  6953. }
  6954. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6955. {
  6956. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6957. AbortXfer handlerAbortXfer = OnAbortXfer;
  6958. if (handlerAbortXfer != null)
  6959. {
  6960. handlerAbortXfer(this, abortXfer.XferID.ID);
  6961. }
  6962. return true;
  6963. }
  6964. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  6965. {
  6966. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  6967. #region Packet Session and User Check
  6968. if (m_checkPackets)
  6969. {
  6970. if (invFolder.AgentData.SessionID != SessionId ||
  6971. invFolder.AgentData.AgentID != AgentId)
  6972. return true;
  6973. }
  6974. #endregion
  6975. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  6976. if (handlerCreateInventoryFolder != null)
  6977. {
  6978. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  6979. (ushort)invFolder.FolderData.Type,
  6980. Util.FieldToString(invFolder.FolderData.Name),
  6981. invFolder.FolderData.ParentID);
  6982. }
  6983. return true;
  6984. }
  6985. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  6986. {
  6987. if (OnUpdateInventoryFolder != null)
  6988. {
  6989. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  6990. #region Packet Session and User Check
  6991. if (m_checkPackets)
  6992. {
  6993. if (invFolderx.AgentData.SessionID != SessionId ||
  6994. invFolderx.AgentData.AgentID != AgentId)
  6995. return true;
  6996. }
  6997. #endregion
  6998. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  6999. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7000. {
  7001. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7002. if (handlerUpdateInventoryFolder != null)
  7003. {
  7004. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7005. (ushort)invFolderx.FolderData[i].Type,
  7006. Util.FieldToString(invFolderx.FolderData[i].Name),
  7007. invFolderx.FolderData[i].ParentID);
  7008. }
  7009. }
  7010. }
  7011. return true;
  7012. }
  7013. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7014. {
  7015. if (OnMoveInventoryFolder != null)
  7016. {
  7017. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7018. #region Packet Session and User Check
  7019. if (m_checkPackets)
  7020. {
  7021. if (invFoldery.AgentData.SessionID != SessionId ||
  7022. invFoldery.AgentData.AgentID != AgentId)
  7023. return true;
  7024. }
  7025. #endregion
  7026. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7027. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7028. {
  7029. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7030. if (handlerMoveInventoryFolder != null)
  7031. {
  7032. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7033. invFoldery.InventoryData[i].ParentID);
  7034. }
  7035. }
  7036. }
  7037. return true;
  7038. }
  7039. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7040. {
  7041. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7042. #region Packet Session and User Check
  7043. if (m_checkPackets)
  7044. {
  7045. if (createItem.AgentData.SessionID != SessionId ||
  7046. createItem.AgentData.AgentID != AgentId)
  7047. return true;
  7048. }
  7049. #endregion
  7050. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7051. if (handlerCreateNewInventoryItem != null)
  7052. {
  7053. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7054. createItem.InventoryBlock.FolderID,
  7055. createItem.InventoryBlock.CallbackID,
  7056. Util.FieldToString(createItem.InventoryBlock.Description),
  7057. Util.FieldToString(createItem.InventoryBlock.Name),
  7058. createItem.InventoryBlock.InvType,
  7059. createItem.InventoryBlock.Type,
  7060. createItem.InventoryBlock.WearableType,
  7061. createItem.InventoryBlock.NextOwnerMask,
  7062. Util.UnixTimeSinceEpoch());
  7063. }
  7064. return true;
  7065. }
  7066. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7067. {
  7068. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7069. #region Packet Session and User Check
  7070. if (m_checkPackets)
  7071. {
  7072. if (createLink.AgentData.SessionID != SessionId ||
  7073. createLink.AgentData.AgentID != AgentId)
  7074. return true;
  7075. }
  7076. #endregion
  7077. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7078. if (linkInventoryItem != null)
  7079. {
  7080. linkInventoryItem(
  7081. this,
  7082. createLink.InventoryBlock.TransactionID,
  7083. createLink.InventoryBlock.FolderID,
  7084. createLink.InventoryBlock.CallbackID,
  7085. Util.FieldToString(createLink.InventoryBlock.Description),
  7086. Util.FieldToString(createLink.InventoryBlock.Name),
  7087. createLink.InventoryBlock.InvType,
  7088. createLink.InventoryBlock.Type,
  7089. createLink.InventoryBlock.OldItemID);
  7090. }
  7091. return true;
  7092. }
  7093. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7094. {
  7095. if (OnFetchInventory != null)
  7096. {
  7097. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7098. #region Packet Session and User Check
  7099. if (m_checkPackets)
  7100. {
  7101. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7102. FetchInventoryx.AgentData.AgentID != AgentId)
  7103. return true;
  7104. }
  7105. #endregion
  7106. FetchInventory handlerFetchInventory = null;
  7107. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7108. {
  7109. handlerFetchInventory = OnFetchInventory;
  7110. if (handlerFetchInventory != null)
  7111. {
  7112. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7113. FetchInventoryx.InventoryData[i].OwnerID);
  7114. }
  7115. }
  7116. }
  7117. return true;
  7118. }
  7119. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7120. {
  7121. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7122. #region Packet Session and User Check
  7123. if (m_checkPackets)
  7124. {
  7125. if (Fetch.AgentData.SessionID != SessionId ||
  7126. Fetch.AgentData.AgentID != AgentId)
  7127. return true;
  7128. }
  7129. #endregion
  7130. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7131. if (handlerFetchInventoryDescendents != null)
  7132. {
  7133. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7134. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7135. Fetch.InventoryData.SortOrder);
  7136. }
  7137. return true;
  7138. }
  7139. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7140. {
  7141. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7142. #region Packet Session and User Check
  7143. if (m_checkPackets)
  7144. {
  7145. if (Purge.AgentData.SessionID != SessionId ||
  7146. Purge.AgentData.AgentID != AgentId)
  7147. return true;
  7148. }
  7149. #endregion
  7150. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7151. if (handlerPurgeInventoryDescendents != null)
  7152. {
  7153. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7154. }
  7155. return true;
  7156. }
  7157. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7158. {
  7159. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7160. #region Packet Session and User Check
  7161. if (m_checkPackets)
  7162. {
  7163. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7164. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7165. return true;
  7166. }
  7167. #endregion
  7168. if (OnUpdateInventoryItem != null)
  7169. {
  7170. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7171. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7172. {
  7173. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7174. if (handlerUpdateInventoryItem != null)
  7175. {
  7176. InventoryItemBase itemUpd = new InventoryItemBase();
  7177. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7178. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7179. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7180. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7181. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7182. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7183. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7184. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7185. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7186. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7187. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7188. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7189. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7190. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7191. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7192. inventoryItemUpdate.InventoryData[i].ItemID,
  7193. itemUpd);
  7194. }
  7195. }
  7196. }
  7197. return true;
  7198. }
  7199. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7200. {
  7201. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7202. #region Packet Session and User Check
  7203. if (m_checkPackets)
  7204. {
  7205. if (copyitem.AgentData.SessionID != SessionId ||
  7206. copyitem.AgentData.AgentID != AgentId)
  7207. return true;
  7208. }
  7209. #endregion
  7210. CopyInventoryItem handlerCopyInventoryItem = null;
  7211. if (OnCopyInventoryItem != null)
  7212. {
  7213. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7214. {
  7215. handlerCopyInventoryItem = OnCopyInventoryItem;
  7216. if (handlerCopyInventoryItem != null)
  7217. {
  7218. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7219. datablock.OldItemID, datablock.NewFolderID,
  7220. Util.FieldToString(datablock.NewName));
  7221. }
  7222. }
  7223. }
  7224. return true;
  7225. }
  7226. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7227. {
  7228. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7229. #region Packet Session and User Check
  7230. if (m_checkPackets)
  7231. {
  7232. if (moveitem.AgentData.SessionID != SessionId ||
  7233. moveitem.AgentData.AgentID != AgentId)
  7234. return true;
  7235. }
  7236. #endregion
  7237. if (OnMoveInventoryItem != null)
  7238. {
  7239. MoveInventoryItem handlerMoveInventoryItem = null;
  7240. InventoryItemBase itm = null;
  7241. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7242. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7243. {
  7244. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7245. itm.Folder = datablock.FolderID;
  7246. itm.Name = Util.FieldToString(datablock.NewName);
  7247. // weird, comes out as empty string
  7248. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7249. items.Add(itm);
  7250. }
  7251. handlerMoveInventoryItem = OnMoveInventoryItem;
  7252. if (handlerMoveInventoryItem != null)
  7253. {
  7254. handlerMoveInventoryItem(this, items);
  7255. }
  7256. }
  7257. return true;
  7258. }
  7259. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7260. {
  7261. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7262. #region Packet Session and User Check
  7263. if (m_checkPackets)
  7264. {
  7265. if (removeItem.AgentData.SessionID != SessionId ||
  7266. removeItem.AgentData.AgentID != AgentId)
  7267. return true;
  7268. }
  7269. #endregion
  7270. if (OnRemoveInventoryItem != null)
  7271. {
  7272. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7273. List<UUID> uuids = new List<UUID>();
  7274. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7275. {
  7276. uuids.Add(datablock.ItemID);
  7277. }
  7278. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7279. if (handlerRemoveInventoryItem != null)
  7280. {
  7281. handlerRemoveInventoryItem(this, uuids);
  7282. }
  7283. }
  7284. return true;
  7285. }
  7286. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7287. {
  7288. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7289. #region Packet Session and User Check
  7290. if (m_checkPackets)
  7291. {
  7292. if (removeFolder.AgentData.SessionID != SessionId ||
  7293. removeFolder.AgentData.AgentID != AgentId)
  7294. return true;
  7295. }
  7296. #endregion
  7297. if (OnRemoveInventoryFolder != null)
  7298. {
  7299. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7300. List<UUID> uuids = new List<UUID>();
  7301. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7302. {
  7303. uuids.Add(datablock.FolderID);
  7304. }
  7305. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7306. if (handlerRemoveInventoryFolder != null)
  7307. {
  7308. handlerRemoveInventoryFolder(this, uuids);
  7309. }
  7310. }
  7311. return true;
  7312. }
  7313. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7314. {
  7315. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7316. #region Packet Session and User Check
  7317. if (m_checkPackets)
  7318. {
  7319. if (removeObject.AgentData.SessionID != SessionId ||
  7320. removeObject.AgentData.AgentID != AgentId)
  7321. return true;
  7322. }
  7323. #endregion
  7324. if (OnRemoveInventoryFolder != null)
  7325. {
  7326. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7327. List<UUID> uuids = new List<UUID>();
  7328. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7329. {
  7330. uuids.Add(datablock.FolderID);
  7331. }
  7332. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7333. if (handlerRemoveInventoryFolder != null)
  7334. {
  7335. handlerRemoveInventoryFolder(this, uuids);
  7336. }
  7337. }
  7338. if (OnRemoveInventoryItem != null)
  7339. {
  7340. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7341. List<UUID> uuids = new List<UUID>();
  7342. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7343. {
  7344. uuids.Add(datablock.ItemID);
  7345. }
  7346. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7347. if (handlerRemoveInventoryItem != null)
  7348. {
  7349. handlerRemoveInventoryItem(this, uuids);
  7350. }
  7351. }
  7352. return true;
  7353. }
  7354. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7355. {
  7356. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7357. #region Packet Session and User Check
  7358. if (m_checkPackets)
  7359. {
  7360. if (requesttask.AgentData.SessionID != SessionId ||
  7361. requesttask.AgentData.AgentID != AgentId)
  7362. return true;
  7363. }
  7364. #endregion
  7365. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7366. if (handlerRequestTaskInventory != null)
  7367. {
  7368. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7369. }
  7370. return true;
  7371. }
  7372. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7373. {
  7374. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7375. #region Packet Session and User Check
  7376. if (m_checkPackets)
  7377. {
  7378. if (updatetask.AgentData.SessionID != SessionId ||
  7379. updatetask.AgentData.AgentID != AgentId)
  7380. return true;
  7381. }
  7382. #endregion
  7383. if (OnUpdateTaskInventory != null)
  7384. {
  7385. if (updatetask.UpdateData.Key == 0)
  7386. {
  7387. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7388. if (handlerUpdateTaskInventory != null)
  7389. {
  7390. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7391. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7392. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7393. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7394. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7395. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7396. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7397. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7398. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7399. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7400. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7401. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7402. // different
  7403. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7404. newTaskItem.Type = updatetask.InventoryData.Type;
  7405. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7406. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7407. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7408. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7409. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7410. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7411. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7412. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7413. newTaskItem, updatetask.UpdateData.LocalID);
  7414. }
  7415. }
  7416. }
  7417. return true;
  7418. }
  7419. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7420. {
  7421. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7422. #region Packet Session and User Check
  7423. if (m_checkPackets)
  7424. {
  7425. if (removeTask.AgentData.SessionID != SessionId ||
  7426. removeTask.AgentData.AgentID != AgentId)
  7427. return true;
  7428. }
  7429. #endregion
  7430. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7431. if (handlerRemoveTaskItem != null)
  7432. {
  7433. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7434. }
  7435. return true;
  7436. }
  7437. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7438. {
  7439. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7440. #region Packet Session and User Check
  7441. if (m_checkPackets)
  7442. {
  7443. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7444. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7445. return true;
  7446. }
  7447. #endregion
  7448. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7449. if (handlerMoveTaskItem != null)
  7450. {
  7451. handlerMoveTaskItem(
  7452. this, moveTaskInventoryPacket.AgentData.FolderID,
  7453. moveTaskInventoryPacket.InventoryData.LocalID,
  7454. moveTaskInventoryPacket.InventoryData.ItemID);
  7455. }
  7456. return true;
  7457. }
  7458. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7459. {
  7460. //m_log.Debug(Pack.ToString());
  7461. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7462. #region Packet Session and User Check
  7463. if (m_checkPackets)
  7464. {
  7465. if (rezScriptx.AgentData.SessionID != SessionId ||
  7466. rezScriptx.AgentData.AgentID != AgentId)
  7467. return true;
  7468. }
  7469. #endregion
  7470. RezScript handlerRezScript = OnRezScript;
  7471. InventoryItemBase item = new InventoryItemBase();
  7472. item.ID = rezScriptx.InventoryBlock.ItemID;
  7473. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7474. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7475. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7476. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7477. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7478. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7479. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7480. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7481. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7482. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7483. item.AssetType = rezScriptx.InventoryBlock.Type;
  7484. item.InvType = rezScriptx.InventoryBlock.InvType;
  7485. item.Flags = rezScriptx.InventoryBlock.Flags;
  7486. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7487. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7488. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7489. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7490. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7491. if (handlerRezScript != null)
  7492. {
  7493. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7494. }
  7495. return true;
  7496. }
  7497. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7498. {
  7499. RequestMapLayer();
  7500. return true;
  7501. }
  7502. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7503. {
  7504. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7505. #region Packet Session and User Check
  7506. if (m_checkPackets)
  7507. {
  7508. if (MapRequest.AgentData.SessionID != SessionId ||
  7509. MapRequest.AgentData.AgentID != AgentId)
  7510. return true;
  7511. }
  7512. #endregion
  7513. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7514. if (handlerRequestMapBlocks != null)
  7515. {
  7516. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7517. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7518. }
  7519. return true;
  7520. }
  7521. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7522. {
  7523. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7524. #region Packet Session and User Check
  7525. if (m_checkPackets)
  7526. {
  7527. if (map.AgentData.SessionID != SessionId ||
  7528. map.AgentData.AgentID != AgentId)
  7529. return true;
  7530. }
  7531. #endregion
  7532. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7533. map.NameData.Name.Length - 1);
  7534. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7535. if (handlerMapNameRequest != null)
  7536. {
  7537. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7538. }
  7539. return true;
  7540. }
  7541. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7542. {
  7543. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7544. #region Packet Session and User Check
  7545. if (m_checkPackets)
  7546. {
  7547. if (tpReq.Info.SessionID != SessionId ||
  7548. tpReq.Info.AgentID != AgentId)
  7549. return true;
  7550. }
  7551. #endregion
  7552. UUID lmid = tpReq.Info.LandmarkID;
  7553. AssetLandmark lm;
  7554. if (lmid != UUID.Zero)
  7555. {
  7556. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7557. AssetBase lma = m_assetService.Get(lmid.ToString());
  7558. if (lma == null)
  7559. {
  7560. // Failed to find landmark
  7561. // Let's try to search in the user's home asset server
  7562. lma = FindAssetInUserAssetServer(lmid.ToString());
  7563. if (lma == null)
  7564. {
  7565. // Really doesn't exist
  7566. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7567. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7568. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7569. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7570. }
  7571. }
  7572. try
  7573. {
  7574. lm = new AssetLandmark(lma);
  7575. }
  7576. catch (NullReferenceException)
  7577. {
  7578. // asset not found generates null ref inside the assetlandmark constructor.
  7579. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7580. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7581. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7582. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7583. return true;
  7584. }
  7585. }
  7586. else
  7587. {
  7588. // Teleport home request
  7589. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7590. if (handlerTeleportHomeRequest != null)
  7591. {
  7592. handlerTeleportHomeRequest(AgentId, this);
  7593. }
  7594. return true;
  7595. }
  7596. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7597. if (handlerTeleportLandmarkRequest != null)
  7598. {
  7599. handlerTeleportLandmarkRequest(this, lm);
  7600. }
  7601. else
  7602. {
  7603. //no event handler so cancel request
  7604. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7605. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7606. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7607. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7608. }
  7609. return true;
  7610. }
  7611. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7612. {
  7613. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7614. if (handlerTeleportCancel != null)
  7615. {
  7616. handlerTeleportCancel(this);
  7617. }
  7618. return true;
  7619. }
  7620. private AssetBase FindAssetInUserAssetServer(string id)
  7621. {
  7622. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7623. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7624. {
  7625. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7626. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7627. }
  7628. return null;
  7629. }
  7630. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7631. {
  7632. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7633. // m_log.Debug(tpLocReq.ToString());
  7634. #region Packet Session and User Check
  7635. if (m_checkPackets)
  7636. {
  7637. if (tpLocReq.AgentData.SessionID != SessionId ||
  7638. tpLocReq.AgentData.AgentID != AgentId)
  7639. return true;
  7640. }
  7641. #endregion
  7642. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7643. if (handlerTeleportLocationRequest != null)
  7644. {
  7645. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7646. tpLocReq.Info.LookAt, 16);
  7647. }
  7648. else
  7649. {
  7650. //no event handler so cancel request
  7651. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7652. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7653. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7654. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7655. }
  7656. return true;
  7657. }
  7658. #endregion Inventory/Asset/Other related packets
  7659. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7660. {
  7661. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7662. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7663. {
  7664. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7665. if (handlerNameRequest != null)
  7666. {
  7667. handlerNameRequest(UUIDBlock.ID, this);
  7668. }
  7669. }
  7670. return true;
  7671. }
  7672. #region Parcel related packets
  7673. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7674. {
  7675. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7676. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7677. if (handlerRegionHandleRequest != null)
  7678. {
  7679. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7680. }
  7681. return true;
  7682. }
  7683. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7684. {
  7685. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7686. #region Packet Session and User Check
  7687. if (m_checkPackets)
  7688. {
  7689. if (pirPack.AgentData.SessionID != SessionId ||
  7690. pirPack.AgentData.AgentID != AgentId)
  7691. return true;
  7692. }
  7693. #endregion
  7694. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7695. if (handlerParcelInfoRequest != null)
  7696. {
  7697. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7698. }
  7699. return true;
  7700. }
  7701. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7702. {
  7703. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7704. #region Packet Session and User Check
  7705. if (m_checkPackets)
  7706. {
  7707. if (requestPacket.AgentData.SessionID != SessionId ||
  7708. requestPacket.AgentData.AgentID != AgentId)
  7709. return true;
  7710. }
  7711. #endregion
  7712. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7713. if (handlerParcelAccessListRequest != null)
  7714. {
  7715. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7716. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7717. requestPacket.Data.LocalID, this);
  7718. }
  7719. return true;
  7720. }
  7721. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7722. {
  7723. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7724. #region Packet Session and User Check
  7725. if (m_checkPackets)
  7726. {
  7727. if (updatePacket.AgentData.SessionID != SessionId ||
  7728. updatePacket.AgentData.AgentID != AgentId)
  7729. return true;
  7730. }
  7731. #endregion
  7732. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7733. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7734. {
  7735. LandAccessEntry entry = new LandAccessEntry();
  7736. entry.AgentID = block.ID;
  7737. entry.Flags = (AccessList)block.Flags;
  7738. entry.Expires = block.Time;
  7739. entries.Add(entry);
  7740. }
  7741. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7742. if (handlerParcelAccessListUpdateRequest != null)
  7743. {
  7744. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7745. updatePacket.Data.Flags,
  7746. updatePacket.Data.LocalID,
  7747. updatePacket.Data.TransactionID,
  7748. updatePacket.Data.SequenceID,
  7749. updatePacket.Data.Sections,
  7750. entries, this);
  7751. }
  7752. return true;
  7753. }
  7754. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7755. {
  7756. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7757. #region Packet Session and User Check
  7758. if (m_checkPackets)
  7759. {
  7760. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7761. propertiesRequest.AgentData.AgentID != AgentId)
  7762. return true;
  7763. }
  7764. #endregion
  7765. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7766. if (handlerParcelPropertiesRequest != null)
  7767. {
  7768. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7769. (int)Math.Round(propertiesRequest.ParcelData.South),
  7770. (int)Math.Round(propertiesRequest.ParcelData.East),
  7771. (int)Math.Round(propertiesRequest.ParcelData.North),
  7772. propertiesRequest.ParcelData.SequenceID,
  7773. propertiesRequest.ParcelData.SnapSelection, this);
  7774. }
  7775. return true;
  7776. }
  7777. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7778. {
  7779. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7780. #region Packet Session and User Check
  7781. if (m_checkPackets)
  7782. {
  7783. if (landDivide.AgentData.SessionID != SessionId ||
  7784. landDivide.AgentData.AgentID != AgentId)
  7785. return true;
  7786. }
  7787. #endregion
  7788. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7789. if (handlerParcelDivideRequest != null)
  7790. {
  7791. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7792. (int)Math.Round(landDivide.ParcelData.South),
  7793. (int)Math.Round(landDivide.ParcelData.East),
  7794. (int)Math.Round(landDivide.ParcelData.North), this);
  7795. }
  7796. return true;
  7797. }
  7798. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7799. {
  7800. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7801. #region Packet Session and User Check
  7802. if (m_checkPackets)
  7803. {
  7804. if (landJoin.AgentData.SessionID != SessionId ||
  7805. landJoin.AgentData.AgentID != AgentId)
  7806. return true;
  7807. }
  7808. #endregion
  7809. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7810. if (handlerParcelJoinRequest != null)
  7811. {
  7812. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7813. (int)Math.Round(landJoin.ParcelData.South),
  7814. (int)Math.Round(landJoin.ParcelData.East),
  7815. (int)Math.Round(landJoin.ParcelData.North), this);
  7816. }
  7817. return true;
  7818. }
  7819. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7820. {
  7821. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7822. #region Packet Session and User Check
  7823. if (m_checkPackets)
  7824. {
  7825. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7826. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7827. return true;
  7828. }
  7829. #endregion
  7830. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7831. if (handlerParcelPropertiesUpdateRequest != null)
  7832. {
  7833. LandUpdateArgs args = new LandUpdateArgs();
  7834. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7835. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7836. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7837. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7838. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7839. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7840. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7841. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7842. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7843. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7844. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7845. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7846. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7847. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7848. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7849. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7850. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7851. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7852. }
  7853. return true;
  7854. }
  7855. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7856. {
  7857. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7858. #region Packet Session and User Check
  7859. if (m_checkPackets)
  7860. {
  7861. if (selectPacket.AgentData.SessionID != SessionId ||
  7862. selectPacket.AgentData.AgentID != AgentId)
  7863. return true;
  7864. }
  7865. #endregion
  7866. List<UUID> returnIDs = new List<UUID>();
  7867. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7868. selectPacket.ReturnIDs)
  7869. {
  7870. returnIDs.Add(rb.ReturnID);
  7871. }
  7872. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7873. if (handlerParcelSelectObjects != null)
  7874. {
  7875. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7876. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7877. }
  7878. return true;
  7879. }
  7880. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7881. {
  7882. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7883. #region Packet Session and User Check
  7884. if (m_checkPackets)
  7885. {
  7886. if (reqPacket.AgentData.SessionID != SessionId ||
  7887. reqPacket.AgentData.AgentID != AgentId)
  7888. return true;
  7889. }
  7890. #endregion
  7891. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7892. if (handlerParcelObjectOwnerRequest != null)
  7893. {
  7894. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7895. }
  7896. return true;
  7897. }
  7898. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7899. {
  7900. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7901. #region Packet Session and User Check
  7902. if (m_checkPackets)
  7903. {
  7904. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7905. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7906. return true;
  7907. }
  7908. #endregion
  7909. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7910. if (handlerParcelGodForceOwner != null)
  7911. {
  7912. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7913. }
  7914. return true;
  7915. }
  7916. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7917. {
  7918. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7919. #region Packet Session and User Check
  7920. if (m_checkPackets)
  7921. {
  7922. if (releasePacket.AgentData.SessionID != SessionId ||
  7923. releasePacket.AgentData.AgentID != AgentId)
  7924. return true;
  7925. }
  7926. #endregion
  7927. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7928. if (handlerParcelAbandonRequest != null)
  7929. {
  7930. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7931. }
  7932. return true;
  7933. }
  7934. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7935. {
  7936. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7937. #region Packet Session and User Check
  7938. if (m_checkPackets)
  7939. {
  7940. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7941. reclaimPacket.AgentData.AgentID != AgentId)
  7942. return true;
  7943. }
  7944. #endregion
  7945. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7946. if (handlerParcelReclaim != null)
  7947. {
  7948. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  7949. }
  7950. return true;
  7951. }
  7952. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  7953. {
  7954. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  7955. #region Packet Session and User Check
  7956. if (m_checkPackets)
  7957. {
  7958. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  7959. parcelReturnObjects.AgentData.AgentID != AgentId)
  7960. return true;
  7961. }
  7962. #endregion
  7963. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  7964. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  7965. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  7966. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  7967. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  7968. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  7969. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  7970. if (handlerParcelReturnObjectsRequest != null)
  7971. {
  7972. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  7973. }
  7974. return true;
  7975. }
  7976. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  7977. {
  7978. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  7979. #region Packet Session and User Check
  7980. if (m_checkPackets)
  7981. {
  7982. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  7983. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  7984. return true;
  7985. }
  7986. #endregion
  7987. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  7988. if (handlerParcelSetOtherCleanTime != null)
  7989. {
  7990. handlerParcelSetOtherCleanTime(this,
  7991. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  7992. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  7993. }
  7994. return true;
  7995. }
  7996. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  7997. {
  7998. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  7999. #region Packet Session and User Check
  8000. if (m_checkPackets)
  8001. {
  8002. if (lsrp.AgentData.SessionID != SessionId ||
  8003. lsrp.AgentData.AgentID != AgentId)
  8004. return true;
  8005. }
  8006. #endregion
  8007. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8008. if (handlerLandStatRequest != null)
  8009. {
  8010. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8011. }
  8012. return true;
  8013. }
  8014. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8015. {
  8016. ParcelDwellRequestPacket dwellrq =
  8017. (ParcelDwellRequestPacket)Pack;
  8018. #region Packet Session and User Check
  8019. if (m_checkPackets)
  8020. {
  8021. if (dwellrq.AgentData.SessionID != SessionId ||
  8022. dwellrq.AgentData.AgentID != AgentId)
  8023. return true;
  8024. }
  8025. #endregion
  8026. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8027. if (handlerParcelDwellRequest != null)
  8028. {
  8029. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8030. }
  8031. return true;
  8032. }
  8033. #endregion Parcel related packets
  8034. #region Estate Packets
  8035. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8036. {
  8037. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8038. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8039. GodLandStatRequest handlerLandStatRequest;
  8040. #region Packet Session and User Check
  8041. if (m_checkPackets)
  8042. {
  8043. if (messagePacket.AgentData.SessionID != SessionId ||
  8044. messagePacket.AgentData.AgentID != AgentId)
  8045. return true;
  8046. }
  8047. #endregion
  8048. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8049. switch (method)
  8050. {
  8051. case "getinfo":
  8052. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8053. {
  8054. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8055. }
  8056. return true;
  8057. case "setregioninfo":
  8058. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8059. {
  8060. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8061. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8062. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8063. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8064. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8065. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8066. }
  8067. return true;
  8068. // case "texturebase":
  8069. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8070. // {
  8071. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8072. // {
  8073. // string s = Utils.BytesToString(block.Parameter);
  8074. // string[] splitField = s.Split(' ');
  8075. // if (splitField.Length == 2)
  8076. // {
  8077. // UUID tempUUID = new UUID(splitField[1]);
  8078. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8079. // }
  8080. // }
  8081. // }
  8082. // break;
  8083. case "texturedetail":
  8084. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8085. {
  8086. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8087. {
  8088. string s = Utils.BytesToString(block.Parameter);
  8089. string[] splitField = s.Split(' ');
  8090. if (splitField.Length == 2)
  8091. {
  8092. Int16 corner = Convert.ToInt16(splitField[0]);
  8093. UUID textureUUID = new UUID(splitField[1]);
  8094. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8095. }
  8096. }
  8097. }
  8098. return true;
  8099. case "textureheights":
  8100. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8101. {
  8102. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8103. {
  8104. string s = Utils.BytesToString(block.Parameter);
  8105. string[] splitField = s.Split(' ');
  8106. if (splitField.Length == 3)
  8107. {
  8108. Int16 corner = Convert.ToInt16(splitField[0]);
  8109. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8110. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8111. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8112. }
  8113. }
  8114. }
  8115. return true;
  8116. case "texturecommit":
  8117. OnCommitEstateTerrainTextureRequest(this);
  8118. return true;
  8119. case "setregionterrain":
  8120. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8121. {
  8122. if (messagePacket.ParamList.Length != 9)
  8123. {
  8124. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8125. }
  8126. else
  8127. {
  8128. try
  8129. {
  8130. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8131. if (!tmp.Contains(".")) tmp += ".00";
  8132. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8133. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8134. if (!tmp.Contains(".")) tmp += ".00";
  8135. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8136. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8137. if (!tmp.Contains(".")) tmp += ".00";
  8138. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8139. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8140. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8141. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8142. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8143. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8144. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8145. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8146. }
  8147. catch (Exception ex)
  8148. {
  8149. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8150. }
  8151. }
  8152. }
  8153. return true;
  8154. case "restart":
  8155. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8156. {
  8157. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8158. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8159. {
  8160. float timeSeconds;
  8161. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8162. timeSeconds = (int)timeSeconds;
  8163. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8164. }
  8165. }
  8166. return true;
  8167. case "estatechangecovenantid":
  8168. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8169. {
  8170. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8171. {
  8172. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8173. OnEstateChangeCovenantRequest(this, newCovenantID);
  8174. }
  8175. }
  8176. return true;
  8177. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8178. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8179. {
  8180. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8181. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8182. }
  8183. return true;
  8184. case "simulatormessage":
  8185. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8186. {
  8187. UUID invoice = messagePacket.MethodData.Invoice;
  8188. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8189. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8190. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8191. UUID sessionID = messagePacket.AgentData.SessionID;
  8192. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8193. }
  8194. return true;
  8195. case "instantmessage":
  8196. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8197. {
  8198. if (messagePacket.ParamList.Length < 2)
  8199. return true;
  8200. UUID invoice = messagePacket.MethodData.Invoice;
  8201. UUID sessionID = messagePacket.AgentData.SessionID;
  8202. UUID SenderID;
  8203. string SenderName;
  8204. string Message;
  8205. if (messagePacket.ParamList.Length < 5)
  8206. {
  8207. SenderID = AgentId;
  8208. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8209. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8210. }
  8211. else
  8212. {
  8213. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8214. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8215. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8216. }
  8217. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8218. }
  8219. return true;
  8220. case "setregiondebug":
  8221. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8222. {
  8223. UUID invoice = messagePacket.MethodData.Invoice;
  8224. UUID SenderID = messagePacket.AgentData.AgentID;
  8225. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8226. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8227. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8228. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8229. }
  8230. return true;
  8231. case "teleporthomeuser":
  8232. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8233. {
  8234. UUID invoice = messagePacket.MethodData.Invoice;
  8235. UUID SenderID = messagePacket.AgentData.AgentID;
  8236. UUID Prey;
  8237. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8238. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8239. }
  8240. return true;
  8241. case "teleporthomeallusers":
  8242. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8243. {
  8244. UUID invoice = messagePacket.MethodData.Invoice;
  8245. UUID SenderID = messagePacket.AgentData.AgentID;
  8246. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8247. }
  8248. return true;
  8249. case "colliders":
  8250. handlerLandStatRequest = OnLandStatRequest;
  8251. if (handlerLandStatRequest != null)
  8252. {
  8253. handlerLandStatRequest(0, 1, 0, "", this);
  8254. }
  8255. return true;
  8256. case "scripts":
  8257. handlerLandStatRequest = OnLandStatRequest;
  8258. if (handlerLandStatRequest != null)
  8259. {
  8260. handlerLandStatRequest(0, 0, 0, "", this);
  8261. }
  8262. return true;
  8263. case "terrain":
  8264. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8265. {
  8266. if (messagePacket.ParamList.Length > 0)
  8267. {
  8268. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8269. {
  8270. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8271. if (handlerBakeTerrain != null)
  8272. {
  8273. handlerBakeTerrain(this);
  8274. }
  8275. }
  8276. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8277. {
  8278. if (messagePacket.ParamList.Length > 1)
  8279. {
  8280. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8281. if (handlerRequestTerrain != null)
  8282. {
  8283. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8284. }
  8285. }
  8286. }
  8287. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8288. {
  8289. if (messagePacket.ParamList.Length > 1)
  8290. {
  8291. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8292. if (handlerUploadTerrain != null)
  8293. {
  8294. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8295. }
  8296. }
  8297. }
  8298. }
  8299. }
  8300. return true;
  8301. case "estatechangeinfo":
  8302. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8303. {
  8304. UUID invoice = messagePacket.MethodData.Invoice;
  8305. UUID SenderID = messagePacket.AgentData.AgentID;
  8306. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8307. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8308. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8309. if (handlerEstateChangeInfo != null)
  8310. {
  8311. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8312. }
  8313. }
  8314. return true;
  8315. case "telehub":
  8316. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8317. {
  8318. UUID invoice = messagePacket.MethodData.Invoice;
  8319. UUID SenderID = messagePacket.AgentData.AgentID;
  8320. UInt32 param1 = 0u;
  8321. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8322. if (command != "info ui")
  8323. {
  8324. try
  8325. {
  8326. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8327. }
  8328. catch
  8329. {
  8330. }
  8331. }
  8332. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8333. if (handlerEstateManageTelehub != null)
  8334. {
  8335. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8336. }
  8337. }
  8338. return true;
  8339. default:
  8340. m_log.WarnFormat(
  8341. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8342. method, Name, Scene.Name);
  8343. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8344. {
  8345. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8346. string data = (string)Utils.BytesToString(block.Parameter);
  8347. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8348. }
  8349. return true;
  8350. }
  8351. //int parcelID, uint reportType, uint requestflags, string filter
  8352. //lsrp.RequestData.ParcelLocalID;
  8353. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8354. //lsrp.RequestData.RequestFlags;
  8355. //lsrp.RequestData.Filter;
  8356. }
  8357. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8358. {
  8359. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8360. #region Packet Session and User Check
  8361. if (m_checkPackets)
  8362. {
  8363. if (mPacket.SessionID != SessionId ||
  8364. mPacket.AgentID != AgentId)
  8365. return true;
  8366. }
  8367. #endregion
  8368. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8369. if (handlerRegionInfoRequest != null)
  8370. {
  8371. handlerRegionInfoRequest(this);
  8372. }
  8373. return true;
  8374. }
  8375. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8376. {
  8377. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8378. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8379. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8380. if (handlerEstateCovenantRequest != null)
  8381. {
  8382. handlerEstateCovenantRequest(this);
  8383. }
  8384. return true;
  8385. }
  8386. #endregion Estate Packets
  8387. #region GodPackets
  8388. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8389. {
  8390. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8391. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8392. UUID token = rblock.Token;
  8393. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8394. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8395. if (handlerReqGodlikePowers != null)
  8396. {
  8397. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8398. }
  8399. return true;
  8400. }
  8401. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8402. {
  8403. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8404. (GodUpdateRegionInfoPacket)Packet;
  8405. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8406. if (handlerGodUpdateRegionInfo != null)
  8407. {
  8408. handlerGodUpdateRegionInfo(this,
  8409. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8410. GodUpdateRegionInfo.RegionInfo.EstateID,
  8411. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8412. GodUpdateRegionInfo.RegionInfo.SimName,
  8413. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8414. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8415. return true;
  8416. }
  8417. return false;
  8418. }
  8419. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8420. {
  8421. SimWideDeletesPacket SimWideDeletesRequest =
  8422. (SimWideDeletesPacket)Packet;
  8423. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8424. if (handlerSimWideDeletesRequest != null)
  8425. {
  8426. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8427. return true;
  8428. }
  8429. return false;
  8430. }
  8431. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8432. {
  8433. GodlikeMessagePacket GodlikeMessage =
  8434. (GodlikeMessagePacket)Packet;
  8435. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8436. if (handlerGodlikeMessage != null)
  8437. {
  8438. handlerGodlikeMessage(this,
  8439. GodlikeMessage.MethodData.Invoice,
  8440. GodlikeMessage.MethodData.Method,
  8441. GodlikeMessage.ParamList[0].Parameter);
  8442. return true;
  8443. }
  8444. return false;
  8445. }
  8446. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8447. {
  8448. StateSavePacket SaveStateMessage =
  8449. (StateSavePacket)Packet;
  8450. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8451. if (handlerSaveStatePacket != null)
  8452. {
  8453. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8454. return true;
  8455. }
  8456. return false;
  8457. }
  8458. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8459. {
  8460. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8461. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8462. {
  8463. GodKickUser handlerGodKickUser = OnGodKickUser;
  8464. if (handlerGodKickUser != null)
  8465. {
  8466. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8467. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8468. }
  8469. }
  8470. else
  8471. {
  8472. SendAgentAlertMessage("Kick request denied", false);
  8473. }
  8474. //KickUserPacket kupack = new KickUserPacket();
  8475. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8476. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8477. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8478. //kupack.TargetBlock.TargetIP = (uint)0;
  8479. //kupack.TargetBlock.TargetPort = (ushort)0;
  8480. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8481. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8482. return true;
  8483. }
  8484. #endregion GodPackets
  8485. #region Economy/Transaction Packets
  8486. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8487. {
  8488. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8489. #region Packet Session and User Check
  8490. if (m_checkPackets)
  8491. {
  8492. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8493. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8494. return true;
  8495. }
  8496. #endregion
  8497. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8498. if (handlerMoneyBalanceRequest != null)
  8499. {
  8500. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8501. }
  8502. return true;
  8503. }
  8504. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8505. {
  8506. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8507. if (handlerEconomoyDataRequest != null)
  8508. {
  8509. handlerEconomoyDataRequest(this);
  8510. }
  8511. return true;
  8512. }
  8513. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8514. {
  8515. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8516. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8517. if (handlerRequestPayPrice != null)
  8518. {
  8519. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8520. }
  8521. return true;
  8522. }
  8523. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8524. {
  8525. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8526. #region Packet Session and User Check
  8527. if (m_checkPackets)
  8528. {
  8529. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8530. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8531. return true;
  8532. }
  8533. #endregion
  8534. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8535. if (handlerObjectSaleInfo != null)
  8536. {
  8537. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8538. in objectSaleInfoPacket.ObjectData)
  8539. {
  8540. handlerObjectSaleInfo(this,
  8541. objectSaleInfoPacket.AgentData.AgentID,
  8542. objectSaleInfoPacket.AgentData.SessionID,
  8543. d.LocalID,
  8544. d.SaleType,
  8545. d.SalePrice);
  8546. }
  8547. }
  8548. return true;
  8549. }
  8550. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8551. {
  8552. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8553. #region Packet Session and User Check
  8554. if (m_checkPackets)
  8555. {
  8556. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8557. objectBuyPacket.AgentData.AgentID != AgentId)
  8558. return true;
  8559. }
  8560. #endregion
  8561. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8562. if (handlerObjectBuy != null)
  8563. {
  8564. foreach (ObjectBuyPacket.ObjectDataBlock d
  8565. in objectBuyPacket.ObjectData)
  8566. {
  8567. handlerObjectBuy(this,
  8568. objectBuyPacket.AgentData.AgentID,
  8569. objectBuyPacket.AgentData.SessionID,
  8570. objectBuyPacket.AgentData.GroupID,
  8571. objectBuyPacket.AgentData.CategoryID,
  8572. d.ObjectLocalID,
  8573. d.SaleType,
  8574. d.SalePrice);
  8575. }
  8576. }
  8577. return true;
  8578. }
  8579. #endregion Economy/Transaction Packets
  8580. #region Script Packets
  8581. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8582. {
  8583. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8584. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8585. if (handlerGetScriptRunning != null)
  8586. {
  8587. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8588. }
  8589. return true;
  8590. }
  8591. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8592. {
  8593. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8594. #region Packet Session and User Check
  8595. if (m_checkPackets)
  8596. {
  8597. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8598. setScriptRunning.AgentData.AgentID != AgentId)
  8599. return true;
  8600. }
  8601. #endregion
  8602. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8603. if (handlerSetScriptRunning != null)
  8604. {
  8605. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8606. }
  8607. return true;
  8608. }
  8609. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8610. {
  8611. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8612. #region Packet Session and User Check
  8613. if (m_checkPackets)
  8614. {
  8615. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8616. scriptResetPacket.AgentData.AgentID != AgentId)
  8617. return true;
  8618. }
  8619. #endregion
  8620. ScriptReset handlerScriptReset = OnScriptReset;
  8621. if (handlerScriptReset != null)
  8622. {
  8623. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8624. }
  8625. return true;
  8626. }
  8627. #endregion Script Packets
  8628. #region Gesture Managment
  8629. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8630. {
  8631. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8632. #region Packet Session and User Check
  8633. if (m_checkPackets)
  8634. {
  8635. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8636. activateGesturePacket.AgentData.AgentID != AgentId)
  8637. return true;
  8638. }
  8639. #endregion
  8640. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8641. if (handlerActivateGesture != null)
  8642. {
  8643. handlerActivateGesture(this,
  8644. activateGesturePacket.Data[0].AssetID,
  8645. activateGesturePacket.Data[0].ItemID);
  8646. }
  8647. else m_log.Error("Null pointer for activateGesture");
  8648. return true;
  8649. }
  8650. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8651. {
  8652. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8653. #region Packet Session and User Check
  8654. if (m_checkPackets)
  8655. {
  8656. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8657. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8658. return true;
  8659. }
  8660. #endregion
  8661. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8662. if (handlerDeactivateGesture != null)
  8663. {
  8664. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8665. }
  8666. return true;
  8667. }
  8668. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8669. {
  8670. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8671. #region Packet Session and User Check
  8672. if (m_checkPackets)
  8673. {
  8674. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8675. objectOwnerPacket.AgentData.AgentID != AgentId)
  8676. return true;
  8677. }
  8678. #endregion
  8679. List<uint> localIDs = new List<uint>();
  8680. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8681. localIDs.Add(d.ObjectLocalID);
  8682. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8683. if (handlerObjectOwner != null)
  8684. {
  8685. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8686. }
  8687. return true;
  8688. }
  8689. #endregion Gesture Managment
  8690. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8691. {
  8692. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8693. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8694. {
  8695. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8696. AgentFOV handlerAgentFOV = OnAgentFOV;
  8697. if (handlerAgentFOV != null)
  8698. {
  8699. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8700. }
  8701. }
  8702. return true;
  8703. }
  8704. #region unimplemented handlers
  8705. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8706. {
  8707. // TODO: handle this packet
  8708. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8709. return true;
  8710. }
  8711. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8712. {
  8713. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8714. #region Packet Session and User Check
  8715. if (m_checkPackets)
  8716. {
  8717. if (mirpk.AgentData.SessionID != SessionId ||
  8718. mirpk.AgentData.AgentID != AgentId)
  8719. return true;
  8720. }
  8721. #endregion
  8722. //m_log.Debug(mirpk.ToString());
  8723. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8724. if (handlerMapItemRequest != null)
  8725. {
  8726. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8727. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8728. mirpk.RequestData.RegionHandle);
  8729. }
  8730. return true;
  8731. }
  8732. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8733. {
  8734. return true;
  8735. }
  8736. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8737. {
  8738. MuteListRequestPacket muteListRequest =
  8739. (MuteListRequestPacket)Pack;
  8740. #region Packet Session and User Check
  8741. if (m_checkPackets)
  8742. {
  8743. if (muteListRequest.AgentData.SessionID != SessionId ||
  8744. muteListRequest.AgentData.AgentID != AgentId)
  8745. return true;
  8746. }
  8747. #endregion
  8748. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8749. if (handlerMuteListRequest != null)
  8750. {
  8751. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8752. }
  8753. else
  8754. {
  8755. SendUseCachedMuteList();
  8756. }
  8757. return true;
  8758. }
  8759. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8760. {
  8761. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8762. (UpdateMuteListEntryPacket)Packet;
  8763. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8764. if (handlerUpdateMuteListEntry != null)
  8765. {
  8766. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8767. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8768. UpdateMuteListEntry.MuteData.MuteType,
  8769. UpdateMuteListEntry.AgentData.AgentID);
  8770. return true;
  8771. }
  8772. return false;
  8773. }
  8774. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8775. {
  8776. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8777. (RemoveMuteListEntryPacket)Packet;
  8778. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8779. if (handlerRemoveMuteListEntry != null)
  8780. {
  8781. handlerRemoveMuteListEntry(this,
  8782. RemoveMuteListEntry.MuteData.MuteID,
  8783. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8784. RemoveMuteListEntry.AgentData.AgentID);
  8785. return true;
  8786. }
  8787. return false;
  8788. }
  8789. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8790. {
  8791. UserReportPacket UserReport =
  8792. (UserReportPacket)Packet;
  8793. NewUserReport handlerUserReport = OnUserReport;
  8794. if (handlerUserReport != null)
  8795. {
  8796. handlerUserReport(this,
  8797. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8798. UserReport.ReportData.AbuserID,
  8799. UserReport.ReportData.Category,
  8800. UserReport.ReportData.CheckFlags,
  8801. Utils.BytesToString(UserReport.ReportData.Details),
  8802. UserReport.ReportData.ObjectID,
  8803. UserReport.ReportData.Position,
  8804. UserReport.ReportData.ReportType,
  8805. UserReport.ReportData.ScreenshotID,
  8806. Utils.BytesToString(UserReport.ReportData.Summary),
  8807. UserReport.AgentData.AgentID);
  8808. return true;
  8809. }
  8810. return false;
  8811. }
  8812. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8813. {
  8814. // SendPostcardPacket SendPostcard =
  8815. // (SendPostcardPacket)packet;
  8816. SendPostcard handlerSendPostcard = OnSendPostcard;
  8817. if (handlerSendPostcard != null)
  8818. {
  8819. handlerSendPostcard(this);
  8820. return true;
  8821. }
  8822. return false;
  8823. }
  8824. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8825. {
  8826. return true;
  8827. }
  8828. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8829. {
  8830. return true;
  8831. }
  8832. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8833. {
  8834. return true;
  8835. }
  8836. #endregion unimplemented handlers
  8837. #region Dir handlers
  8838. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8839. {
  8840. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8841. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8842. #region Packet Session and User Check
  8843. if (m_checkPackets)
  8844. {
  8845. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8846. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8847. return true;
  8848. }
  8849. #endregion
  8850. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8851. if (handlerDirPlacesQuery != null)
  8852. {
  8853. handlerDirPlacesQuery(this,
  8854. dirPlacesQueryPacket.QueryData.QueryID,
  8855. Utils.BytesToString(
  8856. dirPlacesQueryPacket.QueryData.QueryText),
  8857. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8858. (int)dirPlacesQueryPacket.QueryData.Category,
  8859. Utils.BytesToString(
  8860. dirPlacesQueryPacket.QueryData.SimName),
  8861. dirPlacesQueryPacket.QueryData.QueryStart);
  8862. }
  8863. return true;
  8864. }
  8865. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8866. {
  8867. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8868. #region Packet Session and User Check
  8869. if (m_checkPackets)
  8870. {
  8871. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8872. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8873. return true;
  8874. }
  8875. #endregion
  8876. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8877. if (handlerDirFindQuery != null)
  8878. {
  8879. handlerDirFindQuery(this,
  8880. dirFindQueryPacket.QueryData.QueryID,
  8881. Utils.BytesToString(
  8882. dirFindQueryPacket.QueryData.QueryText),
  8883. dirFindQueryPacket.QueryData.QueryFlags,
  8884. dirFindQueryPacket.QueryData.QueryStart);
  8885. }
  8886. return true;
  8887. }
  8888. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8889. {
  8890. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8891. #region Packet Session and User Check
  8892. if (m_checkPackets)
  8893. {
  8894. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8895. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8896. return true;
  8897. }
  8898. #endregion
  8899. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8900. if (handlerDirLandQuery != null)
  8901. {
  8902. handlerDirLandQuery(this,
  8903. dirLandQueryPacket.QueryData.QueryID,
  8904. dirLandQueryPacket.QueryData.QueryFlags,
  8905. dirLandQueryPacket.QueryData.SearchType,
  8906. dirLandQueryPacket.QueryData.Price,
  8907. dirLandQueryPacket.QueryData.Area,
  8908. dirLandQueryPacket.QueryData.QueryStart);
  8909. }
  8910. return true;
  8911. }
  8912. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8913. {
  8914. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8915. #region Packet Session and User Check
  8916. if (m_checkPackets)
  8917. {
  8918. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8919. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8920. return true;
  8921. }
  8922. #endregion
  8923. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8924. if (handlerDirPopularQuery != null)
  8925. {
  8926. handlerDirPopularQuery(this,
  8927. dirPopularQueryPacket.QueryData.QueryID,
  8928. dirPopularQueryPacket.QueryData.QueryFlags);
  8929. }
  8930. return true;
  8931. }
  8932. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8933. {
  8934. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8935. #region Packet Session and User Check
  8936. if (m_checkPackets)
  8937. {
  8938. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8939. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8940. return true;
  8941. }
  8942. #endregion
  8943. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8944. if (handlerDirClassifiedQuery != null)
  8945. {
  8946. handlerDirClassifiedQuery(this,
  8947. dirClassifiedQueryPacket.QueryData.QueryID,
  8948. Utils.BytesToString(
  8949. dirClassifiedQueryPacket.QueryData.QueryText),
  8950. dirClassifiedQueryPacket.QueryData.QueryFlags,
  8951. dirClassifiedQueryPacket.QueryData.Category,
  8952. dirClassifiedQueryPacket.QueryData.QueryStart);
  8953. }
  8954. return true;
  8955. }
  8956. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  8957. {
  8958. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  8959. #region Packet Session and User Check
  8960. if (m_checkPackets)
  8961. {
  8962. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  8963. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  8964. return true;
  8965. }
  8966. #endregion
  8967. if (OnEventInfoRequest != null)
  8968. {
  8969. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  8970. }
  8971. return true;
  8972. }
  8973. #endregion
  8974. #region Calling Card
  8975. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  8976. {
  8977. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  8978. #region Packet Session and User Check
  8979. if (m_checkPackets)
  8980. {
  8981. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  8982. offerCallingCardPacket.AgentData.AgentID != AgentId)
  8983. return true;
  8984. }
  8985. #endregion
  8986. if (OnOfferCallingCard != null)
  8987. {
  8988. OnOfferCallingCard(this,
  8989. offerCallingCardPacket.AgentBlock.DestID,
  8990. offerCallingCardPacket.AgentBlock.TransactionID);
  8991. }
  8992. return true;
  8993. }
  8994. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  8995. {
  8996. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  8997. #region Packet Session and User Check
  8998. if (m_checkPackets)
  8999. {
  9000. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9001. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9002. return true;
  9003. }
  9004. #endregion
  9005. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9006. // contain exactly one entry
  9007. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9008. {
  9009. OnAcceptCallingCard(this,
  9010. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9011. acceptCallingCardPacket.FolderData[0].FolderID);
  9012. }
  9013. return true;
  9014. }
  9015. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9016. {
  9017. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9018. #region Packet Session and User Check
  9019. if (m_checkPackets)
  9020. {
  9021. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9022. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9023. return true;
  9024. }
  9025. #endregion
  9026. if (OnDeclineCallingCard != null)
  9027. {
  9028. OnDeclineCallingCard(this,
  9029. declineCallingCardPacket.TransactionBlock.TransactionID);
  9030. }
  9031. return true;
  9032. }
  9033. #endregion Calling Card
  9034. #region Groups
  9035. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9036. {
  9037. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9038. #region Packet Session and User Check
  9039. if (m_checkPackets)
  9040. {
  9041. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9042. activateGroupPacket.AgentData.AgentID != AgentId)
  9043. return true;
  9044. }
  9045. #endregion
  9046. if (m_GroupsModule != null)
  9047. {
  9048. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9049. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9050. }
  9051. return true;
  9052. }
  9053. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9054. {
  9055. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9056. (GroupVoteHistoryRequestPacket)Packet;
  9057. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9058. if (handlerGroupVoteHistoryRequest != null)
  9059. {
  9060. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9061. return true;
  9062. }
  9063. return false;
  9064. }
  9065. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9066. {
  9067. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9068. (GroupActiveProposalsRequestPacket)Packet;
  9069. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9070. if (handlerGroupActiveProposalsRequest != null)
  9071. {
  9072. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9073. return true;
  9074. }
  9075. return false;
  9076. }
  9077. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9078. {
  9079. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9080. (GroupAccountDetailsRequestPacket)Packet;
  9081. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9082. if (handlerGroupAccountDetailsRequest != null)
  9083. {
  9084. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9085. return true;
  9086. }
  9087. return false;
  9088. }
  9089. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9090. {
  9091. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9092. (GroupAccountSummaryRequestPacket)Packet;
  9093. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9094. if (handlerGroupAccountSummaryRequest != null)
  9095. {
  9096. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9097. return true;
  9098. }
  9099. return false;
  9100. }
  9101. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9102. {
  9103. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9104. (GroupAccountTransactionsRequestPacket)Packet;
  9105. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9106. if (handlerGroupAccountTransactionsRequest != null)
  9107. {
  9108. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9109. return true;
  9110. }
  9111. return false;
  9112. }
  9113. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9114. {
  9115. GroupTitlesRequestPacket groupTitlesRequest =
  9116. (GroupTitlesRequestPacket)Pack;
  9117. #region Packet Session and User Check
  9118. if (m_checkPackets)
  9119. {
  9120. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9121. groupTitlesRequest.AgentData.AgentID != AgentId)
  9122. return true;
  9123. }
  9124. #endregion
  9125. if (m_GroupsModule != null)
  9126. {
  9127. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9128. groupTitlesReply.AgentData =
  9129. new GroupTitlesReplyPacket.AgentDataBlock();
  9130. groupTitlesReply.AgentData.AgentID = AgentId;
  9131. groupTitlesReply.AgentData.GroupID =
  9132. groupTitlesRequest.AgentData.GroupID;
  9133. groupTitlesReply.AgentData.RequestID =
  9134. groupTitlesRequest.AgentData.RequestID;
  9135. List<GroupTitlesData> titles =
  9136. m_GroupsModule.GroupTitlesRequest(this,
  9137. groupTitlesRequest.AgentData.GroupID);
  9138. groupTitlesReply.GroupData =
  9139. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9140. int i = 0;
  9141. foreach (GroupTitlesData d in titles)
  9142. {
  9143. groupTitlesReply.GroupData[i] =
  9144. new GroupTitlesReplyPacket.GroupDataBlock();
  9145. groupTitlesReply.GroupData[i].Title =
  9146. Util.StringToBytes256(d.Name);
  9147. groupTitlesReply.GroupData[i].RoleID =
  9148. d.UUID;
  9149. groupTitlesReply.GroupData[i].Selected =
  9150. d.Selected;
  9151. i++;
  9152. }
  9153. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9154. }
  9155. return true;
  9156. }
  9157. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9158. {
  9159. GroupProfileRequestPacket groupProfileRequest =
  9160. (GroupProfileRequestPacket)Pack;
  9161. #region Packet Session and User Check
  9162. if (m_checkPackets)
  9163. {
  9164. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9165. groupProfileRequest.AgentData.AgentID != AgentId)
  9166. return true;
  9167. }
  9168. #endregion
  9169. if (m_GroupsModule != null)
  9170. {
  9171. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9172. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9173. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9174. groupProfileReply.AgentData.AgentID = AgentId;
  9175. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9176. groupProfileRequest.GroupData.GroupID);
  9177. groupProfileReply.GroupData.GroupID = d.GroupID;
  9178. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9179. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9180. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9181. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9182. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9183. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9184. groupProfileReply.GroupData.FounderID = d.FounderID;
  9185. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9186. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9187. groupProfileReply.GroupData.Money = d.Money;
  9188. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9189. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9190. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9191. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9192. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9193. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9194. }
  9195. return true;
  9196. }
  9197. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9198. {
  9199. GroupMembersRequestPacket groupMembersRequestPacket =
  9200. (GroupMembersRequestPacket)Pack;
  9201. #region Packet Session and User Check
  9202. if (m_checkPackets)
  9203. {
  9204. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9205. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9206. return true;
  9207. }
  9208. #endregion
  9209. if (m_GroupsModule != null)
  9210. {
  9211. List<GroupMembersData> members =
  9212. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9213. int memberCount = members.Count;
  9214. while (true)
  9215. {
  9216. int blockCount = members.Count;
  9217. if (blockCount > 40)
  9218. blockCount = 40;
  9219. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9220. groupMembersReply.AgentData =
  9221. new GroupMembersReplyPacket.AgentDataBlock();
  9222. groupMembersReply.GroupData =
  9223. new GroupMembersReplyPacket.GroupDataBlock();
  9224. groupMembersReply.MemberData =
  9225. new GroupMembersReplyPacket.MemberDataBlock[
  9226. blockCount];
  9227. groupMembersReply.AgentData.AgentID = AgentId;
  9228. groupMembersReply.GroupData.GroupID =
  9229. groupMembersRequestPacket.GroupData.GroupID;
  9230. groupMembersReply.GroupData.RequestID =
  9231. groupMembersRequestPacket.GroupData.RequestID;
  9232. groupMembersReply.GroupData.MemberCount = memberCount;
  9233. for (int i = 0; i < blockCount; i++)
  9234. {
  9235. GroupMembersData m = members[0];
  9236. members.RemoveAt(0);
  9237. groupMembersReply.MemberData[i] =
  9238. new GroupMembersReplyPacket.MemberDataBlock();
  9239. groupMembersReply.MemberData[i].AgentID =
  9240. m.AgentID;
  9241. groupMembersReply.MemberData[i].Contribution =
  9242. m.Contribution;
  9243. groupMembersReply.MemberData[i].OnlineStatus =
  9244. Util.StringToBytes256(m.OnlineStatus);
  9245. groupMembersReply.MemberData[i].AgentPowers =
  9246. m.AgentPowers;
  9247. groupMembersReply.MemberData[i].Title =
  9248. Util.StringToBytes256(m.Title);
  9249. groupMembersReply.MemberData[i].IsOwner =
  9250. m.IsOwner;
  9251. }
  9252. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9253. if (members.Count == 0)
  9254. return true;
  9255. }
  9256. }
  9257. return true;
  9258. }
  9259. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9260. {
  9261. GroupRoleDataRequestPacket groupRolesRequest =
  9262. (GroupRoleDataRequestPacket)Pack;
  9263. #region Packet Session and User Check
  9264. if (m_checkPackets)
  9265. {
  9266. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9267. groupRolesRequest.AgentData.AgentID != AgentId)
  9268. return true;
  9269. }
  9270. #endregion
  9271. if (m_GroupsModule != null)
  9272. {
  9273. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9274. groupRolesReply.AgentData =
  9275. new GroupRoleDataReplyPacket.AgentDataBlock();
  9276. groupRolesReply.AgentData.AgentID = AgentId;
  9277. groupRolesReply.GroupData =
  9278. new GroupRoleDataReplyPacket.GroupDataBlock();
  9279. groupRolesReply.GroupData.GroupID =
  9280. groupRolesRequest.GroupData.GroupID;
  9281. groupRolesReply.GroupData.RequestID =
  9282. groupRolesRequest.GroupData.RequestID;
  9283. List<GroupRolesData> titles =
  9284. m_GroupsModule.GroupRoleDataRequest(this,
  9285. groupRolesRequest.GroupData.GroupID);
  9286. groupRolesReply.GroupData.RoleCount =
  9287. titles.Count;
  9288. groupRolesReply.RoleData =
  9289. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9290. int i = 0;
  9291. foreach (GroupRolesData d in titles)
  9292. {
  9293. groupRolesReply.RoleData[i] =
  9294. new GroupRoleDataReplyPacket.RoleDataBlock();
  9295. groupRolesReply.RoleData[i].RoleID =
  9296. d.RoleID;
  9297. groupRolesReply.RoleData[i].Name =
  9298. Util.StringToBytes256(d.Name);
  9299. groupRolesReply.RoleData[i].Title =
  9300. Util.StringToBytes256(d.Title);
  9301. groupRolesReply.RoleData[i].Description =
  9302. Util.StringToBytes1024(d.Description);
  9303. groupRolesReply.RoleData[i].Powers =
  9304. d.Powers;
  9305. groupRolesReply.RoleData[i].Members =
  9306. (uint)d.Members;
  9307. i++;
  9308. }
  9309. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9310. }
  9311. return true;
  9312. }
  9313. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9314. {
  9315. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9316. (GroupRoleMembersRequestPacket)Pack;
  9317. #region Packet Session and User Check
  9318. if (m_checkPackets)
  9319. {
  9320. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9321. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9322. return true;
  9323. }
  9324. #endregion
  9325. if (m_GroupsModule != null)
  9326. {
  9327. List<GroupRoleMembersData> mappings =
  9328. m_GroupsModule.GroupRoleMembersRequest(this,
  9329. groupRoleMembersRequest.GroupData.GroupID);
  9330. int mappingsCount = mappings.Count;
  9331. while (mappings.Count > 0)
  9332. {
  9333. int pairs = mappings.Count;
  9334. if (pairs > 32)
  9335. pairs = 32;
  9336. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9337. groupRoleMembersReply.AgentData =
  9338. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9339. groupRoleMembersReply.AgentData.AgentID =
  9340. AgentId;
  9341. groupRoleMembersReply.AgentData.GroupID =
  9342. groupRoleMembersRequest.GroupData.GroupID;
  9343. groupRoleMembersReply.AgentData.RequestID =
  9344. groupRoleMembersRequest.GroupData.RequestID;
  9345. groupRoleMembersReply.AgentData.TotalPairs =
  9346. (uint)mappingsCount;
  9347. groupRoleMembersReply.MemberData =
  9348. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9349. for (int i = 0; i < pairs; i++)
  9350. {
  9351. GroupRoleMembersData d = mappings[0];
  9352. mappings.RemoveAt(0);
  9353. groupRoleMembersReply.MemberData[i] =
  9354. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9355. groupRoleMembersReply.MemberData[i].RoleID =
  9356. d.RoleID;
  9357. groupRoleMembersReply.MemberData[i].MemberID =
  9358. d.MemberID;
  9359. }
  9360. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9361. }
  9362. }
  9363. return true;
  9364. }
  9365. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9366. {
  9367. CreateGroupRequestPacket createGroupRequest =
  9368. (CreateGroupRequestPacket)Pack;
  9369. #region Packet Session and User Check
  9370. if (m_checkPackets)
  9371. {
  9372. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9373. createGroupRequest.AgentData.AgentID != AgentId)
  9374. return true;
  9375. }
  9376. #endregion
  9377. if (m_GroupsModule != null)
  9378. {
  9379. m_GroupsModule.CreateGroup(this,
  9380. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9381. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9382. createGroupRequest.GroupData.ShowInList,
  9383. createGroupRequest.GroupData.InsigniaID,
  9384. createGroupRequest.GroupData.MembershipFee,
  9385. createGroupRequest.GroupData.OpenEnrollment,
  9386. createGroupRequest.GroupData.AllowPublish,
  9387. createGroupRequest.GroupData.MaturePublish);
  9388. }
  9389. return true;
  9390. }
  9391. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9392. {
  9393. UpdateGroupInfoPacket updateGroupInfo =
  9394. (UpdateGroupInfoPacket)Pack;
  9395. #region Packet Session and User Check
  9396. if (m_checkPackets)
  9397. {
  9398. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9399. updateGroupInfo.AgentData.AgentID != AgentId)
  9400. return true;
  9401. }
  9402. #endregion
  9403. if (m_GroupsModule != null)
  9404. {
  9405. m_GroupsModule.UpdateGroupInfo(this,
  9406. updateGroupInfo.GroupData.GroupID,
  9407. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9408. updateGroupInfo.GroupData.ShowInList,
  9409. updateGroupInfo.GroupData.InsigniaID,
  9410. updateGroupInfo.GroupData.MembershipFee,
  9411. updateGroupInfo.GroupData.OpenEnrollment,
  9412. updateGroupInfo.GroupData.AllowPublish,
  9413. updateGroupInfo.GroupData.MaturePublish);
  9414. }
  9415. return true;
  9416. }
  9417. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9418. {
  9419. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9420. (SetGroupAcceptNoticesPacket)Pack;
  9421. #region Packet Session and User Check
  9422. if (m_checkPackets)
  9423. {
  9424. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9425. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9426. return true;
  9427. }
  9428. #endregion
  9429. if (m_GroupsModule != null)
  9430. {
  9431. m_GroupsModule.SetGroupAcceptNotices(this,
  9432. setGroupAcceptNotices.Data.GroupID,
  9433. setGroupAcceptNotices.Data.AcceptNotices,
  9434. setGroupAcceptNotices.NewData.ListInProfile);
  9435. }
  9436. return true;
  9437. }
  9438. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9439. {
  9440. GroupTitleUpdatePacket groupTitleUpdate =
  9441. (GroupTitleUpdatePacket)Pack;
  9442. #region Packet Session and User Check
  9443. if (m_checkPackets)
  9444. {
  9445. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9446. groupTitleUpdate.AgentData.AgentID != AgentId)
  9447. return true;
  9448. }
  9449. #endregion
  9450. if (m_GroupsModule != null)
  9451. {
  9452. m_GroupsModule.GroupTitleUpdate(this,
  9453. groupTitleUpdate.AgentData.GroupID,
  9454. groupTitleUpdate.AgentData.TitleRoleID);
  9455. }
  9456. return true;
  9457. }
  9458. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9459. {
  9460. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9461. if (m_GroupsModule != null)
  9462. {
  9463. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9464. if (handlerParcelDeedToGroup != null)
  9465. {
  9466. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9467. }
  9468. }
  9469. return true;
  9470. }
  9471. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9472. {
  9473. GroupNoticesListRequestPacket groupNoticesListRequest =
  9474. (GroupNoticesListRequestPacket)Pack;
  9475. #region Packet Session and User Check
  9476. if (m_checkPackets)
  9477. {
  9478. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9479. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9480. return true;
  9481. }
  9482. #endregion
  9483. if (m_GroupsModule != null)
  9484. {
  9485. GroupNoticeData[] gn =
  9486. m_GroupsModule.GroupNoticesListRequest(this,
  9487. groupNoticesListRequest.Data.GroupID);
  9488. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9489. groupNoticesListReply.AgentData =
  9490. new GroupNoticesListReplyPacket.AgentDataBlock();
  9491. groupNoticesListReply.AgentData.AgentID = AgentId;
  9492. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9493. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9494. int i = 0;
  9495. foreach (GroupNoticeData g in gn)
  9496. {
  9497. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9498. groupNoticesListReply.Data[i].NoticeID =
  9499. g.NoticeID;
  9500. groupNoticesListReply.Data[i].Timestamp =
  9501. g.Timestamp;
  9502. groupNoticesListReply.Data[i].FromName =
  9503. Util.StringToBytes256(g.FromName);
  9504. groupNoticesListReply.Data[i].Subject =
  9505. Util.StringToBytes256(g.Subject);
  9506. groupNoticesListReply.Data[i].HasAttachment =
  9507. g.HasAttachment;
  9508. groupNoticesListReply.Data[i].AssetType =
  9509. g.AssetType;
  9510. i++;
  9511. }
  9512. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9513. }
  9514. return true;
  9515. }
  9516. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9517. {
  9518. GroupNoticeRequestPacket groupNoticeRequest =
  9519. (GroupNoticeRequestPacket)Pack;
  9520. #region Packet Session and User Check
  9521. if (m_checkPackets)
  9522. {
  9523. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9524. groupNoticeRequest.AgentData.AgentID != AgentId)
  9525. return true;
  9526. }
  9527. #endregion
  9528. if (m_GroupsModule != null)
  9529. {
  9530. m_GroupsModule.GroupNoticeRequest(this,
  9531. groupNoticeRequest.Data.GroupNoticeID);
  9532. }
  9533. return true;
  9534. }
  9535. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9536. {
  9537. GroupRoleUpdatePacket groupRoleUpdate =
  9538. (GroupRoleUpdatePacket)Pack;
  9539. #region Packet Session and User Check
  9540. if (m_checkPackets)
  9541. {
  9542. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9543. groupRoleUpdate.AgentData.AgentID != AgentId)
  9544. return true;
  9545. }
  9546. #endregion
  9547. if (m_GroupsModule != null)
  9548. {
  9549. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9550. groupRoleUpdate.RoleData)
  9551. {
  9552. m_GroupsModule.GroupRoleUpdate(this,
  9553. groupRoleUpdate.AgentData.GroupID,
  9554. d.RoleID,
  9555. Utils.BytesToString(d.Name),
  9556. Utils.BytesToString(d.Description),
  9557. Utils.BytesToString(d.Title),
  9558. d.Powers,
  9559. d.UpdateType);
  9560. }
  9561. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9562. }
  9563. return true;
  9564. }
  9565. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9566. {
  9567. GroupRoleChangesPacket groupRoleChanges =
  9568. (GroupRoleChangesPacket)Pack;
  9569. #region Packet Session and User Check
  9570. if (m_checkPackets)
  9571. {
  9572. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9573. groupRoleChanges.AgentData.AgentID != AgentId)
  9574. return true;
  9575. }
  9576. #endregion
  9577. if (m_GroupsModule != null)
  9578. {
  9579. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9580. groupRoleChanges.RoleChange)
  9581. {
  9582. m_GroupsModule.GroupRoleChanges(this,
  9583. groupRoleChanges.AgentData.GroupID,
  9584. d.RoleID,
  9585. d.MemberID,
  9586. d.Change);
  9587. }
  9588. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9589. }
  9590. return true;
  9591. }
  9592. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9593. {
  9594. JoinGroupRequestPacket joinGroupRequest =
  9595. (JoinGroupRequestPacket)Pack;
  9596. #region Packet Session and User Check
  9597. if (m_checkPackets)
  9598. {
  9599. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9600. joinGroupRequest.AgentData.AgentID != AgentId)
  9601. return true;
  9602. }
  9603. #endregion
  9604. if (m_GroupsModule != null)
  9605. {
  9606. m_GroupsModule.JoinGroupRequest(this,
  9607. joinGroupRequest.GroupData.GroupID);
  9608. }
  9609. return true;
  9610. }
  9611. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9612. {
  9613. LeaveGroupRequestPacket leaveGroupRequest =
  9614. (LeaveGroupRequestPacket)Pack;
  9615. #region Packet Session and User Check
  9616. if (m_checkPackets)
  9617. {
  9618. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9619. leaveGroupRequest.AgentData.AgentID != AgentId)
  9620. return true;
  9621. }
  9622. #endregion
  9623. if (m_GroupsModule != null)
  9624. {
  9625. m_GroupsModule.LeaveGroupRequest(this,
  9626. leaveGroupRequest.GroupData.GroupID);
  9627. }
  9628. return true;
  9629. }
  9630. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9631. {
  9632. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9633. (EjectGroupMemberRequestPacket)Pack;
  9634. #region Packet Session and User Check
  9635. if (m_checkPackets)
  9636. {
  9637. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9638. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9639. return true;
  9640. }
  9641. #endregion
  9642. if (m_GroupsModule != null)
  9643. {
  9644. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9645. in ejectGroupMemberRequest.EjectData)
  9646. {
  9647. m_GroupsModule.EjectGroupMemberRequest(this,
  9648. ejectGroupMemberRequest.GroupData.GroupID,
  9649. e.EjecteeID);
  9650. }
  9651. }
  9652. return true;
  9653. }
  9654. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9655. {
  9656. InviteGroupRequestPacket inviteGroupRequest =
  9657. (InviteGroupRequestPacket)Pack;
  9658. #region Packet Session and User Check
  9659. if (m_checkPackets)
  9660. {
  9661. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9662. inviteGroupRequest.AgentData.AgentID != AgentId)
  9663. return true;
  9664. }
  9665. #endregion
  9666. if (m_GroupsModule != null)
  9667. {
  9668. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9669. inviteGroupRequest.InviteData)
  9670. {
  9671. m_GroupsModule.InviteGroupRequest(this,
  9672. inviteGroupRequest.GroupData.GroupID,
  9673. b.InviteeID,
  9674. b.RoleID);
  9675. }
  9676. }
  9677. return true;
  9678. }
  9679. #endregion Groups
  9680. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9681. {
  9682. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9683. #region Packet Session and User Check
  9684. if (m_checkPackets)
  9685. {
  9686. if (startLureRequest.AgentData.SessionID != SessionId ||
  9687. startLureRequest.AgentData.AgentID != AgentId)
  9688. return true;
  9689. }
  9690. #endregion
  9691. StartLure handlerStartLure = OnStartLure;
  9692. if (handlerStartLure != null)
  9693. handlerStartLure(startLureRequest.Info.LureType,
  9694. Utils.BytesToString(
  9695. startLureRequest.Info.Message),
  9696. startLureRequest.TargetData[0].TargetID,
  9697. this);
  9698. return true;
  9699. }
  9700. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9701. {
  9702. TeleportLureRequestPacket teleportLureRequest =
  9703. (TeleportLureRequestPacket)Pack;
  9704. #region Packet Session and User Check
  9705. if (m_checkPackets)
  9706. {
  9707. if (teleportLureRequest.Info.SessionID != SessionId ||
  9708. teleportLureRequest.Info.AgentID != AgentId)
  9709. return true;
  9710. }
  9711. #endregion
  9712. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9713. if (handlerTeleportLureRequest != null)
  9714. handlerTeleportLureRequest(
  9715. teleportLureRequest.Info.LureID,
  9716. teleportLureRequest.Info.TeleportFlags,
  9717. this);
  9718. return true;
  9719. }
  9720. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9721. {
  9722. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9723. (ClassifiedInfoRequestPacket)Pack;
  9724. #region Packet Session and User Check
  9725. if (m_checkPackets)
  9726. {
  9727. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9728. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9729. return true;
  9730. }
  9731. #endregion
  9732. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9733. if (handlerClassifiedInfoRequest != null)
  9734. handlerClassifiedInfoRequest(
  9735. classifiedInfoRequest.Data.ClassifiedID,
  9736. this);
  9737. return true;
  9738. }
  9739. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9740. {
  9741. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9742. (ClassifiedInfoUpdatePacket)Pack;
  9743. #region Packet Session and User Check
  9744. if (m_checkPackets)
  9745. {
  9746. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9747. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9748. return true;
  9749. }
  9750. #endregion
  9751. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9752. if (handlerClassifiedInfoUpdate != null)
  9753. handlerClassifiedInfoUpdate(
  9754. classifiedInfoUpdate.Data.ClassifiedID,
  9755. classifiedInfoUpdate.Data.Category,
  9756. Utils.BytesToString(
  9757. classifiedInfoUpdate.Data.Name),
  9758. Utils.BytesToString(
  9759. classifiedInfoUpdate.Data.Desc),
  9760. classifiedInfoUpdate.Data.ParcelID,
  9761. classifiedInfoUpdate.Data.ParentEstate,
  9762. classifiedInfoUpdate.Data.SnapshotID,
  9763. new Vector3(
  9764. classifiedInfoUpdate.Data.PosGlobal),
  9765. classifiedInfoUpdate.Data.ClassifiedFlags,
  9766. classifiedInfoUpdate.Data.PriceForListing,
  9767. this);
  9768. return true;
  9769. }
  9770. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9771. {
  9772. ClassifiedDeletePacket classifiedDelete =
  9773. (ClassifiedDeletePacket)Pack;
  9774. #region Packet Session and User Check
  9775. if (m_checkPackets)
  9776. {
  9777. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9778. classifiedDelete.AgentData.AgentID != AgentId)
  9779. return true;
  9780. }
  9781. #endregion
  9782. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9783. if (handlerClassifiedDelete != null)
  9784. handlerClassifiedDelete(
  9785. classifiedDelete.Data.ClassifiedID,
  9786. this);
  9787. return true;
  9788. }
  9789. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9790. {
  9791. ClassifiedGodDeletePacket classifiedGodDelete =
  9792. (ClassifiedGodDeletePacket)Pack;
  9793. #region Packet Session and User Check
  9794. if (m_checkPackets)
  9795. {
  9796. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9797. classifiedGodDelete.AgentData.AgentID != AgentId)
  9798. return true;
  9799. }
  9800. #endregion
  9801. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9802. if (handlerClassifiedGodDelete != null)
  9803. handlerClassifiedGodDelete(
  9804. classifiedGodDelete.Data.ClassifiedID,
  9805. this);
  9806. return true;
  9807. }
  9808. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9809. {
  9810. EventGodDeletePacket eventGodDelete =
  9811. (EventGodDeletePacket)Pack;
  9812. #region Packet Session and User Check
  9813. if (m_checkPackets)
  9814. {
  9815. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9816. eventGodDelete.AgentData.AgentID != AgentId)
  9817. return true;
  9818. }
  9819. #endregion
  9820. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9821. if (handlerEventGodDelete != null)
  9822. handlerEventGodDelete(
  9823. eventGodDelete.EventData.EventID,
  9824. eventGodDelete.QueryData.QueryID,
  9825. Utils.BytesToString(
  9826. eventGodDelete.QueryData.QueryText),
  9827. eventGodDelete.QueryData.QueryFlags,
  9828. eventGodDelete.QueryData.QueryStart,
  9829. this);
  9830. return true;
  9831. }
  9832. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9833. {
  9834. EventNotificationAddRequestPacket eventNotificationAdd =
  9835. (EventNotificationAddRequestPacket)Pack;
  9836. #region Packet Session and User Check
  9837. if (m_checkPackets)
  9838. {
  9839. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9840. eventNotificationAdd.AgentData.AgentID != AgentId)
  9841. return true;
  9842. }
  9843. #endregion
  9844. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9845. if (handlerEventNotificationAddRequest != null)
  9846. handlerEventNotificationAddRequest(
  9847. eventNotificationAdd.EventData.EventID, this);
  9848. return true;
  9849. }
  9850. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9851. {
  9852. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9853. (EventNotificationRemoveRequestPacket)Pack;
  9854. #region Packet Session and User Check
  9855. if (m_checkPackets)
  9856. {
  9857. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9858. eventNotificationRemove.AgentData.AgentID != AgentId)
  9859. return true;
  9860. }
  9861. #endregion
  9862. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9863. if (handlerEventNotificationRemoveRequest != null)
  9864. handlerEventNotificationRemoveRequest(
  9865. eventNotificationRemove.EventData.EventID, this);
  9866. return true;
  9867. }
  9868. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9869. {
  9870. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9871. #region Packet Session and User Check
  9872. if (m_checkPackets)
  9873. {
  9874. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9875. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9876. return true;
  9877. }
  9878. #endregion
  9879. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9880. if (handlerRetrieveInstantMessages != null)
  9881. handlerRetrieveInstantMessages(this);
  9882. return true;
  9883. }
  9884. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9885. {
  9886. PickDeletePacket pickDelete =
  9887. (PickDeletePacket)Pack;
  9888. #region Packet Session and User Check
  9889. if (m_checkPackets)
  9890. {
  9891. if (pickDelete.AgentData.SessionID != SessionId ||
  9892. pickDelete.AgentData.AgentID != AgentId)
  9893. return true;
  9894. }
  9895. #endregion
  9896. PickDelete handlerPickDelete = OnPickDelete;
  9897. if (handlerPickDelete != null)
  9898. handlerPickDelete(this, pickDelete.Data.PickID);
  9899. return true;
  9900. }
  9901. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9902. {
  9903. PickGodDeletePacket pickGodDelete =
  9904. (PickGodDeletePacket)Pack;
  9905. #region Packet Session and User Check
  9906. if (m_checkPackets)
  9907. {
  9908. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9909. pickGodDelete.AgentData.AgentID != AgentId)
  9910. return true;
  9911. }
  9912. #endregion
  9913. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9914. if (handlerPickGodDelete != null)
  9915. handlerPickGodDelete(this,
  9916. pickGodDelete.AgentData.AgentID,
  9917. pickGodDelete.Data.PickID,
  9918. pickGodDelete.Data.QueryID);
  9919. return true;
  9920. }
  9921. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9922. {
  9923. PickInfoUpdatePacket pickInfoUpdate =
  9924. (PickInfoUpdatePacket)Pack;
  9925. #region Packet Session and User Check
  9926. if (m_checkPackets)
  9927. {
  9928. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9929. pickInfoUpdate.AgentData.AgentID != AgentId)
  9930. return true;
  9931. }
  9932. #endregion
  9933. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9934. if (handlerPickInfoUpdate != null)
  9935. handlerPickInfoUpdate(this,
  9936. pickInfoUpdate.Data.PickID,
  9937. pickInfoUpdate.Data.CreatorID,
  9938. pickInfoUpdate.Data.TopPick,
  9939. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9940. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9941. pickInfoUpdate.Data.SnapshotID,
  9942. pickInfoUpdate.Data.SortOrder,
  9943. pickInfoUpdate.Data.Enabled);
  9944. return true;
  9945. }
  9946. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9947. {
  9948. AvatarNotesUpdatePacket avatarNotesUpdate =
  9949. (AvatarNotesUpdatePacket)Pack;
  9950. #region Packet Session and User Check
  9951. if (m_checkPackets)
  9952. {
  9953. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  9954. avatarNotesUpdate.AgentData.AgentID != AgentId)
  9955. return true;
  9956. }
  9957. #endregion
  9958. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  9959. if (handlerAvatarNotesUpdate != null)
  9960. handlerAvatarNotesUpdate(this,
  9961. avatarNotesUpdate.Data.TargetID,
  9962. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  9963. return true;
  9964. }
  9965. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  9966. {
  9967. AvatarInterestsUpdatePacket avatarInterestUpdate =
  9968. (AvatarInterestsUpdatePacket)Pack;
  9969. #region Packet Session and User Check
  9970. if (m_checkPackets)
  9971. {
  9972. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  9973. avatarInterestUpdate.AgentData.AgentID != AgentId)
  9974. return true;
  9975. }
  9976. #endregion
  9977. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  9978. if (handlerAvatarInterestUpdate != null)
  9979. handlerAvatarInterestUpdate(this,
  9980. avatarInterestUpdate.PropertiesData.WantToMask,
  9981. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  9982. avatarInterestUpdate.PropertiesData.SkillsMask,
  9983. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  9984. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  9985. return true;
  9986. }
  9987. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  9988. {
  9989. GrantUserRightsPacket GrantUserRights =
  9990. (GrantUserRightsPacket)Pack;
  9991. #region Packet Session and User Check
  9992. if (m_checkPackets)
  9993. {
  9994. if (GrantUserRights.AgentData.SessionID != SessionId ||
  9995. GrantUserRights.AgentData.AgentID != AgentId)
  9996. return true;
  9997. }
  9998. #endregion
  9999. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10000. if (GrantUserRightsHandler != null)
  10001. GrantUserRightsHandler(this,
  10002. GrantUserRights.Rights[0].AgentRelated,
  10003. GrantUserRights.Rights[0].RelatedRights);
  10004. return true;
  10005. }
  10006. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10007. {
  10008. PlacesQueryPacket placesQueryPacket =
  10009. (PlacesQueryPacket)Pack;
  10010. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10011. if (handlerPlacesQuery != null)
  10012. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10013. placesQueryPacket.TransactionData.TransactionID,
  10014. Utils.BytesToString(
  10015. placesQueryPacket.QueryData.QueryText),
  10016. placesQueryPacket.QueryData.QueryFlags,
  10017. (byte)placesQueryPacket.QueryData.Category,
  10018. Utils.BytesToString(
  10019. placesQueryPacket.QueryData.SimName),
  10020. this);
  10021. return true;
  10022. }
  10023. #endregion Packet Handlers
  10024. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10025. {
  10026. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10027. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10028. // TODO: don't create new blocks if recycling an old packet
  10029. scriptQuestion.Data.TaskID = taskID;
  10030. scriptQuestion.Data.ItemID = itemID;
  10031. scriptQuestion.Data.Questions = question;
  10032. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10033. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10034. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10035. }
  10036. /// <summary>
  10037. /// Handler called when we receive a logout packet.
  10038. /// </summary>
  10039. /// <param name="client"></param>
  10040. /// <param name="packet"></param>
  10041. /// <returns></returns>
  10042. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10043. {
  10044. if (packet.Type == PacketType.LogoutRequest)
  10045. {
  10046. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10047. }
  10048. return Logout(client);
  10049. }
  10050. /// <summary>
  10051. ///
  10052. /// </summary>
  10053. /// <param name="client"></param>
  10054. /// <returns></returns>
  10055. protected virtual bool Logout(IClientAPI client)
  10056. {
  10057. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10058. Action<IClientAPI> handlerLogout = OnLogout;
  10059. if (handlerLogout != null)
  10060. {
  10061. handlerLogout(client);
  10062. }
  10063. return true;
  10064. }
  10065. /// <summary>
  10066. /// </summary>
  10067. /// <remarks>
  10068. /// At the moment, we always reply that there is no cached texture.
  10069. /// </remarks>
  10070. /// <param name="simclient"></param>
  10071. /// <param name="packet"></param>
  10072. /// <returns></returns>
  10073. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10074. {
  10075. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10076. if (cachedtex.AgentData.SessionID != SessionId)
  10077. return false;
  10078. List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
  10079. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  10080. {
  10081. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  10082. arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
  10083. arg.WearableHashID = cachedtex.WearableData[i].ID;
  10084. requestArgs.Add(arg);
  10085. }
  10086. try
  10087. {
  10088. CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
  10089. if (handlerCachedTextureRequest != null)
  10090. {
  10091. handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
  10092. }
  10093. }
  10094. catch (Exception e)
  10095. {
  10096. m_log.ErrorFormat("[CLIENT VIEW]: AgentTextureCached packet handler threw an exception, {0}", e);
  10097. return false;
  10098. }
  10099. return true;
  10100. }
  10101. /// <summary>
  10102. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10103. /// its appearance texture cached.
  10104. /// </summary>
  10105. /// <param name="avatar"></param>
  10106. /// <param name="serial"></param>
  10107. /// <param name="cachedTextures"></param>
  10108. /// <returns></returns>
  10109. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10110. {
  10111. ScenePresence presence = avatar as ScenePresence;
  10112. if (presence == null)
  10113. return;
  10114. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10115. // TODO: don't create new blocks if recycling an old packet
  10116. cachedresp.AgentData.AgentID = m_agentId;
  10117. cachedresp.AgentData.SessionID = m_sessionId;
  10118. cachedresp.AgentData.SerialNum = serial;
  10119. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10120. for (int i = 0; i < cachedTextures.Count; i++)
  10121. {
  10122. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10123. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10124. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10125. cachedresp.WearableData[i].HostName = new byte[0];
  10126. }
  10127. cachedresp.Header.Zerocoded = true;
  10128. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10129. }
  10130. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10131. {
  10132. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10133. if (multipleupdate.AgentData.SessionID != SessionId)
  10134. return false;
  10135. // m_log.DebugFormat(
  10136. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10137. Scene tScene = (Scene)m_scene;
  10138. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10139. {
  10140. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10141. // Can't act on Null Data
  10142. if (block.Data != null)
  10143. {
  10144. uint localId = block.ObjectLocalID;
  10145. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10146. if (part == null)
  10147. {
  10148. // It's a ghost! tell the client to delete it from view.
  10149. simClient.SendKillObject(new List<uint> { localId });
  10150. }
  10151. else
  10152. {
  10153. // m_log.DebugFormat(
  10154. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10155. // i, block.Type, part.Name, part.LocalId);
  10156. // // Do this once since fetch parts creates a new array.
  10157. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10158. // for (int j = 0; j < parts.Length; j++)
  10159. // {
  10160. // part.StoreUndoState();
  10161. // parts[j].IgnoreUndoUpdate = true;
  10162. // }
  10163. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10164. switch (block.Type)
  10165. {
  10166. case 1:
  10167. Vector3 pos1 = new Vector3(block.Data, 0);
  10168. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10169. if (handlerUpdatePrimSinglePosition != null)
  10170. {
  10171. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10172. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10173. }
  10174. break;
  10175. case 2:
  10176. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10177. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10178. if (handlerUpdatePrimSingleRotation != null)
  10179. {
  10180. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10181. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10182. }
  10183. break;
  10184. case 3:
  10185. Vector3 rotPos = new Vector3(block.Data, 0);
  10186. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10187. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10188. if (handlerUpdatePrimSingleRotationPosition != null)
  10189. {
  10190. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10191. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10192. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10193. }
  10194. break;
  10195. case 4:
  10196. case 20:
  10197. Vector3 scale4 = new Vector3(block.Data, 0);
  10198. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10199. if (handlerUpdatePrimScale != null)
  10200. {
  10201. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10202. handlerUpdatePrimScale(localId, scale4, this);
  10203. }
  10204. break;
  10205. case 5:
  10206. Vector3 scale1 = new Vector3(block.Data, 12);
  10207. Vector3 pos11 = new Vector3(block.Data, 0);
  10208. handlerUpdatePrimScale = OnUpdatePrimScale;
  10209. if (handlerUpdatePrimScale != null)
  10210. {
  10211. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10212. handlerUpdatePrimScale(localId, scale1, this);
  10213. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10214. if (handlerUpdatePrimSinglePosition != null)
  10215. {
  10216. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10217. }
  10218. }
  10219. break;
  10220. case 9:
  10221. Vector3 pos2 = new Vector3(block.Data, 0);
  10222. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10223. if (handlerUpdateVector != null)
  10224. {
  10225. handlerUpdateVector(localId, pos2, this);
  10226. }
  10227. break;
  10228. case 10:
  10229. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10230. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10231. if (handlerUpdatePrimRotation != null)
  10232. {
  10233. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10234. handlerUpdatePrimRotation(localId, rot3, this);
  10235. }
  10236. break;
  10237. case 11:
  10238. Vector3 pos3 = new Vector3(block.Data, 0);
  10239. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10240. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10241. if (handlerUpdatePrimGroupRotation != null)
  10242. {
  10243. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10244. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10245. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10246. }
  10247. break;
  10248. case 12:
  10249. case 28:
  10250. Vector3 scale7 = new Vector3(block.Data, 0);
  10251. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10252. if (handlerUpdatePrimGroupScale != null)
  10253. {
  10254. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10255. handlerUpdatePrimGroupScale(localId, scale7, this);
  10256. }
  10257. break;
  10258. case 13:
  10259. Vector3 scale2 = new Vector3(block.Data, 12);
  10260. Vector3 pos4 = new Vector3(block.Data, 0);
  10261. handlerUpdatePrimScale = OnUpdatePrimScale;
  10262. if (handlerUpdatePrimScale != null)
  10263. {
  10264. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10265. handlerUpdatePrimScale(localId, scale2, this);
  10266. // Change the position based on scale (for bug number 246)
  10267. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10268. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10269. if (handlerUpdatePrimSinglePosition != null)
  10270. {
  10271. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10272. }
  10273. }
  10274. break;
  10275. case 29:
  10276. Vector3 scale5 = new Vector3(block.Data, 12);
  10277. Vector3 pos5 = new Vector3(block.Data, 0);
  10278. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10279. if (handlerUpdatePrimGroupScale != null)
  10280. {
  10281. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10282. part.StoreUndoState(true);
  10283. part.IgnoreUndoUpdate = true;
  10284. handlerUpdatePrimGroupScale(localId, scale5, this);
  10285. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10286. if (handlerUpdateVector != null)
  10287. {
  10288. handlerUpdateVector(localId, pos5, this);
  10289. }
  10290. part.IgnoreUndoUpdate = false;
  10291. }
  10292. break;
  10293. case 21:
  10294. Vector3 scale6 = new Vector3(block.Data, 12);
  10295. Vector3 pos6 = new Vector3(block.Data, 0);
  10296. handlerUpdatePrimScale = OnUpdatePrimScale;
  10297. if (handlerUpdatePrimScale != null)
  10298. {
  10299. part.StoreUndoState(false);
  10300. part.IgnoreUndoUpdate = true;
  10301. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10302. handlerUpdatePrimScale(localId, scale6, this);
  10303. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10304. if (handlerUpdatePrimSinglePosition != null)
  10305. {
  10306. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10307. }
  10308. part.IgnoreUndoUpdate = false;
  10309. }
  10310. break;
  10311. default:
  10312. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10313. break;
  10314. }
  10315. // for (int j = 0; j < parts.Length; j++)
  10316. // parts[j].IgnoreUndoUpdate = false;
  10317. }
  10318. }
  10319. }
  10320. return true;
  10321. }
  10322. public void RequestMapLayer()
  10323. {
  10324. //should be getting the map layer from the grid server
  10325. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10326. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10327. // TODO: don't create new blocks if recycling an old packet
  10328. mapReply.AgentData.AgentID = AgentId;
  10329. mapReply.AgentData.Flags = 0;
  10330. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10331. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10332. mapReply.LayerData[0].Bottom = 0;
  10333. mapReply.LayerData[0].Left = 0;
  10334. mapReply.LayerData[0].Top = 30000;
  10335. mapReply.LayerData[0].Right = 30000;
  10336. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10337. mapReply.Header.Zerocoded = true;
  10338. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10339. }
  10340. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10341. {
  10342. /*
  10343. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10344. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10345. mbReply.AgentData.AgentId = AgentId;
  10346. int len;
  10347. if (simMapProfiles == null)
  10348. len = 0;
  10349. else
  10350. len = simMapProfiles.Count;
  10351. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10352. int iii;
  10353. for (iii = 0; iii < len; iii++)
  10354. {
  10355. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10356. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10357. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10358. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10359. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10360. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10361. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10362. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10363. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10364. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10365. }
  10366. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10367. */
  10368. }
  10369. /// <summary>
  10370. /// Sets the throttles from values supplied by the client
  10371. /// </summary>
  10372. /// <param name="throttles"></param>
  10373. public void SetChildAgentThrottle(byte[] throttles)
  10374. {
  10375. m_udpClient.SetThrottles(throttles);
  10376. }
  10377. /// <summary>
  10378. /// Get the current throttles for this client as a packed byte array
  10379. /// </summary>
  10380. /// <param name="multiplier">Unused</param>
  10381. /// <returns></returns>
  10382. public byte[] GetThrottlesPacked(float multiplier)
  10383. {
  10384. return m_udpClient.GetThrottlesPacked(multiplier);
  10385. }
  10386. /// <summary>
  10387. /// Cruft?
  10388. /// </summary>
  10389. public virtual void InPacket(object NewPack)
  10390. {
  10391. throw new NotImplementedException();
  10392. }
  10393. /// <summary>
  10394. /// This is the starting point for sending a simulator packet out to the client
  10395. /// </summary>
  10396. /// <param name="packet">Packet to send</param>
  10397. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10398. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10399. {
  10400. #region BinaryStats
  10401. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10402. #endregion BinaryStats
  10403. OutPacket(packet, throttlePacketType, true);
  10404. }
  10405. /// <summary>
  10406. /// This is the starting point for sending a simulator packet out to the client
  10407. /// </summary>
  10408. /// <param name="packet">Packet to send</param>
  10409. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10410. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10411. /// packets (the default), or false to disable splitting if the calling code
  10412. /// handles splitting manually</param>
  10413. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10414. {
  10415. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10416. }
  10417. /// <summary>
  10418. /// This is the starting point for sending a simulator packet out to the client
  10419. /// </summary>
  10420. /// <param name="packet">Packet to send</param>
  10421. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10422. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10423. /// packets (the default), or false to disable splitting if the calling code
  10424. /// handles splitting manually</param>
  10425. /// <param name="method">The method to be called in the event this packet is reliable
  10426. /// and unacknowledged. The server will provide normal resend capability if you do not
  10427. /// provide your own method.</param>
  10428. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10429. {
  10430. if (DebugPacketLevel > 0)
  10431. {
  10432. bool logPacket = true;
  10433. if (DebugPacketLevel <= 255
  10434. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10435. logPacket = false;
  10436. if (DebugPacketLevel <= 200
  10437. && (packet.Type == PacketType.ImagePacket
  10438. || packet.Type == PacketType.ImageData
  10439. || packet.Type == PacketType.LayerData
  10440. || packet.Type == PacketType.CoarseLocationUpdate))
  10441. logPacket = false;
  10442. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10443. logPacket = false;
  10444. if (DebugPacketLevel <= 50
  10445. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10446. logPacket = false;
  10447. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10448. logPacket = false;
  10449. if (logPacket)
  10450. m_log.DebugFormat(
  10451. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10452. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10453. }
  10454. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10455. }
  10456. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10457. {
  10458. float locx = 0;
  10459. float locy = 0;
  10460. float locz = 0;
  10461. uint regionX = 0;
  10462. uint regionY = 0;
  10463. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10464. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10465. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10466. locz = Convert.ToSingle(args[2]);
  10467. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10468. if (handlerAutoPilotGo != null)
  10469. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10470. }
  10471. /// <summary>
  10472. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10473. /// </summary>
  10474. /// <param name="Pack">OpenMetaverse.packet</param>
  10475. public void ProcessInPacket(Packet packet)
  10476. {
  10477. if (DebugPacketLevel > 0)
  10478. {
  10479. bool logPacket = true;
  10480. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10481. logPacket = false;
  10482. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10483. logPacket = false;
  10484. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10485. logPacket = false;
  10486. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10487. logPacket = false;
  10488. if (logPacket)
  10489. m_log.DebugFormat(
  10490. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10491. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10492. }
  10493. if (!ProcessPacketMethod(packet))
  10494. m_log.WarnFormat(
  10495. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10496. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10497. }
  10498. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10499. {
  10500. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10501. shape.PCode = addPacket.ObjectData.PCode;
  10502. shape.State = addPacket.ObjectData.State;
  10503. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10504. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10505. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10506. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10507. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10508. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10509. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10510. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10511. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10512. shape.Scale = addPacket.ObjectData.Scale;
  10513. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10514. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10515. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10516. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10517. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10518. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10519. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10520. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10521. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10522. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10523. shape.TextureEntry = ntex.GetBytes();
  10524. //shape.Textures = ntex;
  10525. return shape;
  10526. }
  10527. public ClientInfo GetClientInfo()
  10528. {
  10529. ClientInfo info = m_udpClient.GetClientInfo();
  10530. info.proxyEP = null;
  10531. if (info.agentcircuit == null)
  10532. info.agentcircuit = RequestClientInfo();
  10533. return info;
  10534. }
  10535. public void SetClientInfo(ClientInfo info)
  10536. {
  10537. m_udpClient.SetClientInfo(info);
  10538. }
  10539. #region Media Parcel Members
  10540. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10541. {
  10542. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10543. commandMessagePacket.CommandBlock.Flags = flags;
  10544. commandMessagePacket.CommandBlock.Command = (uint)command;
  10545. commandMessagePacket.CommandBlock.Time = time;
  10546. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10547. }
  10548. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10549. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10550. byte mediaLoop)
  10551. {
  10552. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10553. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10554. updatePacket.DataBlock.MediaID = mediaTextureID;
  10555. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10556. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10557. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10558. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10559. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10560. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10561. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10562. }
  10563. #endregion
  10564. #region Camera
  10565. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10566. {
  10567. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10568. packet.ObjectData.ObjectID = objectID;
  10569. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10570. uint idx = 0;
  10571. foreach (KeyValuePair<int, float> pair in parameters)
  10572. {
  10573. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10574. block.Type = pair.Key;
  10575. block.Value = pair.Value;
  10576. camPropBlock[idx++] = block;
  10577. }
  10578. packet.CameraProperty = camPropBlock;
  10579. OutPacket(packet, ThrottleOutPacketType.Task);
  10580. }
  10581. public void SendClearFollowCamProperties(UUID objectID)
  10582. {
  10583. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10584. packet.ObjectData.ObjectID = objectID;
  10585. OutPacket(packet, ThrottleOutPacketType.Task);
  10586. }
  10587. #endregion
  10588. public void SetClientOption(string option, string value)
  10589. {
  10590. switch (option)
  10591. {
  10592. default:
  10593. break;
  10594. }
  10595. }
  10596. public string GetClientOption(string option)
  10597. {
  10598. switch (option)
  10599. {
  10600. default:
  10601. break;
  10602. }
  10603. return string.Empty;
  10604. }
  10605. #region IClientCore
  10606. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10607. /// <summary>
  10608. /// Register an interface on this client, should only be called in the constructor.
  10609. /// </summary>
  10610. /// <typeparam name="T"></typeparam>
  10611. /// <param name="iface"></param>
  10612. protected void RegisterInterface<T>(T iface)
  10613. {
  10614. lock (m_clientInterfaces)
  10615. {
  10616. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10617. {
  10618. m_clientInterfaces.Add(typeof(T), iface);
  10619. }
  10620. }
  10621. }
  10622. public bool TryGet<T>(out T iface)
  10623. {
  10624. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10625. {
  10626. iface = (T)m_clientInterfaces[typeof(T)];
  10627. return true;
  10628. }
  10629. iface = default(T);
  10630. return false;
  10631. }
  10632. public T Get<T>()
  10633. {
  10634. return (T)m_clientInterfaces[typeof(T)];
  10635. }
  10636. public void Disconnect(string reason)
  10637. {
  10638. Kick(reason);
  10639. Thread.Sleep(1000);
  10640. Disconnect();
  10641. }
  10642. public void Disconnect()
  10643. {
  10644. Close();
  10645. }
  10646. #endregion
  10647. public void RefreshGroupMembership()
  10648. {
  10649. if (m_GroupsModule != null)
  10650. {
  10651. GroupMembershipData[] GroupMembership =
  10652. m_GroupsModule.GetMembershipData(AgentId);
  10653. m_groupPowers.Clear();
  10654. if (GroupMembership != null)
  10655. {
  10656. for (int i = 0; i < GroupMembership.Length; i++)
  10657. {
  10658. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10659. }
  10660. }
  10661. }
  10662. }
  10663. public string Report()
  10664. {
  10665. return m_udpClient.GetStats();
  10666. }
  10667. public string XReport(string uptime, string version)
  10668. {
  10669. return String.Empty;
  10670. }
  10671. public OSDMap OReport(string uptime, string version)
  10672. {
  10673. return new OSDMap();
  10674. }
  10675. /// <summary>
  10676. /// Make an asset request to the asset service in response to a client request.
  10677. /// </summary>
  10678. /// <param name="transferRequest"></param>
  10679. /// <param name="taskID"></param>
  10680. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10681. {
  10682. UUID requestID = UUID.Zero;
  10683. int sourceType = transferRequest.TransferInfo.SourceType;
  10684. if (sourceType == (int)SourceType.Asset)
  10685. {
  10686. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10687. }
  10688. else if (sourceType == (int)SourceType.SimInventoryItem)
  10689. {
  10690. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10691. }
  10692. else if (sourceType == (int)SourceType.SimEstate)
  10693. {
  10694. requestID = taskID;
  10695. }
  10696. // m_log.DebugFormat(
  10697. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10698. // requestID, taskID, (SourceType)sourceType, Name);
  10699. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10700. }
  10701. /// <summary>
  10702. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10703. /// </summary>
  10704. /// <param name="id"></param>
  10705. /// <param name="sender"></param>
  10706. /// <param name="asset"></param>
  10707. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10708. {
  10709. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10710. UUID requestID = UUID.Zero;
  10711. byte source = (byte)SourceType.Asset;
  10712. AssetRequestToClient req = new AssetRequestToClient();
  10713. if (asset == null)
  10714. {
  10715. req.AssetInf = null;
  10716. req.AssetRequestSource = source;
  10717. req.IsTextureRequest = false;
  10718. req.NumPackets = 0;
  10719. req.Params = transferRequest.TransferInfo.Params;
  10720. req.RequestAssetID = requestID;
  10721. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10722. SendAssetNotFound(req);
  10723. return;
  10724. }
  10725. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10726. {
  10727. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10728. }
  10729. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10730. {
  10731. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10732. source = (byte)SourceType.SimInventoryItem;
  10733. //m_log.Debug("asset request " + requestID);
  10734. }
  10735. // Scripts cannot be retrieved by direct request
  10736. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10737. return;
  10738. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10739. req.AssetInf = asset;
  10740. req.AssetRequestSource = source;
  10741. req.IsTextureRequest = false;
  10742. req.NumPackets = CalculateNumPackets(asset.Data);
  10743. req.Params = transferRequest.TransferInfo.Params;
  10744. req.RequestAssetID = requestID;
  10745. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10746. SendAsset(req);
  10747. }
  10748. /// <summary>
  10749. /// Calculate the number of packets required to send the asset to the client.
  10750. /// </summary>
  10751. /// <param name="data"></param>
  10752. /// <returns></returns>
  10753. private static int CalculateNumPackets(byte[] data)
  10754. {
  10755. const uint m_maxPacketSize = 600;
  10756. int numPackets = 1;
  10757. if (data == null)
  10758. return 0;
  10759. if (data.LongLength > m_maxPacketSize)
  10760. {
  10761. // over max number of bytes so split up file
  10762. long restData = data.LongLength - m_maxPacketSize;
  10763. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10764. numPackets += restPackets;
  10765. }
  10766. return numPackets;
  10767. }
  10768. public void SendRebakeAvatarTextures(UUID textureID)
  10769. {
  10770. RebakeAvatarTexturesPacket pack =
  10771. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10772. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10773. pack.TextureData.TextureID = textureID;
  10774. OutPacket(pack, ThrottleOutPacketType.Task);
  10775. }
  10776. public struct PacketProcessor
  10777. {
  10778. public PacketMethod method;
  10779. public bool Async;
  10780. }
  10781. public class AsyncPacketProcess
  10782. {
  10783. public bool result = false;
  10784. public readonly LLClientView ClientView = null;
  10785. public readonly Packet Pack = null;
  10786. public readonly PacketMethod Method = null;
  10787. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10788. {
  10789. ClientView = pClientview;
  10790. Method = pMethod;
  10791. Pack = pPack;
  10792. }
  10793. }
  10794. public static OSD BuildEvent(string eventName, OSD eventBody)
  10795. {
  10796. OSDMap osdEvent = new OSDMap(2);
  10797. osdEvent.Add("message", new OSDString(eventName));
  10798. osdEvent.Add("body", eventBody);
  10799. return osdEvent;
  10800. }
  10801. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10802. {
  10803. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10804. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10805. packet.AgentData.AgentID = AgentId;
  10806. packet.AgentData.AvatarID = avatarID;
  10807. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10808. packet.PropertiesData.WantToMask = wantMask;
  10809. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10810. packet.PropertiesData.SkillsMask = skillsMask;
  10811. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10812. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10813. OutPacket(packet, ThrottleOutPacketType.Task);
  10814. }
  10815. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10816. {
  10817. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10818. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10819. packet.AgentData.AgentID = agentID;
  10820. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10821. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10822. packet.Rights[0].AgentRelated = friendID;
  10823. packet.Rights[0].RelatedRights = rights;
  10824. OutPacket(packet, ThrottleOutPacketType.Task);
  10825. }
  10826. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10827. {
  10828. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10829. dialog.Data.ObjectID = objectId;
  10830. dialog.Data.ChatChannel = chatChannel;
  10831. dialog.Data.ImageID = UUID.Zero;
  10832. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10833. // this is the username of the *owner*
  10834. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10835. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10836. dialog.Data.Message = Util.StringToBytes256(message);
  10837. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10838. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10839. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10840. dialog.Buttons = buttons;
  10841. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10842. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10843. dialog.OwnerData[0].OwnerID = ownerID;
  10844. OutPacket(dialog, ThrottleOutPacketType.Task);
  10845. }
  10846. public void SendAgentTerseUpdate(ISceneEntity p)
  10847. {
  10848. if (p is ScenePresence)
  10849. {
  10850. ScenePresence presence = p as ScenePresence;
  10851. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10852. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10853. // velocity, collision plane and avatar height
  10854. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10855. // when the avatar stands up
  10856. Vector3 pos = presence.AbsolutePosition;
  10857. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10858. CreateImprovedTerseBlock(p, false);
  10859. const float TIME_DILATION = 1.0f;
  10860. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10861. ImprovedTerseObjectUpdatePacket packet
  10862. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  10863. PacketType.ImprovedTerseObjectUpdate);
  10864. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10865. packet.RegionData.TimeDilation = timeDilation;
  10866. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10867. packet.ObjectData[0] = block;
  10868. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10869. }
  10870. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10871. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10872. }
  10873. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10874. PlacesReplyData[] data)
  10875. {
  10876. PlacesReplyPacket reply = null;
  10877. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10878. new PlacesReplyPacket.QueryDataBlock[0];
  10879. for (int i = 0 ; i < data.Length ; i++)
  10880. {
  10881. PlacesReplyPacket.QueryDataBlock block =
  10882. new PlacesReplyPacket.QueryDataBlock();
  10883. block.OwnerID = data[i].OwnerID;
  10884. block.Name = Util.StringToBytes256(data[i].Name);
  10885. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10886. block.ActualArea = data[i].ActualArea;
  10887. block.BillableArea = data[i].BillableArea;
  10888. block.Flags = data[i].Flags;
  10889. block.GlobalX = data[i].GlobalX;
  10890. block.GlobalY = data[i].GlobalY;
  10891. block.GlobalZ = data[i].GlobalZ;
  10892. block.SimName = Util.StringToBytes256(data[i].SimName);
  10893. block.SnapshotID = data[i].SnapshotID;
  10894. block.Dwell = data[i].Dwell;
  10895. block.Price = data[i].Price;
  10896. if (reply != null && reply.Length + block.Length > 1400)
  10897. {
  10898. OutPacket(reply, ThrottleOutPacketType.Task);
  10899. reply = null;
  10900. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10901. }
  10902. if (reply == null)
  10903. {
  10904. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10905. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10906. reply.AgentData.AgentID = AgentId;
  10907. reply.AgentData.QueryID = queryID;
  10908. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10909. reply.TransactionData.TransactionID = transactionID;
  10910. reply.QueryData = dataBlocks;
  10911. }
  10912. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10913. dataBlocks[dataBlocks.Length - 1] = block;
  10914. reply.QueryData = dataBlocks;
  10915. }
  10916. if (reply != null)
  10917. OutPacket(reply, ThrottleOutPacketType.Task);
  10918. }
  10919. public void SendRemoveInventoryItems(UUID[] items)
  10920. {
  10921. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10922. if (eq == null)
  10923. {
  10924. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10925. return;
  10926. }
  10927. OSDMap llsd = new OSDMap(3);
  10928. OSDMap AgentDataMap = new OSDMap(1);
  10929. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10930. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10931. OSDArray AgentData = new OSDArray(1);
  10932. AgentData.Add(AgentDataMap);
  10933. llsd.Add("AgentData", AgentData);
  10934. OSDArray ItemData = new OSDArray();
  10935. foreach (UUID item in items)
  10936. {
  10937. OSDMap ItemDataMap = new OSDMap(2);
  10938. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  10939. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10940. ItemData.Add(ItemDataMap);
  10941. }
  10942. llsd.Add("InventoryData", ItemData);
  10943. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  10944. llsd), AgentId);
  10945. }
  10946. public void SendRemoveInventoryFolders(UUID[] folders)
  10947. {
  10948. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10949. if (eq == null)
  10950. {
  10951. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10952. return;
  10953. }
  10954. OSDMap llsd = new OSDMap(3);
  10955. OSDMap AgentDataMap = new OSDMap(1);
  10956. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10957. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10958. OSDArray AgentData = new OSDArray(1);
  10959. AgentData.Add(AgentDataMap);
  10960. llsd.Add("AgentData", AgentData);
  10961. OSDArray FolderData = new OSDArray();
  10962. foreach (UUID folder in folders)
  10963. {
  10964. OSDMap FolderDataMap = new OSDMap(2);
  10965. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  10966. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10967. FolderData.Add(FolderDataMap);
  10968. }
  10969. llsd.Add("FolderData", FolderData);
  10970. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  10971. llsd), AgentId);
  10972. }
  10973. private byte[] EncodeU32(uint val)
  10974. {
  10975. byte[] ret = BitConverter.GetBytes(val);
  10976. if (BitConverter.IsLittleEndian)
  10977. Array.Reverse(ret);
  10978. return ret;
  10979. }
  10980. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  10981. {
  10982. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10983. if (eq == null)
  10984. {
  10985. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10986. return;
  10987. }
  10988. OSDMap llsd = new OSDMap(3);
  10989. OSDMap AgentDataMap = new OSDMap(1);
  10990. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10991. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10992. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  10993. OSDArray AgentData = new OSDArray(1);
  10994. AgentData.Add(AgentDataMap);
  10995. llsd.Add("AgentData", AgentData);
  10996. OSDArray FolderData = new OSDArray();
  10997. foreach (InventoryFolderBase folder in folders)
  10998. {
  10999. OSDMap FolderDataMap = new OSDMap(5);
  11000. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11001. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11002. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11003. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11004. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11005. FolderData.Add(FolderDataMap);
  11006. }
  11007. llsd.Add("FolderData", FolderData);
  11008. OSDArray ItemData = new OSDArray();
  11009. foreach (InventoryItemBase item in items)
  11010. {
  11011. OSDMap ItemDataMap = new OSDMap();
  11012. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11013. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11014. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11015. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11016. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11017. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11018. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11019. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11020. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11021. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11022. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11023. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11024. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11025. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11026. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11027. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11028. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11029. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11030. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11031. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11032. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11033. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11034. (sbyte)item.AssetType, item.AssetID,
  11035. item.GroupID, 100,
  11036. item.Owner, item.CreatorIdAsUuid,
  11037. item.ID, item.Folder,
  11038. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11039. (uint)PermissionMask.All)
  11040. )));
  11041. ItemDataMap.Add("CallbackID", 0);
  11042. ItemData.Add(ItemDataMap);
  11043. }
  11044. llsd.Add("ItemData", ItemData);
  11045. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11046. llsd), AgentId);
  11047. }
  11048. }
  11049. }