LLClientView.cs 520 KB

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