LLClientView.cs 567 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Threading;
  34. using System.Timers;
  35. using System.Xml;
  36. using log4net;
  37. using OpenMetaverse;
  38. using OpenMetaverse.Packets;
  39. using OpenMetaverse.Messages.Linden;
  40. using OpenMetaverse.StructuredData;
  41. using OpenSim.Framework;
  42. using OpenSim.Framework.Client;
  43. using OpenSim.Framework.Monitoring;
  44. using OpenSim.Region.Framework.Interfaces;
  45. using OpenSim.Region.Framework.Scenes;
  46. using OpenSim.Services.Interfaces;
  47. using Timer = System.Timers.Timer;
  48. using AssetLandmark = OpenSim.Framework.AssetLandmark;
  49. using RegionFlags = OpenMetaverse.RegionFlags;
  50. using Nini.Config;
  51. using System.IO;
  52. using PermissionMask = OpenSim.Framework.PermissionMask;
  53. namespace OpenSim.Region.ClientStack.LindenUDP
  54. {
  55. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  56. /// <summary>
  57. /// Handles new client connections
  58. /// Constructor takes a single Packet and authenticates everything
  59. /// </summary>
  60. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
  61. {
  62. /// <value>
  63. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  64. /// </value>
  65. public int DebugPacketLevel { get; set; }
  66. #region Events
  67. public event GenericMessage OnGenericMessage;
  68. public event BinaryGenericMessage OnBinaryGenericMessage;
  69. public event Action<IClientAPI> OnLogout;
  70. public event ObjectPermissions OnObjectPermissions;
  71. public event Action<IClientAPI> OnConnectionClosed;
  72. public event ViewerEffectEventHandler OnViewerEffect;
  73. public event ImprovedInstantMessage OnInstantMessage;
  74. public event ChatMessage OnChatFromClient;
  75. public event TextureRequest OnRequestTexture;
  76. public event RezObject OnRezObject;
  77. public event DeRezObject OnDeRezObject;
  78. public event ModifyTerrain OnModifyTerrain;
  79. public event Action<IClientAPI> OnRegionHandShakeReply;
  80. public event GenericCall1 OnRequestWearables;
  81. public event CachedTextureRequest OnCachedTextureRequest;
  82. public event SetAppearance OnSetAppearance;
  83. public event AvatarNowWearing OnAvatarNowWearing;
  84. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  85. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  86. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  87. public event ObjectAttach OnObjectAttach;
  88. public event ObjectDeselect OnObjectDetach;
  89. public event ObjectDrop OnObjectDrop;
  90. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  91. public event UpdateAgent OnPreAgentUpdate;
  92. public event UpdateAgent OnAgentUpdate;
  93. public event UpdateAgent OnAgentCameraUpdate;
  94. public event AgentRequestSit OnAgentRequestSit;
  95. public event AgentSit OnAgentSit;
  96. public event AvatarPickerRequest OnAvatarPickerRequest;
  97. public event StartAnim OnStartAnim;
  98. public event StopAnim OnStopAnim;
  99. public event Action<IClientAPI> OnRequestAvatarsData;
  100. public event LinkObjects OnLinkObjects;
  101. public event DelinkObjects OnDelinkObjects;
  102. public event GrabObject OnGrabObject;
  103. public event DeGrabObject OnDeGrabObject;
  104. public event SpinStart OnSpinStart;
  105. public event SpinStop OnSpinStop;
  106. public event ObjectDuplicate OnObjectDuplicate;
  107. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  108. public event MoveObject OnGrabUpdate;
  109. public event SpinObject OnSpinUpdate;
  110. public event AddNewPrim OnAddPrim;
  111. public event RequestGodlikePowers OnRequestGodlikePowers;
  112. public event GodKickUser OnGodKickUser;
  113. public event ObjectExtraParams OnUpdateExtraParams;
  114. public event UpdateShape OnUpdatePrimShape;
  115. public event ObjectRequest OnObjectRequest;
  116. public event ObjectSelect OnObjectSelect;
  117. public event ObjectDeselect OnObjectDeselect;
  118. public event GenericCall7 OnObjectDescription;
  119. public event GenericCall7 OnObjectName;
  120. public event GenericCall7 OnObjectClickAction;
  121. public event GenericCall7 OnObjectMaterial;
  122. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  123. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  124. public event UpdatePrimFlags OnUpdatePrimFlags;
  125. public event UpdatePrimTexture OnUpdatePrimTexture;
  126. public event UpdateVector OnUpdatePrimGroupPosition;
  127. public event UpdateVector OnUpdatePrimSinglePosition;
  128. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  129. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  130. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  131. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  132. public event UpdateVector OnUpdatePrimScale;
  133. public event UpdateVector OnUpdatePrimGroupScale;
  134. public event StatusChange OnChildAgentStatus;
  135. public event GenericCall2 OnStopMovement;
  136. public event Action<UUID> OnRemoveAvatar;
  137. public event RequestMapBlocks OnRequestMapBlocks;
  138. public event RequestMapName OnMapNameRequest;
  139. public event TeleportLocationRequest OnTeleportLocationRequest;
  140. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  141. public event TeleportCancel OnTeleportCancel;
  142. public event DisconnectUser OnDisconnectUser;
  143. public event RequestAvatarProperties OnRequestAvatarProperties;
  144. public event SetAlwaysRun OnSetAlwaysRun;
  145. public event FetchInventory OnAgentDataUpdateRequest;
  146. public event TeleportLocationRequest OnSetStartLocationRequest;
  147. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  148. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  149. public event LinkInventoryItem OnLinkInventoryItem;
  150. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  151. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  152. public event MoveInventoryFolder OnMoveInventoryFolder;
  153. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  154. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  155. public event FetchInventory OnFetchInventory;
  156. public event RequestTaskInventory OnRequestTaskInventory;
  157. public event UpdateInventoryItem OnUpdateInventoryItem;
  158. public event CopyInventoryItem OnCopyInventoryItem;
  159. public event MoveInventoryItem OnMoveInventoryItem;
  160. public event RemoveInventoryItem OnRemoveInventoryItem;
  161. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  162. public event UDPAssetUploadRequest OnAssetUploadRequest;
  163. public event XferReceive OnXferReceive;
  164. public event RequestXfer OnRequestXfer;
  165. public event ConfirmXfer OnConfirmXfer;
  166. public event AbortXfer OnAbortXfer;
  167. public event RequestTerrain OnRequestTerrain;
  168. public event RezScript OnRezScript;
  169. public event UpdateTaskInventory OnUpdateTaskInventory;
  170. public event MoveTaskInventory OnMoveTaskItem;
  171. public event RemoveTaskInventory OnRemoveTaskItem;
  172. public event RequestAsset OnRequestAsset;
  173. public event UUIDNameRequest OnNameFromUUIDRequest;
  174. public event ParcelAccessListRequest OnParcelAccessListRequest;
  175. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  176. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  177. public event ParcelDivideRequest OnParcelDivideRequest;
  178. public event ParcelJoinRequest OnParcelJoinRequest;
  179. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  180. public event ParcelSelectObjects OnParcelSelectObjects;
  181. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  182. public event ParcelAbandonRequest OnParcelAbandonRequest;
  183. public event ParcelGodForceOwner OnParcelGodForceOwner;
  184. public event ParcelReclaim OnParcelReclaim;
  185. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  186. public event ParcelDeedToGroup OnParcelDeedToGroup;
  187. public event RegionInfoRequest OnRegionInfoRequest;
  188. public event EstateCovenantRequest OnEstateCovenantRequest;
  189. public event FriendActionDelegate OnApproveFriendRequest;
  190. public event FriendActionDelegate OnDenyFriendRequest;
  191. public event FriendshipTermination OnTerminateFriendship;
  192. public event GrantUserFriendRights OnGrantUserRights;
  193. public event MoneyTransferRequest OnMoneyTransferRequest;
  194. public event EconomyDataRequest OnEconomyDataRequest;
  195. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  196. public event ParcelBuy OnParcelBuy;
  197. public event UUIDNameRequest OnTeleportHomeRequest;
  198. public event UUIDNameRequest OnUUIDGroupNameRequest;
  199. public event ScriptAnswer OnScriptAnswer;
  200. public event RequestPayPrice OnRequestPayPrice;
  201. public event ObjectSaleInfo OnObjectSaleInfo;
  202. public event ObjectBuy OnObjectBuy;
  203. public event BuyObjectInventory OnBuyObjectInventory;
  204. public event AgentSit OnUndo;
  205. public event AgentSit OnRedo;
  206. public event LandUndo OnLandUndo;
  207. public event ForceReleaseControls OnForceReleaseControls;
  208. public event GodLandStatRequest OnLandStatRequest;
  209. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  210. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  211. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  212. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  213. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  214. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  215. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  216. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  217. public event BakeTerrain OnBakeTerrain;
  218. public event RequestTerrain OnUploadTerrain;
  219. public event EstateChangeInfo OnEstateChangeInfo;
  220. public event EstateManageTelehub OnEstateManageTelehub;
  221. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  222. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  223. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  224. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  225. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  226. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  227. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  228. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  229. public event RegionHandleRequest OnRegionHandleRequest;
  230. public event ParcelInfoRequest OnParcelInfoRequest;
  231. public event ScriptReset OnScriptReset;
  232. public event GetScriptRunning OnGetScriptRunning;
  233. public event SetScriptRunning OnSetScriptRunning;
  234. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  235. public event TerrainUnacked OnUnackedTerrain;
  236. public event ActivateGesture OnActivateGesture;
  237. public event DeactivateGesture OnDeactivateGesture;
  238. public event ObjectOwner OnObjectOwner;
  239. public event DirPlacesQuery OnDirPlacesQuery;
  240. public event DirFindQuery OnDirFindQuery;
  241. public event DirLandQuery OnDirLandQuery;
  242. public event DirPopularQuery OnDirPopularQuery;
  243. public event DirClassifiedQuery OnDirClassifiedQuery;
  244. public event EventInfoRequest OnEventInfoRequest;
  245. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  246. public event MapItemRequest OnMapItemRequest;
  247. public event OfferCallingCard OnOfferCallingCard;
  248. public event AcceptCallingCard OnAcceptCallingCard;
  249. public event DeclineCallingCard OnDeclineCallingCard;
  250. public event SoundTrigger OnSoundTrigger;
  251. public event StartLure OnStartLure;
  252. public event TeleportLureRequest OnTeleportLureRequest;
  253. public event NetworkStats OnNetworkStatsUpdate;
  254. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  255. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  256. public event ClassifiedDelete OnClassifiedDelete;
  257. public event ClassifiedDelete OnClassifiedGodDelete;
  258. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  259. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  260. public event EventGodDelete OnEventGodDelete;
  261. public event ParcelDwellRequest OnParcelDwellRequest;
  262. public event UserInfoRequest OnUserInfoRequest;
  263. public event UpdateUserInfo OnUpdateUserInfo;
  264. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  265. public event PickDelete OnPickDelete;
  266. public event PickGodDelete OnPickGodDelete;
  267. public event PickInfoUpdate OnPickInfoUpdate;
  268. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  269. public event MuteListRequest OnMuteListRequest;
  270. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  271. public event PlacesQuery OnPlacesQuery;
  272. public event AgentFOV OnAgentFOV;
  273. public event FindAgentUpdate OnFindAgent;
  274. public event TrackAgentUpdate OnTrackAgent;
  275. public event NewUserReport OnUserReport;
  276. public event SaveStateHandler OnSaveState;
  277. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  278. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  279. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  280. public event FreezeUserUpdate OnParcelFreezeUser;
  281. public event EjectUserUpdate OnParcelEjectUser;
  282. public event ParcelBuyPass OnParcelBuyPass;
  283. public event ParcelGodMark OnParcelGodMark;
  284. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  285. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  286. public event SimWideDeletesDelegate OnSimWideDeletes;
  287. public event SendPostcard OnSendPostcard;
  288. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  289. public event MuteListEntryRemove OnRemoveMuteListEntry;
  290. public event GodlikeMessage onGodlikeMessage;
  291. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  292. #endregion Events
  293. #region Class Members
  294. // LLClientView Only
  295. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  296. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  297. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  298. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  299. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  300. /// <summary>
  301. /// Handles UDP texture download.
  302. /// </summary>
  303. public LLImageManager ImageManager { get; private set; }
  304. private readonly LLUDPServer m_udpServer;
  305. private readonly LLUDPClient m_udpClient;
  306. private readonly UUID m_sessionId;
  307. private readonly UUID m_secureSessionId;
  308. protected readonly UUID m_agentId;
  309. private readonly uint m_circuitCode;
  310. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  311. private readonly IGroupsModule m_GroupsModule;
  312. private PriorityQueue m_entityUpdates;
  313. private PriorityQueue m_entityProps;
  314. private Prioritizer m_prioritizer;
  315. private bool m_disableFacelights = false;
  316. private volatile bool m_justEditedTerrain = false;
  317. /// <value>
  318. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  319. /// continually recreate it.
  320. /// </value>
  321. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  322. /// <value>
  323. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  324. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  325. /// ownerless phantom.
  326. ///
  327. /// All manipulation of this set has to occur under a lock
  328. ///
  329. /// </value>
  330. protected HashSet<uint> m_killRecord;
  331. // protected HashSet<uint> m_attachmentsSent;
  332. private int m_animationSequenceNumber = 1;
  333. private bool m_SendLogoutPacketWhenClosing = true;
  334. /// <summary>
  335. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  336. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  337. /// is doing absolutely nothing.
  338. /// </summary>
  339. /// <remarks>
  340. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  341. /// cannot retain a reference to it outside of that method.
  342. /// </remarks>
  343. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  344. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  345. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  346. protected Scene m_scene;
  347. protected string m_firstName;
  348. protected string m_lastName;
  349. protected Thread m_clientThread;
  350. protected Vector3 m_startpos;
  351. protected UUID m_activeGroupID;
  352. protected string m_activeGroupName = String.Empty;
  353. protected ulong m_activeGroupPowers;
  354. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  355. protected int m_terrainCheckerCount;
  356. protected uint m_agentFOVCounter;
  357. protected IAssetService m_assetService;
  358. private const bool m_checkPackets = true;
  359. #endregion Class Members
  360. #region Properties
  361. public LLUDPClient UDPClient { get { return m_udpClient; } }
  362. public LLUDPServer UDPServer { get { return m_udpServer; } }
  363. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  364. public UUID SecureSessionId { get { return m_secureSessionId; } }
  365. public IScene Scene { get { return m_scene; } }
  366. public UUID SessionId { get { return m_sessionId; } }
  367. public Vector3 StartPos
  368. {
  369. get { return m_startpos; }
  370. set { m_startpos = value; }
  371. }
  372. public UUID AgentId { get { return m_agentId; } }
  373. public ISceneAgent SceneAgent { get; set; }
  374. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  375. public string ActiveGroupName { get { return m_activeGroupName; } }
  376. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  377. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  378. /// <summary>
  379. /// Entity update queues
  380. /// </summary>
  381. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  382. /// <summary>
  383. /// First name of the agent/avatar represented by the client
  384. /// </summary>
  385. public string FirstName { get { return m_firstName; } }
  386. /// <summary>
  387. /// Last name of the agent/avatar represented by the client
  388. /// </summary>
  389. public string LastName { get { return m_lastName; } }
  390. /// <summary>
  391. /// Full name of the client (first name and last name)
  392. /// </summary>
  393. public string Name { get { return FirstName + " " + LastName; } }
  394. public uint CircuitCode { get { return m_circuitCode; } }
  395. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  396. /// <summary>
  397. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  398. /// prevent race conditions by different threads calling Close().
  399. /// </summary>
  400. public bool IsActive { get; set; }
  401. /// <summary>
  402. /// Used to synchronise threads when client is being closed.
  403. /// </summary>
  404. public Object CloseSyncLock { get; private set; }
  405. public bool IsLoggingOut { get; set; }
  406. public bool DisableFacelights
  407. {
  408. get { return m_disableFacelights; }
  409. set { m_disableFacelights = value; }
  410. }
  411. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  412. #endregion Properties
  413. // ~LLClientView()
  414. // {
  415. // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode);
  416. // }
  417. /// <summary>
  418. /// Constructor
  419. /// </summary>
  420. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  421. UUID agentId, UUID sessionId, uint circuitCode)
  422. {
  423. // DebugPacketLevel = 1;
  424. CloseSyncLock = new Object();
  425. RegisterInterface<IClientIM>(this);
  426. RegisterInterface<IClientInventory>(this);
  427. RegisterInterface<IClientChat>(this);
  428. m_scene = scene;
  429. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  430. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  431. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  432. m_killRecord = new HashSet<uint>();
  433. // m_attachmentsSent = new HashSet<uint>();
  434. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  435. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  436. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  437. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  438. m_agentId = agentId;
  439. m_sessionId = sessionId;
  440. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  441. m_circuitCode = circuitCode;
  442. m_firstName = sessionInfo.LoginInfo.First;
  443. m_lastName = sessionInfo.LoginInfo.Last;
  444. m_startpos = sessionInfo.LoginInfo.StartPos;
  445. m_udpServer = udpServer;
  446. m_udpClient = udpClient;
  447. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  448. m_udpClient.HasUpdates += HandleHasUpdates;
  449. m_udpClient.OnPacketStats += PopulateStats;
  450. m_prioritizer = new Prioritizer(m_scene);
  451. RegisterLocalPacketHandlers();
  452. IsActive = true;
  453. }
  454. #region Client Methods
  455. public void Close()
  456. {
  457. Close(false);
  458. }
  459. public void Close(bool force)
  460. {
  461. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  462. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  463. lock (CloseSyncLock)
  464. {
  465. // We still perform a force close inside the sync lock since this is intended to attempt close where
  466. // there is some unidentified connection problem, not where we have issues due to deadlock
  467. if (!IsActive && !force)
  468. {
  469. m_log.DebugFormat(
  470. "[CLIENT]: Not attempting to close inactive client {0} in {1} since force flag is not set",
  471. Name, m_scene.Name);
  472. return;
  473. }
  474. IsActive = false;
  475. CloseWithoutChecks();
  476. }
  477. }
  478. /// <summary>
  479. /// Closes down the client view without first checking whether it is active.
  480. /// </summary>
  481. /// <remarks>
  482. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  483. /// CloseWithoutIsActiveCheck asynchronously.
  484. ///
  485. /// Callers must lock ClosingSyncLock before calling.
  486. /// </remarks>
  487. public void CloseWithoutChecks()
  488. {
  489. m_log.DebugFormat(
  490. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  491. Name, m_scene.RegionInfo.RegionName);
  492. // Shutdown the image manager
  493. ImageManager.Close();
  494. // Fire the callback for this connection closing
  495. if (OnConnectionClosed != null)
  496. OnConnectionClosed(this);
  497. // Flush all of the packets out of the UDP server for this client
  498. if (m_udpServer != null)
  499. m_udpServer.Flush(m_udpClient);
  500. // Remove ourselves from the scene
  501. m_scene.RemoveClient(AgentId, true);
  502. SceneAgent = null;
  503. // We can't reach into other scenes and close the connection
  504. // We need to do this over grid communications
  505. //m_scene.CloseAllAgents(CircuitCode);
  506. // Disable UDP handling for this client
  507. m_udpClient.Shutdown();
  508. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  509. //GC.Collect();
  510. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  511. }
  512. public void Kick(string message)
  513. {
  514. if (!SceneAgent.IsChildAgent)
  515. {
  516. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  517. kupack.UserInfo.AgentID = AgentId;
  518. kupack.UserInfo.SessionID = SessionId;
  519. kupack.TargetBlock.TargetIP = 0;
  520. kupack.TargetBlock.TargetPort = 0;
  521. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  522. OutPacket(kupack, ThrottleOutPacketType.Task);
  523. // You must sleep here or users get no message!
  524. Thread.Sleep(500);
  525. }
  526. }
  527. public void Stop()
  528. {
  529. }
  530. #endregion Client Methods
  531. #region Packet Handling
  532. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  533. {
  534. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  535. if (handlerNetworkStatsUpdate != null)
  536. {
  537. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  538. }
  539. }
  540. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  541. {
  542. bool result = false;
  543. lock (PacketHandlers)
  544. {
  545. if (!PacketHandlers.ContainsKey(packetType))
  546. {
  547. PacketHandlers.Add(packetType, handler);
  548. result = true;
  549. }
  550. }
  551. return result;
  552. }
  553. /// <summary>
  554. /// Add a handler for the given packet type.
  555. /// </summary>
  556. /// <remarks>
  557. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  558. /// are received then please use the synchronous version of this method.
  559. /// </remarks>
  560. /// <param name="packetType"></param>
  561. /// <param name="handler"></param>
  562. /// <returns>true if the handler was added. This is currently always the case.</returns>
  563. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  564. {
  565. return AddLocalPacketHandler(packetType, handler, true);
  566. }
  567. /// <summary>
  568. /// Add a handler for the given packet type.
  569. /// </summary>
  570. /// <param name="packetType"></param>
  571. /// <param name="handler"></param>
  572. /// <param name="doAsync">
  573. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  574. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  575. /// synchronously.
  576. /// </param>
  577. /// <returns>true if the handler was added. This is currently always the case.</returns>
  578. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  579. {
  580. bool result = false;
  581. lock (m_packetHandlers)
  582. {
  583. if (!m_packetHandlers.ContainsKey(packetType))
  584. {
  585. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  586. result = true;
  587. }
  588. }
  589. return result;
  590. }
  591. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  592. {
  593. MethodName = MethodName.ToLower().Trim();
  594. bool result = false;
  595. lock (m_genericPacketHandlers)
  596. {
  597. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  598. {
  599. m_genericPacketHandlers.Add(MethodName, handler);
  600. result = true;
  601. }
  602. }
  603. return result;
  604. }
  605. /// <summary>
  606. /// Try to process a packet using registered packet handlers
  607. /// </summary>
  608. /// <param name="packet"></param>
  609. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  610. protected virtual bool ProcessPacketMethod(Packet packet)
  611. {
  612. bool result = false;
  613. PacketProcessor pprocessor;
  614. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  615. {
  616. //there is a local handler for this packet type
  617. if (pprocessor.Async)
  618. {
  619. ClientInfo cinfo = UDPClient.GetClientInfo();
  620. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  621. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  622. cinfo.AsyncRequests[packet.Type.ToString()]++;
  623. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  624. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  625. result = true;
  626. }
  627. else
  628. {
  629. ClientInfo cinfo = UDPClient.GetClientInfo();
  630. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  631. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  632. cinfo.SyncRequests[packet.Type.ToString()]++;
  633. result = pprocessor.method(this, packet);
  634. }
  635. }
  636. else
  637. {
  638. //there is not a local handler so see if there is a Global handler
  639. PacketMethod method = null;
  640. bool found;
  641. lock (PacketHandlers)
  642. {
  643. found = PacketHandlers.TryGetValue(packet.Type, out method);
  644. }
  645. if (found)
  646. {
  647. ClientInfo cinfo = UDPClient.GetClientInfo();
  648. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  649. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  650. cinfo.GenericRequests[packet.Type.ToString()]++;
  651. result = method(this, packet);
  652. }
  653. }
  654. return result;
  655. }
  656. public void ProcessSpecificPacketAsync(object state)
  657. {
  658. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  659. try
  660. {
  661. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  662. }
  663. catch (Exception e)
  664. {
  665. // Make sure that we see any exception caused by the asynchronous operation.
  666. m_log.ErrorFormat(
  667. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  668. packetObject.Pack, Name, e.Message, e.StackTrace);
  669. }
  670. }
  671. #endregion Packet Handling
  672. # region Setup
  673. public virtual void Start()
  674. {
  675. m_scene.AddNewAgent(this, PresenceType.User);
  676. RefreshGroupMembership();
  677. }
  678. # endregion
  679. public void ActivateGesture(UUID assetId, UUID gestureId)
  680. {
  681. }
  682. public void DeactivateGesture(UUID assetId, UUID gestureId)
  683. {
  684. }
  685. // Sound
  686. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  687. {
  688. }
  689. #region Scene/Avatar to Client
  690. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  691. {
  692. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  693. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  694. handshake.RegionInfo.BillableFactor = args.billableFactor;
  695. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  696. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  697. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  698. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  699. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  700. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  701. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  702. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  703. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  704. handshake.RegionInfo.SimAccess = args.simAccess;
  705. handshake.RegionInfo.WaterHeight = args.waterHeight;
  706. handshake.RegionInfo.RegionFlags = args.regionFlags;
  707. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  708. handshake.RegionInfo.SimOwner = args.SimOwner;
  709. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  710. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  711. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  712. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  713. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  714. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  715. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  716. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  717. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  718. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  719. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  720. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  721. handshake.RegionInfo3.CPUClassID = 9;
  722. handshake.RegionInfo3.CPURatio = 1;
  723. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  724. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  725. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  726. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  727. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  728. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  729. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  730. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  731. }
  732. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  733. {
  734. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  735. mov.SimData.ChannelVersion = m_channelVersion;
  736. mov.AgentData.SessionID = m_sessionId;
  737. mov.AgentData.AgentID = AgentId;
  738. mov.Data.RegionHandle = regInfo.RegionHandle;
  739. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  740. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  741. {
  742. mov.Data.Position = m_startpos;
  743. }
  744. else
  745. {
  746. mov.Data.Position = pos;
  747. }
  748. mov.Data.LookAt = look;
  749. // Hack to get this out immediately and skip the throttles
  750. OutPacket(mov, ThrottleOutPacketType.Unknown);
  751. }
  752. public void SendChatMessage(
  753. string message, byte type, Vector3 fromPos, string fromName,
  754. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  755. {
  756. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  757. reply.ChatData.Audible = audible;
  758. reply.ChatData.Message = Util.StringToBytes1024(message);
  759. reply.ChatData.ChatType = type;
  760. reply.ChatData.SourceType = source;
  761. reply.ChatData.Position = fromPos;
  762. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  763. reply.ChatData.OwnerID = ownerID;
  764. reply.ChatData.SourceID = fromAgentID;
  765. OutPacket(reply, ThrottleOutPacketType.Task);
  766. }
  767. /// <summary>
  768. /// Send an instant message to this client
  769. /// </summary>
  770. //
  771. // Don't remove transaction ID! Groups and item gives need to set it!
  772. public void SendInstantMessage(GridInstantMessage im)
  773. {
  774. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  775. {
  776. ImprovedInstantMessagePacket msg
  777. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  778. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  779. msg.AgentData.SessionID = UUID.Zero;
  780. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  781. msg.MessageBlock.Dialog = im.dialog;
  782. msg.MessageBlock.FromGroup = im.fromGroup;
  783. if (im.imSessionID == UUID.Zero.Guid)
  784. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  785. else
  786. msg.MessageBlock.ID = new UUID(im.imSessionID);
  787. msg.MessageBlock.Offline = im.offline;
  788. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  789. msg.MessageBlock.Position = im.Position;
  790. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  791. msg.MessageBlock.Timestamp = im.timestamp;
  792. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  793. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  794. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  795. if (im.message.StartsWith("[grouptest]"))
  796. { // this block is test code for implementing group IM - delete when group IM is finished
  797. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  798. if (eq != null)
  799. {
  800. im.dialog = 17;
  801. //eq.ChatterboxInvitation(
  802. // new UUID("00000000-68f9-1111-024e-222222111123"),
  803. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  804. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  805. eq.ChatterboxInvitation(
  806. new UUID("00000000-68f9-1111-024e-222222111123"),
  807. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  808. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  809. eq.ChatterBoxSessionAgentListUpdates(
  810. new UUID("00000000-68f9-1111-024e-222222111123"),
  811. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  812. }
  813. Console.WriteLine("SendInstantMessage: " + msg);
  814. }
  815. else
  816. OutPacket(msg, ThrottleOutPacketType.Task);
  817. }
  818. }
  819. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  820. {
  821. GenericMessagePacket gmp = new GenericMessagePacket();
  822. gmp.AgentData.AgentID = AgentId;
  823. gmp.AgentData.SessionID = m_sessionId;
  824. gmp.AgentData.TransactionID = invoice;
  825. gmp.MethodData.Method = Util.StringToBytes256(method);
  826. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  827. int i = 0;
  828. foreach (string val in message)
  829. {
  830. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  831. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  832. }
  833. OutPacket(gmp, ThrottleOutPacketType.Task);
  834. }
  835. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  836. {
  837. GenericMessagePacket gmp = new GenericMessagePacket();
  838. gmp.AgentData.AgentID = AgentId;
  839. gmp.AgentData.SessionID = m_sessionId;
  840. gmp.AgentData.TransactionID = invoice;
  841. gmp.MethodData.Method = Util.StringToBytes256(method);
  842. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  843. int i = 0;
  844. foreach (byte[] val in message)
  845. {
  846. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  847. gmp.ParamList[i++].Parameter = val;
  848. }
  849. OutPacket(gmp, ThrottleOutPacketType.Task);
  850. }
  851. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  852. {
  853. int i = 0;
  854. foreach (GroupActiveProposals Proposal in Proposals)
  855. {
  856. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  857. GAPIRP.AgentData.AgentID = AgentId;
  858. GAPIRP.AgentData.GroupID = groupID;
  859. GAPIRP.TransactionData.TransactionID = transactionID;
  860. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  861. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  862. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  863. ProposalData.VoteCast = Utils.StringToBytes("false");
  864. ProposalData.VoteID = new UUID(Proposal.VoteID);
  865. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  866. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  867. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  868. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  869. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  870. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  871. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  872. ProposalData.AlreadyVoted = false;
  873. GAPIRP.ProposalData[i] = ProposalData;
  874. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  875. i++;
  876. }
  877. if (Proposals.Length == 0)
  878. {
  879. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  880. GAPIRP.AgentData.AgentID = AgentId;
  881. GAPIRP.AgentData.GroupID = groupID;
  882. GAPIRP.TransactionData.TransactionID = transactionID;
  883. GAPIRP.TransactionData.TotalNumItems = 1;
  884. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  885. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  886. ProposalData.VoteCast = Utils.StringToBytes("false");
  887. ProposalData.VoteID = UUID.Zero;
  888. ProposalData.VoteInitiator = UUID.Zero;
  889. ProposalData.Majority = 0;
  890. ProposalData.Quorum = 0;
  891. ProposalData.TerseDateID = Utils.StringToBytes("");
  892. ProposalData.StartDateTime = Utils.StringToBytes("");
  893. ProposalData.EndDateTime = Utils.StringToBytes("");
  894. ProposalData.ProposalText = Utils.StringToBytes("");
  895. ProposalData.AlreadyVoted = false;
  896. GAPIRP.ProposalData[0] = ProposalData;
  897. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  898. }
  899. }
  900. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  901. {
  902. int i = 0;
  903. foreach (GroupVoteHistory Vote in Votes)
  904. {
  905. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  906. GVHIRP.AgentData.AgentID = AgentId;
  907. GVHIRP.AgentData.GroupID = groupID;
  908. GVHIRP.TransactionData.TransactionID = transactionID;
  909. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  910. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  911. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  912. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  913. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  914. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  915. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  916. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  917. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  918. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  919. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  920. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  921. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  922. VoteItem.CandidateID = UUID.Zero;
  923. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  924. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  925. GVHIRP.VoteItem[i] = VoteItem;
  926. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  927. i++;
  928. }
  929. if (Votes.Length == 0)
  930. {
  931. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  932. GVHIRP.AgentData.AgentID = AgentId;
  933. GVHIRP.AgentData.GroupID = groupID;
  934. GVHIRP.TransactionData.TransactionID = transactionID;
  935. GVHIRP.TransactionData.TotalNumItems = 0;
  936. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  937. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  938. GVHIRP.HistoryItemData.Majority = 0;
  939. GVHIRP.HistoryItemData.Quorum = 0;
  940. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  941. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  942. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  943. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  944. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  945. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  946. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  947. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  948. VoteItem.CandidateID = UUID.Zero;
  949. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  950. VoteItem.VoteCast = Utils.StringToBytes("No");
  951. GVHIRP.VoteItem[0] = VoteItem;
  952. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  953. }
  954. }
  955. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  956. {
  957. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  958. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  959. GADRP.AgentData.AgentID = sender.AgentId;
  960. GADRP.AgentData.GroupID = groupID;
  961. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  962. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  963. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  964. GADRP.MoneyData.CurrentInterval = 0;
  965. GADRP.MoneyData.IntervalDays = 7;
  966. GADRP.MoneyData.RequestID = transactionID;
  967. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  968. History.Amount = amt;
  969. History.Description = Utils.StringToBytes("");
  970. GADRP.HistoryData[0] = History;
  971. OutPacket(GADRP, ThrottleOutPacketType.Task);
  972. }
  973. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  974. {
  975. GroupAccountSummaryReplyPacket GASRP =
  976. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  977. PacketType.GroupAccountSummaryReply);
  978. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  979. GASRP.AgentData.AgentID = sender.AgentId;
  980. GASRP.AgentData.GroupID = groupID;
  981. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  982. GASRP.MoneyData.Balance = (int)moneyAmt;
  983. GASRP.MoneyData.TotalCredits = totalTier;
  984. GASRP.MoneyData.TotalDebits = usedTier;
  985. GASRP.MoneyData.StartDate = new byte[1];
  986. GASRP.MoneyData.CurrentInterval = 1;
  987. GASRP.MoneyData.GroupTaxCurrent = 0;
  988. GASRP.MoneyData.GroupTaxEstimate = 0;
  989. GASRP.MoneyData.IntervalDays = 0;
  990. GASRP.MoneyData.LandTaxCurrent = 0;
  991. GASRP.MoneyData.LandTaxEstimate = 0;
  992. GASRP.MoneyData.LastTaxDate = new byte[1];
  993. GASRP.MoneyData.LightTaxCurrent = 0;
  994. GASRP.MoneyData.TaxDate = new byte[1];
  995. GASRP.MoneyData.RequestID = sender.AgentId;
  996. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  997. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  998. GASRP.MoneyData.ObjectTaxEstimate = 0;
  999. GASRP.MoneyData.NonExemptMembers = 0;
  1000. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1001. GASRP.MoneyData.LightTaxEstimate = 0;
  1002. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1003. }
  1004. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1005. {
  1006. GroupAccountTransactionsReplyPacket GATRP =
  1007. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1008. PacketType.GroupAccountTransactionsReply);
  1009. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1010. GATRP.AgentData.AgentID = sender.AgentId;
  1011. GATRP.AgentData.GroupID = groupID;
  1012. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1013. GATRP.MoneyData.CurrentInterval = 0;
  1014. GATRP.MoneyData.IntervalDays = 7;
  1015. GATRP.MoneyData.RequestID = transactionID;
  1016. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1017. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1018. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1019. History.Amount = 0;
  1020. History.Item = Utils.StringToBytes("");
  1021. History.Time = Utils.StringToBytes("");
  1022. History.Type = 0;
  1023. History.User = Utils.StringToBytes("");
  1024. GATRP.HistoryData[0] = History;
  1025. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1026. }
  1027. /// <summary>
  1028. /// Send the region heightmap to the client
  1029. /// </summary>
  1030. /// <param name="map">heightmap</param>
  1031. public virtual void SendLayerData(float[] map)
  1032. {
  1033. Util.FireAndForget(DoSendLayerData, map);
  1034. }
  1035. /// <summary>
  1036. /// Send terrain layer information to the client.
  1037. /// </summary>
  1038. /// <param name="o"></param>
  1039. private void DoSendLayerData(object o)
  1040. {
  1041. float[] map = LLHeightFieldMoronize((float[])o);
  1042. try
  1043. {
  1044. //for (int y = 0; y < 16; y++)
  1045. //{
  1046. // for (int x = 0; x < 16; x++)
  1047. // {
  1048. // SendLayerData(x, y, map);
  1049. // }
  1050. //}
  1051. // Send LayerData in a spiral pattern. Fun!
  1052. SendLayerTopRight(map, 0, 0, 15, 15);
  1053. }
  1054. catch (Exception e)
  1055. {
  1056. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1057. }
  1058. }
  1059. private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
  1060. {
  1061. // Row
  1062. for (int i = x1; i <= x2; i++)
  1063. SendLayerData(i, y1, map);
  1064. // Column
  1065. for (int j = y1 + 1; j <= y2; j++)
  1066. SendLayerData(x2, j, map);
  1067. if (x2 - x1 > 0)
  1068. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1069. }
  1070. void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
  1071. {
  1072. // Row in reverse
  1073. for (int i = x2; i >= x1; i--)
  1074. SendLayerData(i, y2, map);
  1075. // Column in reverse
  1076. for (int j = y2 - 1; j >= y1; j--)
  1077. SendLayerData(x1, j, map);
  1078. if (x2 - x1 > 0)
  1079. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1080. }
  1081. /// <summary>
  1082. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1083. /// </summary>
  1084. /// <param name="map">heightmap</param>
  1085. /// <param name="px">X coordinate for patches 0..12</param>
  1086. /// <param name="py">Y coordinate for patches 0..15</param>
  1087. // private void SendLayerPacket(float[] map, int y, int x)
  1088. // {
  1089. // int[] patches = new int[4];
  1090. // patches[0] = x + 0 + y * 16;
  1091. // patches[1] = x + 1 + y * 16;
  1092. // patches[2] = x + 2 + y * 16;
  1093. // patches[3] = x + 3 + y * 16;
  1094. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1095. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1096. // }
  1097. /// <summary>
  1098. /// Sends a specified patch to a client
  1099. /// </summary>
  1100. /// <param name="px">Patch coordinate (x) 0..15</param>
  1101. /// <param name="py">Patch coordinate (y) 0..15</param>
  1102. /// <param name="map">heightmap</param>
  1103. public void SendLayerData(int px, int py, float[] map)
  1104. {
  1105. try
  1106. {
  1107. int[] patches = new int[] { py * 16 + px };
  1108. float[] heightmap = (map.Length == 65536) ?
  1109. map :
  1110. LLHeightFieldMoronize(map);
  1111. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1112. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
  1113. // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
  1114. // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
  1115. // invalidating previous packets for that area.
  1116. // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
  1117. // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
  1118. // One last note on this topic, by the time users are going to be editing the terrain, it's extremely likely that the sim will
  1119. // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
  1120. // patches.
  1121. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
  1122. if (m_justEditedTerrain)
  1123. {
  1124. layerpack.Header.Reliable = false;
  1125. OutPacket(layerpack,
  1126. ThrottleOutPacketType.Unknown );
  1127. }
  1128. else
  1129. {
  1130. layerpack.Header.Reliable = true;
  1131. OutPacket(layerpack,
  1132. ThrottleOutPacketType.Land);
  1133. }
  1134. }
  1135. catch (Exception e)
  1136. {
  1137. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1142. /// </summary>
  1143. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1144. /// <returns>float array in the base 256</returns>
  1145. internal float[] LLHeightFieldMoronize(float[] map)
  1146. {
  1147. if (map.Length == 65536)
  1148. return map;
  1149. else
  1150. {
  1151. float[] returnmap = new float[65536];
  1152. if (map.Length < 65535)
  1153. {
  1154. // rebase the vector stride to 256
  1155. for (int i = 0; i < Constants.RegionSize; i++)
  1156. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1157. }
  1158. else
  1159. {
  1160. for (int i = 0; i < 256; i++)
  1161. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1162. }
  1163. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1164. return returnmap;
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// Send the wind matrix to the client
  1169. /// </summary>
  1170. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1171. public virtual void SendWindData(Vector2[] windSpeeds)
  1172. {
  1173. Util.FireAndForget(DoSendWindData, windSpeeds);
  1174. }
  1175. /// <summary>
  1176. /// Send the cloud matrix to the client
  1177. /// </summary>
  1178. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1179. public virtual void SendCloudData(float[] cloudDensity)
  1180. {
  1181. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1182. }
  1183. /// <summary>
  1184. /// Send wind layer information to the client.
  1185. /// </summary>
  1186. /// <param name="o"></param>
  1187. private void DoSendWindData(object o)
  1188. {
  1189. Vector2[] windSpeeds = (Vector2[])o;
  1190. TerrainPatch[] patches = new TerrainPatch[2];
  1191. patches[0] = new TerrainPatch();
  1192. patches[0].Data = new float[16 * 16];
  1193. patches[1] = new TerrainPatch();
  1194. patches[1].Data = new float[16 * 16];
  1195. for (int y = 0; y < 16; y++)
  1196. {
  1197. for (int x = 0; x < 16; x++)
  1198. {
  1199. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1200. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1201. }
  1202. }
  1203. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1204. layerpack.Header.Zerocoded = true;
  1205. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1206. }
  1207. /// <summary>
  1208. /// Send cloud layer information to the client.
  1209. /// </summary>
  1210. /// <param name="o"></param>
  1211. private void DoSendCloudData(object o)
  1212. {
  1213. float[] cloudCover = (float[])o;
  1214. TerrainPatch[] patches = new TerrainPatch[1];
  1215. patches[0] = new TerrainPatch();
  1216. patches[0].Data = new float[16 * 16];
  1217. for (int y = 0; y < 16; y++)
  1218. {
  1219. for (int x = 0; x < 16; x++)
  1220. {
  1221. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1222. }
  1223. }
  1224. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1225. layerpack.Header.Zerocoded = true;
  1226. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1227. }
  1228. /// <summary>
  1229. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1230. /// </summary>
  1231. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1232. {
  1233. IPAddress neighbourIP = neighbourEndPoint.Address;
  1234. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1235. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1236. // TODO: don't create new blocks if recycling an old packet
  1237. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1238. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1239. byte[] byteIP = neighbourIP.GetAddressBytes();
  1240. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1241. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1242. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1243. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1244. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1245. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1246. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1247. }
  1248. public AgentCircuitData RequestClientInfo()
  1249. {
  1250. AgentCircuitData agentData = new AgentCircuitData();
  1251. agentData.AgentID = AgentId;
  1252. agentData.SessionID = m_sessionId;
  1253. agentData.SecureSessionID = SecureSessionId;
  1254. agentData.circuitcode = m_circuitCode;
  1255. agentData.child = false;
  1256. agentData.firstname = m_firstName;
  1257. agentData.lastname = m_lastName;
  1258. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1259. if (capsModule == null) // can happen when shutting down.
  1260. return agentData;
  1261. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1262. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1263. return agentData;
  1264. }
  1265. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1266. string capsURL)
  1267. {
  1268. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1269. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1270. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1271. // TODO: don't create new blocks if recycling an old packet
  1272. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1273. newSimPack.AgentData.AgentID = AgentId;
  1274. newSimPack.AgentData.SessionID = m_sessionId;
  1275. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1276. newSimPack.Info.Position = pos;
  1277. newSimPack.Info.LookAt = look;
  1278. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1279. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1280. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1281. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1282. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1283. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1284. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1285. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1286. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1287. // Hack to get this out immediately and skip throttles
  1288. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1289. }
  1290. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1291. {
  1292. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1293. // TODO: don't create new blocks if recycling an old packet
  1294. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1295. mapReply.AgentData.AgentID = AgentId;
  1296. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1297. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1298. mapReply.AgentData.Flags = flag;
  1299. for (int i = 0; i < mapBlocks2.Length; i++)
  1300. {
  1301. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1302. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1303. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1304. mapReply.Data[i].X = mapBlocks2[i].X;
  1305. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1306. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1307. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1308. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1309. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1310. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1311. // TODO: hookup varregion sim size here
  1312. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1313. mapReply.Size[i].SizeX = 256;
  1314. mapReply.Size[i].SizeY = 256;
  1315. }
  1316. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1317. }
  1318. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1319. {
  1320. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1321. int maxsend = 10;
  1322. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1323. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1324. for (int i = 0; i < mapBlocks2.Length; i++)
  1325. {
  1326. sendingBlocks.Add(mapBlocks2[i]);
  1327. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1328. {
  1329. SendMapBlockSplit(sendingBlocks, flag);
  1330. sendingBlocks = new List<MapBlockData>();
  1331. }
  1332. }
  1333. }
  1334. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1335. {
  1336. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1337. tpLocal.Info.AgentID = AgentId;
  1338. tpLocal.Info.TeleportFlags = flags;
  1339. tpLocal.Info.LocationID = 2;
  1340. tpLocal.Info.LookAt = lookAt;
  1341. tpLocal.Info.Position = position;
  1342. // Hack to get this out immediately and skip throttles
  1343. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1344. }
  1345. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1346. uint flags, string capsURL)
  1347. {
  1348. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1349. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1350. teleport.Info.AgentID = AgentId;
  1351. teleport.Info.RegionHandle = regionHandle;
  1352. teleport.Info.SimAccess = simAccess;
  1353. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1354. IPAddress oIP = newRegionEndPoint.Address;
  1355. byte[] byteIP = oIP.GetAddressBytes();
  1356. uint ip = (uint)byteIP[3] << 24;
  1357. ip += (uint)byteIP[2] << 16;
  1358. ip += (uint)byteIP[1] << 8;
  1359. ip += (uint)byteIP[0];
  1360. teleport.Info.SimIP = ip;
  1361. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1362. teleport.Info.LocationID = 4;
  1363. teleport.Info.TeleportFlags = 1 << 4;
  1364. // Hack to get this out immediately and skip throttles.
  1365. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1366. }
  1367. /// <summary>
  1368. /// Inform the client that a teleport attempt has failed
  1369. /// </summary>
  1370. public void SendTeleportFailed(string reason)
  1371. {
  1372. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1373. tpFailed.Info.AgentID = AgentId;
  1374. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1375. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1376. // Hack to get this out immediately and skip throttles
  1377. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1378. }
  1379. /// <summary>
  1380. ///
  1381. /// </summary>
  1382. public void SendTeleportStart(uint flags)
  1383. {
  1384. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1385. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1386. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1387. // Hack to get this out immediately and skip throttles
  1388. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1389. }
  1390. public void SendTeleportProgress(uint flags, string message)
  1391. {
  1392. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1393. tpProgress.AgentData.AgentID = this.AgentId;
  1394. tpProgress.Info.TeleportFlags = flags;
  1395. tpProgress.Info.Message = Util.StringToBytes256(message);
  1396. // Hack to get this out immediately and skip throttles
  1397. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1398. }
  1399. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
  1400. {
  1401. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1402. money.MoneyData.AgentID = AgentId;
  1403. money.MoneyData.TransactionID = transaction;
  1404. money.MoneyData.TransactionSuccess = success;
  1405. money.MoneyData.Description = description;
  1406. money.MoneyData.MoneyBalance = balance;
  1407. money.TransactionInfo.TransactionType = transactionType;
  1408. money.TransactionInfo.SourceID = sourceID;
  1409. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1410. money.TransactionInfo.DestID = destID;
  1411. money.TransactionInfo.IsDestGroup = destIsGroup;
  1412. money.TransactionInfo.Amount = amount;
  1413. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1414. OutPacket(money, ThrottleOutPacketType.Task);
  1415. }
  1416. public void SendPayPrice(UUID objectID, int[] payPrice)
  1417. {
  1418. if (payPrice[0] == 0 &&
  1419. payPrice[1] == 0 &&
  1420. payPrice[2] == 0 &&
  1421. payPrice[3] == 0 &&
  1422. payPrice[4] == 0)
  1423. return;
  1424. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1425. payPriceReply.ObjectData.ObjectID = objectID;
  1426. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1427. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1428. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1429. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1430. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1431. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1432. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1433. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1434. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1435. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1436. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1437. }
  1438. public void SendStartPingCheck(byte seq)
  1439. {
  1440. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1441. pc.Header.Reliable = false;
  1442. pc.PingID.PingID = seq;
  1443. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1444. pc.PingID.OldestUnacked = 0;
  1445. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1446. }
  1447. public void SendKillObject(List<uint> localIDs)
  1448. {
  1449. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1450. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1451. // TODO: don't create new blocks if recycling an old packet
  1452. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1453. for (int i = 0 ; i < localIDs.Count ; i++ )
  1454. {
  1455. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1456. kill.ObjectData[i].ID = localIDs[i];
  1457. }
  1458. kill.Header.Reliable = true;
  1459. kill.Header.Zerocoded = true;
  1460. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1461. {
  1462. OutPacket(kill, ThrottleOutPacketType.Task);
  1463. }
  1464. else
  1465. {
  1466. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1467. // condition where a kill can be processed before an out-of-date update for the same object.
  1468. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1469. lock (m_killRecord)
  1470. {
  1471. foreach (uint localID in localIDs)
  1472. m_killRecord.Add(localID);
  1473. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1474. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1475. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1476. // scene objects in a viewer until that viewer is relogged in.
  1477. OutPacket(kill, ThrottleOutPacketType.Task);
  1478. }
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// Send information about the items contained in a folder to the client.
  1483. /// </summary>
  1484. /// <remarks>
  1485. /// XXX This method needs some refactoring loving
  1486. /// </remarks>
  1487. /// <param name="ownerID">The owner of the folder</param>
  1488. /// <param name="folderID">The id of the folder</param>
  1489. /// <param name="items">The items contained in the folder identified by folderID</param>
  1490. /// <param name="folders"></param>
  1491. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1492. /// <param name="fetchItems">Do we need to send item information?</param>
  1493. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1494. List<InventoryFolderBase> folders, int version,
  1495. bool fetchFolders, bool fetchItems)
  1496. {
  1497. // An inventory descendents packet consists of a single agent section and an inventory details
  1498. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1499. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1500. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1501. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1502. //
  1503. // http://opensimulator.org/mantis/view.php?id=226
  1504. //
  1505. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1506. // 6 to 7 items at a time, so let's stick with 6
  1507. int MAX_ITEMS_PER_PACKET = 5;
  1508. int MAX_FOLDERS_PER_PACKET = 6;
  1509. int totalItems = fetchItems ? items.Count : 0;
  1510. int totalFolders = fetchFolders ? folders.Count : 0;
  1511. int itemsSent = 0;
  1512. int foldersSent = 0;
  1513. int foldersToSend = 0;
  1514. int itemsToSend = 0;
  1515. InventoryDescendentsPacket currentPacket = null;
  1516. // Handle empty folders
  1517. //
  1518. if (totalItems == 0 && totalFolders == 0)
  1519. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1520. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1521. //
  1522. while (itemsSent < totalItems || foldersSent < totalFolders)
  1523. {
  1524. if (currentPacket == null) // Start a new packet
  1525. {
  1526. foldersToSend = totalFolders - foldersSent;
  1527. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1528. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1529. if (foldersToSend == 0)
  1530. {
  1531. itemsToSend = totalItems - itemsSent;
  1532. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1533. itemsToSend = MAX_ITEMS_PER_PACKET;
  1534. }
  1535. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1536. }
  1537. if (foldersToSend-- > 0)
  1538. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1539. else if (itemsToSend-- > 0)
  1540. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1541. else
  1542. {
  1543. // m_log.DebugFormat(
  1544. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1545. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1546. currentPacket = null;
  1547. }
  1548. }
  1549. if (currentPacket != null)
  1550. {
  1551. // m_log.DebugFormat(
  1552. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1553. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1554. }
  1555. }
  1556. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1557. {
  1558. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1559. newBlock.FolderID = folder.ID;
  1560. newBlock.Name = Util.StringToBytes256(folder.Name);
  1561. newBlock.ParentID = folder.ParentID;
  1562. newBlock.Type = (sbyte)folder.Type;
  1563. return newBlock;
  1564. }
  1565. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1566. {
  1567. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1568. newBlock.ItemID = item.ID;
  1569. newBlock.AssetID = item.AssetID;
  1570. newBlock.CreatorID = item.CreatorIdAsUuid;
  1571. newBlock.BaseMask = item.BasePermissions;
  1572. newBlock.Description = Util.StringToBytes256(item.Description);
  1573. newBlock.EveryoneMask = item.EveryOnePermissions;
  1574. newBlock.OwnerMask = item.CurrentPermissions;
  1575. newBlock.FolderID = item.Folder;
  1576. newBlock.InvType = (sbyte)item.InvType;
  1577. newBlock.Name = Util.StringToBytes256(item.Name);
  1578. newBlock.NextOwnerMask = item.NextPermissions;
  1579. newBlock.OwnerID = item.Owner;
  1580. newBlock.Type = (sbyte)item.AssetType;
  1581. newBlock.GroupID = item.GroupID;
  1582. newBlock.GroupOwned = item.GroupOwned;
  1583. newBlock.GroupMask = item.GroupPermissions;
  1584. newBlock.CreationDate = item.CreationDate;
  1585. newBlock.SalePrice = item.SalePrice;
  1586. newBlock.SaleType = item.SaleType;
  1587. newBlock.Flags = item.Flags;
  1588. newBlock.CRC =
  1589. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1590. newBlock.InvType, newBlock.Type,
  1591. newBlock.AssetID, newBlock.GroupID,
  1592. newBlock.SalePrice,
  1593. newBlock.OwnerID, newBlock.CreatorID,
  1594. newBlock.ItemID, newBlock.FolderID,
  1595. newBlock.EveryoneMask,
  1596. newBlock.Flags, newBlock.OwnerMask,
  1597. newBlock.GroupMask, newBlock.NextOwnerMask);
  1598. return newBlock;
  1599. }
  1600. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1601. {
  1602. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1603. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1604. packet.FolderData[0].FolderID = UUID.Zero;
  1605. packet.FolderData[0].ParentID = UUID.Zero;
  1606. packet.FolderData[0].Type = -1;
  1607. packet.FolderData[0].Name = new byte[0];
  1608. }
  1609. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1610. {
  1611. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1612. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1613. packet.ItemData[0].ItemID = UUID.Zero;
  1614. packet.ItemData[0].AssetID = UUID.Zero;
  1615. packet.ItemData[0].CreatorID = UUID.Zero;
  1616. packet.ItemData[0].BaseMask = 0;
  1617. packet.ItemData[0].Description = new byte[0];
  1618. packet.ItemData[0].EveryoneMask = 0;
  1619. packet.ItemData[0].OwnerMask = 0;
  1620. packet.ItemData[0].FolderID = UUID.Zero;
  1621. packet.ItemData[0].InvType = (sbyte)0;
  1622. packet.ItemData[0].Name = new byte[0];
  1623. packet.ItemData[0].NextOwnerMask = 0;
  1624. packet.ItemData[0].OwnerID = UUID.Zero;
  1625. packet.ItemData[0].Type = -1;
  1626. packet.ItemData[0].GroupID = UUID.Zero;
  1627. packet.ItemData[0].GroupOwned = false;
  1628. packet.ItemData[0].GroupMask = 0;
  1629. packet.ItemData[0].CreationDate = 0;
  1630. packet.ItemData[0].SalePrice = 0;
  1631. packet.ItemData[0].SaleType = 0;
  1632. packet.ItemData[0].Flags = 0;
  1633. // No need to add CRC
  1634. }
  1635. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1636. {
  1637. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1638. descend.Header.Zerocoded = true;
  1639. descend.AgentData.AgentID = AgentId;
  1640. descend.AgentData.OwnerID = ownerID;
  1641. descend.AgentData.FolderID = folderID;
  1642. descend.AgentData.Version = version;
  1643. descend.AgentData.Descendents = descendents;
  1644. if (folders > 0)
  1645. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1646. else
  1647. AddNullFolderBlockToDecendentsPacket(ref descend);
  1648. if (items > 0)
  1649. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1650. else
  1651. AddNullItemBlockToDescendentsPacket(ref descend);
  1652. return descend;
  1653. }
  1654. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1655. {
  1656. // Fudge this value. It's only needed to make the CRC anyway
  1657. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1658. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1659. // TODO: don't create new blocks if recycling an old packet
  1660. inventoryReply.AgentData.AgentID = AgentId;
  1661. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1662. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1663. inventoryReply.InventoryData[0].ItemID = item.ID;
  1664. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1665. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1666. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1667. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1668. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1669. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1670. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1671. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1672. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1673. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1674. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1675. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1676. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1677. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1678. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1679. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1680. inventoryReply.InventoryData[0].Flags = item.Flags;
  1681. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1682. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1683. inventoryReply.InventoryData[0].CRC =
  1684. Helpers.InventoryCRC(
  1685. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1686. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1687. inventoryReply.InventoryData[0].GroupID, 100,
  1688. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1689. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1690. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1691. FULL_MASK_PERMISSIONS);
  1692. inventoryReply.Header.Zerocoded = true;
  1693. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1694. }
  1695. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1696. {
  1697. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1698. UUID transactionId = UUID.Random();
  1699. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1700. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1701. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1702. if (folderDataBlocks.Count > 0)
  1703. {
  1704. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1705. // Send these now
  1706. BulkUpdateInventoryPacket bulkUpdate
  1707. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1708. bulkUpdate.Header.Zerocoded = true;
  1709. bulkUpdate.AgentData.AgentID = AgentId;
  1710. bulkUpdate.AgentData.TransactionID = transactionId;
  1711. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1712. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1713. bulkUpdate.ItemData = foo.ToArray();
  1714. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1715. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1716. }
  1717. }
  1718. /// <summary>
  1719. /// Recursively construct bulk update packets to send folders and items
  1720. /// </summary>
  1721. /// <param name="folder"></param>
  1722. /// <param name="folderDataBlocks"></param>
  1723. /// <param name="transactionId"></param>
  1724. private void SendBulkUpdateInventoryFolderRecursive(
  1725. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1726. UUID transactionId)
  1727. {
  1728. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1729. const int MAX_ITEMS_PER_PACKET = 5;
  1730. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1731. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1732. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1733. // being used on the Linden grid at 20081203).
  1734. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1735. List<InventoryItemBase> items = contents.Items;
  1736. while (items.Count > 0)
  1737. {
  1738. BulkUpdateInventoryPacket bulkUpdate
  1739. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1740. bulkUpdate.Header.Zerocoded = true;
  1741. bulkUpdate.AgentData.AgentID = AgentId;
  1742. bulkUpdate.AgentData.TransactionID = transactionId;
  1743. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1744. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1745. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1746. for (int i = 0; i < itemsToSend; i++)
  1747. {
  1748. // Remove from the end of the list so that we don't incur a performance penalty
  1749. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1750. items.RemoveAt(items.Count - 1);
  1751. }
  1752. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1753. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1754. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1755. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1756. // items belong.
  1757. if (items.Count > 0)
  1758. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1759. }
  1760. List<InventoryFolderBase> subFolders = contents.Folders;
  1761. foreach (InventoryFolderBase subFolder in subFolders)
  1762. {
  1763. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1764. }
  1765. }
  1766. /// <summary>
  1767. /// Generate a bulk update inventory data block for the given folder
  1768. /// </summary>
  1769. /// <param name="folder"></param>
  1770. /// <returns></returns>
  1771. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1772. {
  1773. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1774. folderBlock.FolderID = folder.ID;
  1775. folderBlock.ParentID = folder.ParentID;
  1776. //folderBlock.Type = -1;
  1777. folderBlock.Type = (sbyte)folder.Type;
  1778. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1779. return folderBlock;
  1780. }
  1781. /// <summary>
  1782. /// Generate a bulk update inventory data block for the given item
  1783. /// </summary>
  1784. /// <param name="item"></param>
  1785. /// <returns></returns>
  1786. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1787. {
  1788. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1789. itemBlock.ItemID = item.ID;
  1790. itemBlock.AssetID = item.AssetID;
  1791. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1792. itemBlock.BaseMask = item.BasePermissions;
  1793. itemBlock.Description = Util.StringToBytes256(item.Description);
  1794. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1795. itemBlock.FolderID = item.Folder;
  1796. itemBlock.InvType = (sbyte)item.InvType;
  1797. itemBlock.Name = Util.StringToBytes256(item.Name);
  1798. itemBlock.NextOwnerMask = item.NextPermissions;
  1799. itemBlock.OwnerID = item.Owner;
  1800. itemBlock.OwnerMask = item.CurrentPermissions;
  1801. itemBlock.Type = (sbyte)item.AssetType;
  1802. itemBlock.GroupID = item.GroupID;
  1803. itemBlock.GroupOwned = item.GroupOwned;
  1804. itemBlock.GroupMask = item.GroupPermissions;
  1805. itemBlock.Flags = item.Flags;
  1806. itemBlock.SalePrice = item.SalePrice;
  1807. itemBlock.SaleType = item.SaleType;
  1808. itemBlock.CreationDate = item.CreationDate;
  1809. itemBlock.CRC =
  1810. Helpers.InventoryCRC(
  1811. 1000, 0, itemBlock.InvType,
  1812. itemBlock.Type, itemBlock.AssetID,
  1813. itemBlock.GroupID, 100,
  1814. itemBlock.OwnerID, itemBlock.CreatorID,
  1815. itemBlock.ItemID, itemBlock.FolderID,
  1816. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1817. (uint)PermissionMask.All);
  1818. return itemBlock;
  1819. }
  1820. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1821. {
  1822. if (node is InventoryItemBase)
  1823. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1824. else if (node is InventoryFolderBase)
  1825. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1826. else if (node != null)
  1827. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1828. else
  1829. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1830. }
  1831. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1832. {
  1833. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1834. BulkUpdateInventoryPacket bulkUpdate
  1835. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1836. bulkUpdate.AgentData.AgentID = AgentId;
  1837. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1838. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1839. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1840. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1841. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1842. bulkUpdate.FolderData[0].Type = -1;
  1843. bulkUpdate.FolderData[0].Name = new byte[0];
  1844. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1845. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1846. bulkUpdate.ItemData[0].ItemID = item.ID;
  1847. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1848. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1849. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1850. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1851. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1852. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1853. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1854. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1855. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1856. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1857. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1858. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1859. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1860. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1861. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1862. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1863. bulkUpdate.ItemData[0].Flags = item.Flags;
  1864. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1865. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1866. bulkUpdate.ItemData[0].CRC =
  1867. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1868. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1869. bulkUpdate.ItemData[0].GroupID, 100,
  1870. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1871. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1872. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1873. FULL_MASK_PERMISSIONS);
  1874. bulkUpdate.Header.Zerocoded = true;
  1875. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1876. }
  1877. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1878. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1879. {
  1880. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1881. UpdateCreateInventoryItemPacket InventoryReply
  1882. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1883. PacketType.UpdateCreateInventoryItem);
  1884. // TODO: don't create new blocks if recycling an old packet
  1885. InventoryReply.AgentData.AgentID = AgentId;
  1886. InventoryReply.AgentData.SimApproved = true;
  1887. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1888. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1889. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1890. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1891. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1892. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1893. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1894. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1895. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1896. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1897. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1898. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1899. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1900. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1901. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1902. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1903. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1904. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1905. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1906. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1907. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1908. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1909. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1910. InventoryReply.InventoryData[0].CRC =
  1911. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1912. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1913. InventoryReply.InventoryData[0].GroupID, 100,
  1914. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1915. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1916. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1917. FULL_MASK_PERMISSIONS);
  1918. InventoryReply.Header.Zerocoded = true;
  1919. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1920. }
  1921. public void SendRemoveInventoryItem(UUID itemID)
  1922. {
  1923. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1924. // TODO: don't create new blocks if recycling an old packet
  1925. remove.AgentData.AgentID = AgentId;
  1926. remove.AgentData.SessionID = m_sessionId;
  1927. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1928. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1929. remove.InventoryData[0].ItemID = itemID;
  1930. remove.Header.Zerocoded = true;
  1931. OutPacket(remove, ThrottleOutPacketType.Asset);
  1932. }
  1933. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1934. {
  1935. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1936. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1937. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1938. ddata.Controls = (uint)controls;
  1939. ddata.PassToAgent = passToAgent;
  1940. ddata.TakeControls = TakeControls;
  1941. data[0] = ddata;
  1942. scriptcontrol.Data = data;
  1943. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1944. }
  1945. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1946. {
  1947. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1948. replytask.InventoryData.TaskID = taskID;
  1949. replytask.InventoryData.Serial = serial;
  1950. replytask.InventoryData.Filename = fileName;
  1951. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1952. }
  1953. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1954. {
  1955. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1956. sendXfer.XferID.ID = xferID;
  1957. sendXfer.XferID.Packet = packet;
  1958. sendXfer.DataPacket.Data = data;
  1959. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1960. }
  1961. public void SendAbortXferPacket(ulong xferID)
  1962. {
  1963. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1964. xferItem.XferID.ID = xferID;
  1965. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1966. }
  1967. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1968. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1969. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1970. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1971. {
  1972. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1973. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1974. economyData.Info.ObjectCapacity = ObjectCapacity;
  1975. economyData.Info.ObjectCount = ObjectCount;
  1976. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1977. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1978. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1979. economyData.Info.PriceObjectRent = PriceObjectRent;
  1980. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1981. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1982. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1983. economyData.Info.PriceParcelRent = PriceParcelRent;
  1984. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1985. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1986. economyData.Info.PriceRentLight = PriceRentLight;
  1987. economyData.Info.PriceUpload = PriceUpload;
  1988. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1989. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1990. economyData.Header.Reliable = true;
  1991. OutPacket(economyData, ThrottleOutPacketType.Task);
  1992. }
  1993. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1994. {
  1995. //construct the AvatarPickerReply packet.
  1996. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1997. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1998. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1999. //int i = 0;
  2000. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  2001. foreach (AvatarPickerReplyDataArgs arg in Data)
  2002. {
  2003. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  2004. db.AvatarID = arg.AvatarID;
  2005. db.FirstName = arg.FirstName;
  2006. db.LastName = arg.LastName;
  2007. data_block.Add(db);
  2008. }
  2009. replyPacket.Data = data_block.ToArray();
  2010. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  2011. }
  2012. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  2013. {
  2014. m_activeGroupID = activegroupid;
  2015. m_activeGroupName = groupname;
  2016. m_activeGroupPowers = grouppowers;
  2017. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  2018. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  2019. sendAgentDataUpdate.AgentData.AgentID = agentid;
  2020. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2021. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2022. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2023. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2024. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2025. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2026. }
  2027. /// <summary>
  2028. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2029. /// blue information box in the bottom right hand corner.
  2030. /// </summary>
  2031. /// <param name="message"></param>
  2032. public void SendAlertMessage(string message)
  2033. {
  2034. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2035. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2036. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2037. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2038. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2039. }
  2040. /// <summary>
  2041. /// Send an agent alert message to the client.
  2042. /// </summary>
  2043. /// <param name="message"></param>
  2044. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2045. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2046. /// the AlertMessage packet).</param>
  2047. public void SendAgentAlertMessage(string message, bool modal)
  2048. {
  2049. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2050. }
  2051. /// <summary>
  2052. /// Construct an agent alert packet
  2053. /// </summary>
  2054. /// <param name="message"></param>
  2055. /// <param name="modal"></param>
  2056. /// <returns></returns>
  2057. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2058. {
  2059. // Prepend a slash to make the message come up in the top right
  2060. // again.
  2061. // Allow special formats to be sent from aware modules.
  2062. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2063. message = "/" + message;
  2064. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2065. alertPack.AgentData.AgentID = AgentId;
  2066. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2067. alertPack.AlertData.Modal = modal;
  2068. return alertPack;
  2069. }
  2070. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2071. string url)
  2072. {
  2073. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2074. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2075. loadURL.Data.ObjectID = objectID;
  2076. loadURL.Data.OwnerID = ownerID;
  2077. loadURL.Data.OwnerIsGroup = groupOwned;
  2078. loadURL.Data.Message = Util.StringToBytes256(message);
  2079. loadURL.Data.URL = Util.StringToBytes256(url);
  2080. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2081. }
  2082. public void SendDialog(
  2083. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2084. UUID textureID, int ch, string[] buttonlabels)
  2085. {
  2086. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2087. dialog.Data.ObjectID = objectID;
  2088. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2089. // this is the username of the *owner*
  2090. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2091. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2092. dialog.Data.Message = Util.StringToBytes1024(msg);
  2093. dialog.Data.ImageID = textureID;
  2094. dialog.Data.ChatChannel = ch;
  2095. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2096. for (int i = 0; i < buttonlabels.Length; i++)
  2097. {
  2098. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2099. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2100. }
  2101. dialog.Buttons = buttons;
  2102. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2103. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2104. dialog.OwnerData[0].OwnerID = ownerID;
  2105. OutPacket(dialog, ThrottleOutPacketType.Task);
  2106. }
  2107. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2108. {
  2109. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2110. // TODO: don't create new blocks if recycling an old packet
  2111. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2112. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2113. preSound.DataBlock[0].ObjectID = objectID;
  2114. preSound.DataBlock[0].OwnerID = ownerID;
  2115. preSound.DataBlock[0].SoundID = soundID;
  2116. preSound.Header.Zerocoded = true;
  2117. OutPacket(preSound, ThrottleOutPacketType.Task);
  2118. }
  2119. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2120. {
  2121. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2122. sound.DataBlock.SoundID = soundID;
  2123. sound.DataBlock.ObjectID = objectID;
  2124. sound.DataBlock.OwnerID = ownerID;
  2125. sound.DataBlock.Gain = gain;
  2126. sound.DataBlock.Flags = flags;
  2127. OutPacket(sound, ThrottleOutPacketType.Task);
  2128. }
  2129. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2130. {
  2131. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2132. sound.SoundData.SoundID = soundID;
  2133. sound.SoundData.OwnerID = ownerID;
  2134. sound.SoundData.ObjectID = objectID;
  2135. sound.SoundData.ParentID = parentID;
  2136. sound.SoundData.Handle = handle;
  2137. sound.SoundData.Position = position;
  2138. sound.SoundData.Gain = gain;
  2139. OutPacket(sound, ThrottleOutPacketType.Task);
  2140. }
  2141. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2142. {
  2143. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2144. sound.DataBlock.ObjectID = objectID;
  2145. sound.DataBlock.Gain = gain;
  2146. OutPacket(sound, ThrottleOutPacketType.Task);
  2147. }
  2148. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2149. {
  2150. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2151. // So adjust for that
  2152. // Contributed by: Godfrey
  2153. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2154. {
  2155. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2156. }
  2157. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2158. viewertime.TimeInfo.SunDirection = Position;
  2159. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2160. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2161. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2162. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2163. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2164. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2165. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2166. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2167. viewertime.Header.Reliable = false;
  2168. viewertime.Header.Zerocoded = true;
  2169. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2170. }
  2171. // Currently Deprecated
  2172. public void SendViewerTime(int phase)
  2173. {
  2174. /*
  2175. Console.WriteLine("SunPhase: {0}", phase);
  2176. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2177. //viewertime.TimeInfo.SecPerDay = 86400;
  2178. //viewertime.TimeInfo.SecPerYear = 31536000;
  2179. viewertime.TimeInfo.SecPerDay = 1000;
  2180. viewertime.TimeInfo.SecPerYear = 365000;
  2181. viewertime.TimeInfo.SunPhase = 1;
  2182. int sunPhase = (phase + 2) / 2;
  2183. if ((sunPhase < 6) || (sunPhase > 36))
  2184. {
  2185. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2186. Console.WriteLine("sending night");
  2187. }
  2188. else
  2189. {
  2190. if (sunPhase < 12)
  2191. {
  2192. sunPhase = 12;
  2193. }
  2194. sunPhase = sunPhase - 12;
  2195. float yValue = 0.1f * (sunPhase);
  2196. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2197. if (yValue > 1.2f)
  2198. {
  2199. yValue = yValue - 1.2f;
  2200. }
  2201. yValue = Util.Clip(yValue, 0, 1);
  2202. if (sunPhase < 14)
  2203. {
  2204. yValue = 1 - yValue;
  2205. }
  2206. if (sunPhase < 12)
  2207. {
  2208. yValue *= -1;
  2209. }
  2210. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2211. Console.WriteLine("sending sun update " + yValue);
  2212. }
  2213. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2214. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2215. viewertime.Header.Reliable = false;
  2216. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2217. */
  2218. }
  2219. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2220. {
  2221. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2222. packet.Header.Reliable = false;
  2223. packet.Header.Zerocoded = true;
  2224. packet.AgentData.AgentID = AgentId;
  2225. packet.AgentData.SessionID = SessionId;
  2226. packet.Effect = effectBlocks;
  2227. // OutPacket(packet, ThrottleOutPacketType.State);
  2228. OutPacket(packet, ThrottleOutPacketType.Task);
  2229. }
  2230. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2231. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2232. UUID partnerID)
  2233. {
  2234. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2235. avatarReply.AgentData.AgentID = AgentId;
  2236. avatarReply.AgentData.AvatarID = avatarID;
  2237. if (aboutText != null)
  2238. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2239. else
  2240. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2241. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2242. avatarReply.PropertiesData.CharterMember = charterMember;
  2243. if (flAbout != null)
  2244. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2245. else
  2246. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2247. avatarReply.PropertiesData.Flags = flags;
  2248. avatarReply.PropertiesData.FLImageID = flImageID;
  2249. avatarReply.PropertiesData.ImageID = imageID;
  2250. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2251. avatarReply.PropertiesData.PartnerID = partnerID;
  2252. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2253. }
  2254. /// <summary>
  2255. /// Send the client an Estate message blue box pop-down with a single OK button
  2256. /// </summary>
  2257. /// <param name="FromAvatarID"></param>
  2258. /// <param name="fromSessionID"></param>
  2259. /// <param name="FromAvatarName"></param>
  2260. /// <param name="Message"></param>
  2261. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2262. {
  2263. if (!SceneAgent.IsChildAgent)
  2264. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2265. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2266. }
  2267. public void SendLogoutPacket()
  2268. {
  2269. // I know this is a bit of a hack, however there are times when you don't
  2270. // want to send this, but still need to do the rest of the shutdown process
  2271. // this method gets called from the packet server.. which makes it practically
  2272. // impossible to do any other way.
  2273. if (m_SendLogoutPacketWhenClosing)
  2274. {
  2275. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2276. // TODO: don't create new blocks if recycling an old packet
  2277. logReply.AgentData.AgentID = AgentId;
  2278. logReply.AgentData.SessionID = SessionId;
  2279. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2280. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2281. logReply.InventoryData[0].ItemID = UUID.Zero;
  2282. OutPacket(logReply, ThrottleOutPacketType.Task);
  2283. }
  2284. }
  2285. public void SendHealth(float health)
  2286. {
  2287. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2288. healthpacket.HealthData.Health = health;
  2289. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2290. }
  2291. public void SendAgentOnline(UUID[] agentIDs)
  2292. {
  2293. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2294. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2295. for (int i = 0; i < agentIDs.Length; i++)
  2296. {
  2297. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2298. onpbl.AgentID = agentIDs[i];
  2299. onpb[i] = onpbl;
  2300. }
  2301. onp.AgentBlock = onpb;
  2302. onp.Header.Reliable = true;
  2303. OutPacket(onp, ThrottleOutPacketType.Task);
  2304. }
  2305. public void SendAgentOffline(UUID[] agentIDs)
  2306. {
  2307. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2308. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2309. for (int i = 0; i < agentIDs.Length; i++)
  2310. {
  2311. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2312. onpbl.AgentID = agentIDs[i];
  2313. offpb[i] = onpbl;
  2314. }
  2315. offp.AgentBlock = offpb;
  2316. offp.Header.Reliable = true;
  2317. OutPacket(offp, ThrottleOutPacketType.Task);
  2318. }
  2319. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2320. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2321. {
  2322. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2323. avatarSitResponse.SitObject.ID = TargetID;
  2324. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2325. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2326. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2327. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2328. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2329. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2330. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2331. }
  2332. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2333. {
  2334. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2335. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2336. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2337. adb.AgentID = AgentId;
  2338. adb.SessionID = SessionId; // More security
  2339. gdb.GodLevel = (byte)AdminLevel;
  2340. gdb.Token = Token;
  2341. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2342. respondPacket.GrantData = gdb;
  2343. respondPacket.AgentData = adb;
  2344. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2345. }
  2346. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2347. {
  2348. m_groupPowers.Clear();
  2349. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2350. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2351. for (int i = 0; i < GroupMembership.Length; i++)
  2352. {
  2353. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2354. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2355. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2356. Group.Contribution = GroupMembership[i].Contribution;
  2357. Group.GroupID = GroupMembership[i].GroupID;
  2358. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2359. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2360. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2361. Groups[i] = Group;
  2362. }
  2363. Groupupdate.GroupData = Groups;
  2364. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2365. Groupupdate.AgentData.AgentID = AgentId;
  2366. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2367. try
  2368. {
  2369. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2370. if (eq != null)
  2371. {
  2372. eq.GroupMembership(Groupupdate, this.AgentId);
  2373. }
  2374. }
  2375. catch (Exception ex)
  2376. {
  2377. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2378. m_log.Warn("sending group membership data via UDP");
  2379. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2380. }
  2381. }
  2382. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2383. {
  2384. SceneObjectPart part = (SceneObjectPart)entity;
  2385. if (part != null && AgentId != UUID.Zero)
  2386. {
  2387. try
  2388. {
  2389. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2390. if (eq != null)
  2391. {
  2392. uint localid = part.LocalId;
  2393. byte physshapetype = part.PhysicsShapeType;
  2394. float density = part.Density;
  2395. float friction = part.Friction;
  2396. float bounce = part.Restitution;
  2397. float gravmod = part.GravityModifier;
  2398. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2399. }
  2400. }
  2401. catch (Exception ex)
  2402. {
  2403. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2404. }
  2405. part.UpdatePhysRequired = false;
  2406. }
  2407. }
  2408. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2409. {
  2410. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2411. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2412. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2413. uidnamebloc.ID = groupLLUID;
  2414. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2415. uidnameblock[0] = uidnamebloc;
  2416. pack.UUIDNameBlock = uidnameblock;
  2417. OutPacket(pack, ThrottleOutPacketType.Task);
  2418. }
  2419. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2420. {
  2421. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2422. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2423. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2424. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2425. // lsrepdb.
  2426. lsrp.RequestData.ReportType = reportType;
  2427. lsrp.RequestData.RequestFlags = requestFlags;
  2428. lsrp.RequestData.TotalObjectCount = resultCount;
  2429. for (int i = 0; i < lsrpia.Length; i++)
  2430. {
  2431. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2432. lsrepdb.LocationX = lsrpia[i].LocationX;
  2433. lsrepdb.LocationY = lsrpia[i].LocationY;
  2434. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2435. lsrepdb.Score = lsrpia[i].Score;
  2436. lsrepdb.TaskID = lsrpia[i].TaskID;
  2437. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2438. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2439. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2440. lsrepdba[i] = lsrepdb;
  2441. }
  2442. lsrp.ReportData = lsrepdba;
  2443. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2444. }
  2445. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2446. {
  2447. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2448. scriptRunningReply.Script.ObjectID = objectID;
  2449. scriptRunningReply.Script.ItemID = itemID;
  2450. scriptRunningReply.Script.Running = running;
  2451. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2452. }
  2453. public void SendAsset(AssetRequestToClient req)
  2454. {
  2455. if (req.AssetInf.Data == null)
  2456. {
  2457. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2458. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2459. return;
  2460. }
  2461. //m_log.Debug("sending asset " + req.RequestAssetID);
  2462. TransferInfoPacket Transfer = new TransferInfoPacket();
  2463. Transfer.TransferInfo.ChannelType = 2;
  2464. Transfer.TransferInfo.Status = 0;
  2465. Transfer.TransferInfo.TargetType = 0;
  2466. if (req.AssetRequestSource == 2)
  2467. {
  2468. Transfer.TransferInfo.Params = new byte[20];
  2469. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2470. int assType = req.AssetInf.Type;
  2471. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2472. }
  2473. else if (req.AssetRequestSource == 3)
  2474. {
  2475. Transfer.TransferInfo.Params = req.Params;
  2476. // Transfer.TransferInfo.Params = new byte[100];
  2477. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2478. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2479. }
  2480. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2481. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2482. Transfer.Header.Zerocoded = true;
  2483. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2484. if (req.NumPackets == 1)
  2485. {
  2486. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2487. TransferPacket.TransferData.Packet = 0;
  2488. TransferPacket.TransferData.ChannelType = 2;
  2489. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2490. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2491. TransferPacket.TransferData.Status = 1;
  2492. TransferPacket.Header.Zerocoded = true;
  2493. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2494. }
  2495. else
  2496. {
  2497. int processedLength = 0;
  2498. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2499. int packetNumber = 0;
  2500. while (processedLength < req.AssetInf.Data.Length)
  2501. {
  2502. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2503. TransferPacket.TransferData.Packet = packetNumber;
  2504. TransferPacket.TransferData.ChannelType = 2;
  2505. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2506. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2507. byte[] chunk = new byte[chunkSize];
  2508. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2509. TransferPacket.TransferData.Data = chunk;
  2510. // 0 indicates more packets to come, 1 indicates last packet
  2511. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2512. {
  2513. TransferPacket.TransferData.Status = 0;
  2514. }
  2515. else
  2516. {
  2517. TransferPacket.TransferData.Status = 1;
  2518. }
  2519. TransferPacket.Header.Zerocoded = true;
  2520. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2521. processedLength += chunkSize;
  2522. packetNumber++;
  2523. }
  2524. }
  2525. }
  2526. public void SendAssetNotFound(AssetRequestToClient req)
  2527. {
  2528. TransferInfoPacket Transfer = new TransferInfoPacket();
  2529. Transfer.TransferInfo.ChannelType = 2;
  2530. Transfer.TransferInfo.Status = -2;
  2531. Transfer.TransferInfo.TargetType = 0;
  2532. Transfer.TransferInfo.Params = req.Params;
  2533. Transfer.TransferInfo.Size = 0;
  2534. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2535. Transfer.Header.Zerocoded = true;
  2536. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2537. }
  2538. public void SendTexture(AssetBase TextureAsset)
  2539. {
  2540. }
  2541. public void SendRegionHandle(UUID regionID, ulong handle)
  2542. {
  2543. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2544. reply.ReplyBlock.RegionID = regionID;
  2545. reply.ReplyBlock.RegionHandle = handle;
  2546. OutPacket(reply, ThrottleOutPacketType.Land);
  2547. }
  2548. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2549. {
  2550. float dwell = 0.0f;
  2551. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2552. if (dwellModule != null)
  2553. dwell = dwellModule.GetDwell(land.GlobalID);
  2554. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2555. reply.AgentData.AgentID = m_agentId;
  2556. reply.Data.ParcelID = parcelID;
  2557. reply.Data.OwnerID = land.OwnerID;
  2558. reply.Data.Name = Utils.StringToBytes(land.Name);
  2559. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2560. reply.Data.ActualArea = land.Area;
  2561. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2562. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2563. reply.Data.Flags = (byte)(
  2564. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2565. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2566. Vector3 pos = land.UserLocation;
  2567. if (pos.Equals(Vector3.Zero))
  2568. {
  2569. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2570. }
  2571. reply.Data.GlobalX = info.RegionLocX + x;
  2572. reply.Data.GlobalY = info.RegionLocY + y;
  2573. reply.Data.GlobalZ = pos.Z;
  2574. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2575. reply.Data.SnapshotID = land.SnapshotID;
  2576. reply.Data.Dwell = dwell;
  2577. reply.Data.SalePrice = land.SalePrice;
  2578. reply.Data.AuctionID = (int)land.AuctionID;
  2579. OutPacket(reply, ThrottleOutPacketType.Land);
  2580. }
  2581. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2582. {
  2583. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2584. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2585. packet.Data.SimName = Utils.StringToBytes(simName);
  2586. packet.Data.SimPosition = pos;
  2587. packet.Data.LookAt = lookAt;
  2588. OutPacket(packet, ThrottleOutPacketType.Task);
  2589. }
  2590. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2591. {
  2592. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2593. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2594. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2595. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2596. packet.AgentData.AgentID = AgentId;
  2597. packet.QueryData[0].QueryID = queryID;
  2598. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2599. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2600. DirPlacesReplyPacket.StatusDataBlock[] status =
  2601. new DirPlacesReplyPacket.StatusDataBlock[0];
  2602. packet.QueryReplies = replies;
  2603. packet.StatusData = status;
  2604. foreach (DirPlacesReplyData d in data)
  2605. {
  2606. int idx = replies.Length;
  2607. Array.Resize(ref replies, idx + 1);
  2608. Array.Resize(ref status, idx + 1);
  2609. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2610. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2611. replies[idx].ParcelID = d.parcelID;
  2612. replies[idx].Name = Utils.StringToBytes(d.name);
  2613. replies[idx].ForSale = d.forSale;
  2614. replies[idx].Auction = d.auction;
  2615. replies[idx].Dwell = d.dwell;
  2616. status[idx].Status = d.Status;
  2617. packet.QueryReplies = replies;
  2618. packet.StatusData = status;
  2619. if (packet.Length >= 1000)
  2620. {
  2621. OutPacket(packet, ThrottleOutPacketType.Task);
  2622. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2623. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2624. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2625. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2626. packet.AgentData.AgentID = AgentId;
  2627. packet.QueryData[0].QueryID = queryID;
  2628. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2629. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2630. }
  2631. }
  2632. if (replies.Length > 0 || data.Length == 0)
  2633. OutPacket(packet, ThrottleOutPacketType.Task);
  2634. }
  2635. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2636. {
  2637. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2638. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2639. packet.AgentData.AgentID = AgentId;
  2640. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2641. packet.QueryData.QueryID = queryID;
  2642. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2643. data.Length];
  2644. int i = 0;
  2645. foreach (DirPeopleReplyData d in data)
  2646. {
  2647. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2648. packet.QueryReplies[i].AgentID = d.agentID;
  2649. packet.QueryReplies[i].FirstName =
  2650. Utils.StringToBytes(d.firstName);
  2651. packet.QueryReplies[i].LastName =
  2652. Utils.StringToBytes(d.lastName);
  2653. packet.QueryReplies[i].Group =
  2654. Utils.StringToBytes(d.group);
  2655. packet.QueryReplies[i].Online = d.online;
  2656. packet.QueryReplies[i].Reputation = d.reputation;
  2657. i++;
  2658. }
  2659. OutPacket(packet, ThrottleOutPacketType.Task);
  2660. }
  2661. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2662. {
  2663. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2664. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2665. packet.AgentData.AgentID = AgentId;
  2666. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2667. packet.QueryData.QueryID = queryID;
  2668. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2669. data.Length];
  2670. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2671. data.Length];
  2672. int i = 0;
  2673. foreach (DirEventsReplyData d in data)
  2674. {
  2675. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2676. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2677. packet.QueryReplies[i].OwnerID = d.ownerID;
  2678. packet.QueryReplies[i].Name =
  2679. Utils.StringToBytes(d.name);
  2680. packet.QueryReplies[i].EventID = d.eventID;
  2681. packet.QueryReplies[i].Date =
  2682. Utils.StringToBytes(d.date);
  2683. packet.QueryReplies[i].UnixTime = d.unixTime;
  2684. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2685. packet.StatusData[i].Status = d.Status;
  2686. i++;
  2687. }
  2688. OutPacket(packet, ThrottleOutPacketType.Task);
  2689. }
  2690. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2691. {
  2692. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2693. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2694. packet.AgentData.AgentID = AgentId;
  2695. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2696. packet.QueryData.QueryID = queryID;
  2697. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2698. data.Length];
  2699. int i = 0;
  2700. foreach (DirGroupsReplyData d in data)
  2701. {
  2702. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2703. packet.QueryReplies[i].GroupID = d.groupID;
  2704. packet.QueryReplies[i].GroupName =
  2705. Utils.StringToBytes(d.groupName);
  2706. packet.QueryReplies[i].Members = d.members;
  2707. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2708. i++;
  2709. }
  2710. OutPacket(packet, ThrottleOutPacketType.Task);
  2711. }
  2712. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2713. {
  2714. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2715. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2716. packet.AgentData.AgentID = AgentId;
  2717. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2718. packet.QueryData.QueryID = queryID;
  2719. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2720. data.Length];
  2721. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2722. data.Length];
  2723. int i = 0;
  2724. foreach (DirClassifiedReplyData d in data)
  2725. {
  2726. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2727. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2728. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2729. packet.QueryReplies[i].Name =
  2730. Utils.StringToBytes(d.name);
  2731. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2732. packet.QueryReplies[i].CreationDate = d.creationDate;
  2733. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2734. packet.QueryReplies[i].PriceForListing = d.price;
  2735. packet.StatusData[i].Status = d.Status;
  2736. i++;
  2737. }
  2738. OutPacket(packet, ThrottleOutPacketType.Task);
  2739. }
  2740. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2741. {
  2742. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2743. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2744. packet.AgentData.AgentID = AgentId;
  2745. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2746. packet.QueryData.QueryID = queryID;
  2747. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2748. data.Length];
  2749. int i = 0;
  2750. foreach (DirLandReplyData d in data)
  2751. {
  2752. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2753. packet.QueryReplies[i].ParcelID = d.parcelID;
  2754. packet.QueryReplies[i].Name =
  2755. Utils.StringToBytes(d.name);
  2756. packet.QueryReplies[i].Auction = d.auction;
  2757. packet.QueryReplies[i].ForSale = d.forSale;
  2758. packet.QueryReplies[i].SalePrice = d.salePrice;
  2759. packet.QueryReplies[i].ActualArea = d.actualArea;
  2760. i++;
  2761. }
  2762. OutPacket(packet, ThrottleOutPacketType.Task);
  2763. }
  2764. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2765. {
  2766. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2767. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2768. packet.AgentData.AgentID = AgentId;
  2769. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2770. packet.QueryData.QueryID = queryID;
  2771. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2772. data.Length];
  2773. int i = 0;
  2774. foreach (DirPopularReplyData d in data)
  2775. {
  2776. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2777. packet.QueryReplies[i].ParcelID = d.parcelID;
  2778. packet.QueryReplies[i].Name =
  2779. Utils.StringToBytes(d.name);
  2780. packet.QueryReplies[i].Dwell = d.dwell;
  2781. i++;
  2782. }
  2783. OutPacket(packet, ThrottleOutPacketType.Task);
  2784. }
  2785. public void SendEventInfoReply(EventData data)
  2786. {
  2787. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2788. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2789. packet.AgentData.AgentID = AgentId;
  2790. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2791. packet.EventData.EventID = data.eventID;
  2792. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2793. packet.EventData.Name = Utils.StringToBytes(data.name);
  2794. packet.EventData.Category = Utils.StringToBytes(data.category);
  2795. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2796. packet.EventData.Date = Utils.StringToBytes(data.date);
  2797. packet.EventData.DateUTC = data.dateUTC;
  2798. packet.EventData.Duration = data.duration;
  2799. packet.EventData.Cover = data.cover;
  2800. packet.EventData.Amount = data.amount;
  2801. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2802. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2803. packet.EventData.EventFlags = data.eventFlags;
  2804. OutPacket(packet, ThrottleOutPacketType.Task);
  2805. }
  2806. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2807. {
  2808. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2809. mirplk.AgentData.AgentID = AgentId;
  2810. mirplk.RequestData.ItemType = mapitemtype;
  2811. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2812. for (int i = 0; i < replies.Length; i++)
  2813. {
  2814. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2815. mrdata.X = replies[i].x;
  2816. mrdata.Y = replies[i].y;
  2817. mrdata.ID = replies[i].id;
  2818. mrdata.Extra = replies[i].Extra;
  2819. mrdata.Extra2 = replies[i].Extra2;
  2820. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2821. mirplk.Data[i] = mrdata;
  2822. }
  2823. //m_log.Debug(mirplk.ToString());
  2824. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2825. }
  2826. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2827. {
  2828. // a bit special, as this uses AgentID to store the source instead
  2829. // of the destination. The destination (the receiver) goes into destID
  2830. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2831. p.AgentData.AgentID = srcID;
  2832. p.AgentData.SessionID = UUID.Zero;
  2833. p.AgentBlock.DestID = AgentId;
  2834. p.AgentBlock.TransactionID = transactionID;
  2835. OutPacket(p, ThrottleOutPacketType.Task);
  2836. }
  2837. public void SendAcceptCallingCard(UUID transactionID)
  2838. {
  2839. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2840. p.AgentData.AgentID = AgentId;
  2841. p.AgentData.SessionID = UUID.Zero;
  2842. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2843. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2844. p.FolderData[0].FolderID = UUID.Zero;
  2845. OutPacket(p, ThrottleOutPacketType.Task);
  2846. }
  2847. public void SendDeclineCallingCard(UUID transactionID)
  2848. {
  2849. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2850. p.AgentData.AgentID = AgentId;
  2851. p.AgentData.SessionID = UUID.Zero;
  2852. p.TransactionBlock.TransactionID = transactionID;
  2853. OutPacket(p, ThrottleOutPacketType.Task);
  2854. }
  2855. public void SendTerminateFriend(UUID exFriendID)
  2856. {
  2857. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2858. p.AgentData.AgentID = AgentId;
  2859. p.AgentData.SessionID = SessionId;
  2860. p.ExBlock.OtherID = exFriendID;
  2861. OutPacket(p, ThrottleOutPacketType.Task);
  2862. }
  2863. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2864. {
  2865. OSDMap llsd = new OSDMap(3);
  2866. OSDArray AgentData = new OSDArray(1);
  2867. OSDMap AgentDataMap = new OSDMap(1);
  2868. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2869. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2870. AgentData.Add(AgentDataMap);
  2871. llsd.Add("AgentData", AgentData);
  2872. OSDArray GroupData = new OSDArray(data.Length);
  2873. OSDArray NewGroupData = new OSDArray(data.Length);
  2874. foreach (GroupMembershipData m in data)
  2875. {
  2876. OSDMap GroupDataMap = new OSDMap(6);
  2877. OSDMap NewGroupDataMap = new OSDMap(1);
  2878. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2879. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2880. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2881. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2882. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2883. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2884. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2885. GroupData.Add(GroupDataMap);
  2886. NewGroupData.Add(NewGroupDataMap);
  2887. }
  2888. llsd.Add("GroupData", GroupData);
  2889. llsd.Add("NewGroupData", NewGroupData);
  2890. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2891. if (eq != null)
  2892. {
  2893. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2894. }
  2895. }
  2896. public void SendJoinGroupReply(UUID groupID, bool success)
  2897. {
  2898. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2899. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2900. p.AgentData.AgentID = AgentId;
  2901. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2902. p.GroupData.GroupID = groupID;
  2903. p.GroupData.Success = success;
  2904. OutPacket(p, ThrottleOutPacketType.Task);
  2905. }
  2906. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2907. {
  2908. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2909. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2910. p.AgentData.AgentID = agentID;
  2911. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2912. p.GroupData.GroupID = groupID;
  2913. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2914. p.EjectData.Success = success;
  2915. OutPacket(p, ThrottleOutPacketType.Task);
  2916. }
  2917. public void SendLeaveGroupReply(UUID groupID, bool success)
  2918. {
  2919. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2920. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2921. p.AgentData.AgentID = AgentId;
  2922. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2923. p.GroupData.GroupID = groupID;
  2924. p.GroupData.Success = success;
  2925. OutPacket(p, ThrottleOutPacketType.Task);
  2926. }
  2927. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2928. {
  2929. if (classifiedID.Length != name.Length)
  2930. return;
  2931. AvatarClassifiedReplyPacket ac =
  2932. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2933. PacketType.AvatarClassifiedReply);
  2934. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2935. ac.AgentData.AgentID = AgentId;
  2936. ac.AgentData.TargetID = targetID;
  2937. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2938. int i;
  2939. for (i = 0; i < classifiedID.Length; i++)
  2940. {
  2941. ac.Data[i].ClassifiedID = classifiedID[i];
  2942. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2943. }
  2944. OutPacket(ac, ThrottleOutPacketType.Task);
  2945. }
  2946. 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)
  2947. {
  2948. ClassifiedInfoReplyPacket cr =
  2949. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2950. PacketType.ClassifiedInfoReply);
  2951. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2952. cr.AgentData.AgentID = AgentId;
  2953. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2954. cr.Data.ClassifiedID = classifiedID;
  2955. cr.Data.CreatorID = creatorID;
  2956. cr.Data.CreationDate = creationDate;
  2957. cr.Data.ExpirationDate = expirationDate;
  2958. cr.Data.Category = category;
  2959. cr.Data.Name = Utils.StringToBytes(name);
  2960. cr.Data.Desc = Utils.StringToBytes(description);
  2961. cr.Data.ParcelID = parcelID;
  2962. cr.Data.ParentEstate = parentEstate;
  2963. cr.Data.SnapshotID = snapshotID;
  2964. cr.Data.SimName = Utils.StringToBytes(simName);
  2965. cr.Data.PosGlobal = new Vector3d(globalPos);
  2966. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2967. cr.Data.ClassifiedFlags = classifiedFlags;
  2968. cr.Data.PriceForListing = price;
  2969. OutPacket(cr, ThrottleOutPacketType.Task);
  2970. }
  2971. public void SendAgentDropGroup(UUID groupID)
  2972. {
  2973. AgentDropGroupPacket dg =
  2974. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2975. PacketType.AgentDropGroup);
  2976. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2977. dg.AgentData.AgentID = AgentId;
  2978. dg.AgentData.GroupID = groupID;
  2979. OutPacket(dg, ThrottleOutPacketType.Task);
  2980. }
  2981. public void SendAvatarNotesReply(UUID targetID, string text)
  2982. {
  2983. AvatarNotesReplyPacket an =
  2984. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2985. PacketType.AvatarNotesReply);
  2986. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2987. an.AgentData.AgentID = AgentId;
  2988. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2989. an.Data.TargetID = targetID;
  2990. an.Data.Notes = Utils.StringToBytes(text);
  2991. OutPacket(an, ThrottleOutPacketType.Task);
  2992. }
  2993. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2994. {
  2995. AvatarPicksReplyPacket ap =
  2996. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2997. PacketType.AvatarPicksReply);
  2998. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2999. ap.AgentData.AgentID = AgentId;
  3000. ap.AgentData.TargetID = targetID;
  3001. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  3002. int i = 0;
  3003. foreach (KeyValuePair<UUID, string> pick in picks)
  3004. {
  3005. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  3006. ap.Data[i].PickID = pick.Key;
  3007. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  3008. i++;
  3009. }
  3010. OutPacket(ap, ThrottleOutPacketType.Task);
  3011. }
  3012. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  3013. {
  3014. AvatarClassifiedReplyPacket ac =
  3015. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3016. PacketType.AvatarClassifiedReply);
  3017. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3018. ac.AgentData.AgentID = AgentId;
  3019. ac.AgentData.TargetID = targetID;
  3020. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3021. int i = 0;
  3022. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3023. {
  3024. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3025. ac.Data[i].ClassifiedID = classified.Key;
  3026. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3027. i++;
  3028. }
  3029. OutPacket(ac, ThrottleOutPacketType.Task);
  3030. }
  3031. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3032. {
  3033. ParcelDwellReplyPacket pd =
  3034. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3035. PacketType.ParcelDwellReply);
  3036. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3037. pd.AgentData.AgentID = AgentId;
  3038. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3039. pd.Data.LocalID = localID;
  3040. pd.Data.ParcelID = parcelID;
  3041. pd.Data.Dwell = dwell;
  3042. OutPacket(pd, ThrottleOutPacketType.Land);
  3043. }
  3044. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3045. {
  3046. UserInfoReplyPacket ur =
  3047. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3048. PacketType.UserInfoReply);
  3049. string Visible = "hidden";
  3050. if (visible)
  3051. Visible = "default";
  3052. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3053. ur.AgentData.AgentID = AgentId;
  3054. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3055. ur.UserData.IMViaEMail = imViaEmail;
  3056. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3057. ur.UserData.EMail = Utils.StringToBytes(email);
  3058. OutPacket(ur, ThrottleOutPacketType.Task);
  3059. }
  3060. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3061. {
  3062. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3063. createGroupReply.AgentData =
  3064. new CreateGroupReplyPacket.AgentDataBlock();
  3065. createGroupReply.ReplyData =
  3066. new CreateGroupReplyPacket.ReplyDataBlock();
  3067. createGroupReply.AgentData.AgentID = AgentId;
  3068. createGroupReply.ReplyData.GroupID = groupID;
  3069. createGroupReply.ReplyData.Success = success;
  3070. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3071. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3072. }
  3073. public void SendUseCachedMuteList()
  3074. {
  3075. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3076. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3077. useCachedMuteList.AgentData.AgentID = AgentId;
  3078. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3079. }
  3080. public void SendMuteListUpdate(string filename)
  3081. {
  3082. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3083. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3084. muteListUpdate.MuteData.AgentID = AgentId;
  3085. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3086. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3087. }
  3088. 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)
  3089. {
  3090. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3091. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3092. pickInfoReply.AgentData.AgentID = AgentId;
  3093. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3094. pickInfoReply.Data.PickID = pickID;
  3095. pickInfoReply.Data.CreatorID = creatorID;
  3096. pickInfoReply.Data.TopPick = topPick;
  3097. pickInfoReply.Data.ParcelID = parcelID;
  3098. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3099. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3100. pickInfoReply.Data.SnapshotID = snapshotID;
  3101. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3102. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3103. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3104. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3105. pickInfoReply.Data.SortOrder = sortOrder;
  3106. pickInfoReply.Data.Enabled = enabled;
  3107. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3108. }
  3109. #endregion Scene/Avatar to Client
  3110. // Gesture
  3111. #region Appearance/ Wearables Methods
  3112. public void SendWearables(AvatarWearable[] wearables, int serial)
  3113. {
  3114. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3115. aw.AgentData.AgentID = AgentId;
  3116. aw.AgentData.SerialNum = (uint)serial;
  3117. aw.AgentData.SessionID = m_sessionId;
  3118. int count = 0;
  3119. for (int i = 0; i < wearables.Length; i++)
  3120. count += wearables[i].Count;
  3121. // TODO: don't create new blocks if recycling an old packet
  3122. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3123. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3124. int idx = 0;
  3125. for (int i = 0; i < wearables.Length; i++)
  3126. {
  3127. for (int j = 0; j < wearables[i].Count; j++)
  3128. {
  3129. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3130. awb.WearableType = (byte)i;
  3131. awb.AssetID = wearables[i][j].AssetID;
  3132. awb.ItemID = wearables[i][j].ItemID;
  3133. aw.WearableData[idx] = awb;
  3134. idx++;
  3135. // m_log.DebugFormat(
  3136. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3137. // awb.ItemID, awb.AssetID, i, Name);
  3138. }
  3139. }
  3140. OutPacket(aw, ThrottleOutPacketType.Task);
  3141. }
  3142. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3143. {
  3144. // m_log.DebugFormat(
  3145. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3146. // agentID, textureEntry.Length, Name, AgentId);
  3147. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3148. // TODO: don't create new blocks if recycling an old packet
  3149. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  3150. avp.ObjectData.TextureEntry = textureEntry;
  3151. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3152. for (int i = 0; i < visualParams.Length; i++)
  3153. {
  3154. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3155. avblock.ParamValue = visualParams[i];
  3156. avp.VisualParam[i] = avblock;
  3157. }
  3158. avp.Sender.IsTrial = false;
  3159. avp.Sender.ID = agentID;
  3160. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3161. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3162. OutPacket(avp, ThrottleOutPacketType.Task);
  3163. }
  3164. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3165. {
  3166. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3167. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3168. // TODO: don't create new blocks if recycling an old packet
  3169. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3170. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3171. ani.Sender.ID = sourceAgentId;
  3172. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3173. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3174. for (int i = 0; i < animations.Length; ++i)
  3175. {
  3176. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3177. ani.AnimationList[i].AnimID = animations[i];
  3178. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3179. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3180. if (objectIDs[i].Equals(sourceAgentId))
  3181. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3182. else
  3183. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3184. }
  3185. ani.Header.Reliable = false;
  3186. OutPacket(ani, ThrottleOutPacketType.Task);
  3187. }
  3188. #endregion
  3189. #region Avatar Packet/Data Sending Methods
  3190. /// <summary>
  3191. /// Send an ObjectUpdate packet with information about an avatar
  3192. /// </summary>
  3193. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3194. {
  3195. // m_log.DebugFormat(
  3196. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3197. // avatar.Name, avatar.UUID, Name, AgentId);
  3198. ScenePresence presence = avatar as ScenePresence;
  3199. if (presence == null)
  3200. return;
  3201. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3202. objupdate.Header.Zerocoded = true;
  3203. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3204. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3205. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3206. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3207. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3208. // We need to record the avatar local id since the root prim of an attachment points to this.
  3209. // m_attachmentsSent.Add(avatar.LocalId);
  3210. }
  3211. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3212. {
  3213. // We don't need to update inactive clients.
  3214. if (!IsActive)
  3215. return;
  3216. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3217. loc.Header.Reliable = false;
  3218. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3219. // a CoarseLocationUpdate packet is received. Oh well.
  3220. int total = Math.Min(CoarseLocations.Count, 60);
  3221. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3222. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3223. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3224. int selfindex = -1;
  3225. for (int i = 0; i < total; i++)
  3226. {
  3227. CoarseLocationUpdatePacket.LocationBlock lb =
  3228. new CoarseLocationUpdatePacket.LocationBlock();
  3229. lb.X = (byte)CoarseLocations[i].X;
  3230. lb.Y = (byte)CoarseLocations[i].Y;
  3231. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3232. loc.Location[i] = lb;
  3233. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3234. loc.AgentData[i].AgentID = users[i];
  3235. if (users[i] == AgentId)
  3236. selfindex = i;
  3237. }
  3238. ib.You = (short)selfindex;
  3239. ib.Prey = -1;
  3240. loc.Index = ib;
  3241. OutPacket(loc, ThrottleOutPacketType.Task);
  3242. }
  3243. #endregion Avatar Packet/Data Sending Methods
  3244. #region Primitive Packet/Data Sending Methods
  3245. /// <summary>
  3246. /// Generate one of the object update packets based on PrimUpdateFlags
  3247. /// and broadcast the packet to clients
  3248. /// </summary>
  3249. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3250. {
  3251. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3252. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3253. lock (m_entityUpdates.SyncRoot)
  3254. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3255. }
  3256. /// <summary>
  3257. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3258. /// We will update the priority and put it in the correct queue, merging update flags
  3259. /// with any other updates that may be queued for the same entity.
  3260. /// The original update time is used for the merged update.
  3261. /// </summary>
  3262. private void ResendPrimUpdate(EntityUpdate update)
  3263. {
  3264. // If the update exists in priority queue, it will be updated.
  3265. // If it does not exist then it will be added with the current (rather than its original) priority
  3266. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3267. lock (m_entityUpdates.SyncRoot)
  3268. m_entityUpdates.Enqueue(priority, update);
  3269. }
  3270. /// <summary>
  3271. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3272. /// We will update the priority and put it in the correct queue, merging update flags
  3273. /// with any other updates that may be queued for the same entity.
  3274. /// The original update time is used for the merged update.
  3275. /// </summary>
  3276. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3277. {
  3278. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3279. // Remove the update packet from the list of packets waiting for acknowledgement
  3280. // because we are requeuing the list of updates. They will be resent in new packets
  3281. // with the most recent state and priority.
  3282. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3283. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3284. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3285. // We're not going to worry about interlock yet since its not currently critical that this total count
  3286. // is 100% correct
  3287. m_udpServer.PacketsResentCount++;
  3288. foreach (EntityUpdate update in updates)
  3289. ResendPrimUpdate(update);
  3290. }
  3291. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3292. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3293. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3294. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3295. //
  3296. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3297. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3298. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3299. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3300. private void ProcessEntityUpdates(int maxUpdates)
  3301. {
  3302. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3303. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3304. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3305. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3306. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3307. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3308. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3309. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3310. // objectUpdateBlocks.Value.Clear();
  3311. // compressedUpdateBlocks.Value.Clear();
  3312. // terseUpdateBlocks.Value.Clear();
  3313. // terseAgentUpdateBlocks.Value.Clear();
  3314. // objectUpdates.Value.Clear();
  3315. // compressedUpdates.Value.Clear();
  3316. // terseUpdates.Value.Clear();
  3317. // terseAgentUpdates.Value.Clear();
  3318. // Check to see if this is a flush
  3319. if (maxUpdates <= 0)
  3320. {
  3321. maxUpdates = Int32.MaxValue;
  3322. }
  3323. int updatesThisCall = 0;
  3324. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3325. // condition where a kill can be processed before an out-of-date update for the same object.
  3326. lock (m_killRecord)
  3327. {
  3328. float avgTimeDilation = 1.0f;
  3329. IEntityUpdate iupdate;
  3330. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3331. while (updatesThisCall < maxUpdates)
  3332. {
  3333. lock (m_entityUpdates.SyncRoot)
  3334. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3335. break;
  3336. EntityUpdate update = (EntityUpdate)iupdate;
  3337. avgTimeDilation += update.TimeDilation;
  3338. avgTimeDilation *= 0.5f;
  3339. if (update.Entity is SceneObjectPart)
  3340. {
  3341. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3342. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3343. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3344. // safety measure.
  3345. //
  3346. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3347. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3348. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3349. //
  3350. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3351. // after the root prim has been deleted.
  3352. if (m_killRecord.Contains(part.LocalId))
  3353. {
  3354. // m_log.WarnFormat(
  3355. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3356. // part.LocalId, Name);
  3357. continue;
  3358. }
  3359. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3360. {
  3361. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3362. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3363. {
  3364. part.Shape.LightEntry = false;
  3365. }
  3366. }
  3367. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3368. {
  3369. // Ensure that mesh has at least 8 valid faces
  3370. part.Shape.ProfileBegin = 12500;
  3371. part.Shape.ProfileEnd = 0;
  3372. part.Shape.ProfileHollow = 27500;
  3373. }
  3374. }
  3375. #region UpdateFlags to packet type conversion
  3376. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3377. bool canUseCompressed = true;
  3378. bool canUseImproved = true;
  3379. // Compressed object updates only make sense for LL primitives
  3380. if (!(update.Entity is SceneObjectPart))
  3381. {
  3382. canUseCompressed = false;
  3383. }
  3384. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3385. {
  3386. canUseCompressed = false;
  3387. canUseImproved = false;
  3388. }
  3389. else
  3390. {
  3391. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3392. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3393. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3394. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3395. {
  3396. canUseCompressed = false;
  3397. }
  3398. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3399. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3400. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3401. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3402. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3403. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3404. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3405. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3406. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3407. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3408. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3409. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3410. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3411. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3412. {
  3413. canUseImproved = false;
  3414. }
  3415. }
  3416. #endregion UpdateFlags to packet type conversion
  3417. #region Block Construction
  3418. // TODO: Remove this once we can build compressed updates
  3419. canUseCompressed = false;
  3420. if (!canUseImproved && !canUseCompressed)
  3421. {
  3422. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3423. if (update.Entity is ScenePresence)
  3424. {
  3425. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3426. }
  3427. else
  3428. {
  3429. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3430. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3431. // If the part has become a private hud since the update was scheduled then we do not
  3432. // want to send it to other avatars.
  3433. if (part.ParentGroup.IsAttachment
  3434. && part.ParentGroup.HasPrivateAttachmentPoint
  3435. && part.ParentGroup.AttachedAvatar != AgentId)
  3436. continue;
  3437. // If the part has since been deleted, then drop the update. In the case of attachments,
  3438. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3439. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3440. // of the test above).
  3441. //
  3442. // Actual deletions (kills) happen in another method.
  3443. if (part.ParentGroup.IsDeleted)
  3444. continue;
  3445. }
  3446. objectUpdateBlocks.Value.Add(updateBlock);
  3447. objectUpdates.Value.Add(update);
  3448. }
  3449. else if (!canUseImproved)
  3450. {
  3451. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3452. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3453. = CreateCompressedUpdateBlock(part, updateFlags);
  3454. // If the part has since been deleted, then drop the update. In the case of attachments,
  3455. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3456. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3457. // of the test above).
  3458. //
  3459. // Actual deletions (kills) happen in another method.
  3460. if (part.ParentGroup.IsDeleted)
  3461. continue;
  3462. compressedUpdateBlocks.Value.Add(compressedBlock);
  3463. compressedUpdates.Value.Add(update);
  3464. }
  3465. else
  3466. {
  3467. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3468. {
  3469. // Self updates go into a special list
  3470. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3471. terseAgentUpdates.Value.Add(update);
  3472. }
  3473. else
  3474. {
  3475. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3476. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3477. // Everything else goes here
  3478. if (update.Entity is SceneObjectPart)
  3479. {
  3480. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3481. // If the part has become a private hud since the update was scheduled then we do not
  3482. // want to send it to other avatars.
  3483. if (part.ParentGroup.IsAttachment
  3484. && part.ParentGroup.HasPrivateAttachmentPoint
  3485. && part.ParentGroup.AttachedAvatar != AgentId)
  3486. continue;
  3487. // If the part has since been deleted, then drop the update. In the case of attachments,
  3488. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3489. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3490. // of the test above).
  3491. //
  3492. // Actual deletions (kills) happen in another method.
  3493. if (part.ParentGroup.IsDeleted)
  3494. continue;
  3495. }
  3496. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3497. terseUpdates.Value.Add(update);
  3498. }
  3499. }
  3500. ++updatesThisCall;
  3501. #endregion Block Construction
  3502. }
  3503. #region Packet Sending
  3504. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3505. if (terseAgentUpdateBlocks.IsValueCreated)
  3506. {
  3507. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3508. ImprovedTerseObjectUpdatePacket packet
  3509. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3510. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3511. packet.RegionData.TimeDilation = timeDilation;
  3512. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3513. for (int i = 0; i < blocks.Count; i++)
  3514. packet.ObjectData[i] = blocks[i];
  3515. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3516. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3517. }
  3518. if (objectUpdateBlocks.IsValueCreated)
  3519. {
  3520. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3521. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3522. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3523. packet.RegionData.TimeDilation = timeDilation;
  3524. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3525. for (int i = 0; i < blocks.Count; i++)
  3526. packet.ObjectData[i] = blocks[i];
  3527. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3528. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3529. }
  3530. if (compressedUpdateBlocks.IsValueCreated)
  3531. {
  3532. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3533. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3534. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3535. packet.RegionData.TimeDilation = timeDilation;
  3536. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3537. for (int i = 0; i < blocks.Count; i++)
  3538. packet.ObjectData[i] = blocks[i];
  3539. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3540. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3541. }
  3542. if (terseUpdateBlocks.IsValueCreated)
  3543. {
  3544. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3545. ImprovedTerseObjectUpdatePacket packet
  3546. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3547. PacketType.ImprovedTerseObjectUpdate);
  3548. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3549. packet.RegionData.TimeDilation = timeDilation;
  3550. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3551. for (int i = 0; i < blocks.Count; i++)
  3552. packet.ObjectData[i] = blocks[i];
  3553. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3554. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3555. }
  3556. }
  3557. #endregion Packet Sending
  3558. }
  3559. public void ReprioritizeUpdates()
  3560. {
  3561. lock (m_entityUpdates.SyncRoot)
  3562. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3563. }
  3564. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3565. {
  3566. if (entity != null)
  3567. {
  3568. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3569. return true;
  3570. }
  3571. return false;
  3572. }
  3573. public void FlushPrimUpdates()
  3574. {
  3575. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3576. while (m_entityUpdates.Count > 0)
  3577. ProcessEntityUpdates(-1);
  3578. }
  3579. #endregion Primitive Packet/Data Sending Methods
  3580. // These are used to implement an adaptive backoff in the number
  3581. // of updates converted to packets. Since we don't want packets
  3582. // to sit in the queue with old data, only convert enough updates
  3583. // to packets that can be sent in 200ms.
  3584. private Int32 m_LastQueueFill = 0;
  3585. private Int32 m_maxUpdates = 0;
  3586. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3587. {
  3588. // if (!m_udpServer.IsRunningOutbound)
  3589. // return;
  3590. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3591. {
  3592. // if (!m_udpServer.IsRunningOutbound)
  3593. // return;
  3594. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3595. {
  3596. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3597. }
  3598. else
  3599. {
  3600. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3601. m_maxUpdates += 5;
  3602. else
  3603. m_maxUpdates = m_maxUpdates >> 1;
  3604. }
  3605. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3606. m_LastQueueFill = Util.EnvironmentTickCount();
  3607. if (m_entityUpdates.Count > 0)
  3608. ProcessEntityUpdates(m_maxUpdates);
  3609. if (m_entityProps.Count > 0)
  3610. ProcessEntityPropertyRequests(m_maxUpdates);
  3611. }
  3612. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3613. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3614. }
  3615. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3616. {
  3617. bool hasUpdates = false;
  3618. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3619. {
  3620. if (m_entityUpdates.Count > 0)
  3621. hasUpdates = true;
  3622. else if (m_entityProps.Count > 0)
  3623. hasUpdates = true;
  3624. }
  3625. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3626. {
  3627. if (ImageManager.HasUpdates())
  3628. hasUpdates = true;
  3629. }
  3630. return hasUpdates;
  3631. }
  3632. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3633. {
  3634. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3635. newPack.AssetBlock.Type = AssetType;
  3636. newPack.AssetBlock.Success = Success;
  3637. newPack.AssetBlock.UUID = AssetFullID;
  3638. newPack.Header.Zerocoded = true;
  3639. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3640. }
  3641. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3642. {
  3643. RequestXferPacket newPack = new RequestXferPacket();
  3644. newPack.XferID.ID = XferID;
  3645. newPack.XferID.VFileType = AssetType;
  3646. newPack.XferID.VFileID = vFileID;
  3647. newPack.XferID.FilePath = FilePath;
  3648. newPack.XferID.Filename = FileName;
  3649. newPack.Header.Zerocoded = true;
  3650. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3651. }
  3652. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3653. {
  3654. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3655. newPack.XferID.ID = xferID;
  3656. newPack.XferID.Packet = PacketID;
  3657. newPack.Header.Zerocoded = true;
  3658. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3659. }
  3660. public void SendInitiateDownload(string simFileName, string clientFileName)
  3661. {
  3662. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3663. newPack.AgentData.AgentID = AgentId;
  3664. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3665. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3666. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3667. }
  3668. public void SendImageFirstPart(
  3669. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3670. {
  3671. ImageDataPacket im = new ImageDataPacket();
  3672. im.Header.Reliable = false;
  3673. im.ImageID.Packets = numParts;
  3674. im.ImageID.ID = ImageUUID;
  3675. if (ImageSize > 0)
  3676. im.ImageID.Size = ImageSize;
  3677. im.ImageData.Data = ImageData;
  3678. im.ImageID.Codec = imageCodec;
  3679. im.Header.Zerocoded = true;
  3680. OutPacket(im, ThrottleOutPacketType.Texture);
  3681. }
  3682. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3683. {
  3684. ImagePacketPacket im = new ImagePacketPacket();
  3685. im.Header.Reliable = false;
  3686. im.ImageID.Packet = partNumber;
  3687. im.ImageID.ID = imageUuid;
  3688. im.ImageData.Data = imageData;
  3689. OutPacket(im, ThrottleOutPacketType.Texture);
  3690. }
  3691. public void SendImageNotFound(UUID imageid)
  3692. {
  3693. ImageNotInDatabasePacket notFoundPacket
  3694. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3695. notFoundPacket.ImageID.ID = imageid;
  3696. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3697. }
  3698. public void SendShutdownConnectionNotice()
  3699. {
  3700. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3701. }
  3702. public void SendSimStats(SimStats stats)
  3703. {
  3704. SimStatsPacket pack = new SimStatsPacket();
  3705. pack.Region = new SimStatsPacket.RegionBlock();
  3706. pack.Region.RegionX = stats.RegionX;
  3707. pack.Region.RegionY = stats.RegionY;
  3708. pack.Region.RegionFlags = stats.RegionFlags;
  3709. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3710. //pack.Region = //stats.RegionBlock;
  3711. pack.Stat = stats.StatsBlock;
  3712. pack.Header.Reliable = false;
  3713. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3714. OutPacket(pack, ThrottleOutPacketType.Task);
  3715. }
  3716. private class ObjectPropertyUpdate : IEntityUpdate
  3717. {
  3718. internal bool SendFamilyProps;
  3719. internal bool SendObjectProps;
  3720. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3721. : base(entity,flags)
  3722. {
  3723. SendFamilyProps = sendfam;
  3724. SendObjectProps = sendobj;
  3725. }
  3726. public void Update(ObjectPropertyUpdate update)
  3727. {
  3728. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3729. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3730. // other properties may need to be updated by base class
  3731. base.Update(update);
  3732. }
  3733. }
  3734. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3735. {
  3736. uint priority = 0; // time based ordering only
  3737. lock (m_entityProps.SyncRoot)
  3738. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3739. }
  3740. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3741. {
  3742. uint priority = 0;
  3743. lock (m_entityProps.SyncRoot)
  3744. m_entityProps.Enqueue(priority, update);
  3745. }
  3746. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3747. {
  3748. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3749. // Remove the update packet from the list of packets waiting for acknowledgement
  3750. // because we are requeuing the list of updates. They will be resent in new packets
  3751. // with the most recent state.
  3752. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3753. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3754. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3755. // We're not going to worry about interlock yet since its not currently critical that this total count
  3756. // is 100% correct
  3757. m_udpServer.PacketsResentCount++;
  3758. foreach (ObjectPropertyUpdate update in updates)
  3759. ResendPropertyUpdate(update);
  3760. }
  3761. public void SendObjectPropertiesReply(ISceneEntity entity)
  3762. {
  3763. uint priority = 0; // time based ordering only
  3764. lock (m_entityProps.SyncRoot)
  3765. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3766. }
  3767. private void ProcessEntityPropertyRequests(int maxUpdates)
  3768. {
  3769. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3770. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3771. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3772. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3773. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3774. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3775. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3776. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3777. IEntityUpdate iupdate;
  3778. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3779. int updatesThisCall = 0;
  3780. while (updatesThisCall < m_maxUpdates)
  3781. {
  3782. lock (m_entityProps.SyncRoot)
  3783. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3784. break;
  3785. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3786. if (update.SendFamilyProps)
  3787. {
  3788. if (update.Entity is SceneObjectPart)
  3789. {
  3790. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3791. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3792. objectFamilyBlocks.Value.Add(objPropDB);
  3793. familyUpdates.Value.Add(update);
  3794. }
  3795. }
  3796. if (update.SendObjectProps)
  3797. {
  3798. if (update.Entity is SceneObjectPart)
  3799. {
  3800. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3801. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3802. objectPropertiesBlocks.Value.Add(objPropDB);
  3803. propertyUpdates.Value.Add(update);
  3804. }
  3805. }
  3806. updatesThisCall++;
  3807. }
  3808. // Int32 ppcnt = 0;
  3809. // Int32 pbcnt = 0;
  3810. if (objectPropertiesBlocks.IsValueCreated)
  3811. {
  3812. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3813. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3814. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3815. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3816. for (int i = 0; i < blocks.Count; i++)
  3817. packet.ObjectData[i] = blocks[i];
  3818. packet.Header.Zerocoded = true;
  3819. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3820. // of the object rather than the properties when the packet was created
  3821. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3822. delegate(OutgoingPacket oPacket)
  3823. {
  3824. ResendPropertyUpdates(updates, oPacket);
  3825. });
  3826. // pbcnt += blocks.Count;
  3827. // ppcnt++;
  3828. }
  3829. // Int32 fpcnt = 0;
  3830. // Int32 fbcnt = 0;
  3831. if (objectFamilyBlocks.IsValueCreated)
  3832. {
  3833. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3834. // one packet per object block... uggh...
  3835. for (int i = 0; i < blocks.Count; i++)
  3836. {
  3837. ObjectPropertiesFamilyPacket packet =
  3838. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3839. packet.ObjectData = blocks[i];
  3840. packet.Header.Zerocoded = true;
  3841. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3842. // of the object rather than the properties when the packet was created
  3843. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3844. updates.Add(familyUpdates.Value[i]);
  3845. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3846. delegate(OutgoingPacket oPacket)
  3847. {
  3848. ResendPropertyUpdates(updates, oPacket);
  3849. });
  3850. // fpcnt++;
  3851. // fbcnt++;
  3852. }
  3853. }
  3854. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3855. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3856. }
  3857. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3858. {
  3859. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3860. block.RequestFlags = requestFlags;
  3861. block.ObjectID = sop.UUID;
  3862. if (sop.OwnerID == sop.GroupID)
  3863. block.OwnerID = UUID.Zero;
  3864. else
  3865. block.OwnerID = sop.OwnerID;
  3866. block.GroupID = sop.GroupID;
  3867. block.BaseMask = sop.BaseMask;
  3868. block.OwnerMask = sop.OwnerMask;
  3869. block.GroupMask = sop.GroupMask;
  3870. block.EveryoneMask = sop.EveryoneMask;
  3871. block.NextOwnerMask = sop.NextOwnerMask;
  3872. // TODO: More properties are needed in SceneObjectPart!
  3873. block.OwnershipCost = sop.OwnershipCost;
  3874. block.SaleType = sop.ObjectSaleType;
  3875. block.SalePrice = sop.SalePrice;
  3876. block.Category = sop.Category;
  3877. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3878. block.Name = Util.StringToBytes256(sop.Name);
  3879. block.Description = Util.StringToBytes256(sop.Description);
  3880. return block;
  3881. }
  3882. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3883. {
  3884. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3885. // TODO: don't create new blocks if recycling an old packet
  3886. ObjectPropertiesPacket.ObjectDataBlock block =
  3887. new ObjectPropertiesPacket.ObjectDataBlock();
  3888. block.ObjectID = sop.UUID;
  3889. block.Name = Util.StringToBytes256(sop.Name);
  3890. block.Description = Util.StringToBytes256(sop.Description);
  3891. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3892. block.CreatorID = sop.CreatorID;
  3893. block.GroupID = sop.GroupID;
  3894. block.LastOwnerID = sop.LastOwnerID;
  3895. if (sop.OwnerID == sop.GroupID)
  3896. block.OwnerID = UUID.Zero;
  3897. else
  3898. block.OwnerID = sop.OwnerID;
  3899. block.ItemID = sop.FromUserInventoryItemID;
  3900. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3901. block.FromTaskID = UUID.Zero; // ???
  3902. block.InventorySerial = (short)sop.InventorySerial;
  3903. SceneObjectPart root = sop.ParentGroup.RootPart;
  3904. block.TouchName = Util.StringToBytes256(root.TouchName);
  3905. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  3906. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  3907. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  3908. // using (MemoryStream memStream = new MemoryStream())
  3909. // {
  3910. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  3911. // {
  3912. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  3913. // {
  3914. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  3915. //
  3916. // UUID textureID;
  3917. //
  3918. // if (teFace != null)
  3919. // textureID = teFace.TextureID;
  3920. // else
  3921. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  3922. //
  3923. // binWriter.Write(textureID.GetBytes());
  3924. // }
  3925. //
  3926. // block.TextureID = memStream.ToArray();
  3927. // }
  3928. // }
  3929. block.TextureID = new byte[0]; // TextureID ???
  3930. block.SitName = Util.StringToBytes256(root.SitName);
  3931. block.OwnerMask = root.OwnerMask;
  3932. block.NextOwnerMask = root.NextOwnerMask;
  3933. block.GroupMask = root.GroupMask;
  3934. block.EveryoneMask = root.EveryoneMask;
  3935. block.BaseMask = root.BaseMask;
  3936. block.SaleType = root.ObjectSaleType;
  3937. block.SalePrice = root.SalePrice;
  3938. return block;
  3939. }
  3940. #region Estate Data Sending Methods
  3941. private static bool convertParamStringToBool(byte[] field)
  3942. {
  3943. string s = Utils.BytesToString(field);
  3944. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3945. {
  3946. return true;
  3947. }
  3948. return false;
  3949. }
  3950. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3951. {
  3952. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3953. packet.AgentData.TransactionID = UUID.Random();
  3954. packet.AgentData.AgentID = AgentId;
  3955. packet.AgentData.SessionID = SessionId;
  3956. packet.MethodData.Invoice = invoice;
  3957. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3958. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3959. for (int i = 0; i < (6 + Data.Length); i++)
  3960. {
  3961. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3962. }
  3963. int j = 0;
  3964. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3965. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3966. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3967. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3968. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3969. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3970. j = 2; // Agents
  3971. if ((code & 2) != 0)
  3972. j = 3; // Groups
  3973. if ((code & 8) != 0)
  3974. j = 5; // Managers
  3975. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3976. j = 6;
  3977. for (int i = 0; i < Data.Length; i++)
  3978. {
  3979. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3980. }
  3981. packet.ParamList = returnblock;
  3982. packet.Header.Reliable = true;
  3983. OutPacket(packet, ThrottleOutPacketType.Task);
  3984. }
  3985. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3986. {
  3987. List<UUID> BannedUsers = new List<UUID>();
  3988. for (int i = 0; i < bl.Length; i++)
  3989. {
  3990. if (bl[i] == null)
  3991. continue;
  3992. if (bl[i].BannedUserID == UUID.Zero)
  3993. continue;
  3994. BannedUsers.Add(bl[i].BannedUserID);
  3995. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3996. {
  3997. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3998. packet.AgentData.TransactionID = UUID.Random();
  3999. packet.AgentData.AgentID = AgentId;
  4000. packet.AgentData.SessionID = SessionId;
  4001. packet.MethodData.Invoice = invoice;
  4002. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  4003. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  4004. int j;
  4005. for (j = 0; j < (6 + BannedUsers.Count); j++)
  4006. {
  4007. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  4008. }
  4009. j = 0;
  4010. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  4011. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  4012. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4013. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4014. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  4015. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4016. foreach (UUID banned in BannedUsers)
  4017. {
  4018. returnblock[j].Parameter = banned.GetBytes(); j++;
  4019. }
  4020. packet.ParamList = returnblock;
  4021. packet.Header.Reliable = true;
  4022. OutPacket(packet, ThrottleOutPacketType.Task);
  4023. BannedUsers.Clear();
  4024. }
  4025. }
  4026. }
  4027. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4028. {
  4029. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4030. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4031. rinfopack.AgentData.AgentID = AgentId;
  4032. rinfopack.AgentData.SessionID = SessionId;
  4033. rinfoblk.BillableFactor = args.billableFactor;
  4034. rinfoblk.EstateID = args.estateID;
  4035. rinfoblk.MaxAgents = args.maxAgents;
  4036. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4037. rinfoblk.ParentEstateID = args.parentEstateID;
  4038. rinfoblk.PricePerMeter = args.pricePerMeter;
  4039. rinfoblk.RedirectGridX = args.redirectGridX;
  4040. rinfoblk.RedirectGridY = args.redirectGridY;
  4041. rinfoblk.RegionFlags = args.regionFlags;
  4042. rinfoblk.SimAccess = args.simAccess;
  4043. rinfoblk.SunHour = args.sunHour;
  4044. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4045. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4046. rinfoblk.UseEstateSun = args.useEstateSun;
  4047. rinfoblk.WaterHeight = args.waterHeight;
  4048. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4049. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4050. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4051. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4052. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4053. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4054. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4055. rinfopack.HasVariableBlocks = true;
  4056. rinfopack.RegionInfo = rinfoblk;
  4057. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4058. rinfopack.AgentData.AgentID = AgentId;
  4059. rinfopack.AgentData.SessionID = SessionId;
  4060. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4061. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4062. }
  4063. public void SendEstateCovenantInformation(UUID covenant)
  4064. {
  4065. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4066. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4067. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4068. edata.CovenantID = covenant;
  4069. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4070. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4071. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4072. einfopack.Data = edata;
  4073. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4074. }
  4075. public void SendDetailedEstateData(
  4076. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4077. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4078. {
  4079. // m_log.DebugFormat(
  4080. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4081. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4082. packet.MethodData.Invoice = invoice;
  4083. packet.AgentData.TransactionID = UUID.Random();
  4084. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4085. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4086. for (int i = 0; i < 10; i++)
  4087. {
  4088. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4089. }
  4090. //Sending Estate Settings
  4091. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4092. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4093. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4094. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4095. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4096. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4097. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4098. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4099. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4100. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4101. packet.ParamList = returnblock;
  4102. packet.Header.Reliable = false;
  4103. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4104. OutPacket(packet, ThrottleOutPacketType.Task);
  4105. }
  4106. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4107. {
  4108. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4109. packet.TelehubBlock.ObjectID = ObjectID;
  4110. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4111. packet.TelehubBlock.TelehubPos = ObjectPos;
  4112. packet.TelehubBlock.TelehubRot = ObjectRot;
  4113. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4114. for (int n = 0; n < SpawnPoint.Count; n++)
  4115. {
  4116. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4117. }
  4118. OutPacket(packet, ThrottleOutPacketType.Task);
  4119. }
  4120. #endregion
  4121. #region Land Data Sending Methods
  4122. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4123. {
  4124. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4125. packet.ParcelData.Data = data;
  4126. packet.ParcelData.SequenceID = sequence_id;
  4127. packet.Header.Zerocoded = true;
  4128. OutPacket(packet, ThrottleOutPacketType.Task);
  4129. }
  4130. public void SendLandProperties(
  4131. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4132. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4133. {
  4134. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4135. LandData landData = lo.LandData;
  4136. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4137. updateMessage.AABBMax = landData.AABBMax;
  4138. updateMessage.AABBMin = landData.AABBMin;
  4139. updateMessage.Area = landData.Area;
  4140. updateMessage.AuctionID = landData.AuctionID;
  4141. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4142. updateMessage.Bitmap = landData.Bitmap;
  4143. updateMessage.Desc = landData.Description;
  4144. updateMessage.Category = landData.Category;
  4145. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4146. updateMessage.ClaimPrice = landData.ClaimPrice;
  4147. updateMessage.GroupID = landData.GroupID;
  4148. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4149. updateMessage.LandingType = (LandingType) landData.LandingType;
  4150. updateMessage.LocalID = landData.LocalID;
  4151. if (landData.Area > 0)
  4152. {
  4153. updateMessage.MaxPrims = parcelObjectCapacity;
  4154. }
  4155. else
  4156. {
  4157. updateMessage.MaxPrims = 0;
  4158. }
  4159. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4160. updateMessage.MediaID = landData.MediaID;
  4161. updateMessage.MediaURL = landData.MediaURL;
  4162. updateMessage.MusicURL = landData.MusicURL;
  4163. updateMessage.Name = landData.Name;
  4164. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4165. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4166. updateMessage.OwnerID = landData.OwnerID;
  4167. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4168. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4169. updateMessage.PassHours = landData.PassHours;
  4170. updateMessage.PassPrice = landData.PassPrice;
  4171. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4172. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4173. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4174. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4175. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4176. updateMessage.RentPrice = 0;
  4177. updateMessage.RequestResult = (ParcelResult) request_result;
  4178. updateMessage.SalePrice = landData.SalePrice;
  4179. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4180. updateMessage.SequenceID = sequence_id;
  4181. if (landData.SimwideArea > 0)
  4182. {
  4183. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4184. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4185. }
  4186. else
  4187. {
  4188. updateMessage.SimWideMaxPrims = 0;
  4189. }
  4190. updateMessage.SnapSelection = snap_selection;
  4191. updateMessage.SnapshotID = landData.SnapshotID;
  4192. updateMessage.Status = (ParcelStatus) landData.Status;
  4193. updateMessage.UserLocation = landData.UserLocation;
  4194. updateMessage.UserLookAt = landData.UserLookAt;
  4195. updateMessage.MediaType = landData.MediaType;
  4196. updateMessage.MediaDesc = landData.MediaDescription;
  4197. updateMessage.MediaWidth = landData.MediaWidth;
  4198. updateMessage.MediaHeight = landData.MediaHeight;
  4199. updateMessage.MediaLoop = landData.MediaLoop;
  4200. updateMessage.ObscureMusic = landData.ObscureMusic;
  4201. updateMessage.ObscureMedia = landData.ObscureMedia;
  4202. IPrimCounts pc = lo.PrimCounts;
  4203. updateMessage.OwnerPrims = pc.Owner;
  4204. updateMessage.GroupPrims = pc.Group;
  4205. updateMessage.OtherPrims = pc.Others;
  4206. updateMessage.SelectedPrims = pc.Selected;
  4207. updateMessage.TotalPrims = pc.Total;
  4208. updateMessage.SimWideTotalPrims = pc.Simulator;
  4209. try
  4210. {
  4211. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4212. if (eq != null)
  4213. {
  4214. eq.ParcelProperties(updateMessage, this.AgentId);
  4215. }
  4216. else
  4217. {
  4218. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4219. }
  4220. }
  4221. catch (Exception ex)
  4222. {
  4223. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4224. }
  4225. }
  4226. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4227. {
  4228. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4229. replyPacket.Data.AgentID = AgentId;
  4230. replyPacket.Data.Flags = accessFlag;
  4231. replyPacket.Data.LocalID = localLandID;
  4232. replyPacket.Data.SequenceID = 0;
  4233. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4234. foreach (LandAccessEntry entry in accessList)
  4235. {
  4236. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4237. block.Flags = accessFlag;
  4238. block.ID = entry.AgentID;
  4239. block.Time = entry.Expires;
  4240. list.Add(block);
  4241. }
  4242. replyPacket.List = list.ToArray();
  4243. replyPacket.Header.Zerocoded = true;
  4244. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4245. }
  4246. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4247. {
  4248. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4249. bool firstCall = true;
  4250. const int MAX_OBJECTS_PER_PACKET = 251;
  4251. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4252. ForceObjectSelectPacket.DataBlock[] data;
  4253. while (ObjectIDs.Count > 0)
  4254. {
  4255. if (firstCall)
  4256. {
  4257. pack._Header.ResetList = true;
  4258. firstCall = false;
  4259. }
  4260. else
  4261. {
  4262. pack._Header.ResetList = false;
  4263. }
  4264. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4265. {
  4266. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4267. }
  4268. else
  4269. {
  4270. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4271. }
  4272. int i;
  4273. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4274. {
  4275. data[i] = new ForceObjectSelectPacket.DataBlock();
  4276. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4277. ObjectIDs.RemoveAt(0);
  4278. }
  4279. pack.Data = data;
  4280. pack.Header.Zerocoded = true;
  4281. OutPacket(pack, ThrottleOutPacketType.Task);
  4282. }
  4283. }
  4284. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4285. {
  4286. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4287. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4288. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4289. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4290. OutPacket(cpack, ThrottleOutPacketType.Task);
  4291. }
  4292. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4293. {
  4294. int notifyCount = ownersAndCount.Count;
  4295. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4296. if (notifyCount > 0)
  4297. {
  4298. if (notifyCount > 32)
  4299. {
  4300. m_log.InfoFormat(
  4301. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4302. + " - a developer might want to investigate whether this is a hard limit", 32);
  4303. notifyCount = 32;
  4304. }
  4305. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4306. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4307. int num = 0;
  4308. foreach (UUID owner in ownersAndCount.Keys)
  4309. {
  4310. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4311. dataBlock[num].Count = ownersAndCount[owner];
  4312. if (land.GroupID == owner || groups.Contains(owner))
  4313. dataBlock[num].IsGroupOwned = true;
  4314. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4315. dataBlock[num].OwnerID = owner;
  4316. num++;
  4317. if (num >= notifyCount)
  4318. {
  4319. break;
  4320. }
  4321. }
  4322. pack.Data = dataBlock;
  4323. }
  4324. else
  4325. {
  4326. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4327. }
  4328. pack.Header.Zerocoded = true;
  4329. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4330. }
  4331. #endregion
  4332. #region Helper Methods
  4333. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4334. {
  4335. #region ScenePresence/SOP Handling
  4336. bool avatar = (entity is ScenePresence);
  4337. uint localID = entity.LocalId;
  4338. uint attachPoint;
  4339. Vector4 collisionPlane;
  4340. Vector3 position, velocity, acceleration, angularVelocity;
  4341. Quaternion rotation;
  4342. byte[] textureEntry;
  4343. if (entity is ScenePresence)
  4344. {
  4345. ScenePresence presence = (ScenePresence)entity;
  4346. // m_log.DebugFormat(
  4347. // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
  4348. attachPoint = presence.State;
  4349. collisionPlane = presence.CollisionPlane;
  4350. position = presence.OffsetPosition;
  4351. velocity = presence.Velocity;
  4352. acceleration = Vector3.Zero;
  4353. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4354. // in that direction, even though we don't model this on the server. Implementing this in the future
  4355. // may improve movement smoothness.
  4356. // acceleration = new Vector3(1, 0, 0);
  4357. angularVelocity = presence.AngularVelocity;
  4358. rotation = presence.Rotation;
  4359. if (sendTexture)
  4360. textureEntry = presence.Appearance.Texture.GetBytes();
  4361. else
  4362. textureEntry = null;
  4363. }
  4364. else
  4365. {
  4366. SceneObjectPart part = (SceneObjectPart)entity;
  4367. attachPoint = part.ParentGroup.AttachmentPoint;
  4368. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4369. // m_log.DebugFormat(
  4370. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4371. // attachPoint, part.Name, part.LocalId, Name);
  4372. collisionPlane = Vector4.Zero;
  4373. position = part.RelativePosition;
  4374. velocity = part.Velocity;
  4375. acceleration = part.Acceleration;
  4376. angularVelocity = part.AngularVelocity;
  4377. rotation = part.RotationOffset;
  4378. if (sendTexture)
  4379. textureEntry = part.Shape.TextureEntry;
  4380. else
  4381. textureEntry = null;
  4382. }
  4383. #endregion ScenePresence/SOP Handling
  4384. int pos = 0;
  4385. byte[] data = new byte[(avatar ? 60 : 44)];
  4386. // LocalID
  4387. Utils.UIntToBytes(localID, data, pos);
  4388. pos += 4;
  4389. // Avatar/CollisionPlane
  4390. data[pos++] = (byte) attachPoint;
  4391. if (avatar)
  4392. {
  4393. data[pos++] = 1;
  4394. if (collisionPlane == Vector4.Zero)
  4395. collisionPlane = Vector4.UnitW;
  4396. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4397. collisionPlane.ToBytes(data, pos);
  4398. pos += 16;
  4399. }
  4400. else
  4401. {
  4402. ++pos;
  4403. }
  4404. // Position
  4405. position.ToBytes(data, pos);
  4406. pos += 12;
  4407. // Velocity
  4408. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4409. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4410. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4411. // Acceleration
  4412. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4413. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4414. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4415. // Rotation
  4416. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4417. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4418. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4419. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4420. // Angular Velocity
  4421. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4422. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4423. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4424. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4425. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4426. block.Data = data;
  4427. if (textureEntry != null && textureEntry.Length > 0)
  4428. {
  4429. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4430. // Texture Length
  4431. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4432. // Texture
  4433. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4434. block.TextureEntry = teBytesFinal;
  4435. }
  4436. else
  4437. {
  4438. block.TextureEntry = Utils.EmptyBytes;
  4439. }
  4440. return block;
  4441. }
  4442. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4443. {
  4444. // m_log.DebugFormat(
  4445. // "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name);
  4446. byte[] objectData = new byte[76];
  4447. data.CollisionPlane.ToBytes(objectData, 0);
  4448. data.OffsetPosition.ToBytes(objectData, 16);
  4449. // data.Velocity.ToBytes(objectData, 28);
  4450. // data.Acceleration.ToBytes(objectData, 40);
  4451. data.Rotation.ToBytes(objectData, 52);
  4452. //data.AngularVelocity.ToBytes(objectData, 64);
  4453. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4454. update.Data = Utils.EmptyBytes;
  4455. update.ExtraParams = new byte[1];
  4456. update.FullID = data.UUID;
  4457. update.ID = data.LocalId;
  4458. update.Material = (byte)Material.Flesh;
  4459. update.MediaURL = Utils.EmptyBytes;
  4460. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4461. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4462. update.ObjectData = objectData;
  4463. SceneObjectPart parentPart = data.ParentPart;
  4464. if (parentPart != null)
  4465. update.ParentID = parentPart.ParentGroup.LocalId;
  4466. else
  4467. update.ParentID = 0;
  4468. update.PathCurve = 16;
  4469. update.PathScaleX = 100;
  4470. update.PathScaleY = 100;
  4471. update.PCode = (byte)PCode.Avatar;
  4472. update.ProfileCurve = 1;
  4473. update.PSBlock = Utils.EmptyBytes;
  4474. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4475. update.Text = Utils.EmptyBytes;
  4476. update.TextColor = new byte[4];
  4477. // Don't send texture anim for avatars - this has no meaning for them.
  4478. update.TextureAnim = Utils.EmptyBytes;
  4479. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4480. update.TextureEntry = Utils.EmptyBytes;
  4481. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4482. update.UpdateFlags = (uint)(
  4483. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4484. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4485. PrimFlags.ObjectOwnerModify);
  4486. return update;
  4487. }
  4488. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4489. {
  4490. byte[] objectData = new byte[60];
  4491. data.RelativePosition.ToBytes(objectData, 0);
  4492. data.Velocity.ToBytes(objectData, 12);
  4493. data.Acceleration.ToBytes(objectData, 24);
  4494. try
  4495. {
  4496. data.RotationOffset.ToBytes(objectData, 36);
  4497. }
  4498. catch (Exception e)
  4499. {
  4500. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4501. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4502. }
  4503. data.AngularVelocity.ToBytes(objectData, 48);
  4504. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4505. update.ClickAction = (byte)data.ClickAction;
  4506. update.CRC = 0;
  4507. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4508. update.FullID = data.UUID;
  4509. update.ID = data.LocalId;
  4510. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4511. //update.JointPivot = Vector3.Zero;
  4512. //update.JointType = 0;
  4513. update.Material = data.Material;
  4514. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4515. if (data.ParentGroup.IsAttachment)
  4516. {
  4517. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4518. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4519. }
  4520. else
  4521. {
  4522. update.NameValue = Utils.EmptyBytes;
  4523. // The root part state is the canonical state for all parts of the object. The other part states in the
  4524. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4525. update.State = data.ParentGroup.RootPart.Shape.State;
  4526. }
  4527. // m_log.DebugFormat(
  4528. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4529. // update.State, data.Name, data.LocalId, Name);
  4530. update.ObjectData = objectData;
  4531. update.ParentID = data.ParentID;
  4532. update.PathBegin = data.Shape.PathBegin;
  4533. update.PathCurve = data.Shape.PathCurve;
  4534. update.PathEnd = data.Shape.PathEnd;
  4535. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4536. update.PathRevolutions = data.Shape.PathRevolutions;
  4537. update.PathScaleX = data.Shape.PathScaleX;
  4538. update.PathScaleY = data.Shape.PathScaleY;
  4539. update.PathShearX = data.Shape.PathShearX;
  4540. update.PathShearY = data.Shape.PathShearY;
  4541. update.PathSkew = data.Shape.PathSkew;
  4542. update.PathTaperX = data.Shape.PathTaperX;
  4543. update.PathTaperY = data.Shape.PathTaperY;
  4544. update.PathTwist = data.Shape.PathTwist;
  4545. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4546. update.PCode = data.Shape.PCode;
  4547. update.ProfileBegin = data.Shape.ProfileBegin;
  4548. update.ProfileCurve = data.Shape.ProfileCurve;
  4549. update.ProfileEnd = data.Shape.ProfileEnd;
  4550. update.ProfileHollow = data.Shape.ProfileHollow;
  4551. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4552. update.TextColor = data.GetTextColor().GetBytes(false);
  4553. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4554. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4555. update.Scale = data.Shape.Scale;
  4556. update.Text = Util.StringToBytes256(data.Text);
  4557. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4558. #region PrimFlags
  4559. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4560. // Don't send the CreateSelected flag to everyone
  4561. flags &= ~PrimFlags.CreateSelected;
  4562. if (recipientID == data.OwnerID)
  4563. {
  4564. if (data.CreateSelected)
  4565. {
  4566. // Only send this flag once, then unset it
  4567. flags |= PrimFlags.CreateSelected;
  4568. data.CreateSelected = false;
  4569. }
  4570. }
  4571. // m_log.DebugFormat(
  4572. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4573. // data.Name, update.FullID, flags, update.ID);
  4574. update.UpdateFlags = (uint)flags;
  4575. #endregion PrimFlags
  4576. if (data.Sound != UUID.Zero)
  4577. {
  4578. update.Sound = data.Sound;
  4579. update.OwnerID = data.OwnerID;
  4580. update.Gain = (float)data.SoundGain;
  4581. update.Radius = (float)data.SoundRadius;
  4582. update.Flags = data.SoundFlags;
  4583. }
  4584. switch ((PCode)data.Shape.PCode)
  4585. {
  4586. case PCode.Grass:
  4587. case PCode.Tree:
  4588. case PCode.NewTree:
  4589. update.Data = new byte[] { data.Shape.State };
  4590. break;
  4591. default:
  4592. update.Data = Utils.EmptyBytes;
  4593. break;
  4594. }
  4595. return update;
  4596. }
  4597. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4598. {
  4599. // TODO: Implement this
  4600. return null;
  4601. }
  4602. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4603. {
  4604. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4605. // TODO: don't create new blocks if recycling an old packet
  4606. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4607. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4608. packet.UUIDNameBlock[0].ID = profileId;
  4609. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4610. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4611. OutPacket(packet, ThrottleOutPacketType.Task);
  4612. }
  4613. public ulong GetGroupPowers(UUID groupID)
  4614. {
  4615. if (groupID == m_activeGroupID)
  4616. return m_activeGroupPowers;
  4617. if (m_groupPowers.ContainsKey(groupID))
  4618. return m_groupPowers[groupID];
  4619. return 0;
  4620. }
  4621. #endregion
  4622. /// <summary>
  4623. /// This is a different way of processing packets then ProcessInPacket
  4624. /// </summary>
  4625. protected virtual void RegisterLocalPacketHandlers()
  4626. {
  4627. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4628. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4629. // for each AgentUpdate packet.
  4630. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4631. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4632. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4633. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4634. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4635. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4636. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4637. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4638. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4639. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4640. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4641. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4642. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4643. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4644. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4645. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4646. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4647. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4648. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4649. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4650. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4651. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4652. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4653. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4654. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4655. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4656. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4657. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4658. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4659. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4660. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4661. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4662. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4663. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4664. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4665. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4666. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4667. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4668. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4669. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4670. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4671. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4672. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4673. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4674. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4675. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4676. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4677. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4678. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4679. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4680. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4681. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4682. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4683. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4684. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4685. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4686. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4687. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4688. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4689. // some clients will send out a separate ObjectImage packet for each face
  4690. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4691. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4692. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4693. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4694. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4695. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4696. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4697. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4698. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4699. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4700. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4701. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4702. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4703. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4704. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4705. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4706. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4707. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4708. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4709. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4710. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4711. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4712. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4713. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4714. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4715. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4716. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4717. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4718. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4719. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4720. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4721. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4722. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4723. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4724. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4725. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4726. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4727. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4728. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4729. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4730. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4731. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4732. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4733. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4734. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4735. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4736. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4737. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4738. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4739. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4740. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4741. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4742. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4743. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4744. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4745. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4746. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4747. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4748. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4749. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4750. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4751. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4752. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4753. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4754. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4755. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4756. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4757. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4758. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4759. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4760. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4761. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4762. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4763. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4764. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4765. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4766. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4767. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4768. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4769. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4770. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4771. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4772. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4773. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4774. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4775. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4776. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4777. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4778. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4779. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4780. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4781. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4782. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4783. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4784. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4785. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4786. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4787. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4788. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4789. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4790. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4791. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4792. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4793. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4794. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4795. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4796. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4797. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4798. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4799. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4800. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4801. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4802. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4803. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4804. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4805. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4806. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4807. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4808. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4809. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4810. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4811. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4812. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4813. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4814. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4815. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4816. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4817. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4818. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4819. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4820. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4821. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4822. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4823. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4824. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4825. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4826. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4827. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4828. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4829. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4830. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4831. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4832. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4833. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4834. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4835. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4836. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4837. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4838. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4839. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4840. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4841. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4842. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4843. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4844. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4845. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4846. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4847. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4848. }
  4849. #region Packet Handlers
  4850. public int TotalAgentUpdates { get; set; }
  4851. #region Scene/Avatar
  4852. // Threshold for body rotation to be a significant agent update
  4853. private const float QDELTA = 0.000001f;
  4854. // Threshold for camera rotation to be a significant agent update
  4855. private const float VDELTA = 0.01f;
  4856. /// <summary>
  4857. /// This checks the update significance against the last update made.
  4858. /// </summary>
  4859. /// <remarks>Can only be called by one thread at a time</remarks>
  4860. /// <returns></returns>
  4861. /// <param name='x'></param>
  4862. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4863. {
  4864. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  4865. }
  4866. /// <summary>
  4867. /// This checks the movement/state update significance against the last update made.
  4868. /// </summary>
  4869. /// <remarks>Can only be called by one thread at a time</remarks>
  4870. /// <returns></returns>
  4871. /// <param name='x'></param>
  4872. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4873. {
  4874. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  4875. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  4876. bool movementSignificant =
  4877. (qdelta1 > QDELTA) // significant if body rotation above threshold
  4878. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  4879. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  4880. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  4881. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  4882. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  4883. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  4884. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  4885. ;
  4886. //if (movementSignificant)
  4887. //{
  4888. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  4889. // qdelta1, qdelta2);
  4890. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  4891. // x.ControlFlags, x.Flags, x.Far, x.State);
  4892. //}
  4893. return movementSignificant;
  4894. }
  4895. /// <summary>
  4896. /// This checks the camera update significance against the last update made.
  4897. /// </summary>
  4898. /// <remarks>Can only be called by one thread at a time</remarks>
  4899. /// <returns></returns>
  4900. /// <param name='x'></param>
  4901. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4902. {
  4903. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  4904. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  4905. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  4906. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  4907. bool cameraSignificant =
  4908. (vdelta1 > VDELTA) ||
  4909. (vdelta2 > VDELTA) ||
  4910. (vdelta3 > VDELTA) ||
  4911. (vdelta4 > VDELTA)
  4912. ;
  4913. //if (cameraSignificant)
  4914. //{
  4915. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  4916. // x.CameraAtAxis, x.CameraCenter);
  4917. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  4918. // x.CameraLeftAxis, x.CameraUpAxis);
  4919. //}
  4920. return cameraSignificant;
  4921. }
  4922. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4923. {
  4924. // We got here, which means that something in agent update was significant
  4925. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4926. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4927. if (x.AgentID != AgentId || x.SessionID != SessionId)
  4928. return false;
  4929. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  4930. // to see what exactly changed
  4931. bool movement = CheckAgentMovementUpdateSignificance(x);
  4932. bool camera = CheckAgentCameraUpdateSignificance(x);
  4933. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  4934. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4935. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4936. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4937. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4938. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4939. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4940. m_thisAgentUpdateArgs.Far = x.Far;
  4941. m_thisAgentUpdateArgs.Flags = x.Flags;
  4942. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4943. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  4944. m_thisAgentUpdateArgs.State = x.State;
  4945. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4946. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4947. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  4948. // Was there a significant movement/state change?
  4949. if (movement)
  4950. {
  4951. if (handlerPreAgentUpdate != null)
  4952. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  4953. if (handlerAgentUpdate != null)
  4954. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  4955. }
  4956. // Was there a significant camera(s) change?
  4957. if (camera)
  4958. if (handlerAgentCameraUpdate != null)
  4959. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  4960. handlerAgentUpdate = null;
  4961. handlerPreAgentUpdate = null;
  4962. handlerAgentCameraUpdate = null;
  4963. PacketPool.Instance.ReturnPacket(packet);
  4964. return true;
  4965. }
  4966. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4967. {
  4968. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4969. // validate the agent owns the agentID and sessionID
  4970. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4971. money.AgentData.SessionID == sender.SessionId)
  4972. {
  4973. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4974. if (handlerMoneyTransferRequest != null)
  4975. {
  4976. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4977. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4978. Util.FieldToString(money.MoneyData.Description));
  4979. }
  4980. return true;
  4981. }
  4982. return false;
  4983. }
  4984. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4985. {
  4986. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4987. (ParcelGodMarkAsContentPacket)Packet;
  4988. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4989. if (ParcelGodMarkAsContentHandler != null)
  4990. {
  4991. ParcelGodMarkAsContentHandler(this,
  4992. ParcelGodMarkAsContent.AgentData.AgentID,
  4993. ParcelGodMarkAsContent.ParcelData.LocalID);
  4994. return true;
  4995. }
  4996. return false;
  4997. }
  4998. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  4999. {
  5000. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5001. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5002. if (FreezeUserHandler != null)
  5003. {
  5004. FreezeUserHandler(this,
  5005. FreezeUser.AgentData.AgentID,
  5006. FreezeUser.Data.Flags,
  5007. FreezeUser.Data.TargetID);
  5008. return true;
  5009. }
  5010. return false;
  5011. }
  5012. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5013. {
  5014. EjectUserPacket EjectUser =
  5015. (EjectUserPacket)Packet;
  5016. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5017. if (EjectUserHandler != null)
  5018. {
  5019. EjectUserHandler(this,
  5020. EjectUser.AgentData.AgentID,
  5021. EjectUser.Data.Flags,
  5022. EjectUser.Data.TargetID);
  5023. return true;
  5024. }
  5025. return false;
  5026. }
  5027. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5028. {
  5029. ParcelBuyPassPacket ParcelBuyPass =
  5030. (ParcelBuyPassPacket)Packet;
  5031. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5032. if (ParcelBuyPassHandler != null)
  5033. {
  5034. ParcelBuyPassHandler(this,
  5035. ParcelBuyPass.AgentData.AgentID,
  5036. ParcelBuyPass.ParcelData.LocalID);
  5037. return true;
  5038. }
  5039. return false;
  5040. }
  5041. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5042. {
  5043. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5044. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5045. {
  5046. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5047. if (handlerParcelBuy != null)
  5048. {
  5049. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5050. parcel.Data.IsGroupOwned,
  5051. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5052. parcel.ParcelData.Price,
  5053. false);
  5054. }
  5055. return true;
  5056. }
  5057. return false;
  5058. }
  5059. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5060. {
  5061. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5062. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5063. {
  5064. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5065. if (handlerUUIDGroupNameRequest != null)
  5066. {
  5067. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5068. }
  5069. }
  5070. return true;
  5071. }
  5072. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5073. {
  5074. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5075. if (m_genericPacketHandlers.Count == 0) return false;
  5076. if (gmpack.AgentData.SessionID != SessionId) return false;
  5077. GenericMessage handlerGenericMessage = null;
  5078. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5079. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5080. {
  5081. List<string> msg = new List<string>();
  5082. List<byte[]> msgBytes = new List<byte[]>();
  5083. if (handlerGenericMessage != null)
  5084. {
  5085. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5086. {
  5087. msg.Add(Util.FieldToString(block.Parameter));
  5088. msgBytes.Add(block.Parameter);
  5089. }
  5090. try
  5091. {
  5092. if (OnBinaryGenericMessage != null)
  5093. {
  5094. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5095. }
  5096. handlerGenericMessage(sender, method, msg);
  5097. return true;
  5098. }
  5099. catch (Exception e)
  5100. {
  5101. m_log.ErrorFormat(
  5102. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5103. }
  5104. }
  5105. }
  5106. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5107. return false;
  5108. }
  5109. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5110. {
  5111. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5112. if (ogpack.AgentData.SessionID != SessionId) return false;
  5113. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5114. if (handlerObjectGroupRequest != null)
  5115. {
  5116. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5117. {
  5118. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5119. }
  5120. }
  5121. return true;
  5122. }
  5123. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5124. {
  5125. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5126. if (viewer.AgentData.SessionID != SessionId) return false;
  5127. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5128. if (handlerViewerEffect != null)
  5129. {
  5130. int length = viewer.Effect.Length;
  5131. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5132. for (int i = 0; i < length; i++)
  5133. {
  5134. //copy the effects block arguments into the event handler arg.
  5135. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5136. argument.AgentID = viewer.Effect[i].AgentID;
  5137. argument.Color = viewer.Effect[i].Color;
  5138. argument.Duration = viewer.Effect[i].Duration;
  5139. argument.ID = viewer.Effect[i].ID;
  5140. argument.Type = viewer.Effect[i].Type;
  5141. argument.TypeData = viewer.Effect[i].TypeData;
  5142. args.Add(argument);
  5143. }
  5144. handlerViewerEffect(sender, args);
  5145. }
  5146. return true;
  5147. }
  5148. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5149. {
  5150. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5151. #region Packet Session and User Check
  5152. if (m_checkPackets)
  5153. {
  5154. if (avatarProperties.AgentData.SessionID != SessionId ||
  5155. avatarProperties.AgentData.AgentID != AgentId)
  5156. return true;
  5157. }
  5158. #endregion
  5159. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5160. if (handlerRequestAvatarProperties != null)
  5161. {
  5162. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5163. }
  5164. return true;
  5165. }
  5166. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5167. {
  5168. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5169. #region Packet Session and User Check
  5170. if (m_checkPackets)
  5171. {
  5172. if (inchatpack.AgentData.SessionID != SessionId ||
  5173. inchatpack.AgentData.AgentID != AgentId)
  5174. return true;
  5175. }
  5176. #endregion
  5177. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5178. byte[] message = inchatpack.ChatData.Message;
  5179. byte type = inchatpack.ChatData.Type;
  5180. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5181. // UUID fromAgentID = AgentId;
  5182. int channel = inchatpack.ChatData.Channel;
  5183. if (OnChatFromClient != null)
  5184. {
  5185. OSChatMessage args = new OSChatMessage();
  5186. args.Channel = channel;
  5187. args.From = fromName;
  5188. args.Message = Utils.BytesToString(message);
  5189. args.Type = (ChatTypeEnum)type;
  5190. args.Position = fromPos;
  5191. args.Scene = Scene;
  5192. args.Sender = this;
  5193. args.SenderUUID = this.AgentId;
  5194. ChatMessage handlerChatFromClient = OnChatFromClient;
  5195. if (handlerChatFromClient != null)
  5196. handlerChatFromClient(this, args);
  5197. }
  5198. return true;
  5199. }
  5200. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5201. {
  5202. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5203. #region Packet Session and User Check
  5204. if (m_checkPackets)
  5205. {
  5206. if (avatarProps.AgentData.SessionID != SessionId ||
  5207. avatarProps.AgentData.AgentID != AgentId)
  5208. return true;
  5209. }
  5210. #endregion
  5211. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5212. if (handlerUpdateAvatarProperties != null)
  5213. {
  5214. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5215. UserProfileData UserProfile = new UserProfileData();
  5216. UserProfile.ID = AgentId;
  5217. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5218. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5219. UserProfile.FirstLifeImage = Properties.FLImageID;
  5220. UserProfile.Image = Properties.ImageID;
  5221. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5222. UserProfile.UserFlags &= ~3;
  5223. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5224. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5225. handlerUpdateAvatarProperties(this, UserProfile);
  5226. }
  5227. return true;
  5228. }
  5229. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5230. {
  5231. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5232. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5233. #region Packet Session and User Check
  5234. if (m_checkPackets)
  5235. {
  5236. if (rdialog.AgentData.SessionID != SessionId ||
  5237. rdialog.AgentData.AgentID != AgentId)
  5238. return true;
  5239. }
  5240. #endregion
  5241. int ch = rdialog.Data.ChatChannel;
  5242. byte[] msg = rdialog.Data.ButtonLabel;
  5243. if (OnChatFromClient != null)
  5244. {
  5245. OSChatMessage args = new OSChatMessage();
  5246. args.Channel = ch;
  5247. args.From = String.Empty;
  5248. args.Message = Utils.BytesToString(msg);
  5249. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5250. args.Position = new Vector3();
  5251. args.Scene = Scene;
  5252. args.Sender = this;
  5253. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5254. if (handlerChatFromClient2 != null)
  5255. handlerChatFromClient2(this, args);
  5256. }
  5257. return true;
  5258. }
  5259. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5260. {
  5261. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5262. #region Packet Session and User Check
  5263. if (m_checkPackets)
  5264. {
  5265. if (msgpack.AgentData.SessionID != SessionId ||
  5266. msgpack.AgentData.AgentID != AgentId)
  5267. return true;
  5268. }
  5269. #endregion
  5270. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5271. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5272. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5273. if (handlerInstantMessage != null)
  5274. {
  5275. GridInstantMessage im = new GridInstantMessage(Scene,
  5276. msgpack.AgentData.AgentID,
  5277. IMfromName,
  5278. msgpack.MessageBlock.ToAgentID,
  5279. msgpack.MessageBlock.Dialog,
  5280. msgpack.MessageBlock.FromGroup,
  5281. IMmessage,
  5282. msgpack.MessageBlock.ID,
  5283. msgpack.MessageBlock.Offline != 0 ? true : false,
  5284. msgpack.MessageBlock.Position,
  5285. msgpack.MessageBlock.BinaryBucket,
  5286. true);
  5287. handlerInstantMessage(this, im);
  5288. }
  5289. return true;
  5290. }
  5291. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5292. {
  5293. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5294. #region Packet Session and User Check
  5295. if (m_checkPackets)
  5296. {
  5297. if (afriendpack.AgentData.SessionID != SessionId ||
  5298. afriendpack.AgentData.AgentID != AgentId)
  5299. return true;
  5300. }
  5301. #endregion
  5302. // My guess is this is the folder to stick the calling card into
  5303. List<UUID> callingCardFolders = new List<UUID>();
  5304. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5305. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5306. {
  5307. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5308. }
  5309. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5310. if (handlerApproveFriendRequest != null)
  5311. {
  5312. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5313. }
  5314. return true;
  5315. }
  5316. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5317. {
  5318. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5319. #region Packet Session and User Check
  5320. if (m_checkPackets)
  5321. {
  5322. if (dfriendpack.AgentData.SessionID != SessionId ||
  5323. dfriendpack.AgentData.AgentID != AgentId)
  5324. return true;
  5325. }
  5326. #endregion
  5327. if (OnDenyFriendRequest != null)
  5328. {
  5329. OnDenyFriendRequest(this,
  5330. dfriendpack.TransactionBlock.TransactionID,
  5331. null);
  5332. }
  5333. return true;
  5334. }
  5335. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5336. {
  5337. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5338. #region Packet Session and User Check
  5339. if (m_checkPackets)
  5340. {
  5341. if (tfriendpack.AgentData.SessionID != SessionId ||
  5342. tfriendpack.AgentData.AgentID != AgentId)
  5343. return true;
  5344. }
  5345. #endregion
  5346. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5347. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5348. if (TerminateFriendshipHandler != null)
  5349. {
  5350. TerminateFriendshipHandler(this, exFriendID);
  5351. return true;
  5352. }
  5353. return false;
  5354. }
  5355. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5356. {
  5357. FindAgentPacket FindAgent =
  5358. (FindAgentPacket)Packet;
  5359. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5360. if (FindAgentHandler != null)
  5361. {
  5362. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5363. return true;
  5364. }
  5365. return false;
  5366. }
  5367. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5368. {
  5369. TrackAgentPacket TrackAgent =
  5370. (TrackAgentPacket)Packet;
  5371. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5372. if (TrackAgentHandler != null)
  5373. {
  5374. TrackAgentHandler(this,
  5375. TrackAgent.AgentData.AgentID,
  5376. TrackAgent.TargetData.PreyID);
  5377. return true;
  5378. }
  5379. return false;
  5380. }
  5381. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5382. {
  5383. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5384. #region Packet Session and User Check
  5385. if (m_checkPackets)
  5386. {
  5387. if (rezPacket.AgentData.SessionID != SessionId ||
  5388. rezPacket.AgentData.AgentID != AgentId)
  5389. return true;
  5390. }
  5391. #endregion
  5392. RezObject handlerRezObject = OnRezObject;
  5393. if (handlerRezObject != null)
  5394. {
  5395. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5396. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5397. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5398. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5399. rezPacket.RezData.FromTaskID);
  5400. }
  5401. return true;
  5402. }
  5403. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5404. {
  5405. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5406. #region Packet Session and User Check
  5407. if (m_checkPackets)
  5408. {
  5409. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5410. DeRezPacket.AgentData.AgentID != AgentId)
  5411. return true;
  5412. }
  5413. #endregion
  5414. DeRezObject handlerDeRezObject = OnDeRezObject;
  5415. if (handlerDeRezObject != null)
  5416. {
  5417. List<uint> deRezIDs = new List<uint>();
  5418. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5419. DeRezPacket.ObjectData)
  5420. {
  5421. deRezIDs.Add(data.ObjectLocalID);
  5422. }
  5423. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5424. // values given by a Second Life client
  5425. handlerDeRezObject(this, deRezIDs,
  5426. DeRezPacket.AgentBlock.GroupID,
  5427. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5428. DeRezPacket.AgentBlock.DestinationID);
  5429. }
  5430. return true;
  5431. }
  5432. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5433. {
  5434. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5435. #region Packet Session and User Check
  5436. if (m_checkPackets)
  5437. {
  5438. if (modify.AgentData.SessionID != SessionId ||
  5439. modify.AgentData.AgentID != AgentId)
  5440. return true;
  5441. }
  5442. #endregion
  5443. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5444. if (modify.ParcelData.Length > 0)
  5445. {
  5446. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5447. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5448. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5449. if (OnModifyTerrain != null)
  5450. {
  5451. for (int i = 0; i < modify.ParcelData.Length; i++)
  5452. {
  5453. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5454. if (handlerModifyTerrain != null)
  5455. {
  5456. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5457. modify.ModifyBlock.BrushSize,
  5458. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5459. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5460. modify.ParcelData[i].East, AgentId);
  5461. }
  5462. }
  5463. }
  5464. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5465. }
  5466. return true;
  5467. }
  5468. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5469. {
  5470. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5471. if (handlerRegionHandShakeReply != null)
  5472. {
  5473. handlerRegionHandShakeReply(this);
  5474. }
  5475. return true;
  5476. }
  5477. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5478. {
  5479. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5480. if (handlerRequestWearables != null)
  5481. {
  5482. handlerRequestWearables(sender);
  5483. }
  5484. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5485. if (handlerRequestAvatarsData != null)
  5486. {
  5487. handlerRequestAvatarsData(this);
  5488. }
  5489. return true;
  5490. }
  5491. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5492. {
  5493. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5494. #region Packet Session and User Check
  5495. if (m_checkPackets)
  5496. {
  5497. if (appear.AgentData.SessionID != SessionId ||
  5498. appear.AgentData.AgentID != AgentId)
  5499. return true;
  5500. }
  5501. #endregion
  5502. SetAppearance handlerSetAppearance = OnSetAppearance;
  5503. if (handlerSetAppearance != null)
  5504. {
  5505. // Temporarily protect ourselves from the mantis #951 failure.
  5506. // However, we could do this for several other handlers where a failure isn't terminal
  5507. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5508. try
  5509. {
  5510. byte[] visualparams = new byte[appear.VisualParam.Length];
  5511. for (int i = 0; i < appear.VisualParam.Length; i++)
  5512. visualparams[i] = appear.VisualParam[i].ParamValue;
  5513. Primitive.TextureEntry te = null;
  5514. if (appear.ObjectData.TextureEntry.Length > 1)
  5515. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5516. List<CachedTextureRequestArg> hashes = new List<CachedTextureRequestArg>();
  5517. for (int i = 0; i < appear.WearableData.Length; i++)
  5518. {
  5519. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  5520. arg.BakedTextureIndex = appear.WearableData[i].TextureIndex;
  5521. arg.WearableHashID = appear.WearableData[i].CacheID;
  5522. hashes.Add(arg);
  5523. }
  5524. handlerSetAppearance(sender, te, visualparams, hashes);
  5525. }
  5526. catch (Exception e)
  5527. {
  5528. m_log.ErrorFormat(
  5529. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5530. e);
  5531. }
  5532. }
  5533. return true;
  5534. }
  5535. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5536. {
  5537. if (OnAvatarNowWearing != null)
  5538. {
  5539. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5540. #region Packet Session and User Check
  5541. if (m_checkPackets)
  5542. {
  5543. if (nowWearing.AgentData.SessionID != SessionId ||
  5544. nowWearing.AgentData.AgentID != AgentId)
  5545. return true;
  5546. }
  5547. #endregion
  5548. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5549. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5550. {
  5551. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5552. AvatarWearingArgs.Wearable wearable =
  5553. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5554. nowWearing.WearableData[i].WearableType);
  5555. wearingArgs.NowWearing.Add(wearable);
  5556. }
  5557. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5558. if (handlerAvatarNowWearing != null)
  5559. {
  5560. handlerAvatarNowWearing(this, wearingArgs);
  5561. }
  5562. }
  5563. return true;
  5564. }
  5565. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5566. {
  5567. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5568. if (handlerRezSingleAttachment != null)
  5569. {
  5570. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5571. #region Packet Session and User Check
  5572. if (m_checkPackets)
  5573. {
  5574. if (rez.AgentData.SessionID != SessionId ||
  5575. rez.AgentData.AgentID != AgentId)
  5576. return true;
  5577. }
  5578. #endregion
  5579. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5580. rez.ObjectData.AttachmentPt);
  5581. }
  5582. return true;
  5583. }
  5584. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5585. {
  5586. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5587. if (handlerRezMultipleAttachments != null)
  5588. {
  5589. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5590. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5591. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5592. handlerRezMultipleAttachments(this, rezlist);
  5593. }
  5594. return true;
  5595. }
  5596. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5597. {
  5598. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5599. if (handlerDetachAttachmentIntoInv != null)
  5600. {
  5601. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5602. #region Packet Session and User Check
  5603. // UNSUPPORTED ON THIS PACKET
  5604. #endregion
  5605. UUID itemID = detachtoInv.ObjectData.ItemID;
  5606. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5607. handlerDetachAttachmentIntoInv(itemID, this);
  5608. }
  5609. return true;
  5610. }
  5611. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5612. {
  5613. if (OnObjectAttach != null)
  5614. {
  5615. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5616. #region Packet Session and User Check
  5617. if (m_checkPackets)
  5618. {
  5619. if (att.AgentData.SessionID != SessionId ||
  5620. att.AgentData.AgentID != AgentId)
  5621. return true;
  5622. }
  5623. #endregion
  5624. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5625. if (handlerObjectAttach != null)
  5626. {
  5627. if (att.ObjectData.Length > 0)
  5628. {
  5629. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5630. }
  5631. }
  5632. }
  5633. return true;
  5634. }
  5635. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5636. {
  5637. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5638. #region Packet Session and User Check
  5639. if (m_checkPackets)
  5640. {
  5641. if (dett.AgentData.SessionID != SessionId ||
  5642. dett.AgentData.AgentID != AgentId)
  5643. return true;
  5644. }
  5645. #endregion
  5646. for (int j = 0; j < dett.ObjectData.Length; j++)
  5647. {
  5648. uint obj = dett.ObjectData[j].ObjectLocalID;
  5649. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5650. if (handlerObjectDetach != null)
  5651. {
  5652. handlerObjectDetach(obj, this);
  5653. }
  5654. }
  5655. return true;
  5656. }
  5657. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5658. {
  5659. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5660. #region Packet Session and User Check
  5661. if (m_checkPackets)
  5662. {
  5663. if (dropp.AgentData.SessionID != SessionId ||
  5664. dropp.AgentData.AgentID != AgentId)
  5665. return true;
  5666. }
  5667. #endregion
  5668. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5669. {
  5670. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5671. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5672. if (handlerObjectDrop != null)
  5673. {
  5674. handlerObjectDrop(obj, this);
  5675. }
  5676. }
  5677. return true;
  5678. }
  5679. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5680. {
  5681. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5682. #region Packet Session and User Check
  5683. if (m_checkPackets)
  5684. {
  5685. if (run.AgentData.SessionID != SessionId ||
  5686. run.AgentData.AgentID != AgentId)
  5687. return true;
  5688. }
  5689. #endregion
  5690. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5691. if (handlerSetAlwaysRun != null)
  5692. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5693. return true;
  5694. }
  5695. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5696. {
  5697. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5698. if (handlerCompleteMovementToRegion != null)
  5699. {
  5700. handlerCompleteMovementToRegion(sender, true);
  5701. }
  5702. handlerCompleteMovementToRegion = null;
  5703. return true;
  5704. }
  5705. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5706. {
  5707. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5708. #region Packet Session and User Check
  5709. if (m_checkPackets)
  5710. {
  5711. if (AgentAni.AgentData.SessionID != SessionId ||
  5712. AgentAni.AgentData.AgentID != AgentId)
  5713. return true;
  5714. }
  5715. #endregion
  5716. StartAnim handlerStartAnim = null;
  5717. StopAnim handlerStopAnim = null;
  5718. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5719. {
  5720. if (AgentAni.AnimationList[i].StartAnim)
  5721. {
  5722. handlerStartAnim = OnStartAnim;
  5723. if (handlerStartAnim != null)
  5724. {
  5725. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5726. }
  5727. }
  5728. else
  5729. {
  5730. handlerStopAnim = OnStopAnim;
  5731. if (handlerStopAnim != null)
  5732. {
  5733. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5734. }
  5735. }
  5736. }
  5737. return true;
  5738. }
  5739. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5740. {
  5741. if (OnAgentRequestSit != null)
  5742. {
  5743. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5744. #region Packet Session and User Check
  5745. if (m_checkPackets)
  5746. {
  5747. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5748. agentRequestSit.AgentData.AgentID != AgentId)
  5749. return true;
  5750. }
  5751. #endregion
  5752. if (SceneAgent.IsChildAgent)
  5753. {
  5754. SendCantSitBecauseChildAgentResponse();
  5755. return true;
  5756. }
  5757. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5758. if (handlerAgentRequestSit != null)
  5759. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5760. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5761. }
  5762. return true;
  5763. }
  5764. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5765. {
  5766. if (OnAgentSit != null)
  5767. {
  5768. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5769. #region Packet Session and User Check
  5770. if (m_checkPackets)
  5771. {
  5772. if (agentSit.AgentData.SessionID != SessionId ||
  5773. agentSit.AgentData.AgentID != AgentId)
  5774. return true;
  5775. }
  5776. #endregion
  5777. if (SceneAgent.IsChildAgent)
  5778. {
  5779. SendCantSitBecauseChildAgentResponse();
  5780. return true;
  5781. }
  5782. AgentSit handlerAgentSit = OnAgentSit;
  5783. if (handlerAgentSit != null)
  5784. {
  5785. OnAgentSit(this, agentSit.AgentData.AgentID);
  5786. }
  5787. }
  5788. return true;
  5789. }
  5790. /// <summary>
  5791. /// Used when a child agent gets a sit response which should not be fulfilled.
  5792. /// </summary>
  5793. private void SendCantSitBecauseChildAgentResponse()
  5794. {
  5795. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5796. }
  5797. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5798. {
  5799. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5800. #region Packet Session and User Check
  5801. if (m_checkPackets)
  5802. {
  5803. // UNSUPPORTED ON THIS PACKET
  5804. }
  5805. #endregion
  5806. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5807. if (handlerSoundTrigger != null)
  5808. {
  5809. // UUIDS are sent as zeroes by the client, substitute agent's id
  5810. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5811. AgentId, AgentId,
  5812. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5813. soundTriggerPacket.SoundData.Handle, 0);
  5814. }
  5815. return true;
  5816. }
  5817. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5818. {
  5819. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5820. #region Packet Session and User Check
  5821. if (m_checkPackets)
  5822. {
  5823. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5824. avRequestQuery.AgentData.AgentID != AgentId)
  5825. return true;
  5826. }
  5827. #endregion
  5828. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5829. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5830. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5831. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5832. if (handlerAvatarPickerRequest != null)
  5833. {
  5834. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5835. Utils.BytesToString(querydata.Name));
  5836. }
  5837. return true;
  5838. }
  5839. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5840. {
  5841. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5842. #region Packet Session and User Check
  5843. if (m_checkPackets)
  5844. {
  5845. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5846. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5847. return true;
  5848. }
  5849. #endregion
  5850. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5851. if (handlerAgentDataUpdateRequest != null)
  5852. {
  5853. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5854. }
  5855. return true;
  5856. }
  5857. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5858. {
  5859. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5860. if (handlerUserInfoRequest != null)
  5861. {
  5862. handlerUserInfoRequest(this);
  5863. }
  5864. else
  5865. {
  5866. SendUserInfoReply(false, true, "");
  5867. }
  5868. return true;
  5869. }
  5870. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5871. {
  5872. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5873. #region Packet Session and User Check
  5874. if (m_checkPackets)
  5875. {
  5876. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5877. updateUserInfo.AgentData.AgentID != AgentId)
  5878. return true;
  5879. }
  5880. #endregion
  5881. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5882. if (handlerUpdateUserInfo != null)
  5883. {
  5884. bool visible = true;
  5885. string DirectoryVisibility =
  5886. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5887. if (DirectoryVisibility == "hidden")
  5888. visible = false;
  5889. handlerUpdateUserInfo(
  5890. updateUserInfo.UserData.IMViaEMail,
  5891. visible, this);
  5892. }
  5893. return true;
  5894. }
  5895. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5896. {
  5897. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5898. #region Packet Session and User Check
  5899. if (m_checkPackets)
  5900. {
  5901. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5902. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5903. return true;
  5904. }
  5905. #endregion
  5906. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5907. {
  5908. // Linden Client limitation..
  5909. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5910. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5911. {
  5912. ScenePresence avatar = null;
  5913. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5914. {
  5915. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5916. {
  5917. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5918. }
  5919. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5920. {
  5921. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5922. }
  5923. }
  5924. }
  5925. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5926. if (handlerSetStartLocationRequest != null)
  5927. {
  5928. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5929. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5930. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5931. }
  5932. }
  5933. return true;
  5934. }
  5935. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5936. {
  5937. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5938. #region Packet Session and User Check
  5939. if (m_checkPackets)
  5940. {
  5941. if (atpack.AgentData.SessionID != SessionId ||
  5942. atpack.AgentData.AgentID != AgentId)
  5943. return true;
  5944. }
  5945. #endregion
  5946. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5947. return true;
  5948. }
  5949. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5950. {
  5951. m_udpClient.IsPaused = true;
  5952. return true;
  5953. }
  5954. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5955. {
  5956. m_udpClient.IsPaused = false;
  5957. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5958. return true;
  5959. }
  5960. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5961. {
  5962. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5963. if (handlerForceReleaseControls != null)
  5964. {
  5965. handlerForceReleaseControls(this, AgentId);
  5966. }
  5967. return true;
  5968. }
  5969. #endregion Scene/Avatar
  5970. #region Objects/m_sceneObjects
  5971. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5972. {
  5973. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5974. #region Packet Session and User Check
  5975. if (m_checkPackets)
  5976. {
  5977. if (link.AgentData.SessionID != SessionId ||
  5978. link.AgentData.AgentID != AgentId)
  5979. return true;
  5980. }
  5981. #endregion
  5982. uint parentprimid = 0;
  5983. List<uint> childrenprims = new List<uint>();
  5984. if (link.ObjectData.Length > 1)
  5985. {
  5986. parentprimid = link.ObjectData[0].ObjectLocalID;
  5987. for (int i = 1; i < link.ObjectData.Length; i++)
  5988. {
  5989. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5990. }
  5991. }
  5992. LinkObjects handlerLinkObjects = OnLinkObjects;
  5993. if (handlerLinkObjects != null)
  5994. {
  5995. handlerLinkObjects(this, parentprimid, childrenprims);
  5996. }
  5997. return true;
  5998. }
  5999. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  6000. {
  6001. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6002. #region Packet Session and User Check
  6003. if (m_checkPackets)
  6004. {
  6005. if (delink.AgentData.SessionID != SessionId ||
  6006. delink.AgentData.AgentID != AgentId)
  6007. return true;
  6008. }
  6009. #endregion
  6010. // It appears the prim at index 0 is not always the root prim (for
  6011. // instance, when one prim of a link set has been edited independently
  6012. // of the others). Therefore, we'll pass all the ids onto the delink
  6013. // method for it to decide which is the root.
  6014. List<uint> prims = new List<uint>();
  6015. for (int i = 0; i < delink.ObjectData.Length; i++)
  6016. {
  6017. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6018. }
  6019. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6020. if (handlerDelinkObjects != null)
  6021. {
  6022. handlerDelinkObjects(prims, this);
  6023. }
  6024. return true;
  6025. }
  6026. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6027. {
  6028. if (OnAddPrim != null)
  6029. {
  6030. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6031. #region Packet Session and User Check
  6032. if (m_checkPackets)
  6033. {
  6034. if (addPacket.AgentData.SessionID != SessionId ||
  6035. addPacket.AgentData.AgentID != AgentId)
  6036. return true;
  6037. }
  6038. #endregion
  6039. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6040. // m_log.Info("[REZData]: " + addPacket.ToString());
  6041. //BypassRaycast: 1
  6042. //RayStart: <69.79469, 158.2652, 98.40343>
  6043. //RayEnd: <61.97724, 141.995, 92.58341>
  6044. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6045. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6046. //object from rezing initially
  6047. AddNewPrim handlerAddPrim = OnAddPrim;
  6048. if (handlerAddPrim != null)
  6049. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6050. }
  6051. return true;
  6052. }
  6053. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6054. {
  6055. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6056. #region Packet Session and User Check
  6057. if (m_checkPackets)
  6058. {
  6059. if (shapePacket.AgentData.SessionID != SessionId ||
  6060. shapePacket.AgentData.AgentID != AgentId)
  6061. return true;
  6062. }
  6063. #endregion
  6064. UpdateShape handlerUpdatePrimShape = null;
  6065. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6066. {
  6067. handlerUpdatePrimShape = OnUpdatePrimShape;
  6068. if (handlerUpdatePrimShape != null)
  6069. {
  6070. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6071. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6072. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6073. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6074. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6075. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6076. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6077. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6078. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6079. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6080. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6081. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6082. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6083. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6084. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6085. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6086. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6087. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6088. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6089. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6090. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6091. shapeData);
  6092. }
  6093. }
  6094. return true;
  6095. }
  6096. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6097. {
  6098. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6099. #region Packet Session and User Check
  6100. if (m_checkPackets)
  6101. {
  6102. if (extraPar.AgentData.SessionID != SessionId ||
  6103. extraPar.AgentData.AgentID != AgentId)
  6104. return true;
  6105. }
  6106. #endregion
  6107. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6108. if (handlerUpdateExtraParams != null)
  6109. {
  6110. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6111. {
  6112. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6113. extraPar.ObjectData[i].ParamType,
  6114. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6115. }
  6116. }
  6117. return true;
  6118. }
  6119. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6120. {
  6121. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6122. #region Packet Session and User Check
  6123. if (m_checkPackets)
  6124. {
  6125. if (dupe.AgentData.SessionID != SessionId ||
  6126. dupe.AgentData.AgentID != AgentId)
  6127. return true;
  6128. }
  6129. #endregion
  6130. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6131. ObjectDuplicate handlerObjectDuplicate = null;
  6132. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6133. {
  6134. handlerObjectDuplicate = OnObjectDuplicate;
  6135. if (handlerObjectDuplicate != null)
  6136. {
  6137. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6138. dupe.SharedData.DuplicateFlags, AgentId,
  6139. m_activeGroupID);
  6140. }
  6141. }
  6142. return true;
  6143. }
  6144. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6145. {
  6146. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6147. #region Packet Session and User Check
  6148. if (m_checkPackets)
  6149. {
  6150. if (incomingRequest.AgentData.SessionID != SessionId ||
  6151. incomingRequest.AgentData.AgentID != AgentId)
  6152. return true;
  6153. }
  6154. #endregion
  6155. ObjectRequest handlerObjectRequest = null;
  6156. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6157. {
  6158. handlerObjectRequest = OnObjectRequest;
  6159. if (handlerObjectRequest != null)
  6160. {
  6161. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6162. }
  6163. }
  6164. return true;
  6165. }
  6166. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6167. {
  6168. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6169. #region Packet Session and User Check
  6170. if (m_checkPackets)
  6171. {
  6172. if (incomingselect.AgentData.SessionID != SessionId ||
  6173. incomingselect.AgentData.AgentID != AgentId)
  6174. return true;
  6175. }
  6176. #endregion
  6177. ObjectSelect handlerObjectSelect = null;
  6178. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6179. {
  6180. handlerObjectSelect = OnObjectSelect;
  6181. if (handlerObjectSelect != null)
  6182. {
  6183. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6184. }
  6185. }
  6186. return true;
  6187. }
  6188. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6189. {
  6190. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6191. #region Packet Session and User Check
  6192. if (m_checkPackets)
  6193. {
  6194. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6195. incomingdeselect.AgentData.AgentID != AgentId)
  6196. return true;
  6197. }
  6198. #endregion
  6199. ObjectDeselect handlerObjectDeselect = null;
  6200. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6201. {
  6202. handlerObjectDeselect = OnObjectDeselect;
  6203. if (handlerObjectDeselect != null)
  6204. {
  6205. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6206. }
  6207. }
  6208. return true;
  6209. }
  6210. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6211. {
  6212. // DEPRECATED: but till libsecondlife removes it, people will use it
  6213. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6214. #region Packet Session and User Check
  6215. if (m_checkPackets)
  6216. {
  6217. if (position.AgentData.SessionID != SessionId ||
  6218. position.AgentData.AgentID != AgentId)
  6219. return true;
  6220. }
  6221. #endregion
  6222. for (int i = 0; i < position.ObjectData.Length; i++)
  6223. {
  6224. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6225. if (handlerUpdateVector != null)
  6226. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6227. }
  6228. return true;
  6229. }
  6230. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6231. {
  6232. // DEPRECATED: but till libsecondlife removes it, people will use it
  6233. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6234. #region Packet Session and User Check
  6235. if (m_checkPackets)
  6236. {
  6237. if (scale.AgentData.SessionID != SessionId ||
  6238. scale.AgentData.AgentID != AgentId)
  6239. return true;
  6240. }
  6241. #endregion
  6242. for (int i = 0; i < scale.ObjectData.Length; i++)
  6243. {
  6244. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6245. if (handlerUpdatePrimGroupScale != null)
  6246. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6247. }
  6248. return true;
  6249. }
  6250. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6251. {
  6252. // DEPRECATED: but till libsecondlife removes it, people will use it
  6253. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6254. #region Packet Session and User Check
  6255. if (m_checkPackets)
  6256. {
  6257. if (rotation.AgentData.SessionID != SessionId ||
  6258. rotation.AgentData.AgentID != AgentId)
  6259. return true;
  6260. }
  6261. #endregion
  6262. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6263. {
  6264. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6265. if (handlerUpdatePrimRotation != null)
  6266. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6267. }
  6268. return true;
  6269. }
  6270. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6271. {
  6272. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6273. #region Packet Session and User Check
  6274. if (m_checkPackets)
  6275. {
  6276. if (flags.AgentData.SessionID != SessionId ||
  6277. flags.AgentData.AgentID != AgentId)
  6278. return true;
  6279. }
  6280. #endregion
  6281. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6282. if (handlerUpdatePrimFlags != null)
  6283. {
  6284. // byte[] data = Pack.ToBytes();
  6285. // 46,47,48 are special positions within the packet
  6286. // This may change so perhaps we need a better way
  6287. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6288. /*
  6289. bool UsePhysics = (data[46] != 0) ? true : false;
  6290. bool IsTemporary = (data[47] != 0) ? true : false;
  6291. bool IsPhantom = (data[48] != 0) ? true : false;
  6292. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6293. */
  6294. bool UsePhysics = flags.AgentData.UsePhysics;
  6295. bool IsPhantom = flags.AgentData.IsPhantom;
  6296. bool IsTemporary = flags.AgentData.IsTemporary;
  6297. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6298. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6299. if (blocks == null || blocks.Length == 0)
  6300. {
  6301. physdata.PhysShapeType = PhysShapeType.invalid;
  6302. }
  6303. else
  6304. {
  6305. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6306. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6307. physdata.Bounce = phsblock.Restitution;
  6308. physdata.Density = phsblock.Density;
  6309. physdata.Friction = phsblock.Friction;
  6310. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6311. }
  6312. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6313. }
  6314. return true;
  6315. }
  6316. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6317. {
  6318. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6319. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6320. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6321. {
  6322. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6323. if (handlerUpdatePrimTexture != null)
  6324. {
  6325. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6326. imagePack.ObjectData[i].TextureEntry, this);
  6327. }
  6328. }
  6329. return true;
  6330. }
  6331. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6332. {
  6333. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6334. #region Packet Session and User Check
  6335. if (m_checkPackets)
  6336. {
  6337. if (grab.AgentData.SessionID != SessionId ||
  6338. grab.AgentData.AgentID != AgentId)
  6339. return true;
  6340. }
  6341. #endregion
  6342. GrabObject handlerGrabObject = OnGrabObject;
  6343. if (handlerGrabObject != null)
  6344. {
  6345. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6346. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6347. {
  6348. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6349. {
  6350. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6351. arg.Binormal = surfaceInfo.Binormal;
  6352. arg.FaceIndex = surfaceInfo.FaceIndex;
  6353. arg.Normal = surfaceInfo.Normal;
  6354. arg.Position = surfaceInfo.Position;
  6355. arg.STCoord = surfaceInfo.STCoord;
  6356. arg.UVCoord = surfaceInfo.UVCoord;
  6357. touchArgs.Add(arg);
  6358. }
  6359. }
  6360. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6361. }
  6362. return true;
  6363. }
  6364. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6365. {
  6366. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6367. #region Packet Session and User Check
  6368. if (m_checkPackets)
  6369. {
  6370. if (grabUpdate.AgentData.SessionID != SessionId ||
  6371. grabUpdate.AgentData.AgentID != AgentId)
  6372. return true;
  6373. }
  6374. #endregion
  6375. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6376. if (handlerGrabUpdate != null)
  6377. {
  6378. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6379. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6380. {
  6381. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6382. {
  6383. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6384. arg.Binormal = surfaceInfo.Binormal;
  6385. arg.FaceIndex = surfaceInfo.FaceIndex;
  6386. arg.Normal = surfaceInfo.Normal;
  6387. arg.Position = surfaceInfo.Position;
  6388. arg.STCoord = surfaceInfo.STCoord;
  6389. arg.UVCoord = surfaceInfo.UVCoord;
  6390. touchArgs.Add(arg);
  6391. }
  6392. }
  6393. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6394. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6395. }
  6396. return true;
  6397. }
  6398. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6399. {
  6400. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6401. #region Packet Session and User Check
  6402. if (m_checkPackets)
  6403. {
  6404. if (deGrab.AgentData.SessionID != SessionId ||
  6405. deGrab.AgentData.AgentID != AgentId)
  6406. return true;
  6407. }
  6408. #endregion
  6409. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6410. if (handlerDeGrabObject != null)
  6411. {
  6412. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6413. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6414. {
  6415. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6416. {
  6417. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6418. arg.Binormal = surfaceInfo.Binormal;
  6419. arg.FaceIndex = surfaceInfo.FaceIndex;
  6420. arg.Normal = surfaceInfo.Normal;
  6421. arg.Position = surfaceInfo.Position;
  6422. arg.STCoord = surfaceInfo.STCoord;
  6423. arg.UVCoord = surfaceInfo.UVCoord;
  6424. touchArgs.Add(arg);
  6425. }
  6426. }
  6427. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6428. }
  6429. return true;
  6430. }
  6431. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6432. {
  6433. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6434. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6435. #region Packet Session and User Check
  6436. if (m_checkPackets)
  6437. {
  6438. if (spinStart.AgentData.SessionID != SessionId ||
  6439. spinStart.AgentData.AgentID != AgentId)
  6440. return true;
  6441. }
  6442. #endregion
  6443. SpinStart handlerSpinStart = OnSpinStart;
  6444. if (handlerSpinStart != null)
  6445. {
  6446. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6447. }
  6448. return true;
  6449. }
  6450. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6451. {
  6452. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6453. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6454. #region Packet Session and User Check
  6455. if (m_checkPackets)
  6456. {
  6457. if (spinUpdate.AgentData.SessionID != SessionId ||
  6458. spinUpdate.AgentData.AgentID != AgentId)
  6459. return true;
  6460. }
  6461. #endregion
  6462. Vector3 axis;
  6463. float angle;
  6464. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6465. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6466. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6467. if (handlerSpinUpdate != null)
  6468. {
  6469. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6470. }
  6471. return true;
  6472. }
  6473. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6474. {
  6475. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6476. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6477. #region Packet Session and User Check
  6478. if (m_checkPackets)
  6479. {
  6480. if (spinStop.AgentData.SessionID != SessionId ||
  6481. spinStop.AgentData.AgentID != AgentId)
  6482. return true;
  6483. }
  6484. #endregion
  6485. SpinStop handlerSpinStop = OnSpinStop;
  6486. if (handlerSpinStop != null)
  6487. {
  6488. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6489. }
  6490. return true;
  6491. }
  6492. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6493. {
  6494. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6495. #region Packet Session and User Check
  6496. if (m_checkPackets)
  6497. {
  6498. if (objDes.AgentData.SessionID != SessionId ||
  6499. objDes.AgentData.AgentID != AgentId)
  6500. return true;
  6501. }
  6502. #endregion
  6503. GenericCall7 handlerObjectDescription = null;
  6504. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6505. {
  6506. handlerObjectDescription = OnObjectDescription;
  6507. if (handlerObjectDescription != null)
  6508. {
  6509. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6510. Util.FieldToString(objDes.ObjectData[i].Description));
  6511. }
  6512. }
  6513. return true;
  6514. }
  6515. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6516. {
  6517. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6518. #region Packet Session and User Check
  6519. if (m_checkPackets)
  6520. {
  6521. if (objName.AgentData.SessionID != SessionId ||
  6522. objName.AgentData.AgentID != AgentId)
  6523. return true;
  6524. }
  6525. #endregion
  6526. GenericCall7 handlerObjectName = null;
  6527. for (int i = 0; i < objName.ObjectData.Length; i++)
  6528. {
  6529. handlerObjectName = OnObjectName;
  6530. if (handlerObjectName != null)
  6531. {
  6532. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6533. Util.FieldToString(objName.ObjectData[i].Name));
  6534. }
  6535. }
  6536. return true;
  6537. }
  6538. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6539. {
  6540. if (OnObjectPermissions != null)
  6541. {
  6542. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6543. #region Packet Session and User Check
  6544. if (m_checkPackets)
  6545. {
  6546. if (newobjPerms.AgentData.SessionID != SessionId ||
  6547. newobjPerms.AgentData.AgentID != AgentId)
  6548. return true;
  6549. }
  6550. #endregion
  6551. UUID AgentID = newobjPerms.AgentData.AgentID;
  6552. UUID SessionID = newobjPerms.AgentData.SessionID;
  6553. ObjectPermissions handlerObjectPermissions = null;
  6554. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6555. {
  6556. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6557. byte field = permChanges.Field;
  6558. uint localID = permChanges.ObjectLocalID;
  6559. uint mask = permChanges.Mask;
  6560. byte set = permChanges.Set;
  6561. handlerObjectPermissions = OnObjectPermissions;
  6562. if (handlerObjectPermissions != null)
  6563. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6564. }
  6565. }
  6566. // Here's our data,
  6567. // PermField contains the field the info goes into
  6568. // PermField determines which mask we're changing
  6569. //
  6570. // chmask is the mask of the change
  6571. // setTF is whether we're adding it or taking it away
  6572. //
  6573. // objLocalID is the localID of the object.
  6574. // Unfortunately, we have to pass the event the packet because objData is an array
  6575. // That means multiple object perms may be updated in a single packet.
  6576. return true;
  6577. }
  6578. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6579. {
  6580. UndoPacket undoitem = (UndoPacket)Pack;
  6581. #region Packet Session and User Check
  6582. if (m_checkPackets)
  6583. {
  6584. if (undoitem.AgentData.SessionID != SessionId ||
  6585. undoitem.AgentData.AgentID != AgentId)
  6586. return true;
  6587. }
  6588. #endregion
  6589. if (undoitem.ObjectData.Length > 0)
  6590. {
  6591. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6592. {
  6593. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6594. AgentSit handlerOnUndo = OnUndo;
  6595. if (handlerOnUndo != null)
  6596. {
  6597. handlerOnUndo(this, objiD);
  6598. }
  6599. }
  6600. }
  6601. return true;
  6602. }
  6603. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6604. {
  6605. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6606. #region Packet Session and User Check
  6607. if (m_checkPackets)
  6608. {
  6609. if (undolanditem.AgentData.SessionID != SessionId ||
  6610. undolanditem.AgentData.AgentID != AgentId)
  6611. return true;
  6612. }
  6613. #endregion
  6614. LandUndo handlerOnUndo = OnLandUndo;
  6615. if (handlerOnUndo != null)
  6616. {
  6617. handlerOnUndo(this);
  6618. }
  6619. return true;
  6620. }
  6621. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6622. {
  6623. RedoPacket redoitem = (RedoPacket)Pack;
  6624. #region Packet Session and User Check
  6625. if (m_checkPackets)
  6626. {
  6627. if (redoitem.AgentData.SessionID != SessionId ||
  6628. redoitem.AgentData.AgentID != AgentId)
  6629. return true;
  6630. }
  6631. #endregion
  6632. if (redoitem.ObjectData.Length > 0)
  6633. {
  6634. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6635. {
  6636. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6637. AgentSit handlerOnRedo = OnRedo;
  6638. if (handlerOnRedo != null)
  6639. {
  6640. handlerOnRedo(this, objiD);
  6641. }
  6642. }
  6643. }
  6644. return true;
  6645. }
  6646. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6647. {
  6648. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6649. #region Packet Session and User Check
  6650. if (m_checkPackets)
  6651. {
  6652. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6653. dupeOnRay.AgentData.AgentID != AgentId)
  6654. return true;
  6655. }
  6656. #endregion
  6657. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6658. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6659. {
  6660. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6661. if (handlerObjectDuplicateOnRay != null)
  6662. {
  6663. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6664. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6665. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6666. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6667. }
  6668. }
  6669. return true;
  6670. }
  6671. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6672. {
  6673. //This powers the little tooltip that appears when you move your mouse over an object
  6674. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6675. #region Packet Session and User Check
  6676. if (m_checkPackets)
  6677. {
  6678. if (packToolTip.AgentData.SessionID != SessionId ||
  6679. packToolTip.AgentData.AgentID != AgentId)
  6680. return true;
  6681. }
  6682. #endregion
  6683. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6684. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6685. if (handlerRequestObjectPropertiesFamily != null)
  6686. {
  6687. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6688. packObjBlock.ObjectID);
  6689. }
  6690. return true;
  6691. }
  6692. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6693. {
  6694. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6695. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6696. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6697. #region Packet Session and User Check
  6698. if (m_checkPackets)
  6699. {
  6700. if (packInSearch.AgentData.SessionID != SessionId ||
  6701. packInSearch.AgentData.AgentID != AgentId)
  6702. return true;
  6703. }
  6704. #endregion
  6705. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6706. {
  6707. bool inSearch = objData.IncludeInSearch;
  6708. uint localID = objData.ObjectLocalID;
  6709. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6710. if (handlerObjectIncludeInSearch != null)
  6711. {
  6712. handlerObjectIncludeInSearch(this, inSearch, localID);
  6713. }
  6714. }
  6715. return true;
  6716. }
  6717. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6718. {
  6719. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6720. #region Packet Session and User Check
  6721. if (m_checkPackets)
  6722. {
  6723. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6724. scriptAnswer.AgentData.AgentID != AgentId)
  6725. return true;
  6726. }
  6727. #endregion
  6728. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6729. if (handlerScriptAnswer != null)
  6730. {
  6731. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6732. }
  6733. return true;
  6734. }
  6735. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6736. {
  6737. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6738. #region Packet Session and User Check
  6739. if (m_checkPackets)
  6740. {
  6741. if (ocpacket.AgentData.SessionID != SessionId ||
  6742. ocpacket.AgentData.AgentID != AgentId)
  6743. return true;
  6744. }
  6745. #endregion
  6746. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6747. if (handlerObjectClickAction != null)
  6748. {
  6749. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6750. {
  6751. byte action = odata.ClickAction;
  6752. uint localID = odata.ObjectLocalID;
  6753. handlerObjectClickAction(this, localID, action.ToString());
  6754. }
  6755. }
  6756. return true;
  6757. }
  6758. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6759. {
  6760. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6761. #region Packet Session and User Check
  6762. if (m_checkPackets)
  6763. {
  6764. if (ompacket.AgentData.SessionID != SessionId ||
  6765. ompacket.AgentData.AgentID != AgentId)
  6766. return true;
  6767. }
  6768. #endregion
  6769. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6770. if (handlerObjectMaterial != null)
  6771. {
  6772. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6773. {
  6774. byte material = odata.Material;
  6775. uint localID = odata.ObjectLocalID;
  6776. handlerObjectMaterial(this, localID, material.ToString());
  6777. }
  6778. }
  6779. return true;
  6780. }
  6781. #endregion Objects/m_sceneObjects
  6782. #region Inventory/Asset/Other related packets
  6783. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6784. {
  6785. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6786. //m_log.Debug("image request: " + Pack.ToString());
  6787. #region Packet Session and User Check
  6788. if (m_checkPackets)
  6789. {
  6790. if (imageRequest.AgentData.SessionID != SessionId ||
  6791. imageRequest.AgentData.AgentID != AgentId)
  6792. return true;
  6793. }
  6794. #endregion
  6795. //handlerTextureRequest = null;
  6796. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6797. {
  6798. TextureRequestArgs args = new TextureRequestArgs();
  6799. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6800. args.RequestedAssetID = block.Image;
  6801. args.DiscardLevel = block.DiscardLevel;
  6802. args.PacketNumber = block.Packet;
  6803. args.Priority = block.DownloadPriority;
  6804. args.requestSequence = imageRequest.Header.Sequence;
  6805. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6806. // priority of avatar textures to get avatars rezzing in faster than the
  6807. // surrounding scene
  6808. if ((ImageType)block.Type == ImageType.Baked)
  6809. args.Priority *= 2.0f;
  6810. ImageManager.EnqueueReq(args);
  6811. }
  6812. return true;
  6813. }
  6814. /// <summary>
  6815. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6816. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6817. /// </summary>
  6818. /// <param name="sender"></param>
  6819. /// <param name="Pack"></param>
  6820. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6821. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6822. {
  6823. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6824. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6825. UUID taskID = UUID.Zero;
  6826. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6827. {
  6828. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6829. {
  6830. // We're spawning a thread because the permissions check can block this thread
  6831. Util.FireAndForget(delegate
  6832. {
  6833. // This requests the asset if needed
  6834. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6835. });
  6836. return true;
  6837. }
  6838. }
  6839. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6840. {
  6841. //TransferRequestPacket does not include covenant uuid?
  6842. //get scene covenant uuid
  6843. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6844. }
  6845. // This is non-blocking
  6846. MakeAssetRequest(transfer, taskID);
  6847. return true;
  6848. }
  6849. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6850. {
  6851. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6852. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6853. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6854. //m_log.DebugFormat(
  6855. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6856. // requestID, itemID, taskID, Name);
  6857. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6858. // Validate inventory transfers
  6859. // Has to be done here, because AssetCache can't do it
  6860. //
  6861. if (taskID != UUID.Zero) // Prim
  6862. {
  6863. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6864. if (part == null)
  6865. {
  6866. m_log.WarnFormat(
  6867. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6868. Name, requestID, itemID, taskID);
  6869. return;
  6870. }
  6871. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6872. if (tii == null)
  6873. {
  6874. m_log.WarnFormat(
  6875. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6876. Name, requestID, itemID, taskID);
  6877. return;
  6878. }
  6879. if (tii.Type == (int)AssetType.LSLText)
  6880. {
  6881. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6882. return;
  6883. }
  6884. else if (tii.Type == (int)AssetType.Notecard)
  6885. {
  6886. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6887. return;
  6888. }
  6889. else
  6890. {
  6891. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6892. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6893. if (part.OwnerID != AgentId)
  6894. {
  6895. m_log.WarnFormat(
  6896. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6897. Name, requestID, itemID, taskID, part.OwnerID);
  6898. return;
  6899. }
  6900. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6901. {
  6902. m_log.WarnFormat(
  6903. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6904. Name, requestID, itemID, taskID);
  6905. return;
  6906. }
  6907. if (tii.OwnerID != AgentId)
  6908. {
  6909. m_log.WarnFormat(
  6910. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6911. Name, requestID, itemID, taskID, tii.OwnerID);
  6912. return;
  6913. }
  6914. if ((
  6915. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6916. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6917. {
  6918. m_log.WarnFormat(
  6919. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6920. Name, requestID, itemID, taskID);
  6921. return;
  6922. }
  6923. if (tii.AssetID != requestID)
  6924. {
  6925. m_log.WarnFormat(
  6926. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6927. Name, requestID, itemID, taskID, tii.AssetID);
  6928. return;
  6929. }
  6930. }
  6931. }
  6932. else // Agent
  6933. {
  6934. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6935. if (invAccess != null)
  6936. {
  6937. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6938. return;
  6939. }
  6940. else
  6941. {
  6942. return;
  6943. }
  6944. }
  6945. // Permissions out of the way, let's request the asset
  6946. MakeAssetRequest(transfer, taskID);
  6947. }
  6948. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6949. {
  6950. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6951. // m_log.Debug("upload request " + request.ToString());
  6952. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6953. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6954. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6955. if (handlerAssetUploadRequest != null)
  6956. {
  6957. handlerAssetUploadRequest(this, temp,
  6958. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6959. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6960. request.AssetBlock.Tempfile);
  6961. }
  6962. return true;
  6963. }
  6964. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6965. {
  6966. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6967. RequestXfer handlerRequestXfer = OnRequestXfer;
  6968. if (handlerRequestXfer != null)
  6969. {
  6970. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6971. }
  6972. return true;
  6973. }
  6974. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6975. {
  6976. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6977. XferReceive handlerXferReceive = OnXferReceive;
  6978. if (handlerXferReceive != null)
  6979. {
  6980. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6981. }
  6982. return true;
  6983. }
  6984. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6985. {
  6986. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6987. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6988. if (handlerConfirmXfer != null)
  6989. {
  6990. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6991. }
  6992. return true;
  6993. }
  6994. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6995. {
  6996. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6997. AbortXfer handlerAbortXfer = OnAbortXfer;
  6998. if (handlerAbortXfer != null)
  6999. {
  7000. handlerAbortXfer(this, abortXfer.XferID.ID);
  7001. }
  7002. return true;
  7003. }
  7004. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7005. {
  7006. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7007. #region Packet Session and User Check
  7008. if (m_checkPackets)
  7009. {
  7010. if (invFolder.AgentData.SessionID != SessionId ||
  7011. invFolder.AgentData.AgentID != AgentId)
  7012. return true;
  7013. }
  7014. #endregion
  7015. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7016. if (handlerCreateInventoryFolder != null)
  7017. {
  7018. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7019. (ushort)invFolder.FolderData.Type,
  7020. Util.FieldToString(invFolder.FolderData.Name),
  7021. invFolder.FolderData.ParentID);
  7022. }
  7023. return true;
  7024. }
  7025. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7026. {
  7027. if (OnUpdateInventoryFolder != null)
  7028. {
  7029. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7030. #region Packet Session and User Check
  7031. if (m_checkPackets)
  7032. {
  7033. if (invFolderx.AgentData.SessionID != SessionId ||
  7034. invFolderx.AgentData.AgentID != AgentId)
  7035. return true;
  7036. }
  7037. #endregion
  7038. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7039. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7040. {
  7041. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7042. if (handlerUpdateInventoryFolder != null)
  7043. {
  7044. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7045. (ushort)invFolderx.FolderData[i].Type,
  7046. Util.FieldToString(invFolderx.FolderData[i].Name),
  7047. invFolderx.FolderData[i].ParentID);
  7048. }
  7049. }
  7050. }
  7051. return true;
  7052. }
  7053. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7054. {
  7055. if (OnMoveInventoryFolder != null)
  7056. {
  7057. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7058. #region Packet Session and User Check
  7059. if (m_checkPackets)
  7060. {
  7061. if (invFoldery.AgentData.SessionID != SessionId ||
  7062. invFoldery.AgentData.AgentID != AgentId)
  7063. return true;
  7064. }
  7065. #endregion
  7066. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7067. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7068. {
  7069. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7070. if (handlerMoveInventoryFolder != null)
  7071. {
  7072. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7073. invFoldery.InventoryData[i].ParentID);
  7074. }
  7075. }
  7076. }
  7077. return true;
  7078. }
  7079. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7080. {
  7081. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7082. #region Packet Session and User Check
  7083. if (m_checkPackets)
  7084. {
  7085. if (createItem.AgentData.SessionID != SessionId ||
  7086. createItem.AgentData.AgentID != AgentId)
  7087. return true;
  7088. }
  7089. #endregion
  7090. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7091. if (handlerCreateNewInventoryItem != null)
  7092. {
  7093. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7094. createItem.InventoryBlock.FolderID,
  7095. createItem.InventoryBlock.CallbackID,
  7096. Util.FieldToString(createItem.InventoryBlock.Description),
  7097. Util.FieldToString(createItem.InventoryBlock.Name),
  7098. createItem.InventoryBlock.InvType,
  7099. createItem.InventoryBlock.Type,
  7100. createItem.InventoryBlock.WearableType,
  7101. createItem.InventoryBlock.NextOwnerMask,
  7102. Util.UnixTimeSinceEpoch());
  7103. }
  7104. return true;
  7105. }
  7106. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7107. {
  7108. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7109. #region Packet Session and User Check
  7110. if (m_checkPackets)
  7111. {
  7112. if (createLink.AgentData.SessionID != SessionId ||
  7113. createLink.AgentData.AgentID != AgentId)
  7114. return true;
  7115. }
  7116. #endregion
  7117. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7118. if (linkInventoryItem != null)
  7119. {
  7120. linkInventoryItem(
  7121. this,
  7122. createLink.InventoryBlock.TransactionID,
  7123. createLink.InventoryBlock.FolderID,
  7124. createLink.InventoryBlock.CallbackID,
  7125. Util.FieldToString(createLink.InventoryBlock.Description),
  7126. Util.FieldToString(createLink.InventoryBlock.Name),
  7127. createLink.InventoryBlock.InvType,
  7128. createLink.InventoryBlock.Type,
  7129. createLink.InventoryBlock.OldItemID);
  7130. }
  7131. return true;
  7132. }
  7133. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7134. {
  7135. if (OnFetchInventory != null)
  7136. {
  7137. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7138. #region Packet Session and User Check
  7139. if (m_checkPackets)
  7140. {
  7141. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7142. FetchInventoryx.AgentData.AgentID != AgentId)
  7143. return true;
  7144. }
  7145. #endregion
  7146. FetchInventory handlerFetchInventory = null;
  7147. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7148. {
  7149. handlerFetchInventory = OnFetchInventory;
  7150. if (handlerFetchInventory != null)
  7151. {
  7152. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7153. FetchInventoryx.InventoryData[i].OwnerID);
  7154. }
  7155. }
  7156. }
  7157. return true;
  7158. }
  7159. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7160. {
  7161. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7162. #region Packet Session and User Check
  7163. if (m_checkPackets)
  7164. {
  7165. if (Fetch.AgentData.SessionID != SessionId ||
  7166. Fetch.AgentData.AgentID != AgentId)
  7167. return true;
  7168. }
  7169. #endregion
  7170. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7171. if (handlerFetchInventoryDescendents != null)
  7172. {
  7173. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7174. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7175. Fetch.InventoryData.SortOrder);
  7176. }
  7177. return true;
  7178. }
  7179. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7180. {
  7181. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7182. #region Packet Session and User Check
  7183. if (m_checkPackets)
  7184. {
  7185. if (Purge.AgentData.SessionID != SessionId ||
  7186. Purge.AgentData.AgentID != AgentId)
  7187. return true;
  7188. }
  7189. #endregion
  7190. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7191. if (handlerPurgeInventoryDescendents != null)
  7192. {
  7193. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7194. }
  7195. return true;
  7196. }
  7197. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7198. {
  7199. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7200. #region Packet Session and User Check
  7201. if (m_checkPackets)
  7202. {
  7203. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7204. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7205. return true;
  7206. }
  7207. #endregion
  7208. if (OnUpdateInventoryItem != null)
  7209. {
  7210. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7211. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7212. {
  7213. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7214. if (handlerUpdateInventoryItem != null)
  7215. {
  7216. InventoryItemBase itemUpd = new InventoryItemBase();
  7217. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7218. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7219. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7220. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7221. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7222. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7223. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7224. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7225. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7226. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7227. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7228. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7229. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7230. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7231. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7232. inventoryItemUpdate.InventoryData[i].ItemID,
  7233. itemUpd);
  7234. }
  7235. }
  7236. }
  7237. return true;
  7238. }
  7239. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7240. {
  7241. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7242. #region Packet Session and User Check
  7243. if (m_checkPackets)
  7244. {
  7245. if (copyitem.AgentData.SessionID != SessionId ||
  7246. copyitem.AgentData.AgentID != AgentId)
  7247. return true;
  7248. }
  7249. #endregion
  7250. CopyInventoryItem handlerCopyInventoryItem = null;
  7251. if (OnCopyInventoryItem != null)
  7252. {
  7253. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7254. {
  7255. handlerCopyInventoryItem = OnCopyInventoryItem;
  7256. if (handlerCopyInventoryItem != null)
  7257. {
  7258. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7259. datablock.OldItemID, datablock.NewFolderID,
  7260. Util.FieldToString(datablock.NewName));
  7261. }
  7262. }
  7263. }
  7264. return true;
  7265. }
  7266. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7267. {
  7268. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7269. #region Packet Session and User Check
  7270. if (m_checkPackets)
  7271. {
  7272. if (moveitem.AgentData.SessionID != SessionId ||
  7273. moveitem.AgentData.AgentID != AgentId)
  7274. return true;
  7275. }
  7276. #endregion
  7277. if (OnMoveInventoryItem != null)
  7278. {
  7279. MoveInventoryItem handlerMoveInventoryItem = null;
  7280. InventoryItemBase itm = null;
  7281. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7282. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7283. {
  7284. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7285. itm.Folder = datablock.FolderID;
  7286. itm.Name = Util.FieldToString(datablock.NewName);
  7287. // weird, comes out as empty string
  7288. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7289. items.Add(itm);
  7290. }
  7291. handlerMoveInventoryItem = OnMoveInventoryItem;
  7292. if (handlerMoveInventoryItem != null)
  7293. {
  7294. handlerMoveInventoryItem(this, items);
  7295. }
  7296. }
  7297. return true;
  7298. }
  7299. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7300. {
  7301. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7302. #region Packet Session and User Check
  7303. if (m_checkPackets)
  7304. {
  7305. if (removeItem.AgentData.SessionID != SessionId ||
  7306. removeItem.AgentData.AgentID != AgentId)
  7307. return true;
  7308. }
  7309. #endregion
  7310. if (OnRemoveInventoryItem != null)
  7311. {
  7312. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7313. List<UUID> uuids = new List<UUID>();
  7314. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7315. {
  7316. uuids.Add(datablock.ItemID);
  7317. }
  7318. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7319. if (handlerRemoveInventoryItem != null)
  7320. {
  7321. handlerRemoveInventoryItem(this, uuids);
  7322. }
  7323. }
  7324. return true;
  7325. }
  7326. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7327. {
  7328. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7329. #region Packet Session and User Check
  7330. if (m_checkPackets)
  7331. {
  7332. if (removeFolder.AgentData.SessionID != SessionId ||
  7333. removeFolder.AgentData.AgentID != AgentId)
  7334. return true;
  7335. }
  7336. #endregion
  7337. if (OnRemoveInventoryFolder != null)
  7338. {
  7339. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7340. List<UUID> uuids = new List<UUID>();
  7341. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7342. {
  7343. uuids.Add(datablock.FolderID);
  7344. }
  7345. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7346. if (handlerRemoveInventoryFolder != null)
  7347. {
  7348. handlerRemoveInventoryFolder(this, uuids);
  7349. }
  7350. }
  7351. return true;
  7352. }
  7353. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7354. {
  7355. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7356. #region Packet Session and User Check
  7357. if (m_checkPackets)
  7358. {
  7359. if (removeObject.AgentData.SessionID != SessionId ||
  7360. removeObject.AgentData.AgentID != AgentId)
  7361. return true;
  7362. }
  7363. #endregion
  7364. if (OnRemoveInventoryFolder != null)
  7365. {
  7366. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7367. List<UUID> uuids = new List<UUID>();
  7368. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7369. {
  7370. uuids.Add(datablock.FolderID);
  7371. }
  7372. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7373. if (handlerRemoveInventoryFolder != null)
  7374. {
  7375. handlerRemoveInventoryFolder(this, uuids);
  7376. }
  7377. }
  7378. if (OnRemoveInventoryItem != null)
  7379. {
  7380. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7381. List<UUID> uuids = new List<UUID>();
  7382. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7383. {
  7384. uuids.Add(datablock.ItemID);
  7385. }
  7386. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7387. if (handlerRemoveInventoryItem != null)
  7388. {
  7389. handlerRemoveInventoryItem(this, uuids);
  7390. }
  7391. }
  7392. return true;
  7393. }
  7394. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7395. {
  7396. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7397. #region Packet Session and User Check
  7398. if (m_checkPackets)
  7399. {
  7400. if (requesttask.AgentData.SessionID != SessionId ||
  7401. requesttask.AgentData.AgentID != AgentId)
  7402. return true;
  7403. }
  7404. #endregion
  7405. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7406. if (handlerRequestTaskInventory != null)
  7407. {
  7408. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7409. }
  7410. return true;
  7411. }
  7412. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7413. {
  7414. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7415. #region Packet Session and User Check
  7416. if (m_checkPackets)
  7417. {
  7418. if (updatetask.AgentData.SessionID != SessionId ||
  7419. updatetask.AgentData.AgentID != AgentId)
  7420. return true;
  7421. }
  7422. #endregion
  7423. if (OnUpdateTaskInventory != null)
  7424. {
  7425. if (updatetask.UpdateData.Key == 0)
  7426. {
  7427. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7428. if (handlerUpdateTaskInventory != null)
  7429. {
  7430. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7431. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7432. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7433. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7434. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7435. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7436. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7437. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7438. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7439. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7440. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7441. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7442. // different
  7443. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7444. newTaskItem.Type = updatetask.InventoryData.Type;
  7445. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7446. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7447. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7448. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7449. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7450. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7451. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7452. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7453. newTaskItem, updatetask.UpdateData.LocalID);
  7454. }
  7455. }
  7456. }
  7457. return true;
  7458. }
  7459. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7460. {
  7461. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7462. #region Packet Session and User Check
  7463. if (m_checkPackets)
  7464. {
  7465. if (removeTask.AgentData.SessionID != SessionId ||
  7466. removeTask.AgentData.AgentID != AgentId)
  7467. return true;
  7468. }
  7469. #endregion
  7470. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7471. if (handlerRemoveTaskItem != null)
  7472. {
  7473. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7474. }
  7475. return true;
  7476. }
  7477. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7478. {
  7479. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7480. #region Packet Session and User Check
  7481. if (m_checkPackets)
  7482. {
  7483. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7484. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7485. return true;
  7486. }
  7487. #endregion
  7488. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7489. if (handlerMoveTaskItem != null)
  7490. {
  7491. handlerMoveTaskItem(
  7492. this, moveTaskInventoryPacket.AgentData.FolderID,
  7493. moveTaskInventoryPacket.InventoryData.LocalID,
  7494. moveTaskInventoryPacket.InventoryData.ItemID);
  7495. }
  7496. return true;
  7497. }
  7498. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7499. {
  7500. //m_log.Debug(Pack.ToString());
  7501. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7502. #region Packet Session and User Check
  7503. if (m_checkPackets)
  7504. {
  7505. if (rezScriptx.AgentData.SessionID != SessionId ||
  7506. rezScriptx.AgentData.AgentID != AgentId)
  7507. return true;
  7508. }
  7509. #endregion
  7510. RezScript handlerRezScript = OnRezScript;
  7511. InventoryItemBase item = new InventoryItemBase();
  7512. item.ID = rezScriptx.InventoryBlock.ItemID;
  7513. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7514. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7515. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7516. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7517. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7518. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7519. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7520. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7521. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7522. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7523. item.AssetType = rezScriptx.InventoryBlock.Type;
  7524. item.InvType = rezScriptx.InventoryBlock.InvType;
  7525. item.Flags = rezScriptx.InventoryBlock.Flags;
  7526. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7527. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7528. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7529. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7530. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7531. if (handlerRezScript != null)
  7532. {
  7533. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7534. }
  7535. return true;
  7536. }
  7537. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7538. {
  7539. RequestMapLayer();
  7540. return true;
  7541. }
  7542. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7543. {
  7544. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7545. #region Packet Session and User Check
  7546. if (m_checkPackets)
  7547. {
  7548. if (MapRequest.AgentData.SessionID != SessionId ||
  7549. MapRequest.AgentData.AgentID != AgentId)
  7550. return true;
  7551. }
  7552. #endregion
  7553. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7554. if (handlerRequestMapBlocks != null)
  7555. {
  7556. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7557. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7558. }
  7559. return true;
  7560. }
  7561. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7562. {
  7563. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7564. #region Packet Session and User Check
  7565. if (m_checkPackets)
  7566. {
  7567. if (map.AgentData.SessionID != SessionId ||
  7568. map.AgentData.AgentID != AgentId)
  7569. return true;
  7570. }
  7571. #endregion
  7572. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7573. map.NameData.Name.Length - 1);
  7574. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7575. if (handlerMapNameRequest != null)
  7576. {
  7577. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7578. }
  7579. return true;
  7580. }
  7581. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7582. {
  7583. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7584. #region Packet Session and User Check
  7585. if (m_checkPackets)
  7586. {
  7587. if (tpReq.Info.SessionID != SessionId ||
  7588. tpReq.Info.AgentID != AgentId)
  7589. return true;
  7590. }
  7591. #endregion
  7592. UUID lmid = tpReq.Info.LandmarkID;
  7593. AssetLandmark lm;
  7594. if (lmid != UUID.Zero)
  7595. {
  7596. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7597. AssetBase lma = m_assetService.Get(lmid.ToString());
  7598. if (lma == null)
  7599. {
  7600. // Failed to find landmark
  7601. // Let's try to search in the user's home asset server
  7602. lma = FindAssetInUserAssetServer(lmid.ToString());
  7603. if (lma == null)
  7604. {
  7605. // Really doesn't exist
  7606. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7607. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7608. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7609. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7610. }
  7611. }
  7612. try
  7613. {
  7614. lm = new AssetLandmark(lma);
  7615. }
  7616. catch (NullReferenceException)
  7617. {
  7618. // asset not found generates null ref inside the assetlandmark constructor.
  7619. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7620. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7621. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7622. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7623. return true;
  7624. }
  7625. }
  7626. else
  7627. {
  7628. // Teleport home request
  7629. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7630. if (handlerTeleportHomeRequest != null)
  7631. {
  7632. handlerTeleportHomeRequest(AgentId, this);
  7633. }
  7634. return true;
  7635. }
  7636. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7637. if (handlerTeleportLandmarkRequest != null)
  7638. {
  7639. handlerTeleportLandmarkRequest(this, lm);
  7640. }
  7641. else
  7642. {
  7643. //no event handler so cancel request
  7644. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7645. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7646. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7647. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7648. }
  7649. return true;
  7650. }
  7651. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7652. {
  7653. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7654. if (handlerTeleportCancel != null)
  7655. {
  7656. handlerTeleportCancel(this);
  7657. }
  7658. return true;
  7659. }
  7660. private AssetBase FindAssetInUserAssetServer(string id)
  7661. {
  7662. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7663. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7664. {
  7665. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7666. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7667. }
  7668. return null;
  7669. }
  7670. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7671. {
  7672. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7673. // m_log.Debug(tpLocReq.ToString());
  7674. #region Packet Session and User Check
  7675. if (m_checkPackets)
  7676. {
  7677. if (tpLocReq.AgentData.SessionID != SessionId ||
  7678. tpLocReq.AgentData.AgentID != AgentId)
  7679. return true;
  7680. }
  7681. #endregion
  7682. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7683. if (handlerTeleportLocationRequest != null)
  7684. {
  7685. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7686. tpLocReq.Info.LookAt, 16);
  7687. }
  7688. else
  7689. {
  7690. //no event handler so cancel request
  7691. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7692. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7693. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7694. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7695. }
  7696. return true;
  7697. }
  7698. #endregion Inventory/Asset/Other related packets
  7699. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7700. {
  7701. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7702. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7703. {
  7704. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7705. if (handlerNameRequest != null)
  7706. {
  7707. handlerNameRequest(UUIDBlock.ID, this);
  7708. }
  7709. }
  7710. return true;
  7711. }
  7712. #region Parcel related packets
  7713. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7714. {
  7715. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7716. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7717. if (handlerRegionHandleRequest != null)
  7718. {
  7719. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7720. }
  7721. return true;
  7722. }
  7723. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7724. {
  7725. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7726. #region Packet Session and User Check
  7727. if (m_checkPackets)
  7728. {
  7729. if (pirPack.AgentData.SessionID != SessionId ||
  7730. pirPack.AgentData.AgentID != AgentId)
  7731. return true;
  7732. }
  7733. #endregion
  7734. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7735. if (handlerParcelInfoRequest != null)
  7736. {
  7737. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7738. }
  7739. return true;
  7740. }
  7741. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7742. {
  7743. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7744. #region Packet Session and User Check
  7745. if (m_checkPackets)
  7746. {
  7747. if (requestPacket.AgentData.SessionID != SessionId ||
  7748. requestPacket.AgentData.AgentID != AgentId)
  7749. return true;
  7750. }
  7751. #endregion
  7752. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7753. if (handlerParcelAccessListRequest != null)
  7754. {
  7755. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7756. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7757. requestPacket.Data.LocalID, this);
  7758. }
  7759. return true;
  7760. }
  7761. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7762. {
  7763. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7764. #region Packet Session and User Check
  7765. if (m_checkPackets)
  7766. {
  7767. if (updatePacket.AgentData.SessionID != SessionId ||
  7768. updatePacket.AgentData.AgentID != AgentId)
  7769. return true;
  7770. }
  7771. #endregion
  7772. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7773. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7774. {
  7775. LandAccessEntry entry = new LandAccessEntry();
  7776. entry.AgentID = block.ID;
  7777. entry.Flags = (AccessList)block.Flags;
  7778. entry.Expires = block.Time;
  7779. entries.Add(entry);
  7780. }
  7781. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7782. if (handlerParcelAccessListUpdateRequest != null)
  7783. {
  7784. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7785. updatePacket.Data.Flags,
  7786. updatePacket.Data.LocalID,
  7787. updatePacket.Data.TransactionID,
  7788. updatePacket.Data.SequenceID,
  7789. updatePacket.Data.Sections,
  7790. entries, this);
  7791. }
  7792. return true;
  7793. }
  7794. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7795. {
  7796. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7797. #region Packet Session and User Check
  7798. if (m_checkPackets)
  7799. {
  7800. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7801. propertiesRequest.AgentData.AgentID != AgentId)
  7802. return true;
  7803. }
  7804. #endregion
  7805. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7806. if (handlerParcelPropertiesRequest != null)
  7807. {
  7808. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7809. (int)Math.Round(propertiesRequest.ParcelData.South),
  7810. (int)Math.Round(propertiesRequest.ParcelData.East),
  7811. (int)Math.Round(propertiesRequest.ParcelData.North),
  7812. propertiesRequest.ParcelData.SequenceID,
  7813. propertiesRequest.ParcelData.SnapSelection, this);
  7814. }
  7815. return true;
  7816. }
  7817. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7818. {
  7819. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7820. #region Packet Session and User Check
  7821. if (m_checkPackets)
  7822. {
  7823. if (landDivide.AgentData.SessionID != SessionId ||
  7824. landDivide.AgentData.AgentID != AgentId)
  7825. return true;
  7826. }
  7827. #endregion
  7828. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7829. if (handlerParcelDivideRequest != null)
  7830. {
  7831. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7832. (int)Math.Round(landDivide.ParcelData.South),
  7833. (int)Math.Round(landDivide.ParcelData.East),
  7834. (int)Math.Round(landDivide.ParcelData.North), this);
  7835. }
  7836. return true;
  7837. }
  7838. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7839. {
  7840. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7841. #region Packet Session and User Check
  7842. if (m_checkPackets)
  7843. {
  7844. if (landJoin.AgentData.SessionID != SessionId ||
  7845. landJoin.AgentData.AgentID != AgentId)
  7846. return true;
  7847. }
  7848. #endregion
  7849. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7850. if (handlerParcelJoinRequest != null)
  7851. {
  7852. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7853. (int)Math.Round(landJoin.ParcelData.South),
  7854. (int)Math.Round(landJoin.ParcelData.East),
  7855. (int)Math.Round(landJoin.ParcelData.North), this);
  7856. }
  7857. return true;
  7858. }
  7859. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7860. {
  7861. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7862. #region Packet Session and User Check
  7863. if (m_checkPackets)
  7864. {
  7865. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7866. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7867. return true;
  7868. }
  7869. #endregion
  7870. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7871. if (handlerParcelPropertiesUpdateRequest != null)
  7872. {
  7873. LandUpdateArgs args = new LandUpdateArgs();
  7874. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7875. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7876. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7877. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7878. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7879. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7880. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7881. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7882. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7883. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7884. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7885. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7886. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7887. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7888. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7889. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7890. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7891. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7892. }
  7893. return true;
  7894. }
  7895. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7896. {
  7897. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7898. #region Packet Session and User Check
  7899. if (m_checkPackets)
  7900. {
  7901. if (selectPacket.AgentData.SessionID != SessionId ||
  7902. selectPacket.AgentData.AgentID != AgentId)
  7903. return true;
  7904. }
  7905. #endregion
  7906. List<UUID> returnIDs = new List<UUID>();
  7907. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7908. selectPacket.ReturnIDs)
  7909. {
  7910. returnIDs.Add(rb.ReturnID);
  7911. }
  7912. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7913. if (handlerParcelSelectObjects != null)
  7914. {
  7915. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7916. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7917. }
  7918. return true;
  7919. }
  7920. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7921. {
  7922. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7923. #region Packet Session and User Check
  7924. if (m_checkPackets)
  7925. {
  7926. if (reqPacket.AgentData.SessionID != SessionId ||
  7927. reqPacket.AgentData.AgentID != AgentId)
  7928. return true;
  7929. }
  7930. #endregion
  7931. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7932. if (handlerParcelObjectOwnerRequest != null)
  7933. {
  7934. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7935. }
  7936. return true;
  7937. }
  7938. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7939. {
  7940. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7941. #region Packet Session and User Check
  7942. if (m_checkPackets)
  7943. {
  7944. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7945. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7946. return true;
  7947. }
  7948. #endregion
  7949. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7950. if (handlerParcelGodForceOwner != null)
  7951. {
  7952. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7953. }
  7954. return true;
  7955. }
  7956. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7957. {
  7958. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7959. #region Packet Session and User Check
  7960. if (m_checkPackets)
  7961. {
  7962. if (releasePacket.AgentData.SessionID != SessionId ||
  7963. releasePacket.AgentData.AgentID != AgentId)
  7964. return true;
  7965. }
  7966. #endregion
  7967. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7968. if (handlerParcelAbandonRequest != null)
  7969. {
  7970. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7971. }
  7972. return true;
  7973. }
  7974. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7975. {
  7976. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7977. #region Packet Session and User Check
  7978. if (m_checkPackets)
  7979. {
  7980. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7981. reclaimPacket.AgentData.AgentID != AgentId)
  7982. return true;
  7983. }
  7984. #endregion
  7985. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7986. if (handlerParcelReclaim != null)
  7987. {
  7988. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  7989. }
  7990. return true;
  7991. }
  7992. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  7993. {
  7994. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  7995. #region Packet Session and User Check
  7996. if (m_checkPackets)
  7997. {
  7998. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  7999. parcelReturnObjects.AgentData.AgentID != AgentId)
  8000. return true;
  8001. }
  8002. #endregion
  8003. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8004. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8005. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8006. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8007. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8008. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8009. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8010. if (handlerParcelReturnObjectsRequest != null)
  8011. {
  8012. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8013. }
  8014. return true;
  8015. }
  8016. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8017. {
  8018. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8019. #region Packet Session and User Check
  8020. if (m_checkPackets)
  8021. {
  8022. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8023. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8024. return true;
  8025. }
  8026. #endregion
  8027. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8028. if (handlerParcelSetOtherCleanTime != null)
  8029. {
  8030. handlerParcelSetOtherCleanTime(this,
  8031. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8032. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8033. }
  8034. return true;
  8035. }
  8036. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8037. {
  8038. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8039. #region Packet Session and User Check
  8040. if (m_checkPackets)
  8041. {
  8042. if (lsrp.AgentData.SessionID != SessionId ||
  8043. lsrp.AgentData.AgentID != AgentId)
  8044. return true;
  8045. }
  8046. #endregion
  8047. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8048. if (handlerLandStatRequest != null)
  8049. {
  8050. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8051. }
  8052. return true;
  8053. }
  8054. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8055. {
  8056. ParcelDwellRequestPacket dwellrq =
  8057. (ParcelDwellRequestPacket)Pack;
  8058. #region Packet Session and User Check
  8059. if (m_checkPackets)
  8060. {
  8061. if (dwellrq.AgentData.SessionID != SessionId ||
  8062. dwellrq.AgentData.AgentID != AgentId)
  8063. return true;
  8064. }
  8065. #endregion
  8066. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8067. if (handlerParcelDwellRequest != null)
  8068. {
  8069. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8070. }
  8071. return true;
  8072. }
  8073. #endregion Parcel related packets
  8074. #region Estate Packets
  8075. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8076. {
  8077. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8078. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8079. GodLandStatRequest handlerLandStatRequest;
  8080. #region Packet Session and User Check
  8081. if (m_checkPackets)
  8082. {
  8083. if (messagePacket.AgentData.SessionID != SessionId ||
  8084. messagePacket.AgentData.AgentID != AgentId)
  8085. return true;
  8086. }
  8087. #endregion
  8088. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8089. switch (method)
  8090. {
  8091. case "getinfo":
  8092. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8093. {
  8094. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8095. }
  8096. return true;
  8097. case "setregioninfo":
  8098. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8099. {
  8100. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8101. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8102. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8103. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8104. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8105. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8106. }
  8107. return true;
  8108. // case "texturebase":
  8109. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8110. // {
  8111. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8112. // {
  8113. // string s = Utils.BytesToString(block.Parameter);
  8114. // string[] splitField = s.Split(' ');
  8115. // if (splitField.Length == 2)
  8116. // {
  8117. // UUID tempUUID = new UUID(splitField[1]);
  8118. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8119. // }
  8120. // }
  8121. // }
  8122. // break;
  8123. case "texturedetail":
  8124. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8125. {
  8126. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8127. {
  8128. string s = Utils.BytesToString(block.Parameter);
  8129. string[] splitField = s.Split(' ');
  8130. if (splitField.Length == 2)
  8131. {
  8132. Int16 corner = Convert.ToInt16(splitField[0]);
  8133. UUID textureUUID = new UUID(splitField[1]);
  8134. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8135. }
  8136. }
  8137. }
  8138. return true;
  8139. case "textureheights":
  8140. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8141. {
  8142. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8143. {
  8144. string s = Utils.BytesToString(block.Parameter);
  8145. string[] splitField = s.Split(' ');
  8146. if (splitField.Length == 3)
  8147. {
  8148. Int16 corner = Convert.ToInt16(splitField[0]);
  8149. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8150. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8151. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8152. }
  8153. }
  8154. }
  8155. return true;
  8156. case "texturecommit":
  8157. OnCommitEstateTerrainTextureRequest(this);
  8158. return true;
  8159. case "setregionterrain":
  8160. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8161. {
  8162. if (messagePacket.ParamList.Length != 9)
  8163. {
  8164. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8165. }
  8166. else
  8167. {
  8168. try
  8169. {
  8170. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8171. if (!tmp.Contains(".")) tmp += ".00";
  8172. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8173. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8174. if (!tmp.Contains(".")) tmp += ".00";
  8175. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8176. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8177. if (!tmp.Contains(".")) tmp += ".00";
  8178. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8179. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8180. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8181. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8182. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8183. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8184. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8185. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8186. }
  8187. catch (Exception ex)
  8188. {
  8189. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8190. }
  8191. }
  8192. }
  8193. return true;
  8194. case "restart":
  8195. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8196. {
  8197. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8198. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8199. {
  8200. float timeSeconds;
  8201. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8202. timeSeconds = (int)timeSeconds;
  8203. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8204. }
  8205. }
  8206. return true;
  8207. case "estatechangecovenantid":
  8208. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8209. {
  8210. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8211. {
  8212. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8213. OnEstateChangeCovenantRequest(this, newCovenantID);
  8214. }
  8215. }
  8216. return true;
  8217. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8218. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8219. {
  8220. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8221. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8222. }
  8223. return true;
  8224. case "simulatormessage":
  8225. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8226. {
  8227. UUID invoice = messagePacket.MethodData.Invoice;
  8228. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8229. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8230. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8231. UUID sessionID = messagePacket.AgentData.SessionID;
  8232. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8233. }
  8234. return true;
  8235. case "instantmessage":
  8236. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8237. {
  8238. if (messagePacket.ParamList.Length < 2)
  8239. return true;
  8240. UUID invoice = messagePacket.MethodData.Invoice;
  8241. UUID sessionID = messagePacket.AgentData.SessionID;
  8242. UUID SenderID;
  8243. string SenderName;
  8244. string Message;
  8245. if (messagePacket.ParamList.Length < 5)
  8246. {
  8247. SenderID = AgentId;
  8248. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8249. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8250. }
  8251. else
  8252. {
  8253. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8254. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8255. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8256. }
  8257. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8258. }
  8259. return true;
  8260. case "setregiondebug":
  8261. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8262. {
  8263. UUID invoice = messagePacket.MethodData.Invoice;
  8264. UUID SenderID = messagePacket.AgentData.AgentID;
  8265. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8266. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8267. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8268. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8269. }
  8270. return true;
  8271. case "teleporthomeuser":
  8272. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8273. {
  8274. UUID invoice = messagePacket.MethodData.Invoice;
  8275. UUID SenderID = messagePacket.AgentData.AgentID;
  8276. UUID Prey;
  8277. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8278. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8279. }
  8280. return true;
  8281. case "teleporthomeallusers":
  8282. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8283. {
  8284. UUID invoice = messagePacket.MethodData.Invoice;
  8285. UUID SenderID = messagePacket.AgentData.AgentID;
  8286. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8287. }
  8288. return true;
  8289. case "colliders":
  8290. handlerLandStatRequest = OnLandStatRequest;
  8291. if (handlerLandStatRequest != null)
  8292. {
  8293. handlerLandStatRequest(0, 1, 0, "", this);
  8294. }
  8295. return true;
  8296. case "scripts":
  8297. handlerLandStatRequest = OnLandStatRequest;
  8298. if (handlerLandStatRequest != null)
  8299. {
  8300. handlerLandStatRequest(0, 0, 0, "", this);
  8301. }
  8302. return true;
  8303. case "terrain":
  8304. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8305. {
  8306. if (messagePacket.ParamList.Length > 0)
  8307. {
  8308. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8309. {
  8310. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8311. if (handlerBakeTerrain != null)
  8312. {
  8313. handlerBakeTerrain(this);
  8314. }
  8315. }
  8316. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8317. {
  8318. if (messagePacket.ParamList.Length > 1)
  8319. {
  8320. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8321. if (handlerRequestTerrain != null)
  8322. {
  8323. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8324. }
  8325. }
  8326. }
  8327. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8328. {
  8329. if (messagePacket.ParamList.Length > 1)
  8330. {
  8331. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8332. if (handlerUploadTerrain != null)
  8333. {
  8334. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8335. }
  8336. }
  8337. }
  8338. }
  8339. }
  8340. return true;
  8341. case "estatechangeinfo":
  8342. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8343. {
  8344. UUID invoice = messagePacket.MethodData.Invoice;
  8345. UUID SenderID = messagePacket.AgentData.AgentID;
  8346. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8347. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8348. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8349. if (handlerEstateChangeInfo != null)
  8350. {
  8351. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8352. }
  8353. }
  8354. return true;
  8355. case "telehub":
  8356. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8357. {
  8358. UUID invoice = messagePacket.MethodData.Invoice;
  8359. UUID SenderID = messagePacket.AgentData.AgentID;
  8360. UInt32 param1 = 0u;
  8361. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8362. if (command != "info ui")
  8363. {
  8364. try
  8365. {
  8366. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8367. }
  8368. catch
  8369. {
  8370. }
  8371. }
  8372. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8373. if (handlerEstateManageTelehub != null)
  8374. {
  8375. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8376. }
  8377. }
  8378. return true;
  8379. default:
  8380. m_log.WarnFormat(
  8381. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8382. method, Name, Scene.Name);
  8383. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8384. {
  8385. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8386. string data = (string)Utils.BytesToString(block.Parameter);
  8387. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8388. }
  8389. return true;
  8390. }
  8391. //int parcelID, uint reportType, uint requestflags, string filter
  8392. //lsrp.RequestData.ParcelLocalID;
  8393. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8394. //lsrp.RequestData.RequestFlags;
  8395. //lsrp.RequestData.Filter;
  8396. }
  8397. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8398. {
  8399. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8400. #region Packet Session and User Check
  8401. if (m_checkPackets)
  8402. {
  8403. if (mPacket.SessionID != SessionId ||
  8404. mPacket.AgentID != AgentId)
  8405. return true;
  8406. }
  8407. #endregion
  8408. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8409. if (handlerRegionInfoRequest != null)
  8410. {
  8411. handlerRegionInfoRequest(this);
  8412. }
  8413. return true;
  8414. }
  8415. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8416. {
  8417. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8418. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8419. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8420. if (handlerEstateCovenantRequest != null)
  8421. {
  8422. handlerEstateCovenantRequest(this);
  8423. }
  8424. return true;
  8425. }
  8426. #endregion Estate Packets
  8427. #region GodPackets
  8428. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8429. {
  8430. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8431. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8432. UUID token = rblock.Token;
  8433. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8434. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8435. if (handlerReqGodlikePowers != null)
  8436. {
  8437. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8438. }
  8439. return true;
  8440. }
  8441. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8442. {
  8443. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8444. (GodUpdateRegionInfoPacket)Packet;
  8445. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8446. if (handlerGodUpdateRegionInfo != null)
  8447. {
  8448. handlerGodUpdateRegionInfo(this,
  8449. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8450. GodUpdateRegionInfo.RegionInfo.EstateID,
  8451. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8452. GodUpdateRegionInfo.RegionInfo.SimName,
  8453. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8454. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8455. return true;
  8456. }
  8457. return false;
  8458. }
  8459. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8460. {
  8461. SimWideDeletesPacket SimWideDeletesRequest =
  8462. (SimWideDeletesPacket)Packet;
  8463. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8464. if (handlerSimWideDeletesRequest != null)
  8465. {
  8466. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8467. return true;
  8468. }
  8469. return false;
  8470. }
  8471. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8472. {
  8473. GodlikeMessagePacket GodlikeMessage =
  8474. (GodlikeMessagePacket)Packet;
  8475. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8476. if (handlerGodlikeMessage != null)
  8477. {
  8478. handlerGodlikeMessage(this,
  8479. GodlikeMessage.MethodData.Invoice,
  8480. GodlikeMessage.MethodData.Method,
  8481. GodlikeMessage.ParamList[0].Parameter);
  8482. return true;
  8483. }
  8484. return false;
  8485. }
  8486. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8487. {
  8488. StateSavePacket SaveStateMessage =
  8489. (StateSavePacket)Packet;
  8490. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8491. if (handlerSaveStatePacket != null)
  8492. {
  8493. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8494. return true;
  8495. }
  8496. return false;
  8497. }
  8498. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8499. {
  8500. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8501. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8502. {
  8503. GodKickUser handlerGodKickUser = OnGodKickUser;
  8504. if (handlerGodKickUser != null)
  8505. {
  8506. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8507. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8508. }
  8509. }
  8510. else
  8511. {
  8512. SendAgentAlertMessage("Kick request denied", false);
  8513. }
  8514. //KickUserPacket kupack = new KickUserPacket();
  8515. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8516. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8517. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8518. //kupack.TargetBlock.TargetIP = (uint)0;
  8519. //kupack.TargetBlock.TargetPort = (ushort)0;
  8520. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8521. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8522. return true;
  8523. }
  8524. #endregion GodPackets
  8525. #region Economy/Transaction Packets
  8526. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8527. {
  8528. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8529. #region Packet Session and User Check
  8530. if (m_checkPackets)
  8531. {
  8532. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8533. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8534. return true;
  8535. }
  8536. #endregion
  8537. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8538. if (handlerMoneyBalanceRequest != null)
  8539. {
  8540. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8541. }
  8542. return true;
  8543. }
  8544. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8545. {
  8546. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8547. if (handlerEconomoyDataRequest != null)
  8548. {
  8549. handlerEconomoyDataRequest(this);
  8550. }
  8551. return true;
  8552. }
  8553. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8554. {
  8555. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8556. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8557. if (handlerRequestPayPrice != null)
  8558. {
  8559. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8560. }
  8561. return true;
  8562. }
  8563. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8564. {
  8565. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8566. #region Packet Session and User Check
  8567. if (m_checkPackets)
  8568. {
  8569. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8570. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8571. return true;
  8572. }
  8573. #endregion
  8574. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8575. if (handlerObjectSaleInfo != null)
  8576. {
  8577. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8578. in objectSaleInfoPacket.ObjectData)
  8579. {
  8580. handlerObjectSaleInfo(this,
  8581. objectSaleInfoPacket.AgentData.AgentID,
  8582. objectSaleInfoPacket.AgentData.SessionID,
  8583. d.LocalID,
  8584. d.SaleType,
  8585. d.SalePrice);
  8586. }
  8587. }
  8588. return true;
  8589. }
  8590. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8591. {
  8592. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8593. #region Packet Session and User Check
  8594. if (m_checkPackets)
  8595. {
  8596. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8597. objectBuyPacket.AgentData.AgentID != AgentId)
  8598. return true;
  8599. }
  8600. #endregion
  8601. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8602. if (handlerObjectBuy != null)
  8603. {
  8604. foreach (ObjectBuyPacket.ObjectDataBlock d
  8605. in objectBuyPacket.ObjectData)
  8606. {
  8607. handlerObjectBuy(this,
  8608. objectBuyPacket.AgentData.AgentID,
  8609. objectBuyPacket.AgentData.SessionID,
  8610. objectBuyPacket.AgentData.GroupID,
  8611. objectBuyPacket.AgentData.CategoryID,
  8612. d.ObjectLocalID,
  8613. d.SaleType,
  8614. d.SalePrice);
  8615. }
  8616. }
  8617. return true;
  8618. }
  8619. #endregion Economy/Transaction Packets
  8620. #region Script Packets
  8621. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8622. {
  8623. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8624. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8625. if (handlerGetScriptRunning != null)
  8626. {
  8627. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8628. }
  8629. return true;
  8630. }
  8631. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8632. {
  8633. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8634. #region Packet Session and User Check
  8635. if (m_checkPackets)
  8636. {
  8637. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8638. setScriptRunning.AgentData.AgentID != AgentId)
  8639. return true;
  8640. }
  8641. #endregion
  8642. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8643. if (handlerSetScriptRunning != null)
  8644. {
  8645. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8646. }
  8647. return true;
  8648. }
  8649. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8650. {
  8651. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8652. #region Packet Session and User Check
  8653. if (m_checkPackets)
  8654. {
  8655. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8656. scriptResetPacket.AgentData.AgentID != AgentId)
  8657. return true;
  8658. }
  8659. #endregion
  8660. ScriptReset handlerScriptReset = OnScriptReset;
  8661. if (handlerScriptReset != null)
  8662. {
  8663. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8664. }
  8665. return true;
  8666. }
  8667. #endregion Script Packets
  8668. #region Gesture Managment
  8669. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8670. {
  8671. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8672. #region Packet Session and User Check
  8673. if (m_checkPackets)
  8674. {
  8675. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8676. activateGesturePacket.AgentData.AgentID != AgentId)
  8677. return true;
  8678. }
  8679. #endregion
  8680. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8681. if (handlerActivateGesture != null)
  8682. {
  8683. handlerActivateGesture(this,
  8684. activateGesturePacket.Data[0].AssetID,
  8685. activateGesturePacket.Data[0].ItemID);
  8686. }
  8687. else m_log.Error("Null pointer for activateGesture");
  8688. return true;
  8689. }
  8690. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8691. {
  8692. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8693. #region Packet Session and User Check
  8694. if (m_checkPackets)
  8695. {
  8696. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8697. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8698. return true;
  8699. }
  8700. #endregion
  8701. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8702. if (handlerDeactivateGesture != null)
  8703. {
  8704. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8705. }
  8706. return true;
  8707. }
  8708. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8709. {
  8710. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8711. #region Packet Session and User Check
  8712. if (m_checkPackets)
  8713. {
  8714. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8715. objectOwnerPacket.AgentData.AgentID != AgentId)
  8716. return true;
  8717. }
  8718. #endregion
  8719. List<uint> localIDs = new List<uint>();
  8720. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8721. localIDs.Add(d.ObjectLocalID);
  8722. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8723. if (handlerObjectOwner != null)
  8724. {
  8725. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8726. }
  8727. return true;
  8728. }
  8729. #endregion Gesture Managment
  8730. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8731. {
  8732. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8733. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8734. {
  8735. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8736. AgentFOV handlerAgentFOV = OnAgentFOV;
  8737. if (handlerAgentFOV != null)
  8738. {
  8739. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8740. }
  8741. }
  8742. return true;
  8743. }
  8744. #region unimplemented handlers
  8745. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8746. {
  8747. // TODO: handle this packet
  8748. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8749. return true;
  8750. }
  8751. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8752. {
  8753. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8754. #region Packet Session and User Check
  8755. if (m_checkPackets)
  8756. {
  8757. if (mirpk.AgentData.SessionID != SessionId ||
  8758. mirpk.AgentData.AgentID != AgentId)
  8759. return true;
  8760. }
  8761. #endregion
  8762. //m_log.Debug(mirpk.ToString());
  8763. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8764. if (handlerMapItemRequest != null)
  8765. {
  8766. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8767. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8768. mirpk.RequestData.RegionHandle);
  8769. }
  8770. return true;
  8771. }
  8772. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8773. {
  8774. return true;
  8775. }
  8776. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8777. {
  8778. MuteListRequestPacket muteListRequest =
  8779. (MuteListRequestPacket)Pack;
  8780. #region Packet Session and User Check
  8781. if (m_checkPackets)
  8782. {
  8783. if (muteListRequest.AgentData.SessionID != SessionId ||
  8784. muteListRequest.AgentData.AgentID != AgentId)
  8785. return true;
  8786. }
  8787. #endregion
  8788. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8789. if (handlerMuteListRequest != null)
  8790. {
  8791. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8792. }
  8793. else
  8794. {
  8795. SendUseCachedMuteList();
  8796. }
  8797. return true;
  8798. }
  8799. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8800. {
  8801. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8802. (UpdateMuteListEntryPacket)Packet;
  8803. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8804. if (handlerUpdateMuteListEntry != null)
  8805. {
  8806. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8807. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8808. UpdateMuteListEntry.MuteData.MuteType,
  8809. UpdateMuteListEntry.AgentData.AgentID);
  8810. return true;
  8811. }
  8812. return false;
  8813. }
  8814. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8815. {
  8816. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8817. (RemoveMuteListEntryPacket)Packet;
  8818. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8819. if (handlerRemoveMuteListEntry != null)
  8820. {
  8821. handlerRemoveMuteListEntry(this,
  8822. RemoveMuteListEntry.MuteData.MuteID,
  8823. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8824. RemoveMuteListEntry.AgentData.AgentID);
  8825. return true;
  8826. }
  8827. return false;
  8828. }
  8829. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8830. {
  8831. UserReportPacket UserReport =
  8832. (UserReportPacket)Packet;
  8833. NewUserReport handlerUserReport = OnUserReport;
  8834. if (handlerUserReport != null)
  8835. {
  8836. handlerUserReport(this,
  8837. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8838. UserReport.ReportData.AbuserID,
  8839. UserReport.ReportData.Category,
  8840. UserReport.ReportData.CheckFlags,
  8841. Utils.BytesToString(UserReport.ReportData.Details),
  8842. UserReport.ReportData.ObjectID,
  8843. UserReport.ReportData.Position,
  8844. UserReport.ReportData.ReportType,
  8845. UserReport.ReportData.ScreenshotID,
  8846. Utils.BytesToString(UserReport.ReportData.Summary),
  8847. UserReport.AgentData.AgentID);
  8848. return true;
  8849. }
  8850. return false;
  8851. }
  8852. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8853. {
  8854. // SendPostcardPacket SendPostcard =
  8855. // (SendPostcardPacket)packet;
  8856. SendPostcard handlerSendPostcard = OnSendPostcard;
  8857. if (handlerSendPostcard != null)
  8858. {
  8859. handlerSendPostcard(this);
  8860. return true;
  8861. }
  8862. return false;
  8863. }
  8864. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8865. {
  8866. return true;
  8867. }
  8868. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8869. {
  8870. return true;
  8871. }
  8872. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8873. {
  8874. return true;
  8875. }
  8876. #endregion unimplemented handlers
  8877. #region Dir handlers
  8878. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8879. {
  8880. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8881. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8882. #region Packet Session and User Check
  8883. if (m_checkPackets)
  8884. {
  8885. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8886. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8887. return true;
  8888. }
  8889. #endregion
  8890. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8891. if (handlerDirPlacesQuery != null)
  8892. {
  8893. handlerDirPlacesQuery(this,
  8894. dirPlacesQueryPacket.QueryData.QueryID,
  8895. Utils.BytesToString(
  8896. dirPlacesQueryPacket.QueryData.QueryText),
  8897. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8898. (int)dirPlacesQueryPacket.QueryData.Category,
  8899. Utils.BytesToString(
  8900. dirPlacesQueryPacket.QueryData.SimName),
  8901. dirPlacesQueryPacket.QueryData.QueryStart);
  8902. }
  8903. return true;
  8904. }
  8905. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8906. {
  8907. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8908. #region Packet Session and User Check
  8909. if (m_checkPackets)
  8910. {
  8911. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8912. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8913. return true;
  8914. }
  8915. #endregion
  8916. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8917. if (handlerDirFindQuery != null)
  8918. {
  8919. handlerDirFindQuery(this,
  8920. dirFindQueryPacket.QueryData.QueryID,
  8921. Utils.BytesToString(
  8922. dirFindQueryPacket.QueryData.QueryText),
  8923. dirFindQueryPacket.QueryData.QueryFlags,
  8924. dirFindQueryPacket.QueryData.QueryStart);
  8925. }
  8926. return true;
  8927. }
  8928. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8929. {
  8930. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8931. #region Packet Session and User Check
  8932. if (m_checkPackets)
  8933. {
  8934. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8935. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8936. return true;
  8937. }
  8938. #endregion
  8939. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8940. if (handlerDirLandQuery != null)
  8941. {
  8942. handlerDirLandQuery(this,
  8943. dirLandQueryPacket.QueryData.QueryID,
  8944. dirLandQueryPacket.QueryData.QueryFlags,
  8945. dirLandQueryPacket.QueryData.SearchType,
  8946. dirLandQueryPacket.QueryData.Price,
  8947. dirLandQueryPacket.QueryData.Area,
  8948. dirLandQueryPacket.QueryData.QueryStart);
  8949. }
  8950. return true;
  8951. }
  8952. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8953. {
  8954. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8955. #region Packet Session and User Check
  8956. if (m_checkPackets)
  8957. {
  8958. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8959. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8960. return true;
  8961. }
  8962. #endregion
  8963. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8964. if (handlerDirPopularQuery != null)
  8965. {
  8966. handlerDirPopularQuery(this,
  8967. dirPopularQueryPacket.QueryData.QueryID,
  8968. dirPopularQueryPacket.QueryData.QueryFlags);
  8969. }
  8970. return true;
  8971. }
  8972. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8973. {
  8974. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8975. #region Packet Session and User Check
  8976. if (m_checkPackets)
  8977. {
  8978. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8979. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8980. return true;
  8981. }
  8982. #endregion
  8983. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8984. if (handlerDirClassifiedQuery != null)
  8985. {
  8986. handlerDirClassifiedQuery(this,
  8987. dirClassifiedQueryPacket.QueryData.QueryID,
  8988. Utils.BytesToString(
  8989. dirClassifiedQueryPacket.QueryData.QueryText),
  8990. dirClassifiedQueryPacket.QueryData.QueryFlags,
  8991. dirClassifiedQueryPacket.QueryData.Category,
  8992. dirClassifiedQueryPacket.QueryData.QueryStart);
  8993. }
  8994. return true;
  8995. }
  8996. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  8997. {
  8998. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  8999. #region Packet Session and User Check
  9000. if (m_checkPackets)
  9001. {
  9002. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9003. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9004. return true;
  9005. }
  9006. #endregion
  9007. if (OnEventInfoRequest != null)
  9008. {
  9009. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9010. }
  9011. return true;
  9012. }
  9013. #endregion
  9014. #region Calling Card
  9015. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9016. {
  9017. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9018. #region Packet Session and User Check
  9019. if (m_checkPackets)
  9020. {
  9021. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9022. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9023. return true;
  9024. }
  9025. #endregion
  9026. if (OnOfferCallingCard != null)
  9027. {
  9028. OnOfferCallingCard(this,
  9029. offerCallingCardPacket.AgentBlock.DestID,
  9030. offerCallingCardPacket.AgentBlock.TransactionID);
  9031. }
  9032. return true;
  9033. }
  9034. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9035. {
  9036. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9037. #region Packet Session and User Check
  9038. if (m_checkPackets)
  9039. {
  9040. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9041. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9042. return true;
  9043. }
  9044. #endregion
  9045. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9046. // contain exactly one entry
  9047. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9048. {
  9049. OnAcceptCallingCard(this,
  9050. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9051. acceptCallingCardPacket.FolderData[0].FolderID);
  9052. }
  9053. return true;
  9054. }
  9055. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9056. {
  9057. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9058. #region Packet Session and User Check
  9059. if (m_checkPackets)
  9060. {
  9061. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9062. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9063. return true;
  9064. }
  9065. #endregion
  9066. if (OnDeclineCallingCard != null)
  9067. {
  9068. OnDeclineCallingCard(this,
  9069. declineCallingCardPacket.TransactionBlock.TransactionID);
  9070. }
  9071. return true;
  9072. }
  9073. #endregion Calling Card
  9074. #region Groups
  9075. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9076. {
  9077. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9078. #region Packet Session and User Check
  9079. if (m_checkPackets)
  9080. {
  9081. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9082. activateGroupPacket.AgentData.AgentID != AgentId)
  9083. return true;
  9084. }
  9085. #endregion
  9086. if (m_GroupsModule != null)
  9087. {
  9088. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9089. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9090. }
  9091. return true;
  9092. }
  9093. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9094. {
  9095. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9096. (GroupVoteHistoryRequestPacket)Packet;
  9097. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9098. if (handlerGroupVoteHistoryRequest != null)
  9099. {
  9100. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9101. return true;
  9102. }
  9103. return false;
  9104. }
  9105. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9106. {
  9107. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9108. (GroupActiveProposalsRequestPacket)Packet;
  9109. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9110. if (handlerGroupActiveProposalsRequest != null)
  9111. {
  9112. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9113. return true;
  9114. }
  9115. return false;
  9116. }
  9117. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9118. {
  9119. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9120. (GroupAccountDetailsRequestPacket)Packet;
  9121. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9122. if (handlerGroupAccountDetailsRequest != null)
  9123. {
  9124. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9125. return true;
  9126. }
  9127. return false;
  9128. }
  9129. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9130. {
  9131. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9132. (GroupAccountSummaryRequestPacket)Packet;
  9133. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9134. if (handlerGroupAccountSummaryRequest != null)
  9135. {
  9136. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9137. return true;
  9138. }
  9139. return false;
  9140. }
  9141. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9142. {
  9143. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9144. (GroupAccountTransactionsRequestPacket)Packet;
  9145. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9146. if (handlerGroupAccountTransactionsRequest != null)
  9147. {
  9148. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9149. return true;
  9150. }
  9151. return false;
  9152. }
  9153. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9154. {
  9155. GroupTitlesRequestPacket groupTitlesRequest =
  9156. (GroupTitlesRequestPacket)Pack;
  9157. #region Packet Session and User Check
  9158. if (m_checkPackets)
  9159. {
  9160. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9161. groupTitlesRequest.AgentData.AgentID != AgentId)
  9162. return true;
  9163. }
  9164. #endregion
  9165. if (m_GroupsModule != null)
  9166. {
  9167. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9168. groupTitlesReply.AgentData =
  9169. new GroupTitlesReplyPacket.AgentDataBlock();
  9170. groupTitlesReply.AgentData.AgentID = AgentId;
  9171. groupTitlesReply.AgentData.GroupID =
  9172. groupTitlesRequest.AgentData.GroupID;
  9173. groupTitlesReply.AgentData.RequestID =
  9174. groupTitlesRequest.AgentData.RequestID;
  9175. List<GroupTitlesData> titles =
  9176. m_GroupsModule.GroupTitlesRequest(this,
  9177. groupTitlesRequest.AgentData.GroupID);
  9178. groupTitlesReply.GroupData =
  9179. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9180. int i = 0;
  9181. foreach (GroupTitlesData d in titles)
  9182. {
  9183. groupTitlesReply.GroupData[i] =
  9184. new GroupTitlesReplyPacket.GroupDataBlock();
  9185. groupTitlesReply.GroupData[i].Title =
  9186. Util.StringToBytes256(d.Name);
  9187. groupTitlesReply.GroupData[i].RoleID =
  9188. d.UUID;
  9189. groupTitlesReply.GroupData[i].Selected =
  9190. d.Selected;
  9191. i++;
  9192. }
  9193. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9194. }
  9195. return true;
  9196. }
  9197. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9198. {
  9199. GroupProfileRequestPacket groupProfileRequest =
  9200. (GroupProfileRequestPacket)Pack;
  9201. #region Packet Session and User Check
  9202. if (m_checkPackets)
  9203. {
  9204. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9205. groupProfileRequest.AgentData.AgentID != AgentId)
  9206. return true;
  9207. }
  9208. #endregion
  9209. if (m_GroupsModule != null)
  9210. {
  9211. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9212. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9213. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9214. groupProfileReply.AgentData.AgentID = AgentId;
  9215. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9216. groupProfileRequest.GroupData.GroupID);
  9217. groupProfileReply.GroupData.GroupID = d.GroupID;
  9218. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9219. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9220. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9221. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9222. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9223. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9224. groupProfileReply.GroupData.FounderID = d.FounderID;
  9225. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9226. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9227. groupProfileReply.GroupData.Money = d.Money;
  9228. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9229. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9230. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9231. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9232. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9233. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9234. }
  9235. return true;
  9236. }
  9237. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9238. {
  9239. GroupMembersRequestPacket groupMembersRequestPacket =
  9240. (GroupMembersRequestPacket)Pack;
  9241. #region Packet Session and User Check
  9242. if (m_checkPackets)
  9243. {
  9244. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9245. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9246. return true;
  9247. }
  9248. #endregion
  9249. if (m_GroupsModule != null)
  9250. {
  9251. List<GroupMembersData> members =
  9252. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9253. int memberCount = members.Count;
  9254. while (true)
  9255. {
  9256. int blockCount = members.Count;
  9257. if (blockCount > 40)
  9258. blockCount = 40;
  9259. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9260. groupMembersReply.AgentData =
  9261. new GroupMembersReplyPacket.AgentDataBlock();
  9262. groupMembersReply.GroupData =
  9263. new GroupMembersReplyPacket.GroupDataBlock();
  9264. groupMembersReply.MemberData =
  9265. new GroupMembersReplyPacket.MemberDataBlock[
  9266. blockCount];
  9267. groupMembersReply.AgentData.AgentID = AgentId;
  9268. groupMembersReply.GroupData.GroupID =
  9269. groupMembersRequestPacket.GroupData.GroupID;
  9270. groupMembersReply.GroupData.RequestID =
  9271. groupMembersRequestPacket.GroupData.RequestID;
  9272. groupMembersReply.GroupData.MemberCount = memberCount;
  9273. for (int i = 0; i < blockCount; i++)
  9274. {
  9275. GroupMembersData m = members[0];
  9276. members.RemoveAt(0);
  9277. groupMembersReply.MemberData[i] =
  9278. new GroupMembersReplyPacket.MemberDataBlock();
  9279. groupMembersReply.MemberData[i].AgentID =
  9280. m.AgentID;
  9281. groupMembersReply.MemberData[i].Contribution =
  9282. m.Contribution;
  9283. groupMembersReply.MemberData[i].OnlineStatus =
  9284. Util.StringToBytes256(m.OnlineStatus);
  9285. groupMembersReply.MemberData[i].AgentPowers =
  9286. m.AgentPowers;
  9287. groupMembersReply.MemberData[i].Title =
  9288. Util.StringToBytes256(m.Title);
  9289. groupMembersReply.MemberData[i].IsOwner =
  9290. m.IsOwner;
  9291. }
  9292. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9293. if (members.Count == 0)
  9294. return true;
  9295. }
  9296. }
  9297. return true;
  9298. }
  9299. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9300. {
  9301. GroupRoleDataRequestPacket groupRolesRequest =
  9302. (GroupRoleDataRequestPacket)Pack;
  9303. #region Packet Session and User Check
  9304. if (m_checkPackets)
  9305. {
  9306. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9307. groupRolesRequest.AgentData.AgentID != AgentId)
  9308. return true;
  9309. }
  9310. #endregion
  9311. if (m_GroupsModule != null)
  9312. {
  9313. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9314. groupRolesReply.AgentData =
  9315. new GroupRoleDataReplyPacket.AgentDataBlock();
  9316. groupRolesReply.AgentData.AgentID = AgentId;
  9317. groupRolesReply.GroupData =
  9318. new GroupRoleDataReplyPacket.GroupDataBlock();
  9319. groupRolesReply.GroupData.GroupID =
  9320. groupRolesRequest.GroupData.GroupID;
  9321. groupRolesReply.GroupData.RequestID =
  9322. groupRolesRequest.GroupData.RequestID;
  9323. List<GroupRolesData> titles =
  9324. m_GroupsModule.GroupRoleDataRequest(this,
  9325. groupRolesRequest.GroupData.GroupID);
  9326. groupRolesReply.GroupData.RoleCount =
  9327. titles.Count;
  9328. groupRolesReply.RoleData =
  9329. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9330. int i = 0;
  9331. foreach (GroupRolesData d in titles)
  9332. {
  9333. groupRolesReply.RoleData[i] =
  9334. new GroupRoleDataReplyPacket.RoleDataBlock();
  9335. groupRolesReply.RoleData[i].RoleID =
  9336. d.RoleID;
  9337. groupRolesReply.RoleData[i].Name =
  9338. Util.StringToBytes256(d.Name);
  9339. groupRolesReply.RoleData[i].Title =
  9340. Util.StringToBytes256(d.Title);
  9341. groupRolesReply.RoleData[i].Description =
  9342. Util.StringToBytes1024(d.Description);
  9343. groupRolesReply.RoleData[i].Powers =
  9344. d.Powers;
  9345. groupRolesReply.RoleData[i].Members =
  9346. (uint)d.Members;
  9347. i++;
  9348. }
  9349. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9350. }
  9351. return true;
  9352. }
  9353. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9354. {
  9355. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9356. (GroupRoleMembersRequestPacket)Pack;
  9357. #region Packet Session and User Check
  9358. if (m_checkPackets)
  9359. {
  9360. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9361. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9362. return true;
  9363. }
  9364. #endregion
  9365. if (m_GroupsModule != null)
  9366. {
  9367. List<GroupRoleMembersData> mappings =
  9368. m_GroupsModule.GroupRoleMembersRequest(this,
  9369. groupRoleMembersRequest.GroupData.GroupID);
  9370. int mappingsCount = mappings.Count;
  9371. while (mappings.Count > 0)
  9372. {
  9373. int pairs = mappings.Count;
  9374. if (pairs > 32)
  9375. pairs = 32;
  9376. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9377. groupRoleMembersReply.AgentData =
  9378. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9379. groupRoleMembersReply.AgentData.AgentID =
  9380. AgentId;
  9381. groupRoleMembersReply.AgentData.GroupID =
  9382. groupRoleMembersRequest.GroupData.GroupID;
  9383. groupRoleMembersReply.AgentData.RequestID =
  9384. groupRoleMembersRequest.GroupData.RequestID;
  9385. groupRoleMembersReply.AgentData.TotalPairs =
  9386. (uint)mappingsCount;
  9387. groupRoleMembersReply.MemberData =
  9388. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9389. for (int i = 0; i < pairs; i++)
  9390. {
  9391. GroupRoleMembersData d = mappings[0];
  9392. mappings.RemoveAt(0);
  9393. groupRoleMembersReply.MemberData[i] =
  9394. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9395. groupRoleMembersReply.MemberData[i].RoleID =
  9396. d.RoleID;
  9397. groupRoleMembersReply.MemberData[i].MemberID =
  9398. d.MemberID;
  9399. }
  9400. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9401. }
  9402. }
  9403. return true;
  9404. }
  9405. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9406. {
  9407. CreateGroupRequestPacket createGroupRequest =
  9408. (CreateGroupRequestPacket)Pack;
  9409. #region Packet Session and User Check
  9410. if (m_checkPackets)
  9411. {
  9412. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9413. createGroupRequest.AgentData.AgentID != AgentId)
  9414. return true;
  9415. }
  9416. #endregion
  9417. if (m_GroupsModule != null)
  9418. {
  9419. m_GroupsModule.CreateGroup(this,
  9420. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9421. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9422. createGroupRequest.GroupData.ShowInList,
  9423. createGroupRequest.GroupData.InsigniaID,
  9424. createGroupRequest.GroupData.MembershipFee,
  9425. createGroupRequest.GroupData.OpenEnrollment,
  9426. createGroupRequest.GroupData.AllowPublish,
  9427. createGroupRequest.GroupData.MaturePublish);
  9428. }
  9429. return true;
  9430. }
  9431. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9432. {
  9433. UpdateGroupInfoPacket updateGroupInfo =
  9434. (UpdateGroupInfoPacket)Pack;
  9435. #region Packet Session and User Check
  9436. if (m_checkPackets)
  9437. {
  9438. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9439. updateGroupInfo.AgentData.AgentID != AgentId)
  9440. return true;
  9441. }
  9442. #endregion
  9443. if (m_GroupsModule != null)
  9444. {
  9445. m_GroupsModule.UpdateGroupInfo(this,
  9446. updateGroupInfo.GroupData.GroupID,
  9447. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9448. updateGroupInfo.GroupData.ShowInList,
  9449. updateGroupInfo.GroupData.InsigniaID,
  9450. updateGroupInfo.GroupData.MembershipFee,
  9451. updateGroupInfo.GroupData.OpenEnrollment,
  9452. updateGroupInfo.GroupData.AllowPublish,
  9453. updateGroupInfo.GroupData.MaturePublish);
  9454. }
  9455. return true;
  9456. }
  9457. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9458. {
  9459. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9460. (SetGroupAcceptNoticesPacket)Pack;
  9461. #region Packet Session and User Check
  9462. if (m_checkPackets)
  9463. {
  9464. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9465. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9466. return true;
  9467. }
  9468. #endregion
  9469. if (m_GroupsModule != null)
  9470. {
  9471. m_GroupsModule.SetGroupAcceptNotices(this,
  9472. setGroupAcceptNotices.Data.GroupID,
  9473. setGroupAcceptNotices.Data.AcceptNotices,
  9474. setGroupAcceptNotices.NewData.ListInProfile);
  9475. }
  9476. return true;
  9477. }
  9478. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9479. {
  9480. GroupTitleUpdatePacket groupTitleUpdate =
  9481. (GroupTitleUpdatePacket)Pack;
  9482. #region Packet Session and User Check
  9483. if (m_checkPackets)
  9484. {
  9485. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9486. groupTitleUpdate.AgentData.AgentID != AgentId)
  9487. return true;
  9488. }
  9489. #endregion
  9490. if (m_GroupsModule != null)
  9491. {
  9492. m_GroupsModule.GroupTitleUpdate(this,
  9493. groupTitleUpdate.AgentData.GroupID,
  9494. groupTitleUpdate.AgentData.TitleRoleID);
  9495. }
  9496. return true;
  9497. }
  9498. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9499. {
  9500. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9501. if (m_GroupsModule != null)
  9502. {
  9503. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9504. if (handlerParcelDeedToGroup != null)
  9505. {
  9506. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9507. }
  9508. }
  9509. return true;
  9510. }
  9511. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9512. {
  9513. GroupNoticesListRequestPacket groupNoticesListRequest =
  9514. (GroupNoticesListRequestPacket)Pack;
  9515. #region Packet Session and User Check
  9516. if (m_checkPackets)
  9517. {
  9518. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9519. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9520. return true;
  9521. }
  9522. #endregion
  9523. if (m_GroupsModule != null)
  9524. {
  9525. GroupNoticeData[] gn =
  9526. m_GroupsModule.GroupNoticesListRequest(this,
  9527. groupNoticesListRequest.Data.GroupID);
  9528. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9529. groupNoticesListReply.AgentData =
  9530. new GroupNoticesListReplyPacket.AgentDataBlock();
  9531. groupNoticesListReply.AgentData.AgentID = AgentId;
  9532. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9533. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9534. int i = 0;
  9535. foreach (GroupNoticeData g in gn)
  9536. {
  9537. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9538. groupNoticesListReply.Data[i].NoticeID =
  9539. g.NoticeID;
  9540. groupNoticesListReply.Data[i].Timestamp =
  9541. g.Timestamp;
  9542. groupNoticesListReply.Data[i].FromName =
  9543. Util.StringToBytes256(g.FromName);
  9544. groupNoticesListReply.Data[i].Subject =
  9545. Util.StringToBytes256(g.Subject);
  9546. groupNoticesListReply.Data[i].HasAttachment =
  9547. g.HasAttachment;
  9548. groupNoticesListReply.Data[i].AssetType =
  9549. g.AssetType;
  9550. i++;
  9551. }
  9552. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9553. }
  9554. return true;
  9555. }
  9556. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9557. {
  9558. GroupNoticeRequestPacket groupNoticeRequest =
  9559. (GroupNoticeRequestPacket)Pack;
  9560. #region Packet Session and User Check
  9561. if (m_checkPackets)
  9562. {
  9563. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9564. groupNoticeRequest.AgentData.AgentID != AgentId)
  9565. return true;
  9566. }
  9567. #endregion
  9568. if (m_GroupsModule != null)
  9569. {
  9570. m_GroupsModule.GroupNoticeRequest(this,
  9571. groupNoticeRequest.Data.GroupNoticeID);
  9572. }
  9573. return true;
  9574. }
  9575. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9576. {
  9577. GroupRoleUpdatePacket groupRoleUpdate =
  9578. (GroupRoleUpdatePacket)Pack;
  9579. #region Packet Session and User Check
  9580. if (m_checkPackets)
  9581. {
  9582. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9583. groupRoleUpdate.AgentData.AgentID != AgentId)
  9584. return true;
  9585. }
  9586. #endregion
  9587. if (m_GroupsModule != null)
  9588. {
  9589. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9590. groupRoleUpdate.RoleData)
  9591. {
  9592. m_GroupsModule.GroupRoleUpdate(this,
  9593. groupRoleUpdate.AgentData.GroupID,
  9594. d.RoleID,
  9595. Utils.BytesToString(d.Name),
  9596. Utils.BytesToString(d.Description),
  9597. Utils.BytesToString(d.Title),
  9598. d.Powers,
  9599. d.UpdateType);
  9600. }
  9601. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9602. }
  9603. return true;
  9604. }
  9605. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9606. {
  9607. GroupRoleChangesPacket groupRoleChanges =
  9608. (GroupRoleChangesPacket)Pack;
  9609. #region Packet Session and User Check
  9610. if (m_checkPackets)
  9611. {
  9612. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9613. groupRoleChanges.AgentData.AgentID != AgentId)
  9614. return true;
  9615. }
  9616. #endregion
  9617. if (m_GroupsModule != null)
  9618. {
  9619. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9620. groupRoleChanges.RoleChange)
  9621. {
  9622. m_GroupsModule.GroupRoleChanges(this,
  9623. groupRoleChanges.AgentData.GroupID,
  9624. d.RoleID,
  9625. d.MemberID,
  9626. d.Change);
  9627. }
  9628. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9629. }
  9630. return true;
  9631. }
  9632. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9633. {
  9634. JoinGroupRequestPacket joinGroupRequest =
  9635. (JoinGroupRequestPacket)Pack;
  9636. #region Packet Session and User Check
  9637. if (m_checkPackets)
  9638. {
  9639. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9640. joinGroupRequest.AgentData.AgentID != AgentId)
  9641. return true;
  9642. }
  9643. #endregion
  9644. if (m_GroupsModule != null)
  9645. {
  9646. m_GroupsModule.JoinGroupRequest(this,
  9647. joinGroupRequest.GroupData.GroupID);
  9648. }
  9649. return true;
  9650. }
  9651. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9652. {
  9653. LeaveGroupRequestPacket leaveGroupRequest =
  9654. (LeaveGroupRequestPacket)Pack;
  9655. #region Packet Session and User Check
  9656. if (m_checkPackets)
  9657. {
  9658. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9659. leaveGroupRequest.AgentData.AgentID != AgentId)
  9660. return true;
  9661. }
  9662. #endregion
  9663. if (m_GroupsModule != null)
  9664. {
  9665. m_GroupsModule.LeaveGroupRequest(this,
  9666. leaveGroupRequest.GroupData.GroupID);
  9667. }
  9668. return true;
  9669. }
  9670. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9671. {
  9672. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9673. (EjectGroupMemberRequestPacket)Pack;
  9674. #region Packet Session and User Check
  9675. if (m_checkPackets)
  9676. {
  9677. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9678. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9679. return true;
  9680. }
  9681. #endregion
  9682. if (m_GroupsModule != null)
  9683. {
  9684. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9685. in ejectGroupMemberRequest.EjectData)
  9686. {
  9687. m_GroupsModule.EjectGroupMemberRequest(this,
  9688. ejectGroupMemberRequest.GroupData.GroupID,
  9689. e.EjecteeID);
  9690. }
  9691. }
  9692. return true;
  9693. }
  9694. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9695. {
  9696. InviteGroupRequestPacket inviteGroupRequest =
  9697. (InviteGroupRequestPacket)Pack;
  9698. #region Packet Session and User Check
  9699. if (m_checkPackets)
  9700. {
  9701. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9702. inviteGroupRequest.AgentData.AgentID != AgentId)
  9703. return true;
  9704. }
  9705. #endregion
  9706. if (m_GroupsModule != null)
  9707. {
  9708. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9709. inviteGroupRequest.InviteData)
  9710. {
  9711. m_GroupsModule.InviteGroupRequest(this,
  9712. inviteGroupRequest.GroupData.GroupID,
  9713. b.InviteeID,
  9714. b.RoleID);
  9715. }
  9716. }
  9717. return true;
  9718. }
  9719. #endregion Groups
  9720. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9721. {
  9722. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9723. #region Packet Session and User Check
  9724. if (m_checkPackets)
  9725. {
  9726. if (startLureRequest.AgentData.SessionID != SessionId ||
  9727. startLureRequest.AgentData.AgentID != AgentId)
  9728. return true;
  9729. }
  9730. #endregion
  9731. StartLure handlerStartLure = OnStartLure;
  9732. if (handlerStartLure != null)
  9733. handlerStartLure(startLureRequest.Info.LureType,
  9734. Utils.BytesToString(
  9735. startLureRequest.Info.Message),
  9736. startLureRequest.TargetData[0].TargetID,
  9737. this);
  9738. return true;
  9739. }
  9740. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9741. {
  9742. TeleportLureRequestPacket teleportLureRequest =
  9743. (TeleportLureRequestPacket)Pack;
  9744. #region Packet Session and User Check
  9745. if (m_checkPackets)
  9746. {
  9747. if (teleportLureRequest.Info.SessionID != SessionId ||
  9748. teleportLureRequest.Info.AgentID != AgentId)
  9749. return true;
  9750. }
  9751. #endregion
  9752. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9753. if (handlerTeleportLureRequest != null)
  9754. handlerTeleportLureRequest(
  9755. teleportLureRequest.Info.LureID,
  9756. teleportLureRequest.Info.TeleportFlags,
  9757. this);
  9758. return true;
  9759. }
  9760. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9761. {
  9762. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9763. (ClassifiedInfoRequestPacket)Pack;
  9764. #region Packet Session and User Check
  9765. if (m_checkPackets)
  9766. {
  9767. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9768. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9769. return true;
  9770. }
  9771. #endregion
  9772. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9773. if (handlerClassifiedInfoRequest != null)
  9774. handlerClassifiedInfoRequest(
  9775. classifiedInfoRequest.Data.ClassifiedID,
  9776. this);
  9777. return true;
  9778. }
  9779. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9780. {
  9781. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9782. (ClassifiedInfoUpdatePacket)Pack;
  9783. #region Packet Session and User Check
  9784. if (m_checkPackets)
  9785. {
  9786. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9787. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9788. return true;
  9789. }
  9790. #endregion
  9791. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9792. if (handlerClassifiedInfoUpdate != null)
  9793. handlerClassifiedInfoUpdate(
  9794. classifiedInfoUpdate.Data.ClassifiedID,
  9795. classifiedInfoUpdate.Data.Category,
  9796. Utils.BytesToString(
  9797. classifiedInfoUpdate.Data.Name),
  9798. Utils.BytesToString(
  9799. classifiedInfoUpdate.Data.Desc),
  9800. classifiedInfoUpdate.Data.ParcelID,
  9801. classifiedInfoUpdate.Data.ParentEstate,
  9802. classifiedInfoUpdate.Data.SnapshotID,
  9803. new Vector3(
  9804. classifiedInfoUpdate.Data.PosGlobal),
  9805. classifiedInfoUpdate.Data.ClassifiedFlags,
  9806. classifiedInfoUpdate.Data.PriceForListing,
  9807. this);
  9808. return true;
  9809. }
  9810. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9811. {
  9812. ClassifiedDeletePacket classifiedDelete =
  9813. (ClassifiedDeletePacket)Pack;
  9814. #region Packet Session and User Check
  9815. if (m_checkPackets)
  9816. {
  9817. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9818. classifiedDelete.AgentData.AgentID != AgentId)
  9819. return true;
  9820. }
  9821. #endregion
  9822. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9823. if (handlerClassifiedDelete != null)
  9824. handlerClassifiedDelete(
  9825. classifiedDelete.Data.ClassifiedID,
  9826. this);
  9827. return true;
  9828. }
  9829. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9830. {
  9831. ClassifiedGodDeletePacket classifiedGodDelete =
  9832. (ClassifiedGodDeletePacket)Pack;
  9833. #region Packet Session and User Check
  9834. if (m_checkPackets)
  9835. {
  9836. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9837. classifiedGodDelete.AgentData.AgentID != AgentId)
  9838. return true;
  9839. }
  9840. #endregion
  9841. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9842. if (handlerClassifiedGodDelete != null)
  9843. handlerClassifiedGodDelete(
  9844. classifiedGodDelete.Data.ClassifiedID,
  9845. this);
  9846. return true;
  9847. }
  9848. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9849. {
  9850. EventGodDeletePacket eventGodDelete =
  9851. (EventGodDeletePacket)Pack;
  9852. #region Packet Session and User Check
  9853. if (m_checkPackets)
  9854. {
  9855. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9856. eventGodDelete.AgentData.AgentID != AgentId)
  9857. return true;
  9858. }
  9859. #endregion
  9860. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9861. if (handlerEventGodDelete != null)
  9862. handlerEventGodDelete(
  9863. eventGodDelete.EventData.EventID,
  9864. eventGodDelete.QueryData.QueryID,
  9865. Utils.BytesToString(
  9866. eventGodDelete.QueryData.QueryText),
  9867. eventGodDelete.QueryData.QueryFlags,
  9868. eventGodDelete.QueryData.QueryStart,
  9869. this);
  9870. return true;
  9871. }
  9872. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9873. {
  9874. EventNotificationAddRequestPacket eventNotificationAdd =
  9875. (EventNotificationAddRequestPacket)Pack;
  9876. #region Packet Session and User Check
  9877. if (m_checkPackets)
  9878. {
  9879. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9880. eventNotificationAdd.AgentData.AgentID != AgentId)
  9881. return true;
  9882. }
  9883. #endregion
  9884. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9885. if (handlerEventNotificationAddRequest != null)
  9886. handlerEventNotificationAddRequest(
  9887. eventNotificationAdd.EventData.EventID, this);
  9888. return true;
  9889. }
  9890. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9891. {
  9892. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9893. (EventNotificationRemoveRequestPacket)Pack;
  9894. #region Packet Session and User Check
  9895. if (m_checkPackets)
  9896. {
  9897. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9898. eventNotificationRemove.AgentData.AgentID != AgentId)
  9899. return true;
  9900. }
  9901. #endregion
  9902. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9903. if (handlerEventNotificationRemoveRequest != null)
  9904. handlerEventNotificationRemoveRequest(
  9905. eventNotificationRemove.EventData.EventID, this);
  9906. return true;
  9907. }
  9908. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9909. {
  9910. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9911. #region Packet Session and User Check
  9912. if (m_checkPackets)
  9913. {
  9914. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9915. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9916. return true;
  9917. }
  9918. #endregion
  9919. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9920. if (handlerRetrieveInstantMessages != null)
  9921. handlerRetrieveInstantMessages(this);
  9922. return true;
  9923. }
  9924. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9925. {
  9926. PickDeletePacket pickDelete =
  9927. (PickDeletePacket)Pack;
  9928. #region Packet Session and User Check
  9929. if (m_checkPackets)
  9930. {
  9931. if (pickDelete.AgentData.SessionID != SessionId ||
  9932. pickDelete.AgentData.AgentID != AgentId)
  9933. return true;
  9934. }
  9935. #endregion
  9936. PickDelete handlerPickDelete = OnPickDelete;
  9937. if (handlerPickDelete != null)
  9938. handlerPickDelete(this, pickDelete.Data.PickID);
  9939. return true;
  9940. }
  9941. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9942. {
  9943. PickGodDeletePacket pickGodDelete =
  9944. (PickGodDeletePacket)Pack;
  9945. #region Packet Session and User Check
  9946. if (m_checkPackets)
  9947. {
  9948. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9949. pickGodDelete.AgentData.AgentID != AgentId)
  9950. return true;
  9951. }
  9952. #endregion
  9953. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9954. if (handlerPickGodDelete != null)
  9955. handlerPickGodDelete(this,
  9956. pickGodDelete.AgentData.AgentID,
  9957. pickGodDelete.Data.PickID,
  9958. pickGodDelete.Data.QueryID);
  9959. return true;
  9960. }
  9961. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9962. {
  9963. PickInfoUpdatePacket pickInfoUpdate =
  9964. (PickInfoUpdatePacket)Pack;
  9965. #region Packet Session and User Check
  9966. if (m_checkPackets)
  9967. {
  9968. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9969. pickInfoUpdate.AgentData.AgentID != AgentId)
  9970. return true;
  9971. }
  9972. #endregion
  9973. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9974. if (handlerPickInfoUpdate != null)
  9975. handlerPickInfoUpdate(this,
  9976. pickInfoUpdate.Data.PickID,
  9977. pickInfoUpdate.Data.CreatorID,
  9978. pickInfoUpdate.Data.TopPick,
  9979. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9980. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9981. pickInfoUpdate.Data.SnapshotID,
  9982. pickInfoUpdate.Data.SortOrder,
  9983. pickInfoUpdate.Data.Enabled);
  9984. return true;
  9985. }
  9986. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9987. {
  9988. AvatarNotesUpdatePacket avatarNotesUpdate =
  9989. (AvatarNotesUpdatePacket)Pack;
  9990. #region Packet Session and User Check
  9991. if (m_checkPackets)
  9992. {
  9993. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  9994. avatarNotesUpdate.AgentData.AgentID != AgentId)
  9995. return true;
  9996. }
  9997. #endregion
  9998. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  9999. if (handlerAvatarNotesUpdate != null)
  10000. handlerAvatarNotesUpdate(this,
  10001. avatarNotesUpdate.Data.TargetID,
  10002. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10003. return true;
  10004. }
  10005. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10006. {
  10007. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10008. (AvatarInterestsUpdatePacket)Pack;
  10009. #region Packet Session and User Check
  10010. if (m_checkPackets)
  10011. {
  10012. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10013. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10014. return true;
  10015. }
  10016. #endregion
  10017. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10018. if (handlerAvatarInterestUpdate != null)
  10019. handlerAvatarInterestUpdate(this,
  10020. avatarInterestUpdate.PropertiesData.WantToMask,
  10021. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10022. avatarInterestUpdate.PropertiesData.SkillsMask,
  10023. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10024. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10025. return true;
  10026. }
  10027. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10028. {
  10029. GrantUserRightsPacket GrantUserRights =
  10030. (GrantUserRightsPacket)Pack;
  10031. #region Packet Session and User Check
  10032. if (m_checkPackets)
  10033. {
  10034. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10035. GrantUserRights.AgentData.AgentID != AgentId)
  10036. return true;
  10037. }
  10038. #endregion
  10039. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10040. if (GrantUserRightsHandler != null)
  10041. GrantUserRightsHandler(this,
  10042. GrantUserRights.Rights[0].AgentRelated,
  10043. GrantUserRights.Rights[0].RelatedRights);
  10044. return true;
  10045. }
  10046. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10047. {
  10048. PlacesQueryPacket placesQueryPacket =
  10049. (PlacesQueryPacket)Pack;
  10050. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10051. if (handlerPlacesQuery != null)
  10052. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10053. placesQueryPacket.TransactionData.TransactionID,
  10054. Utils.BytesToString(
  10055. placesQueryPacket.QueryData.QueryText),
  10056. placesQueryPacket.QueryData.QueryFlags,
  10057. (byte)placesQueryPacket.QueryData.Category,
  10058. Utils.BytesToString(
  10059. placesQueryPacket.QueryData.SimName),
  10060. this);
  10061. return true;
  10062. }
  10063. #endregion Packet Handlers
  10064. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10065. {
  10066. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10067. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10068. // TODO: don't create new blocks if recycling an old packet
  10069. scriptQuestion.Data.TaskID = taskID;
  10070. scriptQuestion.Data.ItemID = itemID;
  10071. scriptQuestion.Data.Questions = question;
  10072. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10073. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10074. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10075. }
  10076. /// <summary>
  10077. /// Handler called when we receive a logout packet.
  10078. /// </summary>
  10079. /// <param name="client"></param>
  10080. /// <param name="packet"></param>
  10081. /// <returns></returns>
  10082. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10083. {
  10084. if (packet.Type == PacketType.LogoutRequest)
  10085. {
  10086. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10087. }
  10088. return Logout(client);
  10089. }
  10090. /// <summary>
  10091. ///
  10092. /// </summary>
  10093. /// <param name="client"></param>
  10094. /// <returns></returns>
  10095. protected virtual bool Logout(IClientAPI client)
  10096. {
  10097. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10098. Action<IClientAPI> handlerLogout = OnLogout;
  10099. if (handlerLogout != null)
  10100. {
  10101. handlerLogout(client);
  10102. }
  10103. return true;
  10104. }
  10105. /// <summary>
  10106. /// </summary>
  10107. /// <remarks>
  10108. /// At the moment, we always reply that there is no cached texture.
  10109. /// </remarks>
  10110. /// <param name="simclient"></param>
  10111. /// <param name="packet"></param>
  10112. /// <returns></returns>
  10113. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10114. {
  10115. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10116. if (cachedtex.AgentData.SessionID != SessionId)
  10117. return false;
  10118. List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
  10119. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  10120. {
  10121. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  10122. arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
  10123. arg.WearableHashID = cachedtex.WearableData[i].ID;
  10124. requestArgs.Add(arg);
  10125. }
  10126. try
  10127. {
  10128. CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
  10129. if (handlerCachedTextureRequest != null)
  10130. {
  10131. handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
  10132. }
  10133. }
  10134. catch (Exception e)
  10135. {
  10136. m_log.ErrorFormat("[CLIENT VIEW]: AgentTextureCached packet handler threw an exception, {0}", e);
  10137. return false;
  10138. }
  10139. return true;
  10140. }
  10141. /// <summary>
  10142. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10143. /// its appearance texture cached.
  10144. /// </summary>
  10145. /// <param name="avatar"></param>
  10146. /// <param name="serial"></param>
  10147. /// <param name="cachedTextures"></param>
  10148. /// <returns></returns>
  10149. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10150. {
  10151. ScenePresence presence = avatar as ScenePresence;
  10152. if (presence == null)
  10153. return;
  10154. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10155. // TODO: don't create new blocks if recycling an old packet
  10156. cachedresp.AgentData.AgentID = m_agentId;
  10157. cachedresp.AgentData.SessionID = m_sessionId;
  10158. cachedresp.AgentData.SerialNum = serial;
  10159. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10160. for (int i = 0; i < cachedTextures.Count; i++)
  10161. {
  10162. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10163. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10164. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10165. cachedresp.WearableData[i].HostName = new byte[0];
  10166. }
  10167. cachedresp.Header.Zerocoded = true;
  10168. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10169. }
  10170. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10171. {
  10172. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10173. if (multipleupdate.AgentData.SessionID != SessionId)
  10174. return false;
  10175. // m_log.DebugFormat(
  10176. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10177. Scene tScene = (Scene)m_scene;
  10178. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10179. {
  10180. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10181. // Can't act on Null Data
  10182. if (block.Data != null)
  10183. {
  10184. uint localId = block.ObjectLocalID;
  10185. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10186. if (part == null)
  10187. {
  10188. // It's a ghost! tell the client to delete it from view.
  10189. simClient.SendKillObject(new List<uint> { localId });
  10190. }
  10191. else
  10192. {
  10193. // m_log.DebugFormat(
  10194. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10195. // i, block.Type, part.Name, part.LocalId);
  10196. // // Do this once since fetch parts creates a new array.
  10197. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10198. // for (int j = 0; j < parts.Length; j++)
  10199. // {
  10200. // part.StoreUndoState();
  10201. // parts[j].IgnoreUndoUpdate = true;
  10202. // }
  10203. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10204. switch (block.Type)
  10205. {
  10206. case 1:
  10207. Vector3 pos1 = new Vector3(block.Data, 0);
  10208. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10209. if (handlerUpdatePrimSinglePosition != null)
  10210. {
  10211. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10212. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10213. }
  10214. break;
  10215. case 2:
  10216. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10217. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10218. if (handlerUpdatePrimSingleRotation != null)
  10219. {
  10220. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10221. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10222. }
  10223. break;
  10224. case 3:
  10225. Vector3 rotPos = new Vector3(block.Data, 0);
  10226. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10227. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10228. if (handlerUpdatePrimSingleRotationPosition != null)
  10229. {
  10230. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10231. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10232. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10233. }
  10234. break;
  10235. case 4:
  10236. case 20:
  10237. Vector3 scale4 = new Vector3(block.Data, 0);
  10238. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10239. if (handlerUpdatePrimScale != null)
  10240. {
  10241. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10242. handlerUpdatePrimScale(localId, scale4, this);
  10243. }
  10244. break;
  10245. case 5:
  10246. Vector3 scale1 = new Vector3(block.Data, 12);
  10247. Vector3 pos11 = new Vector3(block.Data, 0);
  10248. handlerUpdatePrimScale = OnUpdatePrimScale;
  10249. if (handlerUpdatePrimScale != null)
  10250. {
  10251. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10252. handlerUpdatePrimScale(localId, scale1, this);
  10253. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10254. if (handlerUpdatePrimSinglePosition != null)
  10255. {
  10256. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10257. }
  10258. }
  10259. break;
  10260. case 9:
  10261. Vector3 pos2 = new Vector3(block.Data, 0);
  10262. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10263. if (handlerUpdateVector != null)
  10264. {
  10265. handlerUpdateVector(localId, pos2, this);
  10266. }
  10267. break;
  10268. case 10:
  10269. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10270. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10271. if (handlerUpdatePrimRotation != null)
  10272. {
  10273. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10274. handlerUpdatePrimRotation(localId, rot3, this);
  10275. }
  10276. break;
  10277. case 11:
  10278. Vector3 pos3 = new Vector3(block.Data, 0);
  10279. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10280. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10281. if (handlerUpdatePrimGroupRotation != null)
  10282. {
  10283. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10284. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10285. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10286. }
  10287. break;
  10288. case 12:
  10289. case 28:
  10290. Vector3 scale7 = new Vector3(block.Data, 0);
  10291. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10292. if (handlerUpdatePrimGroupScale != null)
  10293. {
  10294. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10295. handlerUpdatePrimGroupScale(localId, scale7, this);
  10296. }
  10297. break;
  10298. case 13:
  10299. Vector3 scale2 = new Vector3(block.Data, 12);
  10300. Vector3 pos4 = new Vector3(block.Data, 0);
  10301. handlerUpdatePrimScale = OnUpdatePrimScale;
  10302. if (handlerUpdatePrimScale != null)
  10303. {
  10304. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10305. handlerUpdatePrimScale(localId, scale2, this);
  10306. // Change the position based on scale (for bug number 246)
  10307. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10308. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10309. if (handlerUpdatePrimSinglePosition != null)
  10310. {
  10311. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10312. }
  10313. }
  10314. break;
  10315. case 29:
  10316. Vector3 scale5 = new Vector3(block.Data, 12);
  10317. Vector3 pos5 = new Vector3(block.Data, 0);
  10318. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10319. if (handlerUpdatePrimGroupScale != null)
  10320. {
  10321. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10322. part.StoreUndoState(true);
  10323. part.IgnoreUndoUpdate = true;
  10324. handlerUpdatePrimGroupScale(localId, scale5, this);
  10325. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10326. if (handlerUpdateVector != null)
  10327. {
  10328. handlerUpdateVector(localId, pos5, this);
  10329. }
  10330. part.IgnoreUndoUpdate = false;
  10331. }
  10332. break;
  10333. case 21:
  10334. Vector3 scale6 = new Vector3(block.Data, 12);
  10335. Vector3 pos6 = new Vector3(block.Data, 0);
  10336. handlerUpdatePrimScale = OnUpdatePrimScale;
  10337. if (handlerUpdatePrimScale != null)
  10338. {
  10339. part.StoreUndoState(false);
  10340. part.IgnoreUndoUpdate = true;
  10341. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10342. handlerUpdatePrimScale(localId, scale6, this);
  10343. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10344. if (handlerUpdatePrimSinglePosition != null)
  10345. {
  10346. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10347. }
  10348. part.IgnoreUndoUpdate = false;
  10349. }
  10350. break;
  10351. default:
  10352. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10353. break;
  10354. }
  10355. // for (int j = 0; j < parts.Length; j++)
  10356. // parts[j].IgnoreUndoUpdate = false;
  10357. }
  10358. }
  10359. }
  10360. return true;
  10361. }
  10362. public void RequestMapLayer()
  10363. {
  10364. //should be getting the map layer from the grid server
  10365. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10366. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10367. // TODO: don't create new blocks if recycling an old packet
  10368. mapReply.AgentData.AgentID = AgentId;
  10369. mapReply.AgentData.Flags = 0;
  10370. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10371. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10372. mapReply.LayerData[0].Bottom = 0;
  10373. mapReply.LayerData[0].Left = 0;
  10374. mapReply.LayerData[0].Top = 30000;
  10375. mapReply.LayerData[0].Right = 30000;
  10376. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10377. mapReply.Header.Zerocoded = true;
  10378. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10379. }
  10380. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10381. {
  10382. /*
  10383. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10384. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10385. mbReply.AgentData.AgentId = AgentId;
  10386. int len;
  10387. if (simMapProfiles == null)
  10388. len = 0;
  10389. else
  10390. len = simMapProfiles.Count;
  10391. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10392. int iii;
  10393. for (iii = 0; iii < len; iii++)
  10394. {
  10395. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10396. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10397. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10398. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10399. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10400. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10401. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10402. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10403. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10404. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10405. }
  10406. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10407. */
  10408. }
  10409. /// <summary>
  10410. /// Sets the throttles from values supplied by the client
  10411. /// </summary>
  10412. /// <param name="throttles"></param>
  10413. public void SetChildAgentThrottle(byte[] throttles)
  10414. {
  10415. m_udpClient.SetThrottles(throttles);
  10416. }
  10417. /// <summary>
  10418. /// Get the current throttles for this client as a packed byte array
  10419. /// </summary>
  10420. /// <param name="multiplier">Unused</param>
  10421. /// <returns></returns>
  10422. public byte[] GetThrottlesPacked(float multiplier)
  10423. {
  10424. return m_udpClient.GetThrottlesPacked(multiplier);
  10425. }
  10426. /// <summary>
  10427. /// Cruft?
  10428. /// </summary>
  10429. public virtual void InPacket(object NewPack)
  10430. {
  10431. throw new NotImplementedException();
  10432. }
  10433. /// <summary>
  10434. /// This is the starting point for sending a simulator packet out to the client
  10435. /// </summary>
  10436. /// <param name="packet">Packet to send</param>
  10437. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10438. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10439. {
  10440. #region BinaryStats
  10441. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10442. #endregion BinaryStats
  10443. OutPacket(packet, throttlePacketType, true);
  10444. }
  10445. /// <summary>
  10446. /// This is the starting point for sending a simulator packet out to the client
  10447. /// </summary>
  10448. /// <param name="packet">Packet to send</param>
  10449. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10450. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10451. /// packets (the default), or false to disable splitting if the calling code
  10452. /// handles splitting manually</param>
  10453. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10454. {
  10455. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10456. }
  10457. /// <summary>
  10458. /// This is the starting point for sending a simulator packet out to the client
  10459. /// </summary>
  10460. /// <param name="packet">Packet to send</param>
  10461. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10462. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10463. /// packets (the default), or false to disable splitting if the calling code
  10464. /// handles splitting manually</param>
  10465. /// <param name="method">The method to be called in the event this packet is reliable
  10466. /// and unacknowledged. The server will provide normal resend capability if you do not
  10467. /// provide your own method.</param>
  10468. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10469. {
  10470. if (DebugPacketLevel > 0)
  10471. {
  10472. bool logPacket = true;
  10473. if (DebugPacketLevel <= 255
  10474. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10475. logPacket = false;
  10476. if (DebugPacketLevel <= 200
  10477. && (packet.Type == PacketType.ImagePacket
  10478. || packet.Type == PacketType.ImageData
  10479. || packet.Type == PacketType.LayerData
  10480. || packet.Type == PacketType.CoarseLocationUpdate))
  10481. logPacket = false;
  10482. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10483. logPacket = false;
  10484. if (DebugPacketLevel <= 50
  10485. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10486. logPacket = false;
  10487. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10488. logPacket = false;
  10489. if (logPacket)
  10490. m_log.DebugFormat(
  10491. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10492. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10493. }
  10494. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10495. }
  10496. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10497. {
  10498. float locx = 0;
  10499. float locy = 0;
  10500. float locz = 0;
  10501. uint regionX = 0;
  10502. uint regionY = 0;
  10503. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10504. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10505. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10506. locz = Convert.ToSingle(args[2]);
  10507. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10508. if (handlerAutoPilotGo != null)
  10509. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10510. }
  10511. /// <summary>
  10512. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10513. /// </summary>
  10514. /// <param name="Pack">OpenMetaverse.packet</param>
  10515. public void ProcessInPacket(Packet packet)
  10516. {
  10517. if (DebugPacketLevel > 0)
  10518. {
  10519. bool logPacket = true;
  10520. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10521. logPacket = false;
  10522. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10523. logPacket = false;
  10524. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10525. logPacket = false;
  10526. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10527. logPacket = false;
  10528. if (logPacket)
  10529. m_log.DebugFormat(
  10530. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10531. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10532. }
  10533. if (!ProcessPacketMethod(packet))
  10534. m_log.WarnFormat(
  10535. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10536. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10537. }
  10538. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10539. {
  10540. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10541. shape.PCode = addPacket.ObjectData.PCode;
  10542. shape.State = addPacket.ObjectData.State;
  10543. shape.LastAttachPoint = addPacket.ObjectData.State;
  10544. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10545. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10546. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10547. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10548. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10549. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10550. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10551. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10552. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10553. shape.Scale = addPacket.ObjectData.Scale;
  10554. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10555. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10556. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10557. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10558. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10559. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10560. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10561. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10562. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10563. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10564. shape.TextureEntry = ntex.GetBytes();
  10565. //shape.Textures = ntex;
  10566. return shape;
  10567. }
  10568. public ClientInfo GetClientInfo()
  10569. {
  10570. ClientInfo info = m_udpClient.GetClientInfo();
  10571. info.proxyEP = null;
  10572. if (info.agentcircuit == null)
  10573. info.agentcircuit = RequestClientInfo();
  10574. return info;
  10575. }
  10576. public void SetClientInfo(ClientInfo info)
  10577. {
  10578. m_udpClient.SetClientInfo(info);
  10579. }
  10580. #region Media Parcel Members
  10581. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10582. {
  10583. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10584. commandMessagePacket.CommandBlock.Flags = flags;
  10585. commandMessagePacket.CommandBlock.Command = (uint)command;
  10586. commandMessagePacket.CommandBlock.Time = time;
  10587. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10588. }
  10589. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10590. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10591. byte mediaLoop)
  10592. {
  10593. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10594. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10595. updatePacket.DataBlock.MediaID = mediaTextureID;
  10596. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10597. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10598. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10599. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10600. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10601. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10602. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10603. }
  10604. #endregion
  10605. #region Camera
  10606. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10607. {
  10608. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10609. packet.ObjectData.ObjectID = objectID;
  10610. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10611. uint idx = 0;
  10612. foreach (KeyValuePair<int, float> pair in parameters)
  10613. {
  10614. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10615. block.Type = pair.Key;
  10616. block.Value = pair.Value;
  10617. camPropBlock[idx++] = block;
  10618. }
  10619. packet.CameraProperty = camPropBlock;
  10620. OutPacket(packet, ThrottleOutPacketType.Task);
  10621. }
  10622. public void SendClearFollowCamProperties(UUID objectID)
  10623. {
  10624. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10625. packet.ObjectData.ObjectID = objectID;
  10626. OutPacket(packet, ThrottleOutPacketType.Task);
  10627. }
  10628. #endregion
  10629. public void SetClientOption(string option, string value)
  10630. {
  10631. switch (option)
  10632. {
  10633. default:
  10634. break;
  10635. }
  10636. }
  10637. public string GetClientOption(string option)
  10638. {
  10639. switch (option)
  10640. {
  10641. default:
  10642. break;
  10643. }
  10644. return string.Empty;
  10645. }
  10646. #region IClientCore
  10647. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10648. /// <summary>
  10649. /// Register an interface on this client, should only be called in the constructor.
  10650. /// </summary>
  10651. /// <typeparam name="T"></typeparam>
  10652. /// <param name="iface"></param>
  10653. protected void RegisterInterface<T>(T iface)
  10654. {
  10655. lock (m_clientInterfaces)
  10656. {
  10657. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10658. {
  10659. m_clientInterfaces.Add(typeof(T), iface);
  10660. }
  10661. }
  10662. }
  10663. public bool TryGet<T>(out T iface)
  10664. {
  10665. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10666. {
  10667. iface = (T)m_clientInterfaces[typeof(T)];
  10668. return true;
  10669. }
  10670. iface = default(T);
  10671. return false;
  10672. }
  10673. public T Get<T>()
  10674. {
  10675. return (T)m_clientInterfaces[typeof(T)];
  10676. }
  10677. public void Disconnect(string reason)
  10678. {
  10679. Kick(reason);
  10680. Thread.Sleep(1000);
  10681. Disconnect();
  10682. }
  10683. public void Disconnect()
  10684. {
  10685. Close();
  10686. }
  10687. #endregion
  10688. public void RefreshGroupMembership()
  10689. {
  10690. if (m_GroupsModule != null)
  10691. {
  10692. GroupMembershipData[] GroupMembership =
  10693. m_GroupsModule.GetMembershipData(AgentId);
  10694. m_groupPowers.Clear();
  10695. if (GroupMembership != null)
  10696. {
  10697. for (int i = 0; i < GroupMembership.Length; i++)
  10698. {
  10699. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10700. }
  10701. }
  10702. }
  10703. }
  10704. public string Report()
  10705. {
  10706. return m_udpClient.GetStats();
  10707. }
  10708. public string XReport(string uptime, string version)
  10709. {
  10710. return String.Empty;
  10711. }
  10712. public OSDMap OReport(string uptime, string version)
  10713. {
  10714. return new OSDMap();
  10715. }
  10716. /// <summary>
  10717. /// Make an asset request to the asset service in response to a client request.
  10718. /// </summary>
  10719. /// <param name="transferRequest"></param>
  10720. /// <param name="taskID"></param>
  10721. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10722. {
  10723. UUID requestID = UUID.Zero;
  10724. int sourceType = transferRequest.TransferInfo.SourceType;
  10725. if (sourceType == (int)SourceType.Asset)
  10726. {
  10727. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10728. }
  10729. else if (sourceType == (int)SourceType.SimInventoryItem)
  10730. {
  10731. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10732. }
  10733. else if (sourceType == (int)SourceType.SimEstate)
  10734. {
  10735. requestID = taskID;
  10736. }
  10737. // m_log.DebugFormat(
  10738. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10739. // requestID, taskID, (SourceType)sourceType, Name);
  10740. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10741. }
  10742. /// <summary>
  10743. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10744. /// </summary>
  10745. /// <param name="id"></param>
  10746. /// <param name="sender"></param>
  10747. /// <param name="asset"></param>
  10748. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10749. {
  10750. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10751. UUID requestID = UUID.Zero;
  10752. byte source = (byte)SourceType.Asset;
  10753. AssetRequestToClient req = new AssetRequestToClient();
  10754. if (asset == null)
  10755. {
  10756. req.AssetInf = null;
  10757. req.AssetRequestSource = source;
  10758. req.IsTextureRequest = false;
  10759. req.NumPackets = 0;
  10760. req.Params = transferRequest.TransferInfo.Params;
  10761. req.RequestAssetID = requestID;
  10762. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10763. SendAssetNotFound(req);
  10764. return;
  10765. }
  10766. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10767. {
  10768. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10769. }
  10770. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10771. {
  10772. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10773. source = (byte)SourceType.SimInventoryItem;
  10774. //m_log.Debug("asset request " + requestID);
  10775. }
  10776. // Scripts cannot be retrieved by direct request
  10777. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10778. return;
  10779. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10780. req.AssetInf = asset;
  10781. req.AssetRequestSource = source;
  10782. req.IsTextureRequest = false;
  10783. req.NumPackets = CalculateNumPackets(asset.Data);
  10784. req.Params = transferRequest.TransferInfo.Params;
  10785. req.RequestAssetID = requestID;
  10786. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10787. SendAsset(req);
  10788. }
  10789. /// <summary>
  10790. /// Calculate the number of packets required to send the asset to the client.
  10791. /// </summary>
  10792. /// <param name="data"></param>
  10793. /// <returns></returns>
  10794. private static int CalculateNumPackets(byte[] data)
  10795. {
  10796. const uint m_maxPacketSize = 600;
  10797. int numPackets = 1;
  10798. if (data == null)
  10799. return 0;
  10800. if (data.LongLength > m_maxPacketSize)
  10801. {
  10802. // over max number of bytes so split up file
  10803. long restData = data.LongLength - m_maxPacketSize;
  10804. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10805. numPackets += restPackets;
  10806. }
  10807. return numPackets;
  10808. }
  10809. public void SendRebakeAvatarTextures(UUID textureID)
  10810. {
  10811. RebakeAvatarTexturesPacket pack =
  10812. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10813. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10814. pack.TextureData.TextureID = textureID;
  10815. OutPacket(pack, ThrottleOutPacketType.Task);
  10816. }
  10817. public struct PacketProcessor
  10818. {
  10819. public PacketMethod method;
  10820. public bool Async;
  10821. }
  10822. public class AsyncPacketProcess
  10823. {
  10824. public bool result = false;
  10825. public readonly LLClientView ClientView = null;
  10826. public readonly Packet Pack = null;
  10827. public readonly PacketMethod Method = null;
  10828. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10829. {
  10830. ClientView = pClientview;
  10831. Method = pMethod;
  10832. Pack = pPack;
  10833. }
  10834. }
  10835. public static OSD BuildEvent(string eventName, OSD eventBody)
  10836. {
  10837. OSDMap osdEvent = new OSDMap(2);
  10838. osdEvent.Add("message", new OSDString(eventName));
  10839. osdEvent.Add("body", eventBody);
  10840. return osdEvent;
  10841. }
  10842. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10843. {
  10844. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10845. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10846. packet.AgentData.AgentID = AgentId;
  10847. packet.AgentData.AvatarID = avatarID;
  10848. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10849. packet.PropertiesData.WantToMask = wantMask;
  10850. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10851. packet.PropertiesData.SkillsMask = skillsMask;
  10852. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10853. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10854. OutPacket(packet, ThrottleOutPacketType.Task);
  10855. }
  10856. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10857. {
  10858. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10859. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10860. packet.AgentData.AgentID = agentID;
  10861. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10862. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10863. packet.Rights[0].AgentRelated = friendID;
  10864. packet.Rights[0].RelatedRights = rights;
  10865. OutPacket(packet, ThrottleOutPacketType.Task);
  10866. }
  10867. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10868. {
  10869. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10870. dialog.Data.ObjectID = objectId;
  10871. dialog.Data.ChatChannel = chatChannel;
  10872. dialog.Data.ImageID = UUID.Zero;
  10873. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10874. // this is the username of the *owner*
  10875. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10876. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10877. dialog.Data.Message = Util.StringToBytes256(message);
  10878. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10879. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10880. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10881. dialog.Buttons = buttons;
  10882. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10883. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10884. dialog.OwnerData[0].OwnerID = ownerID;
  10885. OutPacket(dialog, ThrottleOutPacketType.Task);
  10886. }
  10887. public void SendAgentTerseUpdate(ISceneEntity p)
  10888. {
  10889. if (p is ScenePresence)
  10890. {
  10891. // m_log.DebugFormat(
  10892. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  10893. // p.Name, Name, Scene.Name);
  10894. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10895. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10896. // velocity, collision plane and avatar height
  10897. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10898. // when the avatar stands up
  10899. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10900. CreateImprovedTerseBlock(p, false);
  10901. const float TIME_DILATION = 1.0f;
  10902. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10903. ImprovedTerseObjectUpdatePacket packet
  10904. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  10905. PacketType.ImprovedTerseObjectUpdate);
  10906. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10907. packet.RegionData.TimeDilation = timeDilation;
  10908. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10909. packet.ObjectData[0] = block;
  10910. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10911. }
  10912. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10913. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10914. }
  10915. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10916. PlacesReplyData[] data)
  10917. {
  10918. PlacesReplyPacket reply = null;
  10919. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10920. new PlacesReplyPacket.QueryDataBlock[0];
  10921. for (int i = 0 ; i < data.Length ; i++)
  10922. {
  10923. PlacesReplyPacket.QueryDataBlock block =
  10924. new PlacesReplyPacket.QueryDataBlock();
  10925. block.OwnerID = data[i].OwnerID;
  10926. block.Name = Util.StringToBytes256(data[i].Name);
  10927. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10928. block.ActualArea = data[i].ActualArea;
  10929. block.BillableArea = data[i].BillableArea;
  10930. block.Flags = data[i].Flags;
  10931. block.GlobalX = data[i].GlobalX;
  10932. block.GlobalY = data[i].GlobalY;
  10933. block.GlobalZ = data[i].GlobalZ;
  10934. block.SimName = Util.StringToBytes256(data[i].SimName);
  10935. block.SnapshotID = data[i].SnapshotID;
  10936. block.Dwell = data[i].Dwell;
  10937. block.Price = data[i].Price;
  10938. if (reply != null && reply.Length + block.Length > 1400)
  10939. {
  10940. OutPacket(reply, ThrottleOutPacketType.Task);
  10941. reply = null;
  10942. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10943. }
  10944. if (reply == null)
  10945. {
  10946. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10947. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10948. reply.AgentData.AgentID = AgentId;
  10949. reply.AgentData.QueryID = queryID;
  10950. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10951. reply.TransactionData.TransactionID = transactionID;
  10952. reply.QueryData = dataBlocks;
  10953. }
  10954. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10955. dataBlocks[dataBlocks.Length - 1] = block;
  10956. reply.QueryData = dataBlocks;
  10957. }
  10958. if (reply != null)
  10959. OutPacket(reply, ThrottleOutPacketType.Task);
  10960. }
  10961. public void SendRemoveInventoryItems(UUID[] items)
  10962. {
  10963. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10964. if (eq == null)
  10965. {
  10966. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10967. return;
  10968. }
  10969. OSDMap llsd = new OSDMap(3);
  10970. OSDMap AgentDataMap = new OSDMap(1);
  10971. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10972. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10973. OSDArray AgentData = new OSDArray(1);
  10974. AgentData.Add(AgentDataMap);
  10975. llsd.Add("AgentData", AgentData);
  10976. OSDArray ItemData = new OSDArray();
  10977. foreach (UUID item in items)
  10978. {
  10979. OSDMap ItemDataMap = new OSDMap(2);
  10980. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  10981. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10982. ItemData.Add(ItemDataMap);
  10983. }
  10984. llsd.Add("InventoryData", ItemData);
  10985. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  10986. llsd), AgentId);
  10987. }
  10988. public void SendRemoveInventoryFolders(UUID[] folders)
  10989. {
  10990. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10991. if (eq == null)
  10992. {
  10993. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10994. return;
  10995. }
  10996. OSDMap llsd = new OSDMap(3);
  10997. OSDMap AgentDataMap = new OSDMap(1);
  10998. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10999. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11000. OSDArray AgentData = new OSDArray(1);
  11001. AgentData.Add(AgentDataMap);
  11002. llsd.Add("AgentData", AgentData);
  11003. OSDArray FolderData = new OSDArray();
  11004. foreach (UUID folder in folders)
  11005. {
  11006. OSDMap FolderDataMap = new OSDMap(2);
  11007. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11008. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11009. FolderData.Add(FolderDataMap);
  11010. }
  11011. llsd.Add("FolderData", FolderData);
  11012. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11013. llsd), AgentId);
  11014. }
  11015. private byte[] EncodeU32(uint val)
  11016. {
  11017. byte[] ret = BitConverter.GetBytes(val);
  11018. if (BitConverter.IsLittleEndian)
  11019. Array.Reverse(ret);
  11020. return ret;
  11021. }
  11022. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11023. {
  11024. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11025. if (eq == null)
  11026. {
  11027. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11028. return;
  11029. }
  11030. OSDMap llsd = new OSDMap(3);
  11031. OSDMap AgentDataMap = new OSDMap(1);
  11032. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11033. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11034. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11035. OSDArray AgentData = new OSDArray(1);
  11036. AgentData.Add(AgentDataMap);
  11037. llsd.Add("AgentData", AgentData);
  11038. OSDArray FolderData = new OSDArray();
  11039. foreach (InventoryFolderBase folder in folders)
  11040. {
  11041. OSDMap FolderDataMap = new OSDMap(5);
  11042. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11043. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11044. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11045. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11046. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11047. FolderData.Add(FolderDataMap);
  11048. }
  11049. llsd.Add("FolderData", FolderData);
  11050. OSDArray ItemData = new OSDArray();
  11051. foreach (InventoryItemBase item in items)
  11052. {
  11053. OSDMap ItemDataMap = new OSDMap();
  11054. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11055. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11056. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11057. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11058. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11059. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11060. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11061. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11062. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11063. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11064. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11065. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11066. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11067. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11068. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11069. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11070. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11071. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11072. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11073. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11074. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11075. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11076. (sbyte)item.AssetType, item.AssetID,
  11077. item.GroupID, 100,
  11078. item.Owner, item.CreatorIdAsUuid,
  11079. item.ID, item.Folder,
  11080. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11081. (uint)PermissionMask.All)
  11082. )));
  11083. ItemDataMap.Add("CallbackID", 0);
  11084. ItemData.Add(ItemDataMap);
  11085. }
  11086. llsd.Add("ItemData", ItemData);
  11087. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11088. llsd), AgentId);
  11089. }
  11090. }
  11091. }