LLClientView.cs 531 KB

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