1
0

LLClientView.cs 551 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566
  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. namespace OpenSim.Region.ClientStack.LindenUDP
  53. {
  54. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  55. /// <summary>
  56. /// Handles new client connections
  57. /// Constructor takes a single Packet and authenticates everything
  58. /// </summary>
  59. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
  60. {
  61. /// <value>
  62. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  63. /// </value>
  64. public int DebugPacketLevel { get; set; }
  65. #region Events
  66. public event GenericMessage OnGenericMessage;
  67. public event BinaryGenericMessage OnBinaryGenericMessage;
  68. public event Action<IClientAPI> OnLogout;
  69. public event ObjectPermissions OnObjectPermissions;
  70. public event Action<IClientAPI> OnConnectionClosed;
  71. public event ViewerEffectEventHandler OnViewerEffect;
  72. public event ImprovedInstantMessage OnInstantMessage;
  73. public event ChatMessage OnChatFromClient;
  74. public event TextureRequest OnRequestTexture;
  75. public event RezObject OnRezObject;
  76. public event DeRezObject OnDeRezObject;
  77. public event ModifyTerrain OnModifyTerrain;
  78. public event Action<IClientAPI> OnRegionHandShakeReply;
  79. public event GenericCall1 OnRequestWearables;
  80. public event SetAppearance OnSetAppearance;
  81. public event AvatarNowWearing OnAvatarNowWearing;
  82. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  83. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  84. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  85. public event ObjectAttach OnObjectAttach;
  86. public event ObjectDeselect OnObjectDetach;
  87. public event ObjectDrop OnObjectDrop;
  88. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  89. public event UpdateAgent OnPreAgentUpdate;
  90. public event UpdateAgent OnAgentUpdate;
  91. public event AgentRequestSit OnAgentRequestSit;
  92. public event AgentSit OnAgentSit;
  93. public event AvatarPickerRequest OnAvatarPickerRequest;
  94. public event StartAnim OnStartAnim;
  95. public event StopAnim OnStopAnim;
  96. public event Action<IClientAPI> OnRequestAvatarsData;
  97. public event LinkObjects OnLinkObjects;
  98. public event DelinkObjects OnDelinkObjects;
  99. public event GrabObject OnGrabObject;
  100. public event DeGrabObject OnDeGrabObject;
  101. public event SpinStart OnSpinStart;
  102. public event SpinStop OnSpinStop;
  103. public event ObjectDuplicate OnObjectDuplicate;
  104. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  105. public event MoveObject OnGrabUpdate;
  106. public event SpinObject OnSpinUpdate;
  107. public event AddNewPrim OnAddPrim;
  108. public event RequestGodlikePowers OnRequestGodlikePowers;
  109. public event GodKickUser OnGodKickUser;
  110. public event ObjectExtraParams OnUpdateExtraParams;
  111. public event UpdateShape OnUpdatePrimShape;
  112. public event ObjectRequest OnObjectRequest;
  113. public event ObjectSelect OnObjectSelect;
  114. public event ObjectDeselect OnObjectDeselect;
  115. public event GenericCall7 OnObjectDescription;
  116. public event GenericCall7 OnObjectName;
  117. public event GenericCall7 OnObjectClickAction;
  118. public event GenericCall7 OnObjectMaterial;
  119. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  120. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  121. public event UpdatePrimFlags OnUpdatePrimFlags;
  122. public event UpdatePrimTexture OnUpdatePrimTexture;
  123. public event UpdateVector OnUpdatePrimGroupPosition;
  124. public event UpdateVector OnUpdatePrimSinglePosition;
  125. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  126. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  127. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  128. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  129. public event UpdateVector OnUpdatePrimScale;
  130. public event UpdateVector OnUpdatePrimGroupScale;
  131. public event StatusChange OnChildAgentStatus;
  132. public event GenericCall2 OnStopMovement;
  133. public event Action<UUID> OnRemoveAvatar;
  134. public event RequestMapBlocks OnRequestMapBlocks;
  135. public event RequestMapName OnMapNameRequest;
  136. public event TeleportLocationRequest OnTeleportLocationRequest;
  137. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  138. public event TeleportCancel OnTeleportCancel;
  139. public event DisconnectUser OnDisconnectUser;
  140. public event RequestAvatarProperties OnRequestAvatarProperties;
  141. public event SetAlwaysRun OnSetAlwaysRun;
  142. public event FetchInventory OnAgentDataUpdateRequest;
  143. public event TeleportLocationRequest OnSetStartLocationRequest;
  144. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  145. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  146. public event LinkInventoryItem OnLinkInventoryItem;
  147. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  148. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  149. public event MoveInventoryFolder OnMoveInventoryFolder;
  150. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  151. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  152. public event FetchInventory OnFetchInventory;
  153. public event RequestTaskInventory OnRequestTaskInventory;
  154. public event UpdateInventoryItem OnUpdateInventoryItem;
  155. public event CopyInventoryItem OnCopyInventoryItem;
  156. public event MoveInventoryItem OnMoveInventoryItem;
  157. public event RemoveInventoryItem OnRemoveInventoryItem;
  158. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  159. public event UDPAssetUploadRequest OnAssetUploadRequest;
  160. public event XferReceive OnXferReceive;
  161. public event RequestXfer OnRequestXfer;
  162. public event ConfirmXfer OnConfirmXfer;
  163. public event AbortXfer OnAbortXfer;
  164. public event RequestTerrain OnRequestTerrain;
  165. public event RezScript OnRezScript;
  166. public event UpdateTaskInventory OnUpdateTaskInventory;
  167. public event MoveTaskInventory OnMoveTaskItem;
  168. public event RemoveTaskInventory OnRemoveTaskItem;
  169. public event RequestAsset OnRequestAsset;
  170. public event UUIDNameRequest OnNameFromUUIDRequest;
  171. public event ParcelAccessListRequest OnParcelAccessListRequest;
  172. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  173. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  174. public event ParcelDivideRequest OnParcelDivideRequest;
  175. public event ParcelJoinRequest OnParcelJoinRequest;
  176. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  177. public event ParcelSelectObjects OnParcelSelectObjects;
  178. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  179. public event ParcelAbandonRequest OnParcelAbandonRequest;
  180. public event ParcelGodForceOwner OnParcelGodForceOwner;
  181. public event ParcelReclaim OnParcelReclaim;
  182. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  183. public event ParcelDeedToGroup OnParcelDeedToGroup;
  184. public event RegionInfoRequest OnRegionInfoRequest;
  185. public event EstateCovenantRequest OnEstateCovenantRequest;
  186. public event FriendActionDelegate OnApproveFriendRequest;
  187. public event FriendActionDelegate OnDenyFriendRequest;
  188. public event FriendshipTermination OnTerminateFriendship;
  189. public event GrantUserFriendRights OnGrantUserRights;
  190. public event MoneyTransferRequest OnMoneyTransferRequest;
  191. public event EconomyDataRequest OnEconomyDataRequest;
  192. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  193. public event ParcelBuy OnParcelBuy;
  194. public event UUIDNameRequest OnTeleportHomeRequest;
  195. public event UUIDNameRequest OnUUIDGroupNameRequest;
  196. public event ScriptAnswer OnScriptAnswer;
  197. public event RequestPayPrice OnRequestPayPrice;
  198. public event ObjectSaleInfo OnObjectSaleInfo;
  199. public event ObjectBuy OnObjectBuy;
  200. public event BuyObjectInventory OnBuyObjectInventory;
  201. public event AgentSit OnUndo;
  202. public event AgentSit OnRedo;
  203. public event LandUndo OnLandUndo;
  204. public event ForceReleaseControls OnForceReleaseControls;
  205. public event GodLandStatRequest OnLandStatRequest;
  206. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  207. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  208. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  209. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  210. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  211. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  212. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  213. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  214. public event BakeTerrain OnBakeTerrain;
  215. public event RequestTerrain OnUploadTerrain;
  216. public event EstateChangeInfo OnEstateChangeInfo;
  217. public event EstateManageTelehub OnEstateManageTelehub;
  218. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  219. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  220. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  221. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  222. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  223. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  224. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  225. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  226. public event RegionHandleRequest OnRegionHandleRequest;
  227. public event ParcelInfoRequest OnParcelInfoRequest;
  228. public event ScriptReset OnScriptReset;
  229. public event GetScriptRunning OnGetScriptRunning;
  230. public event SetScriptRunning OnSetScriptRunning;
  231. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  232. public event TerrainUnacked OnUnackedTerrain;
  233. public event ActivateGesture OnActivateGesture;
  234. public event DeactivateGesture OnDeactivateGesture;
  235. public event ObjectOwner OnObjectOwner;
  236. public event DirPlacesQuery OnDirPlacesQuery;
  237. public event DirFindQuery OnDirFindQuery;
  238. public event DirLandQuery OnDirLandQuery;
  239. public event DirPopularQuery OnDirPopularQuery;
  240. public event DirClassifiedQuery OnDirClassifiedQuery;
  241. public event EventInfoRequest OnEventInfoRequest;
  242. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  243. public event MapItemRequest OnMapItemRequest;
  244. public event OfferCallingCard OnOfferCallingCard;
  245. public event AcceptCallingCard OnAcceptCallingCard;
  246. public event DeclineCallingCard OnDeclineCallingCard;
  247. public event SoundTrigger OnSoundTrigger;
  248. public event StartLure OnStartLure;
  249. public event TeleportLureRequest OnTeleportLureRequest;
  250. public event NetworkStats OnNetworkStatsUpdate;
  251. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  252. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  253. public event ClassifiedDelete OnClassifiedDelete;
  254. public event ClassifiedDelete OnClassifiedGodDelete;
  255. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  256. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  257. public event EventGodDelete OnEventGodDelete;
  258. public event ParcelDwellRequest OnParcelDwellRequest;
  259. public event UserInfoRequest OnUserInfoRequest;
  260. public event UpdateUserInfo OnUpdateUserInfo;
  261. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  262. public event PickDelete OnPickDelete;
  263. public event PickGodDelete OnPickGodDelete;
  264. public event PickInfoUpdate OnPickInfoUpdate;
  265. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  266. public event MuteListRequest OnMuteListRequest;
  267. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  268. public event PlacesQuery OnPlacesQuery;
  269. public event AgentFOV OnAgentFOV;
  270. public event FindAgentUpdate OnFindAgent;
  271. public event TrackAgentUpdate OnTrackAgent;
  272. public event NewUserReport OnUserReport;
  273. public event SaveStateHandler OnSaveState;
  274. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  275. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  276. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  277. public event FreezeUserUpdate OnParcelFreezeUser;
  278. public event EjectUserUpdate OnParcelEjectUser;
  279. public event ParcelBuyPass OnParcelBuyPass;
  280. public event ParcelGodMark OnParcelGodMark;
  281. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  282. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  283. public event SimWideDeletesDelegate OnSimWideDeletes;
  284. public event SendPostcard OnSendPostcard;
  285. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  286. public event MuteListEntryRemove OnRemoveMuteListEntry;
  287. public event GodlikeMessage onGodlikeMessage;
  288. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  289. #endregion Events
  290. #region Class Members
  291. // LLClientView Only
  292. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  293. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  294. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  295. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  296. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  297. /// <summary>
  298. /// Handles UDP texture download.
  299. /// </summary>
  300. public LLImageManager ImageManager { get; private set; }
  301. private readonly LLUDPServer m_udpServer;
  302. private readonly LLUDPClient m_udpClient;
  303. private readonly UUID m_sessionId;
  304. private readonly UUID m_secureSessionId;
  305. protected readonly UUID m_agentId;
  306. private readonly uint m_circuitCode;
  307. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  308. private readonly IGroupsModule m_GroupsModule;
  309. private int m_cachedTextureSerial;
  310. private PriorityQueue m_entityUpdates;
  311. private PriorityQueue m_entityProps;
  312. private Prioritizer m_prioritizer;
  313. private bool m_disableFacelights = false;
  314. /// <value>
  315. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  316. /// continually recreate it.
  317. /// </value>
  318. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  319. /// <value>
  320. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  321. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  322. /// ownerless phantom.
  323. ///
  324. /// All manipulation of this set has to occur under a lock
  325. ///
  326. /// </value>
  327. protected HashSet<uint> m_killRecord;
  328. // protected HashSet<uint> m_attachmentsSent;
  329. private int m_moneyBalance;
  330. private int m_animationSequenceNumber = 1;
  331. private bool m_SendLogoutPacketWhenClosing = true;
  332. /// <summary>
  333. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  334. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  335. /// is doing absolutely nothing.
  336. /// </summary>
  337. /// <remarks>
  338. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  339. /// cannot retain a reference to it outside of that method.
  340. /// </remarks>
  341. private AgentUpdateArgs m_lastAgentUpdateArgs;
  342. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  343. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  344. protected Scene m_scene;
  345. protected string m_firstName;
  346. protected string m_lastName;
  347. protected Thread m_clientThread;
  348. protected Vector3 m_startpos;
  349. protected UUID m_activeGroupID;
  350. protected string m_activeGroupName = String.Empty;
  351. protected ulong m_activeGroupPowers;
  352. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  353. protected int m_terrainCheckerCount;
  354. protected uint m_agentFOVCounter;
  355. protected IAssetService m_assetService;
  356. private const bool m_checkPackets = true;
  357. #endregion Class Members
  358. #region Properties
  359. public LLUDPClient UDPClient { get { return m_udpClient; } }
  360. public LLUDPServer UDPServer { get { return m_udpServer; } }
  361. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  362. public UUID SecureSessionId { get { return m_secureSessionId; } }
  363. public IScene Scene { get { return m_scene; } }
  364. public UUID SessionId { get { return m_sessionId; } }
  365. public Vector3 StartPos
  366. {
  367. get { return m_startpos; }
  368. set { m_startpos = value; }
  369. }
  370. public UUID AgentId { get { return m_agentId; } }
  371. public ISceneAgent SceneAgent { get; set; }
  372. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  373. public string ActiveGroupName { get { return m_activeGroupName; } }
  374. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  375. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  376. /// <summary>
  377. /// Entity update queues
  378. /// </summary>
  379. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  380. /// <summary>
  381. /// First name of the agent/avatar represented by the client
  382. /// </summary>
  383. public string FirstName { get { return m_firstName; } }
  384. /// <summary>
  385. /// Last name of the agent/avatar represented by the client
  386. /// </summary>
  387. public string LastName { get { return m_lastName; } }
  388. /// <summary>
  389. /// Full name of the client (first name and last name)
  390. /// </summary>
  391. public string Name { get { return FirstName + " " + LastName; } }
  392. public uint CircuitCode { get { return m_circuitCode; } }
  393. public int MoneyBalance { get { return m_moneyBalance; } }
  394. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  395. /// <summary>
  396. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  397. /// prevent race conditions by different threads calling Close().
  398. /// </summary>
  399. public bool IsActive { get; set; }
  400. /// <summary>
  401. /// Used to synchronise threads when client is being closed.
  402. /// </summary>
  403. public Object CloseSyncLock { get; private set; }
  404. public bool IsLoggingOut { get; set; }
  405. public bool DisableFacelights
  406. {
  407. get { return m_disableFacelights; }
  408. set { m_disableFacelights = value; }
  409. }
  410. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  411. #endregion Properties
  412. // ~LLClientView()
  413. // {
  414. // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode);
  415. // }
  416. /// <summary>
  417. /// Constructor
  418. /// </summary>
  419. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  420. UUID agentId, UUID sessionId, uint circuitCode)
  421. {
  422. // DebugPacketLevel = 1;
  423. CloseSyncLock = new Object();
  424. RegisterInterface<IClientIM>(this);
  425. RegisterInterface<IClientInventory>(this);
  426. RegisterInterface<IClientChat>(this);
  427. m_scene = scene;
  428. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  429. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  430. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  431. m_killRecord = new HashSet<uint>();
  432. // m_attachmentsSent = new HashSet<uint>();
  433. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  434. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  435. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  436. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  437. m_agentId = agentId;
  438. m_sessionId = sessionId;
  439. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  440. m_circuitCode = circuitCode;
  441. m_firstName = sessionInfo.LoginInfo.First;
  442. m_lastName = sessionInfo.LoginInfo.Last;
  443. m_startpos = sessionInfo.LoginInfo.StartPos;
  444. m_moneyBalance = 1000;
  445. m_udpServer = udpServer;
  446. m_udpClient = udpClient;
  447. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  448. m_udpClient.OnPacketStats += PopulateStats;
  449. m_prioritizer = new Prioritizer(m_scene);
  450. RegisterLocalPacketHandlers();
  451. IsActive = true;
  452. }
  453. #region Client Methods
  454. public void Close()
  455. {
  456. Close(false);
  457. }
  458. public void Close(bool force)
  459. {
  460. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  461. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  462. lock (CloseSyncLock)
  463. {
  464. // We still perform a force close inside the sync lock since this is intended to attempt close where
  465. // there is some unidentified connection problem, not where we have issues due to deadlock
  466. if (!IsActive && !force)
  467. return;
  468. IsActive = false;
  469. CloseWithoutChecks();
  470. }
  471. }
  472. /// <summary>
  473. /// Closes down the client view without first checking whether it is active.
  474. /// </summary>
  475. /// <remarks>
  476. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  477. /// CloseWithoutIsActiveCheck asynchronously.
  478. ///
  479. /// Callers must lock ClosingSyncLock before calling.
  480. /// </remarks>
  481. public void CloseWithoutChecks()
  482. {
  483. m_log.DebugFormat(
  484. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  485. Name, m_scene.RegionInfo.RegionName);
  486. // Shutdown the image manager
  487. ImageManager.Close();
  488. // Fire the callback for this connection closing
  489. if (OnConnectionClosed != null)
  490. OnConnectionClosed(this);
  491. // Flush all of the packets out of the UDP server for this client
  492. if (m_udpServer != null)
  493. m_udpServer.Flush(m_udpClient);
  494. // Remove ourselves from the scene
  495. m_scene.RemoveClient(AgentId, true);
  496. SceneAgent = null;
  497. // We can't reach into other scenes and close the connection
  498. // We need to do this over grid communications
  499. //m_scene.CloseAllAgents(CircuitCode);
  500. // Disable UDP handling for this client
  501. m_udpClient.Shutdown();
  502. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  503. //GC.Collect();
  504. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  505. }
  506. public void Kick(string message)
  507. {
  508. if (!SceneAgent.IsChildAgent)
  509. {
  510. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  511. kupack.UserInfo.AgentID = AgentId;
  512. kupack.UserInfo.SessionID = SessionId;
  513. kupack.TargetBlock.TargetIP = 0;
  514. kupack.TargetBlock.TargetPort = 0;
  515. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  516. OutPacket(kupack, ThrottleOutPacketType.Task);
  517. // You must sleep here or users get no message!
  518. Thread.Sleep(500);
  519. }
  520. }
  521. public void Stop()
  522. {
  523. }
  524. #endregion Client Methods
  525. #region Packet Handling
  526. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  527. {
  528. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  529. if (handlerNetworkStatsUpdate != null)
  530. {
  531. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  532. }
  533. }
  534. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  535. {
  536. bool result = false;
  537. lock (PacketHandlers)
  538. {
  539. if (!PacketHandlers.ContainsKey(packetType))
  540. {
  541. PacketHandlers.Add(packetType, handler);
  542. result = true;
  543. }
  544. }
  545. return result;
  546. }
  547. /// <summary>
  548. /// Add a handler for the given packet type.
  549. /// </summary>
  550. /// <remarks>
  551. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  552. /// are received then please use the synchronous version of this method.
  553. /// </remarks>
  554. /// <param name="packetType"></param>
  555. /// <param name="handler"></param>
  556. /// <returns>true if the handler was added. This is currently always the case.</returns>
  557. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  558. {
  559. return AddLocalPacketHandler(packetType, handler, true);
  560. }
  561. /// <summary>
  562. /// Add a handler for the given packet type.
  563. /// </summary>
  564. /// <param name="packetType"></param>
  565. /// <param name="handler"></param>
  566. /// <param name="doAsync">
  567. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  568. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  569. /// synchronously.
  570. /// </param>
  571. /// <returns>true if the handler was added. This is currently always the case.</returns>
  572. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  573. {
  574. bool result = false;
  575. lock (m_packetHandlers)
  576. {
  577. if (!m_packetHandlers.ContainsKey(packetType))
  578. {
  579. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  580. result = true;
  581. }
  582. }
  583. return result;
  584. }
  585. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  586. {
  587. MethodName = MethodName.ToLower().Trim();
  588. bool result = false;
  589. lock (m_genericPacketHandlers)
  590. {
  591. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  592. {
  593. m_genericPacketHandlers.Add(MethodName, handler);
  594. result = true;
  595. }
  596. }
  597. return result;
  598. }
  599. /// <summary>
  600. /// Try to process a packet using registered packet handlers
  601. /// </summary>
  602. /// <param name="packet"></param>
  603. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  604. protected virtual bool ProcessPacketMethod(Packet packet)
  605. {
  606. bool result = false;
  607. PacketProcessor pprocessor;
  608. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  609. {
  610. //there is a local handler for this packet type
  611. if (pprocessor.Async)
  612. {
  613. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  614. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  615. result = true;
  616. }
  617. else
  618. {
  619. result = pprocessor.method(this, packet);
  620. }
  621. }
  622. else
  623. {
  624. //there is not a local handler so see if there is a Global handler
  625. PacketMethod method = null;
  626. bool found;
  627. lock (PacketHandlers)
  628. {
  629. found = PacketHandlers.TryGetValue(packet.Type, out method);
  630. }
  631. if (found)
  632. {
  633. result = method(this, packet);
  634. }
  635. }
  636. return result;
  637. }
  638. public void ProcessSpecificPacketAsync(object state)
  639. {
  640. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  641. try
  642. {
  643. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  644. }
  645. catch (Exception e)
  646. {
  647. // Make sure that we see any exception caused by the asynchronous operation.
  648. m_log.ErrorFormat(
  649. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  650. packetObject.Pack, Name, e.Message, e.StackTrace);
  651. }
  652. }
  653. #endregion Packet Handling
  654. # region Setup
  655. public virtual void Start()
  656. {
  657. m_scene.AddNewClient(this, PresenceType.User);
  658. RefreshGroupMembership();
  659. }
  660. # endregion
  661. public void ActivateGesture(UUID assetId, UUID gestureId)
  662. {
  663. }
  664. public void DeactivateGesture(UUID assetId, UUID gestureId)
  665. {
  666. }
  667. // Sound
  668. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  669. {
  670. }
  671. #region Scene/Avatar to Client
  672. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  673. {
  674. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  675. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  676. handshake.RegionInfo.BillableFactor = args.billableFactor;
  677. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  678. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  679. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  680. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  681. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  682. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  683. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  684. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  685. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  686. handshake.RegionInfo.SimAccess = args.simAccess;
  687. handshake.RegionInfo.WaterHeight = args.waterHeight;
  688. handshake.RegionInfo.RegionFlags = args.regionFlags;
  689. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  690. handshake.RegionInfo.SimOwner = args.SimOwner;
  691. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  692. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  693. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  694. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  695. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  696. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  697. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  698. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  699. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  700. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  701. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  702. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  703. handshake.RegionInfo3.CPUClassID = 9;
  704. handshake.RegionInfo3.CPURatio = 1;
  705. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  706. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  707. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  708. OutPacket(handshake, ThrottleOutPacketType.Task);
  709. }
  710. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  711. {
  712. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  713. mov.SimData.ChannelVersion = m_channelVersion;
  714. mov.AgentData.SessionID = m_sessionId;
  715. mov.AgentData.AgentID = AgentId;
  716. mov.Data.RegionHandle = regInfo.RegionHandle;
  717. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  718. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  719. {
  720. mov.Data.Position = m_startpos;
  721. }
  722. else
  723. {
  724. mov.Data.Position = pos;
  725. }
  726. mov.Data.LookAt = look;
  727. // Hack to get this out immediately and skip the throttles
  728. OutPacket(mov, ThrottleOutPacketType.Unknown);
  729. }
  730. public void SendChatMessage(
  731. string message, byte type, Vector3 fromPos, string fromName,
  732. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  733. {
  734. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  735. reply.ChatData.Audible = audible;
  736. reply.ChatData.Message = Util.StringToBytes1024(message);
  737. reply.ChatData.ChatType = type;
  738. reply.ChatData.SourceType = source;
  739. reply.ChatData.Position = fromPos;
  740. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  741. reply.ChatData.OwnerID = ownerID;
  742. reply.ChatData.SourceID = fromAgentID;
  743. OutPacket(reply, ThrottleOutPacketType.Task);
  744. }
  745. /// <summary>
  746. /// Send an instant message to this client
  747. /// </summary>
  748. //
  749. // Don't remove transaction ID! Groups and item gives need to set it!
  750. public void SendInstantMessage(GridInstantMessage im)
  751. {
  752. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  753. {
  754. ImprovedInstantMessagePacket msg
  755. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  756. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  757. msg.AgentData.SessionID = UUID.Zero;
  758. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  759. msg.MessageBlock.Dialog = im.dialog;
  760. msg.MessageBlock.FromGroup = im.fromGroup;
  761. if (im.imSessionID == UUID.Zero.Guid)
  762. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  763. else
  764. msg.MessageBlock.ID = new UUID(im.imSessionID);
  765. msg.MessageBlock.Offline = im.offline;
  766. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  767. msg.MessageBlock.Position = im.Position;
  768. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  769. msg.MessageBlock.Timestamp = im.timestamp;
  770. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  771. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  772. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  773. if (im.message.StartsWith("[grouptest]"))
  774. { // this block is test code for implementing group IM - delete when group IM is finished
  775. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  776. if (eq != null)
  777. {
  778. im.dialog = 17;
  779. //eq.ChatterboxInvitation(
  780. // new UUID("00000000-68f9-1111-024e-222222111123"),
  781. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  782. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  783. eq.ChatterboxInvitation(
  784. new UUID("00000000-68f9-1111-024e-222222111123"),
  785. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  786. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  787. eq.ChatterBoxSessionAgentListUpdates(
  788. new UUID("00000000-68f9-1111-024e-222222111123"),
  789. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  790. }
  791. Console.WriteLine("SendInstantMessage: " + msg);
  792. }
  793. else
  794. OutPacket(msg, ThrottleOutPacketType.Task);
  795. }
  796. }
  797. public void SendGenericMessage(string method, List<string> message)
  798. {
  799. GenericMessagePacket gmp = new GenericMessagePacket();
  800. gmp.MethodData.Method = Util.StringToBytes256(method);
  801. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  802. int i = 0;
  803. foreach (string val in message)
  804. {
  805. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  806. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  807. }
  808. OutPacket(gmp, ThrottleOutPacketType.Task);
  809. }
  810. public void SendGenericMessage(string method, List<byte[]> message)
  811. {
  812. GenericMessagePacket gmp = new GenericMessagePacket();
  813. gmp.MethodData.Method = Util.StringToBytes256(method);
  814. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  815. int i = 0;
  816. foreach (byte[] val in message)
  817. {
  818. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  819. gmp.ParamList[i++].Parameter = val;
  820. }
  821. OutPacket(gmp, ThrottleOutPacketType.Task);
  822. }
  823. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  824. {
  825. int i = 0;
  826. foreach (GroupActiveProposals Proposal in Proposals)
  827. {
  828. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  829. GAPIRP.AgentData.AgentID = AgentId;
  830. GAPIRP.AgentData.GroupID = groupID;
  831. GAPIRP.TransactionData.TransactionID = transactionID;
  832. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  833. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  834. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  835. ProposalData.VoteCast = Utils.StringToBytes("false");
  836. ProposalData.VoteID = new UUID(Proposal.VoteID);
  837. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  838. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  839. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  840. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  841. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  842. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  843. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  844. ProposalData.AlreadyVoted = false;
  845. GAPIRP.ProposalData[i] = ProposalData;
  846. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  847. i++;
  848. }
  849. if (Proposals.Length == 0)
  850. {
  851. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  852. GAPIRP.AgentData.AgentID = AgentId;
  853. GAPIRP.AgentData.GroupID = groupID;
  854. GAPIRP.TransactionData.TransactionID = transactionID;
  855. GAPIRP.TransactionData.TotalNumItems = 1;
  856. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  857. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  858. ProposalData.VoteCast = Utils.StringToBytes("false");
  859. ProposalData.VoteID = UUID.Zero;
  860. ProposalData.VoteInitiator = UUID.Zero;
  861. ProposalData.Majority = 0;
  862. ProposalData.Quorum = 0;
  863. ProposalData.TerseDateID = Utils.StringToBytes("");
  864. ProposalData.StartDateTime = Utils.StringToBytes("");
  865. ProposalData.EndDateTime = Utils.StringToBytes("");
  866. ProposalData.ProposalText = Utils.StringToBytes("");
  867. ProposalData.AlreadyVoted = false;
  868. GAPIRP.ProposalData[0] = ProposalData;
  869. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  870. }
  871. }
  872. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  873. {
  874. int i = 0;
  875. foreach (GroupVoteHistory Vote in Votes)
  876. {
  877. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  878. GVHIRP.AgentData.AgentID = AgentId;
  879. GVHIRP.AgentData.GroupID = groupID;
  880. GVHIRP.TransactionData.TransactionID = transactionID;
  881. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  882. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  883. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  884. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  885. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  886. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  887. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  888. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  889. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  890. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  891. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  892. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  893. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  894. VoteItem.CandidateID = UUID.Zero;
  895. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  896. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  897. GVHIRP.VoteItem[i] = VoteItem;
  898. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  899. i++;
  900. }
  901. if (Votes.Length == 0)
  902. {
  903. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  904. GVHIRP.AgentData.AgentID = AgentId;
  905. GVHIRP.AgentData.GroupID = groupID;
  906. GVHIRP.TransactionData.TransactionID = transactionID;
  907. GVHIRP.TransactionData.TotalNumItems = 0;
  908. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  909. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  910. GVHIRP.HistoryItemData.Majority = 0;
  911. GVHIRP.HistoryItemData.Quorum = 0;
  912. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  913. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  914. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  915. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  916. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  917. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  918. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  919. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  920. VoteItem.CandidateID = UUID.Zero;
  921. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  922. VoteItem.VoteCast = Utils.StringToBytes("No");
  923. GVHIRP.VoteItem[0] = VoteItem;
  924. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  925. }
  926. }
  927. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  928. {
  929. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  930. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  931. GADRP.AgentData.AgentID = sender.AgentId;
  932. GADRP.AgentData.GroupID = groupID;
  933. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  934. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  935. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  936. GADRP.MoneyData.CurrentInterval = 0;
  937. GADRP.MoneyData.IntervalDays = 7;
  938. GADRP.MoneyData.RequestID = transactionID;
  939. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  940. History.Amount = amt;
  941. History.Description = Utils.StringToBytes("");
  942. GADRP.HistoryData[0] = History;
  943. OutPacket(GADRP, ThrottleOutPacketType.Task);
  944. }
  945. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  946. {
  947. GroupAccountSummaryReplyPacket GASRP =
  948. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  949. PacketType.GroupAccountSummaryReply);
  950. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  951. GASRP.AgentData.AgentID = sender.AgentId;
  952. GASRP.AgentData.GroupID = groupID;
  953. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  954. GASRP.MoneyData.Balance = (int)moneyAmt;
  955. GASRP.MoneyData.TotalCredits = totalTier;
  956. GASRP.MoneyData.TotalDebits = usedTier;
  957. GASRP.MoneyData.StartDate = new byte[1];
  958. GASRP.MoneyData.CurrentInterval = 1;
  959. GASRP.MoneyData.GroupTaxCurrent = 0;
  960. GASRP.MoneyData.GroupTaxEstimate = 0;
  961. GASRP.MoneyData.IntervalDays = 0;
  962. GASRP.MoneyData.LandTaxCurrent = 0;
  963. GASRP.MoneyData.LandTaxEstimate = 0;
  964. GASRP.MoneyData.LastTaxDate = new byte[1];
  965. GASRP.MoneyData.LightTaxCurrent = 0;
  966. GASRP.MoneyData.TaxDate = new byte[1];
  967. GASRP.MoneyData.RequestID = sender.AgentId;
  968. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  969. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  970. GASRP.MoneyData.ObjectTaxEstimate = 0;
  971. GASRP.MoneyData.NonExemptMembers = 0;
  972. GASRP.MoneyData.ObjectTaxCurrent = 0;
  973. GASRP.MoneyData.LightTaxEstimate = 0;
  974. OutPacket(GASRP, ThrottleOutPacketType.Task);
  975. }
  976. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  977. {
  978. GroupAccountTransactionsReplyPacket GATRP =
  979. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  980. PacketType.GroupAccountTransactionsReply);
  981. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  982. GATRP.AgentData.AgentID = sender.AgentId;
  983. GATRP.AgentData.GroupID = groupID;
  984. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  985. GATRP.MoneyData.CurrentInterval = 0;
  986. GATRP.MoneyData.IntervalDays = 7;
  987. GATRP.MoneyData.RequestID = transactionID;
  988. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  989. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  990. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  991. History.Amount = 0;
  992. History.Item = Utils.StringToBytes("");
  993. History.Time = Utils.StringToBytes("");
  994. History.Type = 0;
  995. History.User = Utils.StringToBytes("");
  996. GATRP.HistoryData[0] = History;
  997. OutPacket(GATRP, ThrottleOutPacketType.Task);
  998. }
  999. /// <summary>
  1000. /// Send the region heightmap to the client
  1001. /// </summary>
  1002. /// <param name="map">heightmap</param>
  1003. public virtual void SendLayerData(float[] map)
  1004. {
  1005. Util.FireAndForget(DoSendLayerData, map);
  1006. }
  1007. /// <summary>
  1008. /// Send terrain layer information to the client.
  1009. /// </summary>
  1010. /// <param name="o"></param>
  1011. private void DoSendLayerData(object o)
  1012. {
  1013. float[] map = LLHeightFieldMoronize((float[])o);
  1014. try
  1015. {
  1016. //for (int y = 0; y < 16; y++)
  1017. //{
  1018. // for (int x = 0; x < 16; x++)
  1019. // {
  1020. // SendLayerData(x, y, map);
  1021. // }
  1022. //}
  1023. // Send LayerData in a spiral pattern. Fun!
  1024. SendLayerTopRight(map, 0, 0, 15, 15);
  1025. }
  1026. catch (Exception e)
  1027. {
  1028. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1029. }
  1030. }
  1031. private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
  1032. {
  1033. // Row
  1034. for (int i = x1; i <= x2; i++)
  1035. SendLayerData(i, y1, map);
  1036. // Column
  1037. for (int j = y1 + 1; j <= y2; j++)
  1038. SendLayerData(x2, j, map);
  1039. if (x2 - x1 > 0)
  1040. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1041. }
  1042. void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
  1043. {
  1044. // Row in reverse
  1045. for (int i = x2; i >= x1; i--)
  1046. SendLayerData(i, y2, map);
  1047. // Column in reverse
  1048. for (int j = y2 - 1; j >= y1; j--)
  1049. SendLayerData(x1, j, map);
  1050. if (x2 - x1 > 0)
  1051. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1052. }
  1053. /// <summary>
  1054. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1055. /// </summary>
  1056. /// <param name="map">heightmap</param>
  1057. /// <param name="px">X coordinate for patches 0..12</param>
  1058. /// <param name="py">Y coordinate for patches 0..15</param>
  1059. // private void SendLayerPacket(float[] map, int y, int x)
  1060. // {
  1061. // int[] patches = new int[4];
  1062. // patches[0] = x + 0 + y * 16;
  1063. // patches[1] = x + 1 + y * 16;
  1064. // patches[2] = x + 2 + y * 16;
  1065. // patches[3] = x + 3 + y * 16;
  1066. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1067. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1068. // }
  1069. /// <summary>
  1070. /// Sends a specified patch to a client
  1071. /// </summary>
  1072. /// <param name="px">Patch coordinate (x) 0..15</param>
  1073. /// <param name="py">Patch coordinate (y) 0..15</param>
  1074. /// <param name="map">heightmap</param>
  1075. public void SendLayerData(int px, int py, float[] map)
  1076. {
  1077. try
  1078. {
  1079. int[] patches = new int[] { py * 16 + px };
  1080. float[] heightmap = (map.Length == 65536) ?
  1081. map :
  1082. LLHeightFieldMoronize(map);
  1083. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1084. layerpack.Header.Reliable = true;
  1085. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1086. }
  1087. catch (Exception e)
  1088. {
  1089. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1090. }
  1091. }
  1092. /// <summary>
  1093. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1094. /// </summary>
  1095. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1096. /// <returns>float array in the base 256</returns>
  1097. internal float[] LLHeightFieldMoronize(float[] map)
  1098. {
  1099. if (map.Length == 65536)
  1100. return map;
  1101. else
  1102. {
  1103. float[] returnmap = new float[65536];
  1104. if (map.Length < 65535)
  1105. {
  1106. // rebase the vector stride to 256
  1107. for (int i = 0; i < Constants.RegionSize; i++)
  1108. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1109. }
  1110. else
  1111. {
  1112. for (int i = 0; i < 256; i++)
  1113. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1114. }
  1115. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1116. return returnmap;
  1117. }
  1118. }
  1119. /// <summary>
  1120. /// Send the wind matrix to the client
  1121. /// </summary>
  1122. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1123. public virtual void SendWindData(Vector2[] windSpeeds)
  1124. {
  1125. Util.FireAndForget(DoSendWindData, windSpeeds);
  1126. }
  1127. /// <summary>
  1128. /// Send the cloud matrix to the client
  1129. /// </summary>
  1130. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1131. public virtual void SendCloudData(float[] cloudDensity)
  1132. {
  1133. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1134. }
  1135. /// <summary>
  1136. /// Send wind layer information to the client.
  1137. /// </summary>
  1138. /// <param name="o"></param>
  1139. private void DoSendWindData(object o)
  1140. {
  1141. Vector2[] windSpeeds = (Vector2[])o;
  1142. TerrainPatch[] patches = new TerrainPatch[2];
  1143. patches[0] = new TerrainPatch();
  1144. patches[0].Data = new float[16 * 16];
  1145. patches[1] = new TerrainPatch();
  1146. patches[1].Data = new float[16 * 16];
  1147. for (int y = 0; y < 16; y++)
  1148. {
  1149. for (int x = 0; x < 16; x++)
  1150. {
  1151. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1152. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1153. }
  1154. }
  1155. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1156. layerpack.Header.Zerocoded = true;
  1157. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1158. }
  1159. /// <summary>
  1160. /// Send cloud layer information to the client.
  1161. /// </summary>
  1162. /// <param name="o"></param>
  1163. private void DoSendCloudData(object o)
  1164. {
  1165. float[] cloudCover = (float[])o;
  1166. TerrainPatch[] patches = new TerrainPatch[1];
  1167. patches[0] = new TerrainPatch();
  1168. patches[0].Data = new float[16 * 16];
  1169. for (int y = 0; y < 16; y++)
  1170. {
  1171. for (int x = 0; x < 16; x++)
  1172. {
  1173. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1174. }
  1175. }
  1176. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1177. layerpack.Header.Zerocoded = true;
  1178. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1179. }
  1180. /// <summary>
  1181. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1182. /// </summary>
  1183. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1184. {
  1185. IPAddress neighbourIP = neighbourEndPoint.Address;
  1186. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1187. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1188. // TODO: don't create new blocks if recycling an old packet
  1189. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1190. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1191. byte[] byteIP = neighbourIP.GetAddressBytes();
  1192. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1193. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1194. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1195. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1196. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1197. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1198. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1199. }
  1200. public AgentCircuitData RequestClientInfo()
  1201. {
  1202. AgentCircuitData agentData = new AgentCircuitData();
  1203. agentData.AgentID = AgentId;
  1204. agentData.SessionID = m_sessionId;
  1205. agentData.SecureSessionID = SecureSessionId;
  1206. agentData.circuitcode = m_circuitCode;
  1207. agentData.child = false;
  1208. agentData.firstname = m_firstName;
  1209. agentData.lastname = m_lastName;
  1210. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1211. if (capsModule == null) // can happen when shutting down.
  1212. return agentData;
  1213. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1214. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1215. return agentData;
  1216. }
  1217. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1218. string capsURL)
  1219. {
  1220. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1221. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1222. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1223. // TODO: don't create new blocks if recycling an old packet
  1224. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1225. newSimPack.AgentData.AgentID = AgentId;
  1226. newSimPack.AgentData.SessionID = m_sessionId;
  1227. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1228. newSimPack.Info.Position = pos;
  1229. newSimPack.Info.LookAt = look;
  1230. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1231. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1232. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1233. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1234. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1235. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1236. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1237. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1238. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1239. // Hack to get this out immediately and skip throttles
  1240. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1241. }
  1242. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1243. {
  1244. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1245. // TODO: don't create new blocks if recycling an old packet
  1246. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1247. mapReply.AgentData.AgentID = AgentId;
  1248. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1249. mapReply.AgentData.Flags = flag;
  1250. for (int i = 0; i < mapBlocks2.Length; i++)
  1251. {
  1252. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1253. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1254. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1255. mapReply.Data[i].X = mapBlocks2[i].X;
  1256. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1257. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1258. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1259. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1260. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1261. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1262. }
  1263. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1264. }
  1265. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1266. {
  1267. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1268. int maxsend = 10;
  1269. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1270. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1271. for (int i = 0; i < mapBlocks2.Length; i++)
  1272. {
  1273. sendingBlocks.Add(mapBlocks2[i]);
  1274. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1275. {
  1276. SendMapBlockSplit(sendingBlocks, flag);
  1277. sendingBlocks = new List<MapBlockData>();
  1278. }
  1279. }
  1280. }
  1281. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1282. {
  1283. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1284. tpLocal.Info.AgentID = AgentId;
  1285. tpLocal.Info.TeleportFlags = flags;
  1286. tpLocal.Info.LocationID = 2;
  1287. tpLocal.Info.LookAt = lookAt;
  1288. tpLocal.Info.Position = position;
  1289. // Hack to get this out immediately and skip throttles
  1290. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1291. }
  1292. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1293. uint flags, string capsURL)
  1294. {
  1295. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1296. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1297. teleport.Info.AgentID = AgentId;
  1298. teleport.Info.RegionHandle = regionHandle;
  1299. teleport.Info.SimAccess = simAccess;
  1300. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1301. IPAddress oIP = newRegionEndPoint.Address;
  1302. byte[] byteIP = oIP.GetAddressBytes();
  1303. uint ip = (uint)byteIP[3] << 24;
  1304. ip += (uint)byteIP[2] << 16;
  1305. ip += (uint)byteIP[1] << 8;
  1306. ip += (uint)byteIP[0];
  1307. teleport.Info.SimIP = ip;
  1308. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1309. teleport.Info.LocationID = 4;
  1310. teleport.Info.TeleportFlags = 1 << 4;
  1311. // Hack to get this out immediately and skip throttles.
  1312. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1313. }
  1314. /// <summary>
  1315. /// Inform the client that a teleport attempt has failed
  1316. /// </summary>
  1317. public void SendTeleportFailed(string reason)
  1318. {
  1319. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1320. tpFailed.Info.AgentID = AgentId;
  1321. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1322. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1323. // Hack to get this out immediately and skip throttles
  1324. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1325. }
  1326. /// <summary>
  1327. ///
  1328. /// </summary>
  1329. public void SendTeleportStart(uint flags)
  1330. {
  1331. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1332. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1333. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1334. // Hack to get this out immediately and skip throttles
  1335. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1336. }
  1337. public void SendTeleportProgress(uint flags, string message)
  1338. {
  1339. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1340. tpProgress.AgentData.AgentID = this.AgentId;
  1341. tpProgress.Info.TeleportFlags = flags;
  1342. tpProgress.Info.Message = Util.StringToBytes256(message);
  1343. // Hack to get this out immediately and skip throttles
  1344. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1345. }
  1346. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
  1347. {
  1348. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1349. money.MoneyData.AgentID = AgentId;
  1350. money.MoneyData.TransactionID = transaction;
  1351. money.MoneyData.TransactionSuccess = success;
  1352. money.MoneyData.Description = description;
  1353. money.MoneyData.MoneyBalance = balance;
  1354. money.TransactionInfo.ItemDescription = Util.StringToBytes256("NONE");
  1355. OutPacket(money, ThrottleOutPacketType.Task);
  1356. }
  1357. public void SendPayPrice(UUID objectID, int[] payPrice)
  1358. {
  1359. if (payPrice[0] == 0 &&
  1360. payPrice[1] == 0 &&
  1361. payPrice[2] == 0 &&
  1362. payPrice[3] == 0 &&
  1363. payPrice[4] == 0)
  1364. return;
  1365. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1366. payPriceReply.ObjectData.ObjectID = objectID;
  1367. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1368. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1369. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1370. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1371. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1372. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1373. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1374. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1375. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1376. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1377. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1378. }
  1379. public void SendStartPingCheck(byte seq)
  1380. {
  1381. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1382. pc.Header.Reliable = false;
  1383. pc.PingID.PingID = seq;
  1384. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1385. pc.PingID.OldestUnacked = 0;
  1386. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1387. }
  1388. public void SendKillObject(ulong regionHandle, List<uint> localIDs)
  1389. {
  1390. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1391. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1392. // TODO: don't create new blocks if recycling an old packet
  1393. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1394. for (int i = 0 ; i < localIDs.Count ; i++ )
  1395. {
  1396. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1397. kill.ObjectData[i].ID = localIDs[i];
  1398. }
  1399. kill.Header.Reliable = true;
  1400. kill.Header.Zerocoded = true;
  1401. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1402. {
  1403. OutPacket(kill, ThrottleOutPacketType.State);
  1404. }
  1405. else
  1406. {
  1407. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1408. // condition where a kill can be processed before an out-of-date update for the same object.
  1409. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1410. lock (m_killRecord)
  1411. {
  1412. foreach (uint localID in localIDs)
  1413. m_killRecord.Add(localID);
  1414. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1415. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1416. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1417. // scene objects in a viewer until that viewer is relogged in.
  1418. OutPacket(kill, ThrottleOutPacketType.Task);
  1419. }
  1420. }
  1421. }
  1422. /// <summary>
  1423. /// Send information about the items contained in a folder to the client.
  1424. /// </summary>
  1425. /// <remarks>
  1426. /// XXX This method needs some refactoring loving
  1427. /// </remarks>
  1428. /// <param name="ownerID">The owner of the folder</param>
  1429. /// <param name="folderID">The id of the folder</param>
  1430. /// <param name="items">The items contained in the folder identified by folderID</param>
  1431. /// <param name="folders"></param>
  1432. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1433. /// <param name="fetchItems">Do we need to send item information?</param>
  1434. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1435. List<InventoryFolderBase> folders, int version,
  1436. bool fetchFolders, bool fetchItems)
  1437. {
  1438. // An inventory descendents packet consists of a single agent section and an inventory details
  1439. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1440. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1441. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1442. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1443. //
  1444. // http://opensimulator.org/mantis/view.php?id=226
  1445. //
  1446. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1447. // 6 to 7 items at a time, so let's stick with 6
  1448. int MAX_ITEMS_PER_PACKET = 5;
  1449. int MAX_FOLDERS_PER_PACKET = 6;
  1450. int totalItems = fetchItems ? items.Count : 0;
  1451. int totalFolders = fetchFolders ? folders.Count : 0;
  1452. int itemsSent = 0;
  1453. int foldersSent = 0;
  1454. int foldersToSend = 0;
  1455. int itemsToSend = 0;
  1456. InventoryDescendentsPacket currentPacket = null;
  1457. // Handle empty folders
  1458. //
  1459. if (totalItems == 0 && totalFolders == 0)
  1460. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1461. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1462. //
  1463. while (itemsSent < totalItems || foldersSent < totalFolders)
  1464. {
  1465. if (currentPacket == null) // Start a new packet
  1466. {
  1467. foldersToSend = totalFolders - foldersSent;
  1468. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1469. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1470. if (foldersToSend == 0)
  1471. {
  1472. itemsToSend = totalItems - itemsSent;
  1473. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1474. itemsToSend = MAX_ITEMS_PER_PACKET;
  1475. }
  1476. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1477. }
  1478. if (foldersToSend-- > 0)
  1479. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1480. else if (itemsToSend-- > 0)
  1481. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1482. else
  1483. {
  1484. // m_log.DebugFormat(
  1485. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1486. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1487. currentPacket = null;
  1488. }
  1489. }
  1490. if (currentPacket != null)
  1491. {
  1492. // m_log.DebugFormat(
  1493. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1494. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1495. }
  1496. }
  1497. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1498. {
  1499. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1500. newBlock.FolderID = folder.ID;
  1501. newBlock.Name = Util.StringToBytes256(folder.Name);
  1502. newBlock.ParentID = folder.ParentID;
  1503. newBlock.Type = (sbyte)folder.Type;
  1504. return newBlock;
  1505. }
  1506. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1507. {
  1508. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1509. newBlock.ItemID = item.ID;
  1510. newBlock.AssetID = item.AssetID;
  1511. newBlock.CreatorID = item.CreatorIdAsUuid;
  1512. newBlock.BaseMask = item.BasePermissions;
  1513. newBlock.Description = Util.StringToBytes256(item.Description);
  1514. newBlock.EveryoneMask = item.EveryOnePermissions;
  1515. newBlock.OwnerMask = item.CurrentPermissions;
  1516. newBlock.FolderID = item.Folder;
  1517. newBlock.InvType = (sbyte)item.InvType;
  1518. newBlock.Name = Util.StringToBytes256(item.Name);
  1519. newBlock.NextOwnerMask = item.NextPermissions;
  1520. newBlock.OwnerID = item.Owner;
  1521. newBlock.Type = (sbyte)item.AssetType;
  1522. newBlock.GroupID = item.GroupID;
  1523. newBlock.GroupOwned = item.GroupOwned;
  1524. newBlock.GroupMask = item.GroupPermissions;
  1525. newBlock.CreationDate = item.CreationDate;
  1526. newBlock.SalePrice = item.SalePrice;
  1527. newBlock.SaleType = item.SaleType;
  1528. newBlock.Flags = item.Flags;
  1529. newBlock.CRC =
  1530. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1531. newBlock.InvType, newBlock.Type,
  1532. newBlock.AssetID, newBlock.GroupID,
  1533. newBlock.SalePrice,
  1534. newBlock.OwnerID, newBlock.CreatorID,
  1535. newBlock.ItemID, newBlock.FolderID,
  1536. newBlock.EveryoneMask,
  1537. newBlock.Flags, newBlock.OwnerMask,
  1538. newBlock.GroupMask, newBlock.NextOwnerMask);
  1539. return newBlock;
  1540. }
  1541. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1542. {
  1543. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1544. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1545. packet.FolderData[0].FolderID = UUID.Zero;
  1546. packet.FolderData[0].ParentID = UUID.Zero;
  1547. packet.FolderData[0].Type = -1;
  1548. packet.FolderData[0].Name = new byte[0];
  1549. }
  1550. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1551. {
  1552. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1553. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1554. packet.ItemData[0].ItemID = UUID.Zero;
  1555. packet.ItemData[0].AssetID = UUID.Zero;
  1556. packet.ItemData[0].CreatorID = UUID.Zero;
  1557. packet.ItemData[0].BaseMask = 0;
  1558. packet.ItemData[0].Description = new byte[0];
  1559. packet.ItemData[0].EveryoneMask = 0;
  1560. packet.ItemData[0].OwnerMask = 0;
  1561. packet.ItemData[0].FolderID = UUID.Zero;
  1562. packet.ItemData[0].InvType = (sbyte)0;
  1563. packet.ItemData[0].Name = new byte[0];
  1564. packet.ItemData[0].NextOwnerMask = 0;
  1565. packet.ItemData[0].OwnerID = UUID.Zero;
  1566. packet.ItemData[0].Type = -1;
  1567. packet.ItemData[0].GroupID = UUID.Zero;
  1568. packet.ItemData[0].GroupOwned = false;
  1569. packet.ItemData[0].GroupMask = 0;
  1570. packet.ItemData[0].CreationDate = 0;
  1571. packet.ItemData[0].SalePrice = 0;
  1572. packet.ItemData[0].SaleType = 0;
  1573. packet.ItemData[0].Flags = 0;
  1574. // No need to add CRC
  1575. }
  1576. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1577. {
  1578. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1579. descend.Header.Zerocoded = true;
  1580. descend.AgentData.AgentID = AgentId;
  1581. descend.AgentData.OwnerID = ownerID;
  1582. descend.AgentData.FolderID = folderID;
  1583. descend.AgentData.Version = version;
  1584. descend.AgentData.Descendents = descendents;
  1585. if (folders > 0)
  1586. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1587. else
  1588. AddNullFolderBlockToDecendentsPacket(ref descend);
  1589. if (items > 0)
  1590. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1591. else
  1592. AddNullItemBlockToDescendentsPacket(ref descend);
  1593. return descend;
  1594. }
  1595. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1596. {
  1597. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1598. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1599. // TODO: don't create new blocks if recycling an old packet
  1600. inventoryReply.AgentData.AgentID = AgentId;
  1601. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1602. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1603. inventoryReply.InventoryData[0].ItemID = item.ID;
  1604. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1605. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1606. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1607. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1608. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1609. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1610. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1611. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1612. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1613. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1614. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1615. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1616. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1617. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1618. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1619. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1620. inventoryReply.InventoryData[0].Flags = item.Flags;
  1621. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1622. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1623. inventoryReply.InventoryData[0].CRC =
  1624. Helpers.InventoryCRC(
  1625. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1626. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1627. inventoryReply.InventoryData[0].GroupID, 100,
  1628. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1629. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1630. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1631. FULL_MASK_PERMISSIONS);
  1632. inventoryReply.Header.Zerocoded = true;
  1633. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1634. }
  1635. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1636. {
  1637. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1638. UUID transactionId = UUID.Random();
  1639. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1640. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1641. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1642. if (folderDataBlocks.Count > 0)
  1643. {
  1644. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1645. // Send these now
  1646. BulkUpdateInventoryPacket bulkUpdate
  1647. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1648. bulkUpdate.Header.Zerocoded = true;
  1649. bulkUpdate.AgentData.AgentID = AgentId;
  1650. bulkUpdate.AgentData.TransactionID = transactionId;
  1651. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1652. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1653. bulkUpdate.ItemData = foo.ToArray();
  1654. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1655. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1656. }
  1657. }
  1658. /// <summary>
  1659. /// Recursively construct bulk update packets to send folders and items
  1660. /// </summary>
  1661. /// <param name="folder"></param>
  1662. /// <param name="folderDataBlocks"></param>
  1663. /// <param name="transactionId"></param>
  1664. private void SendBulkUpdateInventoryFolderRecursive(
  1665. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1666. UUID transactionId)
  1667. {
  1668. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1669. const int MAX_ITEMS_PER_PACKET = 5;
  1670. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1671. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1672. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1673. // being used on the Linden grid at 20081203).
  1674. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1675. List<InventoryItemBase> items = contents.Items;
  1676. while (items.Count > 0)
  1677. {
  1678. BulkUpdateInventoryPacket bulkUpdate
  1679. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1680. bulkUpdate.Header.Zerocoded = true;
  1681. bulkUpdate.AgentData.AgentID = AgentId;
  1682. bulkUpdate.AgentData.TransactionID = transactionId;
  1683. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1684. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1685. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1686. for (int i = 0; i < itemsToSend; i++)
  1687. {
  1688. // Remove from the end of the list so that we don't incur a performance penalty
  1689. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1690. items.RemoveAt(items.Count - 1);
  1691. }
  1692. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1693. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1694. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1695. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1696. // items belong.
  1697. if (items.Count > 0)
  1698. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1699. }
  1700. List<InventoryFolderBase> subFolders = contents.Folders;
  1701. foreach (InventoryFolderBase subFolder in subFolders)
  1702. {
  1703. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1704. }
  1705. }
  1706. /// <summary>
  1707. /// Generate a bulk update inventory data block for the given folder
  1708. /// </summary>
  1709. /// <param name="folder"></param>
  1710. /// <returns></returns>
  1711. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1712. {
  1713. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1714. folderBlock.FolderID = folder.ID;
  1715. folderBlock.ParentID = folder.ParentID;
  1716. //folderBlock.Type = -1;
  1717. folderBlock.Type = (sbyte)folder.Type;
  1718. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1719. return folderBlock;
  1720. }
  1721. /// <summary>
  1722. /// Generate a bulk update inventory data block for the given item
  1723. /// </summary>
  1724. /// <param name="item"></param>
  1725. /// <returns></returns>
  1726. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1727. {
  1728. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1729. itemBlock.ItemID = item.ID;
  1730. itemBlock.AssetID = item.AssetID;
  1731. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1732. itemBlock.BaseMask = item.BasePermissions;
  1733. itemBlock.Description = Util.StringToBytes256(item.Description);
  1734. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1735. itemBlock.FolderID = item.Folder;
  1736. itemBlock.InvType = (sbyte)item.InvType;
  1737. itemBlock.Name = Util.StringToBytes256(item.Name);
  1738. itemBlock.NextOwnerMask = item.NextPermissions;
  1739. itemBlock.OwnerID = item.Owner;
  1740. itemBlock.OwnerMask = item.CurrentPermissions;
  1741. itemBlock.Type = (sbyte)item.AssetType;
  1742. itemBlock.GroupID = item.GroupID;
  1743. itemBlock.GroupOwned = item.GroupOwned;
  1744. itemBlock.GroupMask = item.GroupPermissions;
  1745. itemBlock.Flags = item.Flags;
  1746. itemBlock.SalePrice = item.SalePrice;
  1747. itemBlock.SaleType = item.SaleType;
  1748. itemBlock.CreationDate = item.CreationDate;
  1749. itemBlock.CRC =
  1750. Helpers.InventoryCRC(
  1751. 1000, 0, itemBlock.InvType,
  1752. itemBlock.Type, itemBlock.AssetID,
  1753. itemBlock.GroupID, 100,
  1754. itemBlock.OwnerID, itemBlock.CreatorID,
  1755. itemBlock.ItemID, itemBlock.FolderID,
  1756. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1757. (uint)PermissionMask.All);
  1758. return itemBlock;
  1759. }
  1760. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1761. {
  1762. if (node is InventoryItemBase)
  1763. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1764. else if (node is InventoryFolderBase)
  1765. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1766. else if (node != null)
  1767. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1768. else
  1769. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1770. }
  1771. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1772. {
  1773. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1774. BulkUpdateInventoryPacket bulkUpdate
  1775. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1776. bulkUpdate.AgentData.AgentID = AgentId;
  1777. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1778. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1779. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1780. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1781. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1782. bulkUpdate.FolderData[0].Type = -1;
  1783. bulkUpdate.FolderData[0].Name = new byte[0];
  1784. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1785. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1786. bulkUpdate.ItemData[0].ItemID = item.ID;
  1787. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1788. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1789. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1790. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1791. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1792. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1793. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1794. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1795. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1796. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1797. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1798. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1799. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1800. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1801. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1802. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1803. bulkUpdate.ItemData[0].Flags = item.Flags;
  1804. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1805. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1806. bulkUpdate.ItemData[0].CRC =
  1807. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1808. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1809. bulkUpdate.ItemData[0].GroupID, 100,
  1810. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1811. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1812. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1813. FULL_MASK_PERMISSIONS);
  1814. bulkUpdate.Header.Zerocoded = true;
  1815. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1816. }
  1817. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1818. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1819. {
  1820. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1821. UpdateCreateInventoryItemPacket InventoryReply
  1822. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1823. PacketType.UpdateCreateInventoryItem);
  1824. // TODO: don't create new blocks if recycling an old packet
  1825. InventoryReply.AgentData.AgentID = AgentId;
  1826. InventoryReply.AgentData.SimApproved = true;
  1827. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1828. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1829. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1830. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1831. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1832. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1833. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1834. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1835. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1836. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1837. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1838. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1839. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1840. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1841. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1842. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1843. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1844. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1845. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1846. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1847. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1848. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1849. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1850. InventoryReply.InventoryData[0].CRC =
  1851. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1852. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1853. InventoryReply.InventoryData[0].GroupID, 100,
  1854. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1855. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1856. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1857. FULL_MASK_PERMISSIONS);
  1858. InventoryReply.Header.Zerocoded = true;
  1859. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1860. }
  1861. public void SendRemoveInventoryItem(UUID itemID)
  1862. {
  1863. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1864. // TODO: don't create new blocks if recycling an old packet
  1865. remove.AgentData.AgentID = AgentId;
  1866. remove.AgentData.SessionID = m_sessionId;
  1867. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1868. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1869. remove.InventoryData[0].ItemID = itemID;
  1870. remove.Header.Zerocoded = true;
  1871. OutPacket(remove, ThrottleOutPacketType.Asset);
  1872. }
  1873. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1874. {
  1875. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1876. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1877. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1878. ddata.Controls = (uint)controls;
  1879. ddata.PassToAgent = passToAgent;
  1880. ddata.TakeControls = TakeControls;
  1881. data[0] = ddata;
  1882. scriptcontrol.Data = data;
  1883. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1884. }
  1885. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1886. {
  1887. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1888. replytask.InventoryData.TaskID = taskID;
  1889. replytask.InventoryData.Serial = serial;
  1890. replytask.InventoryData.Filename = fileName;
  1891. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1892. }
  1893. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1894. {
  1895. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1896. sendXfer.XferID.ID = xferID;
  1897. sendXfer.XferID.Packet = packet;
  1898. sendXfer.DataPacket.Data = data;
  1899. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1900. }
  1901. public void SendAbortXferPacket(ulong xferID)
  1902. {
  1903. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1904. xferItem.XferID.ID = xferID;
  1905. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1906. }
  1907. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1908. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1909. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1910. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1911. {
  1912. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1913. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1914. economyData.Info.ObjectCapacity = ObjectCapacity;
  1915. economyData.Info.ObjectCount = ObjectCount;
  1916. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1917. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1918. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1919. economyData.Info.PriceObjectRent = PriceObjectRent;
  1920. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1921. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1922. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1923. economyData.Info.PriceParcelRent = PriceParcelRent;
  1924. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1925. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1926. economyData.Info.PriceRentLight = PriceRentLight;
  1927. economyData.Info.PriceUpload = PriceUpload;
  1928. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1929. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1930. economyData.Header.Reliable = true;
  1931. OutPacket(economyData, ThrottleOutPacketType.Task);
  1932. }
  1933. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1934. {
  1935. //construct the AvatarPickerReply packet.
  1936. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1937. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1938. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1939. //int i = 0;
  1940. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1941. foreach (AvatarPickerReplyDataArgs arg in Data)
  1942. {
  1943. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1944. db.AvatarID = arg.AvatarID;
  1945. db.FirstName = arg.FirstName;
  1946. db.LastName = arg.LastName;
  1947. data_block.Add(db);
  1948. }
  1949. replyPacket.Data = data_block.ToArray();
  1950. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  1951. }
  1952. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  1953. {
  1954. m_activeGroupID = activegroupid;
  1955. m_activeGroupName = groupname;
  1956. m_activeGroupPowers = grouppowers;
  1957. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  1958. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  1959. sendAgentDataUpdate.AgentData.AgentID = agentid;
  1960. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  1961. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  1962. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  1963. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  1964. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  1965. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  1966. }
  1967. /// <summary>
  1968. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  1969. /// blue information box in the bottom right hand corner.
  1970. /// </summary>
  1971. /// <param name="message"></param>
  1972. public void SendAlertMessage(string message)
  1973. {
  1974. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  1975. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  1976. alertPack.AlertData.Message = Util.StringToBytes256(message);
  1977. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  1978. OutPacket(alertPack, ThrottleOutPacketType.Task);
  1979. }
  1980. /// <summary>
  1981. /// Send an agent alert message to the client.
  1982. /// </summary>
  1983. /// <param name="message"></param>
  1984. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  1985. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  1986. /// the AlertMessage packet).</param>
  1987. public void SendAgentAlertMessage(string message, bool modal)
  1988. {
  1989. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  1990. }
  1991. /// <summary>
  1992. /// Construct an agent alert packet
  1993. /// </summary>
  1994. /// <param name="message"></param>
  1995. /// <param name="modal"></param>
  1996. /// <returns></returns>
  1997. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  1998. {
  1999. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2000. alertPack.AgentData.AgentID = AgentId;
  2001. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2002. alertPack.AlertData.Modal = modal;
  2003. return alertPack;
  2004. }
  2005. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2006. string url)
  2007. {
  2008. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2009. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2010. loadURL.Data.ObjectID = objectID;
  2011. loadURL.Data.OwnerID = ownerID;
  2012. loadURL.Data.OwnerIsGroup = groupOwned;
  2013. loadURL.Data.Message = Util.StringToBytes256(message);
  2014. loadURL.Data.URL = Util.StringToBytes256(url);
  2015. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2016. }
  2017. public void SendDialog(
  2018. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2019. UUID textureID, int ch, string[] buttonlabels)
  2020. {
  2021. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2022. dialog.Data.ObjectID = objectID;
  2023. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2024. // this is the username of the *owner*
  2025. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2026. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2027. dialog.Data.Message = Util.StringToBytes1024(msg);
  2028. dialog.Data.ImageID = textureID;
  2029. dialog.Data.ChatChannel = ch;
  2030. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2031. for (int i = 0; i < buttonlabels.Length; i++)
  2032. {
  2033. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2034. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2035. }
  2036. dialog.Buttons = buttons;
  2037. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2038. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2039. dialog.OwnerData[0].OwnerID = ownerID;
  2040. OutPacket(dialog, ThrottleOutPacketType.Task);
  2041. }
  2042. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2043. {
  2044. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2045. // TODO: don't create new blocks if recycling an old packet
  2046. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2047. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2048. preSound.DataBlock[0].ObjectID = objectID;
  2049. preSound.DataBlock[0].OwnerID = ownerID;
  2050. preSound.DataBlock[0].SoundID = soundID;
  2051. preSound.Header.Zerocoded = true;
  2052. OutPacket(preSound, ThrottleOutPacketType.Task);
  2053. }
  2054. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2055. {
  2056. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2057. sound.DataBlock.SoundID = soundID;
  2058. sound.DataBlock.ObjectID = objectID;
  2059. sound.DataBlock.OwnerID = ownerID;
  2060. sound.DataBlock.Gain = gain;
  2061. sound.DataBlock.Flags = flags;
  2062. OutPacket(sound, ThrottleOutPacketType.Task);
  2063. }
  2064. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2065. {
  2066. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2067. sound.SoundData.SoundID = soundID;
  2068. sound.SoundData.OwnerID = ownerID;
  2069. sound.SoundData.ObjectID = objectID;
  2070. sound.SoundData.ParentID = parentID;
  2071. sound.SoundData.Handle = handle;
  2072. sound.SoundData.Position = position;
  2073. sound.SoundData.Gain = gain;
  2074. OutPacket(sound, ThrottleOutPacketType.Task);
  2075. }
  2076. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2077. {
  2078. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2079. sound.DataBlock.ObjectID = objectID;
  2080. sound.DataBlock.Gain = gain;
  2081. OutPacket(sound, ThrottleOutPacketType.Task);
  2082. }
  2083. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2084. {
  2085. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2086. // So adjust for that
  2087. // Contributed by: Godfrey
  2088. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2089. {
  2090. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2091. }
  2092. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2093. viewertime.TimeInfo.SunDirection = Position;
  2094. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2095. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2096. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2097. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2098. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2099. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2100. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2101. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2102. viewertime.Header.Reliable = false;
  2103. viewertime.Header.Zerocoded = true;
  2104. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2105. }
  2106. // Currently Deprecated
  2107. public void SendViewerTime(int phase)
  2108. {
  2109. /*
  2110. Console.WriteLine("SunPhase: {0}", phase);
  2111. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2112. //viewertime.TimeInfo.SecPerDay = 86400;
  2113. //viewertime.TimeInfo.SecPerYear = 31536000;
  2114. viewertime.TimeInfo.SecPerDay = 1000;
  2115. viewertime.TimeInfo.SecPerYear = 365000;
  2116. viewertime.TimeInfo.SunPhase = 1;
  2117. int sunPhase = (phase + 2) / 2;
  2118. if ((sunPhase < 6) || (sunPhase > 36))
  2119. {
  2120. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2121. Console.WriteLine("sending night");
  2122. }
  2123. else
  2124. {
  2125. if (sunPhase < 12)
  2126. {
  2127. sunPhase = 12;
  2128. }
  2129. sunPhase = sunPhase - 12;
  2130. float yValue = 0.1f * (sunPhase);
  2131. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2132. if (yValue > 1.2f)
  2133. {
  2134. yValue = yValue - 1.2f;
  2135. }
  2136. yValue = Util.Clip(yValue, 0, 1);
  2137. if (sunPhase < 14)
  2138. {
  2139. yValue = 1 - yValue;
  2140. }
  2141. if (sunPhase < 12)
  2142. {
  2143. yValue *= -1;
  2144. }
  2145. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2146. Console.WriteLine("sending sun update " + yValue);
  2147. }
  2148. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2149. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2150. viewertime.Header.Reliable = false;
  2151. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2152. */
  2153. }
  2154. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2155. {
  2156. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2157. packet.Header.Reliable = false;
  2158. packet.Header.Zerocoded = true;
  2159. packet.AgentData.AgentID = AgentId;
  2160. packet.AgentData.SessionID = SessionId;
  2161. packet.Effect = effectBlocks;
  2162. // OutPacket(packet, ThrottleOutPacketType.State);
  2163. OutPacket(packet, ThrottleOutPacketType.Task);
  2164. }
  2165. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2166. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2167. UUID partnerID)
  2168. {
  2169. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2170. avatarReply.AgentData.AgentID = AgentId;
  2171. avatarReply.AgentData.AvatarID = avatarID;
  2172. if (aboutText != null)
  2173. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2174. else
  2175. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2176. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2177. avatarReply.PropertiesData.CharterMember = charterMember;
  2178. if (flAbout != null)
  2179. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2180. else
  2181. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2182. avatarReply.PropertiesData.Flags = flags;
  2183. avatarReply.PropertiesData.FLImageID = flImageID;
  2184. avatarReply.PropertiesData.ImageID = imageID;
  2185. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2186. avatarReply.PropertiesData.PartnerID = partnerID;
  2187. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2188. }
  2189. /// <summary>
  2190. /// Send the client an Estate message blue box pop-down with a single OK button
  2191. /// </summary>
  2192. /// <param name="FromAvatarID"></param>
  2193. /// <param name="fromSessionID"></param>
  2194. /// <param name="FromAvatarName"></param>
  2195. /// <param name="Message"></param>
  2196. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2197. {
  2198. if (!SceneAgent.IsChildAgent)
  2199. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2200. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2201. }
  2202. public void SendLogoutPacket()
  2203. {
  2204. // I know this is a bit of a hack, however there are times when you don't
  2205. // want to send this, but still need to do the rest of the shutdown process
  2206. // this method gets called from the packet server.. which makes it practically
  2207. // impossible to do any other way.
  2208. if (m_SendLogoutPacketWhenClosing)
  2209. {
  2210. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2211. // TODO: don't create new blocks if recycling an old packet
  2212. logReply.AgentData.AgentID = AgentId;
  2213. logReply.AgentData.SessionID = SessionId;
  2214. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2215. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2216. logReply.InventoryData[0].ItemID = UUID.Zero;
  2217. OutPacket(logReply, ThrottleOutPacketType.Task);
  2218. }
  2219. }
  2220. public void SendHealth(float health)
  2221. {
  2222. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2223. healthpacket.HealthData.Health = health;
  2224. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2225. }
  2226. public void SendAgentOnline(UUID[] agentIDs)
  2227. {
  2228. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2229. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2230. for (int i = 0; i < agentIDs.Length; i++)
  2231. {
  2232. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2233. onpbl.AgentID = agentIDs[i];
  2234. onpb[i] = onpbl;
  2235. }
  2236. onp.AgentBlock = onpb;
  2237. onp.Header.Reliable = true;
  2238. OutPacket(onp, ThrottleOutPacketType.Task);
  2239. }
  2240. public void SendAgentOffline(UUID[] agentIDs)
  2241. {
  2242. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2243. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2244. for (int i = 0; i < agentIDs.Length; i++)
  2245. {
  2246. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2247. onpbl.AgentID = agentIDs[i];
  2248. offpb[i] = onpbl;
  2249. }
  2250. offp.AgentBlock = offpb;
  2251. offp.Header.Reliable = true;
  2252. OutPacket(offp, ThrottleOutPacketType.Task);
  2253. }
  2254. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2255. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2256. {
  2257. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2258. avatarSitResponse.SitObject.ID = TargetID;
  2259. if (CameraAtOffset != Vector3.Zero)
  2260. {
  2261. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2262. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2263. }
  2264. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2265. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2266. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2267. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2268. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2269. }
  2270. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2271. {
  2272. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2273. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2274. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2275. adb.AgentID = AgentId;
  2276. adb.SessionID = SessionId; // More security
  2277. gdb.GodLevel = (byte)AdminLevel;
  2278. gdb.Token = Token;
  2279. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2280. respondPacket.GrantData = gdb;
  2281. respondPacket.AgentData = adb;
  2282. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2283. }
  2284. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2285. {
  2286. m_groupPowers.Clear();
  2287. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2288. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2289. for (int i = 0; i < GroupMembership.Length; i++)
  2290. {
  2291. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2292. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2293. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2294. Group.Contribution = GroupMembership[i].Contribution;
  2295. Group.GroupID = GroupMembership[i].GroupID;
  2296. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2297. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2298. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2299. Groups[i] = Group;
  2300. }
  2301. Groupupdate.GroupData = Groups;
  2302. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2303. Groupupdate.AgentData.AgentID = AgentId;
  2304. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2305. try
  2306. {
  2307. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2308. if (eq != null)
  2309. {
  2310. eq.GroupMembership(Groupupdate, this.AgentId);
  2311. }
  2312. }
  2313. catch (Exception ex)
  2314. {
  2315. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2316. m_log.Warn("sending group membership data via UDP");
  2317. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2318. }
  2319. }
  2320. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2321. {
  2322. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2323. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2324. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2325. uidnamebloc.ID = groupLLUID;
  2326. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2327. uidnameblock[0] = uidnamebloc;
  2328. pack.UUIDNameBlock = uidnameblock;
  2329. OutPacket(pack, ThrottleOutPacketType.Task);
  2330. }
  2331. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2332. {
  2333. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2334. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2335. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2336. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2337. // lsrepdb.
  2338. lsrp.RequestData.ReportType = reportType;
  2339. lsrp.RequestData.RequestFlags = requestFlags;
  2340. lsrp.RequestData.TotalObjectCount = resultCount;
  2341. for (int i = 0; i < lsrpia.Length; i++)
  2342. {
  2343. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2344. lsrepdb.LocationX = lsrpia[i].LocationX;
  2345. lsrepdb.LocationY = lsrpia[i].LocationY;
  2346. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2347. lsrepdb.Score = lsrpia[i].Score;
  2348. lsrepdb.TaskID = lsrpia[i].TaskID;
  2349. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2350. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2351. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2352. lsrepdba[i] = lsrepdb;
  2353. }
  2354. lsrp.ReportData = lsrepdba;
  2355. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2356. }
  2357. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2358. {
  2359. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2360. scriptRunningReply.Script.ObjectID = objectID;
  2361. scriptRunningReply.Script.ItemID = itemID;
  2362. scriptRunningReply.Script.Running = running;
  2363. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2364. }
  2365. public void SendAsset(AssetRequestToClient req)
  2366. {
  2367. if (req.AssetInf.Data == null)
  2368. {
  2369. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2370. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2371. return;
  2372. }
  2373. //m_log.Debug("sending asset " + req.RequestAssetID);
  2374. TransferInfoPacket Transfer = new TransferInfoPacket();
  2375. Transfer.TransferInfo.ChannelType = 2;
  2376. Transfer.TransferInfo.Status = 0;
  2377. Transfer.TransferInfo.TargetType = 0;
  2378. if (req.AssetRequestSource == 2)
  2379. {
  2380. Transfer.TransferInfo.Params = new byte[20];
  2381. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2382. int assType = req.AssetInf.Type;
  2383. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2384. }
  2385. else if (req.AssetRequestSource == 3)
  2386. {
  2387. Transfer.TransferInfo.Params = req.Params;
  2388. // Transfer.TransferInfo.Params = new byte[100];
  2389. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2390. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2391. }
  2392. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2393. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2394. Transfer.Header.Zerocoded = true;
  2395. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2396. if (req.NumPackets == 1)
  2397. {
  2398. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2399. TransferPacket.TransferData.Packet = 0;
  2400. TransferPacket.TransferData.ChannelType = 2;
  2401. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2402. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2403. TransferPacket.TransferData.Status = 1;
  2404. TransferPacket.Header.Zerocoded = true;
  2405. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2406. }
  2407. else
  2408. {
  2409. int processedLength = 0;
  2410. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2411. int packetNumber = 0;
  2412. while (processedLength < req.AssetInf.Data.Length)
  2413. {
  2414. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2415. TransferPacket.TransferData.Packet = packetNumber;
  2416. TransferPacket.TransferData.ChannelType = 2;
  2417. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2418. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2419. byte[] chunk = new byte[chunkSize];
  2420. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2421. TransferPacket.TransferData.Data = chunk;
  2422. // 0 indicates more packets to come, 1 indicates last packet
  2423. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2424. {
  2425. TransferPacket.TransferData.Status = 0;
  2426. }
  2427. else
  2428. {
  2429. TransferPacket.TransferData.Status = 1;
  2430. }
  2431. TransferPacket.Header.Zerocoded = true;
  2432. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2433. processedLength += chunkSize;
  2434. packetNumber++;
  2435. }
  2436. }
  2437. }
  2438. public void SendAssetNotFound(AssetRequestToClient req)
  2439. {
  2440. TransferInfoPacket Transfer = new TransferInfoPacket();
  2441. Transfer.TransferInfo.ChannelType = 2;
  2442. Transfer.TransferInfo.Status = -2;
  2443. Transfer.TransferInfo.TargetType = 0;
  2444. Transfer.TransferInfo.Params = req.Params;
  2445. Transfer.TransferInfo.Size = 0;
  2446. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2447. Transfer.Header.Zerocoded = true;
  2448. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2449. }
  2450. public void SendTexture(AssetBase TextureAsset)
  2451. {
  2452. }
  2453. public void SendRegionHandle(UUID regionID, ulong handle)
  2454. {
  2455. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2456. reply.ReplyBlock.RegionID = regionID;
  2457. reply.ReplyBlock.RegionHandle = handle;
  2458. OutPacket(reply, ThrottleOutPacketType.Land);
  2459. }
  2460. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2461. {
  2462. float dwell = 0.0f;
  2463. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2464. if (dwellModule != null)
  2465. dwell = dwellModule.GetDwell(land.GlobalID);
  2466. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2467. reply.AgentData.AgentID = m_agentId;
  2468. reply.Data.ParcelID = parcelID;
  2469. reply.Data.OwnerID = land.OwnerID;
  2470. reply.Data.Name = Utils.StringToBytes(land.Name);
  2471. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2472. reply.Data.ActualArea = land.Area;
  2473. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2474. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2475. reply.Data.Flags = (byte)(
  2476. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2477. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2478. Vector3 pos = land.UserLocation;
  2479. if (pos.Equals(Vector3.Zero))
  2480. {
  2481. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2482. }
  2483. reply.Data.GlobalX = info.RegionLocX + x;
  2484. reply.Data.GlobalY = info.RegionLocY + y;
  2485. reply.Data.GlobalZ = pos.Z;
  2486. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2487. reply.Data.SnapshotID = land.SnapshotID;
  2488. reply.Data.Dwell = dwell;
  2489. reply.Data.SalePrice = land.SalePrice;
  2490. reply.Data.AuctionID = (int)land.AuctionID;
  2491. OutPacket(reply, ThrottleOutPacketType.Land);
  2492. }
  2493. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2494. {
  2495. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2496. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2497. packet.Data.SimName = Utils.StringToBytes(simName);
  2498. packet.Data.SimPosition = pos;
  2499. packet.Data.LookAt = lookAt;
  2500. OutPacket(packet, ThrottleOutPacketType.Task);
  2501. }
  2502. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2503. {
  2504. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2505. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2506. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2507. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2508. packet.AgentData.AgentID = AgentId;
  2509. packet.QueryData[0].QueryID = queryID;
  2510. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2511. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2512. DirPlacesReplyPacket.StatusDataBlock[] status =
  2513. new DirPlacesReplyPacket.StatusDataBlock[0];
  2514. packet.QueryReplies = replies;
  2515. packet.StatusData = status;
  2516. foreach (DirPlacesReplyData d in data)
  2517. {
  2518. int idx = replies.Length;
  2519. Array.Resize(ref replies, idx + 1);
  2520. Array.Resize(ref status, idx + 1);
  2521. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2522. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2523. replies[idx].ParcelID = d.parcelID;
  2524. replies[idx].Name = Utils.StringToBytes(d.name);
  2525. replies[idx].ForSale = d.forSale;
  2526. replies[idx].Auction = d.auction;
  2527. replies[idx].Dwell = d.dwell;
  2528. status[idx].Status = d.Status;
  2529. packet.QueryReplies = replies;
  2530. packet.StatusData = status;
  2531. if (packet.Length >= 1000)
  2532. {
  2533. OutPacket(packet, ThrottleOutPacketType.Task);
  2534. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2535. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2536. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2537. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2538. packet.AgentData.AgentID = AgentId;
  2539. packet.QueryData[0].QueryID = queryID;
  2540. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2541. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2542. }
  2543. }
  2544. if (replies.Length > 0 || data.Length == 0)
  2545. OutPacket(packet, ThrottleOutPacketType.Task);
  2546. }
  2547. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2548. {
  2549. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2550. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2551. packet.AgentData.AgentID = AgentId;
  2552. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2553. packet.QueryData.QueryID = queryID;
  2554. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2555. data.Length];
  2556. int i = 0;
  2557. foreach (DirPeopleReplyData d in data)
  2558. {
  2559. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2560. packet.QueryReplies[i].AgentID = d.agentID;
  2561. packet.QueryReplies[i].FirstName =
  2562. Utils.StringToBytes(d.firstName);
  2563. packet.QueryReplies[i].LastName =
  2564. Utils.StringToBytes(d.lastName);
  2565. packet.QueryReplies[i].Group =
  2566. Utils.StringToBytes(d.group);
  2567. packet.QueryReplies[i].Online = d.online;
  2568. packet.QueryReplies[i].Reputation = d.reputation;
  2569. i++;
  2570. }
  2571. OutPacket(packet, ThrottleOutPacketType.Task);
  2572. }
  2573. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2574. {
  2575. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2576. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2577. packet.AgentData.AgentID = AgentId;
  2578. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2579. packet.QueryData.QueryID = queryID;
  2580. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2581. data.Length];
  2582. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2583. data.Length];
  2584. int i = 0;
  2585. foreach (DirEventsReplyData d in data)
  2586. {
  2587. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2588. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2589. packet.QueryReplies[i].OwnerID = d.ownerID;
  2590. packet.QueryReplies[i].Name =
  2591. Utils.StringToBytes(d.name);
  2592. packet.QueryReplies[i].EventID = d.eventID;
  2593. packet.QueryReplies[i].Date =
  2594. Utils.StringToBytes(d.date);
  2595. packet.QueryReplies[i].UnixTime = d.unixTime;
  2596. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2597. packet.StatusData[i].Status = d.Status;
  2598. i++;
  2599. }
  2600. OutPacket(packet, ThrottleOutPacketType.Task);
  2601. }
  2602. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2603. {
  2604. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2605. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2606. packet.AgentData.AgentID = AgentId;
  2607. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2608. packet.QueryData.QueryID = queryID;
  2609. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2610. data.Length];
  2611. int i = 0;
  2612. foreach (DirGroupsReplyData d in data)
  2613. {
  2614. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2615. packet.QueryReplies[i].GroupID = d.groupID;
  2616. packet.QueryReplies[i].GroupName =
  2617. Utils.StringToBytes(d.groupName);
  2618. packet.QueryReplies[i].Members = d.members;
  2619. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2620. i++;
  2621. }
  2622. OutPacket(packet, ThrottleOutPacketType.Task);
  2623. }
  2624. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2625. {
  2626. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2627. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2628. packet.AgentData.AgentID = AgentId;
  2629. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2630. packet.QueryData.QueryID = queryID;
  2631. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2632. data.Length];
  2633. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2634. data.Length];
  2635. int i = 0;
  2636. foreach (DirClassifiedReplyData d in data)
  2637. {
  2638. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2639. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2640. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2641. packet.QueryReplies[i].Name =
  2642. Utils.StringToBytes(d.name);
  2643. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2644. packet.QueryReplies[i].CreationDate = d.creationDate;
  2645. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2646. packet.QueryReplies[i].PriceForListing = d.price;
  2647. packet.StatusData[i].Status = d.Status;
  2648. i++;
  2649. }
  2650. OutPacket(packet, ThrottleOutPacketType.Task);
  2651. }
  2652. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2653. {
  2654. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2655. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2656. packet.AgentData.AgentID = AgentId;
  2657. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2658. packet.QueryData.QueryID = queryID;
  2659. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2660. data.Length];
  2661. int i = 0;
  2662. foreach (DirLandReplyData d in data)
  2663. {
  2664. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2665. packet.QueryReplies[i].ParcelID = d.parcelID;
  2666. packet.QueryReplies[i].Name =
  2667. Utils.StringToBytes(d.name);
  2668. packet.QueryReplies[i].Auction = d.auction;
  2669. packet.QueryReplies[i].ForSale = d.forSale;
  2670. packet.QueryReplies[i].SalePrice = d.salePrice;
  2671. packet.QueryReplies[i].ActualArea = d.actualArea;
  2672. i++;
  2673. }
  2674. OutPacket(packet, ThrottleOutPacketType.Task);
  2675. }
  2676. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2677. {
  2678. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2679. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2680. packet.AgentData.AgentID = AgentId;
  2681. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2682. packet.QueryData.QueryID = queryID;
  2683. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2684. data.Length];
  2685. int i = 0;
  2686. foreach (DirPopularReplyData d in data)
  2687. {
  2688. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2689. packet.QueryReplies[i].ParcelID = d.parcelID;
  2690. packet.QueryReplies[i].Name =
  2691. Utils.StringToBytes(d.name);
  2692. packet.QueryReplies[i].Dwell = d.dwell;
  2693. i++;
  2694. }
  2695. OutPacket(packet, ThrottleOutPacketType.Task);
  2696. }
  2697. public void SendEventInfoReply(EventData data)
  2698. {
  2699. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2700. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2701. packet.AgentData.AgentID = AgentId;
  2702. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2703. packet.EventData.EventID = data.eventID;
  2704. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2705. packet.EventData.Name = Utils.StringToBytes(data.name);
  2706. packet.EventData.Category = Utils.StringToBytes(data.category);
  2707. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2708. packet.EventData.Date = Utils.StringToBytes(data.date);
  2709. packet.EventData.DateUTC = data.dateUTC;
  2710. packet.EventData.Duration = data.duration;
  2711. packet.EventData.Cover = data.cover;
  2712. packet.EventData.Amount = data.amount;
  2713. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2714. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2715. packet.EventData.EventFlags = data.eventFlags;
  2716. OutPacket(packet, ThrottleOutPacketType.Task);
  2717. }
  2718. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2719. {
  2720. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2721. mirplk.AgentData.AgentID = AgentId;
  2722. mirplk.RequestData.ItemType = mapitemtype;
  2723. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2724. for (int i = 0; i < replies.Length; i++)
  2725. {
  2726. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2727. mrdata.X = replies[i].x;
  2728. mrdata.Y = replies[i].y;
  2729. mrdata.ID = replies[i].id;
  2730. mrdata.Extra = replies[i].Extra;
  2731. mrdata.Extra2 = replies[i].Extra2;
  2732. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2733. mirplk.Data[i] = mrdata;
  2734. }
  2735. //m_log.Debug(mirplk.ToString());
  2736. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2737. }
  2738. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2739. {
  2740. // a bit special, as this uses AgentID to store the source instead
  2741. // of the destination. The destination (the receiver) goes into destID
  2742. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2743. p.AgentData.AgentID = srcID;
  2744. p.AgentData.SessionID = UUID.Zero;
  2745. p.AgentBlock.DestID = AgentId;
  2746. p.AgentBlock.TransactionID = transactionID;
  2747. OutPacket(p, ThrottleOutPacketType.Task);
  2748. }
  2749. public void SendAcceptCallingCard(UUID transactionID)
  2750. {
  2751. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2752. p.AgentData.AgentID = AgentId;
  2753. p.AgentData.SessionID = UUID.Zero;
  2754. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2755. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2756. p.FolderData[0].FolderID = UUID.Zero;
  2757. OutPacket(p, ThrottleOutPacketType.Task);
  2758. }
  2759. public void SendDeclineCallingCard(UUID transactionID)
  2760. {
  2761. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2762. p.AgentData.AgentID = AgentId;
  2763. p.AgentData.SessionID = UUID.Zero;
  2764. p.TransactionBlock.TransactionID = transactionID;
  2765. OutPacket(p, ThrottleOutPacketType.Task);
  2766. }
  2767. public void SendTerminateFriend(UUID exFriendID)
  2768. {
  2769. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2770. p.AgentData.AgentID = AgentId;
  2771. p.AgentData.SessionID = SessionId;
  2772. p.ExBlock.OtherID = exFriendID;
  2773. OutPacket(p, ThrottleOutPacketType.Task);
  2774. }
  2775. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2776. {
  2777. OSDMap llsd = new OSDMap(3);
  2778. OSDArray AgentData = new OSDArray(1);
  2779. OSDMap AgentDataMap = new OSDMap(1);
  2780. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2781. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2782. AgentData.Add(AgentDataMap);
  2783. llsd.Add("AgentData", AgentData);
  2784. OSDArray GroupData = new OSDArray(data.Length);
  2785. OSDArray NewGroupData = new OSDArray(data.Length);
  2786. foreach (GroupMembershipData m in data)
  2787. {
  2788. OSDMap GroupDataMap = new OSDMap(6);
  2789. OSDMap NewGroupDataMap = new OSDMap(1);
  2790. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2791. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2792. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2793. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2794. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2795. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2796. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2797. GroupData.Add(GroupDataMap);
  2798. NewGroupData.Add(NewGroupDataMap);
  2799. }
  2800. llsd.Add("GroupData", GroupData);
  2801. llsd.Add("NewGroupData", NewGroupData);
  2802. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2803. if (eq != null)
  2804. {
  2805. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2806. }
  2807. }
  2808. public void SendJoinGroupReply(UUID groupID, bool success)
  2809. {
  2810. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2811. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2812. p.AgentData.AgentID = AgentId;
  2813. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2814. p.GroupData.GroupID = groupID;
  2815. p.GroupData.Success = success;
  2816. OutPacket(p, ThrottleOutPacketType.Task);
  2817. }
  2818. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2819. {
  2820. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2821. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2822. p.AgentData.AgentID = agentID;
  2823. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2824. p.GroupData.GroupID = groupID;
  2825. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2826. p.EjectData.Success = success;
  2827. OutPacket(p, ThrottleOutPacketType.Task);
  2828. }
  2829. public void SendLeaveGroupReply(UUID groupID, bool success)
  2830. {
  2831. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2832. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2833. p.AgentData.AgentID = AgentId;
  2834. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2835. p.GroupData.GroupID = groupID;
  2836. p.GroupData.Success = success;
  2837. OutPacket(p, ThrottleOutPacketType.Task);
  2838. }
  2839. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2840. {
  2841. if (classifiedID.Length != name.Length)
  2842. return;
  2843. AvatarClassifiedReplyPacket ac =
  2844. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2845. PacketType.AvatarClassifiedReply);
  2846. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2847. ac.AgentData.AgentID = AgentId;
  2848. ac.AgentData.TargetID = targetID;
  2849. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2850. int i;
  2851. for (i = 0; i < classifiedID.Length; i++)
  2852. {
  2853. ac.Data[i].ClassifiedID = classifiedID[i];
  2854. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2855. }
  2856. OutPacket(ac, ThrottleOutPacketType.Task);
  2857. }
  2858. 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)
  2859. {
  2860. ClassifiedInfoReplyPacket cr =
  2861. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2862. PacketType.ClassifiedInfoReply);
  2863. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2864. cr.AgentData.AgentID = AgentId;
  2865. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2866. cr.Data.ClassifiedID = classifiedID;
  2867. cr.Data.CreatorID = creatorID;
  2868. cr.Data.CreationDate = creationDate;
  2869. cr.Data.ExpirationDate = expirationDate;
  2870. cr.Data.Category = category;
  2871. cr.Data.Name = Utils.StringToBytes(name);
  2872. cr.Data.Desc = Utils.StringToBytes(description);
  2873. cr.Data.ParcelID = parcelID;
  2874. cr.Data.ParentEstate = parentEstate;
  2875. cr.Data.SnapshotID = snapshotID;
  2876. cr.Data.SimName = Utils.StringToBytes(simName);
  2877. cr.Data.PosGlobal = new Vector3d(globalPos);
  2878. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2879. cr.Data.ClassifiedFlags = classifiedFlags;
  2880. cr.Data.PriceForListing = price;
  2881. OutPacket(cr, ThrottleOutPacketType.Task);
  2882. }
  2883. public void SendAgentDropGroup(UUID groupID)
  2884. {
  2885. AgentDropGroupPacket dg =
  2886. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2887. PacketType.AgentDropGroup);
  2888. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2889. dg.AgentData.AgentID = AgentId;
  2890. dg.AgentData.GroupID = groupID;
  2891. OutPacket(dg, ThrottleOutPacketType.Task);
  2892. }
  2893. public void SendAvatarNotesReply(UUID targetID, string text)
  2894. {
  2895. AvatarNotesReplyPacket an =
  2896. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2897. PacketType.AvatarNotesReply);
  2898. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2899. an.AgentData.AgentID = AgentId;
  2900. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2901. an.Data.TargetID = targetID;
  2902. an.Data.Notes = Utils.StringToBytes(text);
  2903. OutPacket(an, ThrottleOutPacketType.Task);
  2904. }
  2905. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2906. {
  2907. AvatarPicksReplyPacket ap =
  2908. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2909. PacketType.AvatarPicksReply);
  2910. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2911. ap.AgentData.AgentID = AgentId;
  2912. ap.AgentData.TargetID = targetID;
  2913. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  2914. int i = 0;
  2915. foreach (KeyValuePair<UUID, string> pick in picks)
  2916. {
  2917. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  2918. ap.Data[i].PickID = pick.Key;
  2919. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  2920. i++;
  2921. }
  2922. OutPacket(ap, ThrottleOutPacketType.Task);
  2923. }
  2924. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  2925. {
  2926. AvatarClassifiedReplyPacket ac =
  2927. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2928. PacketType.AvatarClassifiedReply);
  2929. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2930. ac.AgentData.AgentID = AgentId;
  2931. ac.AgentData.TargetID = targetID;
  2932. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  2933. int i = 0;
  2934. foreach (KeyValuePair<UUID, string> classified in classifieds)
  2935. {
  2936. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  2937. ac.Data[i].ClassifiedID = classified.Key;
  2938. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  2939. i++;
  2940. }
  2941. OutPacket(ac, ThrottleOutPacketType.Task);
  2942. }
  2943. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  2944. {
  2945. ParcelDwellReplyPacket pd =
  2946. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  2947. PacketType.ParcelDwellReply);
  2948. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  2949. pd.AgentData.AgentID = AgentId;
  2950. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  2951. pd.Data.LocalID = localID;
  2952. pd.Data.ParcelID = parcelID;
  2953. pd.Data.Dwell = dwell;
  2954. OutPacket(pd, ThrottleOutPacketType.Land);
  2955. }
  2956. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  2957. {
  2958. UserInfoReplyPacket ur =
  2959. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  2960. PacketType.UserInfoReply);
  2961. string Visible = "hidden";
  2962. if (visible)
  2963. Visible = "default";
  2964. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  2965. ur.AgentData.AgentID = AgentId;
  2966. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  2967. ur.UserData.IMViaEMail = imViaEmail;
  2968. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  2969. ur.UserData.EMail = Utils.StringToBytes(email);
  2970. OutPacket(ur, ThrottleOutPacketType.Task);
  2971. }
  2972. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  2973. {
  2974. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  2975. createGroupReply.AgentData =
  2976. new CreateGroupReplyPacket.AgentDataBlock();
  2977. createGroupReply.ReplyData =
  2978. new CreateGroupReplyPacket.ReplyDataBlock();
  2979. createGroupReply.AgentData.AgentID = AgentId;
  2980. createGroupReply.ReplyData.GroupID = groupID;
  2981. createGroupReply.ReplyData.Success = success;
  2982. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  2983. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  2984. }
  2985. public void SendUseCachedMuteList()
  2986. {
  2987. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  2988. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  2989. useCachedMuteList.AgentData.AgentID = AgentId;
  2990. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  2991. }
  2992. public void SendMuteListUpdate(string filename)
  2993. {
  2994. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  2995. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  2996. muteListUpdate.MuteData.AgentID = AgentId;
  2997. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  2998. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  2999. }
  3000. 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)
  3001. {
  3002. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3003. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3004. pickInfoReply.AgentData.AgentID = AgentId;
  3005. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3006. pickInfoReply.Data.PickID = pickID;
  3007. pickInfoReply.Data.CreatorID = creatorID;
  3008. pickInfoReply.Data.TopPick = topPick;
  3009. pickInfoReply.Data.ParcelID = parcelID;
  3010. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3011. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3012. pickInfoReply.Data.SnapshotID = snapshotID;
  3013. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3014. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3015. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3016. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3017. pickInfoReply.Data.SortOrder = sortOrder;
  3018. pickInfoReply.Data.Enabled = enabled;
  3019. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3020. }
  3021. #endregion Scene/Avatar to Client
  3022. // Gesture
  3023. #region Appearance/ Wearables Methods
  3024. public void SendWearables(AvatarWearable[] wearables, int serial)
  3025. {
  3026. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3027. aw.AgentData.AgentID = AgentId;
  3028. aw.AgentData.SerialNum = (uint)serial;
  3029. aw.AgentData.SessionID = m_sessionId;
  3030. int count = 0;
  3031. for (int i = 0; i < wearables.Length; i++)
  3032. count += wearables[i].Count;
  3033. // TODO: don't create new blocks if recycling an old packet
  3034. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3035. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3036. int idx = 0;
  3037. for (int i = 0; i < wearables.Length; i++)
  3038. {
  3039. for (int j = 0; j < wearables[i].Count; j++)
  3040. {
  3041. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3042. awb.WearableType = (byte)i;
  3043. awb.AssetID = wearables[i][j].AssetID;
  3044. awb.ItemID = wearables[i][j].ItemID;
  3045. aw.WearableData[idx] = awb;
  3046. idx++;
  3047. // m_log.DebugFormat(
  3048. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3049. // awb.ItemID, awb.AssetID, i, Name);
  3050. }
  3051. }
  3052. OutPacket(aw, ThrottleOutPacketType.Task);
  3053. }
  3054. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3055. {
  3056. // m_log.DebugFormat(
  3057. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3058. // agentID, textureEntry.Length, Name, AgentId);
  3059. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3060. // TODO: don't create new blocks if recycling an old packet
  3061. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  3062. avp.ObjectData.TextureEntry = textureEntry;
  3063. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3064. for (int i = 0; i < visualParams.Length; i++)
  3065. {
  3066. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3067. avblock.ParamValue = visualParams[i];
  3068. avp.VisualParam[i] = avblock;
  3069. }
  3070. avp.Sender.IsTrial = false;
  3071. avp.Sender.ID = agentID;
  3072. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3073. OutPacket(avp, ThrottleOutPacketType.Task);
  3074. }
  3075. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3076. {
  3077. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3078. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3079. // TODO: don't create new blocks if recycling an old packet
  3080. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3081. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3082. ani.Sender.ID = sourceAgentId;
  3083. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3084. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3085. for (int i = 0; i < animations.Length; ++i)
  3086. {
  3087. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3088. ani.AnimationList[i].AnimID = animations[i];
  3089. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3090. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3091. if (objectIDs[i].Equals(sourceAgentId))
  3092. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3093. else
  3094. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3095. }
  3096. ani.Header.Reliable = false;
  3097. OutPacket(ani, ThrottleOutPacketType.Task);
  3098. }
  3099. #endregion
  3100. #region Avatar Packet/Data Sending Methods
  3101. /// <summary>
  3102. /// Send an ObjectUpdate packet with information about an avatar
  3103. /// </summary>
  3104. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3105. {
  3106. // m_log.DebugFormat(
  3107. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3108. // avatar.Name, avatar.UUID, Name, AgentId);
  3109. ScenePresence presence = avatar as ScenePresence;
  3110. if (presence == null)
  3111. return;
  3112. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3113. objupdate.Header.Zerocoded = true;
  3114. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3115. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3116. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3117. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3118. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3119. // We need to record the avatar local id since the root prim of an attachment points to this.
  3120. // m_attachmentsSent.Add(avatar.LocalId);
  3121. }
  3122. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3123. {
  3124. // We don't need to update inactive clients.
  3125. if (!IsActive)
  3126. return;
  3127. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3128. loc.Header.Reliable = false;
  3129. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3130. // a CoarseLocationUpdate packet is received. Oh well.
  3131. int total = Math.Min(CoarseLocations.Count, 60);
  3132. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3133. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3134. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3135. int selfindex = -1;
  3136. for (int i = 0; i < total; i++)
  3137. {
  3138. CoarseLocationUpdatePacket.LocationBlock lb =
  3139. new CoarseLocationUpdatePacket.LocationBlock();
  3140. lb.X = (byte)CoarseLocations[i].X;
  3141. lb.Y = (byte)CoarseLocations[i].Y;
  3142. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3143. loc.Location[i] = lb;
  3144. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3145. loc.AgentData[i].AgentID = users[i];
  3146. if (users[i] == AgentId)
  3147. selfindex = i;
  3148. }
  3149. ib.You = (short)selfindex;
  3150. ib.Prey = -1;
  3151. loc.Index = ib;
  3152. OutPacket(loc, ThrottleOutPacketType.Task);
  3153. }
  3154. #endregion Avatar Packet/Data Sending Methods
  3155. #region Primitive Packet/Data Sending Methods
  3156. /// <summary>
  3157. /// Generate one of the object update packets based on PrimUpdateFlags
  3158. /// and broadcast the packet to clients
  3159. /// </summary>
  3160. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3161. {
  3162. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3163. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3164. lock (m_entityUpdates.SyncRoot)
  3165. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3166. }
  3167. /// <summary>
  3168. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3169. /// We will update the priority and put it in the correct queue, merging update flags
  3170. /// with any other updates that may be queued for the same entity.
  3171. /// The original update time is used for the merged update.
  3172. /// </summary>
  3173. private void ResendPrimUpdate(EntityUpdate update)
  3174. {
  3175. // If the update exists in priority queue, it will be updated.
  3176. // If it does not exist then it will be added with the current (rather than its original) priority
  3177. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3178. lock (m_entityUpdates.SyncRoot)
  3179. m_entityUpdates.Enqueue(priority, update);
  3180. }
  3181. /// <summary>
  3182. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3183. /// We will update the priority and put it in the correct queue, merging update flags
  3184. /// with any other updates that may be queued for the same entity.
  3185. /// The original update time is used for the merged update.
  3186. /// </summary>
  3187. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3188. {
  3189. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3190. // Remove the update packet from the list of packets waiting for acknowledgement
  3191. // because we are requeuing the list of updates. They will be resent in new packets
  3192. // with the most recent state and priority.
  3193. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3194. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3195. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3196. foreach (EntityUpdate update in updates)
  3197. ResendPrimUpdate(update);
  3198. }
  3199. private void ProcessEntityUpdates(int maxUpdates)
  3200. {
  3201. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3202. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3203. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3204. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3205. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3206. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3207. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3208. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3209. // Check to see if this is a flush
  3210. if (maxUpdates <= 0)
  3211. {
  3212. maxUpdates = Int32.MaxValue;
  3213. }
  3214. int updatesThisCall = 0;
  3215. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3216. // condition where a kill can be processed before an out-of-date update for the same object.
  3217. lock (m_killRecord)
  3218. {
  3219. float avgTimeDilation = 1.0f;
  3220. IEntityUpdate iupdate;
  3221. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3222. while (updatesThisCall < maxUpdates)
  3223. {
  3224. lock (m_entityUpdates.SyncRoot)
  3225. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3226. break;
  3227. EntityUpdate update = (EntityUpdate)iupdate;
  3228. avgTimeDilation += update.TimeDilation;
  3229. avgTimeDilation *= 0.5f;
  3230. if (update.Entity is SceneObjectPart)
  3231. {
  3232. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3233. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3234. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3235. // safety measure.
  3236. //
  3237. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3238. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3239. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3240. //
  3241. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3242. // after the root prim has been deleted.
  3243. if (m_killRecord.Contains(part.LocalId))
  3244. {
  3245. // m_log.WarnFormat(
  3246. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3247. // part.LocalId, Name);
  3248. continue;
  3249. }
  3250. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3251. {
  3252. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3253. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3254. {
  3255. part.Shape.LightEntry = false;
  3256. }
  3257. }
  3258. }
  3259. #region UpdateFlags to packet type conversion
  3260. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3261. bool canUseCompressed = true;
  3262. bool canUseImproved = true;
  3263. // Compressed object updates only make sense for LL primitives
  3264. if (!(update.Entity is SceneObjectPart))
  3265. {
  3266. canUseCompressed = false;
  3267. }
  3268. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3269. {
  3270. canUseCompressed = false;
  3271. canUseImproved = false;
  3272. }
  3273. else
  3274. {
  3275. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3276. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3277. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3278. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3279. {
  3280. canUseCompressed = false;
  3281. }
  3282. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3283. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3284. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3285. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3286. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3287. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3288. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3289. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3290. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3291. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3292. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3293. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3294. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3295. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3296. {
  3297. canUseImproved = false;
  3298. }
  3299. }
  3300. #endregion UpdateFlags to packet type conversion
  3301. #region Block Construction
  3302. // TODO: Remove this once we can build compressed updates
  3303. canUseCompressed = false;
  3304. if (!canUseImproved && !canUseCompressed)
  3305. {
  3306. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3307. if (update.Entity is ScenePresence)
  3308. {
  3309. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3310. }
  3311. else
  3312. {
  3313. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3314. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3315. // If the part has become a private hud since the update was scheduled then we do not
  3316. // want to send it to other avatars.
  3317. if (part.ParentGroup.IsAttachment
  3318. && part.ParentGroup.HasPrivateAttachmentPoint
  3319. && part.ParentGroup.AttachedAvatar != AgentId)
  3320. continue;
  3321. // If the part has since been deleted, then drop the update. In the case of attachments,
  3322. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3323. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3324. // of the test above).
  3325. //
  3326. // Actual deletions (kills) happen in another method.
  3327. if (part.ParentGroup.IsDeleted)
  3328. continue;
  3329. }
  3330. objectUpdateBlocks.Value.Add(updateBlock);
  3331. objectUpdates.Value.Add(update);
  3332. }
  3333. else if (!canUseImproved)
  3334. {
  3335. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3336. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3337. = CreateCompressedUpdateBlock(part, updateFlags);
  3338. // If the part has since been deleted, then drop the update. In the case of attachments,
  3339. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3340. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3341. // of the test above).
  3342. //
  3343. // Actual deletions (kills) happen in another method.
  3344. if (part.ParentGroup.IsDeleted)
  3345. continue;
  3346. compressedUpdateBlocks.Value.Add(compressedBlock);
  3347. compressedUpdates.Value.Add(update);
  3348. }
  3349. else
  3350. {
  3351. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3352. {
  3353. // Self updates go into a special list
  3354. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3355. terseAgentUpdates.Value.Add(update);
  3356. }
  3357. else
  3358. {
  3359. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3360. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3361. // Everything else goes here
  3362. if (update.Entity is SceneObjectPart)
  3363. {
  3364. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3365. // If the part has become a private hud since the update was scheduled then we do not
  3366. // want to send it to other avatars.
  3367. if (part.ParentGroup.IsAttachment
  3368. && part.ParentGroup.HasPrivateAttachmentPoint
  3369. && part.ParentGroup.AttachedAvatar != AgentId)
  3370. continue;
  3371. // If the part has since been deleted, then drop the update. In the case of attachments,
  3372. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3373. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3374. // of the test above).
  3375. //
  3376. // Actual deletions (kills) happen in another method.
  3377. if (part.ParentGroup.IsDeleted)
  3378. continue;
  3379. }
  3380. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3381. terseUpdates.Value.Add(update);
  3382. }
  3383. }
  3384. ++updatesThisCall;
  3385. #endregion Block Construction
  3386. }
  3387. #region Packet Sending
  3388. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3389. if (terseAgentUpdateBlocks.IsValueCreated)
  3390. {
  3391. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3392. ImprovedTerseObjectUpdatePacket packet
  3393. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3394. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3395. packet.RegionData.TimeDilation = timeDilation;
  3396. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3397. for (int i = 0; i < blocks.Count; i++)
  3398. packet.ObjectData[i] = blocks[i];
  3399. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3400. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3401. }
  3402. if (objectUpdateBlocks.IsValueCreated)
  3403. {
  3404. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3405. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3406. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3407. packet.RegionData.TimeDilation = timeDilation;
  3408. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3409. for (int i = 0; i < blocks.Count; i++)
  3410. packet.ObjectData[i] = blocks[i];
  3411. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3412. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3413. }
  3414. if (compressedUpdateBlocks.IsValueCreated)
  3415. {
  3416. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3417. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3418. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3419. packet.RegionData.TimeDilation = timeDilation;
  3420. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3421. for (int i = 0; i < blocks.Count; i++)
  3422. packet.ObjectData[i] = blocks[i];
  3423. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3424. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3425. }
  3426. if (terseUpdateBlocks.IsValueCreated)
  3427. {
  3428. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3429. ImprovedTerseObjectUpdatePacket packet
  3430. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3431. PacketType.ImprovedTerseObjectUpdate);
  3432. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3433. packet.RegionData.TimeDilation = timeDilation;
  3434. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3435. for (int i = 0; i < blocks.Count; i++)
  3436. packet.ObjectData[i] = blocks[i];
  3437. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3438. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3439. }
  3440. }
  3441. #endregion Packet Sending
  3442. }
  3443. public void ReprioritizeUpdates()
  3444. {
  3445. lock (m_entityUpdates.SyncRoot)
  3446. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3447. }
  3448. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3449. {
  3450. if (entity != null)
  3451. {
  3452. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3453. return true;
  3454. }
  3455. return false;
  3456. }
  3457. public void FlushPrimUpdates()
  3458. {
  3459. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3460. while (m_entityUpdates.Count > 0)
  3461. ProcessEntityUpdates(-1);
  3462. }
  3463. #endregion Primitive Packet/Data Sending Methods
  3464. // These are used to implement an adaptive backoff in the number
  3465. // of updates converted to packets. Since we don't want packets
  3466. // to sit in the queue with old data, only convert enough updates
  3467. // to packets that can be sent in 200ms.
  3468. private Int32 m_LastQueueFill = 0;
  3469. private Int32 m_maxUpdates = 0;
  3470. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3471. {
  3472. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3473. {
  3474. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3475. {
  3476. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3477. }
  3478. else
  3479. {
  3480. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3481. m_maxUpdates += 5;
  3482. else
  3483. m_maxUpdates = m_maxUpdates >> 1;
  3484. }
  3485. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3486. m_LastQueueFill = Util.EnvironmentTickCount();
  3487. if (m_entityUpdates.Count > 0)
  3488. ProcessEntityUpdates(m_maxUpdates);
  3489. if (m_entityProps.Count > 0)
  3490. ProcessEntityPropertyRequests(m_maxUpdates);
  3491. }
  3492. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3493. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3494. }
  3495. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3496. {
  3497. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3498. newPack.AssetBlock.Type = AssetType;
  3499. newPack.AssetBlock.Success = Success;
  3500. newPack.AssetBlock.UUID = AssetFullID;
  3501. newPack.Header.Zerocoded = true;
  3502. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3503. }
  3504. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3505. {
  3506. RequestXferPacket newPack = new RequestXferPacket();
  3507. newPack.XferID.ID = XferID;
  3508. newPack.XferID.VFileType = AssetType;
  3509. newPack.XferID.VFileID = vFileID;
  3510. newPack.XferID.FilePath = FilePath;
  3511. newPack.XferID.Filename = FileName;
  3512. newPack.Header.Zerocoded = true;
  3513. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3514. }
  3515. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3516. {
  3517. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3518. newPack.XferID.ID = xferID;
  3519. newPack.XferID.Packet = PacketID;
  3520. newPack.Header.Zerocoded = true;
  3521. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3522. }
  3523. public void SendInitiateDownload(string simFileName, string clientFileName)
  3524. {
  3525. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3526. newPack.AgentData.AgentID = AgentId;
  3527. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3528. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3529. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3530. }
  3531. public void SendImageFirstPart(
  3532. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3533. {
  3534. ImageDataPacket im = new ImageDataPacket();
  3535. im.Header.Reliable = false;
  3536. im.ImageID.Packets = numParts;
  3537. im.ImageID.ID = ImageUUID;
  3538. if (ImageSize > 0)
  3539. im.ImageID.Size = ImageSize;
  3540. im.ImageData.Data = ImageData;
  3541. im.ImageID.Codec = imageCodec;
  3542. im.Header.Zerocoded = true;
  3543. OutPacket(im, ThrottleOutPacketType.Texture);
  3544. }
  3545. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3546. {
  3547. ImagePacketPacket im = new ImagePacketPacket();
  3548. im.Header.Reliable = false;
  3549. im.ImageID.Packet = partNumber;
  3550. im.ImageID.ID = imageUuid;
  3551. im.ImageData.Data = imageData;
  3552. OutPacket(im, ThrottleOutPacketType.Texture);
  3553. }
  3554. public void SendImageNotFound(UUID imageid)
  3555. {
  3556. ImageNotInDatabasePacket notFoundPacket
  3557. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3558. notFoundPacket.ImageID.ID = imageid;
  3559. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3560. }
  3561. public void SendShutdownConnectionNotice()
  3562. {
  3563. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3564. }
  3565. public void SendSimStats(SimStats stats)
  3566. {
  3567. SimStatsPacket pack = new SimStatsPacket();
  3568. pack.Region = new SimStatsPacket.RegionBlock();
  3569. pack.Region.RegionX = stats.RegionX;
  3570. pack.Region.RegionY = stats.RegionY;
  3571. pack.Region.RegionFlags = stats.RegionFlags;
  3572. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3573. //pack.Region = //stats.RegionBlock;
  3574. pack.Stat = stats.StatsBlock;
  3575. pack.Header.Reliable = false;
  3576. OutPacket(pack, ThrottleOutPacketType.Task);
  3577. }
  3578. private class ObjectPropertyUpdate : IEntityUpdate
  3579. {
  3580. internal bool SendFamilyProps;
  3581. internal bool SendObjectProps;
  3582. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3583. : base(entity,flags)
  3584. {
  3585. SendFamilyProps = sendfam;
  3586. SendObjectProps = sendobj;
  3587. }
  3588. public void Update(ObjectPropertyUpdate update)
  3589. {
  3590. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3591. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3592. // other properties may need to be updated by base class
  3593. base.Update(update);
  3594. }
  3595. }
  3596. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3597. {
  3598. uint priority = 0; // time based ordering only
  3599. lock (m_entityProps.SyncRoot)
  3600. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3601. }
  3602. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3603. {
  3604. uint priority = 0;
  3605. lock (m_entityProps.SyncRoot)
  3606. m_entityProps.Enqueue(priority, update);
  3607. }
  3608. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3609. {
  3610. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3611. // Remove the update packet from the list of packets waiting for acknowledgement
  3612. // because we are requeuing the list of updates. They will be resent in new packets
  3613. // with the most recent state.
  3614. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3615. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3616. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3617. foreach (ObjectPropertyUpdate update in updates)
  3618. ResendPropertyUpdate(update);
  3619. }
  3620. public void SendObjectPropertiesReply(ISceneEntity entity)
  3621. {
  3622. uint priority = 0; // time based ordering only
  3623. lock (m_entityProps.SyncRoot)
  3624. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3625. }
  3626. private void ProcessEntityPropertyRequests(int maxUpdates)
  3627. {
  3628. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3629. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3630. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3631. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3632. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3633. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3634. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3635. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3636. IEntityUpdate iupdate;
  3637. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3638. int updatesThisCall = 0;
  3639. while (updatesThisCall < m_maxUpdates)
  3640. {
  3641. lock (m_entityProps.SyncRoot)
  3642. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3643. break;
  3644. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3645. if (update.SendFamilyProps)
  3646. {
  3647. if (update.Entity is SceneObjectPart)
  3648. {
  3649. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3650. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3651. objectFamilyBlocks.Value.Add(objPropDB);
  3652. familyUpdates.Value.Add(update);
  3653. }
  3654. }
  3655. if (update.SendObjectProps)
  3656. {
  3657. if (update.Entity is SceneObjectPart)
  3658. {
  3659. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3660. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3661. objectPropertiesBlocks.Value.Add(objPropDB);
  3662. propertyUpdates.Value.Add(update);
  3663. }
  3664. }
  3665. updatesThisCall++;
  3666. }
  3667. // Int32 ppcnt = 0;
  3668. // Int32 pbcnt = 0;
  3669. if (objectPropertiesBlocks.IsValueCreated)
  3670. {
  3671. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3672. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3673. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3674. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3675. for (int i = 0; i < blocks.Count; i++)
  3676. packet.ObjectData[i] = blocks[i];
  3677. packet.Header.Zerocoded = true;
  3678. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3679. // of the object rather than the properties when the packet was created
  3680. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3681. delegate(OutgoingPacket oPacket)
  3682. {
  3683. ResendPropertyUpdates(updates, oPacket);
  3684. });
  3685. // pbcnt += blocks.Count;
  3686. // ppcnt++;
  3687. }
  3688. // Int32 fpcnt = 0;
  3689. // Int32 fbcnt = 0;
  3690. if (objectFamilyBlocks.IsValueCreated)
  3691. {
  3692. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3693. // one packet per object block... uggh...
  3694. for (int i = 0; i < blocks.Count; i++)
  3695. {
  3696. ObjectPropertiesFamilyPacket packet =
  3697. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3698. packet.ObjectData = blocks[i];
  3699. packet.Header.Zerocoded = true;
  3700. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3701. // of the object rather than the properties when the packet was created
  3702. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3703. updates.Add(familyUpdates.Value[i]);
  3704. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3705. delegate(OutgoingPacket oPacket)
  3706. {
  3707. ResendPropertyUpdates(updates, oPacket);
  3708. });
  3709. // fpcnt++;
  3710. // fbcnt++;
  3711. }
  3712. }
  3713. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3714. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3715. }
  3716. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3717. {
  3718. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3719. block.RequestFlags = requestFlags;
  3720. block.ObjectID = sop.UUID;
  3721. if (sop.OwnerID == sop.GroupID)
  3722. block.OwnerID = UUID.Zero;
  3723. else
  3724. block.OwnerID = sop.OwnerID;
  3725. block.GroupID = sop.GroupID;
  3726. block.BaseMask = sop.BaseMask;
  3727. block.OwnerMask = sop.OwnerMask;
  3728. block.GroupMask = sop.GroupMask;
  3729. block.EveryoneMask = sop.EveryoneMask;
  3730. block.NextOwnerMask = sop.NextOwnerMask;
  3731. // TODO: More properties are needed in SceneObjectPart!
  3732. block.OwnershipCost = sop.OwnershipCost;
  3733. block.SaleType = sop.ObjectSaleType;
  3734. block.SalePrice = sop.SalePrice;
  3735. block.Category = sop.Category;
  3736. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3737. block.Name = Util.StringToBytes256(sop.Name);
  3738. block.Description = Util.StringToBytes256(sop.Description);
  3739. return block;
  3740. }
  3741. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3742. {
  3743. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3744. // TODO: don't create new blocks if recycling an old packet
  3745. ObjectPropertiesPacket.ObjectDataBlock block =
  3746. new ObjectPropertiesPacket.ObjectDataBlock();
  3747. block.ObjectID = sop.UUID;
  3748. block.Name = Util.StringToBytes256(sop.Name);
  3749. block.Description = Util.StringToBytes256(sop.Description);
  3750. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3751. block.CreatorID = sop.CreatorID;
  3752. block.GroupID = sop.GroupID;
  3753. block.LastOwnerID = sop.LastOwnerID;
  3754. if (sop.OwnerID == sop.GroupID)
  3755. block.OwnerID = UUID.Zero;
  3756. else
  3757. block.OwnerID = sop.OwnerID;
  3758. block.ItemID = sop.FromUserInventoryItemID;
  3759. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3760. block.FromTaskID = UUID.Zero; // ???
  3761. block.InventorySerial = (short)sop.InventorySerial;
  3762. SceneObjectPart root = sop.ParentGroup.RootPart;
  3763. block.TouchName = Util.StringToBytes256(root.TouchName);
  3764. block.TextureID = new byte[0]; // TextureID ???
  3765. block.SitName = Util.StringToBytes256(root.SitName);
  3766. block.OwnerMask = root.OwnerMask;
  3767. block.NextOwnerMask = root.NextOwnerMask;
  3768. block.GroupMask = root.GroupMask;
  3769. block.EveryoneMask = root.EveryoneMask;
  3770. block.BaseMask = root.BaseMask;
  3771. block.SaleType = root.ObjectSaleType;
  3772. block.SalePrice = root.SalePrice;
  3773. return block;
  3774. }
  3775. #region Estate Data Sending Methods
  3776. private static bool convertParamStringToBool(byte[] field)
  3777. {
  3778. string s = Utils.BytesToString(field);
  3779. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3780. {
  3781. return true;
  3782. }
  3783. return false;
  3784. }
  3785. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3786. {
  3787. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3788. packet.AgentData.TransactionID = UUID.Random();
  3789. packet.AgentData.AgentID = AgentId;
  3790. packet.AgentData.SessionID = SessionId;
  3791. packet.MethodData.Invoice = invoice;
  3792. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3793. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3794. for (int i = 0; i < (6 + Data.Length); i++)
  3795. {
  3796. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3797. }
  3798. int j = 0;
  3799. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3800. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3801. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3802. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3803. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3804. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3805. j = 2; // Agents
  3806. if ((code & 2) != 0)
  3807. j = 3; // Groups
  3808. if ((code & 8) != 0)
  3809. j = 5; // Managers
  3810. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3811. j = 6;
  3812. for (int i = 0; i < Data.Length; i++)
  3813. {
  3814. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3815. }
  3816. packet.ParamList = returnblock;
  3817. packet.Header.Reliable = true;
  3818. OutPacket(packet, ThrottleOutPacketType.Task);
  3819. }
  3820. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3821. {
  3822. List<UUID> BannedUsers = new List<UUID>();
  3823. for (int i = 0; i < bl.Length; i++)
  3824. {
  3825. if (bl[i] == null)
  3826. continue;
  3827. if (bl[i].BannedUserID == UUID.Zero)
  3828. continue;
  3829. BannedUsers.Add(bl[i].BannedUserID);
  3830. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3831. {
  3832. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3833. packet.AgentData.TransactionID = UUID.Random();
  3834. packet.AgentData.AgentID = AgentId;
  3835. packet.AgentData.SessionID = SessionId;
  3836. packet.MethodData.Invoice = invoice;
  3837. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3838. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3839. int j;
  3840. for (j = 0; j < (6 + BannedUsers.Count); j++)
  3841. {
  3842. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  3843. }
  3844. j = 0;
  3845. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3846. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3847. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3848. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3849. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3850. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3851. foreach (UUID banned in BannedUsers)
  3852. {
  3853. returnblock[j].Parameter = banned.GetBytes(); j++;
  3854. }
  3855. packet.ParamList = returnblock;
  3856. packet.Header.Reliable = true;
  3857. OutPacket(packet, ThrottleOutPacketType.Task);
  3858. BannedUsers.Clear();
  3859. }
  3860. }
  3861. }
  3862. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  3863. {
  3864. RegionInfoPacket rinfopack = new RegionInfoPacket();
  3865. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  3866. rinfopack.AgentData.AgentID = AgentId;
  3867. rinfopack.AgentData.SessionID = SessionId;
  3868. rinfoblk.BillableFactor = args.billableFactor;
  3869. rinfoblk.EstateID = args.estateID;
  3870. rinfoblk.MaxAgents = args.maxAgents;
  3871. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  3872. rinfoblk.ParentEstateID = args.parentEstateID;
  3873. rinfoblk.PricePerMeter = args.pricePerMeter;
  3874. rinfoblk.RedirectGridX = args.redirectGridX;
  3875. rinfoblk.RedirectGridY = args.redirectGridY;
  3876. rinfoblk.RegionFlags = args.regionFlags;
  3877. rinfoblk.SimAccess = args.simAccess;
  3878. rinfoblk.SunHour = args.sunHour;
  3879. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  3880. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  3881. rinfoblk.UseEstateSun = args.useEstateSun;
  3882. rinfoblk.WaterHeight = args.waterHeight;
  3883. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  3884. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  3885. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  3886. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  3887. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  3888. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  3889. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  3890. rinfopack.HasVariableBlocks = true;
  3891. rinfopack.RegionInfo = rinfoblk;
  3892. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  3893. rinfopack.AgentData.AgentID = AgentId;
  3894. rinfopack.AgentData.SessionID = SessionId;
  3895. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  3896. }
  3897. public void SendEstateCovenantInformation(UUID covenant)
  3898. {
  3899. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  3900. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  3901. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  3902. edata.CovenantID = covenant;
  3903. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  3904. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  3905. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  3906. einfopack.Data = edata;
  3907. OutPacket(einfopack, ThrottleOutPacketType.Task);
  3908. }
  3909. public void SendDetailedEstateData(
  3910. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  3911. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  3912. {
  3913. // m_log.DebugFormat(
  3914. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  3915. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3916. packet.MethodData.Invoice = invoice;
  3917. packet.AgentData.TransactionID = UUID.Random();
  3918. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  3919. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  3920. for (int i = 0; i < 10; i++)
  3921. {
  3922. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3923. }
  3924. //Sending Estate Settings
  3925. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  3926. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  3927. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  3928. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  3929. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  3930. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  3931. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  3932. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  3933. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  3934. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  3935. packet.ParamList = returnblock;
  3936. packet.Header.Reliable = false;
  3937. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  3938. OutPacket(packet, ThrottleOutPacketType.Task);
  3939. }
  3940. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  3941. {
  3942. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  3943. packet.TelehubBlock.ObjectID = ObjectID;
  3944. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  3945. packet.TelehubBlock.TelehubPos = ObjectPos;
  3946. packet.TelehubBlock.TelehubRot = ObjectRot;
  3947. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  3948. for (int n = 0; n < SpawnPoint.Count; n++)
  3949. {
  3950. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  3951. }
  3952. OutPacket(packet, ThrottleOutPacketType.Task);
  3953. }
  3954. #endregion
  3955. #region Land Data Sending Methods
  3956. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  3957. {
  3958. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  3959. packet.ParcelData.Data = data;
  3960. packet.ParcelData.SequenceID = sequence_id;
  3961. packet.Header.Zerocoded = true;
  3962. OutPacket(packet, ThrottleOutPacketType.Task);
  3963. }
  3964. public void SendLandProperties(
  3965. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  3966. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  3967. {
  3968. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  3969. LandData landData = lo.LandData;
  3970. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  3971. updateMessage.AABBMax = landData.AABBMax;
  3972. updateMessage.AABBMin = landData.AABBMin;
  3973. updateMessage.Area = landData.Area;
  3974. updateMessage.AuctionID = landData.AuctionID;
  3975. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  3976. updateMessage.Bitmap = landData.Bitmap;
  3977. updateMessage.Desc = landData.Description;
  3978. updateMessage.Category = landData.Category;
  3979. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  3980. updateMessage.ClaimPrice = landData.ClaimPrice;
  3981. updateMessage.GroupID = landData.GroupID;
  3982. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  3983. updateMessage.LandingType = (LandingType) landData.LandingType;
  3984. updateMessage.LocalID = landData.LocalID;
  3985. if (landData.Area > 0)
  3986. {
  3987. updateMessage.MaxPrims = parcelObjectCapacity;
  3988. }
  3989. else
  3990. {
  3991. updateMessage.MaxPrims = 0;
  3992. }
  3993. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  3994. updateMessage.MediaID = landData.MediaID;
  3995. updateMessage.MediaURL = landData.MediaURL;
  3996. updateMessage.MusicURL = landData.MusicURL;
  3997. updateMessage.Name = landData.Name;
  3998. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  3999. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4000. updateMessage.OwnerID = landData.OwnerID;
  4001. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4002. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4003. updateMessage.PassHours = landData.PassHours;
  4004. updateMessage.PassPrice = landData.PassPrice;
  4005. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4006. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4007. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4008. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4009. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4010. updateMessage.RentPrice = 0;
  4011. updateMessage.RequestResult = (ParcelResult) request_result;
  4012. updateMessage.SalePrice = landData.SalePrice;
  4013. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4014. updateMessage.SequenceID = sequence_id;
  4015. if (landData.SimwideArea > 0)
  4016. {
  4017. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4018. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4019. }
  4020. else
  4021. {
  4022. updateMessage.SimWideMaxPrims = 0;
  4023. }
  4024. updateMessage.SnapSelection = snap_selection;
  4025. updateMessage.SnapshotID = landData.SnapshotID;
  4026. updateMessage.Status = (ParcelStatus) landData.Status;
  4027. updateMessage.UserLocation = landData.UserLocation;
  4028. updateMessage.UserLookAt = landData.UserLookAt;
  4029. updateMessage.MediaType = landData.MediaType;
  4030. updateMessage.MediaDesc = landData.MediaDescription;
  4031. updateMessage.MediaWidth = landData.MediaWidth;
  4032. updateMessage.MediaHeight = landData.MediaHeight;
  4033. updateMessage.MediaLoop = landData.MediaLoop;
  4034. updateMessage.ObscureMusic = landData.ObscureMusic;
  4035. updateMessage.ObscureMedia = landData.ObscureMedia;
  4036. IPrimCounts pc = lo.PrimCounts;
  4037. updateMessage.OwnerPrims = pc.Owner;
  4038. updateMessage.GroupPrims = pc.Group;
  4039. updateMessage.OtherPrims = pc.Others;
  4040. updateMessage.SelectedPrims = pc.Selected;
  4041. updateMessage.TotalPrims = pc.Total;
  4042. updateMessage.SimWideTotalPrims = pc.Simulator;
  4043. try
  4044. {
  4045. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4046. if (eq != null)
  4047. {
  4048. eq.ParcelProperties(updateMessage, this.AgentId);
  4049. }
  4050. else
  4051. {
  4052. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4053. }
  4054. }
  4055. catch (Exception ex)
  4056. {
  4057. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4058. }
  4059. }
  4060. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4061. {
  4062. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4063. replyPacket.Data.AgentID = AgentId;
  4064. replyPacket.Data.Flags = accessFlag;
  4065. replyPacket.Data.LocalID = localLandID;
  4066. replyPacket.Data.SequenceID = 0;
  4067. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4068. foreach (LandAccessEntry entry in accessList)
  4069. {
  4070. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4071. block.Flags = accessFlag;
  4072. block.ID = entry.AgentID;
  4073. block.Time = entry.Expires;
  4074. list.Add(block);
  4075. }
  4076. replyPacket.List = list.ToArray();
  4077. replyPacket.Header.Zerocoded = true;
  4078. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4079. }
  4080. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4081. {
  4082. m_log.WarnFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4083. bool firstCall = true;
  4084. const int MAX_OBJECTS_PER_PACKET = 251;
  4085. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4086. ForceObjectSelectPacket.DataBlock[] data;
  4087. while (ObjectIDs.Count > 0)
  4088. {
  4089. if (firstCall)
  4090. {
  4091. pack._Header.ResetList = true;
  4092. firstCall = false;
  4093. }
  4094. else
  4095. {
  4096. pack._Header.ResetList = false;
  4097. }
  4098. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4099. {
  4100. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4101. }
  4102. else
  4103. {
  4104. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4105. }
  4106. int i;
  4107. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4108. {
  4109. data[i] = new ForceObjectSelectPacket.DataBlock();
  4110. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4111. ObjectIDs.RemoveAt(0);
  4112. }
  4113. pack.Data = data;
  4114. pack.Header.Zerocoded = true;
  4115. OutPacket(pack, ThrottleOutPacketType.Task);
  4116. }
  4117. }
  4118. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4119. {
  4120. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4121. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4122. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4123. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4124. OutPacket(cpack, ThrottleOutPacketType.Task);
  4125. }
  4126. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4127. {
  4128. int notifyCount = ownersAndCount.Count;
  4129. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4130. if (notifyCount > 0)
  4131. {
  4132. if (notifyCount > 32)
  4133. {
  4134. m_log.InfoFormat(
  4135. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4136. + " - a developer might want to investigate whether this is a hard limit", 32);
  4137. notifyCount = 32;
  4138. }
  4139. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4140. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4141. int num = 0;
  4142. foreach (UUID owner in ownersAndCount.Keys)
  4143. {
  4144. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4145. dataBlock[num].Count = ownersAndCount[owner];
  4146. if (land.GroupID == owner || groups.Contains(owner))
  4147. dataBlock[num].IsGroupOwned = true;
  4148. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4149. dataBlock[num].OwnerID = owner;
  4150. num++;
  4151. if (num >= notifyCount)
  4152. {
  4153. break;
  4154. }
  4155. }
  4156. pack.Data = dataBlock;
  4157. }
  4158. else
  4159. {
  4160. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4161. }
  4162. pack.Header.Zerocoded = true;
  4163. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4164. }
  4165. #endregion
  4166. #region Helper Methods
  4167. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4168. {
  4169. #region ScenePresence/SOP Handling
  4170. bool avatar = (entity is ScenePresence);
  4171. uint localID = entity.LocalId;
  4172. uint attachPoint;
  4173. Vector4 collisionPlane;
  4174. Vector3 position, velocity, acceleration, angularVelocity;
  4175. Quaternion rotation;
  4176. byte[] textureEntry;
  4177. if (entity is ScenePresence)
  4178. {
  4179. ScenePresence presence = (ScenePresence)entity;
  4180. attachPoint = 0;
  4181. collisionPlane = presence.CollisionPlane;
  4182. position = presence.OffsetPosition;
  4183. velocity = presence.Velocity;
  4184. acceleration = Vector3.Zero;
  4185. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4186. // in that direction, even though we don't model this on the server. Implementing this in the future
  4187. // may improve movement smoothness.
  4188. // acceleration = new Vector3(1, 0, 0);
  4189. angularVelocity = Vector3.Zero;
  4190. rotation = presence.Rotation;
  4191. if (sendTexture)
  4192. textureEntry = presence.Appearance.Texture.GetBytes();
  4193. else
  4194. textureEntry = null;
  4195. }
  4196. else
  4197. {
  4198. SceneObjectPart part = (SceneObjectPart)entity;
  4199. attachPoint = part.ParentGroup.AttachmentPoint;
  4200. // m_log.DebugFormat(
  4201. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4202. // attachPoint, part.Name, part.LocalId, Name);
  4203. collisionPlane = Vector4.Zero;
  4204. position = part.RelativePosition;
  4205. velocity = part.Velocity;
  4206. acceleration = part.Acceleration;
  4207. angularVelocity = part.AngularVelocity;
  4208. rotation = part.RotationOffset;
  4209. if (sendTexture)
  4210. textureEntry = part.Shape.TextureEntry;
  4211. else
  4212. textureEntry = null;
  4213. }
  4214. #endregion ScenePresence/SOP Handling
  4215. int pos = 0;
  4216. byte[] data = new byte[(avatar ? 60 : 44)];
  4217. // LocalID
  4218. Utils.UIntToBytes(localID, data, pos);
  4219. pos += 4;
  4220. // Avatar/CollisionPlane
  4221. data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ;
  4222. if (avatar)
  4223. {
  4224. data[pos++] = 1;
  4225. if (collisionPlane == Vector4.Zero)
  4226. collisionPlane = Vector4.UnitW;
  4227. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4228. collisionPlane.ToBytes(data, pos);
  4229. pos += 16;
  4230. }
  4231. else
  4232. {
  4233. ++pos;
  4234. }
  4235. // Position
  4236. position.ToBytes(data, pos);
  4237. pos += 12;
  4238. // Velocity
  4239. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4240. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4241. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4242. // Acceleration
  4243. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4244. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4245. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4246. // Rotation
  4247. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4248. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4249. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4250. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4251. // Angular Velocity
  4252. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4253. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4254. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4255. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4256. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4257. block.Data = data;
  4258. if (textureEntry != null && textureEntry.Length > 0)
  4259. {
  4260. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4261. // Texture Length
  4262. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4263. // Texture
  4264. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4265. block.TextureEntry = teBytesFinal;
  4266. }
  4267. else
  4268. {
  4269. block.TextureEntry = Utils.EmptyBytes;
  4270. }
  4271. return block;
  4272. }
  4273. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4274. {
  4275. byte[] objectData = new byte[76];
  4276. data.CollisionPlane.ToBytes(objectData, 0);
  4277. data.OffsetPosition.ToBytes(objectData, 16);
  4278. // data.Velocity.ToBytes(objectData, 28);
  4279. // data.Acceleration.ToBytes(objectData, 40);
  4280. data.Rotation.ToBytes(objectData, 52);
  4281. //data.AngularVelocity.ToBytes(objectData, 64);
  4282. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4283. update.Data = Utils.EmptyBytes;
  4284. update.ExtraParams = new byte[1];
  4285. update.FullID = data.UUID;
  4286. update.ID = data.LocalId;
  4287. update.Material = (byte)Material.Flesh;
  4288. update.MediaURL = Utils.EmptyBytes;
  4289. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4290. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4291. update.ObjectData = objectData;
  4292. update.ParentID = data.ParentID;
  4293. update.PathCurve = 16;
  4294. update.PathScaleX = 100;
  4295. update.PathScaleY = 100;
  4296. update.PCode = (byte)PCode.Avatar;
  4297. update.ProfileCurve = 1;
  4298. update.PSBlock = Utils.EmptyBytes;
  4299. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4300. update.Text = Utils.EmptyBytes;
  4301. update.TextColor = new byte[4];
  4302. // Don't send texture anim for avatars - this has no meaning for them.
  4303. update.TextureAnim = Utils.EmptyBytes;
  4304. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4305. update.TextureEntry = Utils.EmptyBytes;
  4306. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4307. update.UpdateFlags = (uint)(
  4308. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4309. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4310. PrimFlags.ObjectOwnerModify);
  4311. return update;
  4312. }
  4313. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4314. {
  4315. byte[] objectData = new byte[60];
  4316. data.RelativePosition.ToBytes(objectData, 0);
  4317. data.Velocity.ToBytes(objectData, 12);
  4318. data.Acceleration.ToBytes(objectData, 24);
  4319. try
  4320. {
  4321. data.RotationOffset.ToBytes(objectData, 36);
  4322. }
  4323. catch (Exception e)
  4324. {
  4325. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4326. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4327. }
  4328. data.AngularVelocity.ToBytes(objectData, 48);
  4329. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4330. update.ClickAction = (byte)data.ClickAction;
  4331. update.CRC = 0;
  4332. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4333. update.FullID = data.UUID;
  4334. update.ID = data.LocalId;
  4335. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4336. //update.JointPivot = Vector3.Zero;
  4337. //update.JointType = 0;
  4338. update.Material = data.Material;
  4339. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4340. if (data.ParentGroup.IsAttachment)
  4341. {
  4342. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4343. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4344. }
  4345. else
  4346. {
  4347. update.NameValue = Utils.EmptyBytes;
  4348. // The root part state is the canonical state for all parts of the object. The other part states in the
  4349. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4350. update.State = data.ParentGroup.RootPart.Shape.State;
  4351. }
  4352. // m_log.DebugFormat(
  4353. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4354. // update.State, data.Name, data.LocalId, Name);
  4355. update.ObjectData = objectData;
  4356. update.ParentID = data.ParentID;
  4357. update.PathBegin = data.Shape.PathBegin;
  4358. update.PathCurve = data.Shape.PathCurve;
  4359. update.PathEnd = data.Shape.PathEnd;
  4360. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4361. update.PathRevolutions = data.Shape.PathRevolutions;
  4362. update.PathScaleX = data.Shape.PathScaleX;
  4363. update.PathScaleY = data.Shape.PathScaleY;
  4364. update.PathShearX = data.Shape.PathShearX;
  4365. update.PathShearY = data.Shape.PathShearY;
  4366. update.PathSkew = data.Shape.PathSkew;
  4367. update.PathTaperX = data.Shape.PathTaperX;
  4368. update.PathTaperY = data.Shape.PathTaperY;
  4369. update.PathTwist = data.Shape.PathTwist;
  4370. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4371. update.PCode = data.Shape.PCode;
  4372. update.ProfileBegin = data.Shape.ProfileBegin;
  4373. update.ProfileCurve = data.Shape.ProfileCurve;
  4374. update.ProfileEnd = data.Shape.ProfileEnd;
  4375. update.ProfileHollow = data.Shape.ProfileHollow;
  4376. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4377. update.TextColor = data.GetTextColor().GetBytes(false);
  4378. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4379. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4380. update.Scale = data.Shape.Scale;
  4381. update.Text = Util.StringToBytes256(data.Text);
  4382. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4383. #region PrimFlags
  4384. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4385. // Don't send the CreateSelected flag to everyone
  4386. flags &= ~PrimFlags.CreateSelected;
  4387. if (recipientID == data.OwnerID)
  4388. {
  4389. if (data.CreateSelected)
  4390. {
  4391. // Only send this flag once, then unset it
  4392. flags |= PrimFlags.CreateSelected;
  4393. data.CreateSelected = false;
  4394. }
  4395. }
  4396. // m_log.DebugFormat(
  4397. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4398. // data.Name, update.FullID, flags, update.ID);
  4399. update.UpdateFlags = (uint)flags;
  4400. #endregion PrimFlags
  4401. if (data.Sound != UUID.Zero)
  4402. {
  4403. update.Sound = data.Sound;
  4404. update.OwnerID = data.OwnerID;
  4405. update.Gain = (float)data.SoundGain;
  4406. update.Radius = (float)data.SoundRadius;
  4407. update.Flags = data.SoundFlags;
  4408. }
  4409. switch ((PCode)data.Shape.PCode)
  4410. {
  4411. case PCode.Grass:
  4412. case PCode.Tree:
  4413. case PCode.NewTree:
  4414. update.Data = new byte[] { data.Shape.State };
  4415. break;
  4416. default:
  4417. update.Data = Utils.EmptyBytes;
  4418. break;
  4419. }
  4420. return update;
  4421. }
  4422. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4423. {
  4424. // TODO: Implement this
  4425. return null;
  4426. }
  4427. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4428. {
  4429. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4430. // TODO: don't create new blocks if recycling an old packet
  4431. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4432. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4433. packet.UUIDNameBlock[0].ID = profileId;
  4434. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4435. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4436. OutPacket(packet, ThrottleOutPacketType.Task);
  4437. }
  4438. public ulong GetGroupPowers(UUID groupID)
  4439. {
  4440. if (groupID == m_activeGroupID)
  4441. return m_activeGroupPowers;
  4442. if (m_groupPowers.ContainsKey(groupID))
  4443. return m_groupPowers[groupID];
  4444. return 0;
  4445. }
  4446. #endregion
  4447. /// <summary>
  4448. /// This is a different way of processing packets then ProcessInPacket
  4449. /// </summary>
  4450. protected virtual void RegisterLocalPacketHandlers()
  4451. {
  4452. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4453. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4454. // for each AgentUpdate packet.
  4455. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4456. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4457. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4458. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4459. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4460. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4461. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4462. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4463. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4464. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4465. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4466. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4467. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4468. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4469. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4470. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4471. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4472. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4473. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4474. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4475. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply);
  4476. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4477. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4478. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4479. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4480. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4481. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4482. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4483. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4484. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4485. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4486. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4487. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4488. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4489. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4490. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4491. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4492. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4493. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4494. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4495. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4496. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4497. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4498. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4499. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4500. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4501. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4502. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4503. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4504. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4505. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4506. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4507. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4508. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4509. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4510. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4511. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4512. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4513. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4514. // some clients will send out a separate ObjectImage packet for each face
  4515. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4516. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4517. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4518. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4519. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4520. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4521. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4522. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4523. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4524. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4525. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4526. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4527. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4528. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4529. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4530. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4531. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4532. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4533. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4534. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage);
  4535. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest);
  4536. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4537. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4538. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4539. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4540. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4541. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4542. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4543. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4544. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4545. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4546. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4547. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4548. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4549. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4550. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4551. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4552. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4553. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4554. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4555. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4556. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4557. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4558. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4559. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4560. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4561. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4562. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4563. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4564. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4565. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4566. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4567. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest);
  4568. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4569. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4570. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4571. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4572. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4573. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4574. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4575. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4576. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4577. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4578. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4579. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4580. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4581. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4582. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4583. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4584. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4585. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4586. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4587. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4588. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4589. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4590. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4591. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4592. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4593. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4594. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4595. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4596. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4597. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4598. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4599. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4600. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4601. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4602. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4603. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4604. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4605. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4606. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4607. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4608. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4609. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4610. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4611. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4612. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4613. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4614. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4615. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4616. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4617. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4618. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4619. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4620. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4621. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4622. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4623. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4624. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4625. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4626. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4627. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4628. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4629. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4630. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4631. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4632. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4633. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4634. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4635. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4636. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4637. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4638. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4639. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4640. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4641. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4642. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4643. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4644. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4645. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4646. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4647. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4648. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4649. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4650. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4651. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4652. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4653. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4654. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4655. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4656. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4657. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4658. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4659. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4660. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4661. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4662. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4663. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4664. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4665. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4666. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4667. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4668. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4669. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4670. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4671. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4672. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4673. }
  4674. #region Packet Handlers
  4675. #region Scene/Avatar
  4676. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4677. {
  4678. if (OnAgentUpdate != null)
  4679. {
  4680. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4681. #region Packet Session and User Check
  4682. if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId)
  4683. {
  4684. PacketPool.Instance.ReturnPacket(packet);
  4685. return false;
  4686. }
  4687. #endregion
  4688. bool update = false;
  4689. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4690. if (m_lastAgentUpdateArgs != null)
  4691. {
  4692. // These should be ordered from most-likely to
  4693. // least likely to change. I've made an initial
  4694. // guess at that.
  4695. update =
  4696. (
  4697. (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) ||
  4698. (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) ||
  4699. (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) ||
  4700. (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) ||
  4701. (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) ||
  4702. (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) ||
  4703. (x.Far != m_lastAgentUpdateArgs.Far) ||
  4704. (x.Flags != m_lastAgentUpdateArgs.Flags) ||
  4705. (x.State != m_lastAgentUpdateArgs.State) ||
  4706. (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) ||
  4707. (x.SessionID != m_lastAgentUpdateArgs.SessionID) ||
  4708. (x.AgentID != m_lastAgentUpdateArgs.AgentID)
  4709. );
  4710. }
  4711. else
  4712. {
  4713. m_lastAgentUpdateArgs = new AgentUpdateArgs();
  4714. update = true;
  4715. }
  4716. if (update)
  4717. {
  4718. // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
  4719. m_lastAgentUpdateArgs.AgentID = x.AgentID;
  4720. m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4721. m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4722. m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4723. m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4724. m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4725. m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4726. m_lastAgentUpdateArgs.Far = x.Far;
  4727. m_lastAgentUpdateArgs.Flags = x.Flags;
  4728. m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4729. m_lastAgentUpdateArgs.SessionID = x.SessionID;
  4730. m_lastAgentUpdateArgs.State = x.State;
  4731. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4732. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4733. if (handlerPreAgentUpdate != null)
  4734. OnPreAgentUpdate(this, m_lastAgentUpdateArgs);
  4735. if (handlerAgentUpdate != null)
  4736. OnAgentUpdate(this, m_lastAgentUpdateArgs);
  4737. handlerAgentUpdate = null;
  4738. handlerPreAgentUpdate = null;
  4739. }
  4740. }
  4741. PacketPool.Instance.ReturnPacket(packet);
  4742. return true;
  4743. }
  4744. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4745. {
  4746. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4747. // validate the agent owns the agentID and sessionID
  4748. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4749. money.AgentData.SessionID == sender.SessionId)
  4750. {
  4751. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4752. if (handlerMoneyTransferRequest != null)
  4753. {
  4754. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4755. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4756. Util.FieldToString(money.MoneyData.Description));
  4757. }
  4758. return true;
  4759. }
  4760. return false;
  4761. }
  4762. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4763. {
  4764. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4765. (ParcelGodMarkAsContentPacket)Packet;
  4766. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4767. if (ParcelGodMarkAsContentHandler != null)
  4768. {
  4769. ParcelGodMarkAsContentHandler(this,
  4770. ParcelGodMarkAsContent.AgentData.AgentID,
  4771. ParcelGodMarkAsContent.ParcelData.LocalID);
  4772. return true;
  4773. }
  4774. return false;
  4775. }
  4776. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  4777. {
  4778. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  4779. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  4780. if (FreezeUserHandler != null)
  4781. {
  4782. FreezeUserHandler(this,
  4783. FreezeUser.AgentData.AgentID,
  4784. FreezeUser.Data.Flags,
  4785. FreezeUser.Data.TargetID);
  4786. return true;
  4787. }
  4788. return false;
  4789. }
  4790. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  4791. {
  4792. EjectUserPacket EjectUser =
  4793. (EjectUserPacket)Packet;
  4794. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  4795. if (EjectUserHandler != null)
  4796. {
  4797. EjectUserHandler(this,
  4798. EjectUser.AgentData.AgentID,
  4799. EjectUser.Data.Flags,
  4800. EjectUser.Data.TargetID);
  4801. return true;
  4802. }
  4803. return false;
  4804. }
  4805. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  4806. {
  4807. ParcelBuyPassPacket ParcelBuyPass =
  4808. (ParcelBuyPassPacket)Packet;
  4809. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  4810. if (ParcelBuyPassHandler != null)
  4811. {
  4812. ParcelBuyPassHandler(this,
  4813. ParcelBuyPass.AgentData.AgentID,
  4814. ParcelBuyPass.ParcelData.LocalID);
  4815. return true;
  4816. }
  4817. return false;
  4818. }
  4819. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  4820. {
  4821. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  4822. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  4823. {
  4824. ParcelBuy handlerParcelBuy = OnParcelBuy;
  4825. if (handlerParcelBuy != null)
  4826. {
  4827. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  4828. parcel.Data.IsGroupOwned,
  4829. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  4830. parcel.ParcelData.Price,
  4831. false);
  4832. }
  4833. return true;
  4834. }
  4835. return false;
  4836. }
  4837. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  4838. {
  4839. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  4840. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  4841. {
  4842. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  4843. if (handlerUUIDGroupNameRequest != null)
  4844. {
  4845. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  4846. }
  4847. }
  4848. return true;
  4849. }
  4850. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  4851. {
  4852. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  4853. if (m_genericPacketHandlers.Count == 0) return false;
  4854. if (gmpack.AgentData.SessionID != SessionId) return false;
  4855. GenericMessage handlerGenericMessage = null;
  4856. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  4857. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  4858. {
  4859. List<string> msg = new List<string>();
  4860. List<byte[]> msgBytes = new List<byte[]>();
  4861. if (handlerGenericMessage != null)
  4862. {
  4863. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  4864. {
  4865. msg.Add(Util.FieldToString(block.Parameter));
  4866. msgBytes.Add(block.Parameter);
  4867. }
  4868. try
  4869. {
  4870. if (OnBinaryGenericMessage != null)
  4871. {
  4872. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  4873. }
  4874. handlerGenericMessage(sender, method, msg);
  4875. return true;
  4876. }
  4877. catch (Exception e)
  4878. {
  4879. m_log.ErrorFormat(
  4880. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  4881. }
  4882. }
  4883. }
  4884. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  4885. return false;
  4886. }
  4887. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  4888. {
  4889. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  4890. if (ogpack.AgentData.SessionID != SessionId) return false;
  4891. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  4892. if (handlerObjectGroupRequest != null)
  4893. {
  4894. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  4895. {
  4896. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  4897. }
  4898. }
  4899. return true;
  4900. }
  4901. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  4902. {
  4903. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  4904. if (viewer.AgentData.SessionID != SessionId) return false;
  4905. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  4906. if (handlerViewerEffect != null)
  4907. {
  4908. int length = viewer.Effect.Length;
  4909. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  4910. for (int i = 0; i < length; i++)
  4911. {
  4912. //copy the effects block arguments into the event handler arg.
  4913. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  4914. argument.AgentID = viewer.Effect[i].AgentID;
  4915. argument.Color = viewer.Effect[i].Color;
  4916. argument.Duration = viewer.Effect[i].Duration;
  4917. argument.ID = viewer.Effect[i].ID;
  4918. argument.Type = viewer.Effect[i].Type;
  4919. argument.TypeData = viewer.Effect[i].TypeData;
  4920. args.Add(argument);
  4921. }
  4922. handlerViewerEffect(sender, args);
  4923. }
  4924. return true;
  4925. }
  4926. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  4927. {
  4928. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  4929. #region Packet Session and User Check
  4930. if (m_checkPackets)
  4931. {
  4932. if (avatarProperties.AgentData.SessionID != SessionId ||
  4933. avatarProperties.AgentData.AgentID != AgentId)
  4934. return true;
  4935. }
  4936. #endregion
  4937. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  4938. if (handlerRequestAvatarProperties != null)
  4939. {
  4940. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  4941. }
  4942. return true;
  4943. }
  4944. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  4945. {
  4946. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  4947. #region Packet Session and User Check
  4948. if (m_checkPackets)
  4949. {
  4950. if (inchatpack.AgentData.SessionID != SessionId ||
  4951. inchatpack.AgentData.AgentID != AgentId)
  4952. return true;
  4953. }
  4954. #endregion
  4955. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  4956. byte[] message = inchatpack.ChatData.Message;
  4957. byte type = inchatpack.ChatData.Type;
  4958. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  4959. // UUID fromAgentID = AgentId;
  4960. int channel = inchatpack.ChatData.Channel;
  4961. if (OnChatFromClient != null)
  4962. {
  4963. OSChatMessage args = new OSChatMessage();
  4964. args.Channel = channel;
  4965. args.From = fromName;
  4966. args.Message = Utils.BytesToString(message);
  4967. args.Type = (ChatTypeEnum)type;
  4968. args.Position = fromPos;
  4969. args.Scene = Scene;
  4970. args.Sender = this;
  4971. args.SenderUUID = this.AgentId;
  4972. ChatMessage handlerChatFromClient = OnChatFromClient;
  4973. if (handlerChatFromClient != null)
  4974. handlerChatFromClient(this, args);
  4975. }
  4976. return true;
  4977. }
  4978. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  4979. {
  4980. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  4981. #region Packet Session and User Check
  4982. if (m_checkPackets)
  4983. {
  4984. if (avatarProps.AgentData.SessionID != SessionId ||
  4985. avatarProps.AgentData.AgentID != AgentId)
  4986. return true;
  4987. }
  4988. #endregion
  4989. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  4990. if (handlerUpdateAvatarProperties != null)
  4991. {
  4992. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  4993. UserProfileData UserProfile = new UserProfileData();
  4994. UserProfile.ID = AgentId;
  4995. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  4996. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  4997. UserProfile.FirstLifeImage = Properties.FLImageID;
  4998. UserProfile.Image = Properties.ImageID;
  4999. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5000. UserProfile.UserFlags &= ~3;
  5001. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5002. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5003. handlerUpdateAvatarProperties(this, UserProfile);
  5004. }
  5005. return true;
  5006. }
  5007. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5008. {
  5009. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5010. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5011. #region Packet Session and User Check
  5012. if (m_checkPackets)
  5013. {
  5014. if (rdialog.AgentData.SessionID != SessionId ||
  5015. rdialog.AgentData.AgentID != AgentId)
  5016. return true;
  5017. }
  5018. #endregion
  5019. int ch = rdialog.Data.ChatChannel;
  5020. byte[] msg = rdialog.Data.ButtonLabel;
  5021. if (OnChatFromClient != null)
  5022. {
  5023. OSChatMessage args = new OSChatMessage();
  5024. args.Channel = ch;
  5025. args.From = String.Empty;
  5026. args.Message = Utils.BytesToString(msg);
  5027. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5028. args.Position = new Vector3();
  5029. args.Scene = Scene;
  5030. args.Sender = this;
  5031. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5032. if (handlerChatFromClient2 != null)
  5033. handlerChatFromClient2(this, args);
  5034. }
  5035. return true;
  5036. }
  5037. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5038. {
  5039. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5040. #region Packet Session and User Check
  5041. if (m_checkPackets)
  5042. {
  5043. if (msgpack.AgentData.SessionID != SessionId ||
  5044. msgpack.AgentData.AgentID != AgentId)
  5045. return true;
  5046. }
  5047. #endregion
  5048. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5049. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5050. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5051. if (handlerInstantMessage != null)
  5052. {
  5053. GridInstantMessage im = new GridInstantMessage(Scene,
  5054. msgpack.AgentData.AgentID,
  5055. IMfromName,
  5056. msgpack.MessageBlock.ToAgentID,
  5057. msgpack.MessageBlock.Dialog,
  5058. msgpack.MessageBlock.FromGroup,
  5059. IMmessage,
  5060. msgpack.MessageBlock.ID,
  5061. msgpack.MessageBlock.Offline != 0 ? true : false,
  5062. msgpack.MessageBlock.Position,
  5063. msgpack.MessageBlock.BinaryBucket,
  5064. true);
  5065. handlerInstantMessage(this, im);
  5066. }
  5067. return true;
  5068. }
  5069. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5070. {
  5071. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5072. #region Packet Session and User Check
  5073. if (m_checkPackets)
  5074. {
  5075. if (afriendpack.AgentData.SessionID != SessionId ||
  5076. afriendpack.AgentData.AgentID != AgentId)
  5077. return true;
  5078. }
  5079. #endregion
  5080. // My guess is this is the folder to stick the calling card into
  5081. List<UUID> callingCardFolders = new List<UUID>();
  5082. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5083. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5084. {
  5085. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5086. }
  5087. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5088. if (handlerApproveFriendRequest != null)
  5089. {
  5090. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5091. }
  5092. return true;
  5093. }
  5094. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5095. {
  5096. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5097. #region Packet Session and User Check
  5098. if (m_checkPackets)
  5099. {
  5100. if (dfriendpack.AgentData.SessionID != SessionId ||
  5101. dfriendpack.AgentData.AgentID != AgentId)
  5102. return true;
  5103. }
  5104. #endregion
  5105. if (OnDenyFriendRequest != null)
  5106. {
  5107. OnDenyFriendRequest(this,
  5108. dfriendpack.TransactionBlock.TransactionID,
  5109. null);
  5110. }
  5111. return true;
  5112. }
  5113. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5114. {
  5115. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5116. #region Packet Session and User Check
  5117. if (m_checkPackets)
  5118. {
  5119. if (tfriendpack.AgentData.SessionID != SessionId ||
  5120. tfriendpack.AgentData.AgentID != AgentId)
  5121. return true;
  5122. }
  5123. #endregion
  5124. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5125. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5126. if (TerminateFriendshipHandler != null)
  5127. {
  5128. TerminateFriendshipHandler(this, exFriendID);
  5129. return true;
  5130. }
  5131. return false;
  5132. }
  5133. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5134. {
  5135. FindAgentPacket FindAgent =
  5136. (FindAgentPacket)Packet;
  5137. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5138. if (FindAgentHandler != null)
  5139. {
  5140. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5141. return true;
  5142. }
  5143. return false;
  5144. }
  5145. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5146. {
  5147. TrackAgentPacket TrackAgent =
  5148. (TrackAgentPacket)Packet;
  5149. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5150. if (TrackAgentHandler != null)
  5151. {
  5152. TrackAgentHandler(this,
  5153. TrackAgent.AgentData.AgentID,
  5154. TrackAgent.TargetData.PreyID);
  5155. return true;
  5156. }
  5157. return false;
  5158. }
  5159. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5160. {
  5161. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5162. #region Packet Session and User Check
  5163. if (m_checkPackets)
  5164. {
  5165. if (rezPacket.AgentData.SessionID != SessionId ||
  5166. rezPacket.AgentData.AgentID != AgentId)
  5167. return true;
  5168. }
  5169. #endregion
  5170. RezObject handlerRezObject = OnRezObject;
  5171. if (handlerRezObject != null)
  5172. {
  5173. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5174. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5175. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5176. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5177. rezPacket.RezData.FromTaskID);
  5178. }
  5179. return true;
  5180. }
  5181. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5182. {
  5183. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5184. #region Packet Session and User Check
  5185. if (m_checkPackets)
  5186. {
  5187. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5188. DeRezPacket.AgentData.AgentID != AgentId)
  5189. return true;
  5190. }
  5191. #endregion
  5192. DeRezObject handlerDeRezObject = OnDeRezObject;
  5193. if (handlerDeRezObject != null)
  5194. {
  5195. List<uint> deRezIDs = new List<uint>();
  5196. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5197. DeRezPacket.ObjectData)
  5198. {
  5199. deRezIDs.Add(data.ObjectLocalID);
  5200. }
  5201. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5202. // values given by a Second Life client
  5203. handlerDeRezObject(this, deRezIDs,
  5204. DeRezPacket.AgentBlock.GroupID,
  5205. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5206. DeRezPacket.AgentBlock.DestinationID);
  5207. }
  5208. return true;
  5209. }
  5210. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5211. {
  5212. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5213. #region Packet Session and User Check
  5214. if (m_checkPackets)
  5215. {
  5216. if (modify.AgentData.SessionID != SessionId ||
  5217. modify.AgentData.AgentID != AgentId)
  5218. return true;
  5219. }
  5220. #endregion
  5221. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5222. if (modify.ParcelData.Length > 0)
  5223. {
  5224. if (OnModifyTerrain != null)
  5225. {
  5226. for (int i = 0; i < modify.ParcelData.Length; i++)
  5227. {
  5228. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5229. if (handlerModifyTerrain != null)
  5230. {
  5231. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5232. modify.ModifyBlock.BrushSize,
  5233. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5234. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5235. modify.ParcelData[i].East, AgentId);
  5236. }
  5237. }
  5238. }
  5239. }
  5240. return true;
  5241. }
  5242. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5243. {
  5244. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5245. if (handlerRegionHandShakeReply != null)
  5246. {
  5247. handlerRegionHandShakeReply(this);
  5248. }
  5249. return true;
  5250. }
  5251. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5252. {
  5253. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5254. if (handlerRequestWearables != null)
  5255. {
  5256. handlerRequestWearables(sender);
  5257. }
  5258. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5259. if (handlerRequestAvatarsData != null)
  5260. {
  5261. handlerRequestAvatarsData(this);
  5262. }
  5263. return true;
  5264. }
  5265. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5266. {
  5267. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5268. #region Packet Session and User Check
  5269. if (m_checkPackets)
  5270. {
  5271. if (appear.AgentData.SessionID != SessionId ||
  5272. appear.AgentData.AgentID != AgentId)
  5273. return true;
  5274. }
  5275. #endregion
  5276. SetAppearance handlerSetAppearance = OnSetAppearance;
  5277. if (handlerSetAppearance != null)
  5278. {
  5279. // Temporarily protect ourselves from the mantis #951 failure.
  5280. // However, we could do this for several other handlers where a failure isn't terminal
  5281. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5282. try
  5283. {
  5284. byte[] visualparams = new byte[appear.VisualParam.Length];
  5285. for (int i = 0; i < appear.VisualParam.Length; i++)
  5286. visualparams[i] = appear.VisualParam[i].ParamValue;
  5287. Primitive.TextureEntry te = null;
  5288. if (appear.ObjectData.TextureEntry.Length > 1)
  5289. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5290. handlerSetAppearance(sender, te, visualparams);
  5291. }
  5292. catch (Exception e)
  5293. {
  5294. m_log.ErrorFormat(
  5295. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5296. e);
  5297. }
  5298. }
  5299. return true;
  5300. }
  5301. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5302. {
  5303. if (OnAvatarNowWearing != null)
  5304. {
  5305. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5306. #region Packet Session and User Check
  5307. if (m_checkPackets)
  5308. {
  5309. if (nowWearing.AgentData.SessionID != SessionId ||
  5310. nowWearing.AgentData.AgentID != AgentId)
  5311. return true;
  5312. }
  5313. #endregion
  5314. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5315. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5316. {
  5317. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5318. AvatarWearingArgs.Wearable wearable =
  5319. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5320. nowWearing.WearableData[i].WearableType);
  5321. wearingArgs.NowWearing.Add(wearable);
  5322. }
  5323. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5324. if (handlerAvatarNowWearing != null)
  5325. {
  5326. handlerAvatarNowWearing(this, wearingArgs);
  5327. }
  5328. }
  5329. return true;
  5330. }
  5331. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5332. {
  5333. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5334. if (handlerRezSingleAttachment != null)
  5335. {
  5336. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5337. #region Packet Session and User Check
  5338. if (m_checkPackets)
  5339. {
  5340. if (rez.AgentData.SessionID != SessionId ||
  5341. rez.AgentData.AgentID != AgentId)
  5342. return true;
  5343. }
  5344. #endregion
  5345. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5346. rez.ObjectData.AttachmentPt);
  5347. }
  5348. return true;
  5349. }
  5350. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5351. {
  5352. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5353. if (handlerRezMultipleAttachments != null)
  5354. {
  5355. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5356. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5357. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5358. handlerRezMultipleAttachments(this, rezlist);
  5359. }
  5360. return true;
  5361. }
  5362. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5363. {
  5364. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5365. if (handlerDetachAttachmentIntoInv != null)
  5366. {
  5367. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5368. #region Packet Session and User Check
  5369. // UNSUPPORTED ON THIS PACKET
  5370. #endregion
  5371. UUID itemID = detachtoInv.ObjectData.ItemID;
  5372. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5373. handlerDetachAttachmentIntoInv(itemID, this);
  5374. }
  5375. return true;
  5376. }
  5377. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5378. {
  5379. if (OnObjectAttach != null)
  5380. {
  5381. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5382. #region Packet Session and User Check
  5383. if (m_checkPackets)
  5384. {
  5385. if (att.AgentData.SessionID != SessionId ||
  5386. att.AgentData.AgentID != AgentId)
  5387. return true;
  5388. }
  5389. #endregion
  5390. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5391. if (handlerObjectAttach != null)
  5392. {
  5393. if (att.ObjectData.Length > 0)
  5394. {
  5395. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5396. }
  5397. }
  5398. }
  5399. return true;
  5400. }
  5401. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5402. {
  5403. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5404. #region Packet Session and User Check
  5405. if (m_checkPackets)
  5406. {
  5407. if (dett.AgentData.SessionID != SessionId ||
  5408. dett.AgentData.AgentID != AgentId)
  5409. return true;
  5410. }
  5411. #endregion
  5412. for (int j = 0; j < dett.ObjectData.Length; j++)
  5413. {
  5414. uint obj = dett.ObjectData[j].ObjectLocalID;
  5415. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5416. if (handlerObjectDetach != null)
  5417. {
  5418. handlerObjectDetach(obj, this);
  5419. }
  5420. }
  5421. return true;
  5422. }
  5423. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5424. {
  5425. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5426. #region Packet Session and User Check
  5427. if (m_checkPackets)
  5428. {
  5429. if (dropp.AgentData.SessionID != SessionId ||
  5430. dropp.AgentData.AgentID != AgentId)
  5431. return true;
  5432. }
  5433. #endregion
  5434. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5435. {
  5436. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5437. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5438. if (handlerObjectDrop != null)
  5439. {
  5440. handlerObjectDrop(obj, this);
  5441. }
  5442. }
  5443. return true;
  5444. }
  5445. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5446. {
  5447. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5448. #region Packet Session and User Check
  5449. if (m_checkPackets)
  5450. {
  5451. if (run.AgentData.SessionID != SessionId ||
  5452. run.AgentData.AgentID != AgentId)
  5453. return true;
  5454. }
  5455. #endregion
  5456. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5457. if (handlerSetAlwaysRun != null)
  5458. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5459. return true;
  5460. }
  5461. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5462. {
  5463. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5464. if (handlerCompleteMovementToRegion != null)
  5465. {
  5466. handlerCompleteMovementToRegion(sender, true);
  5467. }
  5468. handlerCompleteMovementToRegion = null;
  5469. return true;
  5470. }
  5471. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5472. {
  5473. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5474. #region Packet Session and User Check
  5475. if (m_checkPackets)
  5476. {
  5477. if (AgentAni.AgentData.SessionID != SessionId ||
  5478. AgentAni.AgentData.AgentID != AgentId)
  5479. return true;
  5480. }
  5481. #endregion
  5482. StartAnim handlerStartAnim = null;
  5483. StopAnim handlerStopAnim = null;
  5484. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5485. {
  5486. if (AgentAni.AnimationList[i].StartAnim)
  5487. {
  5488. handlerStartAnim = OnStartAnim;
  5489. if (handlerStartAnim != null)
  5490. {
  5491. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5492. }
  5493. }
  5494. else
  5495. {
  5496. handlerStopAnim = OnStopAnim;
  5497. if (handlerStopAnim != null)
  5498. {
  5499. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5500. }
  5501. }
  5502. }
  5503. return true;
  5504. }
  5505. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5506. {
  5507. if (OnAgentRequestSit != null)
  5508. {
  5509. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5510. #region Packet Session and User Check
  5511. if (m_checkPackets)
  5512. {
  5513. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5514. agentRequestSit.AgentData.AgentID != AgentId)
  5515. return true;
  5516. }
  5517. #endregion
  5518. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5519. if (handlerAgentRequestSit != null)
  5520. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5521. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5522. }
  5523. return true;
  5524. }
  5525. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5526. {
  5527. if (OnAgentSit != null)
  5528. {
  5529. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5530. #region Packet Session and User Check
  5531. if (m_checkPackets)
  5532. {
  5533. if (agentSit.AgentData.SessionID != SessionId ||
  5534. agentSit.AgentData.AgentID != AgentId)
  5535. return true;
  5536. }
  5537. #endregion
  5538. AgentSit handlerAgentSit = OnAgentSit;
  5539. if (handlerAgentSit != null)
  5540. {
  5541. OnAgentSit(this, agentSit.AgentData.AgentID);
  5542. }
  5543. }
  5544. return true;
  5545. }
  5546. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5547. {
  5548. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5549. #region Packet Session and User Check
  5550. if (m_checkPackets)
  5551. {
  5552. // UNSUPPORTED ON THIS PACKET
  5553. }
  5554. #endregion
  5555. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5556. if (handlerSoundTrigger != null)
  5557. {
  5558. // UUIDS are sent as zeroes by the client, substitute agent's id
  5559. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5560. AgentId, AgentId,
  5561. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5562. soundTriggerPacket.SoundData.Handle, 0);
  5563. }
  5564. return true;
  5565. }
  5566. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5567. {
  5568. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5569. #region Packet Session and User Check
  5570. if (m_checkPackets)
  5571. {
  5572. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5573. avRequestQuery.AgentData.AgentID != AgentId)
  5574. return true;
  5575. }
  5576. #endregion
  5577. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5578. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5579. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5580. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5581. if (handlerAvatarPickerRequest != null)
  5582. {
  5583. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5584. Utils.BytesToString(querydata.Name));
  5585. }
  5586. return true;
  5587. }
  5588. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5589. {
  5590. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5591. #region Packet Session and User Check
  5592. if (m_checkPackets)
  5593. {
  5594. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5595. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5596. return true;
  5597. }
  5598. #endregion
  5599. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5600. if (handlerAgentDataUpdateRequest != null)
  5601. {
  5602. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5603. }
  5604. return true;
  5605. }
  5606. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5607. {
  5608. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5609. if (handlerUserInfoRequest != null)
  5610. {
  5611. handlerUserInfoRequest(this);
  5612. }
  5613. else
  5614. {
  5615. SendUserInfoReply(false, true, "");
  5616. }
  5617. return true;
  5618. }
  5619. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5620. {
  5621. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5622. #region Packet Session and User Check
  5623. if (m_checkPackets)
  5624. {
  5625. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5626. updateUserInfo.AgentData.AgentID != AgentId)
  5627. return true;
  5628. }
  5629. #endregion
  5630. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5631. if (handlerUpdateUserInfo != null)
  5632. {
  5633. bool visible = true;
  5634. string DirectoryVisibility =
  5635. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5636. if (DirectoryVisibility == "hidden")
  5637. visible = false;
  5638. handlerUpdateUserInfo(
  5639. updateUserInfo.UserData.IMViaEMail,
  5640. visible, this);
  5641. }
  5642. return true;
  5643. }
  5644. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5645. {
  5646. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5647. #region Packet Session and User Check
  5648. if (m_checkPackets)
  5649. {
  5650. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5651. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5652. return true;
  5653. }
  5654. #endregion
  5655. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5656. {
  5657. // Linden Client limitation..
  5658. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5659. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5660. {
  5661. ScenePresence avatar = null;
  5662. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5663. {
  5664. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5665. {
  5666. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5667. }
  5668. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5669. {
  5670. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5671. }
  5672. }
  5673. }
  5674. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5675. if (handlerSetStartLocationRequest != null)
  5676. {
  5677. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5678. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5679. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5680. }
  5681. }
  5682. return true;
  5683. }
  5684. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5685. {
  5686. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5687. #region Packet Session and User Check
  5688. if (m_checkPackets)
  5689. {
  5690. if (atpack.AgentData.SessionID != SessionId ||
  5691. atpack.AgentData.AgentID != AgentId)
  5692. return true;
  5693. }
  5694. #endregion
  5695. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5696. return true;
  5697. }
  5698. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5699. {
  5700. m_udpClient.IsPaused = true;
  5701. return true;
  5702. }
  5703. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5704. {
  5705. m_udpClient.IsPaused = false;
  5706. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5707. return true;
  5708. }
  5709. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5710. {
  5711. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5712. if (handlerForceReleaseControls != null)
  5713. {
  5714. handlerForceReleaseControls(this, AgentId);
  5715. }
  5716. return true;
  5717. }
  5718. #endregion Scene/Avatar
  5719. #region Objects/m_sceneObjects
  5720. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5721. {
  5722. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5723. #region Packet Session and User Check
  5724. if (m_checkPackets)
  5725. {
  5726. if (link.AgentData.SessionID != SessionId ||
  5727. link.AgentData.AgentID != AgentId)
  5728. return true;
  5729. }
  5730. #endregion
  5731. uint parentprimid = 0;
  5732. List<uint> childrenprims = new List<uint>();
  5733. if (link.ObjectData.Length > 1)
  5734. {
  5735. parentprimid = link.ObjectData[0].ObjectLocalID;
  5736. for (int i = 1; i < link.ObjectData.Length; i++)
  5737. {
  5738. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5739. }
  5740. }
  5741. LinkObjects handlerLinkObjects = OnLinkObjects;
  5742. if (handlerLinkObjects != null)
  5743. {
  5744. handlerLinkObjects(this, parentprimid, childrenprims);
  5745. }
  5746. return true;
  5747. }
  5748. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  5749. {
  5750. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  5751. #region Packet Session and User Check
  5752. if (m_checkPackets)
  5753. {
  5754. if (delink.AgentData.SessionID != SessionId ||
  5755. delink.AgentData.AgentID != AgentId)
  5756. return true;
  5757. }
  5758. #endregion
  5759. // It appears the prim at index 0 is not always the root prim (for
  5760. // instance, when one prim of a link set has been edited independently
  5761. // of the others). Therefore, we'll pass all the ids onto the delink
  5762. // method for it to decide which is the root.
  5763. List<uint> prims = new List<uint>();
  5764. for (int i = 0; i < delink.ObjectData.Length; i++)
  5765. {
  5766. prims.Add(delink.ObjectData[i].ObjectLocalID);
  5767. }
  5768. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  5769. if (handlerDelinkObjects != null)
  5770. {
  5771. handlerDelinkObjects(prims, this);
  5772. }
  5773. return true;
  5774. }
  5775. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  5776. {
  5777. if (OnAddPrim != null)
  5778. {
  5779. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  5780. #region Packet Session and User Check
  5781. if (m_checkPackets)
  5782. {
  5783. if (addPacket.AgentData.SessionID != SessionId ||
  5784. addPacket.AgentData.AgentID != AgentId)
  5785. return true;
  5786. }
  5787. #endregion
  5788. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  5789. // m_log.Info("[REZData]: " + addPacket.ToString());
  5790. //BypassRaycast: 1
  5791. //RayStart: <69.79469, 158.2652, 98.40343>
  5792. //RayEnd: <61.97724, 141.995, 92.58341>
  5793. //RayTargetID: 00000000-0000-0000-0000-000000000000
  5794. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  5795. //object from rezing initially
  5796. AddNewPrim handlerAddPrim = OnAddPrim;
  5797. if (handlerAddPrim != null)
  5798. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  5799. }
  5800. return true;
  5801. }
  5802. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  5803. {
  5804. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  5805. #region Packet Session and User Check
  5806. if (m_checkPackets)
  5807. {
  5808. if (shapePacket.AgentData.SessionID != SessionId ||
  5809. shapePacket.AgentData.AgentID != AgentId)
  5810. return true;
  5811. }
  5812. #endregion
  5813. UpdateShape handlerUpdatePrimShape = null;
  5814. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  5815. {
  5816. handlerUpdatePrimShape = OnUpdatePrimShape;
  5817. if (handlerUpdatePrimShape != null)
  5818. {
  5819. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  5820. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  5821. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  5822. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  5823. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  5824. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  5825. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  5826. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  5827. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  5828. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  5829. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  5830. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  5831. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  5832. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  5833. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  5834. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  5835. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  5836. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  5837. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  5838. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  5839. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  5840. shapeData);
  5841. }
  5842. }
  5843. return true;
  5844. }
  5845. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  5846. {
  5847. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  5848. #region Packet Session and User Check
  5849. if (m_checkPackets)
  5850. {
  5851. if (extraPar.AgentData.SessionID != SessionId ||
  5852. extraPar.AgentData.AgentID != AgentId)
  5853. return true;
  5854. }
  5855. #endregion
  5856. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  5857. if (handlerUpdateExtraParams != null)
  5858. {
  5859. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  5860. {
  5861. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  5862. extraPar.ObjectData[i].ParamType,
  5863. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  5864. }
  5865. }
  5866. return true;
  5867. }
  5868. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  5869. {
  5870. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  5871. #region Packet Session and User Check
  5872. if (m_checkPackets)
  5873. {
  5874. if (dupe.AgentData.SessionID != SessionId ||
  5875. dupe.AgentData.AgentID != AgentId)
  5876. return true;
  5877. }
  5878. #endregion
  5879. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  5880. ObjectDuplicate handlerObjectDuplicate = null;
  5881. for (int i = 0; i < dupe.ObjectData.Length; i++)
  5882. {
  5883. handlerObjectDuplicate = OnObjectDuplicate;
  5884. if (handlerObjectDuplicate != null)
  5885. {
  5886. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  5887. dupe.SharedData.DuplicateFlags, AgentId,
  5888. m_activeGroupID);
  5889. }
  5890. }
  5891. return true;
  5892. }
  5893. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  5894. {
  5895. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  5896. #region Packet Session and User Check
  5897. if (m_checkPackets)
  5898. {
  5899. if (incomingRequest.AgentData.SessionID != SessionId ||
  5900. incomingRequest.AgentData.AgentID != AgentId)
  5901. return true;
  5902. }
  5903. #endregion
  5904. ObjectRequest handlerObjectRequest = null;
  5905. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  5906. {
  5907. handlerObjectRequest = OnObjectRequest;
  5908. if (handlerObjectRequest != null)
  5909. {
  5910. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  5911. }
  5912. }
  5913. return true;
  5914. }
  5915. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  5916. {
  5917. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  5918. #region Packet Session and User Check
  5919. if (m_checkPackets)
  5920. {
  5921. if (incomingselect.AgentData.SessionID != SessionId ||
  5922. incomingselect.AgentData.AgentID != AgentId)
  5923. return true;
  5924. }
  5925. #endregion
  5926. ObjectSelect handlerObjectSelect = null;
  5927. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  5928. {
  5929. handlerObjectSelect = OnObjectSelect;
  5930. if (handlerObjectSelect != null)
  5931. {
  5932. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  5933. }
  5934. }
  5935. return true;
  5936. }
  5937. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  5938. {
  5939. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  5940. #region Packet Session and User Check
  5941. if (m_checkPackets)
  5942. {
  5943. if (incomingdeselect.AgentData.SessionID != SessionId ||
  5944. incomingdeselect.AgentData.AgentID != AgentId)
  5945. return true;
  5946. }
  5947. #endregion
  5948. ObjectDeselect handlerObjectDeselect = null;
  5949. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  5950. {
  5951. handlerObjectDeselect = OnObjectDeselect;
  5952. if (handlerObjectDeselect != null)
  5953. {
  5954. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  5955. }
  5956. }
  5957. return true;
  5958. }
  5959. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  5960. {
  5961. // DEPRECATED: but till libsecondlife removes it, people will use it
  5962. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  5963. #region Packet Session and User Check
  5964. if (m_checkPackets)
  5965. {
  5966. if (position.AgentData.SessionID != SessionId ||
  5967. position.AgentData.AgentID != AgentId)
  5968. return true;
  5969. }
  5970. #endregion
  5971. for (int i = 0; i < position.ObjectData.Length; i++)
  5972. {
  5973. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  5974. if (handlerUpdateVector != null)
  5975. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  5976. }
  5977. return true;
  5978. }
  5979. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  5980. {
  5981. // DEPRECATED: but till libsecondlife removes it, people will use it
  5982. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  5983. #region Packet Session and User Check
  5984. if (m_checkPackets)
  5985. {
  5986. if (scale.AgentData.SessionID != SessionId ||
  5987. scale.AgentData.AgentID != AgentId)
  5988. return true;
  5989. }
  5990. #endregion
  5991. for (int i = 0; i < scale.ObjectData.Length; i++)
  5992. {
  5993. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  5994. if (handlerUpdatePrimGroupScale != null)
  5995. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  5996. }
  5997. return true;
  5998. }
  5999. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6000. {
  6001. // DEPRECATED: but till libsecondlife removes it, people will use it
  6002. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6003. #region Packet Session and User Check
  6004. if (m_checkPackets)
  6005. {
  6006. if (rotation.AgentData.SessionID != SessionId ||
  6007. rotation.AgentData.AgentID != AgentId)
  6008. return true;
  6009. }
  6010. #endregion
  6011. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6012. {
  6013. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6014. if (handlerUpdatePrimRotation != null)
  6015. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6016. }
  6017. return true;
  6018. }
  6019. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6020. {
  6021. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6022. #region Packet Session and User Check
  6023. if (m_checkPackets)
  6024. {
  6025. if (flags.AgentData.SessionID != SessionId ||
  6026. flags.AgentData.AgentID != AgentId)
  6027. return true;
  6028. }
  6029. #endregion
  6030. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6031. if (handlerUpdatePrimFlags != null)
  6032. {
  6033. byte[] data = Pack.ToBytes();
  6034. // 46,47,48 are special positions within the packet
  6035. // This may change so perhaps we need a better way
  6036. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6037. bool UsePhysics = (data[46] != 0) ? true : false;
  6038. bool IsTemporary = (data[47] != 0) ? true : false;
  6039. bool IsPhantom = (data[48] != 0) ? true : false;
  6040. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6041. }
  6042. return true;
  6043. }
  6044. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6045. {
  6046. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6047. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6048. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6049. {
  6050. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6051. if (handlerUpdatePrimTexture != null)
  6052. {
  6053. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6054. imagePack.ObjectData[i].TextureEntry, this);
  6055. }
  6056. }
  6057. return true;
  6058. }
  6059. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6060. {
  6061. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6062. #region Packet Session and User Check
  6063. if (m_checkPackets)
  6064. {
  6065. if (grab.AgentData.SessionID != SessionId ||
  6066. grab.AgentData.AgentID != AgentId)
  6067. return true;
  6068. }
  6069. #endregion
  6070. GrabObject handlerGrabObject = OnGrabObject;
  6071. if (handlerGrabObject != null)
  6072. {
  6073. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6074. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6075. {
  6076. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6077. {
  6078. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6079. arg.Binormal = surfaceInfo.Binormal;
  6080. arg.FaceIndex = surfaceInfo.FaceIndex;
  6081. arg.Normal = surfaceInfo.Normal;
  6082. arg.Position = surfaceInfo.Position;
  6083. arg.STCoord = surfaceInfo.STCoord;
  6084. arg.UVCoord = surfaceInfo.UVCoord;
  6085. touchArgs.Add(arg);
  6086. }
  6087. }
  6088. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6089. }
  6090. return true;
  6091. }
  6092. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6093. {
  6094. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6095. #region Packet Session and User Check
  6096. if (m_checkPackets)
  6097. {
  6098. if (grabUpdate.AgentData.SessionID != SessionId ||
  6099. grabUpdate.AgentData.AgentID != AgentId)
  6100. return true;
  6101. }
  6102. #endregion
  6103. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6104. if (handlerGrabUpdate != null)
  6105. {
  6106. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6107. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6108. {
  6109. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6110. {
  6111. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6112. arg.Binormal = surfaceInfo.Binormal;
  6113. arg.FaceIndex = surfaceInfo.FaceIndex;
  6114. arg.Normal = surfaceInfo.Normal;
  6115. arg.Position = surfaceInfo.Position;
  6116. arg.STCoord = surfaceInfo.STCoord;
  6117. arg.UVCoord = surfaceInfo.UVCoord;
  6118. touchArgs.Add(arg);
  6119. }
  6120. }
  6121. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6122. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6123. }
  6124. return true;
  6125. }
  6126. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6127. {
  6128. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6129. #region Packet Session and User Check
  6130. if (m_checkPackets)
  6131. {
  6132. if (deGrab.AgentData.SessionID != SessionId ||
  6133. deGrab.AgentData.AgentID != AgentId)
  6134. return true;
  6135. }
  6136. #endregion
  6137. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6138. if (handlerDeGrabObject != null)
  6139. {
  6140. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6141. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6142. {
  6143. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6144. {
  6145. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6146. arg.Binormal = surfaceInfo.Binormal;
  6147. arg.FaceIndex = surfaceInfo.FaceIndex;
  6148. arg.Normal = surfaceInfo.Normal;
  6149. arg.Position = surfaceInfo.Position;
  6150. arg.STCoord = surfaceInfo.STCoord;
  6151. arg.UVCoord = surfaceInfo.UVCoord;
  6152. touchArgs.Add(arg);
  6153. }
  6154. }
  6155. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6156. }
  6157. return true;
  6158. }
  6159. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6160. {
  6161. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6162. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6163. #region Packet Session and User Check
  6164. if (m_checkPackets)
  6165. {
  6166. if (spinStart.AgentData.SessionID != SessionId ||
  6167. spinStart.AgentData.AgentID != AgentId)
  6168. return true;
  6169. }
  6170. #endregion
  6171. SpinStart handlerSpinStart = OnSpinStart;
  6172. if (handlerSpinStart != null)
  6173. {
  6174. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6175. }
  6176. return true;
  6177. }
  6178. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6179. {
  6180. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6181. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6182. #region Packet Session and User Check
  6183. if (m_checkPackets)
  6184. {
  6185. if (spinUpdate.AgentData.SessionID != SessionId ||
  6186. spinUpdate.AgentData.AgentID != AgentId)
  6187. return true;
  6188. }
  6189. #endregion
  6190. Vector3 axis;
  6191. float angle;
  6192. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6193. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6194. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6195. if (handlerSpinUpdate != null)
  6196. {
  6197. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6198. }
  6199. return true;
  6200. }
  6201. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6202. {
  6203. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6204. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6205. #region Packet Session and User Check
  6206. if (m_checkPackets)
  6207. {
  6208. if (spinStop.AgentData.SessionID != SessionId ||
  6209. spinStop.AgentData.AgentID != AgentId)
  6210. return true;
  6211. }
  6212. #endregion
  6213. SpinStop handlerSpinStop = OnSpinStop;
  6214. if (handlerSpinStop != null)
  6215. {
  6216. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6217. }
  6218. return true;
  6219. }
  6220. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6221. {
  6222. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6223. #region Packet Session and User Check
  6224. if (m_checkPackets)
  6225. {
  6226. if (objDes.AgentData.SessionID != SessionId ||
  6227. objDes.AgentData.AgentID != AgentId)
  6228. return true;
  6229. }
  6230. #endregion
  6231. GenericCall7 handlerObjectDescription = null;
  6232. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6233. {
  6234. handlerObjectDescription = OnObjectDescription;
  6235. if (handlerObjectDescription != null)
  6236. {
  6237. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6238. Util.FieldToString(objDes.ObjectData[i].Description));
  6239. }
  6240. }
  6241. return true;
  6242. }
  6243. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6244. {
  6245. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6246. #region Packet Session and User Check
  6247. if (m_checkPackets)
  6248. {
  6249. if (objName.AgentData.SessionID != SessionId ||
  6250. objName.AgentData.AgentID != AgentId)
  6251. return true;
  6252. }
  6253. #endregion
  6254. GenericCall7 handlerObjectName = null;
  6255. for (int i = 0; i < objName.ObjectData.Length; i++)
  6256. {
  6257. handlerObjectName = OnObjectName;
  6258. if (handlerObjectName != null)
  6259. {
  6260. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6261. Util.FieldToString(objName.ObjectData[i].Name));
  6262. }
  6263. }
  6264. return true;
  6265. }
  6266. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6267. {
  6268. if (OnObjectPermissions != null)
  6269. {
  6270. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6271. #region Packet Session and User Check
  6272. if (m_checkPackets)
  6273. {
  6274. if (newobjPerms.AgentData.SessionID != SessionId ||
  6275. newobjPerms.AgentData.AgentID != AgentId)
  6276. return true;
  6277. }
  6278. #endregion
  6279. UUID AgentID = newobjPerms.AgentData.AgentID;
  6280. UUID SessionID = newobjPerms.AgentData.SessionID;
  6281. ObjectPermissions handlerObjectPermissions = null;
  6282. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6283. {
  6284. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6285. byte field = permChanges.Field;
  6286. uint localID = permChanges.ObjectLocalID;
  6287. uint mask = permChanges.Mask;
  6288. byte set = permChanges.Set;
  6289. handlerObjectPermissions = OnObjectPermissions;
  6290. if (handlerObjectPermissions != null)
  6291. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6292. }
  6293. }
  6294. // Here's our data,
  6295. // PermField contains the field the info goes into
  6296. // PermField determines which mask we're changing
  6297. //
  6298. // chmask is the mask of the change
  6299. // setTF is whether we're adding it or taking it away
  6300. //
  6301. // objLocalID is the localID of the object.
  6302. // Unfortunately, we have to pass the event the packet because objData is an array
  6303. // That means multiple object perms may be updated in a single packet.
  6304. return true;
  6305. }
  6306. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6307. {
  6308. UndoPacket undoitem = (UndoPacket)Pack;
  6309. #region Packet Session and User Check
  6310. if (m_checkPackets)
  6311. {
  6312. if (undoitem.AgentData.SessionID != SessionId ||
  6313. undoitem.AgentData.AgentID != AgentId)
  6314. return true;
  6315. }
  6316. #endregion
  6317. if (undoitem.ObjectData.Length > 0)
  6318. {
  6319. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6320. {
  6321. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6322. AgentSit handlerOnUndo = OnUndo;
  6323. if (handlerOnUndo != null)
  6324. {
  6325. handlerOnUndo(this, objiD);
  6326. }
  6327. }
  6328. }
  6329. return true;
  6330. }
  6331. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6332. {
  6333. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6334. #region Packet Session and User Check
  6335. if (m_checkPackets)
  6336. {
  6337. if (undolanditem.AgentData.SessionID != SessionId ||
  6338. undolanditem.AgentData.AgentID != AgentId)
  6339. return true;
  6340. }
  6341. #endregion
  6342. LandUndo handlerOnUndo = OnLandUndo;
  6343. if (handlerOnUndo != null)
  6344. {
  6345. handlerOnUndo(this);
  6346. }
  6347. return true;
  6348. }
  6349. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6350. {
  6351. RedoPacket redoitem = (RedoPacket)Pack;
  6352. #region Packet Session and User Check
  6353. if (m_checkPackets)
  6354. {
  6355. if (redoitem.AgentData.SessionID != SessionId ||
  6356. redoitem.AgentData.AgentID != AgentId)
  6357. return true;
  6358. }
  6359. #endregion
  6360. if (redoitem.ObjectData.Length > 0)
  6361. {
  6362. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6363. {
  6364. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6365. AgentSit handlerOnRedo = OnRedo;
  6366. if (handlerOnRedo != null)
  6367. {
  6368. handlerOnRedo(this, objiD);
  6369. }
  6370. }
  6371. }
  6372. return true;
  6373. }
  6374. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6375. {
  6376. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6377. #region Packet Session and User Check
  6378. if (m_checkPackets)
  6379. {
  6380. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6381. dupeOnRay.AgentData.AgentID != AgentId)
  6382. return true;
  6383. }
  6384. #endregion
  6385. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6386. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6387. {
  6388. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6389. if (handlerObjectDuplicateOnRay != null)
  6390. {
  6391. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6392. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6393. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6394. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6395. }
  6396. }
  6397. return true;
  6398. }
  6399. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6400. {
  6401. //This powers the little tooltip that appears when you move your mouse over an object
  6402. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6403. #region Packet Session and User Check
  6404. if (m_checkPackets)
  6405. {
  6406. if (packToolTip.AgentData.SessionID != SessionId ||
  6407. packToolTip.AgentData.AgentID != AgentId)
  6408. return true;
  6409. }
  6410. #endregion
  6411. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6412. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6413. if (handlerRequestObjectPropertiesFamily != null)
  6414. {
  6415. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6416. packObjBlock.ObjectID);
  6417. }
  6418. return true;
  6419. }
  6420. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6421. {
  6422. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6423. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6424. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6425. #region Packet Session and User Check
  6426. if (m_checkPackets)
  6427. {
  6428. if (packInSearch.AgentData.SessionID != SessionId ||
  6429. packInSearch.AgentData.AgentID != AgentId)
  6430. return true;
  6431. }
  6432. #endregion
  6433. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6434. {
  6435. bool inSearch = objData.IncludeInSearch;
  6436. uint localID = objData.ObjectLocalID;
  6437. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6438. if (handlerObjectIncludeInSearch != null)
  6439. {
  6440. handlerObjectIncludeInSearch(this, inSearch, localID);
  6441. }
  6442. }
  6443. return true;
  6444. }
  6445. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6446. {
  6447. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6448. #region Packet Session and User Check
  6449. if (m_checkPackets)
  6450. {
  6451. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6452. scriptAnswer.AgentData.AgentID != AgentId)
  6453. return true;
  6454. }
  6455. #endregion
  6456. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6457. if (handlerScriptAnswer != null)
  6458. {
  6459. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6460. }
  6461. return true;
  6462. }
  6463. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6464. {
  6465. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6466. #region Packet Session and User Check
  6467. if (m_checkPackets)
  6468. {
  6469. if (ocpacket.AgentData.SessionID != SessionId ||
  6470. ocpacket.AgentData.AgentID != AgentId)
  6471. return true;
  6472. }
  6473. #endregion
  6474. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6475. if (handlerObjectClickAction != null)
  6476. {
  6477. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6478. {
  6479. byte action = odata.ClickAction;
  6480. uint localID = odata.ObjectLocalID;
  6481. handlerObjectClickAction(this, localID, action.ToString());
  6482. }
  6483. }
  6484. return true;
  6485. }
  6486. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6487. {
  6488. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6489. #region Packet Session and User Check
  6490. if (m_checkPackets)
  6491. {
  6492. if (ompacket.AgentData.SessionID != SessionId ||
  6493. ompacket.AgentData.AgentID != AgentId)
  6494. return true;
  6495. }
  6496. #endregion
  6497. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6498. if (handlerObjectMaterial != null)
  6499. {
  6500. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6501. {
  6502. byte material = odata.Material;
  6503. uint localID = odata.ObjectLocalID;
  6504. handlerObjectMaterial(this, localID, material.ToString());
  6505. }
  6506. }
  6507. return true;
  6508. }
  6509. #endregion Objects/m_sceneObjects
  6510. #region Inventory/Asset/Other related packets
  6511. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6512. {
  6513. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6514. //m_log.Debug("image request: " + Pack.ToString());
  6515. #region Packet Session and User Check
  6516. if (m_checkPackets)
  6517. {
  6518. if (imageRequest.AgentData.SessionID != SessionId ||
  6519. imageRequest.AgentData.AgentID != AgentId)
  6520. return true;
  6521. }
  6522. #endregion
  6523. //handlerTextureRequest = null;
  6524. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6525. {
  6526. TextureRequestArgs args = new TextureRequestArgs();
  6527. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6528. args.RequestedAssetID = block.Image;
  6529. args.DiscardLevel = block.DiscardLevel;
  6530. args.PacketNumber = block.Packet;
  6531. args.Priority = block.DownloadPriority;
  6532. args.requestSequence = imageRequest.Header.Sequence;
  6533. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6534. // priority of avatar textures to get avatars rezzing in faster than the
  6535. // surrounding scene
  6536. if ((ImageType)block.Type == ImageType.Baked)
  6537. args.Priority *= 2.0f;
  6538. ImageManager.EnqueueReq(args);
  6539. }
  6540. return true;
  6541. }
  6542. /// <summary>
  6543. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6544. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6545. /// </summary>
  6546. /// <param name="sender"></param>
  6547. /// <param name="Pack"></param>
  6548. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6549. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6550. {
  6551. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6552. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6553. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6554. // Validate inventory transfers
  6555. // Has to be done here, because AssetCache can't do it
  6556. //
  6557. UUID taskID = UUID.Zero;
  6558. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6559. {
  6560. taskID = new UUID(transfer.TransferInfo.Params, 48);
  6561. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6562. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6563. // m_log.DebugFormat(
  6564. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6565. // requestID, itemID, taskID, Name);
  6566. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6567. {
  6568. if (taskID != UUID.Zero) // Prim
  6569. {
  6570. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6571. if (part == null)
  6572. {
  6573. m_log.WarnFormat(
  6574. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6575. Name, requestID, itemID, taskID);
  6576. return true;
  6577. }
  6578. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6579. if (tii == null)
  6580. {
  6581. m_log.WarnFormat(
  6582. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6583. Name, requestID, itemID, taskID);
  6584. return true;
  6585. }
  6586. if (tii.Type == (int)AssetType.LSLText)
  6587. {
  6588. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6589. return true;
  6590. }
  6591. else if (tii.Type == (int)AssetType.Notecard)
  6592. {
  6593. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6594. return true;
  6595. }
  6596. else
  6597. {
  6598. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6599. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6600. if (part.OwnerID != AgentId)
  6601. {
  6602. m_log.WarnFormat(
  6603. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6604. Name, requestID, itemID, taskID, part.OwnerID);
  6605. return true;
  6606. }
  6607. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6608. {
  6609. m_log.WarnFormat(
  6610. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6611. Name, requestID, itemID, taskID);
  6612. return true;
  6613. }
  6614. if (tii.OwnerID != AgentId)
  6615. {
  6616. m_log.WarnFormat(
  6617. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6618. Name, requestID, itemID, taskID, tii.OwnerID);
  6619. return true;
  6620. }
  6621. if ((
  6622. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6623. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6624. {
  6625. m_log.WarnFormat(
  6626. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6627. Name, requestID, itemID, taskID);
  6628. return true;
  6629. }
  6630. if (tii.AssetID != requestID)
  6631. {
  6632. m_log.WarnFormat(
  6633. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6634. Name, requestID, itemID, taskID, tii.AssetID);
  6635. return true;
  6636. }
  6637. }
  6638. }
  6639. else // Agent
  6640. {
  6641. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6642. if (invAccess != null)
  6643. {
  6644. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6645. return false;
  6646. }
  6647. else
  6648. {
  6649. return false;
  6650. }
  6651. }
  6652. }
  6653. }
  6654. else
  6655. if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6656. {
  6657. //TransferRequestPacket does not include covenant uuid?
  6658. //get scene covenant uuid
  6659. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6660. }
  6661. MakeAssetRequest(transfer, taskID);
  6662. return true;
  6663. }
  6664. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6665. {
  6666. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6667. // m_log.Debug("upload request " + request.ToString());
  6668. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6669. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6670. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6671. if (handlerAssetUploadRequest != null)
  6672. {
  6673. handlerAssetUploadRequest(this, temp,
  6674. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6675. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6676. request.AssetBlock.Tempfile);
  6677. }
  6678. return true;
  6679. }
  6680. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6681. {
  6682. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6683. RequestXfer handlerRequestXfer = OnRequestXfer;
  6684. if (handlerRequestXfer != null)
  6685. {
  6686. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6687. }
  6688. return true;
  6689. }
  6690. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6691. {
  6692. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6693. XferReceive handlerXferReceive = OnXferReceive;
  6694. if (handlerXferReceive != null)
  6695. {
  6696. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6697. }
  6698. return true;
  6699. }
  6700. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6701. {
  6702. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6703. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6704. if (handlerConfirmXfer != null)
  6705. {
  6706. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6707. }
  6708. return true;
  6709. }
  6710. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6711. {
  6712. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6713. AbortXfer handlerAbortXfer = OnAbortXfer;
  6714. if (handlerAbortXfer != null)
  6715. {
  6716. handlerAbortXfer(this, abortXfer.XferID.ID);
  6717. }
  6718. return true;
  6719. }
  6720. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  6721. {
  6722. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  6723. #region Packet Session and User Check
  6724. if (m_checkPackets)
  6725. {
  6726. if (invFolder.AgentData.SessionID != SessionId ||
  6727. invFolder.AgentData.AgentID != AgentId)
  6728. return true;
  6729. }
  6730. #endregion
  6731. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  6732. if (handlerCreateInventoryFolder != null)
  6733. {
  6734. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  6735. (ushort)invFolder.FolderData.Type,
  6736. Util.FieldToString(invFolder.FolderData.Name),
  6737. invFolder.FolderData.ParentID);
  6738. }
  6739. return true;
  6740. }
  6741. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  6742. {
  6743. if (OnUpdateInventoryFolder != null)
  6744. {
  6745. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  6746. #region Packet Session and User Check
  6747. if (m_checkPackets)
  6748. {
  6749. if (invFolderx.AgentData.SessionID != SessionId ||
  6750. invFolderx.AgentData.AgentID != AgentId)
  6751. return true;
  6752. }
  6753. #endregion
  6754. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  6755. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  6756. {
  6757. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  6758. if (handlerUpdateInventoryFolder != null)
  6759. {
  6760. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  6761. (ushort)invFolderx.FolderData[i].Type,
  6762. Util.FieldToString(invFolderx.FolderData[i].Name),
  6763. invFolderx.FolderData[i].ParentID);
  6764. }
  6765. }
  6766. }
  6767. return true;
  6768. }
  6769. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  6770. {
  6771. if (OnMoveInventoryFolder != null)
  6772. {
  6773. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  6774. #region Packet Session and User Check
  6775. if (m_checkPackets)
  6776. {
  6777. if (invFoldery.AgentData.SessionID != SessionId ||
  6778. invFoldery.AgentData.AgentID != AgentId)
  6779. return true;
  6780. }
  6781. #endregion
  6782. MoveInventoryFolder handlerMoveInventoryFolder = null;
  6783. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  6784. {
  6785. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  6786. if (handlerMoveInventoryFolder != null)
  6787. {
  6788. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  6789. invFoldery.InventoryData[i].ParentID);
  6790. }
  6791. }
  6792. }
  6793. return true;
  6794. }
  6795. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  6796. {
  6797. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  6798. #region Packet Session and User Check
  6799. if (m_checkPackets)
  6800. {
  6801. if (createItem.AgentData.SessionID != SessionId ||
  6802. createItem.AgentData.AgentID != AgentId)
  6803. return true;
  6804. }
  6805. #endregion
  6806. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  6807. if (handlerCreateNewInventoryItem != null)
  6808. {
  6809. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  6810. createItem.InventoryBlock.FolderID,
  6811. createItem.InventoryBlock.CallbackID,
  6812. Util.FieldToString(createItem.InventoryBlock.Description),
  6813. Util.FieldToString(createItem.InventoryBlock.Name),
  6814. createItem.InventoryBlock.InvType,
  6815. createItem.InventoryBlock.Type,
  6816. createItem.InventoryBlock.WearableType,
  6817. createItem.InventoryBlock.NextOwnerMask,
  6818. Util.UnixTimeSinceEpoch());
  6819. }
  6820. return true;
  6821. }
  6822. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  6823. {
  6824. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  6825. #region Packet Session and User Check
  6826. if (m_checkPackets)
  6827. {
  6828. if (createLink.AgentData.SessionID != SessionId ||
  6829. createLink.AgentData.AgentID != AgentId)
  6830. return true;
  6831. }
  6832. #endregion
  6833. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  6834. if (linkInventoryItem != null)
  6835. {
  6836. linkInventoryItem(
  6837. this,
  6838. createLink.InventoryBlock.TransactionID,
  6839. createLink.InventoryBlock.FolderID,
  6840. createLink.InventoryBlock.CallbackID,
  6841. Util.FieldToString(createLink.InventoryBlock.Description),
  6842. Util.FieldToString(createLink.InventoryBlock.Name),
  6843. createLink.InventoryBlock.InvType,
  6844. createLink.InventoryBlock.Type,
  6845. createLink.InventoryBlock.OldItemID);
  6846. }
  6847. return true;
  6848. }
  6849. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  6850. {
  6851. if (OnFetchInventory != null)
  6852. {
  6853. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  6854. #region Packet Session and User Check
  6855. if (m_checkPackets)
  6856. {
  6857. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  6858. FetchInventoryx.AgentData.AgentID != AgentId)
  6859. return true;
  6860. }
  6861. #endregion
  6862. FetchInventory handlerFetchInventory = null;
  6863. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  6864. {
  6865. handlerFetchInventory = OnFetchInventory;
  6866. if (handlerFetchInventory != null)
  6867. {
  6868. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  6869. FetchInventoryx.InventoryData[i].OwnerID);
  6870. }
  6871. }
  6872. }
  6873. return true;
  6874. }
  6875. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  6876. {
  6877. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  6878. #region Packet Session and User Check
  6879. if (m_checkPackets)
  6880. {
  6881. if (Fetch.AgentData.SessionID != SessionId ||
  6882. Fetch.AgentData.AgentID != AgentId)
  6883. return true;
  6884. }
  6885. #endregion
  6886. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  6887. if (handlerFetchInventoryDescendents != null)
  6888. {
  6889. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  6890. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  6891. Fetch.InventoryData.SortOrder);
  6892. }
  6893. return true;
  6894. }
  6895. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  6896. {
  6897. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  6898. #region Packet Session and User Check
  6899. if (m_checkPackets)
  6900. {
  6901. if (Purge.AgentData.SessionID != SessionId ||
  6902. Purge.AgentData.AgentID != AgentId)
  6903. return true;
  6904. }
  6905. #endregion
  6906. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  6907. if (handlerPurgeInventoryDescendents != null)
  6908. {
  6909. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  6910. }
  6911. return true;
  6912. }
  6913. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  6914. {
  6915. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  6916. #region Packet Session and User Check
  6917. if (m_checkPackets)
  6918. {
  6919. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  6920. inventoryItemUpdate.AgentData.AgentID != AgentId)
  6921. return true;
  6922. }
  6923. #endregion
  6924. if (OnUpdateInventoryItem != null)
  6925. {
  6926. UpdateInventoryItem handlerUpdateInventoryItem = null;
  6927. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  6928. {
  6929. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  6930. if (handlerUpdateInventoryItem != null)
  6931. {
  6932. InventoryItemBase itemUpd = new InventoryItemBase();
  6933. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  6934. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  6935. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  6936. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  6937. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  6938. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  6939. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  6940. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  6941. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  6942. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  6943. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  6944. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  6945. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  6946. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  6947. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  6948. inventoryItemUpdate.InventoryData[i].ItemID,
  6949. itemUpd);
  6950. }
  6951. }
  6952. }
  6953. return true;
  6954. }
  6955. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  6956. {
  6957. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  6958. #region Packet Session and User Check
  6959. if (m_checkPackets)
  6960. {
  6961. if (copyitem.AgentData.SessionID != SessionId ||
  6962. copyitem.AgentData.AgentID != AgentId)
  6963. return true;
  6964. }
  6965. #endregion
  6966. CopyInventoryItem handlerCopyInventoryItem = null;
  6967. if (OnCopyInventoryItem != null)
  6968. {
  6969. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  6970. {
  6971. handlerCopyInventoryItem = OnCopyInventoryItem;
  6972. if (handlerCopyInventoryItem != null)
  6973. {
  6974. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  6975. datablock.OldItemID, datablock.NewFolderID,
  6976. Util.FieldToString(datablock.NewName));
  6977. }
  6978. }
  6979. }
  6980. return true;
  6981. }
  6982. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  6983. {
  6984. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  6985. #region Packet Session and User Check
  6986. if (m_checkPackets)
  6987. {
  6988. if (moveitem.AgentData.SessionID != SessionId ||
  6989. moveitem.AgentData.AgentID != AgentId)
  6990. return true;
  6991. }
  6992. #endregion
  6993. if (OnMoveInventoryItem != null)
  6994. {
  6995. MoveInventoryItem handlerMoveInventoryItem = null;
  6996. InventoryItemBase itm = null;
  6997. List<InventoryItemBase> items = new List<InventoryItemBase>();
  6998. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  6999. {
  7000. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7001. itm.Folder = datablock.FolderID;
  7002. itm.Name = Util.FieldToString(datablock.NewName);
  7003. // weird, comes out as empty string
  7004. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7005. items.Add(itm);
  7006. }
  7007. handlerMoveInventoryItem = OnMoveInventoryItem;
  7008. if (handlerMoveInventoryItem != null)
  7009. {
  7010. handlerMoveInventoryItem(this, items);
  7011. }
  7012. }
  7013. return true;
  7014. }
  7015. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7016. {
  7017. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7018. #region Packet Session and User Check
  7019. if (m_checkPackets)
  7020. {
  7021. if (removeItem.AgentData.SessionID != SessionId ||
  7022. removeItem.AgentData.AgentID != AgentId)
  7023. return true;
  7024. }
  7025. #endregion
  7026. if (OnRemoveInventoryItem != null)
  7027. {
  7028. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7029. List<UUID> uuids = new List<UUID>();
  7030. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7031. {
  7032. uuids.Add(datablock.ItemID);
  7033. }
  7034. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7035. if (handlerRemoveInventoryItem != null)
  7036. {
  7037. handlerRemoveInventoryItem(this, uuids);
  7038. }
  7039. }
  7040. return true;
  7041. }
  7042. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7043. {
  7044. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7045. #region Packet Session and User Check
  7046. if (m_checkPackets)
  7047. {
  7048. if (removeFolder.AgentData.SessionID != SessionId ||
  7049. removeFolder.AgentData.AgentID != AgentId)
  7050. return true;
  7051. }
  7052. #endregion
  7053. if (OnRemoveInventoryFolder != null)
  7054. {
  7055. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7056. List<UUID> uuids = new List<UUID>();
  7057. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7058. {
  7059. uuids.Add(datablock.FolderID);
  7060. }
  7061. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7062. if (handlerRemoveInventoryFolder != null)
  7063. {
  7064. handlerRemoveInventoryFolder(this, uuids);
  7065. }
  7066. }
  7067. return true;
  7068. }
  7069. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7070. {
  7071. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7072. #region Packet Session and User Check
  7073. if (m_checkPackets)
  7074. {
  7075. if (removeObject.AgentData.SessionID != SessionId ||
  7076. removeObject.AgentData.AgentID != AgentId)
  7077. return true;
  7078. }
  7079. #endregion
  7080. if (OnRemoveInventoryFolder != null)
  7081. {
  7082. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7083. List<UUID> uuids = new List<UUID>();
  7084. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7085. {
  7086. uuids.Add(datablock.FolderID);
  7087. }
  7088. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7089. if (handlerRemoveInventoryFolder != null)
  7090. {
  7091. handlerRemoveInventoryFolder(this, uuids);
  7092. }
  7093. }
  7094. if (OnRemoveInventoryItem != null)
  7095. {
  7096. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7097. List<UUID> uuids = new List<UUID>();
  7098. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7099. {
  7100. uuids.Add(datablock.ItemID);
  7101. }
  7102. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7103. if (handlerRemoveInventoryItem != null)
  7104. {
  7105. handlerRemoveInventoryItem(this, uuids);
  7106. }
  7107. }
  7108. return true;
  7109. }
  7110. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7111. {
  7112. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7113. #region Packet Session and User Check
  7114. if (m_checkPackets)
  7115. {
  7116. if (requesttask.AgentData.SessionID != SessionId ||
  7117. requesttask.AgentData.AgentID != AgentId)
  7118. return true;
  7119. }
  7120. #endregion
  7121. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7122. if (handlerRequestTaskInventory != null)
  7123. {
  7124. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7125. }
  7126. return true;
  7127. }
  7128. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7129. {
  7130. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7131. #region Packet Session and User Check
  7132. if (m_checkPackets)
  7133. {
  7134. if (updatetask.AgentData.SessionID != SessionId ||
  7135. updatetask.AgentData.AgentID != AgentId)
  7136. return true;
  7137. }
  7138. #endregion
  7139. if (OnUpdateTaskInventory != null)
  7140. {
  7141. if (updatetask.UpdateData.Key == 0)
  7142. {
  7143. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7144. if (handlerUpdateTaskInventory != null)
  7145. {
  7146. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7147. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7148. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7149. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7150. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7151. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7152. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7153. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7154. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7155. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7156. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7157. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7158. // different
  7159. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7160. newTaskItem.Type = updatetask.InventoryData.Type;
  7161. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7162. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7163. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7164. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7165. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7166. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7167. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7168. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7169. newTaskItem, updatetask.UpdateData.LocalID);
  7170. }
  7171. }
  7172. }
  7173. return true;
  7174. }
  7175. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7176. {
  7177. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7178. #region Packet Session and User Check
  7179. if (m_checkPackets)
  7180. {
  7181. if (removeTask.AgentData.SessionID != SessionId ||
  7182. removeTask.AgentData.AgentID != AgentId)
  7183. return true;
  7184. }
  7185. #endregion
  7186. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7187. if (handlerRemoveTaskItem != null)
  7188. {
  7189. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7190. }
  7191. return true;
  7192. }
  7193. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7194. {
  7195. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7196. #region Packet Session and User Check
  7197. if (m_checkPackets)
  7198. {
  7199. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7200. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7201. return true;
  7202. }
  7203. #endregion
  7204. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7205. if (handlerMoveTaskItem != null)
  7206. {
  7207. handlerMoveTaskItem(
  7208. this, moveTaskInventoryPacket.AgentData.FolderID,
  7209. moveTaskInventoryPacket.InventoryData.LocalID,
  7210. moveTaskInventoryPacket.InventoryData.ItemID);
  7211. }
  7212. return true;
  7213. }
  7214. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7215. {
  7216. //m_log.Debug(Pack.ToString());
  7217. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7218. #region Packet Session and User Check
  7219. if (m_checkPackets)
  7220. {
  7221. if (rezScriptx.AgentData.SessionID != SessionId ||
  7222. rezScriptx.AgentData.AgentID != AgentId)
  7223. return true;
  7224. }
  7225. #endregion
  7226. RezScript handlerRezScript = OnRezScript;
  7227. InventoryItemBase item = new InventoryItemBase();
  7228. item.ID = rezScriptx.InventoryBlock.ItemID;
  7229. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7230. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7231. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7232. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7233. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7234. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7235. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7236. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7237. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7238. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7239. item.AssetType = rezScriptx.InventoryBlock.Type;
  7240. item.InvType = rezScriptx.InventoryBlock.InvType;
  7241. item.Flags = rezScriptx.InventoryBlock.Flags;
  7242. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7243. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7244. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7245. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7246. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7247. if (handlerRezScript != null)
  7248. {
  7249. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7250. }
  7251. return true;
  7252. }
  7253. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7254. {
  7255. RequestMapLayer();
  7256. return true;
  7257. }
  7258. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7259. {
  7260. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7261. #region Packet Session and User Check
  7262. if (m_checkPackets)
  7263. {
  7264. if (MapRequest.AgentData.SessionID != SessionId ||
  7265. MapRequest.AgentData.AgentID != AgentId)
  7266. return true;
  7267. }
  7268. #endregion
  7269. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7270. if (handlerRequestMapBlocks != null)
  7271. {
  7272. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7273. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7274. }
  7275. return true;
  7276. }
  7277. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7278. {
  7279. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7280. #region Packet Session and User Check
  7281. if (m_checkPackets)
  7282. {
  7283. if (map.AgentData.SessionID != SessionId ||
  7284. map.AgentData.AgentID != AgentId)
  7285. return true;
  7286. }
  7287. #endregion
  7288. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7289. map.NameData.Name.Length - 1);
  7290. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7291. if (handlerMapNameRequest != null)
  7292. {
  7293. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7294. }
  7295. return true;
  7296. }
  7297. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7298. {
  7299. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7300. #region Packet Session and User Check
  7301. if (m_checkPackets)
  7302. {
  7303. if (tpReq.Info.SessionID != SessionId ||
  7304. tpReq.Info.AgentID != AgentId)
  7305. return true;
  7306. }
  7307. #endregion
  7308. UUID lmid = tpReq.Info.LandmarkID;
  7309. AssetLandmark lm;
  7310. if (lmid != UUID.Zero)
  7311. {
  7312. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7313. AssetBase lma = m_assetService.Get(lmid.ToString());
  7314. if (lma == null)
  7315. {
  7316. // Failed to find landmark
  7317. // Let's try to search in the user's home asset server
  7318. lma = FindAssetInUserAssetServer(lmid.ToString());
  7319. if (lma == null)
  7320. {
  7321. // Really doesn't exist
  7322. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7323. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7324. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7325. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7326. }
  7327. }
  7328. try
  7329. {
  7330. lm = new AssetLandmark(lma);
  7331. }
  7332. catch (NullReferenceException)
  7333. {
  7334. // asset not found generates null ref inside the assetlandmark constructor.
  7335. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7336. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7337. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7338. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7339. return true;
  7340. }
  7341. }
  7342. else
  7343. {
  7344. // Teleport home request
  7345. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7346. if (handlerTeleportHomeRequest != null)
  7347. {
  7348. handlerTeleportHomeRequest(AgentId, this);
  7349. }
  7350. return true;
  7351. }
  7352. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7353. if (handlerTeleportLandmarkRequest != null)
  7354. {
  7355. handlerTeleportLandmarkRequest(this, lm);
  7356. }
  7357. else
  7358. {
  7359. //no event handler so cancel request
  7360. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7361. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7362. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7363. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7364. }
  7365. return true;
  7366. }
  7367. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7368. {
  7369. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7370. if (handlerTeleportCancel != null)
  7371. {
  7372. handlerTeleportCancel(this);
  7373. }
  7374. return true;
  7375. }
  7376. private AssetBase FindAssetInUserAssetServer(string id)
  7377. {
  7378. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7379. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7380. {
  7381. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7382. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7383. }
  7384. return null;
  7385. }
  7386. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7387. {
  7388. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7389. // m_log.Debug(tpLocReq.ToString());
  7390. #region Packet Session and User Check
  7391. if (m_checkPackets)
  7392. {
  7393. if (tpLocReq.AgentData.SessionID != SessionId ||
  7394. tpLocReq.AgentData.AgentID != AgentId)
  7395. return true;
  7396. }
  7397. #endregion
  7398. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7399. if (handlerTeleportLocationRequest != null)
  7400. {
  7401. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7402. tpLocReq.Info.LookAt, 16);
  7403. }
  7404. else
  7405. {
  7406. //no event handler so cancel request
  7407. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7408. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7409. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7410. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7411. }
  7412. return true;
  7413. }
  7414. #endregion Inventory/Asset/Other related packets
  7415. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7416. {
  7417. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7418. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7419. {
  7420. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7421. if (handlerNameRequest != null)
  7422. {
  7423. handlerNameRequest(UUIDBlock.ID, this);
  7424. }
  7425. }
  7426. return true;
  7427. }
  7428. #region Parcel related packets
  7429. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7430. {
  7431. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7432. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7433. if (handlerRegionHandleRequest != null)
  7434. {
  7435. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7436. }
  7437. return true;
  7438. }
  7439. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7440. {
  7441. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7442. #region Packet Session and User Check
  7443. if (m_checkPackets)
  7444. {
  7445. if (pirPack.AgentData.SessionID != SessionId ||
  7446. pirPack.AgentData.AgentID != AgentId)
  7447. return true;
  7448. }
  7449. #endregion
  7450. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7451. if (handlerParcelInfoRequest != null)
  7452. {
  7453. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7454. }
  7455. return true;
  7456. }
  7457. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7458. {
  7459. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7460. #region Packet Session and User Check
  7461. if (m_checkPackets)
  7462. {
  7463. if (requestPacket.AgentData.SessionID != SessionId ||
  7464. requestPacket.AgentData.AgentID != AgentId)
  7465. return true;
  7466. }
  7467. #endregion
  7468. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7469. if (handlerParcelAccessListRequest != null)
  7470. {
  7471. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7472. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7473. requestPacket.Data.LocalID, this);
  7474. }
  7475. return true;
  7476. }
  7477. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7478. {
  7479. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7480. #region Packet Session and User Check
  7481. if (m_checkPackets)
  7482. {
  7483. if (updatePacket.AgentData.SessionID != SessionId ||
  7484. updatePacket.AgentData.AgentID != AgentId)
  7485. return true;
  7486. }
  7487. #endregion
  7488. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7489. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7490. {
  7491. LandAccessEntry entry = new LandAccessEntry();
  7492. entry.AgentID = block.ID;
  7493. entry.Flags = (AccessList)block.Flags;
  7494. entry.Expires = block.Time;
  7495. entries.Add(entry);
  7496. }
  7497. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7498. if (handlerParcelAccessListUpdateRequest != null)
  7499. {
  7500. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7501. updatePacket.Data.Flags,
  7502. updatePacket.Data.LocalID,
  7503. updatePacket.Data.TransactionID,
  7504. updatePacket.Data.SequenceID,
  7505. updatePacket.Data.Sections,
  7506. entries, this);
  7507. }
  7508. return true;
  7509. }
  7510. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7511. {
  7512. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7513. #region Packet Session and User Check
  7514. if (m_checkPackets)
  7515. {
  7516. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7517. propertiesRequest.AgentData.AgentID != AgentId)
  7518. return true;
  7519. }
  7520. #endregion
  7521. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7522. if (handlerParcelPropertiesRequest != null)
  7523. {
  7524. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7525. (int)Math.Round(propertiesRequest.ParcelData.South),
  7526. (int)Math.Round(propertiesRequest.ParcelData.East),
  7527. (int)Math.Round(propertiesRequest.ParcelData.North),
  7528. propertiesRequest.ParcelData.SequenceID,
  7529. propertiesRequest.ParcelData.SnapSelection, this);
  7530. }
  7531. return true;
  7532. }
  7533. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7534. {
  7535. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7536. #region Packet Session and User Check
  7537. if (m_checkPackets)
  7538. {
  7539. if (landDivide.AgentData.SessionID != SessionId ||
  7540. landDivide.AgentData.AgentID != AgentId)
  7541. return true;
  7542. }
  7543. #endregion
  7544. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7545. if (handlerParcelDivideRequest != null)
  7546. {
  7547. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7548. (int)Math.Round(landDivide.ParcelData.South),
  7549. (int)Math.Round(landDivide.ParcelData.East),
  7550. (int)Math.Round(landDivide.ParcelData.North), this);
  7551. }
  7552. return true;
  7553. }
  7554. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7555. {
  7556. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7557. #region Packet Session and User Check
  7558. if (m_checkPackets)
  7559. {
  7560. if (landJoin.AgentData.SessionID != SessionId ||
  7561. landJoin.AgentData.AgentID != AgentId)
  7562. return true;
  7563. }
  7564. #endregion
  7565. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7566. if (handlerParcelJoinRequest != null)
  7567. {
  7568. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7569. (int)Math.Round(landJoin.ParcelData.South),
  7570. (int)Math.Round(landJoin.ParcelData.East),
  7571. (int)Math.Round(landJoin.ParcelData.North), this);
  7572. }
  7573. return true;
  7574. }
  7575. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7576. {
  7577. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7578. #region Packet Session and User Check
  7579. if (m_checkPackets)
  7580. {
  7581. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7582. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7583. return true;
  7584. }
  7585. #endregion
  7586. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7587. if (handlerParcelPropertiesUpdateRequest != null)
  7588. {
  7589. LandUpdateArgs args = new LandUpdateArgs();
  7590. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7591. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7592. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7593. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7594. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7595. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7596. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7597. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7598. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7599. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7600. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7601. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7602. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7603. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7604. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7605. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7606. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7607. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7608. }
  7609. return true;
  7610. }
  7611. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7612. {
  7613. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7614. #region Packet Session and User Check
  7615. if (m_checkPackets)
  7616. {
  7617. if (selectPacket.AgentData.SessionID != SessionId ||
  7618. selectPacket.AgentData.AgentID != AgentId)
  7619. return true;
  7620. }
  7621. #endregion
  7622. List<UUID> returnIDs = new List<UUID>();
  7623. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7624. selectPacket.ReturnIDs)
  7625. {
  7626. returnIDs.Add(rb.ReturnID);
  7627. }
  7628. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7629. if (handlerParcelSelectObjects != null)
  7630. {
  7631. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7632. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7633. }
  7634. return true;
  7635. }
  7636. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7637. {
  7638. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7639. #region Packet Session and User Check
  7640. if (m_checkPackets)
  7641. {
  7642. if (reqPacket.AgentData.SessionID != SessionId ||
  7643. reqPacket.AgentData.AgentID != AgentId)
  7644. return true;
  7645. }
  7646. #endregion
  7647. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7648. if (handlerParcelObjectOwnerRequest != null)
  7649. {
  7650. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7651. }
  7652. return true;
  7653. }
  7654. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7655. {
  7656. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7657. #region Packet Session and User Check
  7658. if (m_checkPackets)
  7659. {
  7660. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7661. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7662. return true;
  7663. }
  7664. #endregion
  7665. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7666. if (handlerParcelGodForceOwner != null)
  7667. {
  7668. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7669. }
  7670. return true;
  7671. }
  7672. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7673. {
  7674. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7675. #region Packet Session and User Check
  7676. if (m_checkPackets)
  7677. {
  7678. if (releasePacket.AgentData.SessionID != SessionId ||
  7679. releasePacket.AgentData.AgentID != AgentId)
  7680. return true;
  7681. }
  7682. #endregion
  7683. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7684. if (handlerParcelAbandonRequest != null)
  7685. {
  7686. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7687. }
  7688. return true;
  7689. }
  7690. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7691. {
  7692. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7693. #region Packet Session and User Check
  7694. if (m_checkPackets)
  7695. {
  7696. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7697. reclaimPacket.AgentData.AgentID != AgentId)
  7698. return true;
  7699. }
  7700. #endregion
  7701. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7702. if (handlerParcelReclaim != null)
  7703. {
  7704. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  7705. }
  7706. return true;
  7707. }
  7708. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  7709. {
  7710. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  7711. #region Packet Session and User Check
  7712. if (m_checkPackets)
  7713. {
  7714. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  7715. parcelReturnObjects.AgentData.AgentID != AgentId)
  7716. return true;
  7717. }
  7718. #endregion
  7719. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  7720. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  7721. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  7722. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  7723. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  7724. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  7725. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  7726. if (handlerParcelReturnObjectsRequest != null)
  7727. {
  7728. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  7729. }
  7730. return true;
  7731. }
  7732. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  7733. {
  7734. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  7735. #region Packet Session and User Check
  7736. if (m_checkPackets)
  7737. {
  7738. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  7739. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  7740. return true;
  7741. }
  7742. #endregion
  7743. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  7744. if (handlerParcelSetOtherCleanTime != null)
  7745. {
  7746. handlerParcelSetOtherCleanTime(this,
  7747. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  7748. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  7749. }
  7750. return true;
  7751. }
  7752. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  7753. {
  7754. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  7755. #region Packet Session and User Check
  7756. if (m_checkPackets)
  7757. {
  7758. if (lsrp.AgentData.SessionID != SessionId ||
  7759. lsrp.AgentData.AgentID != AgentId)
  7760. return true;
  7761. }
  7762. #endregion
  7763. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  7764. if (handlerLandStatRequest != null)
  7765. {
  7766. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  7767. }
  7768. return true;
  7769. }
  7770. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  7771. {
  7772. ParcelDwellRequestPacket dwellrq =
  7773. (ParcelDwellRequestPacket)Pack;
  7774. #region Packet Session and User Check
  7775. if (m_checkPackets)
  7776. {
  7777. if (dwellrq.AgentData.SessionID != SessionId ||
  7778. dwellrq.AgentData.AgentID != AgentId)
  7779. return true;
  7780. }
  7781. #endregion
  7782. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  7783. if (handlerParcelDwellRequest != null)
  7784. {
  7785. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  7786. }
  7787. return true;
  7788. }
  7789. #endregion Parcel related packets
  7790. #region Estate Packets
  7791. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  7792. {
  7793. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  7794. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  7795. GodLandStatRequest handlerLandStatRequest;
  7796. #region Packet Session and User Check
  7797. if (m_checkPackets)
  7798. {
  7799. if (messagePacket.AgentData.SessionID != SessionId ||
  7800. messagePacket.AgentData.AgentID != AgentId)
  7801. return true;
  7802. }
  7803. #endregion
  7804. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  7805. switch (method)
  7806. {
  7807. case "getinfo":
  7808. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7809. {
  7810. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  7811. }
  7812. return true;
  7813. case "setregioninfo":
  7814. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7815. {
  7816. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  7817. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  7818. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  7819. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  7820. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  7821. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  7822. }
  7823. return true;
  7824. // case "texturebase":
  7825. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7826. // {
  7827. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7828. // {
  7829. // string s = Utils.BytesToString(block.Parameter);
  7830. // string[] splitField = s.Split(' ');
  7831. // if (splitField.Length == 2)
  7832. // {
  7833. // UUID tempUUID = new UUID(splitField[1]);
  7834. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  7835. // }
  7836. // }
  7837. // }
  7838. // break;
  7839. case "texturedetail":
  7840. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7841. {
  7842. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7843. {
  7844. string s = Utils.BytesToString(block.Parameter);
  7845. string[] splitField = s.Split(' ');
  7846. if (splitField.Length == 2)
  7847. {
  7848. Int16 corner = Convert.ToInt16(splitField[0]);
  7849. UUID textureUUID = new UUID(splitField[1]);
  7850. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  7851. }
  7852. }
  7853. }
  7854. return true;
  7855. case "textureheights":
  7856. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7857. {
  7858. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7859. {
  7860. string s = Utils.BytesToString(block.Parameter);
  7861. string[] splitField = s.Split(' ');
  7862. if (splitField.Length == 3)
  7863. {
  7864. Int16 corner = Convert.ToInt16(splitField[0]);
  7865. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  7866. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  7867. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  7868. }
  7869. }
  7870. }
  7871. return true;
  7872. case "texturecommit":
  7873. OnCommitEstateTerrainTextureRequest(this);
  7874. return true;
  7875. case "setregionterrain":
  7876. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7877. {
  7878. if (messagePacket.ParamList.Length != 9)
  7879. {
  7880. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  7881. }
  7882. else
  7883. {
  7884. try
  7885. {
  7886. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7887. if (!tmp.Contains(".")) tmp += ".00";
  7888. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7889. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7890. if (!tmp.Contains(".")) tmp += ".00";
  7891. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7892. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  7893. if (!tmp.Contains(".")) tmp += ".00";
  7894. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7895. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  7896. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  7897. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  7898. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  7899. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  7900. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  7901. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  7902. }
  7903. catch (Exception ex)
  7904. {
  7905. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  7906. }
  7907. }
  7908. }
  7909. return true;
  7910. case "restart":
  7911. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7912. {
  7913. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  7914. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7915. {
  7916. float timeSeconds;
  7917. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  7918. timeSeconds = (int)timeSeconds;
  7919. OnEstateRestartSimRequest(this, (int)timeSeconds);
  7920. }
  7921. }
  7922. return true;
  7923. case "estatechangecovenantid":
  7924. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7925. {
  7926. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7927. {
  7928. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  7929. OnEstateChangeCovenantRequest(this, newCovenantID);
  7930. }
  7931. }
  7932. return true;
  7933. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  7934. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7935. {
  7936. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7937. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  7938. }
  7939. return true;
  7940. case "simulatormessage":
  7941. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7942. {
  7943. UUID invoice = messagePacket.MethodData.Invoice;
  7944. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7945. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7946. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7947. UUID sessionID = messagePacket.AgentData.SessionID;
  7948. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7949. }
  7950. return true;
  7951. case "instantmessage":
  7952. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7953. {
  7954. if (messagePacket.ParamList.Length < 2)
  7955. return true;
  7956. UUID invoice = messagePacket.MethodData.Invoice;
  7957. UUID sessionID = messagePacket.AgentData.SessionID;
  7958. UUID SenderID;
  7959. string SenderName;
  7960. string Message;
  7961. if (messagePacket.ParamList.Length < 5)
  7962. {
  7963. SenderID = AgentId;
  7964. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7965. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7966. }
  7967. else
  7968. {
  7969. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7970. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7971. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7972. }
  7973. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7974. }
  7975. return true;
  7976. case "setregiondebug":
  7977. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7978. {
  7979. UUID invoice = messagePacket.MethodData.Invoice;
  7980. UUID SenderID = messagePacket.AgentData.AgentID;
  7981. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  7982. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  7983. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  7984. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  7985. }
  7986. return true;
  7987. case "teleporthomeuser":
  7988. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7989. {
  7990. UUID invoice = messagePacket.MethodData.Invoice;
  7991. UUID SenderID = messagePacket.AgentData.AgentID;
  7992. UUID Prey;
  7993. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  7994. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  7995. }
  7996. return true;
  7997. case "teleporthomeallusers":
  7998. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7999. {
  8000. UUID invoice = messagePacket.MethodData.Invoice;
  8001. UUID SenderID = messagePacket.AgentData.AgentID;
  8002. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8003. }
  8004. return true;
  8005. case "colliders":
  8006. handlerLandStatRequest = OnLandStatRequest;
  8007. if (handlerLandStatRequest != null)
  8008. {
  8009. handlerLandStatRequest(0, 1, 0, "", this);
  8010. }
  8011. return true;
  8012. case "scripts":
  8013. handlerLandStatRequest = OnLandStatRequest;
  8014. if (handlerLandStatRequest != null)
  8015. {
  8016. handlerLandStatRequest(0, 0, 0, "", this);
  8017. }
  8018. return true;
  8019. case "terrain":
  8020. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8021. {
  8022. if (messagePacket.ParamList.Length > 0)
  8023. {
  8024. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8025. {
  8026. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8027. if (handlerBakeTerrain != null)
  8028. {
  8029. handlerBakeTerrain(this);
  8030. }
  8031. }
  8032. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8033. {
  8034. if (messagePacket.ParamList.Length > 1)
  8035. {
  8036. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8037. if (handlerRequestTerrain != null)
  8038. {
  8039. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8040. }
  8041. }
  8042. }
  8043. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8044. {
  8045. if (messagePacket.ParamList.Length > 1)
  8046. {
  8047. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8048. if (handlerUploadTerrain != null)
  8049. {
  8050. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8051. }
  8052. }
  8053. }
  8054. }
  8055. }
  8056. return true;
  8057. case "estatechangeinfo":
  8058. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8059. {
  8060. UUID invoice = messagePacket.MethodData.Invoice;
  8061. UUID SenderID = messagePacket.AgentData.AgentID;
  8062. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8063. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8064. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8065. if (handlerEstateChangeInfo != null)
  8066. {
  8067. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8068. }
  8069. }
  8070. return true;
  8071. case "telehub":
  8072. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8073. {
  8074. UUID invoice = messagePacket.MethodData.Invoice;
  8075. UUID SenderID = messagePacket.AgentData.AgentID;
  8076. UInt32 param1 = 0u;
  8077. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8078. if (command != "info ui")
  8079. {
  8080. try
  8081. {
  8082. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8083. }
  8084. catch
  8085. {
  8086. }
  8087. }
  8088. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8089. if (handlerEstateManageTelehub != null)
  8090. {
  8091. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8092. }
  8093. }
  8094. return true;
  8095. default:
  8096. m_log.WarnFormat(
  8097. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8098. method, Name, Scene.Name);
  8099. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8100. {
  8101. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8102. string data = (string)Utils.BytesToString(block.Parameter);
  8103. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8104. }
  8105. return true;
  8106. }
  8107. //int parcelID, uint reportType, uint requestflags, string filter
  8108. //lsrp.RequestData.ParcelLocalID;
  8109. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8110. //lsrp.RequestData.RequestFlags;
  8111. //lsrp.RequestData.Filter;
  8112. }
  8113. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8114. {
  8115. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8116. #region Packet Session and User Check
  8117. if (m_checkPackets)
  8118. {
  8119. if (mPacket.SessionID != SessionId ||
  8120. mPacket.AgentID != AgentId)
  8121. return true;
  8122. }
  8123. #endregion
  8124. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8125. if (handlerRegionInfoRequest != null)
  8126. {
  8127. handlerRegionInfoRequest(this);
  8128. }
  8129. return true;
  8130. }
  8131. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8132. {
  8133. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8134. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8135. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8136. if (handlerEstateCovenantRequest != null)
  8137. {
  8138. handlerEstateCovenantRequest(this);
  8139. }
  8140. return true;
  8141. }
  8142. #endregion Estate Packets
  8143. #region GodPackets
  8144. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8145. {
  8146. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8147. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8148. UUID token = rblock.Token;
  8149. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8150. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8151. if (handlerReqGodlikePowers != null)
  8152. {
  8153. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8154. }
  8155. return true;
  8156. }
  8157. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8158. {
  8159. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8160. (GodUpdateRegionInfoPacket)Packet;
  8161. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8162. if (handlerGodUpdateRegionInfo != null)
  8163. {
  8164. handlerGodUpdateRegionInfo(this,
  8165. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8166. GodUpdateRegionInfo.RegionInfo.EstateID,
  8167. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8168. GodUpdateRegionInfo.RegionInfo.SimName,
  8169. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8170. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8171. return true;
  8172. }
  8173. return false;
  8174. }
  8175. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8176. {
  8177. SimWideDeletesPacket SimWideDeletesRequest =
  8178. (SimWideDeletesPacket)Packet;
  8179. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8180. if (handlerSimWideDeletesRequest != null)
  8181. {
  8182. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8183. return true;
  8184. }
  8185. return false;
  8186. }
  8187. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8188. {
  8189. GodlikeMessagePacket GodlikeMessage =
  8190. (GodlikeMessagePacket)Packet;
  8191. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8192. if (handlerGodlikeMessage != null)
  8193. {
  8194. handlerGodlikeMessage(this,
  8195. GodlikeMessage.MethodData.Invoice,
  8196. GodlikeMessage.MethodData.Method,
  8197. GodlikeMessage.ParamList[0].Parameter);
  8198. return true;
  8199. }
  8200. return false;
  8201. }
  8202. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8203. {
  8204. StateSavePacket SaveStateMessage =
  8205. (StateSavePacket)Packet;
  8206. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8207. if (handlerSaveStatePacket != null)
  8208. {
  8209. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8210. return true;
  8211. }
  8212. return false;
  8213. }
  8214. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8215. {
  8216. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8217. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8218. {
  8219. GodKickUser handlerGodKickUser = OnGodKickUser;
  8220. if (handlerGodKickUser != null)
  8221. {
  8222. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8223. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8224. }
  8225. }
  8226. else
  8227. {
  8228. SendAgentAlertMessage("Kick request denied", false);
  8229. }
  8230. //KickUserPacket kupack = new KickUserPacket();
  8231. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8232. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8233. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8234. //kupack.TargetBlock.TargetIP = (uint)0;
  8235. //kupack.TargetBlock.TargetPort = (ushort)0;
  8236. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8237. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8238. return true;
  8239. }
  8240. #endregion GodPackets
  8241. #region Economy/Transaction Packets
  8242. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8243. {
  8244. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8245. #region Packet Session and User Check
  8246. if (m_checkPackets)
  8247. {
  8248. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8249. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8250. return true;
  8251. }
  8252. #endregion
  8253. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8254. if (handlerMoneyBalanceRequest != null)
  8255. {
  8256. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8257. }
  8258. return true;
  8259. }
  8260. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8261. {
  8262. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8263. if (handlerEconomoyDataRequest != null)
  8264. {
  8265. handlerEconomoyDataRequest(AgentId);
  8266. }
  8267. return true;
  8268. }
  8269. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8270. {
  8271. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8272. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8273. if (handlerRequestPayPrice != null)
  8274. {
  8275. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8276. }
  8277. return true;
  8278. }
  8279. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8280. {
  8281. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8282. #region Packet Session and User Check
  8283. if (m_checkPackets)
  8284. {
  8285. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8286. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8287. return true;
  8288. }
  8289. #endregion
  8290. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8291. if (handlerObjectSaleInfo != null)
  8292. {
  8293. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8294. in objectSaleInfoPacket.ObjectData)
  8295. {
  8296. handlerObjectSaleInfo(this,
  8297. objectSaleInfoPacket.AgentData.AgentID,
  8298. objectSaleInfoPacket.AgentData.SessionID,
  8299. d.LocalID,
  8300. d.SaleType,
  8301. d.SalePrice);
  8302. }
  8303. }
  8304. return true;
  8305. }
  8306. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8307. {
  8308. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8309. #region Packet Session and User Check
  8310. if (m_checkPackets)
  8311. {
  8312. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8313. objectBuyPacket.AgentData.AgentID != AgentId)
  8314. return true;
  8315. }
  8316. #endregion
  8317. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8318. if (handlerObjectBuy != null)
  8319. {
  8320. foreach (ObjectBuyPacket.ObjectDataBlock d
  8321. in objectBuyPacket.ObjectData)
  8322. {
  8323. handlerObjectBuy(this,
  8324. objectBuyPacket.AgentData.AgentID,
  8325. objectBuyPacket.AgentData.SessionID,
  8326. objectBuyPacket.AgentData.GroupID,
  8327. objectBuyPacket.AgentData.CategoryID,
  8328. d.ObjectLocalID,
  8329. d.SaleType,
  8330. d.SalePrice);
  8331. }
  8332. }
  8333. return true;
  8334. }
  8335. #endregion Economy/Transaction Packets
  8336. #region Script Packets
  8337. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8338. {
  8339. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8340. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8341. if (handlerGetScriptRunning != null)
  8342. {
  8343. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8344. }
  8345. return true;
  8346. }
  8347. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8348. {
  8349. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8350. #region Packet Session and User Check
  8351. if (m_checkPackets)
  8352. {
  8353. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8354. setScriptRunning.AgentData.AgentID != AgentId)
  8355. return true;
  8356. }
  8357. #endregion
  8358. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8359. if (handlerSetScriptRunning != null)
  8360. {
  8361. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8362. }
  8363. return true;
  8364. }
  8365. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8366. {
  8367. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8368. #region Packet Session and User Check
  8369. if (m_checkPackets)
  8370. {
  8371. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8372. scriptResetPacket.AgentData.AgentID != AgentId)
  8373. return true;
  8374. }
  8375. #endregion
  8376. ScriptReset handlerScriptReset = OnScriptReset;
  8377. if (handlerScriptReset != null)
  8378. {
  8379. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8380. }
  8381. return true;
  8382. }
  8383. #endregion Script Packets
  8384. #region Gesture Managment
  8385. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8386. {
  8387. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8388. #region Packet Session and User Check
  8389. if (m_checkPackets)
  8390. {
  8391. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8392. activateGesturePacket.AgentData.AgentID != AgentId)
  8393. return true;
  8394. }
  8395. #endregion
  8396. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8397. if (handlerActivateGesture != null)
  8398. {
  8399. handlerActivateGesture(this,
  8400. activateGesturePacket.Data[0].AssetID,
  8401. activateGesturePacket.Data[0].ItemID);
  8402. }
  8403. else m_log.Error("Null pointer for activateGesture");
  8404. return true;
  8405. }
  8406. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8407. {
  8408. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8409. #region Packet Session and User Check
  8410. if (m_checkPackets)
  8411. {
  8412. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8413. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8414. return true;
  8415. }
  8416. #endregion
  8417. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8418. if (handlerDeactivateGesture != null)
  8419. {
  8420. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8421. }
  8422. return true;
  8423. }
  8424. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8425. {
  8426. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8427. #region Packet Session and User Check
  8428. if (m_checkPackets)
  8429. {
  8430. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8431. objectOwnerPacket.AgentData.AgentID != AgentId)
  8432. return true;
  8433. }
  8434. #endregion
  8435. List<uint> localIDs = new List<uint>();
  8436. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8437. localIDs.Add(d.ObjectLocalID);
  8438. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8439. if (handlerObjectOwner != null)
  8440. {
  8441. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8442. }
  8443. return true;
  8444. }
  8445. #endregion Gesture Managment
  8446. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8447. {
  8448. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8449. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8450. {
  8451. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8452. AgentFOV handlerAgentFOV = OnAgentFOV;
  8453. if (handlerAgentFOV != null)
  8454. {
  8455. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8456. }
  8457. }
  8458. return true;
  8459. }
  8460. #region unimplemented handlers
  8461. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8462. {
  8463. // TODO: handle this packet
  8464. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8465. return true;
  8466. }
  8467. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8468. {
  8469. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8470. #region Packet Session and User Check
  8471. if (m_checkPackets)
  8472. {
  8473. if (mirpk.AgentData.SessionID != SessionId ||
  8474. mirpk.AgentData.AgentID != AgentId)
  8475. return true;
  8476. }
  8477. #endregion
  8478. //m_log.Debug(mirpk.ToString());
  8479. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8480. if (handlerMapItemRequest != null)
  8481. {
  8482. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8483. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8484. mirpk.RequestData.RegionHandle);
  8485. }
  8486. return true;
  8487. }
  8488. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8489. {
  8490. return true;
  8491. }
  8492. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8493. {
  8494. MuteListRequestPacket muteListRequest =
  8495. (MuteListRequestPacket)Pack;
  8496. #region Packet Session and User Check
  8497. if (m_checkPackets)
  8498. {
  8499. if (muteListRequest.AgentData.SessionID != SessionId ||
  8500. muteListRequest.AgentData.AgentID != AgentId)
  8501. return true;
  8502. }
  8503. #endregion
  8504. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8505. if (handlerMuteListRequest != null)
  8506. {
  8507. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8508. }
  8509. else
  8510. {
  8511. SendUseCachedMuteList();
  8512. }
  8513. return true;
  8514. }
  8515. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8516. {
  8517. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8518. (UpdateMuteListEntryPacket)Packet;
  8519. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8520. if (handlerUpdateMuteListEntry != null)
  8521. {
  8522. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8523. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8524. UpdateMuteListEntry.MuteData.MuteType,
  8525. UpdateMuteListEntry.AgentData.AgentID);
  8526. return true;
  8527. }
  8528. return false;
  8529. }
  8530. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8531. {
  8532. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8533. (RemoveMuteListEntryPacket)Packet;
  8534. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8535. if (handlerRemoveMuteListEntry != null)
  8536. {
  8537. handlerRemoveMuteListEntry(this,
  8538. RemoveMuteListEntry.MuteData.MuteID,
  8539. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8540. RemoveMuteListEntry.AgentData.AgentID);
  8541. return true;
  8542. }
  8543. return false;
  8544. }
  8545. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8546. {
  8547. UserReportPacket UserReport =
  8548. (UserReportPacket)Packet;
  8549. NewUserReport handlerUserReport = OnUserReport;
  8550. if (handlerUserReport != null)
  8551. {
  8552. handlerUserReport(this,
  8553. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8554. UserReport.ReportData.AbuserID,
  8555. UserReport.ReportData.Category,
  8556. UserReport.ReportData.CheckFlags,
  8557. Utils.BytesToString(UserReport.ReportData.Details),
  8558. UserReport.ReportData.ObjectID,
  8559. UserReport.ReportData.Position,
  8560. UserReport.ReportData.ReportType,
  8561. UserReport.ReportData.ScreenshotID,
  8562. Utils.BytesToString(UserReport.ReportData.Summary),
  8563. UserReport.AgentData.AgentID);
  8564. return true;
  8565. }
  8566. return false;
  8567. }
  8568. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8569. {
  8570. // SendPostcardPacket SendPostcard =
  8571. // (SendPostcardPacket)packet;
  8572. SendPostcard handlerSendPostcard = OnSendPostcard;
  8573. if (handlerSendPostcard != null)
  8574. {
  8575. handlerSendPostcard(this);
  8576. return true;
  8577. }
  8578. return false;
  8579. }
  8580. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8581. {
  8582. return true;
  8583. }
  8584. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8585. {
  8586. return true;
  8587. }
  8588. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8589. {
  8590. return true;
  8591. }
  8592. #endregion unimplemented handlers
  8593. #region Dir handlers
  8594. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8595. {
  8596. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8597. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8598. #region Packet Session and User Check
  8599. if (m_checkPackets)
  8600. {
  8601. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8602. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8603. return true;
  8604. }
  8605. #endregion
  8606. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8607. if (handlerDirPlacesQuery != null)
  8608. {
  8609. handlerDirPlacesQuery(this,
  8610. dirPlacesQueryPacket.QueryData.QueryID,
  8611. Utils.BytesToString(
  8612. dirPlacesQueryPacket.QueryData.QueryText),
  8613. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8614. (int)dirPlacesQueryPacket.QueryData.Category,
  8615. Utils.BytesToString(
  8616. dirPlacesQueryPacket.QueryData.SimName),
  8617. dirPlacesQueryPacket.QueryData.QueryStart);
  8618. }
  8619. return true;
  8620. }
  8621. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8622. {
  8623. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8624. #region Packet Session and User Check
  8625. if (m_checkPackets)
  8626. {
  8627. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8628. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8629. return true;
  8630. }
  8631. #endregion
  8632. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8633. if (handlerDirFindQuery != null)
  8634. {
  8635. handlerDirFindQuery(this,
  8636. dirFindQueryPacket.QueryData.QueryID,
  8637. Utils.BytesToString(
  8638. dirFindQueryPacket.QueryData.QueryText),
  8639. dirFindQueryPacket.QueryData.QueryFlags,
  8640. dirFindQueryPacket.QueryData.QueryStart);
  8641. }
  8642. return true;
  8643. }
  8644. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8645. {
  8646. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8647. #region Packet Session and User Check
  8648. if (m_checkPackets)
  8649. {
  8650. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8651. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8652. return true;
  8653. }
  8654. #endregion
  8655. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8656. if (handlerDirLandQuery != null)
  8657. {
  8658. handlerDirLandQuery(this,
  8659. dirLandQueryPacket.QueryData.QueryID,
  8660. dirLandQueryPacket.QueryData.QueryFlags,
  8661. dirLandQueryPacket.QueryData.SearchType,
  8662. dirLandQueryPacket.QueryData.Price,
  8663. dirLandQueryPacket.QueryData.Area,
  8664. dirLandQueryPacket.QueryData.QueryStart);
  8665. }
  8666. return true;
  8667. }
  8668. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8669. {
  8670. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8671. #region Packet Session and User Check
  8672. if (m_checkPackets)
  8673. {
  8674. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8675. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8676. return true;
  8677. }
  8678. #endregion
  8679. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8680. if (handlerDirPopularQuery != null)
  8681. {
  8682. handlerDirPopularQuery(this,
  8683. dirPopularQueryPacket.QueryData.QueryID,
  8684. dirPopularQueryPacket.QueryData.QueryFlags);
  8685. }
  8686. return true;
  8687. }
  8688. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8689. {
  8690. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8691. #region Packet Session and User Check
  8692. if (m_checkPackets)
  8693. {
  8694. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8695. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8696. return true;
  8697. }
  8698. #endregion
  8699. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8700. if (handlerDirClassifiedQuery != null)
  8701. {
  8702. handlerDirClassifiedQuery(this,
  8703. dirClassifiedQueryPacket.QueryData.QueryID,
  8704. Utils.BytesToString(
  8705. dirClassifiedQueryPacket.QueryData.QueryText),
  8706. dirClassifiedQueryPacket.QueryData.QueryFlags,
  8707. dirClassifiedQueryPacket.QueryData.Category,
  8708. dirClassifiedQueryPacket.QueryData.QueryStart);
  8709. }
  8710. return true;
  8711. }
  8712. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  8713. {
  8714. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  8715. #region Packet Session and User Check
  8716. if (m_checkPackets)
  8717. {
  8718. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  8719. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  8720. return true;
  8721. }
  8722. #endregion
  8723. if (OnEventInfoRequest != null)
  8724. {
  8725. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  8726. }
  8727. return true;
  8728. }
  8729. #endregion
  8730. #region Calling Card
  8731. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  8732. {
  8733. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  8734. #region Packet Session and User Check
  8735. if (m_checkPackets)
  8736. {
  8737. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  8738. offerCallingCardPacket.AgentData.AgentID != AgentId)
  8739. return true;
  8740. }
  8741. #endregion
  8742. if (OnOfferCallingCard != null)
  8743. {
  8744. OnOfferCallingCard(this,
  8745. offerCallingCardPacket.AgentBlock.DestID,
  8746. offerCallingCardPacket.AgentBlock.TransactionID);
  8747. }
  8748. return true;
  8749. }
  8750. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  8751. {
  8752. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  8753. #region Packet Session and User Check
  8754. if (m_checkPackets)
  8755. {
  8756. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  8757. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  8758. return true;
  8759. }
  8760. #endregion
  8761. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  8762. // contain exactly one entry
  8763. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  8764. {
  8765. OnAcceptCallingCard(this,
  8766. acceptCallingCardPacket.TransactionBlock.TransactionID,
  8767. acceptCallingCardPacket.FolderData[0].FolderID);
  8768. }
  8769. return true;
  8770. }
  8771. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  8772. {
  8773. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  8774. #region Packet Session and User Check
  8775. if (m_checkPackets)
  8776. {
  8777. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  8778. declineCallingCardPacket.AgentData.AgentID != AgentId)
  8779. return true;
  8780. }
  8781. #endregion
  8782. if (OnDeclineCallingCard != null)
  8783. {
  8784. OnDeclineCallingCard(this,
  8785. declineCallingCardPacket.TransactionBlock.TransactionID);
  8786. }
  8787. return true;
  8788. }
  8789. #endregion Calling Card
  8790. #region Groups
  8791. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  8792. {
  8793. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  8794. #region Packet Session and User Check
  8795. if (m_checkPackets)
  8796. {
  8797. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  8798. activateGroupPacket.AgentData.AgentID != AgentId)
  8799. return true;
  8800. }
  8801. #endregion
  8802. if (m_GroupsModule != null)
  8803. {
  8804. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  8805. m_GroupsModule.SendAgentGroupDataUpdate(this);
  8806. }
  8807. return true;
  8808. }
  8809. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  8810. {
  8811. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  8812. (GroupVoteHistoryRequestPacket)Packet;
  8813. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  8814. if (handlerGroupVoteHistoryRequest != null)
  8815. {
  8816. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  8817. return true;
  8818. }
  8819. return false;
  8820. }
  8821. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  8822. {
  8823. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  8824. (GroupActiveProposalsRequestPacket)Packet;
  8825. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  8826. if (handlerGroupActiveProposalsRequest != null)
  8827. {
  8828. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  8829. return true;
  8830. }
  8831. return false;
  8832. }
  8833. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  8834. {
  8835. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  8836. (GroupAccountDetailsRequestPacket)Packet;
  8837. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  8838. if (handlerGroupAccountDetailsRequest != null)
  8839. {
  8840. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  8841. return true;
  8842. }
  8843. return false;
  8844. }
  8845. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  8846. {
  8847. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  8848. (GroupAccountSummaryRequestPacket)Packet;
  8849. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  8850. if (handlerGroupAccountSummaryRequest != null)
  8851. {
  8852. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  8853. return true;
  8854. }
  8855. return false;
  8856. }
  8857. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  8858. {
  8859. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  8860. (GroupAccountTransactionsRequestPacket)Packet;
  8861. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  8862. if (handlerGroupAccountTransactionsRequest != null)
  8863. {
  8864. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  8865. return true;
  8866. }
  8867. return false;
  8868. }
  8869. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  8870. {
  8871. GroupTitlesRequestPacket groupTitlesRequest =
  8872. (GroupTitlesRequestPacket)Pack;
  8873. #region Packet Session and User Check
  8874. if (m_checkPackets)
  8875. {
  8876. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  8877. groupTitlesRequest.AgentData.AgentID != AgentId)
  8878. return true;
  8879. }
  8880. #endregion
  8881. if (m_GroupsModule != null)
  8882. {
  8883. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  8884. groupTitlesReply.AgentData =
  8885. new GroupTitlesReplyPacket.AgentDataBlock();
  8886. groupTitlesReply.AgentData.AgentID = AgentId;
  8887. groupTitlesReply.AgentData.GroupID =
  8888. groupTitlesRequest.AgentData.GroupID;
  8889. groupTitlesReply.AgentData.RequestID =
  8890. groupTitlesRequest.AgentData.RequestID;
  8891. List<GroupTitlesData> titles =
  8892. m_GroupsModule.GroupTitlesRequest(this,
  8893. groupTitlesRequest.AgentData.GroupID);
  8894. groupTitlesReply.GroupData =
  8895. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  8896. int i = 0;
  8897. foreach (GroupTitlesData d in titles)
  8898. {
  8899. groupTitlesReply.GroupData[i] =
  8900. new GroupTitlesReplyPacket.GroupDataBlock();
  8901. groupTitlesReply.GroupData[i].Title =
  8902. Util.StringToBytes256(d.Name);
  8903. groupTitlesReply.GroupData[i].RoleID =
  8904. d.UUID;
  8905. groupTitlesReply.GroupData[i].Selected =
  8906. d.Selected;
  8907. i++;
  8908. }
  8909. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  8910. }
  8911. return true;
  8912. }
  8913. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  8914. {
  8915. GroupProfileRequestPacket groupProfileRequest =
  8916. (GroupProfileRequestPacket)Pack;
  8917. #region Packet Session and User Check
  8918. if (m_checkPackets)
  8919. {
  8920. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  8921. groupProfileRequest.AgentData.AgentID != AgentId)
  8922. return true;
  8923. }
  8924. #endregion
  8925. if (m_GroupsModule != null)
  8926. {
  8927. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  8928. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  8929. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  8930. groupProfileReply.AgentData.AgentID = AgentId;
  8931. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  8932. groupProfileRequest.GroupData.GroupID);
  8933. groupProfileReply.GroupData.GroupID = d.GroupID;
  8934. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  8935. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  8936. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  8937. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  8938. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  8939. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  8940. groupProfileReply.GroupData.FounderID = d.FounderID;
  8941. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  8942. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  8943. groupProfileReply.GroupData.Money = d.Money;
  8944. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  8945. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  8946. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  8947. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  8948. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  8949. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  8950. }
  8951. return true;
  8952. }
  8953. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  8954. {
  8955. GroupMembersRequestPacket groupMembersRequestPacket =
  8956. (GroupMembersRequestPacket)Pack;
  8957. #region Packet Session and User Check
  8958. if (m_checkPackets)
  8959. {
  8960. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  8961. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  8962. return true;
  8963. }
  8964. #endregion
  8965. if (m_GroupsModule != null)
  8966. {
  8967. List<GroupMembersData> members =
  8968. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  8969. int memberCount = members.Count;
  8970. while (true)
  8971. {
  8972. int blockCount = members.Count;
  8973. if (blockCount > 40)
  8974. blockCount = 40;
  8975. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  8976. groupMembersReply.AgentData =
  8977. new GroupMembersReplyPacket.AgentDataBlock();
  8978. groupMembersReply.GroupData =
  8979. new GroupMembersReplyPacket.GroupDataBlock();
  8980. groupMembersReply.MemberData =
  8981. new GroupMembersReplyPacket.MemberDataBlock[
  8982. blockCount];
  8983. groupMembersReply.AgentData.AgentID = AgentId;
  8984. groupMembersReply.GroupData.GroupID =
  8985. groupMembersRequestPacket.GroupData.GroupID;
  8986. groupMembersReply.GroupData.RequestID =
  8987. groupMembersRequestPacket.GroupData.RequestID;
  8988. groupMembersReply.GroupData.MemberCount = memberCount;
  8989. for (int i = 0; i < blockCount; i++)
  8990. {
  8991. GroupMembersData m = members[0];
  8992. members.RemoveAt(0);
  8993. groupMembersReply.MemberData[i] =
  8994. new GroupMembersReplyPacket.MemberDataBlock();
  8995. groupMembersReply.MemberData[i].AgentID =
  8996. m.AgentID;
  8997. groupMembersReply.MemberData[i].Contribution =
  8998. m.Contribution;
  8999. groupMembersReply.MemberData[i].OnlineStatus =
  9000. Util.StringToBytes256(m.OnlineStatus);
  9001. groupMembersReply.MemberData[i].AgentPowers =
  9002. m.AgentPowers;
  9003. groupMembersReply.MemberData[i].Title =
  9004. Util.StringToBytes256(m.Title);
  9005. groupMembersReply.MemberData[i].IsOwner =
  9006. m.IsOwner;
  9007. }
  9008. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9009. if (members.Count == 0)
  9010. return true;
  9011. }
  9012. }
  9013. return true;
  9014. }
  9015. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9016. {
  9017. GroupRoleDataRequestPacket groupRolesRequest =
  9018. (GroupRoleDataRequestPacket)Pack;
  9019. #region Packet Session and User Check
  9020. if (m_checkPackets)
  9021. {
  9022. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9023. groupRolesRequest.AgentData.AgentID != AgentId)
  9024. return true;
  9025. }
  9026. #endregion
  9027. if (m_GroupsModule != null)
  9028. {
  9029. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9030. groupRolesReply.AgentData =
  9031. new GroupRoleDataReplyPacket.AgentDataBlock();
  9032. groupRolesReply.AgentData.AgentID = AgentId;
  9033. groupRolesReply.GroupData =
  9034. new GroupRoleDataReplyPacket.GroupDataBlock();
  9035. groupRolesReply.GroupData.GroupID =
  9036. groupRolesRequest.GroupData.GroupID;
  9037. groupRolesReply.GroupData.RequestID =
  9038. groupRolesRequest.GroupData.RequestID;
  9039. List<GroupRolesData> titles =
  9040. m_GroupsModule.GroupRoleDataRequest(this,
  9041. groupRolesRequest.GroupData.GroupID);
  9042. groupRolesReply.GroupData.RoleCount =
  9043. titles.Count;
  9044. groupRolesReply.RoleData =
  9045. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9046. int i = 0;
  9047. foreach (GroupRolesData d in titles)
  9048. {
  9049. groupRolesReply.RoleData[i] =
  9050. new GroupRoleDataReplyPacket.RoleDataBlock();
  9051. groupRolesReply.RoleData[i].RoleID =
  9052. d.RoleID;
  9053. groupRolesReply.RoleData[i].Name =
  9054. Util.StringToBytes256(d.Name);
  9055. groupRolesReply.RoleData[i].Title =
  9056. Util.StringToBytes256(d.Title);
  9057. groupRolesReply.RoleData[i].Description =
  9058. Util.StringToBytes1024(d.Description);
  9059. groupRolesReply.RoleData[i].Powers =
  9060. d.Powers;
  9061. groupRolesReply.RoleData[i].Members =
  9062. (uint)d.Members;
  9063. i++;
  9064. }
  9065. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9066. }
  9067. return true;
  9068. }
  9069. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9070. {
  9071. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9072. (GroupRoleMembersRequestPacket)Pack;
  9073. #region Packet Session and User Check
  9074. if (m_checkPackets)
  9075. {
  9076. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9077. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9078. return true;
  9079. }
  9080. #endregion
  9081. if (m_GroupsModule != null)
  9082. {
  9083. List<GroupRoleMembersData> mappings =
  9084. m_GroupsModule.GroupRoleMembersRequest(this,
  9085. groupRoleMembersRequest.GroupData.GroupID);
  9086. int mappingsCount = mappings.Count;
  9087. while (mappings.Count > 0)
  9088. {
  9089. int pairs = mappings.Count;
  9090. if (pairs > 32)
  9091. pairs = 32;
  9092. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9093. groupRoleMembersReply.AgentData =
  9094. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9095. groupRoleMembersReply.AgentData.AgentID =
  9096. AgentId;
  9097. groupRoleMembersReply.AgentData.GroupID =
  9098. groupRoleMembersRequest.GroupData.GroupID;
  9099. groupRoleMembersReply.AgentData.RequestID =
  9100. groupRoleMembersRequest.GroupData.RequestID;
  9101. groupRoleMembersReply.AgentData.TotalPairs =
  9102. (uint)mappingsCount;
  9103. groupRoleMembersReply.MemberData =
  9104. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9105. for (int i = 0; i < pairs; i++)
  9106. {
  9107. GroupRoleMembersData d = mappings[0];
  9108. mappings.RemoveAt(0);
  9109. groupRoleMembersReply.MemberData[i] =
  9110. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9111. groupRoleMembersReply.MemberData[i].RoleID =
  9112. d.RoleID;
  9113. groupRoleMembersReply.MemberData[i].MemberID =
  9114. d.MemberID;
  9115. }
  9116. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9117. }
  9118. }
  9119. return true;
  9120. }
  9121. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9122. {
  9123. CreateGroupRequestPacket createGroupRequest =
  9124. (CreateGroupRequestPacket)Pack;
  9125. #region Packet Session and User Check
  9126. if (m_checkPackets)
  9127. {
  9128. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9129. createGroupRequest.AgentData.AgentID != AgentId)
  9130. return true;
  9131. }
  9132. #endregion
  9133. if (m_GroupsModule != null)
  9134. {
  9135. m_GroupsModule.CreateGroup(this,
  9136. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9137. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9138. createGroupRequest.GroupData.ShowInList,
  9139. createGroupRequest.GroupData.InsigniaID,
  9140. createGroupRequest.GroupData.MembershipFee,
  9141. createGroupRequest.GroupData.OpenEnrollment,
  9142. createGroupRequest.GroupData.AllowPublish,
  9143. createGroupRequest.GroupData.MaturePublish);
  9144. }
  9145. return true;
  9146. }
  9147. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9148. {
  9149. UpdateGroupInfoPacket updateGroupInfo =
  9150. (UpdateGroupInfoPacket)Pack;
  9151. #region Packet Session and User Check
  9152. if (m_checkPackets)
  9153. {
  9154. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9155. updateGroupInfo.AgentData.AgentID != AgentId)
  9156. return true;
  9157. }
  9158. #endregion
  9159. if (m_GroupsModule != null)
  9160. {
  9161. m_GroupsModule.UpdateGroupInfo(this,
  9162. updateGroupInfo.GroupData.GroupID,
  9163. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9164. updateGroupInfo.GroupData.ShowInList,
  9165. updateGroupInfo.GroupData.InsigniaID,
  9166. updateGroupInfo.GroupData.MembershipFee,
  9167. updateGroupInfo.GroupData.OpenEnrollment,
  9168. updateGroupInfo.GroupData.AllowPublish,
  9169. updateGroupInfo.GroupData.MaturePublish);
  9170. }
  9171. return true;
  9172. }
  9173. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9174. {
  9175. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9176. (SetGroupAcceptNoticesPacket)Pack;
  9177. #region Packet Session and User Check
  9178. if (m_checkPackets)
  9179. {
  9180. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9181. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9182. return true;
  9183. }
  9184. #endregion
  9185. if (m_GroupsModule != null)
  9186. {
  9187. m_GroupsModule.SetGroupAcceptNotices(this,
  9188. setGroupAcceptNotices.Data.GroupID,
  9189. setGroupAcceptNotices.Data.AcceptNotices,
  9190. setGroupAcceptNotices.NewData.ListInProfile);
  9191. }
  9192. return true;
  9193. }
  9194. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9195. {
  9196. GroupTitleUpdatePacket groupTitleUpdate =
  9197. (GroupTitleUpdatePacket)Pack;
  9198. #region Packet Session and User Check
  9199. if (m_checkPackets)
  9200. {
  9201. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9202. groupTitleUpdate.AgentData.AgentID != AgentId)
  9203. return true;
  9204. }
  9205. #endregion
  9206. if (m_GroupsModule != null)
  9207. {
  9208. m_GroupsModule.GroupTitleUpdate(this,
  9209. groupTitleUpdate.AgentData.GroupID,
  9210. groupTitleUpdate.AgentData.TitleRoleID);
  9211. }
  9212. return true;
  9213. }
  9214. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9215. {
  9216. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9217. if (m_GroupsModule != null)
  9218. {
  9219. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9220. if (handlerParcelDeedToGroup != null)
  9221. {
  9222. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9223. }
  9224. }
  9225. return true;
  9226. }
  9227. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9228. {
  9229. GroupNoticesListRequestPacket groupNoticesListRequest =
  9230. (GroupNoticesListRequestPacket)Pack;
  9231. #region Packet Session and User Check
  9232. if (m_checkPackets)
  9233. {
  9234. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9235. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9236. return true;
  9237. }
  9238. #endregion
  9239. if (m_GroupsModule != null)
  9240. {
  9241. GroupNoticeData[] gn =
  9242. m_GroupsModule.GroupNoticesListRequest(this,
  9243. groupNoticesListRequest.Data.GroupID);
  9244. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9245. groupNoticesListReply.AgentData =
  9246. new GroupNoticesListReplyPacket.AgentDataBlock();
  9247. groupNoticesListReply.AgentData.AgentID = AgentId;
  9248. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9249. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9250. int i = 0;
  9251. foreach (GroupNoticeData g in gn)
  9252. {
  9253. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9254. groupNoticesListReply.Data[i].NoticeID =
  9255. g.NoticeID;
  9256. groupNoticesListReply.Data[i].Timestamp =
  9257. g.Timestamp;
  9258. groupNoticesListReply.Data[i].FromName =
  9259. Util.StringToBytes256(g.FromName);
  9260. groupNoticesListReply.Data[i].Subject =
  9261. Util.StringToBytes256(g.Subject);
  9262. groupNoticesListReply.Data[i].HasAttachment =
  9263. g.HasAttachment;
  9264. groupNoticesListReply.Data[i].AssetType =
  9265. g.AssetType;
  9266. i++;
  9267. }
  9268. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9269. }
  9270. return true;
  9271. }
  9272. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9273. {
  9274. GroupNoticeRequestPacket groupNoticeRequest =
  9275. (GroupNoticeRequestPacket)Pack;
  9276. #region Packet Session and User Check
  9277. if (m_checkPackets)
  9278. {
  9279. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9280. groupNoticeRequest.AgentData.AgentID != AgentId)
  9281. return true;
  9282. }
  9283. #endregion
  9284. if (m_GroupsModule != null)
  9285. {
  9286. m_GroupsModule.GroupNoticeRequest(this,
  9287. groupNoticeRequest.Data.GroupNoticeID);
  9288. }
  9289. return true;
  9290. }
  9291. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9292. {
  9293. GroupRoleUpdatePacket groupRoleUpdate =
  9294. (GroupRoleUpdatePacket)Pack;
  9295. #region Packet Session and User Check
  9296. if (m_checkPackets)
  9297. {
  9298. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9299. groupRoleUpdate.AgentData.AgentID != AgentId)
  9300. return true;
  9301. }
  9302. #endregion
  9303. if (m_GroupsModule != null)
  9304. {
  9305. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9306. groupRoleUpdate.RoleData)
  9307. {
  9308. m_GroupsModule.GroupRoleUpdate(this,
  9309. groupRoleUpdate.AgentData.GroupID,
  9310. d.RoleID,
  9311. Utils.BytesToString(d.Name),
  9312. Utils.BytesToString(d.Description),
  9313. Utils.BytesToString(d.Title),
  9314. d.Powers,
  9315. d.UpdateType);
  9316. }
  9317. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9318. }
  9319. return true;
  9320. }
  9321. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9322. {
  9323. GroupRoleChangesPacket groupRoleChanges =
  9324. (GroupRoleChangesPacket)Pack;
  9325. #region Packet Session and User Check
  9326. if (m_checkPackets)
  9327. {
  9328. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9329. groupRoleChanges.AgentData.AgentID != AgentId)
  9330. return true;
  9331. }
  9332. #endregion
  9333. if (m_GroupsModule != null)
  9334. {
  9335. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9336. groupRoleChanges.RoleChange)
  9337. {
  9338. m_GroupsModule.GroupRoleChanges(this,
  9339. groupRoleChanges.AgentData.GroupID,
  9340. d.RoleID,
  9341. d.MemberID,
  9342. d.Change);
  9343. }
  9344. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9345. }
  9346. return true;
  9347. }
  9348. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9349. {
  9350. JoinGroupRequestPacket joinGroupRequest =
  9351. (JoinGroupRequestPacket)Pack;
  9352. #region Packet Session and User Check
  9353. if (m_checkPackets)
  9354. {
  9355. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9356. joinGroupRequest.AgentData.AgentID != AgentId)
  9357. return true;
  9358. }
  9359. #endregion
  9360. if (m_GroupsModule != null)
  9361. {
  9362. m_GroupsModule.JoinGroupRequest(this,
  9363. joinGroupRequest.GroupData.GroupID);
  9364. }
  9365. return true;
  9366. }
  9367. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9368. {
  9369. LeaveGroupRequestPacket leaveGroupRequest =
  9370. (LeaveGroupRequestPacket)Pack;
  9371. #region Packet Session and User Check
  9372. if (m_checkPackets)
  9373. {
  9374. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9375. leaveGroupRequest.AgentData.AgentID != AgentId)
  9376. return true;
  9377. }
  9378. #endregion
  9379. if (m_GroupsModule != null)
  9380. {
  9381. m_GroupsModule.LeaveGroupRequest(this,
  9382. leaveGroupRequest.GroupData.GroupID);
  9383. }
  9384. return true;
  9385. }
  9386. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9387. {
  9388. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9389. (EjectGroupMemberRequestPacket)Pack;
  9390. #region Packet Session and User Check
  9391. if (m_checkPackets)
  9392. {
  9393. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9394. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9395. return true;
  9396. }
  9397. #endregion
  9398. if (m_GroupsModule != null)
  9399. {
  9400. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9401. in ejectGroupMemberRequest.EjectData)
  9402. {
  9403. m_GroupsModule.EjectGroupMemberRequest(this,
  9404. ejectGroupMemberRequest.GroupData.GroupID,
  9405. e.EjecteeID);
  9406. }
  9407. }
  9408. return true;
  9409. }
  9410. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9411. {
  9412. InviteGroupRequestPacket inviteGroupRequest =
  9413. (InviteGroupRequestPacket)Pack;
  9414. #region Packet Session and User Check
  9415. if (m_checkPackets)
  9416. {
  9417. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9418. inviteGroupRequest.AgentData.AgentID != AgentId)
  9419. return true;
  9420. }
  9421. #endregion
  9422. if (m_GroupsModule != null)
  9423. {
  9424. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9425. inviteGroupRequest.InviteData)
  9426. {
  9427. m_GroupsModule.InviteGroupRequest(this,
  9428. inviteGroupRequest.GroupData.GroupID,
  9429. b.InviteeID,
  9430. b.RoleID);
  9431. }
  9432. }
  9433. return true;
  9434. }
  9435. #endregion Groups
  9436. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9437. {
  9438. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9439. #region Packet Session and User Check
  9440. if (m_checkPackets)
  9441. {
  9442. if (startLureRequest.AgentData.SessionID != SessionId ||
  9443. startLureRequest.AgentData.AgentID != AgentId)
  9444. return true;
  9445. }
  9446. #endregion
  9447. StartLure handlerStartLure = OnStartLure;
  9448. if (handlerStartLure != null)
  9449. handlerStartLure(startLureRequest.Info.LureType,
  9450. Utils.BytesToString(
  9451. startLureRequest.Info.Message),
  9452. startLureRequest.TargetData[0].TargetID,
  9453. this);
  9454. return true;
  9455. }
  9456. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9457. {
  9458. TeleportLureRequestPacket teleportLureRequest =
  9459. (TeleportLureRequestPacket)Pack;
  9460. #region Packet Session and User Check
  9461. if (m_checkPackets)
  9462. {
  9463. if (teleportLureRequest.Info.SessionID != SessionId ||
  9464. teleportLureRequest.Info.AgentID != AgentId)
  9465. return true;
  9466. }
  9467. #endregion
  9468. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9469. if (handlerTeleportLureRequest != null)
  9470. handlerTeleportLureRequest(
  9471. teleportLureRequest.Info.LureID,
  9472. teleportLureRequest.Info.TeleportFlags,
  9473. this);
  9474. return true;
  9475. }
  9476. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9477. {
  9478. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9479. (ClassifiedInfoRequestPacket)Pack;
  9480. #region Packet Session and User Check
  9481. if (m_checkPackets)
  9482. {
  9483. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9484. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9485. return true;
  9486. }
  9487. #endregion
  9488. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9489. if (handlerClassifiedInfoRequest != null)
  9490. handlerClassifiedInfoRequest(
  9491. classifiedInfoRequest.Data.ClassifiedID,
  9492. this);
  9493. return true;
  9494. }
  9495. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9496. {
  9497. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9498. (ClassifiedInfoUpdatePacket)Pack;
  9499. #region Packet Session and User Check
  9500. if (m_checkPackets)
  9501. {
  9502. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9503. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9504. return true;
  9505. }
  9506. #endregion
  9507. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9508. if (handlerClassifiedInfoUpdate != null)
  9509. handlerClassifiedInfoUpdate(
  9510. classifiedInfoUpdate.Data.ClassifiedID,
  9511. classifiedInfoUpdate.Data.Category,
  9512. Utils.BytesToString(
  9513. classifiedInfoUpdate.Data.Name),
  9514. Utils.BytesToString(
  9515. classifiedInfoUpdate.Data.Desc),
  9516. classifiedInfoUpdate.Data.ParcelID,
  9517. classifiedInfoUpdate.Data.ParentEstate,
  9518. classifiedInfoUpdate.Data.SnapshotID,
  9519. new Vector3(
  9520. classifiedInfoUpdate.Data.PosGlobal),
  9521. classifiedInfoUpdate.Data.ClassifiedFlags,
  9522. classifiedInfoUpdate.Data.PriceForListing,
  9523. this);
  9524. return true;
  9525. }
  9526. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9527. {
  9528. ClassifiedDeletePacket classifiedDelete =
  9529. (ClassifiedDeletePacket)Pack;
  9530. #region Packet Session and User Check
  9531. if (m_checkPackets)
  9532. {
  9533. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9534. classifiedDelete.AgentData.AgentID != AgentId)
  9535. return true;
  9536. }
  9537. #endregion
  9538. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9539. if (handlerClassifiedDelete != null)
  9540. handlerClassifiedDelete(
  9541. classifiedDelete.Data.ClassifiedID,
  9542. this);
  9543. return true;
  9544. }
  9545. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9546. {
  9547. ClassifiedGodDeletePacket classifiedGodDelete =
  9548. (ClassifiedGodDeletePacket)Pack;
  9549. #region Packet Session and User Check
  9550. if (m_checkPackets)
  9551. {
  9552. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9553. classifiedGodDelete.AgentData.AgentID != AgentId)
  9554. return true;
  9555. }
  9556. #endregion
  9557. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9558. if (handlerClassifiedGodDelete != null)
  9559. handlerClassifiedGodDelete(
  9560. classifiedGodDelete.Data.ClassifiedID,
  9561. this);
  9562. return true;
  9563. }
  9564. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9565. {
  9566. EventGodDeletePacket eventGodDelete =
  9567. (EventGodDeletePacket)Pack;
  9568. #region Packet Session and User Check
  9569. if (m_checkPackets)
  9570. {
  9571. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9572. eventGodDelete.AgentData.AgentID != AgentId)
  9573. return true;
  9574. }
  9575. #endregion
  9576. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9577. if (handlerEventGodDelete != null)
  9578. handlerEventGodDelete(
  9579. eventGodDelete.EventData.EventID,
  9580. eventGodDelete.QueryData.QueryID,
  9581. Utils.BytesToString(
  9582. eventGodDelete.QueryData.QueryText),
  9583. eventGodDelete.QueryData.QueryFlags,
  9584. eventGodDelete.QueryData.QueryStart,
  9585. this);
  9586. return true;
  9587. }
  9588. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9589. {
  9590. EventNotificationAddRequestPacket eventNotificationAdd =
  9591. (EventNotificationAddRequestPacket)Pack;
  9592. #region Packet Session and User Check
  9593. if (m_checkPackets)
  9594. {
  9595. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9596. eventNotificationAdd.AgentData.AgentID != AgentId)
  9597. return true;
  9598. }
  9599. #endregion
  9600. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9601. if (handlerEventNotificationAddRequest != null)
  9602. handlerEventNotificationAddRequest(
  9603. eventNotificationAdd.EventData.EventID, this);
  9604. return true;
  9605. }
  9606. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9607. {
  9608. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9609. (EventNotificationRemoveRequestPacket)Pack;
  9610. #region Packet Session and User Check
  9611. if (m_checkPackets)
  9612. {
  9613. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9614. eventNotificationRemove.AgentData.AgentID != AgentId)
  9615. return true;
  9616. }
  9617. #endregion
  9618. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9619. if (handlerEventNotificationRemoveRequest != null)
  9620. handlerEventNotificationRemoveRequest(
  9621. eventNotificationRemove.EventData.EventID, this);
  9622. return true;
  9623. }
  9624. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9625. {
  9626. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9627. #region Packet Session and User Check
  9628. if (m_checkPackets)
  9629. {
  9630. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9631. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9632. return true;
  9633. }
  9634. #endregion
  9635. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9636. if (handlerRetrieveInstantMessages != null)
  9637. handlerRetrieveInstantMessages(this);
  9638. return true;
  9639. }
  9640. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9641. {
  9642. PickDeletePacket pickDelete =
  9643. (PickDeletePacket)Pack;
  9644. #region Packet Session and User Check
  9645. if (m_checkPackets)
  9646. {
  9647. if (pickDelete.AgentData.SessionID != SessionId ||
  9648. pickDelete.AgentData.AgentID != AgentId)
  9649. return true;
  9650. }
  9651. #endregion
  9652. PickDelete handlerPickDelete = OnPickDelete;
  9653. if (handlerPickDelete != null)
  9654. handlerPickDelete(this, pickDelete.Data.PickID);
  9655. return true;
  9656. }
  9657. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9658. {
  9659. PickGodDeletePacket pickGodDelete =
  9660. (PickGodDeletePacket)Pack;
  9661. #region Packet Session and User Check
  9662. if (m_checkPackets)
  9663. {
  9664. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9665. pickGodDelete.AgentData.AgentID != AgentId)
  9666. return true;
  9667. }
  9668. #endregion
  9669. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9670. if (handlerPickGodDelete != null)
  9671. handlerPickGodDelete(this,
  9672. pickGodDelete.AgentData.AgentID,
  9673. pickGodDelete.Data.PickID,
  9674. pickGodDelete.Data.QueryID);
  9675. return true;
  9676. }
  9677. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9678. {
  9679. PickInfoUpdatePacket pickInfoUpdate =
  9680. (PickInfoUpdatePacket)Pack;
  9681. #region Packet Session and User Check
  9682. if (m_checkPackets)
  9683. {
  9684. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9685. pickInfoUpdate.AgentData.AgentID != AgentId)
  9686. return true;
  9687. }
  9688. #endregion
  9689. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9690. if (handlerPickInfoUpdate != null)
  9691. handlerPickInfoUpdate(this,
  9692. pickInfoUpdate.Data.PickID,
  9693. pickInfoUpdate.Data.CreatorID,
  9694. pickInfoUpdate.Data.TopPick,
  9695. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9696. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9697. pickInfoUpdate.Data.SnapshotID,
  9698. pickInfoUpdate.Data.SortOrder,
  9699. pickInfoUpdate.Data.Enabled);
  9700. return true;
  9701. }
  9702. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9703. {
  9704. AvatarNotesUpdatePacket avatarNotesUpdate =
  9705. (AvatarNotesUpdatePacket)Pack;
  9706. #region Packet Session and User Check
  9707. if (m_checkPackets)
  9708. {
  9709. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  9710. avatarNotesUpdate.AgentData.AgentID != AgentId)
  9711. return true;
  9712. }
  9713. #endregion
  9714. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  9715. if (handlerAvatarNotesUpdate != null)
  9716. handlerAvatarNotesUpdate(this,
  9717. avatarNotesUpdate.Data.TargetID,
  9718. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  9719. return true;
  9720. }
  9721. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  9722. {
  9723. AvatarInterestsUpdatePacket avatarInterestUpdate =
  9724. (AvatarInterestsUpdatePacket)Pack;
  9725. #region Packet Session and User Check
  9726. if (m_checkPackets)
  9727. {
  9728. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  9729. avatarInterestUpdate.AgentData.AgentID != AgentId)
  9730. return true;
  9731. }
  9732. #endregion
  9733. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  9734. if (handlerAvatarInterestUpdate != null)
  9735. handlerAvatarInterestUpdate(this,
  9736. avatarInterestUpdate.PropertiesData.WantToMask,
  9737. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  9738. avatarInterestUpdate.PropertiesData.SkillsMask,
  9739. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  9740. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  9741. return true;
  9742. }
  9743. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  9744. {
  9745. GrantUserRightsPacket GrantUserRights =
  9746. (GrantUserRightsPacket)Pack;
  9747. #region Packet Session and User Check
  9748. if (m_checkPackets)
  9749. {
  9750. if (GrantUserRights.AgentData.SessionID != SessionId ||
  9751. GrantUserRights.AgentData.AgentID != AgentId)
  9752. return true;
  9753. }
  9754. #endregion
  9755. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  9756. if (GrantUserRightsHandler != null)
  9757. GrantUserRightsHandler(this,
  9758. GrantUserRights.Rights[0].AgentRelated,
  9759. GrantUserRights.Rights[0].RelatedRights);
  9760. return true;
  9761. }
  9762. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  9763. {
  9764. PlacesQueryPacket placesQueryPacket =
  9765. (PlacesQueryPacket)Pack;
  9766. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  9767. if (handlerPlacesQuery != null)
  9768. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  9769. placesQueryPacket.TransactionData.TransactionID,
  9770. Utils.BytesToString(
  9771. placesQueryPacket.QueryData.QueryText),
  9772. placesQueryPacket.QueryData.QueryFlags,
  9773. (byte)placesQueryPacket.QueryData.Category,
  9774. Utils.BytesToString(
  9775. placesQueryPacket.QueryData.SimName),
  9776. this);
  9777. return true;
  9778. }
  9779. #endregion Packet Handlers
  9780. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  9781. {
  9782. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  9783. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  9784. // TODO: don't create new blocks if recycling an old packet
  9785. scriptQuestion.Data.TaskID = taskID;
  9786. scriptQuestion.Data.ItemID = itemID;
  9787. scriptQuestion.Data.Questions = question;
  9788. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  9789. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  9790. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  9791. }
  9792. /// <summary>
  9793. /// Handler called when we receive a logout packet.
  9794. /// </summary>
  9795. /// <param name="client"></param>
  9796. /// <param name="packet"></param>
  9797. /// <returns></returns>
  9798. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  9799. {
  9800. if (packet.Type == PacketType.LogoutRequest)
  9801. {
  9802. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  9803. }
  9804. return Logout(client);
  9805. }
  9806. /// <summary>
  9807. ///
  9808. /// </summary>
  9809. /// <param name="client"></param>
  9810. /// <returns></returns>
  9811. protected virtual bool Logout(IClientAPI client)
  9812. {
  9813. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  9814. Action<IClientAPI> handlerLogout = OnLogout;
  9815. if (handlerLogout != null)
  9816. {
  9817. handlerLogout(client);
  9818. }
  9819. return true;
  9820. }
  9821. /// <summary>
  9822. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  9823. /// its appearance texture cached.
  9824. /// </summary>
  9825. /// <remarks>
  9826. /// At the moment, we always reply that there is no cached texture.
  9827. /// </remarks>
  9828. /// <param name="simclient"></param>
  9829. /// <param name="packet"></param>
  9830. /// <returns></returns>
  9831. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  9832. {
  9833. //m_log.Debug("texture cached: " + packet.ToString());
  9834. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  9835. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  9836. if (cachedtex.AgentData.SessionID != SessionId)
  9837. return false;
  9838. // TODO: don't create new blocks if recycling an old packet
  9839. cachedresp.AgentData.AgentID = AgentId;
  9840. cachedresp.AgentData.SessionID = m_sessionId;
  9841. cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
  9842. m_cachedTextureSerial++;
  9843. cachedresp.WearableData =
  9844. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  9845. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  9846. {
  9847. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  9848. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  9849. cachedresp.WearableData[i].TextureID = UUID.Zero;
  9850. cachedresp.WearableData[i].HostName = new byte[0];
  9851. }
  9852. cachedresp.Header.Zerocoded = true;
  9853. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  9854. return true;
  9855. }
  9856. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  9857. {
  9858. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  9859. if (multipleupdate.AgentData.SessionID != SessionId)
  9860. return false;
  9861. // m_log.DebugFormat(
  9862. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  9863. Scene tScene = (Scene)m_scene;
  9864. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  9865. {
  9866. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  9867. // Can't act on Null Data
  9868. if (block.Data != null)
  9869. {
  9870. uint localId = block.ObjectLocalID;
  9871. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  9872. if (part == null)
  9873. {
  9874. // It's a ghost! tell the client to delete it from view.
  9875. simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
  9876. new List<uint> { localId });
  9877. }
  9878. else
  9879. {
  9880. // m_log.DebugFormat(
  9881. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  9882. // i, block.Type, part.Name, part.LocalId);
  9883. // // Do this once since fetch parts creates a new array.
  9884. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  9885. // for (int j = 0; j < parts.Length; j++)
  9886. // {
  9887. // part.StoreUndoState();
  9888. // parts[j].IgnoreUndoUpdate = true;
  9889. // }
  9890. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  9891. switch (block.Type)
  9892. {
  9893. case 1:
  9894. Vector3 pos1 = new Vector3(block.Data, 0);
  9895. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9896. if (handlerUpdatePrimSinglePosition != null)
  9897. {
  9898. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9899. handlerUpdatePrimSinglePosition(localId, pos1, this);
  9900. }
  9901. break;
  9902. case 2:
  9903. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  9904. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  9905. if (handlerUpdatePrimSingleRotation != null)
  9906. {
  9907. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  9908. handlerUpdatePrimSingleRotation(localId, rot1, this);
  9909. }
  9910. break;
  9911. case 3:
  9912. Vector3 rotPos = new Vector3(block.Data, 0);
  9913. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  9914. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  9915. if (handlerUpdatePrimSingleRotationPosition != null)
  9916. {
  9917. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  9918. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  9919. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  9920. }
  9921. break;
  9922. case 4:
  9923. case 20:
  9924. Vector3 scale4 = new Vector3(block.Data, 0);
  9925. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  9926. if (handlerUpdatePrimScale != null)
  9927. {
  9928. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  9929. handlerUpdatePrimScale(localId, scale4, this);
  9930. }
  9931. break;
  9932. case 5:
  9933. Vector3 scale1 = new Vector3(block.Data, 12);
  9934. Vector3 pos11 = new Vector3(block.Data, 0);
  9935. handlerUpdatePrimScale = OnUpdatePrimScale;
  9936. if (handlerUpdatePrimScale != null)
  9937. {
  9938. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9939. handlerUpdatePrimScale(localId, scale1, this);
  9940. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9941. if (handlerUpdatePrimSinglePosition != null)
  9942. {
  9943. handlerUpdatePrimSinglePosition(localId, pos11, this);
  9944. }
  9945. }
  9946. break;
  9947. case 9:
  9948. Vector3 pos2 = new Vector3(block.Data, 0);
  9949. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  9950. if (handlerUpdateVector != null)
  9951. {
  9952. handlerUpdateVector(localId, pos2, this);
  9953. }
  9954. break;
  9955. case 10:
  9956. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  9957. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  9958. if (handlerUpdatePrimRotation != null)
  9959. {
  9960. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  9961. handlerUpdatePrimRotation(localId, rot3, this);
  9962. }
  9963. break;
  9964. case 11:
  9965. Vector3 pos3 = new Vector3(block.Data, 0);
  9966. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  9967. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  9968. if (handlerUpdatePrimGroupRotation != null)
  9969. {
  9970. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9971. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  9972. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  9973. }
  9974. break;
  9975. case 12:
  9976. case 28:
  9977. Vector3 scale7 = new Vector3(block.Data, 0);
  9978. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  9979. if (handlerUpdatePrimGroupScale != null)
  9980. {
  9981. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  9982. handlerUpdatePrimGroupScale(localId, scale7, this);
  9983. }
  9984. break;
  9985. case 13:
  9986. Vector3 scale2 = new Vector3(block.Data, 12);
  9987. Vector3 pos4 = new Vector3(block.Data, 0);
  9988. handlerUpdatePrimScale = OnUpdatePrimScale;
  9989. if (handlerUpdatePrimScale != null)
  9990. {
  9991. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9992. handlerUpdatePrimScale(localId, scale2, this);
  9993. // Change the position based on scale (for bug number 246)
  9994. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9995. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9996. if (handlerUpdatePrimSinglePosition != null)
  9997. {
  9998. handlerUpdatePrimSinglePosition(localId, pos4, this);
  9999. }
  10000. }
  10001. break;
  10002. case 29:
  10003. Vector3 scale5 = new Vector3(block.Data, 12);
  10004. Vector3 pos5 = new Vector3(block.Data, 0);
  10005. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10006. if (handlerUpdatePrimGroupScale != null)
  10007. {
  10008. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10009. part.StoreUndoState(true);
  10010. part.IgnoreUndoUpdate = true;
  10011. handlerUpdatePrimGroupScale(localId, scale5, this);
  10012. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10013. if (handlerUpdateVector != null)
  10014. {
  10015. handlerUpdateVector(localId, pos5, this);
  10016. }
  10017. part.IgnoreUndoUpdate = false;
  10018. }
  10019. break;
  10020. case 21:
  10021. Vector3 scale6 = new Vector3(block.Data, 12);
  10022. Vector3 pos6 = new Vector3(block.Data, 0);
  10023. handlerUpdatePrimScale = OnUpdatePrimScale;
  10024. if (handlerUpdatePrimScale != null)
  10025. {
  10026. part.StoreUndoState(false);
  10027. part.IgnoreUndoUpdate = true;
  10028. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10029. handlerUpdatePrimScale(localId, scale6, this);
  10030. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10031. if (handlerUpdatePrimSinglePosition != null)
  10032. {
  10033. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10034. }
  10035. part.IgnoreUndoUpdate = false;
  10036. }
  10037. break;
  10038. default:
  10039. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10040. break;
  10041. }
  10042. // for (int j = 0; j < parts.Length; j++)
  10043. // parts[j].IgnoreUndoUpdate = false;
  10044. }
  10045. }
  10046. }
  10047. return true;
  10048. }
  10049. public void RequestMapLayer()
  10050. {
  10051. //should be getting the map layer from the grid server
  10052. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10053. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10054. // TODO: don't create new blocks if recycling an old packet
  10055. mapReply.AgentData.AgentID = AgentId;
  10056. mapReply.AgentData.Flags = 0;
  10057. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10058. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10059. mapReply.LayerData[0].Bottom = 0;
  10060. mapReply.LayerData[0].Left = 0;
  10061. mapReply.LayerData[0].Top = 30000;
  10062. mapReply.LayerData[0].Right = 30000;
  10063. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10064. mapReply.Header.Zerocoded = true;
  10065. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10066. }
  10067. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10068. {
  10069. /*
  10070. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10071. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10072. mbReply.AgentData.AgentId = AgentId;
  10073. int len;
  10074. if (simMapProfiles == null)
  10075. len = 0;
  10076. else
  10077. len = simMapProfiles.Count;
  10078. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10079. int iii;
  10080. for (iii = 0; iii < len; iii++)
  10081. {
  10082. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10083. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10084. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10085. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10086. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10087. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10088. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10089. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10090. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10091. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10092. }
  10093. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10094. */
  10095. }
  10096. /// <summary>
  10097. /// Sets the throttles from values supplied by the client
  10098. /// </summary>
  10099. /// <param name="throttles"></param>
  10100. public void SetChildAgentThrottle(byte[] throttles)
  10101. {
  10102. m_udpClient.SetThrottles(throttles);
  10103. }
  10104. /// <summary>
  10105. /// Get the current throttles for this client as a packed byte array
  10106. /// </summary>
  10107. /// <param name="multiplier">Unused</param>
  10108. /// <returns></returns>
  10109. public byte[] GetThrottlesPacked(float multiplier)
  10110. {
  10111. return m_udpClient.GetThrottlesPacked(multiplier);
  10112. }
  10113. /// <summary>
  10114. /// Cruft?
  10115. /// </summary>
  10116. public virtual void InPacket(object NewPack)
  10117. {
  10118. throw new NotImplementedException();
  10119. }
  10120. /// <summary>
  10121. /// This is the starting point for sending a simulator packet out to the client
  10122. /// </summary>
  10123. /// <param name="packet">Packet to send</param>
  10124. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10125. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10126. {
  10127. #region BinaryStats
  10128. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10129. #endregion BinaryStats
  10130. OutPacket(packet, throttlePacketType, true);
  10131. }
  10132. /// <summary>
  10133. /// This is the starting point for sending a simulator packet out to the client
  10134. /// </summary>
  10135. /// <param name="packet">Packet to send</param>
  10136. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10137. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10138. /// packets (the default), or false to disable splitting if the calling code
  10139. /// handles splitting manually</param>
  10140. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10141. {
  10142. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10143. }
  10144. /// <summary>
  10145. /// This is the starting point for sending a simulator packet out to the client
  10146. /// </summary>
  10147. /// <param name="packet">Packet to send</param>
  10148. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10149. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10150. /// packets (the default), or false to disable splitting if the calling code
  10151. /// handles splitting manually</param>
  10152. /// <param name="method">The method to be called in the event this packet is reliable
  10153. /// and unacknowledged. The server will provide normal resend capability if you do not
  10154. /// provide your own method.</param>
  10155. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10156. {
  10157. if (DebugPacketLevel > 0)
  10158. {
  10159. bool logPacket = true;
  10160. if (DebugPacketLevel <= 255
  10161. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10162. logPacket = false;
  10163. if (DebugPacketLevel <= 200
  10164. && (packet.Type == PacketType.ImagePacket
  10165. || packet.Type == PacketType.ImageData
  10166. || packet.Type == PacketType.LayerData
  10167. || packet.Type == PacketType.CoarseLocationUpdate))
  10168. logPacket = false;
  10169. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10170. logPacket = false;
  10171. if (DebugPacketLevel <= 50
  10172. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10173. logPacket = false;
  10174. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10175. logPacket = false;
  10176. if (logPacket)
  10177. m_log.DebugFormat(
  10178. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10179. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10180. }
  10181. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10182. }
  10183. public bool AddMoney(int debit)
  10184. {
  10185. if (m_moneyBalance + debit >= 0)
  10186. {
  10187. m_moneyBalance += debit;
  10188. SendMoneyBalance(UUID.Zero, true, Util.StringToBytes256("Poof Poof!"), m_moneyBalance);
  10189. return true;
  10190. }
  10191. return false;
  10192. }
  10193. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10194. {
  10195. float locx = 0;
  10196. float locy = 0;
  10197. float locz = 0;
  10198. uint regionX = 0;
  10199. uint regionY = 0;
  10200. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10201. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10202. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10203. locz = Convert.ToSingle(args[2]);
  10204. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10205. if (handlerAutoPilotGo != null)
  10206. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10207. }
  10208. /// <summary>
  10209. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10210. /// </summary>
  10211. /// <param name="Pack">OpenMetaverse.packet</param>
  10212. public void ProcessInPacket(Packet packet)
  10213. {
  10214. if (DebugPacketLevel > 0)
  10215. {
  10216. bool logPacket = true;
  10217. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10218. logPacket = false;
  10219. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10220. logPacket = false;
  10221. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10222. logPacket = false;
  10223. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10224. logPacket = false;
  10225. if (logPacket)
  10226. m_log.DebugFormat(
  10227. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10228. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10229. }
  10230. if (!ProcessPacketMethod(packet))
  10231. m_log.Warn("[CLIENT]: unhandled packet " + packet.Type);
  10232. }
  10233. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10234. {
  10235. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10236. shape.PCode = addPacket.ObjectData.PCode;
  10237. shape.State = addPacket.ObjectData.State;
  10238. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10239. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10240. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10241. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10242. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10243. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10244. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10245. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10246. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10247. shape.Scale = addPacket.ObjectData.Scale;
  10248. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10249. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10250. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10251. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10252. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10253. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10254. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10255. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10256. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10257. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10258. shape.TextureEntry = ntex.GetBytes();
  10259. //shape.Textures = ntex;
  10260. return shape;
  10261. }
  10262. public ClientInfo GetClientInfo()
  10263. {
  10264. ClientInfo info = m_udpClient.GetClientInfo();
  10265. info.proxyEP = null;
  10266. info.agentcircuit = RequestClientInfo();
  10267. return info;
  10268. }
  10269. public void SetClientInfo(ClientInfo info)
  10270. {
  10271. m_udpClient.SetClientInfo(info);
  10272. }
  10273. #region Media Parcel Members
  10274. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10275. {
  10276. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10277. commandMessagePacket.CommandBlock.Flags = flags;
  10278. commandMessagePacket.CommandBlock.Command = (uint)command;
  10279. commandMessagePacket.CommandBlock.Time = time;
  10280. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10281. }
  10282. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10283. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10284. byte mediaLoop)
  10285. {
  10286. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10287. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10288. updatePacket.DataBlock.MediaID = mediaTextureID;
  10289. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10290. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10291. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10292. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10293. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10294. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10295. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10296. }
  10297. #endregion
  10298. #region Camera
  10299. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10300. {
  10301. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10302. packet.ObjectData.ObjectID = objectID;
  10303. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10304. uint idx = 0;
  10305. foreach (KeyValuePair<int, float> pair in parameters)
  10306. {
  10307. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10308. block.Type = pair.Key;
  10309. block.Value = pair.Value;
  10310. camPropBlock[idx++] = block;
  10311. }
  10312. packet.CameraProperty = camPropBlock;
  10313. OutPacket(packet, ThrottleOutPacketType.Task);
  10314. }
  10315. public void SendClearFollowCamProperties(UUID objectID)
  10316. {
  10317. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10318. packet.ObjectData.ObjectID = objectID;
  10319. OutPacket(packet, ThrottleOutPacketType.Task);
  10320. }
  10321. #endregion
  10322. public void SetClientOption(string option, string value)
  10323. {
  10324. switch (option)
  10325. {
  10326. default:
  10327. break;
  10328. }
  10329. }
  10330. public string GetClientOption(string option)
  10331. {
  10332. switch (option)
  10333. {
  10334. default:
  10335. break;
  10336. }
  10337. return string.Empty;
  10338. }
  10339. #region IClientCore
  10340. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10341. /// <summary>
  10342. /// Register an interface on this client, should only be called in the constructor.
  10343. /// </summary>
  10344. /// <typeparam name="T"></typeparam>
  10345. /// <param name="iface"></param>
  10346. protected void RegisterInterface<T>(T iface)
  10347. {
  10348. lock (m_clientInterfaces)
  10349. {
  10350. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10351. {
  10352. m_clientInterfaces.Add(typeof(T), iface);
  10353. }
  10354. }
  10355. }
  10356. public bool TryGet<T>(out T iface)
  10357. {
  10358. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10359. {
  10360. iface = (T)m_clientInterfaces[typeof(T)];
  10361. return true;
  10362. }
  10363. iface = default(T);
  10364. return false;
  10365. }
  10366. public T Get<T>()
  10367. {
  10368. return (T)m_clientInterfaces[typeof(T)];
  10369. }
  10370. public void Disconnect(string reason)
  10371. {
  10372. Kick(reason);
  10373. Thread.Sleep(1000);
  10374. Disconnect();
  10375. }
  10376. public void Disconnect()
  10377. {
  10378. Close();
  10379. }
  10380. #endregion
  10381. public void RefreshGroupMembership()
  10382. {
  10383. if (m_GroupsModule != null)
  10384. {
  10385. GroupMembershipData[] GroupMembership =
  10386. m_GroupsModule.GetMembershipData(AgentId);
  10387. m_groupPowers.Clear();
  10388. if (GroupMembership != null)
  10389. {
  10390. for (int i = 0; i < GroupMembership.Length; i++)
  10391. {
  10392. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10393. }
  10394. }
  10395. }
  10396. }
  10397. public string Report()
  10398. {
  10399. return m_udpClient.GetStats();
  10400. }
  10401. public string XReport(string uptime, string version)
  10402. {
  10403. return String.Empty;
  10404. }
  10405. /// <summary>
  10406. /// Make an asset request to the asset service in response to a client request.
  10407. /// </summary>
  10408. /// <param name="transferRequest"></param>
  10409. /// <param name="taskID"></param>
  10410. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10411. {
  10412. UUID requestID = UUID.Zero;
  10413. int sourceType = transferRequest.TransferInfo.SourceType;
  10414. if (sourceType == (int)SourceType.Asset)
  10415. {
  10416. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10417. }
  10418. else if (sourceType == (int)SourceType.SimInventoryItem)
  10419. {
  10420. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10421. }
  10422. else if (sourceType == (int)SourceType.SimEstate)
  10423. {
  10424. requestID = taskID;
  10425. }
  10426. // m_log.DebugFormat(
  10427. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10428. // requestID, taskID, (SourceType)sourceType, Name);
  10429. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10430. }
  10431. /// <summary>
  10432. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10433. /// </summary>
  10434. /// <param name="id"></param>
  10435. /// <param name="sender"></param>
  10436. /// <param name="asset"></param>
  10437. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10438. {
  10439. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10440. UUID requestID = UUID.Zero;
  10441. byte source = (byte)SourceType.Asset;
  10442. AssetRequestToClient req = new AssetRequestToClient();
  10443. if (asset == null)
  10444. {
  10445. req.AssetInf = null;
  10446. req.AssetRequestSource = source;
  10447. req.IsTextureRequest = false;
  10448. req.NumPackets = 0;
  10449. req.Params = transferRequest.TransferInfo.Params;
  10450. req.RequestAssetID = requestID;
  10451. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10452. SendAssetNotFound(req);
  10453. return;
  10454. }
  10455. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10456. {
  10457. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10458. }
  10459. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10460. {
  10461. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10462. source = (byte)SourceType.SimInventoryItem;
  10463. //m_log.Debug("asset request " + requestID);
  10464. }
  10465. // Scripts cannot be retrieved by direct request
  10466. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10467. return;
  10468. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10469. req.AssetInf = asset;
  10470. req.AssetRequestSource = source;
  10471. req.IsTextureRequest = false;
  10472. req.NumPackets = CalculateNumPackets(asset.Data);
  10473. req.Params = transferRequest.TransferInfo.Params;
  10474. req.RequestAssetID = requestID;
  10475. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10476. SendAsset(req);
  10477. }
  10478. /// <summary>
  10479. /// Calculate the number of packets required to send the asset to the client.
  10480. /// </summary>
  10481. /// <param name="data"></param>
  10482. /// <returns></returns>
  10483. private static int CalculateNumPackets(byte[] data)
  10484. {
  10485. const uint m_maxPacketSize = 600;
  10486. int numPackets = 1;
  10487. if (data == null)
  10488. return 0;
  10489. if (data.LongLength > m_maxPacketSize)
  10490. {
  10491. // over max number of bytes so split up file
  10492. long restData = data.LongLength - m_maxPacketSize;
  10493. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10494. numPackets += restPackets;
  10495. }
  10496. return numPackets;
  10497. }
  10498. public void SendRebakeAvatarTextures(UUID textureID)
  10499. {
  10500. RebakeAvatarTexturesPacket pack =
  10501. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10502. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10503. pack.TextureData.TextureID = textureID;
  10504. OutPacket(pack, ThrottleOutPacketType.Task);
  10505. }
  10506. public struct PacketProcessor
  10507. {
  10508. public PacketMethod method;
  10509. public bool Async;
  10510. }
  10511. public class AsyncPacketProcess
  10512. {
  10513. public bool result = false;
  10514. public readonly LLClientView ClientView = null;
  10515. public readonly Packet Pack = null;
  10516. public readonly PacketMethod Method = null;
  10517. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10518. {
  10519. ClientView = pClientview;
  10520. Method = pMethod;
  10521. Pack = pPack;
  10522. }
  10523. }
  10524. public static OSD BuildEvent(string eventName, OSD eventBody)
  10525. {
  10526. OSDMap osdEvent = new OSDMap(2);
  10527. osdEvent.Add("message", new OSDString(eventName));
  10528. osdEvent.Add("body", eventBody);
  10529. return osdEvent;
  10530. }
  10531. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10532. {
  10533. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10534. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10535. packet.AgentData.AgentID = AgentId;
  10536. packet.AgentData.AvatarID = avatarID;
  10537. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10538. packet.PropertiesData.WantToMask = wantMask;
  10539. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10540. packet.PropertiesData.SkillsMask = skillsMask;
  10541. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10542. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10543. OutPacket(packet, ThrottleOutPacketType.Task);
  10544. }
  10545. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10546. {
  10547. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10548. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10549. packet.AgentData.AgentID = agentID;
  10550. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10551. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10552. packet.Rights[0].AgentRelated = friendID;
  10553. packet.Rights[0].RelatedRights = rights;
  10554. OutPacket(packet, ThrottleOutPacketType.Task);
  10555. }
  10556. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10557. {
  10558. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10559. dialog.Data.ObjectID = objectId;
  10560. dialog.Data.ChatChannel = chatChannel;
  10561. dialog.Data.ImageID = UUID.Zero;
  10562. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10563. // this is the username of the *owner*
  10564. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10565. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10566. dialog.Data.Message = Util.StringToBytes256(message);
  10567. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10568. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10569. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10570. dialog.Buttons = buttons;
  10571. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10572. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10573. dialog.OwnerData[0].OwnerID = ownerID;
  10574. OutPacket(dialog, ThrottleOutPacketType.Task);
  10575. }
  10576. public void StopFlying(ISceneEntity p)
  10577. {
  10578. if (p is ScenePresence)
  10579. {
  10580. ScenePresence presence = p as ScenePresence;
  10581. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10582. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10583. // velocity, collision plane and avatar height
  10584. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10585. // when the avatar stands up
  10586. Vector3 pos = presence.AbsolutePosition;
  10587. if (presence.Appearance.AvatarHeight != 127.0f)
  10588. pos += new Vector3(0f, 0f, (presence.Appearance.AvatarHeight/6f));
  10589. else
  10590. pos += new Vector3(0f, 0f, (1.56f/6f));
  10591. presence.AbsolutePosition = pos;
  10592. // attach a suitable collision plane regardless of the actual situation to force the LLClient to land.
  10593. // Collision plane below the avatar's position a 6th of the avatar's height is suitable.
  10594. // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a
  10595. // certain amount.. because the LLClient wouldn't land in that situation anyway.
  10596. // why are we still testing for this really old height value default???
  10597. if (presence.Appearance.AvatarHeight != 127.0f)
  10598. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - presence.Appearance.AvatarHeight/6f);
  10599. else
  10600. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f/6f));
  10601. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10602. CreateImprovedTerseBlock(p, false);
  10603. const float TIME_DILATION = 1.0f;
  10604. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10605. ImprovedTerseObjectUpdatePacket packet
  10606. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  10607. PacketType.ImprovedTerseObjectUpdate);
  10608. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10609. packet.RegionData.TimeDilation = timeDilation;
  10610. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10611. packet.ObjectData[0] = block;
  10612. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10613. }
  10614. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10615. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10616. }
  10617. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10618. PlacesReplyData[] data)
  10619. {
  10620. PlacesReplyPacket reply = null;
  10621. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10622. new PlacesReplyPacket.QueryDataBlock[0];
  10623. for (int i = 0 ; i < data.Length ; i++)
  10624. {
  10625. PlacesReplyPacket.QueryDataBlock block =
  10626. new PlacesReplyPacket.QueryDataBlock();
  10627. block.OwnerID = data[i].OwnerID;
  10628. block.Name = Util.StringToBytes256(data[i].Name);
  10629. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10630. block.ActualArea = data[i].ActualArea;
  10631. block.BillableArea = data[i].BillableArea;
  10632. block.Flags = data[i].Flags;
  10633. block.GlobalX = data[i].GlobalX;
  10634. block.GlobalY = data[i].GlobalY;
  10635. block.GlobalZ = data[i].GlobalZ;
  10636. block.SimName = Util.StringToBytes256(data[i].SimName);
  10637. block.SnapshotID = data[i].SnapshotID;
  10638. block.Dwell = data[i].Dwell;
  10639. block.Price = data[i].Price;
  10640. if (reply != null && reply.Length + block.Length > 1400)
  10641. {
  10642. OutPacket(reply, ThrottleOutPacketType.Task);
  10643. reply = null;
  10644. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10645. }
  10646. if (reply == null)
  10647. {
  10648. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10649. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10650. reply.AgentData.AgentID = AgentId;
  10651. reply.AgentData.QueryID = queryID;
  10652. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10653. reply.TransactionData.TransactionID = transactionID;
  10654. reply.QueryData = dataBlocks;
  10655. }
  10656. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10657. dataBlocks[dataBlocks.Length - 1] = block;
  10658. reply.QueryData = dataBlocks;
  10659. }
  10660. if (reply != null)
  10661. OutPacket(reply, ThrottleOutPacketType.Task);
  10662. }
  10663. public void SendRemoveInventoryItems(UUID[] items)
  10664. {
  10665. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10666. if (eq == null)
  10667. {
  10668. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10669. return;
  10670. }
  10671. OSDMap llsd = new OSDMap(3);
  10672. OSDMap AgentDataMap = new OSDMap(1);
  10673. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10674. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10675. OSDArray AgentData = new OSDArray(1);
  10676. AgentData.Add(AgentDataMap);
  10677. llsd.Add("AgentData", AgentData);
  10678. OSDArray ItemData = new OSDArray();
  10679. foreach (UUID item in items)
  10680. {
  10681. OSDMap ItemDataMap = new OSDMap(2);
  10682. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  10683. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10684. ItemData.Add(ItemDataMap);
  10685. }
  10686. llsd.Add("InventoryData", ItemData);
  10687. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  10688. llsd), AgentId);
  10689. }
  10690. public void SendRemoveInventoryFolders(UUID[] folders)
  10691. {
  10692. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10693. if (eq == null)
  10694. {
  10695. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10696. return;
  10697. }
  10698. OSDMap llsd = new OSDMap(3);
  10699. OSDMap AgentDataMap = new OSDMap(1);
  10700. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10701. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10702. OSDArray AgentData = new OSDArray(1);
  10703. AgentData.Add(AgentDataMap);
  10704. llsd.Add("AgentData", AgentData);
  10705. OSDArray FolderData = new OSDArray();
  10706. foreach (UUID folder in folders)
  10707. {
  10708. OSDMap FolderDataMap = new OSDMap(2);
  10709. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  10710. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10711. FolderData.Add(FolderDataMap);
  10712. }
  10713. llsd.Add("FolderData", FolderData);
  10714. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  10715. llsd), AgentId);
  10716. }
  10717. private byte[] EncodeU32(uint val)
  10718. {
  10719. byte[] ret = BitConverter.GetBytes(val);
  10720. if (BitConverter.IsLittleEndian)
  10721. Array.Reverse(ret);
  10722. return ret;
  10723. }
  10724. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  10725. {
  10726. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10727. if (eq == null)
  10728. {
  10729. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10730. return;
  10731. }
  10732. OSDMap llsd = new OSDMap(3);
  10733. OSDMap AgentDataMap = new OSDMap(1);
  10734. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10735. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  10736. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  10737. OSDArray AgentData = new OSDArray(1);
  10738. AgentData.Add(AgentDataMap);
  10739. llsd.Add("AgentData", AgentData);
  10740. OSDArray FolderData = new OSDArray();
  10741. foreach (InventoryFolderBase folder in folders)
  10742. {
  10743. OSDMap FolderDataMap = new OSDMap(5);
  10744. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  10745. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10746. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  10747. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  10748. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  10749. FolderData.Add(FolderDataMap);
  10750. }
  10751. llsd.Add("FolderData", FolderData);
  10752. OSDArray ItemData = new OSDArray();
  10753. foreach (InventoryItemBase item in items)
  10754. {
  10755. OSDMap ItemDataMap = new OSDMap();
  10756. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  10757. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  10758. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  10759. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  10760. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  10761. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  10762. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  10763. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  10764. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  10765. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  10766. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  10767. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  10768. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  10769. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  10770. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  10771. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  10772. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  10773. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  10774. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  10775. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  10776. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  10777. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  10778. (sbyte)item.AssetType, item.AssetID,
  10779. item.GroupID, 100,
  10780. item.Owner, item.CreatorIdAsUuid,
  10781. item.ID, item.Folder,
  10782. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  10783. (uint)PermissionMask.All)
  10784. )));
  10785. ItemDataMap.Add("CallbackID", 0);
  10786. ItemData.Add(ItemDataMap);
  10787. }
  10788. llsd.Add("ItemData", ItemData);
  10789. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  10790. llsd), AgentId);
  10791. }
  10792. }
  10793. }