LLClientView.cs 599 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979
  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 System.IO;
  51. using PermissionMask = OpenSim.Framework.PermissionMask;
  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, IClientIPEndpoint
  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 BinaryGenericMessage OnBinaryGenericMessage;
  67. public event Action<IClientAPI> OnLogout;
  68. public event ObjectPermissions OnObjectPermissions;
  69. public event Action<IClientAPI> OnConnectionClosed;
  70. public event ViewerEffectEventHandler OnViewerEffect;
  71. public event ImprovedInstantMessage OnInstantMessage;
  72. public event ChatMessage OnChatFromClient;
  73. public event RezObject OnRezObject;
  74. public event DeRezObject OnDeRezObject;
  75. public event RezRestoreToWorld OnRezRestoreToWorld;
  76. public event ModifyTerrain OnModifyTerrain;
  77. public event Action<IClientAPI> OnRegionHandShakeReply;
  78. public event GenericCall1 OnRequestWearables;
  79. public event SetAppearance OnSetAppearance;
  80. public event AvatarNowWearing OnAvatarNowWearing;
  81. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  82. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  83. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  84. public event ObjectAttach OnObjectAttach;
  85. public event ObjectDeselect OnObjectDetach;
  86. public event ObjectDrop OnObjectDrop;
  87. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  88. public event UpdateAgent OnPreAgentUpdate;
  89. public event UpdateAgent OnAgentUpdate;
  90. public event UpdateAgent OnAgentCameraUpdate;
  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 ChangeAnim OnChangeAnim;
  97. public event Action<IClientAPI> OnRequestAvatarsData;
  98. public event LinkObjects OnLinkObjects;
  99. public event DelinkObjects OnDelinkObjects;
  100. public event GrabObject OnGrabObject;
  101. public event DeGrabObject OnDeGrabObject;
  102. public event SpinStart OnSpinStart;
  103. public event SpinStop OnSpinStop;
  104. public event ObjectDuplicate OnObjectDuplicate;
  105. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  106. public event MoveObject OnGrabUpdate;
  107. public event SpinObject OnSpinUpdate;
  108. public event AddNewPrim OnAddPrim;
  109. public event RequestGodlikePowers OnRequestGodlikePowers;
  110. public event GodKickUser OnGodKickUser;
  111. public event ObjectExtraParams OnUpdateExtraParams;
  112. public event UpdateShape OnUpdatePrimShape;
  113. public event ObjectRequest OnObjectRequest;
  114. public event ObjectSelect OnObjectSelect;
  115. public event ObjectDeselect OnObjectDeselect;
  116. public event GenericCall7 OnObjectDescription;
  117. public event GenericCall7 OnObjectName;
  118. public event GenericCall7 OnObjectClickAction;
  119. public event GenericCall7 OnObjectMaterial;
  120. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  121. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  122. public event UpdatePrimFlags OnUpdatePrimFlags;
  123. public event UpdatePrimTexture OnUpdatePrimTexture;
  124. public event ClientChangeObject onClientChangeObject;
  125. public event UpdateVector OnUpdatePrimGroupPosition;
  126. public event UpdateVector OnUpdatePrimSinglePosition;
  127. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  128. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  129. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  130. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  131. public event UpdateVector OnUpdatePrimScale;
  132. public event UpdateVector OnUpdatePrimGroupScale;
  133. public event RequestMapBlocks OnRequestMapBlocks;
  134. public event RequestMapName OnMapNameRequest;
  135. public event TeleportLocationRequest OnTeleportLocationRequest;
  136. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  137. public event TeleportCancel OnTeleportCancel;
  138. public event RequestAvatarProperties OnRequestAvatarProperties;
  139. public event SetAlwaysRun OnSetAlwaysRun;
  140. public event FetchInventory OnAgentDataUpdateRequest;
  141. public event TeleportLocationRequest OnSetStartLocationRequest;
  142. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  143. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  144. public event LinkInventoryItem OnLinkInventoryItem;
  145. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  146. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  147. public event MoveInventoryFolder OnMoveInventoryFolder;
  148. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  149. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  150. public event FetchInventory OnFetchInventory;
  151. public event RequestTaskInventory OnRequestTaskInventory;
  152. public event UpdateInventoryItem OnUpdateInventoryItem;
  153. public event CopyInventoryItem OnCopyInventoryItem;
  154. public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
  155. public event MoveInventoryItem OnMoveInventoryItem;
  156. public event RemoveInventoryItem OnRemoveInventoryItem;
  157. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  158. public event UDPAssetUploadRequest OnAssetUploadRequest;
  159. public event XferReceive OnXferReceive;
  160. public event RequestXfer OnRequestXfer;
  161. public event ConfirmXfer OnConfirmXfer;
  162. public event AbortXfer OnAbortXfer;
  163. public event RequestTerrain OnRequestTerrain;
  164. public event RezScript OnRezScript;
  165. public event UpdateTaskInventory OnUpdateTaskInventory;
  166. public event MoveTaskInventory OnMoveTaskItem;
  167. public event RemoveTaskInventory OnRemoveTaskItem;
  168. public event UUIDNameRequest OnNameFromUUIDRequest;
  169. public event ParcelAccessListRequest OnParcelAccessListRequest;
  170. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  171. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  172. public event ParcelDivideRequest OnParcelDivideRequest;
  173. public event ParcelJoinRequest OnParcelJoinRequest;
  174. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  175. public event ParcelSelectObjects OnParcelSelectObjects;
  176. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  177. public event ParcelAbandonRequest OnParcelAbandonRequest;
  178. public event ParcelGodForceOwner OnParcelGodForceOwner;
  179. public event ParcelReclaim OnParcelReclaim;
  180. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  181. public event ParcelDeedToGroup OnParcelDeedToGroup;
  182. public event RegionInfoRequest OnRegionInfoRequest;
  183. public event EstateCovenantRequest OnEstateCovenantRequest;
  184. public event FriendActionDelegate OnApproveFriendRequest;
  185. public event FriendActionDelegate OnDenyFriendRequest;
  186. public event FriendshipTermination OnTerminateFriendship;
  187. public event GrantUserFriendRights OnGrantUserRights;
  188. public event MoneyTransferRequest OnMoneyTransferRequest;
  189. public event EconomyDataRequest OnEconomyDataRequest;
  190. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  191. public event ParcelBuy OnParcelBuy;
  192. public event UUIDNameRequest OnTeleportHomeRequest;
  193. public event UUIDNameRequest OnUUIDGroupNameRequest;
  194. public event ScriptAnswer OnScriptAnswer;
  195. public event RequestPayPrice OnRequestPayPrice;
  196. public event ObjectSaleInfo OnObjectSaleInfo;
  197. public event ObjectBuy OnObjectBuy;
  198. public event AgentSit OnUndo;
  199. public event AgentSit OnRedo;
  200. public event LandUndo OnLandUndo;
  201. public event ForceReleaseControls OnForceReleaseControls;
  202. public event GodLandStatRequest OnLandStatRequest;
  203. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  204. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  205. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  206. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  207. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  208. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  209. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  210. public event BakeTerrain OnBakeTerrain;
  211. public event RequestTerrain OnUploadTerrain;
  212. public event EstateChangeInfo OnEstateChangeInfo;
  213. public event EstateManageTelehub OnEstateManageTelehub;
  214. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  215. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  216. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  217. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  218. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  219. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  220. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  221. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  222. public event RegionHandleRequest OnRegionHandleRequest;
  223. public event ParcelInfoRequest OnParcelInfoRequest;
  224. public event ScriptReset OnScriptReset;
  225. public event GetScriptRunning OnGetScriptRunning;
  226. public event SetScriptRunning OnSetScriptRunning;
  227. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  228. public event ActivateGesture OnActivateGesture;
  229. public event DeactivateGesture OnDeactivateGesture;
  230. public event ObjectOwner OnObjectOwner;
  231. public event DirPlacesQuery OnDirPlacesQuery;
  232. public event DirFindQuery OnDirFindQuery;
  233. public event DirLandQuery OnDirLandQuery;
  234. public event DirPopularQuery OnDirPopularQuery;
  235. public event DirClassifiedQuery OnDirClassifiedQuery;
  236. public event EventInfoRequest OnEventInfoRequest;
  237. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  238. public event MapItemRequest OnMapItemRequest;
  239. public event OfferCallingCard OnOfferCallingCard;
  240. public event AcceptCallingCard OnAcceptCallingCard;
  241. public event DeclineCallingCard OnDeclineCallingCard;
  242. public event SoundTrigger OnSoundTrigger;
  243. public event StartLure OnStartLure;
  244. public event TeleportLureRequest OnTeleportLureRequest;
  245. public event NetworkStats OnNetworkStatsUpdate;
  246. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  247. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  248. public event ClassifiedDelete OnClassifiedDelete;
  249. public event ClassifiedGodDelete OnClassifiedGodDelete;
  250. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  251. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  252. public event EventGodDelete OnEventGodDelete;
  253. public event ParcelDwellRequest OnParcelDwellRequest;
  254. public event UserInfoRequest OnUserInfoRequest;
  255. public event UpdateUserInfo OnUpdateUserInfo;
  256. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  257. public event PickDelete OnPickDelete;
  258. public event PickGodDelete OnPickGodDelete;
  259. public event PickInfoUpdate OnPickInfoUpdate;
  260. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  261. public event MuteListRequest OnMuteListRequest;
  262. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  263. public event PlacesQuery OnPlacesQuery;
  264. public event AgentFOV OnAgentFOV;
  265. public event FindAgentUpdate OnFindAgent;
  266. public event TrackAgentUpdate OnTrackAgent;
  267. public event NewUserReport OnUserReport;
  268. public event SaveStateHandler OnSaveState;
  269. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  270. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  271. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  272. public event FreezeUserUpdate OnParcelFreezeUser;
  273. public event EjectUserUpdate OnParcelEjectUser;
  274. public event ParcelBuyPass OnParcelBuyPass;
  275. public event ParcelGodMark OnParcelGodMark;
  276. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  277. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  278. public event SimWideDeletesDelegate OnSimWideDeletes;
  279. public event SendPostcard OnSendPostcard;
  280. public event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
  281. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  282. public event MuteListEntryRemove OnRemoveMuteListEntry;
  283. public event GodlikeMessage onGodlikeMessage;
  284. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  285. public event GenericCall2 OnUpdateThrottles;
  286. #pragma warning disable 0067
  287. public event GenericMessage OnGenericMessage;
  288. public event TextureRequest OnRequestTexture;
  289. public event StatusChange OnChildAgentStatus;
  290. public event GenericCall2 OnStopMovement;
  291. public event Action<UUID> OnRemoveAvatar;
  292. public event DisconnectUser OnDisconnectUser;
  293. public event RequestAsset OnRequestAsset;
  294. public event BuyObjectInventory OnBuyObjectInventory;
  295. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  296. public event TerrainUnacked OnUnackedTerrain;
  297. public event CachedTextureRequest OnCachedTextureRequest;
  298. #pragma warning restore 0067
  299. #endregion Events
  300. #region Class Members
  301. // LLClientView Only
  302. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  303. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  304. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  305. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  306. private static string LogHeader = "[LLCLIENTVIEW]";
  307. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  308. /// <summary>
  309. /// Handles UDP texture download.
  310. /// </summary>
  311. public LLImageManager ImageManager { get; private set; }
  312. public JobEngine m_asyncPacketProcess;
  313. private readonly LLUDPServer m_udpServer;
  314. private readonly LLUDPClient m_udpClient;
  315. private readonly UUID m_sessionId;
  316. private readonly UUID m_secureSessionId;
  317. protected readonly UUID m_agentId;
  318. private readonly uint m_circuitCode;
  319. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  320. private readonly IGroupsModule m_GroupsModule;
  321. private int m_cachedTextureSerial;
  322. private PriorityQueue m_entityUpdates;
  323. private PriorityQueue m_entityProps;
  324. private Prioritizer m_prioritizer;
  325. private bool m_disableFacelights = false;
  326. // needs optimazation
  327. private HashSet<SceneObjectGroup> GroupsInView = new HashSet<SceneObjectGroup>();
  328. private bool m_VelocityInterpolate = false;
  329. private const uint MaxTransferBytesPerPacket = 600;
  330. /// <value>
  331. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  332. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  333. /// ownerless phantom.
  334. ///
  335. /// All manipulation of this set has to occur under an m_entityUpdates.SyncRoot lock
  336. ///
  337. /// </value>
  338. protected List<uint> m_killRecord;
  339. // protected HashSet<uint> m_attachmentsSent;
  340. private bool m_deliverPackets = true;
  341. private bool m_SendLogoutPacketWhenClosing = true;
  342. /// <summary>
  343. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  344. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  345. /// is doing absolutely nothing.
  346. /// </summary>
  347. /// <remarks>
  348. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  349. /// cannot retain a reference to it outside of that method.
  350. /// </remarks>
  351. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  352. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  353. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  354. protected Scene m_scene;
  355. protected string m_firstName;
  356. protected string m_lastName;
  357. protected Vector3 m_startpos;
  358. protected UUID m_activeGroupID;
  359. protected string m_activeGroupName = String.Empty;
  360. protected ulong m_activeGroupPowers;
  361. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  362. protected int m_terrainCheckerCount;
  363. protected uint m_agentFOVCounter;
  364. protected IAssetService m_assetService;
  365. private const bool m_checkPackets = true;
  366. #endregion Class Members
  367. #region Properties
  368. public LLUDPClient UDPClient { get { return m_udpClient; } }
  369. public LLUDPServer UDPServer { get { return m_udpServer; } }
  370. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  371. public UUID SecureSessionId { get { return m_secureSessionId; } }
  372. public IScene Scene { get { return m_scene; } }
  373. public UUID SessionId { get { return m_sessionId; } }
  374. public Vector3 StartPos
  375. {
  376. get { return m_startpos; }
  377. set { m_startpos = value; }
  378. }
  379. public bool DeliverPackets
  380. {
  381. get { return m_deliverPackets; }
  382. set {
  383. m_deliverPackets = value;
  384. m_udpClient.m_deliverPackets = value;
  385. }
  386. }
  387. public UUID AgentId { get { return m_agentId; } }
  388. public ISceneAgent SceneAgent { get; set; }
  389. public UUID ActiveGroupId { get { return m_activeGroupID; } set { m_activeGroupID = value; } }
  390. public string ActiveGroupName { get { return m_activeGroupName; } set { m_activeGroupName = value; } }
  391. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } set { m_activeGroupPowers = value; } }
  392. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  393. public int PingTimeMS
  394. {
  395. get
  396. {
  397. if (UDPClient != null)
  398. return UDPClient.PingTimeMS;
  399. return 0;
  400. }
  401. }
  402. /// <summary>
  403. /// Entity update queues
  404. /// </summary>
  405. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  406. /// <summary>
  407. /// First name of the agent/avatar represented by the client
  408. /// </summary>
  409. public string FirstName { get { return m_firstName; } }
  410. /// <summary>
  411. /// Last name of the agent/avatar represented by the client
  412. /// </summary>
  413. public string LastName { get { return m_lastName; } }
  414. /// <summary>
  415. /// Full name of the client (first name and last name)
  416. /// </summary>
  417. public string Name { get { return FirstName + " " + LastName; } }
  418. public uint CircuitCode { get { return m_circuitCode; } }
  419. public int NextAnimationSequenceNumber
  420. {
  421. get { return m_udpServer.NextAnimationSequenceNumber; }
  422. }
  423. /// <summary>
  424. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  425. /// prevent race conditions by different threads calling Close().
  426. /// </summary>
  427. public bool IsActive { get; set; }
  428. /// <summary>
  429. /// Used to synchronise threads when client is being closed.
  430. /// </summary>
  431. public Object CloseSyncLock { get; private set; }
  432. public bool IsLoggingOut { get; set; }
  433. public bool DisableFacelights
  434. {
  435. get { return m_disableFacelights; }
  436. set { m_disableFacelights = value; }
  437. }
  438. public List<uint> SelectedObjects {get; private set;}
  439. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  440. #endregion Properties
  441. // ~LLClientView()
  442. // {
  443. // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode);
  444. // }
  445. /// <summary>
  446. /// Constructor
  447. /// </summary>
  448. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  449. UUID agentId, UUID sessionId, uint circuitCode)
  450. {
  451. // DebugPacketLevel = 1;
  452. CloseSyncLock = new Object();
  453. SelectedObjects = new List<uint>();
  454. RegisterInterface<IClientIM>(this);
  455. RegisterInterface<IClientInventory>(this);
  456. RegisterInterface<IClientChat>(this);
  457. m_scene = scene;
  458. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  459. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  460. m_killRecord = new List<uint>();
  461. // m_attachmentsSent = new HashSet<uint>();
  462. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  463. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  464. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  465. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  466. m_agentId = agentId;
  467. m_sessionId = sessionId;
  468. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  469. m_circuitCode = circuitCode;
  470. m_firstName = sessionInfo.LoginInfo.First;
  471. m_lastName = sessionInfo.LoginInfo.Last;
  472. m_startpos = sessionInfo.LoginInfo.StartPos;
  473. m_udpServer = udpServer;
  474. m_udpClient = udpClient;
  475. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  476. m_udpClient.HasUpdates += HandleHasUpdates;
  477. m_udpClient.OnPacketStats += PopulateStats;
  478. m_prioritizer = new Prioritizer(m_scene);
  479. RegisterLocalPacketHandlers();
  480. string name = string.Format("AsyncInUDP-{0}",m_agentId.ToString());
  481. m_asyncPacketProcess = new JobEngine(name, name, 10000);
  482. IsActive = true;
  483. }
  484. #region Client Methods
  485. /// <summary>
  486. /// Close down the client view
  487. /// </summary>
  488. public void Close()
  489. {
  490. Close(true, false);
  491. }
  492. public void Close(bool sendStop, bool force)
  493. {
  494. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  495. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  496. lock (CloseSyncLock)
  497. {
  498. // We still perform a force close inside the sync lock since this is intended to attempt close where
  499. // there is some unidentified connection problem, not where we have issues due to deadlock
  500. if (!IsActive && !force)
  501. {
  502. m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set",
  503. LogHeader, Name, m_scene.Name);
  504. return;
  505. }
  506. IsActive = false;
  507. CloseWithoutChecks(sendStop);
  508. }
  509. }
  510. /// <summary>
  511. /// Closes down the client view without first checking whether it is active.
  512. /// </summary>
  513. /// <remarks>
  514. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  515. /// CloseWithoutIsActiveCheck asynchronously.
  516. ///
  517. /// Callers must lock ClosingSyncLock before calling.
  518. /// </remarks>
  519. public void CloseWithoutChecks(bool sendStop)
  520. {
  521. m_log.DebugFormat(
  522. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  523. Name, m_scene.RegionInfo.RegionName);
  524. if (sendStop)
  525. {
  526. // Send the STOP packet
  527. DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
  528. OutPacket(disable, ThrottleOutPacketType.Unknown);
  529. }
  530. // Fire the callback for this connection closing
  531. if (OnConnectionClosed != null)
  532. OnConnectionClosed(this);
  533. m_asyncPacketProcess.Stop();
  534. // Flush all of the packets out of the UDP server for this client
  535. if (m_udpServer != null)
  536. m_udpServer.Flush(m_udpClient);
  537. // Remove ourselves from the scene
  538. m_scene.RemoveClient(AgentId, true);
  539. SceneAgent = null;
  540. // We can't reach into other scenes and close the connection
  541. // We need to do this over grid communications
  542. //m_scene.CloseAllAgents(CircuitCode);
  543. // Disable UDP handling for this client
  544. m_udpClient.OnQueueEmpty -= HandleQueueEmpty;
  545. m_udpClient.HasUpdates -= HandleHasUpdates;
  546. m_udpClient.OnPacketStats -= PopulateStats;
  547. m_udpClient.Shutdown();
  548. // Shutdown the image manager
  549. ImageManager.Close();
  550. ImageManager = null;
  551. m_entityUpdates = new PriorityQueue(1);
  552. m_entityProps = new PriorityQueue(1);
  553. m_killRecord.Clear();
  554. GroupsInView.Clear();
  555. if(m_scene.GetNumberOfClients() == 0)
  556. {
  557. GC.Collect();
  558. GC.WaitForPendingFinalizers();
  559. GC.Collect();
  560. }
  561. }
  562. public void Kick(string message)
  563. {
  564. if (!SceneAgent.IsChildAgent)
  565. {
  566. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  567. kupack.UserInfo.AgentID = AgentId;
  568. kupack.UserInfo.SessionID = SessionId;
  569. kupack.TargetBlock.TargetIP = 0;
  570. kupack.TargetBlock.TargetPort = 0;
  571. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  572. OutPacket(kupack, ThrottleOutPacketType.Task);
  573. // You must sleep here or users get no message!
  574. Thread.Sleep(500);
  575. }
  576. }
  577. public void Stop()
  578. {
  579. }
  580. #endregion Client Methods
  581. #region Packet Handling
  582. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  583. {
  584. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  585. if (handlerNetworkStatsUpdate != null)
  586. {
  587. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  588. }
  589. }
  590. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  591. {
  592. bool result = false;
  593. lock (PacketHandlers)
  594. {
  595. if (!PacketHandlers.ContainsKey(packetType))
  596. {
  597. PacketHandlers.Add(packetType, handler);
  598. result = true;
  599. }
  600. }
  601. return result;
  602. }
  603. /// <summary>
  604. /// Add a handler for the given packet type.
  605. /// </summary>
  606. /// <remarks>
  607. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  608. /// are received then please use the synchronous version of this method.
  609. /// </remarks>
  610. /// <param name="packetType"></param>
  611. /// <param name="handler"></param>
  612. /// <returns>true if the handler was added. This is currently always the case.</returns>
  613. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  614. {
  615. return AddLocalPacketHandler(packetType, handler, true);
  616. }
  617. /// <summary>
  618. /// Add a handler for the given packet type.
  619. /// </summary>
  620. /// <param name="packetType"></param>
  621. /// <param name="handler"></param>
  622. /// <param name="doAsync">
  623. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  624. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  625. /// synchronously.
  626. /// </param>
  627. /// <returns>true if the handler was added. This is currently always the case.</returns>
  628. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  629. {
  630. bool result = false;
  631. lock (m_packetHandlers)
  632. {
  633. if (!m_packetHandlers.ContainsKey(packetType))
  634. {
  635. m_packetHandlers.Add(
  636. packetType, new PacketProcessor() { method = handler, Async = doAsync});
  637. result = true;
  638. }
  639. }
  640. return result;
  641. }
  642. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  643. {
  644. MethodName = MethodName.ToLower().Trim();
  645. bool result = false;
  646. lock (m_genericPacketHandlers)
  647. {
  648. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  649. {
  650. m_genericPacketHandlers.Add(MethodName, handler);
  651. result = true;
  652. }
  653. }
  654. return result;
  655. }
  656. /// <summary>
  657. /// Try to process a packet using registered packet handlers
  658. /// </summary>
  659. /// <param name="packet"></param>
  660. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  661. protected virtual bool ProcessPacketMethod(Packet packet)
  662. {
  663. bool result = false;
  664. PacketProcessor pprocessor;
  665. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  666. {
  667. //there is a local handler for this packet type
  668. if (pprocessor.Async)
  669. {
  670. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  671. m_asyncPacketProcess.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj));
  672. result = true;
  673. }
  674. else
  675. {
  676. result = pprocessor.method(this, packet);
  677. }
  678. }
  679. else
  680. {
  681. //there is not a local handler so see if there is a Global handler
  682. PacketMethod method = null;
  683. bool found;
  684. lock (PacketHandlers)
  685. {
  686. found = PacketHandlers.TryGetValue(packet.Type, out method);
  687. }
  688. if (found)
  689. {
  690. result = method(this, packet);
  691. }
  692. }
  693. return result;
  694. }
  695. public void ProcessSpecificPacketAsync(object state)
  696. {
  697. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  698. try
  699. {
  700. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  701. }
  702. catch (Exception e)
  703. {
  704. // Make sure that we see any exception caused by the asynchronous operation.
  705. m_log.Error(
  706. string.Format(
  707. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packetObject.Pack, Name),
  708. e);
  709. }
  710. }
  711. #endregion Packet Handling
  712. # region Setup
  713. public virtual void Start()
  714. {
  715. m_asyncPacketProcess.Start();
  716. m_scene.AddNewAgent(this, PresenceType.User);
  717. // RefreshGroupMembership();
  718. }
  719. # endregion
  720. public void ActivateGesture(UUID assetId, UUID gestureId)
  721. {
  722. }
  723. public void DeactivateGesture(UUID assetId, UUID gestureId)
  724. {
  725. }
  726. // Sound
  727. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  728. {
  729. }
  730. #region Scene/Avatar to Client
  731. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  732. {
  733. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  734. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  735. handshake.RegionInfo.BillableFactor = args.billableFactor;
  736. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  737. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  738. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  739. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  740. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  741. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  742. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  743. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  744. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  745. handshake.RegionInfo.SimAccess = args.simAccess;
  746. handshake.RegionInfo.WaterHeight = args.waterHeight;
  747. handshake.RegionInfo.RegionFlags = args.regionFlags;
  748. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  749. handshake.RegionInfo.SimOwner = args.SimOwner;
  750. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  751. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  752. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  753. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  754. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  755. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  756. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  757. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  758. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  759. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  760. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  761. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  762. handshake.RegionInfo3.CPUClassID = 9;
  763. handshake.RegionInfo3.CPURatio = 1;
  764. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  765. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  766. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  767. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  768. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  769. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  770. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  771. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  772. }
  773. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  774. {
  775. m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
  776. // m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
  777. m_thisAgentUpdateArgs.ControlFlags = 0;
  778. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  779. mov.SimData.ChannelVersion = m_channelVersion;
  780. mov.AgentData.SessionID = m_sessionId;
  781. mov.AgentData.AgentID = AgentId;
  782. mov.Data.RegionHandle = regInfo.RegionHandle;
  783. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  784. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  785. {
  786. mov.Data.Position = m_startpos;
  787. }
  788. else
  789. {
  790. mov.Data.Position = pos;
  791. }
  792. mov.Data.LookAt = look;
  793. // Hack to get this out immediately and skip the throttles
  794. OutPacket(mov, ThrottleOutPacketType.Unknown);
  795. }
  796. public void SendChatMessage(
  797. string message, byte type, Vector3 fromPos, string fromName,
  798. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  799. {
  800. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  801. reply.ChatData.Audible = audible;
  802. reply.ChatData.Message = Util.StringToBytes1024(message);
  803. reply.ChatData.ChatType = type;
  804. reply.ChatData.SourceType = source;
  805. reply.ChatData.Position = fromPos;
  806. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  807. reply.ChatData.OwnerID = ownerID;
  808. reply.ChatData.SourceID = fromAgentID;
  809. OutPacket(reply, ThrottleOutPacketType.Unknown);
  810. }
  811. /// <summary>
  812. /// Send an instant message to this client
  813. /// </summary>
  814. //
  815. public void SendInstantMessage(GridInstantMessage im)
  816. {
  817. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  818. {
  819. ImprovedInstantMessagePacket msg
  820. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  821. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  822. msg.AgentData.SessionID = UUID.Zero;
  823. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  824. msg.MessageBlock.Dialog = im.dialog;
  825. msg.MessageBlock.FromGroup = im.fromGroup;
  826. // this is odd
  827. if (im.imSessionID == UUID.Zero.Guid)
  828. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  829. else
  830. msg.MessageBlock.ID = new UUID(im.imSessionID);
  831. msg.MessageBlock.Offline = im.offline;
  832. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  833. msg.MessageBlock.Position = im.Position;
  834. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  835. msg.MessageBlock.Timestamp = im.timestamp;
  836. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  837. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  838. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  839. OutPacket(msg, ThrottleOutPacketType.Task);
  840. }
  841. }
  842. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  843. {
  844. GenericMessagePacket gmp = new GenericMessagePacket();
  845. gmp.AgentData.AgentID = AgentId;
  846. gmp.AgentData.SessionID = m_sessionId;
  847. gmp.AgentData.TransactionID = invoice;
  848. gmp.MethodData.Method = Util.StringToBytes256(method);
  849. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  850. int i = 0;
  851. foreach (string val in message)
  852. {
  853. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  854. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  855. }
  856. OutPacket(gmp, ThrottleOutPacketType.Task);
  857. }
  858. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  859. {
  860. GenericMessagePacket gmp = new GenericMessagePacket();
  861. gmp.AgentData.AgentID = AgentId;
  862. gmp.AgentData.SessionID = m_sessionId;
  863. gmp.AgentData.TransactionID = invoice;
  864. gmp.MethodData.Method = Util.StringToBytes256(method);
  865. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  866. int i = 0;
  867. foreach (byte[] val in message)
  868. {
  869. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  870. gmp.ParamList[i++].Parameter = val;
  871. }
  872. OutPacket(gmp, ThrottleOutPacketType.Task);
  873. }
  874. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  875. {
  876. int i = 0;
  877. foreach (GroupActiveProposals Proposal in Proposals)
  878. {
  879. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  880. GAPIRP.AgentData.AgentID = AgentId;
  881. GAPIRP.AgentData.GroupID = groupID;
  882. GAPIRP.TransactionData.TransactionID = transactionID;
  883. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  884. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  885. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  886. ProposalData.VoteCast = Utils.StringToBytes("false");
  887. ProposalData.VoteID = new UUID(Proposal.VoteID);
  888. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  889. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  890. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  891. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  892. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  893. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  894. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  895. ProposalData.AlreadyVoted = false;
  896. GAPIRP.ProposalData[i] = ProposalData;
  897. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  898. i++;
  899. }
  900. if (Proposals.Length == 0)
  901. {
  902. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  903. GAPIRP.AgentData.AgentID = AgentId;
  904. GAPIRP.AgentData.GroupID = groupID;
  905. GAPIRP.TransactionData.TransactionID = transactionID;
  906. GAPIRP.TransactionData.TotalNumItems = 1;
  907. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  908. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  909. ProposalData.VoteCast = Utils.StringToBytes("false");
  910. ProposalData.VoteID = UUID.Zero;
  911. ProposalData.VoteInitiator = UUID.Zero;
  912. ProposalData.Majority = 0;
  913. ProposalData.Quorum = 0;
  914. ProposalData.TerseDateID = Utils.StringToBytes("");
  915. ProposalData.StartDateTime = Utils.StringToBytes("");
  916. ProposalData.EndDateTime = Utils.StringToBytes("");
  917. ProposalData.ProposalText = Utils.StringToBytes("");
  918. ProposalData.AlreadyVoted = false;
  919. GAPIRP.ProposalData[0] = ProposalData;
  920. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  921. }
  922. }
  923. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  924. {
  925. int i = 0;
  926. foreach (GroupVoteHistory Vote in Votes)
  927. {
  928. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  929. GVHIRP.AgentData.AgentID = AgentId;
  930. GVHIRP.AgentData.GroupID = groupID;
  931. GVHIRP.TransactionData.TransactionID = transactionID;
  932. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  933. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  934. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  935. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  936. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  937. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  938. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  939. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  940. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  941. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  942. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  943. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  944. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  945. VoteItem.CandidateID = UUID.Zero;
  946. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  947. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  948. GVHIRP.VoteItem[i] = VoteItem;
  949. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  950. i++;
  951. }
  952. if (Votes.Length == 0)
  953. {
  954. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  955. GVHIRP.AgentData.AgentID = AgentId;
  956. GVHIRP.AgentData.GroupID = groupID;
  957. GVHIRP.TransactionData.TransactionID = transactionID;
  958. GVHIRP.TransactionData.TotalNumItems = 0;
  959. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  960. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  961. GVHIRP.HistoryItemData.Majority = 0;
  962. GVHIRP.HistoryItemData.Quorum = 0;
  963. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  964. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  965. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  966. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  967. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  968. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  969. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  970. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  971. VoteItem.CandidateID = UUID.Zero;
  972. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  973. VoteItem.VoteCast = Utils.StringToBytes("No");
  974. GVHIRP.VoteItem[0] = VoteItem;
  975. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  976. }
  977. }
  978. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  979. {
  980. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  981. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  982. GADRP.AgentData.AgentID = sender.AgentId;
  983. GADRP.AgentData.GroupID = groupID;
  984. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  985. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  986. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  987. GADRP.MoneyData.CurrentInterval = 0;
  988. GADRP.MoneyData.IntervalDays = 7;
  989. GADRP.MoneyData.RequestID = transactionID;
  990. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  991. History.Amount = amt;
  992. History.Description = Utils.StringToBytes("");
  993. GADRP.HistoryData[0] = History;
  994. OutPacket(GADRP, ThrottleOutPacketType.Task);
  995. }
  996. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  997. {
  998. GroupAccountSummaryReplyPacket GASRP =
  999. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  1000. PacketType.GroupAccountSummaryReply);
  1001. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  1002. GASRP.AgentData.AgentID = sender.AgentId;
  1003. GASRP.AgentData.GroupID = groupID;
  1004. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  1005. GASRP.MoneyData.Balance = (int)moneyAmt;
  1006. GASRP.MoneyData.TotalCredits = totalTier;
  1007. GASRP.MoneyData.TotalDebits = usedTier;
  1008. GASRP.MoneyData.StartDate = new byte[1];
  1009. GASRP.MoneyData.CurrentInterval = 1;
  1010. GASRP.MoneyData.GroupTaxCurrent = 0;
  1011. GASRP.MoneyData.GroupTaxEstimate = 0;
  1012. GASRP.MoneyData.IntervalDays = 0;
  1013. GASRP.MoneyData.LandTaxCurrent = 0;
  1014. GASRP.MoneyData.LandTaxEstimate = 0;
  1015. GASRP.MoneyData.LastTaxDate = new byte[1];
  1016. GASRP.MoneyData.LightTaxCurrent = 0;
  1017. GASRP.MoneyData.TaxDate = new byte[1];
  1018. GASRP.MoneyData.RequestID = sender.AgentId;
  1019. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  1020. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  1021. GASRP.MoneyData.ObjectTaxEstimate = 0;
  1022. GASRP.MoneyData.NonExemptMembers = 0;
  1023. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1024. GASRP.MoneyData.LightTaxEstimate = 0;
  1025. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1026. }
  1027. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1028. {
  1029. GroupAccountTransactionsReplyPacket GATRP =
  1030. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1031. PacketType.GroupAccountTransactionsReply);
  1032. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1033. GATRP.AgentData.AgentID = sender.AgentId;
  1034. GATRP.AgentData.GroupID = groupID;
  1035. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1036. GATRP.MoneyData.CurrentInterval = 0;
  1037. GATRP.MoneyData.IntervalDays = 7;
  1038. GATRP.MoneyData.RequestID = transactionID;
  1039. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1040. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1041. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1042. History.Amount = 0;
  1043. History.Item = Utils.StringToBytes("");
  1044. History.Time = Utils.StringToBytes("");
  1045. History.Type = 0;
  1046. History.User = Utils.StringToBytes("");
  1047. GATRP.HistoryData[0] = History;
  1048. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1049. }
  1050. public virtual bool CanSendLayerData()
  1051. {
  1052. int n = m_udpClient.GetPacketsQueuedCount(ThrottleOutPacketType.Land);
  1053. if ( n > 128)
  1054. return false;
  1055. return true;
  1056. }
  1057. /// <summary>
  1058. /// Send the region heightmap to the client
  1059. /// This method is only called when not doing intellegent terrain patch sending and
  1060. /// is only called when the scene presence is initially created and sends all of the
  1061. /// region's patches to the client.
  1062. /// </summary>
  1063. /// <param name="map">heightmap</param>
  1064. public virtual void SendLayerData(float[] map)
  1065. {
  1066. Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData(), "LLClientView.DoSendLayerData");
  1067. // Send it sync, and async. It's not that much data
  1068. // and it improves user experience just so much!
  1069. // DoSendLayerData(map);
  1070. }
  1071. /// <summary>
  1072. /// Send terrain layer information to the client.
  1073. /// </summary>
  1074. /// <param name="o"></param>
  1075. private void DoSendLayerData(object o)
  1076. {
  1077. TerrainData map = (TerrainData)o;
  1078. try
  1079. {
  1080. // Send LayerData in typerwriter pattern
  1081. //for (int y = 0; y < 16; y++)
  1082. //{
  1083. // for (int x = 0; x < 16; x++)
  1084. // {
  1085. // SendLayerData(x, y, map);
  1086. // }
  1087. //}
  1088. // Send LayerData in a spiral pattern. Fun!
  1089. SendLayerTopRight(map, 0, 0, map.SizeX / Constants.TerrainPatchSize - 1, map.SizeY / Constants.TerrainPatchSize - 1);
  1090. }
  1091. catch (Exception e)
  1092. {
  1093. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1094. }
  1095. }
  1096. private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2)
  1097. {
  1098. // Row
  1099. for (int i = x1; i <= x2; i++)
  1100. SendLayerData(i, y1, map);
  1101. // Column
  1102. for (int j = y1 + 1; j <= y2; j++)
  1103. SendLayerData(x2, j, map);
  1104. if (x2 - x1 > 0 && y2 - y1 > 0)
  1105. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1106. }
  1107. void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2)
  1108. {
  1109. // Row in reverse
  1110. for (int i = x2; i >= x1; i--)
  1111. SendLayerData(i, y2, map);
  1112. // Column in reverse
  1113. for (int j = y2 - 1; j >= y1; j--)
  1114. SendLayerData(x1, j, map);
  1115. if (x2 - x1 > 0 && y2 - y1 > 0)
  1116. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1117. }
  1118. // Legacy form of invocation that passes around a bare data array.
  1119. // Just ignore what was passed and use the real terrain info that is part of the scene.
  1120. // As a HORRIBLE kludge in an attempt to not change the definition of IClientAPI,
  1121. // there is a special form for specifying multiple terrain patches to send.
  1122. // The form is to pass 'px' as negative the number of patches to send and to
  1123. // pass the float array as pairs of patch X and Y coordinates. So, passing 'px'
  1124. // as -2 and map= [3, 5, 8, 4] would mean to send two terrain heightmap patches
  1125. // and the patches to send are <3,5> and <8,4>.
  1126. public void SendLayerData(int px, int py, float[] map)
  1127. {
  1128. if (px >= 0)
  1129. {
  1130. SendLayerData(px, py, m_scene.Heightmap.GetTerrainData());
  1131. }
  1132. else
  1133. {
  1134. int numPatches = -px;
  1135. int[] xPatches = new int[numPatches];
  1136. int[] yPatches = new int[numPatches];
  1137. for (int pp = 0; pp < numPatches; pp++)
  1138. {
  1139. xPatches[pp] = (int)map[pp * 2];
  1140. yPatches[pp] = (int)map[pp * 2 + 1];
  1141. }
  1142. // DebugSendingPatches("SendLayerData", xPatches, yPatches);
  1143. SendLayerData(xPatches, yPatches, m_scene.Heightmap.GetTerrainData());
  1144. }
  1145. }
  1146. private void DebugSendingPatches(string pWho, int[] pX, int[] pY)
  1147. {
  1148. if (m_log.IsDebugEnabled)
  1149. {
  1150. int numPatches = pX.Length;
  1151. string Xs = "";
  1152. string Ys = "";
  1153. for (int pp = 0; pp < numPatches; pp++)
  1154. {
  1155. Xs += String.Format("{0}", (int)pX[pp]) + ",";
  1156. Ys += String.Format("{0}", (int)pY[pp]) + ",";
  1157. }
  1158. m_log.DebugFormat("{0} {1}: numPatches={2}, X={3}, Y={4}", LogHeader, pWho, numPatches, Xs, Ys);
  1159. }
  1160. }
  1161. /// <summary>
  1162. /// Sends a terrain packet for the point specified.
  1163. /// This is a legacy call that has refarbed the terrain into a flat map of floats.
  1164. /// We just use the terrain from the region we know about.
  1165. /// </summary>
  1166. /// <param name="px">Patch coordinate (x) 0..15</param>
  1167. /// <param name="py">Patch coordinate (y) 0..15</param>
  1168. /// <param name="map">heightmap</param>
  1169. public void SendLayerData(int px, int py, TerrainData terrData)
  1170. {
  1171. int[] xPatches = new[] { px };
  1172. int[] yPatches = new[] { py };
  1173. SendLayerData(xPatches, yPatches, terrData);
  1174. }
  1175. private void SendLayerData(int[] px, int[] py, TerrainData terrData)
  1176. {
  1177. try
  1178. {
  1179. byte landPacketType;
  1180. if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize)
  1181. landPacketType = (byte)TerrainPatch.LayerType.LandExtended;
  1182. else
  1183. landPacketType = (byte)TerrainPatch.LayerType.Land;
  1184. List<LayerDataPacket> packets = OpenSimTerrainCompressor.CreateLayerDataPackets(terrData, px, py, landPacketType);
  1185. foreach(LayerDataPacket pkt in packets)
  1186. OutPacket(pkt, ThrottleOutPacketType.Land);
  1187. }
  1188. catch (Exception e)
  1189. {
  1190. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1191. }
  1192. }
  1193. // wind caching
  1194. private static Dictionary<ulong,int> lastWindVersion = new Dictionary<ulong,int>();
  1195. private static Dictionary<ulong,List<LayerDataPacket>> lastWindPackets =
  1196. new Dictionary<ulong,List<LayerDataPacket>>();
  1197. /// <summary>
  1198. /// Send the wind matrix to the client
  1199. /// </summary>
  1200. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1201. public virtual void SendWindData(int version, Vector2[] windSpeeds)
  1202. {
  1203. // Vector2[] windSpeeds = (Vector2[])o;
  1204. ulong handle = this.Scene.RegionInfo.RegionHandle;
  1205. bool isNewData;
  1206. lock(lastWindPackets)
  1207. {
  1208. if(!lastWindVersion.ContainsKey(handle) ||
  1209. !lastWindPackets.ContainsKey(handle))
  1210. {
  1211. lastWindVersion[handle] = 0;
  1212. lastWindPackets[handle] = new List<LayerDataPacket>();
  1213. isNewData = true;
  1214. }
  1215. else
  1216. isNewData = lastWindVersion[handle] != version;
  1217. }
  1218. if(isNewData)
  1219. {
  1220. TerrainPatch[] patches = new TerrainPatch[2];
  1221. patches[0] = new TerrainPatch { Data = new float[16 * 16] };
  1222. patches[1] = new TerrainPatch { Data = new float[16 * 16] };
  1223. for (int x = 0; x < 16 * 16; x++)
  1224. {
  1225. patches[0].Data[x] = windSpeeds[x].X;
  1226. patches[1].Data[x] = windSpeeds[x].Y;
  1227. }
  1228. // neither we or viewers have extended wind
  1229. byte layerType = (byte)TerrainPatch.LayerType.Wind;
  1230. LayerDataPacket layerpack =
  1231. OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(
  1232. patches, layerType);
  1233. layerpack.Header.Zerocoded = true;
  1234. lock(lastWindPackets)
  1235. {
  1236. lastWindPackets[handle].Clear();
  1237. lastWindPackets[handle].Add(layerpack);
  1238. lastWindVersion[handle] = version;
  1239. }
  1240. }
  1241. lock(lastWindPackets)
  1242. foreach(LayerDataPacket pkt in lastWindPackets[handle])
  1243. OutPacket(pkt, ThrottleOutPacketType.Wind);
  1244. }
  1245. // cloud caching
  1246. private static Dictionary<ulong,int> lastCloudVersion = new Dictionary<ulong,int>();
  1247. private static Dictionary<ulong,List<LayerDataPacket>> lastCloudPackets =
  1248. new Dictionary<ulong,List<LayerDataPacket>>();
  1249. /// <summary>
  1250. /// Send the cloud matrix to the client
  1251. /// </summary>
  1252. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1253. public virtual void SendCloudData(int version, float[] cloudDensity)
  1254. {
  1255. ulong handle = this.Scene.RegionInfo.RegionHandle;
  1256. bool isNewData;
  1257. lock(lastWindPackets)
  1258. {
  1259. if(!lastCloudVersion.ContainsKey(handle) ||
  1260. !lastCloudPackets.ContainsKey(handle))
  1261. {
  1262. lastCloudVersion[handle] = 0;
  1263. lastCloudPackets[handle] = new List<LayerDataPacket>();
  1264. isNewData = true;
  1265. }
  1266. else
  1267. isNewData = lastCloudVersion[handle] != version;
  1268. }
  1269. if(isNewData)
  1270. {
  1271. TerrainPatch[] patches = new TerrainPatch[1];
  1272. patches[0] = new TerrainPatch();
  1273. patches[0].Data = new float[16 * 16];
  1274. for (int y = 0; y < 16; y++)
  1275. {
  1276. for (int x = 0; x < 16; x++)
  1277. {
  1278. patches[0].Data[y * 16 + x] = cloudDensity[y * 16 + x];
  1279. }
  1280. }
  1281. // neither we or viewers have extended clouds
  1282. byte layerType = (byte)TerrainPatch.LayerType.Cloud;
  1283. LayerDataPacket layerpack =
  1284. OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(
  1285. patches, layerType);
  1286. layerpack.Header.Zerocoded = true;
  1287. lock(lastCloudPackets)
  1288. {
  1289. lastCloudPackets[handle].Clear();
  1290. lastCloudPackets[handle].Add(layerpack);
  1291. lastCloudVersion[handle] = version;
  1292. }
  1293. }
  1294. lock(lastCloudPackets)
  1295. foreach(LayerDataPacket pkt in lastCloudPackets[handle])
  1296. OutPacket(pkt, ThrottleOutPacketType.Cloud);
  1297. }
  1298. /// <summary>
  1299. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1300. /// </summary>
  1301. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1302. {
  1303. IPAddress neighbourIP = neighbourEndPoint.Address;
  1304. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1305. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1306. // TODO: don't create new blocks if recycling an old packet
  1307. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1308. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1309. byte[] byteIP = neighbourIP.GetAddressBytes();
  1310. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1311. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1312. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1313. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1314. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1315. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1316. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1317. }
  1318. public AgentCircuitData RequestClientInfo()
  1319. {
  1320. AgentCircuitData agentData = new AgentCircuitData();
  1321. agentData.AgentID = AgentId;
  1322. agentData.SessionID = m_sessionId;
  1323. agentData.SecureSessionID = SecureSessionId;
  1324. agentData.circuitcode = m_circuitCode;
  1325. agentData.child = false;
  1326. agentData.firstname = m_firstName;
  1327. agentData.lastname = m_lastName;
  1328. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1329. if (capsModule == null) // can happen when shutting down.
  1330. return agentData;
  1331. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1332. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1333. return agentData;
  1334. }
  1335. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1336. string capsURL)
  1337. {
  1338. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1339. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1340. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1341. // TODO: don't create new blocks if recycling an old packet
  1342. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1343. newSimPack.AgentData.AgentID = AgentId;
  1344. newSimPack.AgentData.SessionID = m_sessionId;
  1345. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1346. newSimPack.Info.Position = pos;
  1347. newSimPack.Info.LookAt = look;
  1348. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1349. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1350. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1351. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1352. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1353. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1354. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1355. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1356. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1357. // Hack to get this out immediately and skip throttles
  1358. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1359. }
  1360. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1361. {
  1362. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1363. // TODO: don't create new blocks if recycling an old packet
  1364. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1365. mapReply.AgentData.AgentID = AgentId;
  1366. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1367. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1368. mapReply.AgentData.Flags = flag;
  1369. for (int i = 0; i < mapBlocks2.Length; i++)
  1370. {
  1371. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1372. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1373. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1374. mapReply.Data[i].X = mapBlocks2[i].X;
  1375. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1376. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1377. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1378. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1379. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1380. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1381. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1382. mapReply.Size[i].SizeX = mapBlocks2[i].SizeX;
  1383. mapReply.Size[i].SizeY = mapBlocks2[i].SizeY;
  1384. }
  1385. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1386. }
  1387. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1388. {
  1389. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1390. int maxsend = 10;
  1391. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1392. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1393. for (int i = 0; i < mapBlocks2.Length; i++)
  1394. {
  1395. sendingBlocks.Add(mapBlocks2[i]);
  1396. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1397. {
  1398. SendMapBlockSplit(sendingBlocks, flag);
  1399. sendingBlocks = new List<MapBlockData>();
  1400. }
  1401. }
  1402. }
  1403. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1404. {
  1405. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1406. tpLocal.Info.AgentID = AgentId;
  1407. tpLocal.Info.TeleportFlags = flags;
  1408. tpLocal.Info.LocationID = 2;
  1409. tpLocal.Info.LookAt = lookAt;
  1410. tpLocal.Info.Position = position;
  1411. // Hack to get this out immediately and skip throttles
  1412. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1413. }
  1414. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1415. uint flags, string capsURL)
  1416. {
  1417. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1418. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1419. teleport.Info.AgentID = AgentId;
  1420. teleport.Info.RegionHandle = regionHandle;
  1421. teleport.Info.SimAccess = simAccess;
  1422. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1423. IPAddress oIP = newRegionEndPoint.Address;
  1424. byte[] byteIP = oIP.GetAddressBytes();
  1425. uint ip = (uint)byteIP[3] << 24;
  1426. ip += (uint)byteIP[2] << 16;
  1427. ip += (uint)byteIP[1] << 8;
  1428. ip += (uint)byteIP[0];
  1429. teleport.Info.SimIP = ip;
  1430. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1431. teleport.Info.LocationID = 4;
  1432. teleport.Info.TeleportFlags = 1 << 4;
  1433. // Hack to get this out immediately and skip throttles.
  1434. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1435. }
  1436. /// <summary>
  1437. /// Inform the client that a teleport attempt has failed
  1438. /// </summary>
  1439. public void SendTeleportFailed(string reason)
  1440. {
  1441. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1442. tpFailed.Info.AgentID = AgentId;
  1443. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1444. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1445. // Hack to get this out immediately and skip throttles
  1446. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1447. }
  1448. /// <summary>
  1449. ///
  1450. /// </summary>
  1451. public void SendTeleportStart(uint flags)
  1452. {
  1453. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1454. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1455. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1456. // Hack to get this out immediately and skip throttles
  1457. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1458. }
  1459. public void SendTeleportProgress(uint flags, string message)
  1460. {
  1461. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1462. tpProgress.AgentData.AgentID = this.AgentId;
  1463. tpProgress.Info.TeleportFlags = flags;
  1464. tpProgress.Info.Message = Util.StringToBytes256(message);
  1465. // Hack to get this out immediately and skip throttles
  1466. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1467. }
  1468. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
  1469. {
  1470. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1471. money.MoneyData.AgentID = AgentId;
  1472. money.MoneyData.TransactionID = transaction;
  1473. money.MoneyData.TransactionSuccess = success;
  1474. money.MoneyData.Description = description;
  1475. money.MoneyData.MoneyBalance = balance;
  1476. money.TransactionInfo.TransactionType = transactionType;
  1477. money.TransactionInfo.SourceID = sourceID;
  1478. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1479. money.TransactionInfo.DestID = destID;
  1480. money.TransactionInfo.IsDestGroup = destIsGroup;
  1481. money.TransactionInfo.Amount = amount;
  1482. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1483. OutPacket(money, ThrottleOutPacketType.Task);
  1484. }
  1485. public void SendPayPrice(UUID objectID, int[] payPrice)
  1486. {
  1487. if (payPrice[0] == 0 &&
  1488. payPrice[1] == 0 &&
  1489. payPrice[2] == 0 &&
  1490. payPrice[3] == 0 &&
  1491. payPrice[4] == 0)
  1492. return;
  1493. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1494. payPriceReply.ObjectData.ObjectID = objectID;
  1495. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1496. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1497. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1498. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1499. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1500. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1501. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1502. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1503. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1504. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1505. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1506. }
  1507. public void SendStartPingCheck(byte seq)
  1508. {
  1509. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1510. pc.Header.Reliable = false;
  1511. pc.PingID.PingID = seq;
  1512. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1513. pc.PingID.OldestUnacked = 0;
  1514. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1515. UDPClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
  1516. }
  1517. public void SendKillObject(List<uint> localIDs)
  1518. {
  1519. // foreach (uint id in localIDs)
  1520. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, id, regionHandle);
  1521. // remove pending entities to reduce looping chances.
  1522. lock (m_entityProps.SyncRoot)
  1523. m_entityProps.Remove(localIDs);
  1524. lock (m_entityUpdates.SyncRoot)
  1525. m_entityUpdates.Remove(localIDs);
  1526. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1527. int perpacket = localIDs.Count;
  1528. if(perpacket > 200)
  1529. perpacket = 200;
  1530. int nsent = 0;
  1531. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[perpacket];
  1532. for (int i = 0 ; i < localIDs.Count ; i++ )
  1533. {
  1534. kill.ObjectData[nsent] = new KillObjectPacket.ObjectDataBlock();
  1535. kill.ObjectData[nsent].ID = localIDs[i];
  1536. if(++nsent >= 200)
  1537. {
  1538. kill.Header.Reliable = true;
  1539. kill.Header.Zerocoded = true;
  1540. OutPacket(kill, ThrottleOutPacketType.Task);
  1541. perpacket = localIDs.Count - i - 1;
  1542. if(perpacket == 0)
  1543. break;
  1544. if(perpacket > 200)
  1545. perpacket = 200;
  1546. kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1547. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[perpacket];
  1548. nsent = 0;
  1549. }
  1550. }
  1551. if(nsent != 0)
  1552. {
  1553. kill.Header.Reliable = true;
  1554. kill.Header.Zerocoded = true;
  1555. OutPacket(kill, ThrottleOutPacketType.Task);
  1556. }
  1557. }
  1558. /// <summary>
  1559. /// Send information about the items contained in a folder to the client.
  1560. /// </summary>
  1561. /// <remarks>
  1562. /// XXX This method needs some refactoring loving
  1563. /// </remarks>
  1564. /// <param name="ownerID">The owner of the folder</param>
  1565. /// <param name="folderID">The id of the folder</param>
  1566. /// <param name="items">The items contained in the folder identified by folderID</param>
  1567. /// <param name="folders"></param>
  1568. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1569. /// <param name="fetchItems">Do we need to send item information?</param>
  1570. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1571. List<InventoryFolderBase> folders, int version,
  1572. bool fetchFolders, bool fetchItems)
  1573. {
  1574. // An inventory descendents packet consists of a single agent section and an inventory details
  1575. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1576. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1577. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1578. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1579. //
  1580. // http://opensimulator.org/mantis/view.php?id=226
  1581. //
  1582. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1583. // 6 to 7 items at a time, so let's stick with 6
  1584. int MAX_ITEMS_PER_PACKET = 5;
  1585. int MAX_FOLDERS_PER_PACKET = 6;
  1586. int totalItems = fetchItems ? items.Count : 0;
  1587. int totalFolders = fetchFolders ? folders.Count : 0;
  1588. int itemsSent = 0;
  1589. int foldersSent = 0;
  1590. int foldersToSend = 0;
  1591. int itemsToSend = 0;
  1592. InventoryDescendentsPacket currentPacket = null;
  1593. // Handle empty folders
  1594. //
  1595. if (totalItems == 0 && totalFolders == 0)
  1596. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1597. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1598. //
  1599. while (itemsSent < totalItems || foldersSent < totalFolders)
  1600. {
  1601. if (currentPacket == null) // Start a new packet
  1602. {
  1603. foldersToSend = totalFolders - foldersSent;
  1604. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1605. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1606. if (foldersToSend == 0)
  1607. {
  1608. itemsToSend = totalItems - itemsSent;
  1609. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1610. itemsToSend = MAX_ITEMS_PER_PACKET;
  1611. }
  1612. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1613. }
  1614. if (foldersToSend-- > 0)
  1615. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1616. else if (itemsToSend-- > 0)
  1617. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1618. else
  1619. {
  1620. // m_log.DebugFormat(
  1621. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1622. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1623. currentPacket = null;
  1624. }
  1625. }
  1626. if (currentPacket != null)
  1627. {
  1628. // m_log.DebugFormat(
  1629. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1630. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1631. }
  1632. }
  1633. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1634. {
  1635. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1636. newBlock.FolderID = folder.ID;
  1637. newBlock.Name = Util.StringToBytes256(folder.Name);
  1638. newBlock.ParentID = folder.ParentID;
  1639. newBlock.Type = (sbyte)folder.Type;
  1640. //if (newBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
  1641. // newBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
  1642. return newBlock;
  1643. }
  1644. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1645. {
  1646. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1647. newBlock.ItemID = item.ID;
  1648. newBlock.AssetID = item.AssetID;
  1649. newBlock.CreatorID = item.CreatorIdAsUuid;
  1650. newBlock.BaseMask = item.BasePermissions;
  1651. newBlock.Description = Util.StringToBytes256(item.Description);
  1652. newBlock.EveryoneMask = item.EveryOnePermissions;
  1653. newBlock.OwnerMask = item.CurrentPermissions;
  1654. newBlock.FolderID = item.Folder;
  1655. newBlock.InvType = (sbyte)item.InvType;
  1656. newBlock.Name = Util.StringToBytes256(item.Name);
  1657. newBlock.NextOwnerMask = item.NextPermissions;
  1658. newBlock.OwnerID = item.Owner;
  1659. newBlock.Type = (sbyte)item.AssetType;
  1660. newBlock.GroupID = item.GroupID;
  1661. newBlock.GroupOwned = item.GroupOwned;
  1662. newBlock.GroupMask = item.GroupPermissions;
  1663. newBlock.CreationDate = item.CreationDate;
  1664. newBlock.SalePrice = item.SalePrice;
  1665. newBlock.SaleType = item.SaleType;
  1666. newBlock.Flags = item.Flags & 0x2000ff;
  1667. newBlock.CRC =
  1668. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1669. newBlock.InvType, newBlock.Type,
  1670. newBlock.AssetID, newBlock.GroupID,
  1671. newBlock.SalePrice,
  1672. newBlock.OwnerID, newBlock.CreatorID,
  1673. newBlock.ItemID, newBlock.FolderID,
  1674. newBlock.EveryoneMask,
  1675. newBlock.Flags, newBlock.OwnerMask,
  1676. newBlock.GroupMask, newBlock.NextOwnerMask);
  1677. return newBlock;
  1678. }
  1679. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1680. {
  1681. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1682. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1683. packet.FolderData[0].FolderID = UUID.Zero;
  1684. packet.FolderData[0].ParentID = UUID.Zero;
  1685. packet.FolderData[0].Type = -1;
  1686. packet.FolderData[0].Name = new byte[0];
  1687. }
  1688. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1689. {
  1690. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1691. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1692. packet.ItemData[0].ItemID = UUID.Zero;
  1693. packet.ItemData[0].AssetID = UUID.Zero;
  1694. packet.ItemData[0].CreatorID = UUID.Zero;
  1695. packet.ItemData[0].BaseMask = 0;
  1696. packet.ItemData[0].Description = new byte[0];
  1697. packet.ItemData[0].EveryoneMask = 0;
  1698. packet.ItemData[0].OwnerMask = 0;
  1699. packet.ItemData[0].FolderID = UUID.Zero;
  1700. packet.ItemData[0].InvType = (sbyte)0;
  1701. packet.ItemData[0].Name = new byte[0];
  1702. packet.ItemData[0].NextOwnerMask = 0;
  1703. packet.ItemData[0].OwnerID = UUID.Zero;
  1704. packet.ItemData[0].Type = -1;
  1705. packet.ItemData[0].GroupID = UUID.Zero;
  1706. packet.ItemData[0].GroupOwned = false;
  1707. packet.ItemData[0].GroupMask = 0;
  1708. packet.ItemData[0].CreationDate = 0;
  1709. packet.ItemData[0].SalePrice = 0;
  1710. packet.ItemData[0].SaleType = 0;
  1711. packet.ItemData[0].Flags = 0;
  1712. // No need to add CRC
  1713. }
  1714. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1715. {
  1716. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1717. descend.Header.Zerocoded = true;
  1718. descend.AgentData.AgentID = AgentId;
  1719. descend.AgentData.OwnerID = ownerID;
  1720. descend.AgentData.FolderID = folderID;
  1721. descend.AgentData.Version = version;
  1722. descend.AgentData.Descendents = descendents;
  1723. if (folders > 0)
  1724. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1725. else
  1726. AddNullFolderBlockToDecendentsPacket(ref descend);
  1727. if (items > 0)
  1728. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1729. else
  1730. AddNullItemBlockToDescendentsPacket(ref descend);
  1731. return descend;
  1732. }
  1733. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1734. {
  1735. // Fudge this value. It's only needed to make the CRC anyway
  1736. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1737. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1738. // TODO: don't create new blocks if recycling an old packet
  1739. inventoryReply.AgentData.AgentID = AgentId;
  1740. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1741. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1742. inventoryReply.InventoryData[0].ItemID = item.ID;
  1743. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1744. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1745. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1746. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1747. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1748. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1749. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1750. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1751. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1752. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1753. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1754. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1755. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1756. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1757. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1758. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1759. inventoryReply.InventoryData[0].Flags = item.Flags;
  1760. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1761. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1762. inventoryReply.InventoryData[0].CRC =
  1763. Helpers.InventoryCRC(
  1764. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1765. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1766. inventoryReply.InventoryData[0].GroupID, 100,
  1767. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1768. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1769. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1770. FULL_MASK_PERMISSIONS);
  1771. inventoryReply.Header.Zerocoded = true;
  1772. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1773. }
  1774. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1775. {
  1776. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1777. UUID transactionId = UUID.Random();
  1778. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1779. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1780. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1781. if (folderDataBlocks.Count > 0)
  1782. {
  1783. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1784. // Send these now
  1785. BulkUpdateInventoryPacket bulkUpdate
  1786. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1787. bulkUpdate.Header.Zerocoded = true;
  1788. bulkUpdate.AgentData.AgentID = AgentId;
  1789. bulkUpdate.AgentData.TransactionID = transactionId;
  1790. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1791. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1792. bulkUpdate.ItemData = foo.ToArray();
  1793. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1794. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1795. }
  1796. }
  1797. /// <summary>
  1798. /// Recursively construct bulk update packets to send folders and items
  1799. /// </summary>
  1800. /// <param name="folder"></param>
  1801. /// <param name="folderDataBlocks"></param>
  1802. /// <param name="transactionId"></param>
  1803. private void SendBulkUpdateInventoryFolderRecursive(
  1804. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1805. UUID transactionId)
  1806. {
  1807. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1808. const int MAX_ITEMS_PER_PACKET = 5;
  1809. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1810. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1811. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1812. // being used on the Linden grid at 20081203).
  1813. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1814. List<InventoryItemBase> items = contents.Items;
  1815. while (items.Count > 0)
  1816. {
  1817. BulkUpdateInventoryPacket bulkUpdate
  1818. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1819. bulkUpdate.Header.Zerocoded = true;
  1820. bulkUpdate.AgentData.AgentID = AgentId;
  1821. bulkUpdate.AgentData.TransactionID = transactionId;
  1822. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1823. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1824. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1825. for (int i = 0; i < itemsToSend; i++)
  1826. {
  1827. // Remove from the end of the list so that we don't incur a performance penalty
  1828. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1829. items.RemoveAt(items.Count - 1);
  1830. }
  1831. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1832. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1833. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1834. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1835. // items belong.
  1836. if (items.Count > 0)
  1837. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1838. }
  1839. List<InventoryFolderBase> subFolders = contents.Folders;
  1840. foreach (InventoryFolderBase subFolder in subFolders)
  1841. {
  1842. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1843. }
  1844. }
  1845. /// <summary>
  1846. /// Generate a bulk update inventory data block for the given folder
  1847. /// </summary>
  1848. /// <param name="folder"></param>
  1849. /// <returns></returns>
  1850. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1851. {
  1852. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1853. folderBlock.FolderID = folder.ID;
  1854. folderBlock.ParentID = folder.ParentID;
  1855. folderBlock.Type = (sbyte)folder.Type;
  1856. // Leaving this here for now, just in case we need to do this for a while
  1857. //if (folderBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
  1858. // folderBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
  1859. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1860. return folderBlock;
  1861. }
  1862. /// <summary>
  1863. /// Generate a bulk update inventory data block for the given item
  1864. /// </summary>
  1865. /// <param name="item"></param>
  1866. /// <returns></returns>
  1867. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1868. {
  1869. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1870. itemBlock.ItemID = item.ID;
  1871. itemBlock.AssetID = item.AssetID;
  1872. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1873. itemBlock.BaseMask = item.BasePermissions;
  1874. itemBlock.Description = Util.StringToBytes256(item.Description);
  1875. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1876. itemBlock.FolderID = item.Folder;
  1877. itemBlock.InvType = (sbyte)item.InvType;
  1878. itemBlock.Name = Util.StringToBytes256(item.Name);
  1879. itemBlock.NextOwnerMask = item.NextPermissions;
  1880. itemBlock.OwnerID = item.Owner;
  1881. itemBlock.OwnerMask = item.CurrentPermissions;
  1882. itemBlock.Type = (sbyte)item.AssetType;
  1883. itemBlock.GroupID = item.GroupID;
  1884. itemBlock.GroupOwned = item.GroupOwned;
  1885. itemBlock.GroupMask = item.GroupPermissions;
  1886. itemBlock.Flags = item.Flags & 0x2000ff;
  1887. itemBlock.SalePrice = item.SalePrice;
  1888. itemBlock.SaleType = item.SaleType;
  1889. itemBlock.CreationDate = item.CreationDate;
  1890. itemBlock.CRC =
  1891. Helpers.InventoryCRC(
  1892. 1000, 0, itemBlock.InvType,
  1893. itemBlock.Type, itemBlock.AssetID,
  1894. itemBlock.GroupID, 100,
  1895. itemBlock.OwnerID, itemBlock.CreatorID,
  1896. itemBlock.ItemID, itemBlock.FolderID,
  1897. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1898. (uint)PermissionMask.All);
  1899. return itemBlock;
  1900. }
  1901. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1902. {
  1903. if (node is InventoryItemBase)
  1904. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1905. else if (node is InventoryFolderBase)
  1906. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1907. else if (node != null)
  1908. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1909. else
  1910. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1911. }
  1912. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1913. {
  1914. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1915. BulkUpdateInventoryPacket bulkUpdate
  1916. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1917. bulkUpdate.AgentData.AgentID = AgentId;
  1918. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1919. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1920. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1921. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1922. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1923. bulkUpdate.FolderData[0].Type = -1;
  1924. bulkUpdate.FolderData[0].Name = new byte[0];
  1925. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1926. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1927. bulkUpdate.ItemData[0].ItemID = item.ID;
  1928. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1929. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1930. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1931. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1932. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1933. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1934. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1935. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1936. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1937. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1938. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1939. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1940. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1941. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1942. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1943. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1944. bulkUpdate.ItemData[0].Flags = item.Flags & 0x2000ff;
  1945. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1946. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1947. bulkUpdate.ItemData[0].CRC =
  1948. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1949. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1950. bulkUpdate.ItemData[0].GroupID, 100,
  1951. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1952. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1953. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1954. FULL_MASK_PERMISSIONS);
  1955. bulkUpdate.Header.Zerocoded = true;
  1956. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1957. }
  1958. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1959. {
  1960. SendInventoryItemCreateUpdate(Item, UUID.Zero, callbackId);
  1961. }
  1962. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1963. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
  1964. {
  1965. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1966. UpdateCreateInventoryItemPacket InventoryReply
  1967. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1968. PacketType.UpdateCreateInventoryItem);
  1969. // TODO: don't create new blocks if recycling an old packet
  1970. InventoryReply.AgentData.AgentID = AgentId;
  1971. InventoryReply.AgentData.SimApproved = true;
  1972. InventoryReply.AgentData.TransactionID = transactionID;
  1973. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1974. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1975. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1976. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1977. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1978. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1979. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1980. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1981. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1982. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1983. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1984. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1985. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1986. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1987. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1988. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1989. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1990. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1991. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1992. InventoryReply.InventoryData[0].Flags = Item.Flags & 0x2000ff;
  1993. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1994. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1995. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1996. InventoryReply.InventoryData[0].CRC =
  1997. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1998. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1999. InventoryReply.InventoryData[0].GroupID, 100,
  2000. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  2001. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  2002. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  2003. FULL_MASK_PERMISSIONS);
  2004. InventoryReply.Header.Zerocoded = true;
  2005. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  2006. }
  2007. public void SendRemoveInventoryItem(UUID itemID)
  2008. {
  2009. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  2010. // TODO: don't create new blocks if recycling an old packet
  2011. remove.AgentData.AgentID = AgentId;
  2012. remove.AgentData.SessionID = m_sessionId;
  2013. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  2014. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  2015. remove.InventoryData[0].ItemID = itemID;
  2016. remove.Header.Zerocoded = true;
  2017. OutPacket(remove, ThrottleOutPacketType.Asset);
  2018. }
  2019. /*
  2020. private uint adjustControls(int input)
  2021. {
  2022. uint ret = (uint)input;
  2023. uint masked = ret & 0x0f;
  2024. masked <<= 19;
  2025. ret |= masked;
  2026. return ret;
  2027. }
  2028. */
  2029. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  2030. {
  2031. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  2032. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  2033. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  2034. // ddata.Controls = adjustControls(controls);
  2035. ddata.Controls = (uint)controls;
  2036. ddata.PassToAgent = passToAgent;
  2037. ddata.TakeControls = TakeControls;
  2038. data[0] = ddata;
  2039. scriptcontrol.Data = data;
  2040. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  2041. }
  2042. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  2043. {
  2044. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  2045. replytask.InventoryData.TaskID = taskID;
  2046. replytask.InventoryData.Serial = serial;
  2047. replytask.InventoryData.Filename = fileName;
  2048. // OutPacket(replytask, ThrottleOutPacketType.Task);
  2049. OutPacket(replytask, ThrottleOutPacketType.Asset);
  2050. }
  2051. public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
  2052. {
  2053. ThrottleOutPacketType type = ThrottleOutPacketType.Asset;
  2054. // if (isTaskInventory)
  2055. // type = ThrottleOutPacketType.Task;
  2056. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  2057. sendXfer.XferID.ID = xferID;
  2058. sendXfer.XferID.Packet = packet;
  2059. sendXfer.DataPacket.Data = data;
  2060. OutPacket(sendXfer, type);
  2061. }
  2062. public void SendAbortXferPacket(ulong xferID)
  2063. {
  2064. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  2065. xferItem.XferID.ID = xferID;
  2066. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  2067. }
  2068. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  2069. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  2070. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  2071. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  2072. {
  2073. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  2074. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  2075. economyData.Info.ObjectCapacity = ObjectCapacity;
  2076. economyData.Info.ObjectCount = ObjectCount;
  2077. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  2078. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  2079. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  2080. economyData.Info.PriceObjectRent = PriceObjectRent;
  2081. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  2082. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  2083. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  2084. economyData.Info.PriceParcelRent = PriceParcelRent;
  2085. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  2086. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  2087. economyData.Info.PriceRentLight = PriceRentLight;
  2088. economyData.Info.PriceUpload = PriceUpload;
  2089. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  2090. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  2091. economyData.Header.Reliable = true;
  2092. OutPacket(economyData, ThrottleOutPacketType.Task);
  2093. }
  2094. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  2095. {
  2096. //construct the AvatarPickerReply packet.
  2097. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  2098. replyPacket.AgentData.AgentID = AgentData.AgentID;
  2099. replyPacket.AgentData.QueryID = AgentData.QueryID;
  2100. //int i = 0;
  2101. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  2102. foreach (AvatarPickerReplyDataArgs arg in Data)
  2103. {
  2104. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  2105. db.AvatarID = arg.AvatarID;
  2106. db.FirstName = arg.FirstName;
  2107. db.LastName = arg.LastName;
  2108. data_block.Add(db);
  2109. }
  2110. replyPacket.Data = data_block.ToArray();
  2111. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  2112. }
  2113. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  2114. {
  2115. if (agentid == AgentId)
  2116. {
  2117. ActiveGroupId = activegroupid;
  2118. ActiveGroupName = groupname;
  2119. ActiveGroupPowers = grouppowers;
  2120. }
  2121. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  2122. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  2123. sendAgentDataUpdate.AgentData.AgentID = agentid;
  2124. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2125. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2126. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2127. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2128. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2129. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2130. }
  2131. /// <summary>
  2132. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2133. /// blue information box in the bottom right hand corner.
  2134. /// </summary>
  2135. /// <param name="message"></param>
  2136. public void SendAlertMessage(string message)
  2137. {
  2138. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2139. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2140. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2141. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2142. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2143. }
  2144. public void SendAlertMessage(string message, string info)
  2145. {
  2146. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2147. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2148. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2149. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[1];
  2150. alertPack.AlertInfo[0] = new AlertMessagePacket.AlertInfoBlock();
  2151. alertPack.AlertInfo[0].Message = Util.StringToBytes256(info);
  2152. alertPack.AlertInfo[0].ExtraParams = new Byte[0];
  2153. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2154. }
  2155. /// <summary>
  2156. /// Send an agent alert message to the client.
  2157. /// </summary>
  2158. /// <param name="message"></param>
  2159. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2160. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2161. /// the AlertMessage packet).</param>
  2162. public void SendAgentAlertMessage(string message, bool modal)
  2163. {
  2164. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2165. }
  2166. /// <summary>
  2167. /// Construct an agent alert packet
  2168. /// </summary>
  2169. /// <param name="message"></param>
  2170. /// <param name="modal"></param>
  2171. /// <returns></returns>
  2172. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2173. {
  2174. // Prepend a slash to make the message come up in the top right
  2175. // again.
  2176. // Allow special formats to be sent from aware modules.
  2177. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2178. message = "/" + message;
  2179. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2180. alertPack.AgentData.AgentID = AgentId;
  2181. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2182. alertPack.AlertData.Modal = modal;
  2183. return alertPack;
  2184. }
  2185. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2186. string url)
  2187. {
  2188. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2189. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2190. loadURL.Data.ObjectID = objectID;
  2191. loadURL.Data.OwnerID = ownerID;
  2192. loadURL.Data.OwnerIsGroup = groupOwned;
  2193. loadURL.Data.Message = Util.StringToBytes256(message);
  2194. loadURL.Data.URL = Util.StringToBytes256(url);
  2195. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2196. }
  2197. public void SendDialog(
  2198. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2199. UUID textureID, int ch, string[] buttonlabels)
  2200. {
  2201. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2202. dialog.Data.ObjectID = objectID;
  2203. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2204. // this is the username of the *owner*
  2205. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2206. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2207. dialog.Data.Message = Util.StringToBytes(msg,512);
  2208. dialog.Data.ImageID = textureID;
  2209. dialog.Data.ChatChannel = ch;
  2210. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2211. for (int i = 0; i < buttonlabels.Length; i++)
  2212. {
  2213. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2214. buttons[i].ButtonLabel = Util.StringToBytes(buttonlabels[i],24);
  2215. }
  2216. dialog.Buttons = buttons;
  2217. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2218. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2219. dialog.OwnerData[0].OwnerID = ownerID;
  2220. OutPacket(dialog, ThrottleOutPacketType.Task);
  2221. }
  2222. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2223. {
  2224. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2225. // TODO: don't create new blocks if recycling an old packet
  2226. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2227. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2228. preSound.DataBlock[0].ObjectID = objectID;
  2229. preSound.DataBlock[0].OwnerID = ownerID;
  2230. preSound.DataBlock[0].SoundID = soundID;
  2231. preSound.Header.Zerocoded = true;
  2232. OutPacket(preSound, ThrottleOutPacketType.Task);
  2233. }
  2234. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2235. {
  2236. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2237. sound.DataBlock.SoundID = soundID;
  2238. sound.DataBlock.ObjectID = objectID;
  2239. sound.DataBlock.OwnerID = ownerID;
  2240. sound.DataBlock.Gain = gain;
  2241. sound.DataBlock.Flags = flags;
  2242. OutPacket(sound, ThrottleOutPacketType.Task);
  2243. }
  2244. public void SendTransferAbort(TransferRequestPacket transferRequest)
  2245. {
  2246. TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
  2247. abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
  2248. abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
  2249. m_log.Debug("[Assets] Aborting transfer; asset request failed");
  2250. OutPacket(abort, ThrottleOutPacketType.Task);
  2251. }
  2252. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2253. {
  2254. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2255. sound.SoundData.SoundID = soundID;
  2256. sound.SoundData.OwnerID = ownerID;
  2257. sound.SoundData.ObjectID = objectID;
  2258. sound.SoundData.ParentID = parentID;
  2259. sound.SoundData.Handle = handle;
  2260. sound.SoundData.Position = position;
  2261. sound.SoundData.Gain = gain;
  2262. OutPacket(sound, ThrottleOutPacketType.Task);
  2263. }
  2264. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2265. {
  2266. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2267. sound.DataBlock.ObjectID = objectID;
  2268. sound.DataBlock.Gain = gain;
  2269. OutPacket(sound, ThrottleOutPacketType.Task);
  2270. }
  2271. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2272. {
  2273. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2274. // So adjust for that
  2275. // Contributed by: Godfrey
  2276. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2277. {
  2278. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2279. }
  2280. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2281. viewertime.TimeInfo.SunDirection = Position;
  2282. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2283. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2284. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2285. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2286. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2287. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2288. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2289. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2290. viewertime.Header.Reliable = false;
  2291. viewertime.Header.Zerocoded = true;
  2292. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2293. }
  2294. // Currently Deprecated
  2295. public void SendViewerTime(int phase)
  2296. {
  2297. /*
  2298. Console.WriteLine("SunPhase: {0}", phase);
  2299. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2300. //viewertime.TimeInfo.SecPerDay = 86400;
  2301. //viewertime.TimeInfo.SecPerYear = 31536000;
  2302. viewertime.TimeInfo.SecPerDay = 1000;
  2303. viewertime.TimeInfo.SecPerYear = 365000;
  2304. viewertime.TimeInfo.SunPhase = 1;
  2305. int sunPhase = (phase + 2) / 2;
  2306. if ((sunPhase < 6) || (sunPhase > 36))
  2307. {
  2308. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2309. Console.WriteLine("sending night");
  2310. }
  2311. else
  2312. {
  2313. if (sunPhase < 12)
  2314. {
  2315. sunPhase = 12;
  2316. }
  2317. sunPhase = sunPhase - 12;
  2318. float yValue = 0.1f * (sunPhase);
  2319. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2320. if (yValue > 1.2f)
  2321. {
  2322. yValue = yValue - 1.2f;
  2323. }
  2324. yValue = Util.Clip(yValue, 0, 1);
  2325. if (sunPhase < 14)
  2326. {
  2327. yValue = 1 - yValue;
  2328. }
  2329. if (sunPhase < 12)
  2330. {
  2331. yValue *= -1;
  2332. }
  2333. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2334. Console.WriteLine("sending sun update " + yValue);
  2335. }
  2336. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2337. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2338. viewertime.Header.Reliable = false;
  2339. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2340. */
  2341. }
  2342. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2343. {
  2344. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2345. packet.Header.Reliable = false;
  2346. packet.Header.Zerocoded = true;
  2347. packet.AgentData.AgentID = AgentId;
  2348. packet.AgentData.SessionID = SessionId;
  2349. packet.Effect = effectBlocks;
  2350. // OutPacket(packet, ThrottleOutPacketType.State);
  2351. OutPacket(packet, ThrottleOutPacketType.Task);
  2352. }
  2353. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
  2354. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2355. UUID partnerID)
  2356. {
  2357. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2358. avatarReply.AgentData.AgentID = AgentId;
  2359. avatarReply.AgentData.AvatarID = avatarID;
  2360. if (aboutText != null)
  2361. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2362. else
  2363. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2364. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2365. avatarReply.PropertiesData.CharterMember = membershipType;
  2366. if (flAbout != null)
  2367. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2368. else
  2369. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2370. avatarReply.PropertiesData.Flags = flags;
  2371. avatarReply.PropertiesData.FLImageID = flImageID;
  2372. avatarReply.PropertiesData.ImageID = imageID;
  2373. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2374. avatarReply.PropertiesData.PartnerID = partnerID;
  2375. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2376. }
  2377. /// <summary>
  2378. /// Send the client an Estate message blue box pop-down with a single OK button
  2379. /// </summary>
  2380. /// <param name="FromAvatarID"></param>
  2381. /// <param name="fromSessionID"></param>
  2382. /// <param name="FromAvatarName"></param>
  2383. /// <param name="Message"></param>
  2384. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2385. {
  2386. if (!SceneAgent.IsChildAgent)
  2387. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2388. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2389. }
  2390. public void SendLogoutPacket()
  2391. {
  2392. // I know this is a bit of a hack, however there are times when you don't
  2393. // want to send this, but still need to do the rest of the shutdown process
  2394. // this method gets called from the packet server.. which makes it practically
  2395. // impossible to do any other way.
  2396. if (m_SendLogoutPacketWhenClosing)
  2397. {
  2398. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2399. // TODO: don't create new blocks if recycling an old packet
  2400. logReply.AgentData.AgentID = AgentId;
  2401. logReply.AgentData.SessionID = SessionId;
  2402. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2403. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2404. logReply.InventoryData[0].ItemID = UUID.Zero;
  2405. OutPacket(logReply, ThrottleOutPacketType.Task);
  2406. }
  2407. }
  2408. public void SendHealth(float health)
  2409. {
  2410. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2411. healthpacket.HealthData.Health = health;
  2412. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2413. }
  2414. public void SendAgentOnline(UUID[] agentIDs)
  2415. {
  2416. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2417. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2418. for (int i = 0; i < agentIDs.Length; i++)
  2419. {
  2420. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2421. onpbl.AgentID = agentIDs[i];
  2422. onpb[i] = onpbl;
  2423. }
  2424. onp.AgentBlock = onpb;
  2425. onp.Header.Reliable = true;
  2426. OutPacket(onp, ThrottleOutPacketType.Task);
  2427. }
  2428. public void SendAgentOffline(UUID[] agentIDs)
  2429. {
  2430. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2431. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2432. for (int i = 0; i < agentIDs.Length; i++)
  2433. {
  2434. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2435. onpbl.AgentID = agentIDs[i];
  2436. offpb[i] = onpbl;
  2437. }
  2438. offp.AgentBlock = offpb;
  2439. offp.Header.Reliable = true;
  2440. OutPacket(offp, ThrottleOutPacketType.Task);
  2441. }
  2442. public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY)
  2443. {
  2444. FindAgentPacket fap = new FindAgentPacket();
  2445. fap.AgentBlock.Hunter = HunterID;
  2446. fap.AgentBlock.Prey = PreyID;
  2447. fap.AgentBlock.SpaceIP = 0;
  2448. fap.LocationBlock = new FindAgentPacket.LocationBlockBlock[1];
  2449. fap.LocationBlock[0] = new FindAgentPacket.LocationBlockBlock();
  2450. fap.LocationBlock[0].GlobalX = GlobalX;
  2451. fap.LocationBlock[0].GlobalY = GlobalY;
  2452. OutPacket(fap, ThrottleOutPacketType.Task);
  2453. }
  2454. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos,
  2455. Quaternion SitOrientation, bool autopilot,
  2456. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2457. {
  2458. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2459. avatarSitResponse.SitObject.ID = TargetID;
  2460. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2461. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2462. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2463. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2464. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2465. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2466. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2467. }
  2468. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2469. {
  2470. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2471. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2472. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2473. adb.AgentID = AgentId;
  2474. adb.SessionID = SessionId; // More security
  2475. gdb.GodLevel = (byte)AdminLevel;
  2476. gdb.Token = Token;
  2477. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2478. respondPacket.GrantData = gdb;
  2479. respondPacket.AgentData = adb;
  2480. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2481. }
  2482. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2483. {
  2484. UpdateGroupMembership(GroupMembership);
  2485. SendAgentGroupDataUpdate(AgentId,GroupMembership);
  2486. }
  2487. public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
  2488. {
  2489. /* not in use
  2490. // udp part
  2491. ObjectPropertiesPacket packet =
  2492. (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  2493. ObjectPropertiesPacket.ObjectDataBlock[] ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[parts.Count];
  2494. int i = 0;
  2495. foreach(SceneObjectPart sop in parts)
  2496. ObjectData[i++] = CreateObjectPropertiesBlock(sop);
  2497. packet.ObjectData = ObjectData;
  2498. packet.Header.Zerocoded = true;
  2499. // udp send splits this mega packets correctly
  2500. // mb later will avoid that to reduce gc stress
  2501. OutPacket(packet, ThrottleOutPacketType.Task, true);
  2502. // caps physics part
  2503. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2504. if(eq == null)
  2505. return;
  2506. OSDArray array = new OSDArray();
  2507. foreach(SceneObjectPart sop in parts)
  2508. {
  2509. OSDMap physinfo = new OSDMap(6);
  2510. physinfo["LocalID"] = sop.LocalId;
  2511. physinfo["Density"] = sop.Density;
  2512. physinfo["Friction"] = sop.Friction;
  2513. physinfo["GravityMultiplier"] = sop.GravityModifier;
  2514. physinfo["Restitution"] = sop.Restitution;
  2515. physinfo["PhysicsShapeType"] = (int)sop.PhysicsShapeType;
  2516. array.Add(physinfo);
  2517. }
  2518. OSDMap llsdBody = new OSDMap(1);
  2519. llsdBody.Add("ObjectData", array);
  2520. eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId);
  2521. */
  2522. }
  2523. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2524. {
  2525. SceneObjectPart part = (SceneObjectPart)entity;
  2526. if (part != null && AgentId != UUID.Zero)
  2527. {
  2528. try
  2529. {
  2530. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2531. if (eq != null)
  2532. {
  2533. uint localid = part.LocalId;
  2534. byte physshapetype = part.PhysicsShapeType;
  2535. float density = part.Density;
  2536. float friction = part.Friction;
  2537. float bounce = part.Restitution;
  2538. float gravmod = part.GravityModifier;
  2539. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2540. }
  2541. }
  2542. catch (Exception ex)
  2543. {
  2544. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2545. }
  2546. }
  2547. }
  2548. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2549. {
  2550. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2551. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2552. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2553. uidnamebloc.ID = groupLLUID;
  2554. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2555. uidnameblock[0] = uidnamebloc;
  2556. pack.UUIDNameBlock = uidnameblock;
  2557. OutPacket(pack, ThrottleOutPacketType.Task);
  2558. }
  2559. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2560. {
  2561. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2562. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2563. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2564. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2565. // lsrepdb.
  2566. lsrp.RequestData.ReportType = reportType;
  2567. lsrp.RequestData.RequestFlags = requestFlags;
  2568. lsrp.RequestData.TotalObjectCount = resultCount;
  2569. for (int i = 0; i < lsrpia.Length; i++)
  2570. {
  2571. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2572. lsrepdb.LocationX = lsrpia[i].LocationX;
  2573. lsrepdb.LocationY = lsrpia[i].LocationY;
  2574. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2575. lsrepdb.Score = lsrpia[i].Score;
  2576. lsrepdb.TaskID = lsrpia[i].TaskID;
  2577. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2578. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2579. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2580. lsrepdba[i] = lsrepdb;
  2581. }
  2582. lsrp.ReportData = lsrepdba;
  2583. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2584. }
  2585. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2586. {
  2587. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2588. scriptRunningReply.Script.ObjectID = objectID;
  2589. scriptRunningReply.Script.ItemID = itemID;
  2590. scriptRunningReply.Script.Running = running;
  2591. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2592. }
  2593. public void SendAsset(AssetRequestToClient req)
  2594. {
  2595. if (req.AssetInf == null)
  2596. {
  2597. m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset is null",
  2598. LogHeader);
  2599. return;
  2600. }
  2601. if (req.AssetInf.Data == null)
  2602. {
  2603. m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
  2604. LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2605. return;
  2606. }
  2607. bool isWearable = false;
  2608. isWearable = ((AssetType) req.AssetInf.Type ==
  2609. AssetType.Bodypart || (AssetType) req.AssetInf.Type == AssetType.Clothing);
  2610. //m_log.Debug("sending asset " + req.RequestAssetID + ", iswearable: " + isWearable);
  2611. //if (isWearable)
  2612. // m_log.Debug((AssetType)req.AssetInf.Type);
  2613. TransferInfoPacket Transfer = new TransferInfoPacket();
  2614. Transfer.TransferInfo.ChannelType = 2;
  2615. Transfer.TransferInfo.Status = 0;
  2616. Transfer.TransferInfo.TargetType = 0;
  2617. if (req.AssetRequestSource == 2)
  2618. {
  2619. Transfer.TransferInfo.Params = new byte[20];
  2620. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2621. int assType = req.AssetInf.Type;
  2622. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2623. }
  2624. else if (req.AssetRequestSource == 3)
  2625. {
  2626. Transfer.TransferInfo.Params = req.Params;
  2627. // Transfer.TransferInfo.Params = new byte[100];
  2628. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2629. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2630. }
  2631. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2632. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2633. Transfer.Header.Zerocoded = true;
  2634. OutPacket(Transfer, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
  2635. if (req.NumPackets == 1)
  2636. {
  2637. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2638. TransferPacket.TransferData.Packet = 0;
  2639. TransferPacket.TransferData.ChannelType = 2;
  2640. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2641. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2642. TransferPacket.TransferData.Status = 1;
  2643. TransferPacket.Header.Zerocoded = true;
  2644. OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
  2645. }
  2646. else
  2647. {
  2648. int processedLength = 0;
  2649. // int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2650. int maxChunkSize = (int) MaxTransferBytesPerPacket;
  2651. int packetNumber = 0;
  2652. while (processedLength < req.AssetInf.Data.Length)
  2653. {
  2654. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2655. TransferPacket.TransferData.Packet = packetNumber;
  2656. TransferPacket.TransferData.ChannelType = 2;
  2657. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2658. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2659. byte[] chunk = new byte[chunkSize];
  2660. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2661. TransferPacket.TransferData.Data = chunk;
  2662. // 0 indicates more packets to come, 1 indicates last packet
  2663. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2664. {
  2665. TransferPacket.TransferData.Status = 0;
  2666. }
  2667. else
  2668. {
  2669. TransferPacket.TransferData.Status = 1;
  2670. }
  2671. TransferPacket.Header.Zerocoded = true;
  2672. OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
  2673. processedLength += chunkSize;
  2674. packetNumber++;
  2675. }
  2676. }
  2677. }
  2678. public void SendAssetNotFound(AssetRequestToClient req)
  2679. {
  2680. TransferInfoPacket Transfer = new TransferInfoPacket();
  2681. Transfer.TransferInfo.ChannelType = 2;
  2682. Transfer.TransferInfo.Status = -2;
  2683. Transfer.TransferInfo.TargetType = 0;
  2684. Transfer.TransferInfo.Params = req.Params;
  2685. Transfer.TransferInfo.Size = 0;
  2686. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2687. Transfer.Header.Zerocoded = true;
  2688. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2689. }
  2690. public void SendTexture(AssetBase TextureAsset)
  2691. {
  2692. }
  2693. public void SendRegionHandle(UUID regionID, ulong handle)
  2694. {
  2695. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2696. reply.ReplyBlock.RegionID = regionID;
  2697. reply.ReplyBlock.RegionHandle = handle;
  2698. OutPacket(reply, ThrottleOutPacketType.Land);
  2699. }
  2700. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2701. {
  2702. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2703. reply.AgentData.AgentID = m_agentId;
  2704. reply.Data.ParcelID = parcelID;
  2705. reply.Data.OwnerID = land.OwnerID;
  2706. reply.Data.Name = Utils.StringToBytes(land.Name);
  2707. if (land.Description != null && land.Description != String.Empty)
  2708. reply.Data.Desc = Utils.StringToBytes(land.Description.Substring(0, land.Description.Length > 254 ? 254: land.Description.Length));
  2709. else
  2710. reply.Data.Desc = new Byte[0];
  2711. reply.Data.ActualArea = land.Area;
  2712. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2713. reply.Data.Flags = (byte)Util.ConvertAccessLevelToMaturity((byte)info.AccessLevel);
  2714. if((land.Flags & (uint)ParcelFlags.ForSale) != 0)
  2715. reply.Data.Flags |= (byte)((1 << 7));
  2716. Vector3 pos = land.UserLocation;
  2717. if (pos.Equals(Vector3.Zero))
  2718. {
  2719. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2720. }
  2721. reply.Data.GlobalX = info.RegionLocX + x;
  2722. reply.Data.GlobalY = info.RegionLocY + y;
  2723. reply.Data.GlobalZ = pos.Z;
  2724. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2725. reply.Data.SnapshotID = land.SnapshotID;
  2726. reply.Data.Dwell = land.Dwell;
  2727. reply.Data.SalePrice = land.SalePrice;
  2728. reply.Data.AuctionID = (int)land.AuctionID;
  2729. OutPacket(reply, ThrottleOutPacketType.Land);
  2730. }
  2731. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2732. {
  2733. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2734. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2735. packet.Data.SimName = Utils.StringToBytes(simName);
  2736. packet.Data.SimPosition = pos;
  2737. packet.Data.LookAt = lookAt;
  2738. OutPacket(packet, ThrottleOutPacketType.Task);
  2739. }
  2740. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2741. {
  2742. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2743. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2744. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2745. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2746. packet.AgentData.AgentID = AgentId;
  2747. packet.QueryData[0].QueryID = queryID;
  2748. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2749. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2750. DirPlacesReplyPacket.StatusDataBlock[] status =
  2751. new DirPlacesReplyPacket.StatusDataBlock[0];
  2752. packet.QueryReplies = replies;
  2753. packet.StatusData = status;
  2754. foreach (DirPlacesReplyData d in data)
  2755. {
  2756. int idx = replies.Length;
  2757. Array.Resize(ref replies, idx + 1);
  2758. Array.Resize(ref status, idx + 1);
  2759. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2760. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2761. replies[idx].ParcelID = d.parcelID;
  2762. replies[idx].Name = Utils.StringToBytes(d.name);
  2763. replies[idx].ForSale = d.forSale;
  2764. replies[idx].Auction = d.auction;
  2765. replies[idx].Dwell = d.dwell;
  2766. status[idx].Status = d.Status;
  2767. packet.QueryReplies = replies;
  2768. packet.StatusData = status;
  2769. if (packet.Length >= 1000)
  2770. {
  2771. OutPacket(packet, ThrottleOutPacketType.Task);
  2772. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2773. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2774. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2775. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2776. packet.AgentData.AgentID = AgentId;
  2777. packet.QueryData[0].QueryID = queryID;
  2778. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2779. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2780. }
  2781. }
  2782. if (replies.Length > 0 || data.Length == 0)
  2783. OutPacket(packet, ThrottleOutPacketType.Task);
  2784. }
  2785. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2786. {
  2787. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2788. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2789. packet.AgentData.AgentID = AgentId;
  2790. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2791. packet.QueryData.QueryID = queryID;
  2792. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2793. data.Length];
  2794. int i = 0;
  2795. foreach (DirPeopleReplyData d in data)
  2796. {
  2797. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2798. packet.QueryReplies[i].AgentID = d.agentID;
  2799. packet.QueryReplies[i].FirstName =
  2800. Utils.StringToBytes(d.firstName);
  2801. packet.QueryReplies[i].LastName =
  2802. Utils.StringToBytes(d.lastName);
  2803. packet.QueryReplies[i].Group =
  2804. Utils.StringToBytes(d.group);
  2805. packet.QueryReplies[i].Online = d.online;
  2806. packet.QueryReplies[i].Reputation = d.reputation;
  2807. i++;
  2808. }
  2809. OutPacket(packet, ThrottleOutPacketType.Task);
  2810. }
  2811. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2812. {
  2813. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2814. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2815. packet.AgentData.AgentID = AgentId;
  2816. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2817. packet.QueryData.QueryID = queryID;
  2818. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2819. data.Length];
  2820. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2821. data.Length];
  2822. int i = 0;
  2823. foreach (DirEventsReplyData d in data)
  2824. {
  2825. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2826. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2827. packet.QueryReplies[i].OwnerID = d.ownerID;
  2828. packet.QueryReplies[i].Name =
  2829. Utils.StringToBytes(d.name);
  2830. packet.QueryReplies[i].EventID = d.eventID;
  2831. packet.QueryReplies[i].Date =
  2832. Utils.StringToBytes(d.date);
  2833. packet.QueryReplies[i].UnixTime = d.unixTime;
  2834. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2835. packet.StatusData[i].Status = d.Status;
  2836. i++;
  2837. }
  2838. OutPacket(packet, ThrottleOutPacketType.Task);
  2839. }
  2840. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2841. {
  2842. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2843. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2844. packet.AgentData.AgentID = AgentId;
  2845. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2846. packet.QueryData.QueryID = queryID;
  2847. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2848. data.Length];
  2849. int i = 0;
  2850. foreach (DirGroupsReplyData d in data)
  2851. {
  2852. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2853. packet.QueryReplies[i].GroupID = d.groupID;
  2854. packet.QueryReplies[i].GroupName =
  2855. Utils.StringToBytes(d.groupName);
  2856. packet.QueryReplies[i].Members = d.members;
  2857. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2858. i++;
  2859. }
  2860. OutPacket(packet, ThrottleOutPacketType.Task);
  2861. }
  2862. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2863. {
  2864. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2865. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2866. packet.AgentData.AgentID = AgentId;
  2867. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2868. packet.QueryData.QueryID = queryID;
  2869. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2870. data.Length];
  2871. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2872. data.Length];
  2873. int i = 0;
  2874. foreach (DirClassifiedReplyData d in data)
  2875. {
  2876. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2877. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2878. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2879. packet.QueryReplies[i].Name =
  2880. Utils.StringToBytes(d.name);
  2881. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2882. packet.QueryReplies[i].CreationDate = d.creationDate;
  2883. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2884. packet.QueryReplies[i].PriceForListing = d.price;
  2885. packet.StatusData[i].Status = d.Status;
  2886. i++;
  2887. }
  2888. OutPacket(packet, ThrottleOutPacketType.Task);
  2889. }
  2890. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2891. {
  2892. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2893. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2894. packet.AgentData.AgentID = AgentId;
  2895. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2896. packet.QueryData.QueryID = queryID;
  2897. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2898. data.Length];
  2899. int i = 0;
  2900. foreach (DirLandReplyData d in data)
  2901. {
  2902. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2903. packet.QueryReplies[i].ParcelID = d.parcelID;
  2904. packet.QueryReplies[i].Name =
  2905. Utils.StringToBytes(d.name);
  2906. packet.QueryReplies[i].Auction = d.auction;
  2907. packet.QueryReplies[i].ForSale = d.forSale;
  2908. packet.QueryReplies[i].SalePrice = d.salePrice;
  2909. packet.QueryReplies[i].ActualArea = d.actualArea;
  2910. i++;
  2911. }
  2912. OutPacket(packet, ThrottleOutPacketType.Task);
  2913. }
  2914. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2915. {
  2916. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2917. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2918. packet.AgentData.AgentID = AgentId;
  2919. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2920. packet.QueryData.QueryID = queryID;
  2921. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2922. data.Length];
  2923. int i = 0;
  2924. foreach (DirPopularReplyData d in data)
  2925. {
  2926. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2927. packet.QueryReplies[i].ParcelID = d.parcelID;
  2928. packet.QueryReplies[i].Name =
  2929. Utils.StringToBytes(d.name);
  2930. packet.QueryReplies[i].Dwell = d.dwell;
  2931. i++;
  2932. }
  2933. OutPacket(packet, ThrottleOutPacketType.Task);
  2934. }
  2935. public void SendEventInfoReply(EventData data)
  2936. {
  2937. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2938. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2939. packet.AgentData.AgentID = AgentId;
  2940. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2941. packet.EventData.EventID = data.eventID;
  2942. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2943. packet.EventData.Name = Utils.StringToBytes(data.name);
  2944. packet.EventData.Category = Utils.StringToBytes(data.category);
  2945. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2946. packet.EventData.Date = Utils.StringToBytes(data.date);
  2947. packet.EventData.DateUTC = data.dateUTC;
  2948. packet.EventData.Duration = data.duration;
  2949. packet.EventData.Cover = data.cover;
  2950. packet.EventData.Amount = data.amount;
  2951. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2952. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2953. packet.EventData.EventFlags = data.eventFlags;
  2954. OutPacket(packet, ThrottleOutPacketType.Task);
  2955. }
  2956. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2957. {
  2958. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2959. mirplk.AgentData.AgentID = AgentId;
  2960. mirplk.RequestData.ItemType = mapitemtype;
  2961. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2962. for (int i = 0; i < replies.Length; i++)
  2963. {
  2964. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2965. mrdata.X = replies[i].x;
  2966. mrdata.Y = replies[i].y;
  2967. mrdata.ID = replies[i].id;
  2968. mrdata.Extra = replies[i].Extra;
  2969. mrdata.Extra2 = replies[i].Extra2;
  2970. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2971. mirplk.Data[i] = mrdata;
  2972. }
  2973. //m_log.Debug(mirplk.ToString());
  2974. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2975. }
  2976. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2977. {
  2978. // a bit special, as this uses AgentID to store the source instead
  2979. // of the destination. The destination (the receiver) goes into destID
  2980. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2981. p.AgentData.AgentID = srcID;
  2982. p.AgentData.SessionID = UUID.Zero;
  2983. p.AgentBlock.DestID = AgentId;
  2984. p.AgentBlock.TransactionID = transactionID;
  2985. OutPacket(p, ThrottleOutPacketType.Task);
  2986. }
  2987. public void SendAcceptCallingCard(UUID transactionID)
  2988. {
  2989. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2990. p.AgentData.AgentID = AgentId;
  2991. p.AgentData.SessionID = UUID.Zero;
  2992. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2993. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2994. p.FolderData[0].FolderID = UUID.Zero;
  2995. OutPacket(p, ThrottleOutPacketType.Task);
  2996. }
  2997. public void SendDeclineCallingCard(UUID transactionID)
  2998. {
  2999. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  3000. p.AgentData.AgentID = AgentId;
  3001. p.AgentData.SessionID = UUID.Zero;
  3002. p.TransactionBlock.TransactionID = transactionID;
  3003. OutPacket(p, ThrottleOutPacketType.Task);
  3004. }
  3005. public void SendTerminateFriend(UUID exFriendID)
  3006. {
  3007. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  3008. p.AgentData.AgentID = AgentId;
  3009. p.AgentData.SessionID = SessionId;
  3010. p.ExBlock.OtherID = exFriendID;
  3011. OutPacket(p, ThrottleOutPacketType.Task);
  3012. }
  3013. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  3014. {
  3015. OSDMap llsd = new OSDMap(3);
  3016. OSDArray AgentData = new OSDArray(1);
  3017. OSDMap AgentDataMap = new OSDMap(1);
  3018. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  3019. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  3020. AgentData.Add(AgentDataMap);
  3021. llsd.Add("AgentData", AgentData);
  3022. OSDArray GroupData = new OSDArray(data.Length);
  3023. // OSDArray NewGroupData = new OSDArray(data.Length);
  3024. foreach (GroupMembershipData m in data)
  3025. {
  3026. OSDMap GroupDataMap = new OSDMap(6);
  3027. OSDMap NewGroupDataMap = new OSDMap(1);
  3028. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  3029. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  3030. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  3031. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  3032. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  3033. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  3034. // NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  3035. GroupData.Add(GroupDataMap);
  3036. // NewGroupData.Add(NewGroupDataMap);
  3037. }
  3038. llsd.Add("GroupData", GroupData);
  3039. // llsd.Add("NewGroupData", NewGroupData);
  3040. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  3041. if (eq != null)
  3042. {
  3043. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  3044. }
  3045. }
  3046. public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data)
  3047. {
  3048. if(avatarID != AgentId)
  3049. m_log.Debug("[CLIENT]: SendAgentGroupDataUpdate avatarID != AgentId");
  3050. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  3051. if(eq != null)
  3052. {
  3053. eq.GroupMembershipData(avatarID,data);
  3054. }
  3055. else
  3056. {
  3057. // use UDP if no caps
  3058. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  3059. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[data.Length];
  3060. for (int i = 0; i < data.Length; i++)
  3061. {
  3062. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  3063. Group.AcceptNotices = data[i].AcceptNotices;
  3064. Group.Contribution = data[i].Contribution;
  3065. Group.GroupID = data[i].GroupID;
  3066. Group.GroupInsigniaID = data[i].GroupPicture;
  3067. Group.GroupName = Util.StringToBytes256(data[i].GroupName);
  3068. Group.GroupPowers = data[i].GroupPowers;
  3069. Groups[i] = Group;
  3070. }
  3071. Groupupdate.GroupData = Groups;
  3072. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  3073. Groupupdate.AgentData.AgentID = avatarID;
  3074. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  3075. }
  3076. }
  3077. public void SendJoinGroupReply(UUID groupID, bool success)
  3078. {
  3079. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  3080. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  3081. p.AgentData.AgentID = AgentId;
  3082. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  3083. p.GroupData.GroupID = groupID;
  3084. p.GroupData.Success = success;
  3085. OutPacket(p, ThrottleOutPacketType.Task);
  3086. }
  3087. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  3088. {
  3089. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  3090. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  3091. p.AgentData.AgentID = agentID;
  3092. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  3093. p.GroupData.GroupID = groupID;
  3094. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  3095. p.EjectData.Success = success;
  3096. OutPacket(p, ThrottleOutPacketType.Task);
  3097. }
  3098. public void SendLeaveGroupReply(UUID groupID, bool success)
  3099. {
  3100. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  3101. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  3102. p.AgentData.AgentID = AgentId;
  3103. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  3104. p.GroupData.GroupID = groupID;
  3105. p.GroupData.Success = success;
  3106. OutPacket(p, ThrottleOutPacketType.Task);
  3107. }
  3108. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  3109. {
  3110. if (classifiedID.Length != name.Length)
  3111. return;
  3112. AvatarClassifiedReplyPacket ac =
  3113. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3114. PacketType.AvatarClassifiedReply);
  3115. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3116. ac.AgentData.AgentID = AgentId;
  3117. ac.AgentData.TargetID = targetID;
  3118. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  3119. int i;
  3120. for (i = 0; i < classifiedID.Length; i++)
  3121. {
  3122. ac.Data[i].ClassifiedID = classifiedID[i];
  3123. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  3124. }
  3125. OutPacket(ac, ThrottleOutPacketType.Task);
  3126. }
  3127. 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)
  3128. {
  3129. ClassifiedInfoReplyPacket cr =
  3130. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  3131. PacketType.ClassifiedInfoReply);
  3132. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  3133. cr.AgentData.AgentID = AgentId;
  3134. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  3135. cr.Data.ClassifiedID = classifiedID;
  3136. cr.Data.CreatorID = creatorID;
  3137. cr.Data.CreationDate = creationDate;
  3138. cr.Data.ExpirationDate = expirationDate;
  3139. cr.Data.Category = category;
  3140. cr.Data.Name = Utils.StringToBytes(name);
  3141. cr.Data.Desc = Utils.StringToBytes(description);
  3142. cr.Data.ParcelID = parcelID;
  3143. cr.Data.ParentEstate = parentEstate;
  3144. cr.Data.SnapshotID = snapshotID;
  3145. cr.Data.SimName = Utils.StringToBytes(simName);
  3146. cr.Data.PosGlobal = new Vector3d(globalPos);
  3147. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  3148. cr.Data.ClassifiedFlags = classifiedFlags;
  3149. cr.Data.PriceForListing = price;
  3150. OutPacket(cr, ThrottleOutPacketType.Task);
  3151. }
  3152. public void SendAgentDropGroup(UUID groupID)
  3153. {
  3154. AgentDropGroupPacket dg =
  3155. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  3156. PacketType.AgentDropGroup);
  3157. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  3158. dg.AgentData.AgentID = AgentId;
  3159. dg.AgentData.GroupID = groupID;
  3160. OutPacket(dg, ThrottleOutPacketType.Task);
  3161. }
  3162. public void SendAvatarNotesReply(UUID targetID, string text)
  3163. {
  3164. AvatarNotesReplyPacket an =
  3165. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  3166. PacketType.AvatarNotesReply);
  3167. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  3168. an.AgentData.AgentID = AgentId;
  3169. an.Data = new AvatarNotesReplyPacket.DataBlock();
  3170. an.Data.TargetID = targetID;
  3171. an.Data.Notes = Utils.StringToBytes(text);
  3172. OutPacket(an, ThrottleOutPacketType.Task);
  3173. }
  3174. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  3175. {
  3176. AvatarPicksReplyPacket ap =
  3177. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  3178. PacketType.AvatarPicksReply);
  3179. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  3180. ap.AgentData.AgentID = AgentId;
  3181. ap.AgentData.TargetID = targetID;
  3182. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  3183. int i = 0;
  3184. foreach (KeyValuePair<UUID, string> pick in picks)
  3185. {
  3186. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  3187. ap.Data[i].PickID = pick.Key;
  3188. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  3189. i++;
  3190. }
  3191. OutPacket(ap, ThrottleOutPacketType.Task);
  3192. }
  3193. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  3194. {
  3195. AvatarClassifiedReplyPacket ac =
  3196. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3197. PacketType.AvatarClassifiedReply);
  3198. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3199. ac.AgentData.AgentID = AgentId;
  3200. ac.AgentData.TargetID = targetID;
  3201. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3202. int i = 0;
  3203. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3204. {
  3205. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3206. ac.Data[i].ClassifiedID = classified.Key;
  3207. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3208. i++;
  3209. }
  3210. OutPacket(ac, ThrottleOutPacketType.Task);
  3211. }
  3212. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3213. {
  3214. ParcelDwellReplyPacket pd =
  3215. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3216. PacketType.ParcelDwellReply);
  3217. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3218. pd.AgentData.AgentID = AgentId;
  3219. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3220. pd.Data.LocalID = localID;
  3221. pd.Data.ParcelID = parcelID;
  3222. pd.Data.Dwell = dwell;
  3223. OutPacket(pd, ThrottleOutPacketType.Land);
  3224. }
  3225. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3226. {
  3227. UserInfoReplyPacket ur =
  3228. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3229. PacketType.UserInfoReply);
  3230. string Visible = "hidden";
  3231. if (visible)
  3232. Visible = "default";
  3233. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3234. ur.AgentData.AgentID = AgentId;
  3235. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3236. ur.UserData.IMViaEMail = imViaEmail;
  3237. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3238. ur.UserData.EMail = Utils.StringToBytes(email);
  3239. OutPacket(ur, ThrottleOutPacketType.Task);
  3240. }
  3241. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3242. {
  3243. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3244. createGroupReply.AgentData =
  3245. new CreateGroupReplyPacket.AgentDataBlock();
  3246. createGroupReply.ReplyData =
  3247. new CreateGroupReplyPacket.ReplyDataBlock();
  3248. createGroupReply.AgentData.AgentID = AgentId;
  3249. createGroupReply.ReplyData.GroupID = groupID;
  3250. createGroupReply.ReplyData.Success = success;
  3251. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3252. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3253. }
  3254. public void SendUseCachedMuteList()
  3255. {
  3256. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3257. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3258. useCachedMuteList.AgentData.AgentID = AgentId;
  3259. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3260. }
  3261. public void SendEmpytMuteList()
  3262. {
  3263. GenericMessagePacket gmp = new GenericMessagePacket();
  3264. gmp.AgentData.AgentID = AgentId;
  3265. gmp.AgentData.SessionID = m_sessionId;
  3266. gmp.AgentData.TransactionID = UUID.Zero;
  3267. gmp.MethodData.Method = Util.StringToBytes256("emptymutelist");
  3268. gmp.ParamList = new GenericMessagePacket.ParamListBlock[1];
  3269. gmp.ParamList[0] = new GenericMessagePacket.ParamListBlock();
  3270. gmp.ParamList[0].Parameter = new byte[0];
  3271. OutPacket(gmp, ThrottleOutPacketType.Task);
  3272. }
  3273. public void SendMuteListUpdate(string filename)
  3274. {
  3275. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3276. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3277. muteListUpdate.MuteData.AgentID = AgentId;
  3278. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3279. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3280. }
  3281. 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)
  3282. {
  3283. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3284. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3285. pickInfoReply.AgentData.AgentID = AgentId;
  3286. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3287. pickInfoReply.Data.PickID = pickID;
  3288. pickInfoReply.Data.CreatorID = creatorID;
  3289. pickInfoReply.Data.TopPick = topPick;
  3290. pickInfoReply.Data.ParcelID = parcelID;
  3291. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3292. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3293. pickInfoReply.Data.SnapshotID = snapshotID;
  3294. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3295. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3296. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3297. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3298. pickInfoReply.Data.SortOrder = sortOrder;
  3299. pickInfoReply.Data.Enabled = enabled;
  3300. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3301. }
  3302. #endregion Scene/Avatar to Client
  3303. // Gesture
  3304. #region Appearance/ Wearables Methods
  3305. public void SendWearables(AvatarWearable[] wearables, int serial)
  3306. {
  3307. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3308. aw.AgentData.AgentID = AgentId;
  3309. aw.AgentData.SerialNum = (uint)serial;
  3310. aw.AgentData.SessionID = m_sessionId;
  3311. int count = 0;
  3312. for (int i = 0; i < wearables.Length; i++)
  3313. count += wearables[i].Count;
  3314. // TODO: don't create new blocks if recycling an old packet
  3315. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3316. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3317. int idx = 0;
  3318. for (int i = 0; i < wearables.Length; i++)
  3319. {
  3320. for (int j = 0; j < wearables[i].Count; j++)
  3321. {
  3322. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3323. awb.WearableType = (byte) i;
  3324. awb.AssetID = wearables[i][j].AssetID;
  3325. awb.ItemID = wearables[i][j].ItemID;
  3326. aw.WearableData[idx] = awb;
  3327. idx++;
  3328. // m_log.DebugFormat(
  3329. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3330. // awb.ItemID, awb.AssetID, i, Name);
  3331. }
  3332. }
  3333. OutPacket(aw, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
  3334. }
  3335. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3336. {
  3337. // m_log.DebugFormat(
  3338. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3339. // agentID, textureEntry.Length, Name, AgentId);
  3340. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3341. // TODO: don't create new blocks if recycling an old packet
  3342. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
  3343. avp.ObjectData.TextureEntry = textureEntry;
  3344. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3345. for (int i = 0; i < visualParams.Length; i++)
  3346. {
  3347. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3348. avblock.ParamValue = visualParams[i];
  3349. avp.VisualParam[i] = avblock;
  3350. }
  3351. avp.Sender.IsTrial = false;
  3352. avp.Sender.ID = agentID;
  3353. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3354. avp.AppearanceHover = new AvatarAppearancePacket.AppearanceHoverBlock[0];
  3355. // this need be use in future ?
  3356. // avp.AppearanceData[0].AppearanceVersion = 0;
  3357. // avp.AppearanceData[0].CofVersion = 0;
  3358. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3359. OutPacket(avp, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
  3360. }
  3361. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3362. {
  3363. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3364. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3365. // TODO: don't create new blocks if recycling an old packet
  3366. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3367. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3368. ani.Sender.ID = sourceAgentId;
  3369. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3370. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3371. for (int i = 0; i < animations.Length; ++i)
  3372. {
  3373. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3374. ani.AnimationList[i].AnimID = animations[i];
  3375. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3376. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3377. if (objectIDs[i].Equals(sourceAgentId))
  3378. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3379. else
  3380. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3381. }
  3382. ani.Header.Reliable = false;
  3383. OutPacket(ani, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
  3384. }
  3385. #endregion
  3386. #region Avatar Packet/Data Sending Methods
  3387. /// <summary>
  3388. /// Send an ObjectUpdate packet with information about an avatar
  3389. /// </summary>
  3390. public void SendEntityFullUpdateImmediate(ISceneEntity ent)
  3391. {
  3392. // m_log.DebugFormat(
  3393. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3394. // avatar.Name, avatar.UUID, Name, AgentId);
  3395. if (ent == null)
  3396. return;
  3397. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3398. objupdate.Header.Zerocoded = true;
  3399. objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
  3400. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3401. if(ent is ScenePresence)
  3402. {
  3403. ScenePresence presence = ent as ScenePresence;
  3404. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3405. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3406. }
  3407. else if(ent is SceneObjectPart)
  3408. {
  3409. SceneObjectPart part = ent as SceneObjectPart;
  3410. objupdate.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3411. objupdate.ObjectData[0] = CreatePrimUpdateBlock(part, (ScenePresence)SceneAgent);
  3412. }
  3413. OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
  3414. // We need to record the avatar local id since the root prim of an attachment points to this.
  3415. // m_attachmentsSent.Add(avatar.LocalId);
  3416. }
  3417. public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
  3418. {
  3419. // m_log.DebugFormat(
  3420. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3421. // avatar.Name, avatar.UUID, Name, AgentId);
  3422. if (ent == null)
  3423. return;
  3424. ImprovedTerseObjectUpdatePacket objupdate =
  3425. (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3426. objupdate.Header.Zerocoded = true;
  3427. objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
  3428. objupdate.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  3429. if(ent is ScenePresence)
  3430. {
  3431. ScenePresence presence = ent as ScenePresence;
  3432. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3433. objupdate.ObjectData[0] = CreateImprovedTerseBlock(ent, false);
  3434. }
  3435. else if(ent is SceneObjectPart)
  3436. {
  3437. SceneObjectPart part = ent as SceneObjectPart;
  3438. objupdate.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3439. objupdate.ObjectData[0] = CreateImprovedTerseBlock(ent, false);
  3440. }
  3441. OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
  3442. // We need to record the avatar local id since the root prim of an attachment points to this.
  3443. // m_attachmentsSent.Add(avatar.LocalId);
  3444. }
  3445. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3446. {
  3447. // We don't need to update inactive clients.
  3448. if (!IsActive)
  3449. return;
  3450. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3451. loc.Header.Reliable = false;
  3452. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3453. // a CoarseLocationUpdate packet is received. Oh well.
  3454. int total = Math.Min(CoarseLocations.Count, 60);
  3455. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3456. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3457. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3458. int selfindex = -1;
  3459. for (int i = 0; i < total; i++)
  3460. {
  3461. CoarseLocationUpdatePacket.LocationBlock lb =
  3462. new CoarseLocationUpdatePacket.LocationBlock();
  3463. lb.X = (byte)CoarseLocations[i].X;
  3464. lb.Y = (byte)CoarseLocations[i].Y;
  3465. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3466. loc.Location[i] = lb;
  3467. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3468. loc.AgentData[i].AgentID = users[i];
  3469. if (users[i] == AgentId)
  3470. selfindex = i;
  3471. }
  3472. ib.You = (short)selfindex;
  3473. ib.Prey = -1;
  3474. loc.Index = ib;
  3475. OutPacket(loc, ThrottleOutPacketType.Task);
  3476. }
  3477. #endregion Avatar Packet/Data Sending Methods
  3478. #region Primitive Packet/Data Sending Methods
  3479. /// <summary>
  3480. /// Generate one of the object update packets based on PrimUpdateFlags
  3481. /// and broadcast the packet to clients
  3482. /// </summary>
  3483. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3484. {
  3485. /*
  3486. if (entity.UUID == m_agentId && !updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3487. {
  3488. ImprovedTerseObjectUpdatePacket packet
  3489. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3490. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3491. packet.RegionData.TimeDilation = Utils.FloatToUInt16(1, 0.0f, 1.0f);
  3492. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  3493. packet.ObjectData[0] = CreateImprovedTerseBlock(entity, false);
  3494. OutPacket(packet, ThrottleOutPacketType.Unknown, true);
  3495. return;
  3496. }
  3497. */
  3498. if (entity is SceneObjectPart)
  3499. {
  3500. SceneObjectPart p = (SceneObjectPart)entity;
  3501. SceneObjectGroup g = p.ParentGroup;
  3502. if (g.HasPrivateAttachmentPoint && g.OwnerID != AgentId)
  3503. return; // Don't send updates for other people's HUDs
  3504. if((updateFlags ^ PrimUpdateFlags.SendInTransit) == 0)
  3505. {
  3506. List<uint> partIDs = (new List<uint> {p.LocalId});
  3507. lock (m_entityProps.SyncRoot)
  3508. m_entityProps.Remove(partIDs);
  3509. lock (m_entityUpdates.SyncRoot)
  3510. m_entityUpdates.Remove(partIDs);
  3511. return;
  3512. }
  3513. }
  3514. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3515. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3516. lock (m_entityUpdates.SyncRoot)
  3517. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags));
  3518. }
  3519. /// <summary>
  3520. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3521. /// We will update the priority and put it in the correct queue, merging update flags
  3522. /// with any other updates that may be queued for the same entity.
  3523. /// The original update time is used for the merged update.
  3524. /// </summary>
  3525. private void ResendPrimUpdate(EntityUpdate update)
  3526. {
  3527. // If the update exists in priority queue, it will be updated.
  3528. // If it does not exist then it will be added with the current (rather than its original) priority
  3529. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3530. lock (m_entityUpdates.SyncRoot)
  3531. m_entityUpdates.Enqueue(priority, update);
  3532. }
  3533. /// <summary>
  3534. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3535. /// We will update the priority and put it in the correct queue, merging update flags
  3536. /// with any other updates that may be queued for the same entity.
  3537. /// The original update time is used for the merged update.
  3538. /// </summary>
  3539. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3540. {
  3541. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3542. // Remove the update packet from the list of packets waiting for acknowledgement
  3543. // because we are requeuing the list of updates. They will be resent in new packets
  3544. // with the most recent state and priority.
  3545. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3546. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3547. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3548. // We're not going to worry about interlock yet since its not currently critical that this total count
  3549. // is 100% correct
  3550. m_udpServer.PacketsResentCount++;
  3551. foreach (EntityUpdate update in updates)
  3552. ResendPrimUpdate(update);
  3553. }
  3554. private List<ObjectUpdatePacket.ObjectDataBlock> objectUpdateBlocks = new List<ObjectUpdatePacket.ObjectDataBlock>();
  3555. private List<ObjectUpdateCompressedPacket.ObjectDataBlock> compressedUpdateBlocks = new List<ObjectUpdateCompressedPacket.ObjectDataBlock>();
  3556. private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> terseUpdateBlocks = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  3557. private List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> terseAgentUpdateBlocks = new List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  3558. private void ProcessEntityUpdates(int maxUpdatesBytes)
  3559. {
  3560. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3561. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3562. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3563. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3564. // Check to see if this is a flush
  3565. if (maxUpdatesBytes <= 0)
  3566. {
  3567. maxUpdatesBytes = Int32.MaxValue;
  3568. }
  3569. EntityUpdate update;
  3570. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3571. bool doCulling = m_scene.ObjectsCullingByDistance;
  3572. float cullingrange = 64.0f;
  3573. HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
  3574. // Vector3 mycamera = Vector3.Zero;
  3575. Vector3 mypos = Vector3.Zero;
  3576. ScenePresence mysp = (ScenePresence)SceneAgent;
  3577. bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
  3578. // we should have a presence
  3579. if(mysp == null)
  3580. return;
  3581. if(doCulling)
  3582. {
  3583. cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
  3584. // mycamera = mysp.CameraPosition;
  3585. mypos = mysp.AbsolutePosition;
  3586. }
  3587. while (maxUpdatesBytes > 0)
  3588. {
  3589. lock (m_entityUpdates.SyncRoot)
  3590. {
  3591. if(orderedDequeue)
  3592. {
  3593. if (!m_entityUpdates.TryOrderedDequeue(out update, out timeinqueue))
  3594. break;
  3595. }
  3596. else
  3597. {
  3598. if (!m_entityUpdates.TryDequeue(out update, out timeinqueue))
  3599. break;
  3600. }
  3601. }
  3602. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3603. if(updateFlags.HasFlag(PrimUpdateFlags.Kill))
  3604. {
  3605. m_killRecord.Add(update.Entity.LocalId);
  3606. maxUpdatesBytes -= 30;
  3607. continue;
  3608. }
  3609. if (update.Entity is SceneObjectPart)
  3610. {
  3611. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3612. SceneObjectGroup grp = part.ParentGroup;
  3613. if (grp.inTransit && !update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
  3614. continue;
  3615. /* debug
  3616. if (update.Flags.HasFlag(PrimUpdateFlags.SendInTransit))
  3617. {
  3618. }
  3619. */
  3620. if (grp.IsDeleted)
  3621. {
  3622. // Don't send updates for objects that have been marked deleted.
  3623. // Instead send another kill object, because the first one may have gotten
  3624. // into a race condition
  3625. if (part == grp.RootPart && !m_killRecord.Contains(grp.LocalId))
  3626. {
  3627. m_killRecord.Add(grp.LocalId);
  3628. maxUpdatesBytes -= 30;
  3629. }
  3630. continue;
  3631. }
  3632. if (grp.IsAttachment)
  3633. { // Someone else's HUD, why are we getting these?
  3634. if (grp.OwnerID != AgentId && grp.HasPrivateAttachmentPoint)
  3635. continue;
  3636. ScenePresence sp;
  3637. // Owner is not in the sim, don't update it to
  3638. // anyone
  3639. if (!m_scene.TryGetScenePresence(part.OwnerID, out sp))
  3640. continue;
  3641. List<SceneObjectGroup> atts = sp.GetAttachments();
  3642. bool found = false;
  3643. foreach (SceneObjectGroup att in atts)
  3644. {
  3645. if (att == grp)
  3646. {
  3647. found = true;
  3648. break;
  3649. }
  3650. }
  3651. // It's an attachment of a valid avatar, but
  3652. // doesn't seem to be attached, skip
  3653. if (!found)
  3654. continue;
  3655. // On vehicle crossing, the attachments are received
  3656. // while the avatar is still a child. Don't send
  3657. // updates here because the LocalId has not yet
  3658. // been updated and the viewer will derender the
  3659. // attachments until the avatar becomes root.
  3660. if (sp.IsChildAgent)
  3661. continue;
  3662. }
  3663. if (grp.IsAttachment && m_disableFacelights)
  3664. {
  3665. if (grp.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3666. grp.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3667. {
  3668. part.Shape.LightEntry = false;
  3669. }
  3670. }
  3671. if(doCulling && !grp.IsAttachment)
  3672. {
  3673. if(GroupsNeedFullUpdate.Contains(grp))
  3674. continue;
  3675. bool inview = false;
  3676. lock(GroupsInView)
  3677. inview = GroupsInView.Contains(grp);
  3678. if(!inview)
  3679. {
  3680. float bradius = grp.GetBoundsRadius();
  3681. Vector3 partpos = grp.AbsolutePosition + grp.getBoundsCenter();
  3682. // float dcam = (partpos - mycamera).LengthSquared();
  3683. float dpos = (partpos - mypos).LengthSquared();
  3684. // if(dcam < dpos)
  3685. // dpos = dcam;
  3686. dpos = (float)Math.Sqrt(dpos) - bradius;
  3687. if(dpos > cullingrange)
  3688. continue;
  3689. GroupsNeedFullUpdate.Add(grp);
  3690. continue;
  3691. }
  3692. }
  3693. }
  3694. else if (update.Entity is ScenePresence)
  3695. {
  3696. ScenePresence presence = (ScenePresence)update.Entity;
  3697. if (presence.IsDeleted)
  3698. continue;
  3699. // If ParentUUID is not UUID.Zero and ParentID is 0, this
  3700. // avatar is in the process of crossing regions while
  3701. // sat on an object. In this state, we don't want any
  3702. // updates because they will visually orbit the avatar.
  3703. // Update will be forced once crossing is completed anyway.
  3704. if (presence.ParentUUID != UUID.Zero && presence.ParentID == 0)
  3705. continue;
  3706. }
  3707. #region UpdateFlags to packet type conversion
  3708. bool canUseCompressed = true;
  3709. bool canUseImproved = true;
  3710. // Compressed object updates only make sense for LL primitives
  3711. if (!(update.Entity is SceneObjectPart))
  3712. {
  3713. canUseCompressed = false;
  3714. }
  3715. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3716. {
  3717. canUseCompressed = false;
  3718. canUseImproved = false;
  3719. }
  3720. else
  3721. {
  3722. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3723. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3724. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3725. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3726. {
  3727. canUseCompressed = false;
  3728. }
  3729. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3730. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3731. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3732. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3733. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3734. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3735. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3736. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3737. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3738. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3739. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3740. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3741. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3742. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3743. {
  3744. canUseImproved = false;
  3745. }
  3746. }
  3747. #endregion UpdateFlags to packet type conversion
  3748. #region Block Construction
  3749. // TODO: Remove this once we can build compressed updates
  3750. canUseCompressed = false;
  3751. if (!canUseImproved && !canUseCompressed)
  3752. {
  3753. ObjectUpdatePacket.ObjectDataBlock ablock;
  3754. if (update.Entity is ScenePresence)
  3755. ablock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3756. else
  3757. ablock = CreatePrimUpdateBlock((SceneObjectPart)update.Entity, mysp);
  3758. objectUpdateBlocks.Add(ablock);
  3759. objectUpdates.Value.Add(update);
  3760. maxUpdatesBytes -= ablock.Length;
  3761. }
  3762. else if (!canUseImproved)
  3763. {
  3764. ObjectUpdateCompressedPacket.ObjectDataBlock ablock =
  3765. CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags);
  3766. compressedUpdateBlocks.Add(ablock);
  3767. compressedUpdates.Value.Add(update);
  3768. maxUpdatesBytes -= ablock.Length;
  3769. }
  3770. else
  3771. {
  3772. ImprovedTerseObjectUpdatePacket.ObjectDataBlock ablock;
  3773. if (update.Entity is ScenePresence)
  3774. {
  3775. // ALL presence updates go into a special list
  3776. ablock = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3777. terseAgentUpdateBlocks.Add(ablock);
  3778. terseAgentUpdates.Value.Add(update);
  3779. }
  3780. else
  3781. {
  3782. // Everything else goes here
  3783. ablock = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3784. terseUpdateBlocks.Add(ablock);
  3785. terseUpdates.Value.Add(update);
  3786. }
  3787. maxUpdatesBytes -= ablock.Length;
  3788. }
  3789. #endregion Block Construction
  3790. }
  3791. #region Packet Sending
  3792. ushort timeDilation;
  3793. if(!IsActive)
  3794. return;
  3795. timeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
  3796. if (terseAgentUpdateBlocks.Count > 0)
  3797. {
  3798. ImprovedTerseObjectUpdatePacket packet
  3799. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3800. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3801. packet.RegionData.TimeDilation = timeDilation;
  3802. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[terseAgentUpdateBlocks.Count];
  3803. for (int i = 0; i < terseAgentUpdateBlocks.Count; i++)
  3804. packet.ObjectData[i] = terseAgentUpdateBlocks[i];
  3805. terseAgentUpdateBlocks.Clear();
  3806. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3807. }
  3808. if (objectUpdateBlocks.Count > 0)
  3809. {
  3810. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3811. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3812. packet.RegionData.TimeDilation = timeDilation;
  3813. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[objectUpdateBlocks.Count];
  3814. for (int i = 0; i < objectUpdateBlocks.Count; i++)
  3815. packet.ObjectData[i] = objectUpdateBlocks[i];
  3816. objectUpdateBlocks.Clear();
  3817. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3818. }
  3819. if (compressedUpdateBlocks.Count > 0)
  3820. {
  3821. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3822. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3823. packet.RegionData.TimeDilation = timeDilation;
  3824. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[compressedUpdateBlocks.Count];
  3825. for (int i = 0; i < compressedUpdateBlocks.Count; i++)
  3826. packet.ObjectData[i] = compressedUpdateBlocks[i];
  3827. compressedUpdateBlocks.Clear();
  3828. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3829. }
  3830. if (terseUpdateBlocks.Count > 0)
  3831. {
  3832. ImprovedTerseObjectUpdatePacket packet
  3833. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3834. PacketType.ImprovedTerseObjectUpdate);
  3835. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3836. packet.RegionData.TimeDilation = timeDilation;
  3837. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[terseUpdateBlocks.Count];
  3838. for (int i = 0; i < terseUpdateBlocks.Count; i++)
  3839. packet.ObjectData[i] = terseUpdateBlocks[i];
  3840. terseUpdateBlocks.Clear();
  3841. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3842. }
  3843. #endregion Packet Sending
  3844. #region Handle deleted objects
  3845. if (m_killRecord.Count > 0)
  3846. {
  3847. SendKillObject(m_killRecord);
  3848. m_killRecord.Clear();
  3849. }
  3850. if(GroupsNeedFullUpdate.Count > 0)
  3851. {
  3852. foreach(SceneObjectGroup grp in GroupsNeedFullUpdate)
  3853. {
  3854. foreach(SceneObjectPart p in grp.Parts)
  3855. SendEntityUpdate(p,PrimUpdateFlags.CancelKill);
  3856. lock(GroupsInView)
  3857. GroupsInView.Add(grp);
  3858. }
  3859. }
  3860. #endregion
  3861. }
  3862. // hack.. dont use
  3863. /*
  3864. public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
  3865. {
  3866. if (ent is SceneObjectPart)
  3867. {
  3868. SceneObjectPart part = (SceneObjectPart)ent;
  3869. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3870. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3871. packet.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
  3872. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3873. ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, mysp);
  3874. if (parentID.HasValue)
  3875. {
  3876. blk.ParentID = parentID.Value;
  3877. }
  3878. packet.ObjectData[0] = blk;
  3879. OutPacket(packet, ThrottleOutPacketType.Task, true);
  3880. }
  3881. // m_log.DebugFormat(
  3882. // "[LLCLIENTVIEW]: Sent {0} updates in ProcessEntityUpdates() for {1} {2} in {3}",
  3883. // updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name);
  3884. //
  3885. }
  3886. */
  3887. public void ReprioritizeUpdates()
  3888. {
  3889. lock (m_entityUpdates.SyncRoot)
  3890. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3891. CheckGroupsInView();
  3892. }
  3893. private bool CheckGroupsInViewBusy = false;
  3894. public void CheckGroupsInView()
  3895. {
  3896. bool doCulling = m_scene.ObjectsCullingByDistance;
  3897. if(!doCulling)
  3898. return;
  3899. if(CheckGroupsInViewBusy)
  3900. return;
  3901. CheckGroupsInViewBusy = true;
  3902. float cullingrange = 64.0f;
  3903. // Vector3 mycamera = Vector3.Zero;
  3904. Vector3 mypos = Vector3.Zero;
  3905. ScenePresence mysp = (ScenePresence)SceneAgent;
  3906. if(mysp != null && !mysp.IsDeleted)
  3907. {
  3908. cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f;
  3909. // mycamera = mysp.CameraPosition;
  3910. mypos = mysp.AbsolutePosition;
  3911. }
  3912. else
  3913. {
  3914. CheckGroupsInViewBusy= false;
  3915. return;
  3916. }
  3917. HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>();
  3918. HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>();
  3919. List<SceneObjectGroup> kills = new List<SceneObjectGroup>();
  3920. EntityBase[] entities = m_scene.Entities.GetEntities();
  3921. foreach (EntityBase e in entities)
  3922. {
  3923. if(!IsActive)
  3924. return;
  3925. if (e != null && e is SceneObjectGroup)
  3926. {
  3927. SceneObjectGroup grp = (SceneObjectGroup)e;
  3928. if(grp.IsDeleted || grp.IsAttachment)
  3929. continue;
  3930. float bradius = grp.GetBoundsRadius();
  3931. Vector3 grppos = grp.AbsolutePosition + grp.getBoundsCenter();
  3932. // float dcam = (grppos - mycamera).LengthSquared();
  3933. float dpos = (grppos - mypos).LengthSquared();
  3934. // if(dcam < dpos)
  3935. // dpos = dcam;
  3936. dpos = (float)Math.Sqrt(dpos) - bradius;
  3937. bool inview;
  3938. lock(GroupsInView)
  3939. inview = GroupsInView.Contains(grp);
  3940. if(dpos > cullingrange)
  3941. {
  3942. if(inview)
  3943. kills.Add(grp);
  3944. }
  3945. else
  3946. {
  3947. if(!inview)
  3948. GroupsNeedFullUpdate.Add(grp);
  3949. NewGroupsInView.Add(grp);
  3950. }
  3951. }
  3952. }
  3953. lock(GroupsInView)
  3954. GroupsInView = NewGroupsInView;
  3955. if (kills.Count > 0)
  3956. {
  3957. List<uint> partIDs = new List<uint>();
  3958. foreach(SceneObjectGroup grp in kills)
  3959. {
  3960. SendEntityUpdate(grp.RootPart,PrimUpdateFlags.Kill);
  3961. foreach(SceneObjectPart p in grp.Parts)
  3962. {
  3963. if(p != grp.RootPart)
  3964. partIDs.Add(p.LocalId);
  3965. }
  3966. }
  3967. kills.Clear();
  3968. if(partIDs.Count > 0)
  3969. {
  3970. lock (m_entityProps.SyncRoot)
  3971. m_entityProps.Remove(partIDs);
  3972. lock (m_entityUpdates.SyncRoot)
  3973. m_entityUpdates.Remove(partIDs);
  3974. }
  3975. }
  3976. if(GroupsNeedFullUpdate.Count > 0)
  3977. {
  3978. foreach(SceneObjectGroup grp in GroupsNeedFullUpdate)
  3979. {
  3980. foreach(SceneObjectPart p in grp.Parts)
  3981. SendEntityUpdate(p,PrimUpdateFlags.CancelKill);
  3982. }
  3983. }
  3984. CheckGroupsInViewBusy = false;
  3985. }
  3986. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3987. {
  3988. if (entity != null)
  3989. {
  3990. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3991. return true;
  3992. }
  3993. return false;
  3994. }
  3995. public void FlushPrimUpdates()
  3996. {
  3997. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3998. while (m_entityUpdates.Count > 0)
  3999. ProcessEntityUpdates(-1);
  4000. }
  4001. #endregion Primitive Packet/Data Sending Methods
  4002. // These are used to implement an adaptive backoff in the number
  4003. // of updates converted to packets. Since we don't want packets
  4004. // to sit in the queue with old data, only convert enough updates
  4005. // to packets that can be sent in 200ms.
  4006. // private Int32 m_LastQueueFill = 0;
  4007. // private Int32 m_maxUpdates = 0;
  4008. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  4009. {
  4010. if(m_scene == null)
  4011. return;
  4012. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  4013. {
  4014. int maxUpdateBytes = m_udpClient.GetCatBytesCanSend(ThrottleOutPacketType.Task, 30);
  4015. if (m_entityUpdates.Count > 0)
  4016. ProcessEntityUpdates(maxUpdateBytes);
  4017. if (m_entityProps.Count > 0)
  4018. ProcessEntityPropertyRequests(maxUpdateBytes);
  4019. }
  4020. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  4021. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  4022. }
  4023. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  4024. {
  4025. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  4026. {
  4027. if (m_entityUpdates.Count > 0)
  4028. return true;
  4029. if (m_entityProps.Count > 0)
  4030. return true;
  4031. }
  4032. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  4033. {
  4034. if (ImageManager.HasUpdates())
  4035. return true;
  4036. }
  4037. return false;
  4038. }
  4039. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  4040. {
  4041. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  4042. newPack.AssetBlock.Type = AssetType;
  4043. newPack.AssetBlock.Success = Success;
  4044. newPack.AssetBlock.UUID = AssetFullID;
  4045. newPack.Header.Zerocoded = true;
  4046. OutPacket(newPack, ThrottleOutPacketType.Asset);
  4047. }
  4048. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  4049. {
  4050. RequestXferPacket newPack = new RequestXferPacket();
  4051. newPack.XferID.ID = XferID;
  4052. newPack.XferID.VFileType = AssetType;
  4053. newPack.XferID.VFileID = vFileID;
  4054. newPack.XferID.FilePath = FilePath;
  4055. newPack.XferID.Filename = FileName;
  4056. newPack.Header.Zerocoded = true;
  4057. OutPacket(newPack, ThrottleOutPacketType.Asset);
  4058. }
  4059. public void SendConfirmXfer(ulong xferID, uint PacketID)
  4060. {
  4061. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  4062. newPack.XferID.ID = xferID;
  4063. newPack.XferID.Packet = PacketID;
  4064. newPack.Header.Zerocoded = true;
  4065. OutPacket(newPack, ThrottleOutPacketType.Asset);
  4066. }
  4067. public void SendInitiateDownload(string simFileName, string clientFileName)
  4068. {
  4069. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  4070. newPack.AgentData.AgentID = AgentId;
  4071. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  4072. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  4073. OutPacket(newPack, ThrottleOutPacketType.Asset);
  4074. }
  4075. public void SendImageFirstPart(
  4076. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  4077. {
  4078. ImageDataPacket im = new ImageDataPacket();
  4079. im.Header.Reliable = false;
  4080. im.ImageID.Packets = numParts;
  4081. im.ImageID.ID = ImageUUID;
  4082. if (ImageSize > 0)
  4083. im.ImageID.Size = ImageSize;
  4084. im.ImageData.Data = ImageData;
  4085. im.ImageID.Codec = imageCodec;
  4086. im.Header.Zerocoded = true;
  4087. OutPacket(im, ThrottleOutPacketType.Texture);
  4088. }
  4089. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  4090. {
  4091. ImagePacketPacket im = new ImagePacketPacket();
  4092. im.Header.Reliable = false;
  4093. im.ImageID.Packet = partNumber;
  4094. im.ImageID.ID = imageUuid;
  4095. im.ImageData.Data = imageData;
  4096. OutPacket(im, ThrottleOutPacketType.Texture);
  4097. }
  4098. public void SendImageNotFound(UUID imageid)
  4099. {
  4100. ImageNotInDatabasePacket notFoundPacket
  4101. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  4102. notFoundPacket.ImageID.ID = imageid;
  4103. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  4104. }
  4105. public void SendShutdownConnectionNotice()
  4106. {
  4107. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  4108. }
  4109. public void SendSimStats(SimStats stats)
  4110. {
  4111. SimStatsPacket pack = new SimStatsPacket();
  4112. pack.Region = new SimStatsPacket.RegionBlock();
  4113. pack.Region.RegionX = stats.RegionX;
  4114. pack.Region.RegionY = stats.RegionY;
  4115. pack.Region.RegionFlags = stats.RegionFlags;
  4116. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  4117. //pack.Region = //stats.RegionBlock;
  4118. pack.Stat = stats.StatsBlock;
  4119. pack.Header.Reliable = false;
  4120. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  4121. OutPacket(pack, ThrottleOutPacketType.Task);
  4122. }
  4123. private class ObjectPropertyUpdate : EntityUpdate
  4124. {
  4125. internal bool SendFamilyProps;
  4126. internal bool SendObjectProps;
  4127. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  4128. : base(entity,(PrimUpdateFlags)flags)
  4129. {
  4130. SendFamilyProps = sendfam;
  4131. SendObjectProps = sendobj;
  4132. }
  4133. public void Update(ObjectPropertyUpdate update)
  4134. {
  4135. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  4136. SendObjectProps = SendObjectProps || update.SendObjectProps;
  4137. // other properties may need to be updated by base class
  4138. base.Update(update);
  4139. }
  4140. }
  4141. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  4142. {
  4143. uint priority = 0; // time based ordering only
  4144. lock (m_entityProps.SyncRoot)
  4145. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  4146. }
  4147. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  4148. {
  4149. uint priority = 0;
  4150. lock (m_entityProps.SyncRoot)
  4151. m_entityProps.Enqueue(priority, update);
  4152. }
  4153. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  4154. {
  4155. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  4156. // Remove the update packet from the list of packets waiting for acknowledgement
  4157. // because we are requeuing the list of updates. They will be resent in new packets
  4158. // with the most recent state.
  4159. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  4160. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  4161. Interlocked.Increment(ref m_udpClient.PacketsResent);
  4162. // We're not going to worry about interlock yet since its not currently critical that this total count
  4163. // is 100% correct
  4164. m_udpServer.PacketsResentCount++;
  4165. foreach (ObjectPropertyUpdate update in updates)
  4166. ResendPropertyUpdate(update);
  4167. }
  4168. public void SendObjectPropertiesReply(ISceneEntity entity)
  4169. {
  4170. uint priority = 0; // time based ordering only
  4171. lock (m_entityProps.SyncRoot)
  4172. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  4173. }
  4174. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> objectFamilyBlocks = new
  4175. List<ObjectPropertiesFamilyPacket.ObjectDataBlock>();
  4176. List<ObjectPropertiesPacket.ObjectDataBlock> objectPropertiesBlocks =
  4177. new List<ObjectPropertiesPacket.ObjectDataBlock>();
  4178. List<SceneObjectPart> needPhysics = new List<SceneObjectPart>();
  4179. private void ProcessEntityPropertyRequests(int maxUpdateBytes)
  4180. {
  4181. // OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  4182. // new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  4183. // OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  4184. // new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  4185. bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance;
  4186. EntityUpdate iupdate;
  4187. Int32 timeinqueue; // this is just debugging code & can be dropped later
  4188. while (maxUpdateBytes > 0)
  4189. {
  4190. lock (m_entityProps.SyncRoot)
  4191. {
  4192. if(orderedDequeue)
  4193. {
  4194. if (!m_entityProps.TryOrderedDequeue(out iupdate, out timeinqueue))
  4195. break;
  4196. }
  4197. else
  4198. {
  4199. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  4200. break;
  4201. }
  4202. }
  4203. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  4204. if (update.SendFamilyProps)
  4205. {
  4206. if (update.Entity is SceneObjectPart)
  4207. {
  4208. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  4209. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  4210. objectFamilyBlocks.Add(objPropDB);
  4211. // familyUpdates.Value.Add(update);
  4212. maxUpdateBytes -= objPropDB.Length;
  4213. }
  4214. }
  4215. if (update.SendObjectProps)
  4216. {
  4217. if (update.Entity is SceneObjectPart)
  4218. {
  4219. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  4220. needPhysics.Add(sop);
  4221. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  4222. objectPropertiesBlocks.Add(objPropDB);
  4223. // propertyUpdates.Value.Add(update);
  4224. maxUpdateBytes -= objPropDB.Length;
  4225. }
  4226. }
  4227. }
  4228. if (objectPropertiesBlocks.Count > 0)
  4229. {
  4230. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  4231. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[objectPropertiesBlocks.Count];
  4232. for (int i = 0; i < objectPropertiesBlocks.Count; i++)
  4233. packet.ObjectData[i] = objectPropertiesBlocks[i];
  4234. objectPropertiesBlocks.Clear();
  4235. packet.Header.Zerocoded = true;
  4236. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  4237. // of the object rather than the properties when the packet was created
  4238. // HACK : Remove intelligent resending until it's fixed in core
  4239. //OutPacket(packet, ThrottleOutPacketType.Task, true,
  4240. // delegate(OutgoingPacket oPacket)
  4241. // {
  4242. // ResendPropertyUpdates(propertyUpdates.Value, oPacket);
  4243. // });
  4244. OutPacket(packet, ThrottleOutPacketType.Task, true);
  4245. // pbcnt += blocks.Count;
  4246. // ppcnt++;
  4247. }
  4248. // Int32 fpcnt = 0;
  4249. // Int32 fbcnt = 0;
  4250. if (objectFamilyBlocks.Count > 0)
  4251. {
  4252. // one packet per object block... uggh...
  4253. for (int i = 0; i < objectFamilyBlocks.Count; i++)
  4254. {
  4255. ObjectPropertiesFamilyPacket packet =
  4256. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  4257. packet.ObjectData = objectFamilyBlocks[i];
  4258. packet.Header.Zerocoded = true;
  4259. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  4260. // of the object rather than the properties when the packet was created
  4261. // List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  4262. // updates.Add(familyUpdates.Value[i]);
  4263. // HACK : Remove intelligent resending until it's fixed in core
  4264. //OutPacket(packet, ThrottleOutPacketType.Task, true,
  4265. // delegate(OutgoingPacket oPacket)
  4266. // {
  4267. // ResendPropertyUpdates(updates, oPacket);
  4268. // });
  4269. OutPacket(packet, ThrottleOutPacketType.Task, true);
  4270. // fpcnt++;
  4271. // fbcnt++;
  4272. }
  4273. objectFamilyBlocks.Clear();
  4274. }
  4275. if(needPhysics.Count > 0)
  4276. {
  4277. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4278. if(eq != null)
  4279. {
  4280. OSDArray array = new OSDArray();
  4281. foreach(SceneObjectPart sop in needPhysics)
  4282. {
  4283. OSDMap physinfo = new OSDMap(6);
  4284. physinfo["LocalID"] = sop.LocalId;
  4285. physinfo["Density"] = sop.Density;
  4286. physinfo["Friction"] = sop.Friction;
  4287. physinfo["GravityMultiplier"] = sop.GravityModifier;
  4288. physinfo["Restitution"] = sop.Restitution;
  4289. physinfo["PhysicsShapeType"] = (int)sop.PhysicsShapeType;
  4290. array.Add(physinfo);
  4291. }
  4292. OSDMap llsdBody = new OSDMap(1);
  4293. llsdBody.Add("ObjectData", array);
  4294. eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId);
  4295. }
  4296. needPhysics.Clear();
  4297. }
  4298. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  4299. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  4300. }
  4301. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, PrimUpdateFlags requestFlags)
  4302. {
  4303. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  4304. block.RequestFlags = (uint)requestFlags;
  4305. block.ObjectID = sop.UUID;
  4306. if (sop.OwnerID == sop.GroupID)
  4307. block.OwnerID = UUID.Zero;
  4308. else
  4309. block.OwnerID = sop.OwnerID;
  4310. block.GroupID = sop.GroupID;
  4311. block.BaseMask = sop.BaseMask;
  4312. block.OwnerMask = sop.OwnerMask;
  4313. block.GroupMask = sop.GroupMask;
  4314. block.EveryoneMask = sop.EveryoneMask;
  4315. block.NextOwnerMask = sop.NextOwnerMask;
  4316. // TODO: More properties are needed in SceneObjectPart!
  4317. block.OwnershipCost = sop.OwnershipCost;
  4318. block.SaleType = sop.ObjectSaleType;
  4319. block.SalePrice = sop.SalePrice;
  4320. block.Category = sop.Category;
  4321. block.LastOwnerID = sop.LastOwnerID;
  4322. block.Name = Util.StringToBytes256(sop.Name);
  4323. block.Description = Util.StringToBytes256(sop.Description);
  4324. return block;
  4325. }
  4326. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  4327. {
  4328. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  4329. // TODO: don't create new blocks if recycling an old packet
  4330. ObjectPropertiesPacket.ObjectDataBlock block =
  4331. new ObjectPropertiesPacket.ObjectDataBlock();
  4332. block.ObjectID = sop.UUID;
  4333. block.Name = Util.StringToBytes256(sop.Name);
  4334. block.Description = Util.StringToBytes256(sop.Description);
  4335. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  4336. block.CreatorID = sop.CreatorID;
  4337. block.GroupID = sop.GroupID;
  4338. block.LastOwnerID = sop.LastOwnerID;
  4339. if (sop.OwnerID == sop.GroupID)
  4340. block.OwnerID = UUID.Zero;
  4341. else
  4342. block.OwnerID = sop.OwnerID;
  4343. block.ItemID = sop.FromUserInventoryItemID;
  4344. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  4345. block.FromTaskID = UUID.Zero; // ???
  4346. block.InventorySerial = (short)sop.InventorySerial;
  4347. SceneObjectPart root = sop.ParentGroup.RootPart;
  4348. block.TouchName = Util.StringToBytes256(root.TouchName);
  4349. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  4350. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  4351. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  4352. // using (MemoryStream memStream = new MemoryStream())
  4353. // {
  4354. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  4355. // {
  4356. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  4357. // {
  4358. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  4359. //
  4360. // UUID textureID;
  4361. //
  4362. // if (teFace != null)
  4363. // textureID = teFace.TextureID;
  4364. // else
  4365. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  4366. //
  4367. // binWriter.Write(textureID.GetBytes());
  4368. // }
  4369. //
  4370. // block.TextureID = memStream.ToArray();
  4371. // }
  4372. // }
  4373. block.TextureID = new byte[0]; // TextureID ???
  4374. block.SitName = Util.StringToBytes256(root.SitName);
  4375. block.OwnerMask = root.OwnerMask;
  4376. block.NextOwnerMask = root.NextOwnerMask;
  4377. block.GroupMask = root.GroupMask;
  4378. block.EveryoneMask = root.EveryoneMask;
  4379. block.BaseMask = root.BaseMask;
  4380. block.SaleType = root.ObjectSaleType;
  4381. block.SalePrice = root.SalePrice;
  4382. return block;
  4383. }
  4384. #region Estate Data Sending Methods
  4385. private static bool convertParamStringToBool(byte[] field)
  4386. {
  4387. string s = Utils.BytesToString(field);
  4388. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  4389. {
  4390. return true;
  4391. }
  4392. return false;
  4393. }
  4394. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  4395. {
  4396. int TotalnumberIDs = Data.Length;
  4397. int numberIDs;
  4398. int IDIndex = 0;
  4399. do
  4400. {
  4401. if(TotalnumberIDs > 63)
  4402. numberIDs = 63;
  4403. else
  4404. numberIDs = TotalnumberIDs;
  4405. TotalnumberIDs -= numberIDs;
  4406. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4407. packet.AgentData.TransactionID = UUID.Random();
  4408. packet.AgentData.AgentID = AgentId;
  4409. packet.AgentData.SessionID = SessionId;
  4410. packet.MethodData.Invoice = invoice;
  4411. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  4412. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + numberIDs];
  4413. for (int i = 0; i < (6 + numberIDs); i++)
  4414. {
  4415. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4416. }
  4417. returnblock[0].Parameter = Utils.StringToBytes(estateID.ToString());
  4418. returnblock[1].Parameter = Utils.StringToBytes(code.ToString());
  4419. if((code & 1) != 0) // allowagents
  4420. returnblock[2].Parameter = Utils.StringToBytes(numberIDs.ToString());
  4421. else
  4422. returnblock[2].Parameter = Utils.StringToBytes("0");
  4423. if((code & 2) != 0) // groups
  4424. returnblock[3].Parameter = Utils.StringToBytes(numberIDs.ToString());
  4425. else
  4426. returnblock[3].Parameter = Utils.StringToBytes("0");
  4427. if((code & 4) != 0) // bans
  4428. returnblock[4].Parameter = Utils.StringToBytes(numberIDs.ToString());
  4429. else
  4430. returnblock[4].Parameter = Utils.StringToBytes("0");
  4431. if((code & 8) != 0) // managers
  4432. returnblock[5].Parameter = Utils.StringToBytes(numberIDs.ToString());
  4433. else
  4434. returnblock[5].Parameter = Utils.StringToBytes("0");
  4435. int j = 6;
  4436. for (int i = 0; i < numberIDs; i++)
  4437. {
  4438. returnblock[j].Parameter = Data[IDIndex].GetBytes();
  4439. j++;
  4440. IDIndex++;
  4441. }
  4442. packet.ParamList = returnblock;
  4443. packet.Header.Reliable = true;
  4444. OutPacket(packet, ThrottleOutPacketType.Task);
  4445. } while (TotalnumberIDs > 0);
  4446. }
  4447. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  4448. {
  4449. List<UUID> BannedUsers = new List<UUID>();
  4450. for (int i = 0; i < bl.Length; i++)
  4451. {
  4452. if (bl[i] == null)
  4453. continue;
  4454. if (bl[i].BannedUserID == UUID.Zero)
  4455. continue;
  4456. BannedUsers.Add(bl[i].BannedUserID);
  4457. }
  4458. SendEstateList(invoice, 4, BannedUsers.ToArray(), estateID);
  4459. }
  4460. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4461. {
  4462. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4463. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4464. rinfopack.AgentData.AgentID = AgentId;
  4465. rinfopack.AgentData.SessionID = SessionId;
  4466. rinfoblk.BillableFactor = args.billableFactor;
  4467. rinfoblk.EstateID = args.estateID;
  4468. rinfoblk.MaxAgents = args.maxAgents;
  4469. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4470. rinfoblk.ParentEstateID = args.parentEstateID;
  4471. rinfoblk.PricePerMeter = args.pricePerMeter;
  4472. rinfoblk.RedirectGridX = args.redirectGridX;
  4473. rinfoblk.RedirectGridY = args.redirectGridY;
  4474. rinfoblk.RegionFlags = args.regionFlags;
  4475. rinfoblk.SimAccess = args.simAccess;
  4476. rinfoblk.SunHour = args.sunHour;
  4477. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4478. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4479. rinfoblk.UseEstateSun = args.useEstateSun;
  4480. rinfoblk.WaterHeight = args.waterHeight;
  4481. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4482. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4483. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4484. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4485. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4486. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4487. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4488. rinfopack.HasVariableBlocks = true;
  4489. rinfopack.RegionInfo = rinfoblk;
  4490. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4491. rinfopack.AgentData.AgentID = AgentId;
  4492. rinfopack.AgentData.SessionID = SessionId;
  4493. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4494. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4495. }
  4496. public void SendEstateCovenantInformation(UUID covenant)
  4497. {
  4498. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4499. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4500. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4501. edata.CovenantID = covenant;
  4502. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4503. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4504. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4505. einfopack.Data = edata;
  4506. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4507. }
  4508. public void SendDetailedEstateData(
  4509. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4510. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4511. {
  4512. // m_log.DebugFormat(
  4513. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4514. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4515. packet.MethodData.Invoice = invoice;
  4516. packet.AgentData.TransactionID = UUID.Random();
  4517. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4518. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4519. for (int i = 0; i < 10; i++)
  4520. {
  4521. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4522. }
  4523. //Sending Estate Settings
  4524. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4525. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4526. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4527. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4528. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4529. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4530. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4531. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4532. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4533. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4534. packet.ParamList = returnblock;
  4535. packet.Header.Reliable = false;
  4536. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4537. OutPacket(packet, ThrottleOutPacketType.Task);
  4538. }
  4539. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4540. {
  4541. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4542. packet.TelehubBlock.ObjectID = ObjectID;
  4543. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4544. packet.TelehubBlock.TelehubPos = ObjectPos;
  4545. packet.TelehubBlock.TelehubRot = ObjectRot;
  4546. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4547. for (int n = 0; n < SpawnPoint.Count; n++)
  4548. {
  4549. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4550. }
  4551. OutPacket(packet, ThrottleOutPacketType.Task);
  4552. }
  4553. #endregion
  4554. #region Land Data Sending Methods
  4555. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4556. {
  4557. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4558. packet.ParcelData.Data = data;
  4559. packet.ParcelData.SequenceID = sequence_id;
  4560. packet.Header.Zerocoded = true;
  4561. // OutPacket(packet, ThrottleOutPacketType.Task);
  4562. OutPacket(packet, ThrottleOutPacketType.Land);
  4563. }
  4564. public void SendLandProperties(
  4565. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4566. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4567. {
  4568. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4569. LandData landData = lo.LandData;
  4570. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4571. updateMessage.AABBMax = landData.AABBMax;
  4572. updateMessage.AABBMin = landData.AABBMin;
  4573. updateMessage.Area = landData.Area;
  4574. updateMessage.AuctionID = landData.AuctionID;
  4575. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4576. updateMessage.Bitmap = landData.Bitmap;
  4577. updateMessage.Desc = landData.Description;
  4578. updateMessage.Category = landData.Category;
  4579. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4580. updateMessage.ClaimPrice = landData.ClaimPrice;
  4581. updateMessage.GroupID = landData.GroupID;
  4582. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4583. updateMessage.LandingType = (LandingType) landData.LandingType;
  4584. updateMessage.LocalID = landData.LocalID;
  4585. if (landData.Area > 0)
  4586. {
  4587. updateMessage.MaxPrims = parcelObjectCapacity;
  4588. }
  4589. else
  4590. {
  4591. updateMessage.MaxPrims = 0;
  4592. }
  4593. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4594. updateMessage.MediaID = landData.MediaID;
  4595. updateMessage.MediaURL = landData.MediaURL;
  4596. updateMessage.MusicURL = landData.MusicURL;
  4597. updateMessage.Name = landData.Name;
  4598. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4599. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4600. updateMessage.OwnerID = landData.OwnerID;
  4601. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4602. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4603. updateMessage.PassHours = landData.PassHours;
  4604. updateMessage.PassPrice = landData.PassPrice;
  4605. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4606. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4607. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4608. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4609. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4610. updateMessage.RentPrice = 0;
  4611. updateMessage.RequestResult = (ParcelResult) request_result;
  4612. updateMessage.SalePrice = landData.SalePrice;
  4613. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4614. updateMessage.SequenceID = sequence_id;
  4615. if (landData.SimwideArea > 0)
  4616. {
  4617. updateMessage.SimWideMaxPrims = lo.GetSimulatorMaxPrimCount();
  4618. }
  4619. else
  4620. {
  4621. updateMessage.SimWideMaxPrims = 0;
  4622. }
  4623. updateMessage.SnapSelection = snap_selection;
  4624. updateMessage.SnapshotID = landData.SnapshotID;
  4625. updateMessage.Status = (ParcelStatus) landData.Status;
  4626. updateMessage.UserLocation = landData.UserLocation;
  4627. updateMessage.UserLookAt = landData.UserLookAt;
  4628. updateMessage.MediaType = landData.MediaType;
  4629. updateMessage.MediaDesc = landData.MediaDescription;
  4630. updateMessage.MediaWidth = landData.MediaWidth;
  4631. updateMessage.MediaHeight = landData.MediaHeight;
  4632. updateMessage.MediaLoop = landData.MediaLoop;
  4633. updateMessage.ObscureMusic = landData.ObscureMusic;
  4634. updateMessage.ObscureMedia = landData.ObscureMedia;
  4635. updateMessage.SeeAVs = landData.SeeAVs;
  4636. updateMessage.AnyAVSounds = landData.AnyAVSounds;
  4637. updateMessage.GroupAVSounds = landData.GroupAVSounds;
  4638. IPrimCounts pc = lo.PrimCounts;
  4639. updateMessage.OwnerPrims = pc.Owner;
  4640. updateMessage.GroupPrims = pc.Group;
  4641. updateMessage.OtherPrims = pc.Others;
  4642. updateMessage.SelectedPrims = pc.Selected;
  4643. updateMessage.TotalPrims = pc.Total;
  4644. updateMessage.SimWideTotalPrims = pc.Simulator;
  4645. //m_log.DebugFormat("[YYY]: SimWideMaxPrims={0} OwnerPrims={1} TotalPrims={2} SimWideTotalPrims={3} MaxPrims={4}",
  4646. // updateMessage.SimWideMaxPrims, updateMessage.OwnerPrims, updateMessage.TotalPrims, updateMessage.SimWideTotalPrims, updateMessage.MaxPrims);
  4647. try
  4648. {
  4649. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4650. if (eq != null)
  4651. {
  4652. eq.ParcelProperties(updateMessage, this.AgentId);
  4653. }
  4654. else
  4655. {
  4656. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4657. }
  4658. }
  4659. catch (Exception ex)
  4660. {
  4661. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4662. }
  4663. }
  4664. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4665. {
  4666. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4667. replyPacket.Data.AgentID = AgentId;
  4668. replyPacket.Data.Flags = accessFlag;
  4669. replyPacket.Data.LocalID = localLandID;
  4670. replyPacket.Data.SequenceID = 0;
  4671. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4672. foreach (LandAccessEntry entry in accessList)
  4673. {
  4674. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4675. block.Flags = accessFlag;
  4676. block.ID = entry.AgentID;
  4677. block.Time = entry.Expires;
  4678. list.Add(block);
  4679. }
  4680. replyPacket.List = list.ToArray();
  4681. replyPacket.Header.Zerocoded = true;
  4682. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4683. }
  4684. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4685. {
  4686. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4687. bool firstCall = true;
  4688. const int MAX_OBJECTS_PER_PACKET = 251;
  4689. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4690. ForceObjectSelectPacket.DataBlock[] data;
  4691. while (ObjectIDs.Count > 0)
  4692. {
  4693. if (firstCall)
  4694. {
  4695. pack._Header.ResetList = true;
  4696. firstCall = false;
  4697. }
  4698. else
  4699. {
  4700. pack._Header.ResetList = false;
  4701. }
  4702. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4703. {
  4704. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4705. }
  4706. else
  4707. {
  4708. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4709. }
  4710. int i;
  4711. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4712. {
  4713. data[i] = new ForceObjectSelectPacket.DataBlock();
  4714. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4715. ObjectIDs.RemoveAt(0);
  4716. }
  4717. pack.Data = data;
  4718. pack.Header.Zerocoded = true;
  4719. OutPacket(pack, ThrottleOutPacketType.Task);
  4720. }
  4721. }
  4722. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4723. {
  4724. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4725. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4726. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4727. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4728. OutPacket(cpack, ThrottleOutPacketType.Task);
  4729. }
  4730. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4731. {
  4732. int notifyCount = ownersAndCount.Count;
  4733. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4734. if (notifyCount > 0)
  4735. {
  4736. // if (notifyCount > 32)
  4737. // {
  4738. // m_log.InfoFormat(
  4739. // "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4740. // + " - a developer might want to investigate whether this is a hard limit", 32);
  4741. //
  4742. // notifyCount = 32;
  4743. // }
  4744. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4745. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4746. int num = 0;
  4747. foreach (UUID owner in ownersAndCount.Keys)
  4748. {
  4749. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4750. dataBlock[num].Count = ownersAndCount[owner];
  4751. if (land.GroupID == owner || groups.Contains(owner))
  4752. dataBlock[num].IsGroupOwned = true;
  4753. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4754. dataBlock[num].OwnerID = owner;
  4755. num++;
  4756. if (num >= notifyCount)
  4757. {
  4758. break;
  4759. }
  4760. }
  4761. pack.Data = dataBlock;
  4762. }
  4763. else
  4764. {
  4765. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4766. }
  4767. pack.Header.Zerocoded = true;
  4768. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4769. }
  4770. #endregion
  4771. #region Helper Methods
  4772. private void ClampVectorForUint(ref Vector3 v, float max)
  4773. {
  4774. float a,b;
  4775. a = Math.Abs(v.X);
  4776. b = Math.Abs(v.Y);
  4777. if(b > a)
  4778. a = b;
  4779. b= Math.Abs(v.Z);
  4780. if(b > a)
  4781. a = b;
  4782. if (a > max)
  4783. {
  4784. a = max / a;
  4785. v.X *= a;
  4786. v.Y *= a;
  4787. v.Z *= a;
  4788. }
  4789. }
  4790. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4791. {
  4792. #region ScenePresence/SOP Handling
  4793. bool avatar = (entity is ScenePresence);
  4794. uint localID = entity.LocalId;
  4795. uint attachPoint;
  4796. Vector4 collisionPlane;
  4797. Vector3 position, velocity, acceleration, angularVelocity;
  4798. Quaternion rotation;
  4799. byte[] textureEntry;
  4800. if (avatar)
  4801. {
  4802. ScenePresence presence = (ScenePresence)entity;
  4803. position = presence.OffsetPosition;
  4804. velocity = presence.Velocity;
  4805. acceleration = Vector3.Zero;
  4806. rotation = presence.Rotation;
  4807. // tpvs can only see rotations around Z in some cases
  4808. if(!presence.Flying && !presence.IsSatOnObject)
  4809. {
  4810. rotation.X = 0f;
  4811. rotation.Y = 0f;
  4812. rotation.Normalize();
  4813. }
  4814. angularVelocity = presence.AngularVelocity;
  4815. // m_log.DebugFormat(
  4816. // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
  4817. attachPoint = presence.State;
  4818. collisionPlane = presence.CollisionPlane;
  4819. if (sendTexture)
  4820. {
  4821. textureEntry = presence.Appearance.Texture.GetBytes();
  4822. }
  4823. else
  4824. textureEntry = null;
  4825. }
  4826. else
  4827. {
  4828. SceneObjectPart part = (SceneObjectPart)entity;
  4829. attachPoint = part.ParentGroup.AttachmentPoint;
  4830. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4831. // m_log.DebugFormat(
  4832. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4833. // attachPoint, part.Name, part.LocalId, Name);
  4834. collisionPlane = Vector4.Zero;
  4835. position = part.RelativePosition;
  4836. velocity = part.Velocity;
  4837. acceleration = part.Acceleration;
  4838. angularVelocity = part.AngularVelocity;
  4839. rotation = part.RotationOffset;
  4840. if (sendTexture)
  4841. textureEntry = part.Shape.TextureEntry;
  4842. else
  4843. textureEntry = null;
  4844. }
  4845. #endregion ScenePresence/SOP Handling
  4846. int pos = 0;
  4847. byte[] data = new byte[(avatar ? 60 : 44)];
  4848. // LocalID
  4849. Utils.UIntToBytes(localID, data, pos);
  4850. pos += 4;
  4851. // Avatar/CollisionPlane
  4852. data[pos++] = (byte) attachPoint;
  4853. if (avatar)
  4854. {
  4855. data[pos++] = 1;
  4856. if (collisionPlane == Vector4.Zero)
  4857. collisionPlane = Vector4.UnitW;
  4858. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4859. collisionPlane.ToBytes(data, pos);
  4860. pos += 16;
  4861. }
  4862. else
  4863. {
  4864. ++pos;
  4865. }
  4866. // Position
  4867. position.ToBytes(data, pos);
  4868. pos += 12;
  4869. // Velocity
  4870. ClampVectorForUint(ref velocity, 128f);
  4871. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4872. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4873. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4874. // Acceleration
  4875. ClampVectorForUint(ref acceleration, 64f);
  4876. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4877. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4878. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4879. // Rotation
  4880. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4881. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4882. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4883. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4884. // Angular Velocity
  4885. ClampVectorForUint(ref angularVelocity, 64f);
  4886. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4887. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4888. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4889. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4890. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4891. block.Data = data;
  4892. if (textureEntry != null && textureEntry.Length > 0)
  4893. {
  4894. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4895. // Texture Length
  4896. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4897. // Texture
  4898. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4899. block.TextureEntry = teBytesFinal;
  4900. }
  4901. else
  4902. {
  4903. block.TextureEntry = Utils.EmptyBytes;
  4904. }
  4905. return block;
  4906. }
  4907. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4908. {
  4909. Vector3 offsetPosition = data.OffsetPosition;
  4910. Quaternion rotation = data.Rotation;
  4911. uint parentID = data.ParentID;
  4912. // m_log.DebugFormat(
  4913. // "[LLCLIENTVIEW]: Sending full update to {0} with pos {1}, vel {2} in {3}", Name, data.OffsetPosition, data.Velocity, m_scene.Name);
  4914. byte[] objectData = new byte[76];
  4915. Vector3 velocity = new Vector3(0, 0, 0);
  4916. Vector3 acceleration = new Vector3(0, 0, 0);
  4917. // tpvs can only see rotations around Z in some cases
  4918. if(!data.Flying && !data.IsSatOnObject)
  4919. {
  4920. rotation.X = 0f;
  4921. rotation.Y = 0f;
  4922. }
  4923. rotation.Normalize();
  4924. data.CollisionPlane.ToBytes(objectData, 0);
  4925. offsetPosition.ToBytes(objectData, 16);
  4926. velocity.ToBytes(objectData, 28);
  4927. acceleration.ToBytes(objectData, 40);
  4928. rotation.ToBytes(objectData, 52);
  4929. data.AngularVelocity.ToBytes(objectData, 64);
  4930. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4931. update.Data = Utils.EmptyBytes;
  4932. update.ExtraParams = new byte[1];
  4933. update.FullID = data.UUID;
  4934. update.ID = data.LocalId;
  4935. update.Material = (byte)Material.Flesh;
  4936. update.MediaURL = Utils.EmptyBytes;
  4937. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4938. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4939. update.ObjectData = objectData;
  4940. SceneObjectPart parentPart = data.ParentPart;
  4941. if (parentPart != null)
  4942. update.ParentID = parentPart.ParentGroup.LocalId;
  4943. else
  4944. update.ParentID = 0;
  4945. update.PathCurve = 16;
  4946. update.PathScaleX = 100;
  4947. update.PathScaleY = 100;
  4948. update.PCode = (byte)PCode.Avatar;
  4949. update.ProfileCurve = 1;
  4950. update.PSBlock = Utils.EmptyBytes;
  4951. update.Scale = data.Appearance.AvatarSize;
  4952. // update.Scale.Z -= 0.2f;
  4953. update.Text = Utils.EmptyBytes;
  4954. update.TextColor = new byte[4];
  4955. // Don't send texture anim for avatars - this has no meaning for them.
  4956. update.TextureAnim = Utils.EmptyBytes;
  4957. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4958. update.TextureEntry = Utils.EmptyBytes;
  4959. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4960. /* all this flags seem related to prims and not avatars. This allow for wrong viewer side move of a avatar in prim edition mode (anv mantis 854)
  4961. update.UpdateFlags = (uint)(
  4962. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4963. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4964. PrimFlags.ObjectOwnerModify);
  4965. */
  4966. update.UpdateFlags = 0;
  4967. return update;
  4968. }
  4969. // protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4970. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart part, ScenePresence sp)
  4971. {
  4972. byte[] objectData = new byte[60];
  4973. part.RelativePosition.ToBytes(objectData, 0);
  4974. part.Velocity.ToBytes(objectData, 12);
  4975. part.Acceleration.ToBytes(objectData, 24);
  4976. Quaternion rotation = part.RotationOffset;
  4977. rotation.Normalize();
  4978. rotation.ToBytes(objectData, 36);
  4979. part.AngularVelocity.ToBytes(objectData, 48);
  4980. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4981. update.ClickAction = (byte)part.ClickAction;
  4982. update.CRC = 0;
  4983. update.ExtraParams = part.Shape.ExtraParams ?? Utils.EmptyBytes;
  4984. update.FullID = part.UUID;
  4985. update.ID = part.LocalId;
  4986. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4987. //update.JointPivot = Vector3.Zero;
  4988. //update.JointType = 0;
  4989. update.Material = part.Material;
  4990. /*
  4991. if (data.ParentGroup.IsAttachment)
  4992. {
  4993. update.NameValue
  4994. = Util.StringToBytes256(
  4995. string.Format("AttachItemID STRING RW SV {0}", data.ParentGroup.FromItemID));
  4996. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4997. // m_log.DebugFormat(
  4998. // "[LLCLIENTVIEW]: Sending NameValue {0} for {1} {2} to {3}",
  4999. // Util.UTF8.GetString(update.NameValue), data.Name, data.LocalId, Name);
  5000. //
  5001. // m_log.DebugFormat(
  5002. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  5003. // update.State, data.Name, data.LocalId, Name);
  5004. }
  5005. else
  5006. {
  5007. update.NameValue = Utils.EmptyBytes;
  5008. // The root part state is the canonical state for all parts of the object. The other part states in the
  5009. // case for attachments may contain conflicting values that can end up crashing the viewer.
  5010. update.State = data.ParentGroup.RootPart.Shape.State;
  5011. }
  5012. */
  5013. if (part.ParentGroup.IsAttachment)
  5014. {
  5015. if (part.IsRoot)
  5016. {
  5017. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + part.ParentGroup.FromItemID);
  5018. }
  5019. else
  5020. update.NameValue = Utils.EmptyBytes;
  5021. int st = (int)part.ParentGroup.AttachmentPoint;
  5022. update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
  5023. }
  5024. else
  5025. {
  5026. update.NameValue = Utils.EmptyBytes;
  5027. update.State = part.Shape.State; // not sure about this
  5028. }
  5029. update.ObjectData = objectData;
  5030. update.ParentID = part.ParentID;
  5031. update.PathBegin = part.Shape.PathBegin;
  5032. update.PathCurve = part.Shape.PathCurve;
  5033. update.PathEnd = part.Shape.PathEnd;
  5034. update.PathRadiusOffset = part.Shape.PathRadiusOffset;
  5035. update.PathRevolutions = part.Shape.PathRevolutions;
  5036. update.PathScaleX = part.Shape.PathScaleX;
  5037. update.PathScaleY = part.Shape.PathScaleY;
  5038. update.PathShearX = part.Shape.PathShearX;
  5039. update.PathShearY = part.Shape.PathShearY;
  5040. update.PathSkew = part.Shape.PathSkew;
  5041. update.PathTaperX = part.Shape.PathTaperX;
  5042. update.PathTaperY = part.Shape.PathTaperY;
  5043. update.PathTwist = part.Shape.PathTwist;
  5044. update.PathTwistBegin = part.Shape.PathTwistBegin;
  5045. update.PCode = part.Shape.PCode;
  5046. update.ProfileBegin = part.Shape.ProfileBegin;
  5047. update.ProfileCurve = part.Shape.ProfileCurve;
  5048. ushort profileBegin = part.Shape.ProfileBegin;
  5049. ushort profileHollow = part.Shape.ProfileHollow;
  5050. if(part.Shape.SculptType == (byte)SculptType.Mesh) // filter out hack
  5051. {
  5052. update.ProfileCurve = (byte)(part.Shape.ProfileCurve & 0x0f);
  5053. // fix old values that confused viewers
  5054. if(profileBegin == 1)
  5055. profileBegin = 9375;
  5056. if(profileHollow == 1)
  5057. profileHollow = 27500;
  5058. // fix torus hole size Y that also confuse some viewers
  5059. if(update.ProfileCurve == (byte)ProfileShape.Circle && update.PathScaleY < 150)
  5060. update.PathScaleY = 150;
  5061. }
  5062. else
  5063. {
  5064. update.ProfileCurve = part.Shape.ProfileCurve;
  5065. }
  5066. update.ProfileHollow = profileHollow;
  5067. update.ProfileBegin = profileBegin;
  5068. update.ProfileEnd = part.Shape.ProfileEnd;
  5069. update.PSBlock = part.ParticleSystem ?? Utils.EmptyBytes;
  5070. update.TextColor = part.GetTextColor().GetBytes(false);
  5071. update.TextureAnim = part.TextureAnimation ?? Utils.EmptyBytes;
  5072. update.TextureEntry = part.Shape.TextureEntry ?? Utils.EmptyBytes;
  5073. update.Scale = part.Shape.Scale;
  5074. update.Text = Util.StringToBytes(part.Text, 255);
  5075. update.MediaURL = Util.StringToBytes(part.MediaUrl, 255);
  5076. #region PrimFlags
  5077. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(part, sp);
  5078. // Don't send the CreateSelected flag to everyone
  5079. flags &= ~PrimFlags.CreateSelected;
  5080. if (sp.UUID == part.OwnerID)
  5081. {
  5082. if (part.CreateSelected)
  5083. {
  5084. // Only send this flag once, then unset it
  5085. flags |= PrimFlags.CreateSelected;
  5086. part.CreateSelected = false;
  5087. }
  5088. }
  5089. // m_log.DebugFormat(
  5090. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  5091. // data.Name, update.FullID, flags, update.ID);
  5092. update.UpdateFlags = (uint)flags;
  5093. #endregion PrimFlags
  5094. if (part.Sound != UUID.Zero)
  5095. {
  5096. update.Sound = part.Sound;
  5097. update.OwnerID = part.OwnerID;
  5098. update.Gain = (float)part.SoundGain;
  5099. update.Radius = (float)part.SoundRadius;
  5100. update.Flags = part.SoundFlags;
  5101. }
  5102. switch ((PCode)part.Shape.PCode)
  5103. {
  5104. case PCode.Grass:
  5105. case PCode.Tree:
  5106. case PCode.NewTree:
  5107. update.Data = new byte[] { part.Shape.State };
  5108. break;
  5109. default:
  5110. update.Data = Utils.EmptyBytes;
  5111. break;
  5112. }
  5113. return update;
  5114. }
  5115. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  5116. {
  5117. // TODO: Implement this
  5118. return null;
  5119. }
  5120. public void SendNameReply(UUID profileId, string firstname, string lastname)
  5121. {
  5122. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  5123. // TODO: don't create new blocks if recycling an old packet
  5124. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  5125. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  5126. packet.UUIDNameBlock[0].ID = profileId;
  5127. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  5128. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  5129. OutPacket(packet, ThrottleOutPacketType.Task);
  5130. }
  5131. public Dictionary<UUID, ulong> GetGroupPowers()
  5132. {
  5133. lock(m_groupPowers)
  5134. {
  5135. return new Dictionary<UUID, ulong>(m_groupPowers);
  5136. }
  5137. }
  5138. public void SetGroupPowers(Dictionary<UUID, ulong> powers)
  5139. {
  5140. lock(m_groupPowers)
  5141. {
  5142. m_groupPowers.Clear();
  5143. m_groupPowers = powers;
  5144. }
  5145. }
  5146. public ulong GetGroupPowers(UUID groupID)
  5147. {
  5148. lock(m_groupPowers)
  5149. {
  5150. if (m_groupPowers.ContainsKey(groupID))
  5151. return m_groupPowers[groupID];
  5152. }
  5153. return 0;
  5154. }
  5155. #endregion
  5156. /// <summary>
  5157. /// This is a different way of processing packets then ProcessInPacket
  5158. /// </summary>
  5159. protected virtual void RegisterLocalPacketHandlers()
  5160. {
  5161. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  5162. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  5163. // for each AgentUpdate packet.
  5164. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  5165. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  5166. AddLocalPacketHandler(PacketType.VelocityInterpolateOff, HandleVelocityInterpolateOff, false);
  5167. AddLocalPacketHandler(PacketType.VelocityInterpolateOn, HandleVelocityInterpolateOn, false);
  5168. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  5169. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  5170. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  5171. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  5172. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  5173. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  5174. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  5175. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  5176. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  5177. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  5178. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  5179. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  5180. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  5181. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  5182. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  5183. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  5184. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  5185. AddLocalPacketHandler(PacketType.RezRestoreToWorld, HandlerRezRestoreToWorld);
  5186. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  5187. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  5188. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  5189. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  5190. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  5191. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  5192. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  5193. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  5194. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  5195. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  5196. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  5197. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  5198. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  5199. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  5200. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  5201. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  5202. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  5203. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  5204. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  5205. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  5206. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  5207. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  5208. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  5209. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  5210. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  5211. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  5212. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  5213. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  5214. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  5215. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  5216. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  5217. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  5218. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  5219. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  5220. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  5221. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  5222. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  5223. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  5224. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  5225. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  5226. // some clients will send out a separate ObjectImage packet for each face
  5227. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  5228. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  5229. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  5230. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  5231. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  5232. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  5233. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  5234. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  5235. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  5236. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  5237. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  5238. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  5239. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  5240. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  5241. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  5242. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  5243. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  5244. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  5245. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  5246. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  5247. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  5248. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  5249. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  5250. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  5251. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  5252. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  5253. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  5254. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  5255. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  5256. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  5257. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  5258. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  5259. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  5260. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  5261. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  5262. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  5263. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  5264. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  5265. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  5266. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  5267. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  5268. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  5269. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  5270. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  5271. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  5272. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  5273. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  5274. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  5275. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  5276. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  5277. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  5278. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  5279. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  5280. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  5281. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  5282. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  5283. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  5284. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  5285. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  5286. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  5287. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  5288. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  5289. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  5290. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  5291. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  5292. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  5293. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  5294. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  5295. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  5296. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  5297. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  5298. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  5299. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  5300. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  5301. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  5302. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  5303. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  5304. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  5305. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  5306. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  5307. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  5308. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  5309. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  5310. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  5311. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  5312. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  5313. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  5314. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  5315. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  5316. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  5317. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  5318. AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
  5319. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  5320. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  5321. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  5322. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  5323. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  5324. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  5325. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  5326. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  5327. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  5328. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  5329. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  5330. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  5331. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  5332. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  5333. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  5334. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  5335. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  5336. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  5337. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  5338. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  5339. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  5340. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  5341. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  5342. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  5343. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  5344. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  5345. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  5346. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  5347. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  5348. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  5349. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  5350. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  5351. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  5352. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  5353. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  5354. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  5355. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  5356. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  5357. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  5358. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  5359. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  5360. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  5361. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  5362. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  5363. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  5364. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  5365. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  5366. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  5367. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  5368. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  5369. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  5370. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  5371. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  5372. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  5373. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  5374. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  5375. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  5376. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  5377. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  5378. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  5379. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  5380. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  5381. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  5382. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  5383. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  5384. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  5385. AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags);
  5386. AddLocalPacketHandler(PacketType.RevokePermissions, HandleRevokePermissions);
  5387. AddGenericPacketHandler("autopilot", HandleAutopilot);
  5388. }
  5389. #region Packet Handlers
  5390. public int TotalAgentUpdates { get; set; }
  5391. #region Scene/Avatar
  5392. // Threshold for body rotation to be a significant agent update
  5393. // use the abs of cos
  5394. private const float QDELTABody = 1.0f - 0.00005f;
  5395. private const float QDELTAHead = 1.0f - 0.00005f;
  5396. // Threshold for camera rotation to be a significant agent update
  5397. private const float VDELTA = 0.01f;
  5398. /// <summary>
  5399. /// This checks the update significance against the last update made.
  5400. /// </summary>
  5401. /// <remarks>Can only be called by one thread at a time</remarks>
  5402. /// <returns></returns>
  5403. /// <param name='x'></param>
  5404. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5405. {
  5406. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  5407. }
  5408. /// <summary>
  5409. /// This checks the movement/state update significance against the last update made.
  5410. /// </summary>
  5411. /// <remarks>Can only be called by one thread at a time</remarks>
  5412. /// <returns></returns>
  5413. /// <param name='x'></param>
  5414. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5415. {
  5416. if(
  5417. (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  5418. // || ((x.ControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0 &&
  5419. // (x.ControlFlags & 0x3f8dfff) != 0) // we need to rotate the av on fly
  5420. || x.ControlFlags != (byte)AgentManager.ControlFlags.NONE// actually all movement controls need to pass
  5421. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  5422. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  5423. || (Math.Abs(x.Far - m_thisAgentUpdateArgs.Far) >= 32) // significant if far distance changed
  5424. )
  5425. return true;
  5426. float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
  5427. //qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
  5428. if(
  5429. qdelta1 < QDELTABody // significant if body rotation above(below cos) threshold
  5430. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  5431. // || qdelta2 < QDELTAHead // significant if head rotation above(below cos) threshold
  5432. )
  5433. return true;
  5434. return false;
  5435. }
  5436. /// <summary>
  5437. /// This checks the camera update significance against the last update made.
  5438. /// </summary>
  5439. /// <remarks>Can only be called by one thread at a time</remarks>
  5440. /// <returns></returns>
  5441. /// <param name='x'></param>
  5442. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5443. {
  5444. if(Math.Abs(x.CameraCenter.X - m_thisAgentUpdateArgs.CameraCenter.X) > VDELTA ||
  5445. Math.Abs(x.CameraCenter.Y - m_thisAgentUpdateArgs.CameraCenter.Y) > VDELTA ||
  5446. Math.Abs(x.CameraCenter.Z - m_thisAgentUpdateArgs.CameraCenter.Z) > VDELTA ||
  5447. Math.Abs(x.CameraAtAxis.X - m_thisAgentUpdateArgs.CameraAtAxis.X) > VDELTA ||
  5448. Math.Abs(x.CameraAtAxis.Y - m_thisAgentUpdateArgs.CameraAtAxis.Y) > VDELTA ||
  5449. // Math.Abs(x.CameraAtAxis.Z - m_thisAgentUpdateArgs.CameraAtAxis.Z) > VDELTA ||
  5450. Math.Abs(x.CameraLeftAxis.X - m_thisAgentUpdateArgs.CameraLeftAxis.X) > VDELTA ||
  5451. Math.Abs(x.CameraLeftAxis.Y - m_thisAgentUpdateArgs.CameraLeftAxis.Y) > VDELTA ||
  5452. // Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA ||
  5453. Math.Abs(x.CameraUpAxis.X - m_thisAgentUpdateArgs.CameraUpAxis.X) > VDELTA ||
  5454. Math.Abs(x.CameraUpAxis.Y - m_thisAgentUpdateArgs.CameraUpAxis.Y) > VDELTA
  5455. // Math.Abs(x.CameraLeftAxis.Z - m_thisAgentUpdateArgs.CameraLeftAxis.Z) > VDELTA ||
  5456. )
  5457. return true;
  5458. return false;
  5459. }
  5460. private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
  5461. {
  5462. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  5463. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  5464. if (x.AgentID != AgentId || x.SessionID != SessionId)
  5465. {
  5466. PacketPool.Instance.ReturnPacket(packet);
  5467. return false;
  5468. }
  5469. uint seq = packet.Header.Sequence;
  5470. TotalAgentUpdates++;
  5471. // dont let ignored updates pollute this throttles
  5472. if(SceneAgent == null || SceneAgent.IsChildAgent ||
  5473. SceneAgent.IsInTransit || seq <= m_thisAgentUpdateArgs.lastpacketSequence )
  5474. {
  5475. // throttle reset is done at MoveAgentIntoRegion()
  5476. // called by scenepresence on completemovement
  5477. PacketPool.Instance.ReturnPacket(packet);
  5478. return true;
  5479. }
  5480. m_thisAgentUpdateArgs.lastpacketSequence = seq;
  5481. bool movement = CheckAgentMovementUpdateSignificance(x);
  5482. bool camera = CheckAgentCameraUpdateSignificance(x);
  5483. // Was there a significant movement/state change?
  5484. if (movement)
  5485. {
  5486. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  5487. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  5488. m_thisAgentUpdateArgs.Far = x.Far;
  5489. m_thisAgentUpdateArgs.Flags = x.Flags;
  5490. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  5491. m_thisAgentUpdateArgs.State = x.State;
  5492. m_thisAgentUpdateArgs.NeedsCameraCollision = !camera;
  5493. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  5494. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  5495. if (handlerPreAgentUpdate != null)
  5496. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  5497. if (handlerAgentUpdate != null)
  5498. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  5499. }
  5500. // Was there a significant camera(s) change?
  5501. if (camera)
  5502. {
  5503. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  5504. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  5505. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  5506. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  5507. m_thisAgentUpdateArgs.NeedsCameraCollision = true;
  5508. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  5509. if (handlerAgentCameraUpdate != null)
  5510. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  5511. }
  5512. PacketPool.Instance.ReturnPacket(packet);
  5513. return true;
  5514. }
  5515. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  5516. {
  5517. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  5518. // validate the agent owns the agentID and sessionID
  5519. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  5520. money.AgentData.SessionID == sender.SessionId)
  5521. {
  5522. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  5523. if (handlerMoneyTransferRequest != null)
  5524. {
  5525. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  5526. money.MoneyData.Amount, money.MoneyData.TransactionType,
  5527. Util.FieldToString(money.MoneyData.Description));
  5528. }
  5529. return true;
  5530. }
  5531. return false;
  5532. }
  5533. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  5534. {
  5535. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  5536. (ParcelGodMarkAsContentPacket)Packet;
  5537. if(SessionId != ParcelGodMarkAsContent.AgentData.SessionID || AgentId != ParcelGodMarkAsContent.AgentData.AgentID)
  5538. return false;
  5539. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  5540. if (ParcelGodMarkAsContentHandler != null)
  5541. {
  5542. ParcelGodMarkAsContentHandler(this,
  5543. ParcelGodMarkAsContent.AgentData.AgentID,
  5544. ParcelGodMarkAsContent.ParcelData.LocalID);
  5545. return true;
  5546. }
  5547. return false;
  5548. }
  5549. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  5550. {
  5551. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5552. if(SessionId != FreezeUser.AgentData.SessionID || AgentId != FreezeUser.AgentData.AgentID)
  5553. return false;
  5554. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5555. if (FreezeUserHandler != null)
  5556. {
  5557. FreezeUserHandler(this,
  5558. FreezeUser.AgentData.AgentID,
  5559. FreezeUser.Data.Flags,
  5560. FreezeUser.Data.TargetID);
  5561. return true;
  5562. }
  5563. return false;
  5564. }
  5565. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5566. {
  5567. EjectUserPacket EjectUser =
  5568. (EjectUserPacket)Packet;
  5569. if(SessionId != EjectUser.AgentData.SessionID || AgentId != EjectUser.AgentData.AgentID)
  5570. return false;
  5571. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5572. if (EjectUserHandler != null)
  5573. {
  5574. EjectUserHandler(this,
  5575. EjectUser.AgentData.AgentID,
  5576. EjectUser.Data.Flags,
  5577. EjectUser.Data.TargetID);
  5578. return true;
  5579. }
  5580. return false;
  5581. }
  5582. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5583. {
  5584. ParcelBuyPassPacket ParcelBuyPass =
  5585. (ParcelBuyPassPacket)Packet;
  5586. if(SessionId != ParcelBuyPass.AgentData.SessionID || AgentId != ParcelBuyPass.AgentData.AgentID)
  5587. return false;
  5588. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5589. if (ParcelBuyPassHandler != null)
  5590. {
  5591. ParcelBuyPassHandler(this,
  5592. ParcelBuyPass.AgentData.AgentID,
  5593. ParcelBuyPass.ParcelData.LocalID);
  5594. return true;
  5595. }
  5596. return false;
  5597. }
  5598. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5599. {
  5600. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5601. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5602. {
  5603. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5604. if (handlerParcelBuy != null)
  5605. {
  5606. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5607. parcel.Data.IsGroupOwned,
  5608. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5609. parcel.ParcelData.Price,
  5610. false);
  5611. }
  5612. return true;
  5613. }
  5614. return false;
  5615. }
  5616. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5617. {
  5618. ScenePresence sp = (ScenePresence)SceneAgent;
  5619. if(sp == null || sp.IsDeleted || (sp.IsInTransit && !sp.IsInLocalTransit))
  5620. return true;
  5621. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5622. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5623. {
  5624. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5625. if (handlerUUIDGroupNameRequest != null)
  5626. {
  5627. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5628. }
  5629. }
  5630. return true;
  5631. }
  5632. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5633. {
  5634. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5635. if (m_genericPacketHandlers.Count == 0) return false;
  5636. if (gmpack.AgentData.SessionID != SessionId) return false;
  5637. GenericMessage handlerGenericMessage = null;
  5638. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5639. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5640. {
  5641. List<string> msg = new List<string>();
  5642. List<byte[]> msgBytes = new List<byte[]>();
  5643. if (handlerGenericMessage != null)
  5644. {
  5645. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5646. {
  5647. msg.Add(Util.FieldToString(block.Parameter));
  5648. msgBytes.Add(block.Parameter);
  5649. }
  5650. try
  5651. {
  5652. if (OnBinaryGenericMessage != null)
  5653. {
  5654. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5655. }
  5656. handlerGenericMessage(sender, method, msg);
  5657. return true;
  5658. }
  5659. catch (Exception e)
  5660. {
  5661. m_log.ErrorFormat(
  5662. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5663. }
  5664. }
  5665. }
  5666. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5667. return false;
  5668. }
  5669. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5670. {
  5671. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5672. if (ogpack.AgentData.SessionID != SessionId) return false;
  5673. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5674. if (handlerObjectGroupRequest != null)
  5675. {
  5676. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5677. {
  5678. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5679. }
  5680. }
  5681. return true;
  5682. }
  5683. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5684. {
  5685. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5686. if (viewer.AgentData.SessionID != SessionId) return false;
  5687. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5688. if (handlerViewerEffect != null)
  5689. {
  5690. int length = viewer.Effect.Length;
  5691. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5692. for (int i = 0; i < length; i++)
  5693. {
  5694. //copy the effects block arguments into the event handler arg.
  5695. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5696. argument.AgentID = viewer.Effect[i].AgentID;
  5697. argument.Color = viewer.Effect[i].Color;
  5698. argument.Duration = viewer.Effect[i].Duration;
  5699. argument.ID = viewer.Effect[i].ID;
  5700. argument.Type = viewer.Effect[i].Type;
  5701. argument.TypeData = viewer.Effect[i].TypeData;
  5702. args.Add(argument);
  5703. }
  5704. handlerViewerEffect(sender, args);
  5705. }
  5706. return true;
  5707. }
  5708. private bool HandleVelocityInterpolateOff(IClientAPI sender, Packet Pack)
  5709. {
  5710. VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack;
  5711. if (p.AgentData.SessionID != SessionId ||
  5712. p.AgentData.AgentID != AgentId)
  5713. return true;
  5714. m_VelocityInterpolate = false;
  5715. return true;
  5716. }
  5717. private bool HandleVelocityInterpolateOn(IClientAPI sender, Packet Pack)
  5718. {
  5719. VelocityInterpolateOnPacket p = (VelocityInterpolateOnPacket)Pack;
  5720. if (p.AgentData.SessionID != SessionId ||
  5721. p.AgentData.AgentID != AgentId)
  5722. return true;
  5723. m_VelocityInterpolate = true;
  5724. return true;
  5725. }
  5726. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5727. {
  5728. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5729. #region Packet Session and User Check
  5730. if (m_checkPackets)
  5731. {
  5732. if (avatarProperties.AgentData.SessionID != SessionId ||
  5733. avatarProperties.AgentData.AgentID != AgentId)
  5734. return true;
  5735. }
  5736. #endregion
  5737. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5738. if (handlerRequestAvatarProperties != null)
  5739. {
  5740. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5741. }
  5742. return true;
  5743. }
  5744. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5745. {
  5746. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5747. #region Packet Session and User Check
  5748. if (m_checkPackets)
  5749. {
  5750. if (inchatpack.AgentData.SessionID != SessionId ||
  5751. inchatpack.AgentData.AgentID != AgentId)
  5752. return true;
  5753. }
  5754. #endregion
  5755. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5756. byte[] message = inchatpack.ChatData.Message;
  5757. byte type = inchatpack.ChatData.Type;
  5758. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5759. // UUID fromAgentID = AgentId;
  5760. int channel = inchatpack.ChatData.Channel;
  5761. if (OnChatFromClient != null)
  5762. {
  5763. OSChatMessage args = new OSChatMessage();
  5764. args.Channel = channel;
  5765. args.From = fromName;
  5766. args.Message = Utils.BytesToString(message);
  5767. args.Type = (ChatTypeEnum)type;
  5768. args.Position = fromPos;
  5769. args.Scene = Scene;
  5770. args.Sender = this;
  5771. args.SenderUUID = this.AgentId;
  5772. ChatMessage handlerChatFromClient = OnChatFromClient;
  5773. if (handlerChatFromClient != null)
  5774. handlerChatFromClient(this, args);
  5775. }
  5776. return true;
  5777. }
  5778. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5779. {
  5780. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5781. #region Packet Session and User Check
  5782. if (m_checkPackets)
  5783. {
  5784. if (avatarProps.AgentData.SessionID != SessionId ||
  5785. avatarProps.AgentData.AgentID != AgentId)
  5786. return true;
  5787. }
  5788. #endregion
  5789. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5790. if (handlerUpdateAvatarProperties != null)
  5791. {
  5792. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5793. UserProfileData UserProfile = new UserProfileData();
  5794. UserProfile.ID = AgentId;
  5795. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5796. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5797. UserProfile.FirstLifeImage = Properties.FLImageID;
  5798. UserProfile.Image = Properties.ImageID;
  5799. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5800. UserProfile.UserFlags &= ~3;
  5801. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5802. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5803. handlerUpdateAvatarProperties(this, UserProfile);
  5804. }
  5805. return true;
  5806. }
  5807. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5808. {
  5809. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5810. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5811. #region Packet Session and User Check
  5812. if (m_checkPackets)
  5813. {
  5814. if (rdialog.AgentData.SessionID != SessionId ||
  5815. rdialog.AgentData.AgentID != AgentId)
  5816. return true;
  5817. }
  5818. #endregion
  5819. int ch = rdialog.Data.ChatChannel;
  5820. byte[] msg = rdialog.Data.ButtonLabel;
  5821. if (OnChatFromClient != null)
  5822. {
  5823. OSChatMessage args = new OSChatMessage();
  5824. args.Channel = ch;
  5825. args.From = String.Empty;
  5826. args.Message = Utils.BytesToString(msg);
  5827. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5828. args.Position = new Vector3();
  5829. args.Scene = Scene;
  5830. args.Sender = this;
  5831. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5832. if (handlerChatFromClient2 != null)
  5833. handlerChatFromClient2(this, args);
  5834. }
  5835. return true;
  5836. }
  5837. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5838. {
  5839. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5840. #region Packet Session and User Check
  5841. if (m_checkPackets)
  5842. {
  5843. if (msgpack.AgentData.SessionID != SessionId ||
  5844. msgpack.AgentData.AgentID != AgentId)
  5845. return true;
  5846. }
  5847. #endregion
  5848. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5849. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5850. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5851. if (handlerInstantMessage != null)
  5852. {
  5853. GridInstantMessage im = new GridInstantMessage(Scene,
  5854. msgpack.AgentData.AgentID,
  5855. IMfromName,
  5856. msgpack.MessageBlock.ToAgentID,
  5857. msgpack.MessageBlock.Dialog,
  5858. msgpack.MessageBlock.FromGroup,
  5859. IMmessage,
  5860. msgpack.MessageBlock.ID,
  5861. msgpack.MessageBlock.Offline != 0 ? true : false,
  5862. msgpack.MessageBlock.Position,
  5863. msgpack.MessageBlock.BinaryBucket,
  5864. true);
  5865. handlerInstantMessage(this, im);
  5866. }
  5867. return true;
  5868. }
  5869. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5870. {
  5871. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5872. #region Packet Session and User Check
  5873. if (m_checkPackets)
  5874. {
  5875. if (afriendpack.AgentData.SessionID != SessionId ||
  5876. afriendpack.AgentData.AgentID != AgentId)
  5877. return true;
  5878. }
  5879. #endregion
  5880. // My guess is this is the folder to stick the calling card into
  5881. List<UUID> callingCardFolders = new List<UUID>();
  5882. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5883. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5884. {
  5885. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5886. }
  5887. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5888. if (handlerApproveFriendRequest != null)
  5889. {
  5890. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5891. }
  5892. return true;
  5893. }
  5894. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5895. {
  5896. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5897. #region Packet Session and User Check
  5898. if (m_checkPackets)
  5899. {
  5900. if (dfriendpack.AgentData.SessionID != SessionId ||
  5901. dfriendpack.AgentData.AgentID != AgentId)
  5902. return true;
  5903. }
  5904. #endregion
  5905. if (OnDenyFriendRequest != null)
  5906. {
  5907. OnDenyFriendRequest(this,
  5908. dfriendpack.TransactionBlock.TransactionID,
  5909. null);
  5910. }
  5911. return true;
  5912. }
  5913. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5914. {
  5915. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5916. #region Packet Session and User Check
  5917. if (m_checkPackets)
  5918. {
  5919. if (tfriendpack.AgentData.SessionID != SessionId ||
  5920. tfriendpack.AgentData.AgentID != AgentId)
  5921. return true;
  5922. }
  5923. #endregion
  5924. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5925. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5926. if (TerminateFriendshipHandler != null)
  5927. {
  5928. TerminateFriendshipHandler(this, exFriendID);
  5929. return true;
  5930. }
  5931. return false;
  5932. }
  5933. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5934. {
  5935. FindAgentPacket FindAgent =
  5936. (FindAgentPacket)Packet;
  5937. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5938. if (FindAgentHandler != null)
  5939. {
  5940. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5941. return true;
  5942. }
  5943. return false;
  5944. }
  5945. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5946. {
  5947. TrackAgentPacket TrackAgent =
  5948. (TrackAgentPacket)Packet;
  5949. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5950. if (TrackAgentHandler != null)
  5951. {
  5952. TrackAgentHandler(this,
  5953. TrackAgent.AgentData.AgentID,
  5954. TrackAgent.TargetData.PreyID);
  5955. return true;
  5956. }
  5957. return false;
  5958. }
  5959. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5960. {
  5961. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5962. #region Packet Session and User Check
  5963. if (m_checkPackets)
  5964. {
  5965. if (rezPacket.AgentData.SessionID != SessionId ||
  5966. rezPacket.AgentData.AgentID != AgentId)
  5967. return true;
  5968. }
  5969. #endregion
  5970. RezObject handlerRezObject = OnRezObject;
  5971. if (handlerRezObject != null)
  5972. {
  5973. UUID rezGroupID = rezPacket.AgentData.GroupID;
  5974. if(!IsGroupMember(rezGroupID))
  5975. rezGroupID = UUID.Zero;
  5976. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezGroupID, rezPacket.RezData.RayEnd,
  5977. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5978. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5979. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5980. rezPacket.RezData.FromTaskID);
  5981. }
  5982. return true;
  5983. }
  5984. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5985. {
  5986. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5987. #region Packet Session and User Check
  5988. if (m_checkPackets)
  5989. {
  5990. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5991. DeRezPacket.AgentData.AgentID != AgentId)
  5992. return true;
  5993. }
  5994. #endregion
  5995. DeRezObject handlerDeRezObject = OnDeRezObject;
  5996. if (handlerDeRezObject != null)
  5997. {
  5998. List<uint> deRezIDs = new List<uint>();
  5999. foreach (DeRezObjectPacket.ObjectDataBlock data in
  6000. DeRezPacket.ObjectData)
  6001. {
  6002. deRezIDs.Add(data.ObjectLocalID);
  6003. }
  6004. // It just so happens that the values on the DeRezAction enumerator match the Destination
  6005. // values given by a Second Life client
  6006. handlerDeRezObject(this, deRezIDs,
  6007. DeRezPacket.AgentBlock.GroupID,
  6008. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  6009. DeRezPacket.AgentBlock.DestinationID);
  6010. }
  6011. return true;
  6012. }
  6013. private bool HandlerRezRestoreToWorld(IClientAPI sender, Packet Pack)
  6014. {
  6015. RezRestoreToWorldPacket restore = (RezRestoreToWorldPacket)Pack;
  6016. #region Packet Session and User Check
  6017. if (m_checkPackets)
  6018. {
  6019. if (restore.AgentData.SessionID != SessionId ||
  6020. restore.AgentData.AgentID != AgentId)
  6021. return true;
  6022. }
  6023. #endregion
  6024. RezRestoreToWorld handlerRezRestoreToWorld = OnRezRestoreToWorld;
  6025. if (handlerRezRestoreToWorld != null)
  6026. handlerRezRestoreToWorld(this, restore.InventoryData.ItemID);
  6027. return true;
  6028. }
  6029. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  6030. {
  6031. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  6032. #region Packet Session and User Check
  6033. if (m_checkPackets)
  6034. {
  6035. if (modify.AgentData.SessionID != SessionId ||
  6036. modify.AgentData.AgentID != AgentId)
  6037. return true;
  6038. }
  6039. #endregion
  6040. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  6041. if (modify.ParcelData.Length > 0)
  6042. {
  6043. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  6044. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  6045. if (OnModifyTerrain != null)
  6046. {
  6047. for (int i = 0; i < modify.ParcelData.Length; i++)
  6048. {
  6049. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  6050. if (handlerModifyTerrain != null)
  6051. {
  6052. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  6053. modify.ModifyBlock.BrushSize,
  6054. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  6055. modify.ParcelData[i].West, modify.ParcelData[i].South,
  6056. modify.ParcelData[i].East, AgentId);
  6057. }
  6058. }
  6059. }
  6060. }
  6061. return true;
  6062. }
  6063. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  6064. {
  6065. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  6066. if (handlerRegionHandShakeReply != null)
  6067. {
  6068. handlerRegionHandShakeReply(this);
  6069. }
  6070. return true;
  6071. }
  6072. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  6073. {
  6074. GenericCall1 handlerRequestWearables = OnRequestWearables;
  6075. if (handlerRequestWearables != null)
  6076. {
  6077. handlerRequestWearables(sender);
  6078. }
  6079. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  6080. if (handlerRequestAvatarsData != null)
  6081. {
  6082. handlerRequestAvatarsData(this);
  6083. }
  6084. return true;
  6085. }
  6086. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  6087. {
  6088. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  6089. #region Packet Session and User Check
  6090. if (m_checkPackets)
  6091. {
  6092. if (appear.AgentData.SessionID != SessionId ||
  6093. appear.AgentData.AgentID != AgentId)
  6094. return true;
  6095. }
  6096. #endregion
  6097. SetAppearance handlerSetAppearance = OnSetAppearance;
  6098. if (handlerSetAppearance != null)
  6099. {
  6100. // Temporarily protect ourselves from the mantis #951 failure.
  6101. // However, we could do this for several other handlers where a failure isn't terminal
  6102. // for the client session anyway, in order to protect ourselves against bad code in plugins
  6103. Vector3 avSize = appear.AgentData.Size;
  6104. try
  6105. {
  6106. byte[] visualparams = new byte[appear.VisualParam.Length];
  6107. for (int i = 0; i < appear.VisualParam.Length; i++)
  6108. visualparams[i] = appear.VisualParam[i].ParamValue;
  6109. //var b = appear.WearableData[0];
  6110. Primitive.TextureEntry te = null;
  6111. if (appear.ObjectData.TextureEntry.Length > 1)
  6112. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  6113. WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
  6114. for (int i=0; i<appear.WearableData.Length;i++)
  6115. cacheitems[i] = new WearableCacheItem(){
  6116. CacheId = appear.WearableData[i].CacheID,
  6117. TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)
  6118. };
  6119. handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
  6120. }
  6121. catch (Exception e)
  6122. {
  6123. m_log.ErrorFormat(
  6124. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  6125. e);
  6126. }
  6127. }
  6128. return true;
  6129. }
  6130. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  6131. {
  6132. if (OnAvatarNowWearing != null)
  6133. {
  6134. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  6135. #region Packet Session and User Check
  6136. if (m_checkPackets)
  6137. {
  6138. if (nowWearing.AgentData.SessionID != SessionId ||
  6139. nowWearing.AgentData.AgentID != AgentId)
  6140. return true;
  6141. }
  6142. #endregion
  6143. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  6144. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  6145. {
  6146. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  6147. AvatarWearingArgs.Wearable wearable =
  6148. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  6149. nowWearing.WearableData[i].WearableType);
  6150. wearingArgs.NowWearing.Add(wearable);
  6151. }
  6152. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  6153. if (handlerAvatarNowWearing != null)
  6154. {
  6155. handlerAvatarNowWearing(this, wearingArgs);
  6156. }
  6157. }
  6158. return true;
  6159. }
  6160. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  6161. {
  6162. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  6163. if (handlerRezSingleAttachment != null)
  6164. {
  6165. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  6166. #region Packet Session and User Check
  6167. if (m_checkPackets)
  6168. {
  6169. if (rez.AgentData.SessionID != SessionId ||
  6170. rez.AgentData.AgentID != AgentId)
  6171. return true;
  6172. }
  6173. #endregion
  6174. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  6175. rez.ObjectData.AttachmentPt);
  6176. }
  6177. return true;
  6178. }
  6179. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  6180. {
  6181. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  6182. if (handlerRezMultipleAttachments != null)
  6183. {
  6184. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  6185. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  6186. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  6187. handlerRezMultipleAttachments(this, rezlist);
  6188. }
  6189. return true;
  6190. }
  6191. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  6192. {
  6193. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  6194. if (handlerDetachAttachmentIntoInv != null)
  6195. {
  6196. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  6197. #region Packet Session and User Check
  6198. // UNSUPPORTED ON THIS PACKET
  6199. #endregion
  6200. UUID itemID = detachtoInv.ObjectData.ItemID;
  6201. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  6202. handlerDetachAttachmentIntoInv(itemID, this);
  6203. }
  6204. return true;
  6205. }
  6206. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  6207. {
  6208. if (OnObjectAttach != null)
  6209. {
  6210. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  6211. #region Packet Session and User Check
  6212. if (m_checkPackets)
  6213. {
  6214. if (att.AgentData.SessionID != SessionId ||
  6215. att.AgentData.AgentID != AgentId)
  6216. return true;
  6217. }
  6218. #endregion
  6219. ObjectAttach handlerObjectAttach = OnObjectAttach;
  6220. if (handlerObjectAttach != null)
  6221. {
  6222. if (att.ObjectData.Length > 0)
  6223. {
  6224. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  6225. }
  6226. }
  6227. }
  6228. return true;
  6229. }
  6230. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  6231. {
  6232. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  6233. #region Packet Session and User Check
  6234. if (m_checkPackets)
  6235. {
  6236. if (dett.AgentData.SessionID != SessionId ||
  6237. dett.AgentData.AgentID != AgentId)
  6238. return true;
  6239. }
  6240. #endregion
  6241. for (int j = 0; j < dett.ObjectData.Length; j++)
  6242. {
  6243. uint obj = dett.ObjectData[j].ObjectLocalID;
  6244. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  6245. if (handlerObjectDetach != null)
  6246. {
  6247. handlerObjectDetach(obj, this);
  6248. }
  6249. }
  6250. return true;
  6251. }
  6252. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  6253. {
  6254. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  6255. #region Packet Session and User Check
  6256. if (m_checkPackets)
  6257. {
  6258. if (dropp.AgentData.SessionID != SessionId ||
  6259. dropp.AgentData.AgentID != AgentId)
  6260. return true;
  6261. }
  6262. #endregion
  6263. for (int j = 0; j < dropp.ObjectData.Length; j++)
  6264. {
  6265. uint obj = dropp.ObjectData[j].ObjectLocalID;
  6266. ObjectDrop handlerObjectDrop = OnObjectDrop;
  6267. if (handlerObjectDrop != null)
  6268. {
  6269. handlerObjectDrop(obj, this);
  6270. }
  6271. }
  6272. return true;
  6273. }
  6274. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  6275. {
  6276. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  6277. #region Packet Session and User Check
  6278. if (m_checkPackets)
  6279. {
  6280. if (run.AgentData.SessionID != SessionId ||
  6281. run.AgentData.AgentID != AgentId)
  6282. return true;
  6283. }
  6284. #endregion
  6285. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  6286. if (handlerSetAlwaysRun != null)
  6287. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  6288. return true;
  6289. }
  6290. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  6291. {
  6292. m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement");
  6293. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  6294. if (handlerCompleteMovementToRegion != null)
  6295. {
  6296. handlerCompleteMovementToRegion(sender, true);
  6297. }
  6298. else
  6299. m_log.Debug("HandleCompleteAgentMovement NULL handler");
  6300. handlerCompleteMovementToRegion = null;
  6301. return true;
  6302. }
  6303. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  6304. {
  6305. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  6306. #region Packet Session and User Check
  6307. if (m_checkPackets)
  6308. {
  6309. if (AgentAni.AgentData.SessionID != SessionId ||
  6310. AgentAni.AgentData.AgentID != AgentId)
  6311. return true;
  6312. }
  6313. #endregion
  6314. /*
  6315. StartAnim handlerStartAnim = null;
  6316. StopAnim handlerStopAnim = null;
  6317. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  6318. {
  6319. if (AgentAni.AnimationList[i].StartAnim)
  6320. {
  6321. handlerStartAnim = OnStartAnim;
  6322. if (handlerStartAnim != null)
  6323. {
  6324. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  6325. }
  6326. }
  6327. else
  6328. {
  6329. handlerStopAnim = OnStopAnim;
  6330. if (handlerStopAnim != null)
  6331. {
  6332. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  6333. }
  6334. }
  6335. }
  6336. return true;
  6337. */
  6338. ChangeAnim handlerChangeAnim = null;
  6339. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  6340. {
  6341. handlerChangeAnim = OnChangeAnim;
  6342. if (handlerChangeAnim != null)
  6343. {
  6344. handlerChangeAnim(AgentAni.AnimationList[i].AnimID, AgentAni.AnimationList[i].StartAnim, false);
  6345. }
  6346. }
  6347. handlerChangeAnim = OnChangeAnim;
  6348. if (handlerChangeAnim != null)
  6349. {
  6350. handlerChangeAnim(UUID.Zero, false, true);
  6351. }
  6352. return true;
  6353. }
  6354. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  6355. {
  6356. if (OnAgentRequestSit != null)
  6357. {
  6358. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  6359. #region Packet Session and User Check
  6360. if (m_checkPackets)
  6361. {
  6362. if (agentRequestSit.AgentData.SessionID != SessionId ||
  6363. agentRequestSit.AgentData.AgentID != AgentId)
  6364. return true;
  6365. }
  6366. #endregion
  6367. if (SceneAgent.IsChildAgent)
  6368. {
  6369. SendCantSitBecauseChildAgentResponse();
  6370. return true;
  6371. }
  6372. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  6373. if (handlerAgentRequestSit != null)
  6374. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  6375. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  6376. }
  6377. return true;
  6378. }
  6379. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  6380. {
  6381. if (OnAgentSit != null)
  6382. {
  6383. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  6384. #region Packet Session and User Check
  6385. if (m_checkPackets)
  6386. {
  6387. if (agentSit.AgentData.SessionID != SessionId ||
  6388. agentSit.AgentData.AgentID != AgentId)
  6389. return true;
  6390. }
  6391. #endregion
  6392. if (SceneAgent.IsChildAgent)
  6393. {
  6394. SendCantSitBecauseChildAgentResponse();
  6395. return true;
  6396. }
  6397. AgentSit handlerAgentSit = OnAgentSit;
  6398. if (handlerAgentSit != null)
  6399. {
  6400. OnAgentSit(this, agentSit.AgentData.AgentID);
  6401. }
  6402. }
  6403. return true;
  6404. }
  6405. /// <summary>
  6406. /// Used when a child agent gets a sit response which should not be fulfilled.
  6407. /// </summary>
  6408. private void SendCantSitBecauseChildAgentResponse()
  6409. {
  6410. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  6411. }
  6412. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  6413. {
  6414. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  6415. #region Packet Session and User Check
  6416. if (m_checkPackets)
  6417. {
  6418. // UNSUPPORTED ON THIS PACKET
  6419. }
  6420. #endregion
  6421. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  6422. if (handlerSoundTrigger != null)
  6423. {
  6424. // UUIDS are sent as zeroes by the client, substitute agent's id
  6425. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  6426. AgentId, AgentId,
  6427. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  6428. soundTriggerPacket.SoundData.Handle, 0);
  6429. }
  6430. return true;
  6431. }
  6432. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  6433. {
  6434. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  6435. #region Packet Session and User Check
  6436. if (m_checkPackets)
  6437. {
  6438. if (avRequestQuery.AgentData.SessionID != SessionId ||
  6439. avRequestQuery.AgentData.AgentID != AgentId)
  6440. return true;
  6441. }
  6442. #endregion
  6443. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  6444. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  6445. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  6446. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  6447. if (handlerAvatarPickerRequest != null)
  6448. {
  6449. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  6450. Utils.BytesToString(querydata.Name));
  6451. }
  6452. return true;
  6453. }
  6454. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  6455. {
  6456. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  6457. #region Packet Session and User Check
  6458. if (m_checkPackets)
  6459. {
  6460. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  6461. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  6462. return true;
  6463. }
  6464. #endregion
  6465. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  6466. if (handlerAgentDataUpdateRequest != null)
  6467. {
  6468. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  6469. }
  6470. return true;
  6471. }
  6472. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  6473. {
  6474. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  6475. if (handlerUserInfoRequest != null)
  6476. {
  6477. handlerUserInfoRequest(this);
  6478. }
  6479. else
  6480. {
  6481. SendUserInfoReply(false, true, "");
  6482. }
  6483. return true;
  6484. }
  6485. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  6486. {
  6487. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  6488. #region Packet Session and User Check
  6489. if (m_checkPackets)
  6490. {
  6491. if (updateUserInfo.AgentData.SessionID != SessionId ||
  6492. updateUserInfo.AgentData.AgentID != AgentId)
  6493. return true;
  6494. }
  6495. #endregion
  6496. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  6497. if (handlerUpdateUserInfo != null)
  6498. {
  6499. bool visible = true;
  6500. string DirectoryVisibility =
  6501. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  6502. if (DirectoryVisibility == "hidden")
  6503. visible = false;
  6504. handlerUpdateUserInfo(
  6505. updateUserInfo.UserData.IMViaEMail,
  6506. visible, this);
  6507. }
  6508. return true;
  6509. }
  6510. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  6511. {
  6512. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  6513. #region Packet Session and User Check
  6514. if (m_checkPackets)
  6515. {
  6516. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  6517. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  6518. return true;
  6519. }
  6520. #endregion
  6521. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  6522. {
  6523. // Linden Client limitation..
  6524. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  6525. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  6526. {
  6527. ScenePresence avatar = null;
  6528. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  6529. {
  6530. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  6531. {
  6532. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  6533. }
  6534. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  6535. {
  6536. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  6537. }
  6538. }
  6539. }
  6540. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  6541. if (handlerSetStartLocationRequest != null)
  6542. {
  6543. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  6544. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  6545. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  6546. }
  6547. }
  6548. return true;
  6549. }
  6550. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  6551. {
  6552. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  6553. #region Packet Session and User Check
  6554. if (m_checkPackets)
  6555. {
  6556. if (atpack.AgentData.SessionID != SessionId ||
  6557. atpack.AgentData.AgentID != AgentId)
  6558. return true;
  6559. }
  6560. #endregion
  6561. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  6562. GenericCall2 handler = OnUpdateThrottles;
  6563. if (handler != null)
  6564. {
  6565. handler();
  6566. }
  6567. return true;
  6568. }
  6569. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  6570. {
  6571. m_udpClient.IsPaused = true;
  6572. return true;
  6573. }
  6574. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  6575. {
  6576. m_udpClient.IsPaused = false;
  6577. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  6578. return true;
  6579. }
  6580. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  6581. {
  6582. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  6583. if (handlerForceReleaseControls != null)
  6584. {
  6585. handlerForceReleaseControls(this, AgentId);
  6586. }
  6587. return true;
  6588. }
  6589. #endregion Scene/Avatar
  6590. #region Objects/m_sceneObjects
  6591. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  6592. {
  6593. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  6594. #region Packet Session and User Check
  6595. if (m_checkPackets)
  6596. {
  6597. if (link.AgentData.SessionID != SessionId ||
  6598. link.AgentData.AgentID != AgentId)
  6599. return true;
  6600. }
  6601. #endregion
  6602. uint parentprimid = 0;
  6603. List<uint> childrenprims = new List<uint>();
  6604. if (link.ObjectData.Length > 1)
  6605. {
  6606. parentprimid = link.ObjectData[0].ObjectLocalID;
  6607. for (int i = 1; i < link.ObjectData.Length; i++)
  6608. {
  6609. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  6610. }
  6611. }
  6612. LinkObjects handlerLinkObjects = OnLinkObjects;
  6613. if (handlerLinkObjects != null)
  6614. {
  6615. handlerLinkObjects(this, parentprimid, childrenprims);
  6616. }
  6617. return true;
  6618. }
  6619. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  6620. {
  6621. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6622. #region Packet Session and User Check
  6623. if (m_checkPackets)
  6624. {
  6625. if (delink.AgentData.SessionID != SessionId ||
  6626. delink.AgentData.AgentID != AgentId)
  6627. return true;
  6628. }
  6629. #endregion
  6630. // It appears the prim at index 0 is not always the root prim (for
  6631. // instance, when one prim of a link set has been edited independently
  6632. // of the others). Therefore, we'll pass all the ids onto the delink
  6633. // method for it to decide which is the root.
  6634. List<uint> prims = new List<uint>();
  6635. for (int i = 0; i < delink.ObjectData.Length; i++)
  6636. {
  6637. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6638. }
  6639. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6640. if (handlerDelinkObjects != null)
  6641. {
  6642. handlerDelinkObjects(prims, this);
  6643. }
  6644. return true;
  6645. }
  6646. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6647. {
  6648. if (OnAddPrim != null)
  6649. {
  6650. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6651. #region Packet Session and User Check
  6652. if (m_checkPackets)
  6653. {
  6654. if (addPacket.AgentData.SessionID != SessionId ||
  6655. addPacket.AgentData.AgentID != AgentId)
  6656. return true;
  6657. }
  6658. #endregion
  6659. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6660. // m_log.Info("[REZData]: " + addPacket.ToString());
  6661. //BypassRaycast: 1
  6662. //RayStart: <69.79469, 158.2652, 98.40343>
  6663. //RayEnd: <61.97724, 141.995, 92.58341>
  6664. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6665. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6666. //object from rezing initially
  6667. AddNewPrim handlerAddPrim = OnAddPrim;
  6668. if (handlerAddPrim != null)
  6669. handlerAddPrim(AgentId, addPacket.AgentData.GroupID, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6670. }
  6671. return true;
  6672. }
  6673. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6674. {
  6675. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6676. #region Packet Session and User Check
  6677. if (m_checkPackets)
  6678. {
  6679. if (shapePacket.AgentData.SessionID != SessionId ||
  6680. shapePacket.AgentData.AgentID != AgentId)
  6681. return true;
  6682. }
  6683. #endregion
  6684. UpdateShape handlerUpdatePrimShape = null;
  6685. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6686. {
  6687. handlerUpdatePrimShape = OnUpdatePrimShape;
  6688. if (handlerUpdatePrimShape != null)
  6689. {
  6690. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6691. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6692. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6693. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6694. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6695. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6696. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6697. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6698. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6699. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6700. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6701. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6702. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6703. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6704. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6705. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6706. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6707. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6708. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6709. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6710. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6711. shapeData);
  6712. }
  6713. }
  6714. return true;
  6715. }
  6716. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6717. {
  6718. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6719. #region Packet Session and User Check
  6720. if (m_checkPackets)
  6721. {
  6722. if (extraPar.AgentData.SessionID != SessionId ||
  6723. extraPar.AgentData.AgentID != AgentId)
  6724. return true;
  6725. }
  6726. #endregion
  6727. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6728. if (handlerUpdateExtraParams != null)
  6729. {
  6730. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6731. {
  6732. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6733. extraPar.ObjectData[i].ParamType,
  6734. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6735. }
  6736. }
  6737. return true;
  6738. }
  6739. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6740. {
  6741. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6742. #region Packet Session and User Check
  6743. if (m_checkPackets)
  6744. {
  6745. if (dupe.AgentData.SessionID != SessionId ||
  6746. dupe.AgentData.AgentID != AgentId)
  6747. return true;
  6748. }
  6749. #endregion
  6750. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6751. ObjectDuplicate handlerObjectDuplicate = null;
  6752. handlerObjectDuplicate = OnObjectDuplicate;
  6753. if (handlerObjectDuplicate != null)
  6754. {
  6755. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6756. {
  6757. UUID rezGroupID = dupe.AgentData.GroupID;
  6758. if(!IsGroupMember(rezGroupID))
  6759. rezGroupID = UUID.Zero;
  6760. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6761. dupe.SharedData.DuplicateFlags, AgentId,
  6762. rezGroupID);
  6763. }
  6764. }
  6765. return true;
  6766. }
  6767. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6768. {
  6769. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6770. #region Packet Session and User Check
  6771. if (m_checkPackets)
  6772. {
  6773. if (incomingRequest.AgentData.SessionID != SessionId ||
  6774. incomingRequest.AgentData.AgentID != AgentId)
  6775. return true;
  6776. }
  6777. #endregion
  6778. ObjectRequest handlerObjectRequest = null;
  6779. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6780. {
  6781. handlerObjectRequest = OnObjectRequest;
  6782. if (handlerObjectRequest != null)
  6783. {
  6784. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6785. }
  6786. }
  6787. return true;
  6788. }
  6789. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6790. {
  6791. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6792. #region Packet Session and User Check
  6793. if (m_checkPackets)
  6794. {
  6795. if (incomingselect.AgentData.SessionID != SessionId ||
  6796. incomingselect.AgentData.AgentID != AgentId)
  6797. return true;
  6798. }
  6799. #endregion
  6800. List<uint> thisSelection = new List<uint>();
  6801. ObjectSelect handlerObjectSelect = null;
  6802. uint objID;
  6803. handlerObjectSelect = OnObjectSelect;
  6804. if (handlerObjectSelect != null)
  6805. {
  6806. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6807. {
  6808. objID = incomingselect.ObjectData[i].ObjectLocalID;
  6809. thisSelection.Add(objID);
  6810. }
  6811. handlerObjectSelect(thisSelection, this);
  6812. }
  6813. return true;
  6814. }
  6815. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6816. {
  6817. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6818. #region Packet Session and User Check
  6819. if (m_checkPackets)
  6820. {
  6821. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6822. incomingdeselect.AgentData.AgentID != AgentId)
  6823. return true;
  6824. }
  6825. #endregion
  6826. ObjectDeselect handlerObjectDeselect = null;
  6827. uint objID;
  6828. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6829. {
  6830. objID = incomingdeselect.ObjectData[i].ObjectLocalID;
  6831. handlerObjectDeselect = OnObjectDeselect;
  6832. if (handlerObjectDeselect != null)
  6833. {
  6834. OnObjectDeselect(objID, this);
  6835. }
  6836. }
  6837. return true;
  6838. }
  6839. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6840. {
  6841. // DEPRECATED: but till libsecondlife removes it, people will use it
  6842. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6843. #region Packet Session and User Check
  6844. if (m_checkPackets)
  6845. {
  6846. if (position.AgentData.SessionID != SessionId ||
  6847. position.AgentData.AgentID != AgentId)
  6848. return true;
  6849. }
  6850. #endregion
  6851. for (int i = 0; i < position.ObjectData.Length; i++)
  6852. {
  6853. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6854. if (handlerUpdateVector != null)
  6855. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6856. }
  6857. return true;
  6858. }
  6859. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6860. {
  6861. // DEPRECATED: but till libsecondlife removes it, people will use it
  6862. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6863. #region Packet Session and User Check
  6864. if (m_checkPackets)
  6865. {
  6866. if (scale.AgentData.SessionID != SessionId ||
  6867. scale.AgentData.AgentID != AgentId)
  6868. return true;
  6869. }
  6870. #endregion
  6871. for (int i = 0; i < scale.ObjectData.Length; i++)
  6872. {
  6873. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6874. if (handlerUpdatePrimGroupScale != null)
  6875. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6876. }
  6877. return true;
  6878. }
  6879. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6880. {
  6881. // DEPRECATED: but till libsecondlife removes it, people will use it
  6882. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6883. #region Packet Session and User Check
  6884. if (m_checkPackets)
  6885. {
  6886. if (rotation.AgentData.SessionID != SessionId ||
  6887. rotation.AgentData.AgentID != AgentId)
  6888. return true;
  6889. }
  6890. #endregion
  6891. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6892. {
  6893. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6894. if (handlerUpdatePrimRotation != null)
  6895. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6896. }
  6897. return true;
  6898. }
  6899. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6900. {
  6901. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6902. #region Packet Session and User Check
  6903. if (m_checkPackets)
  6904. {
  6905. if (flags.AgentData.SessionID != SessionId ||
  6906. flags.AgentData.AgentID != AgentId)
  6907. return true;
  6908. }
  6909. #endregion
  6910. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6911. if (handlerUpdatePrimFlags != null)
  6912. {
  6913. // byte[] data = Pack.ToBytes();
  6914. // 46,47,48 are special positions within the packet
  6915. // This may change so perhaps we need a better way
  6916. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6917. /*
  6918. bool UsePhysics = (data[46] != 0) ? true : false;
  6919. bool IsTemporary = (data[47] != 0) ? true : false;
  6920. bool IsPhantom = (data[48] != 0) ? true : false;
  6921. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6922. */
  6923. bool UsePhysics = flags.AgentData.UsePhysics;
  6924. bool IsPhantom = flags.AgentData.IsPhantom;
  6925. bool IsTemporary = flags.AgentData.IsTemporary;
  6926. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6927. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6928. if (blocks == null || blocks.Length == 0)
  6929. {
  6930. physdata.PhysShapeType = PhysShapeType.invalid;
  6931. }
  6932. else
  6933. {
  6934. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6935. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6936. physdata.Bounce = phsblock.Restitution;
  6937. physdata.Density = phsblock.Density;
  6938. physdata.Friction = phsblock.Friction;
  6939. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6940. }
  6941. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6942. }
  6943. return true;
  6944. }
  6945. Dictionary<uint, uint> objImageSeqs = null;
  6946. double lastobjImageSeqsMS = 0.0;
  6947. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6948. {
  6949. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6950. UpdatePrimTexture handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6951. if (handlerUpdatePrimTexture == null)
  6952. return true;
  6953. double now = Util.GetTimeStampMS();
  6954. if(objImageSeqs == null || ( now - lastobjImageSeqsMS > 30000.0))
  6955. {
  6956. objImageSeqs = null; // yeah i know superstition...
  6957. objImageSeqs = new Dictionary<uint, uint>(16);
  6958. }
  6959. lastobjImageSeqsMS = now;
  6960. uint seq = Pack.Header.Sequence;
  6961. uint id;
  6962. uint lastseq;
  6963. ObjectImagePacket.ObjectDataBlock o;
  6964. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6965. {
  6966. o = imagePack.ObjectData[i];
  6967. id = o.ObjectLocalID;
  6968. if(objImageSeqs.TryGetValue(id, out lastseq))
  6969. {
  6970. if(seq <= lastseq)
  6971. continue;
  6972. }
  6973. objImageSeqs[id] = seq;
  6974. handlerUpdatePrimTexture(id, o.TextureEntry, this);
  6975. }
  6976. return true;
  6977. }
  6978. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6979. {
  6980. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6981. #region Packet Session and User Check
  6982. if (m_checkPackets)
  6983. {
  6984. if (grab.AgentData.SessionID != SessionId ||
  6985. grab.AgentData.AgentID != AgentId)
  6986. return true;
  6987. }
  6988. #endregion
  6989. GrabObject handlerGrabObject = OnGrabObject;
  6990. if (handlerGrabObject != null)
  6991. {
  6992. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6993. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6994. {
  6995. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6996. {
  6997. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6998. arg.Binormal = surfaceInfo.Binormal;
  6999. arg.FaceIndex = surfaceInfo.FaceIndex;
  7000. arg.Normal = surfaceInfo.Normal;
  7001. arg.Position = surfaceInfo.Position;
  7002. arg.STCoord = surfaceInfo.STCoord;
  7003. arg.UVCoord = surfaceInfo.UVCoord;
  7004. touchArgs.Add(arg);
  7005. }
  7006. }
  7007. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  7008. }
  7009. return true;
  7010. }
  7011. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  7012. {
  7013. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  7014. #region Packet Session and User Check
  7015. if (m_checkPackets)
  7016. {
  7017. if (grabUpdate.AgentData.SessionID != SessionId ||
  7018. grabUpdate.AgentData.AgentID != AgentId)
  7019. return true;
  7020. }
  7021. #endregion
  7022. MoveObject handlerGrabUpdate = OnGrabUpdate;
  7023. if (handlerGrabUpdate != null)
  7024. {
  7025. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  7026. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  7027. {
  7028. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  7029. {
  7030. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  7031. arg.Binormal = surfaceInfo.Binormal;
  7032. arg.FaceIndex = surfaceInfo.FaceIndex;
  7033. arg.Normal = surfaceInfo.Normal;
  7034. arg.Position = surfaceInfo.Position;
  7035. arg.STCoord = surfaceInfo.STCoord;
  7036. arg.UVCoord = surfaceInfo.UVCoord;
  7037. touchArgs.Add(arg);
  7038. }
  7039. }
  7040. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  7041. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  7042. }
  7043. return true;
  7044. }
  7045. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  7046. {
  7047. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  7048. #region Packet Session and User Check
  7049. if (m_checkPackets)
  7050. {
  7051. if (deGrab.AgentData.SessionID != SessionId ||
  7052. deGrab.AgentData.AgentID != AgentId)
  7053. return true;
  7054. }
  7055. #endregion
  7056. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  7057. if (handlerDeGrabObject != null)
  7058. {
  7059. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  7060. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  7061. {
  7062. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  7063. {
  7064. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  7065. arg.Binormal = surfaceInfo.Binormal;
  7066. arg.FaceIndex = surfaceInfo.FaceIndex;
  7067. arg.Normal = surfaceInfo.Normal;
  7068. arg.Position = surfaceInfo.Position;
  7069. arg.STCoord = surfaceInfo.STCoord;
  7070. arg.UVCoord = surfaceInfo.UVCoord;
  7071. touchArgs.Add(arg);
  7072. }
  7073. }
  7074. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  7075. }
  7076. return true;
  7077. }
  7078. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  7079. {
  7080. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  7081. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  7082. #region Packet Session and User Check
  7083. if (m_checkPackets)
  7084. {
  7085. if (spinStart.AgentData.SessionID != SessionId ||
  7086. spinStart.AgentData.AgentID != AgentId)
  7087. return true;
  7088. }
  7089. #endregion
  7090. SpinStart handlerSpinStart = OnSpinStart;
  7091. if (handlerSpinStart != null)
  7092. {
  7093. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  7094. }
  7095. return true;
  7096. }
  7097. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  7098. {
  7099. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  7100. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  7101. #region Packet Session and User Check
  7102. if (m_checkPackets)
  7103. {
  7104. if (spinUpdate.AgentData.SessionID != SessionId ||
  7105. spinUpdate.AgentData.AgentID != AgentId)
  7106. return true;
  7107. }
  7108. #endregion
  7109. Vector3 axis;
  7110. float angle;
  7111. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  7112. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  7113. SpinObject handlerSpinUpdate = OnSpinUpdate;
  7114. if (handlerSpinUpdate != null)
  7115. {
  7116. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  7117. }
  7118. return true;
  7119. }
  7120. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  7121. {
  7122. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  7123. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  7124. #region Packet Session and User Check
  7125. if (m_checkPackets)
  7126. {
  7127. if (spinStop.AgentData.SessionID != SessionId ||
  7128. spinStop.AgentData.AgentID != AgentId)
  7129. return true;
  7130. }
  7131. #endregion
  7132. SpinStop handlerSpinStop = OnSpinStop;
  7133. if (handlerSpinStop != null)
  7134. {
  7135. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  7136. }
  7137. return true;
  7138. }
  7139. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  7140. {
  7141. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  7142. #region Packet Session and User Check
  7143. if (m_checkPackets)
  7144. {
  7145. if (objDes.AgentData.SessionID != SessionId ||
  7146. objDes.AgentData.AgentID != AgentId)
  7147. return true;
  7148. }
  7149. #endregion
  7150. GenericCall7 handlerObjectDescription = null;
  7151. for (int i = 0; i < objDes.ObjectData.Length; i++)
  7152. {
  7153. handlerObjectDescription = OnObjectDescription;
  7154. if (handlerObjectDescription != null)
  7155. {
  7156. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  7157. Util.FieldToString(objDes.ObjectData[i].Description));
  7158. }
  7159. }
  7160. return true;
  7161. }
  7162. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  7163. {
  7164. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  7165. #region Packet Session and User Check
  7166. if (m_checkPackets)
  7167. {
  7168. if (objName.AgentData.SessionID != SessionId ||
  7169. objName.AgentData.AgentID != AgentId)
  7170. return true;
  7171. }
  7172. #endregion
  7173. GenericCall7 handlerObjectName = null;
  7174. for (int i = 0; i < objName.ObjectData.Length; i++)
  7175. {
  7176. handlerObjectName = OnObjectName;
  7177. if (handlerObjectName != null)
  7178. {
  7179. handlerObjectName(this, objName.ObjectData[i].LocalID,
  7180. Util.FieldToString(objName.ObjectData[i].Name));
  7181. }
  7182. }
  7183. return true;
  7184. }
  7185. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  7186. {
  7187. if (OnObjectPermissions != null)
  7188. {
  7189. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  7190. #region Packet Session and User Check
  7191. if (m_checkPackets)
  7192. {
  7193. if (newobjPerms.AgentData.SessionID != SessionId ||
  7194. newobjPerms.AgentData.AgentID != AgentId)
  7195. return true;
  7196. }
  7197. #endregion
  7198. UUID AgentID = newobjPerms.AgentData.AgentID;
  7199. UUID SessionID = newobjPerms.AgentData.SessionID;
  7200. ObjectPermissions handlerObjectPermissions = null;
  7201. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  7202. {
  7203. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  7204. byte field = permChanges.Field;
  7205. uint localID = permChanges.ObjectLocalID;
  7206. uint mask = permChanges.Mask;
  7207. byte set = permChanges.Set;
  7208. handlerObjectPermissions = OnObjectPermissions;
  7209. if (handlerObjectPermissions != null)
  7210. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  7211. }
  7212. }
  7213. // Here's our data,
  7214. // PermField contains the field the info goes into
  7215. // PermField determines which mask we're changing
  7216. //
  7217. // chmask is the mask of the change
  7218. // setTF is whether we're adding it or taking it away
  7219. //
  7220. // objLocalID is the localID of the object.
  7221. // Unfortunately, we have to pass the event the packet because objData is an array
  7222. // That means multiple object perms may be updated in a single packet.
  7223. return true;
  7224. }
  7225. private bool HandleUndo(IClientAPI sender, Packet Pack)
  7226. {
  7227. UndoPacket undoitem = (UndoPacket)Pack;
  7228. #region Packet Session and User Check
  7229. if (m_checkPackets)
  7230. {
  7231. if (undoitem.AgentData.SessionID != SessionId ||
  7232. undoitem.AgentData.AgentID != AgentId)
  7233. return true;
  7234. }
  7235. #endregion
  7236. if (undoitem.ObjectData.Length > 0)
  7237. {
  7238. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  7239. {
  7240. UUID objiD = undoitem.ObjectData[i].ObjectID;
  7241. AgentSit handlerOnUndo = OnUndo;
  7242. if (handlerOnUndo != null)
  7243. {
  7244. handlerOnUndo(this, objiD);
  7245. }
  7246. }
  7247. }
  7248. return true;
  7249. }
  7250. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  7251. {
  7252. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  7253. #region Packet Session and User Check
  7254. if (m_checkPackets)
  7255. {
  7256. if (undolanditem.AgentData.SessionID != SessionId ||
  7257. undolanditem.AgentData.AgentID != AgentId)
  7258. return true;
  7259. }
  7260. #endregion
  7261. LandUndo handlerOnUndo = OnLandUndo;
  7262. if (handlerOnUndo != null)
  7263. {
  7264. handlerOnUndo(this);
  7265. }
  7266. return true;
  7267. }
  7268. private bool HandleRedo(IClientAPI sender, Packet Pack)
  7269. {
  7270. RedoPacket redoitem = (RedoPacket)Pack;
  7271. #region Packet Session and User Check
  7272. if (m_checkPackets)
  7273. {
  7274. if (redoitem.AgentData.SessionID != SessionId ||
  7275. redoitem.AgentData.AgentID != AgentId)
  7276. return true;
  7277. }
  7278. #endregion
  7279. if (redoitem.ObjectData.Length > 0)
  7280. {
  7281. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  7282. {
  7283. UUID objiD = redoitem.ObjectData[i].ObjectID;
  7284. AgentSit handlerOnRedo = OnRedo;
  7285. if (handlerOnRedo != null)
  7286. {
  7287. handlerOnRedo(this, objiD);
  7288. }
  7289. }
  7290. }
  7291. return true;
  7292. }
  7293. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  7294. {
  7295. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  7296. #region Packet Session and User Check
  7297. if (m_checkPackets)
  7298. {
  7299. if (dupeOnRay.AgentData.SessionID != SessionId ||
  7300. dupeOnRay.AgentData.AgentID != AgentId)
  7301. return true;
  7302. }
  7303. #endregion
  7304. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  7305. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  7306. {
  7307. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  7308. if (handlerObjectDuplicateOnRay != null)
  7309. {
  7310. UUID rezGroupID = dupeOnRay.AgentData.GroupID;
  7311. if(!IsGroupMember(rezGroupID))
  7312. rezGroupID = UUID.Zero;
  7313. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID,
  7314. dupeOnRay.AgentData.DuplicateFlags, AgentId, rezGroupID,
  7315. dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  7316. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast,
  7317. dupeOnRay.AgentData.RayEndIsIntersection,
  7318. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  7319. }
  7320. }
  7321. return true;
  7322. }
  7323. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  7324. {
  7325. //This powers the little tooltip that appears when you move your mouse over an object
  7326. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  7327. #region Packet Session and User Check
  7328. if (m_checkPackets)
  7329. {
  7330. if (packToolTip.AgentData.SessionID != SessionId ||
  7331. packToolTip.AgentData.AgentID != AgentId)
  7332. return true;
  7333. }
  7334. #endregion
  7335. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  7336. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  7337. if (handlerRequestObjectPropertiesFamily != null)
  7338. {
  7339. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  7340. packObjBlock.ObjectID);
  7341. }
  7342. return true;
  7343. }
  7344. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  7345. {
  7346. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  7347. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  7348. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  7349. #region Packet Session and User Check
  7350. if (m_checkPackets)
  7351. {
  7352. if (packInSearch.AgentData.SessionID != SessionId ||
  7353. packInSearch.AgentData.AgentID != AgentId)
  7354. return true;
  7355. }
  7356. #endregion
  7357. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  7358. {
  7359. bool inSearch = objData.IncludeInSearch;
  7360. uint localID = objData.ObjectLocalID;
  7361. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  7362. if (handlerObjectIncludeInSearch != null)
  7363. {
  7364. handlerObjectIncludeInSearch(this, inSearch, localID);
  7365. }
  7366. }
  7367. return true;
  7368. }
  7369. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  7370. {
  7371. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  7372. #region Packet Session and User Check
  7373. if (m_checkPackets)
  7374. {
  7375. if (scriptAnswer.AgentData.SessionID != SessionId ||
  7376. scriptAnswer.AgentData.AgentID != AgentId)
  7377. return true;
  7378. }
  7379. #endregion
  7380. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  7381. if (handlerScriptAnswer != null)
  7382. {
  7383. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  7384. }
  7385. return true;
  7386. }
  7387. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  7388. {
  7389. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  7390. #region Packet Session and User Check
  7391. if (m_checkPackets)
  7392. {
  7393. if (ocpacket.AgentData.SessionID != SessionId ||
  7394. ocpacket.AgentData.AgentID != AgentId)
  7395. return true;
  7396. }
  7397. #endregion
  7398. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  7399. if (handlerObjectClickAction != null)
  7400. {
  7401. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  7402. {
  7403. byte action = odata.ClickAction;
  7404. uint localID = odata.ObjectLocalID;
  7405. handlerObjectClickAction(this, localID, action.ToString());
  7406. }
  7407. }
  7408. return true;
  7409. }
  7410. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  7411. {
  7412. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  7413. #region Packet Session and User Check
  7414. if (m_checkPackets)
  7415. {
  7416. if (ompacket.AgentData.SessionID != SessionId ||
  7417. ompacket.AgentData.AgentID != AgentId)
  7418. return true;
  7419. }
  7420. #endregion
  7421. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  7422. if (handlerObjectMaterial != null)
  7423. {
  7424. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  7425. {
  7426. byte material = odata.Material;
  7427. uint localID = odata.ObjectLocalID;
  7428. handlerObjectMaterial(this, localID, material.ToString());
  7429. }
  7430. }
  7431. return true;
  7432. }
  7433. #endregion Objects/m_sceneObjects
  7434. #region Inventory/Asset/Other related packets
  7435. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  7436. {
  7437. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  7438. //m_log.Debug("image request: " + Pack.ToString());
  7439. #region Packet Session and User Check
  7440. if (m_checkPackets)
  7441. {
  7442. if (imageRequest.AgentData.SessionID != SessionId ||
  7443. imageRequest.AgentData.AgentID != AgentId)
  7444. return true;
  7445. }
  7446. #endregion
  7447. //handlerTextureRequest = null;
  7448. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  7449. {
  7450. TextureRequestArgs args = new TextureRequestArgs();
  7451. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  7452. args.RequestedAssetID = block.Image;
  7453. args.DiscardLevel = block.DiscardLevel;
  7454. args.PacketNumber = block.Packet;
  7455. args.Priority = block.DownloadPriority;
  7456. args.requestSequence = imageRequest.Header.Sequence;
  7457. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  7458. // priority of avatar textures to get avatars rezzing in faster than the
  7459. // surrounding scene
  7460. if ((ImageType)block.Type == ImageType.Baked)
  7461. args.Priority *= 2.0f;
  7462. ImageManager.EnqueueReq(args);
  7463. }
  7464. return true;
  7465. }
  7466. /// <summary>
  7467. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  7468. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  7469. /// </summary>
  7470. /// <param name="sender"></param>
  7471. /// <param name="Pack"></param>
  7472. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  7473. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  7474. {
  7475. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  7476. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  7477. UUID taskID = UUID.Zero;
  7478. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  7479. {
  7480. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  7481. {
  7482. // We're spawning a thread because the permissions check can block this thread
  7483. Util.FireAndForget(delegate
  7484. {
  7485. // This requests the asset if needed
  7486. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  7487. }, null, "LLClientView.HandleTransferRequest");
  7488. return true;
  7489. }
  7490. }
  7491. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  7492. {
  7493. //TransferRequestPacket does not include covenant uuid?
  7494. //get scene covenant uuid
  7495. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  7496. }
  7497. // This is non-blocking
  7498. MakeAssetRequest(transfer, taskID);
  7499. return true;
  7500. }
  7501. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  7502. {
  7503. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  7504. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  7505. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  7506. //m_log.DebugFormat(
  7507. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  7508. // requestID, itemID, taskID, Name);
  7509. //m_log.Debug("Transfer Request: " + transfer.ToString());
  7510. // Validate inventory transfers
  7511. // Has to be done here, because AssetCache can't do it
  7512. //
  7513. if (taskID != UUID.Zero) // Prim
  7514. {
  7515. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  7516. if (part == null)
  7517. {
  7518. m_log.WarnFormat(
  7519. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  7520. Name, requestID, itemID, taskID);
  7521. return;
  7522. }
  7523. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  7524. if (tii == null)
  7525. {
  7526. m_log.WarnFormat(
  7527. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  7528. Name, requestID, itemID, taskID);
  7529. return;
  7530. }
  7531. if (tii.Type == (int)AssetType.LSLText)
  7532. {
  7533. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  7534. return;
  7535. }
  7536. else if (tii.Type == (int)AssetType.Notecard)
  7537. {
  7538. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  7539. return;
  7540. }
  7541. else
  7542. {
  7543. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  7544. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  7545. if (part.OwnerID != AgentId)
  7546. {
  7547. m_log.WarnFormat(
  7548. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  7549. Name, requestID, itemID, taskID, part.OwnerID);
  7550. return;
  7551. }
  7552. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  7553. {
  7554. m_log.WarnFormat(
  7555. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  7556. Name, requestID, itemID, taskID);
  7557. return;
  7558. }
  7559. if (tii.OwnerID != AgentId)
  7560. {
  7561. m_log.WarnFormat(
  7562. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  7563. Name, requestID, itemID, taskID, tii.OwnerID);
  7564. return;
  7565. }
  7566. if ((
  7567. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  7568. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  7569. {
  7570. m_log.WarnFormat(
  7571. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  7572. Name, requestID, itemID, taskID);
  7573. return;
  7574. }
  7575. if (tii.AssetID != requestID)
  7576. {
  7577. m_log.WarnFormat(
  7578. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  7579. Name, requestID, itemID, taskID, tii.AssetID);
  7580. return;
  7581. }
  7582. }
  7583. }
  7584. else // Agent
  7585. {
  7586. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  7587. if (invAccess != null)
  7588. {
  7589. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  7590. return;
  7591. }
  7592. else
  7593. {
  7594. return;
  7595. }
  7596. }
  7597. // Permissions out of the way, let's request the asset
  7598. MakeAssetRequest(transfer, taskID);
  7599. }
  7600. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  7601. {
  7602. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  7603. // m_log.Debug("upload request " + request.ToString());
  7604. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  7605. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  7606. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  7607. if (handlerAssetUploadRequest != null)
  7608. {
  7609. handlerAssetUploadRequest(this, temp,
  7610. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  7611. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  7612. request.AssetBlock.Tempfile);
  7613. }
  7614. return true;
  7615. }
  7616. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  7617. {
  7618. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  7619. RequestXfer handlerRequestXfer = OnRequestXfer;
  7620. if (handlerRequestXfer != null)
  7621. {
  7622. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  7623. }
  7624. return true;
  7625. }
  7626. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  7627. {
  7628. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  7629. XferReceive handlerXferReceive = OnXferReceive;
  7630. if (handlerXferReceive != null)
  7631. {
  7632. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  7633. }
  7634. return true;
  7635. }
  7636. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  7637. {
  7638. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  7639. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  7640. if (handlerConfirmXfer != null)
  7641. {
  7642. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  7643. }
  7644. return true;
  7645. }
  7646. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  7647. {
  7648. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  7649. AbortXfer handlerAbortXfer = OnAbortXfer;
  7650. if (handlerAbortXfer != null)
  7651. {
  7652. handlerAbortXfer(this, abortXfer.XferID.ID);
  7653. }
  7654. return true;
  7655. }
  7656. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7657. {
  7658. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7659. #region Packet Session and User Check
  7660. if (m_checkPackets)
  7661. {
  7662. if (invFolder.AgentData.SessionID != SessionId ||
  7663. invFolder.AgentData.AgentID != AgentId)
  7664. return true;
  7665. }
  7666. #endregion
  7667. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7668. if (handlerCreateInventoryFolder != null)
  7669. {
  7670. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7671. (ushort)invFolder.FolderData.Type,
  7672. Util.FieldToString(invFolder.FolderData.Name),
  7673. invFolder.FolderData.ParentID);
  7674. }
  7675. return true;
  7676. }
  7677. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7678. {
  7679. if (OnUpdateInventoryFolder != null)
  7680. {
  7681. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7682. #region Packet Session and User Check
  7683. if (m_checkPackets)
  7684. {
  7685. if (invFolderx.AgentData.SessionID != SessionId ||
  7686. invFolderx.AgentData.AgentID != AgentId)
  7687. return true;
  7688. }
  7689. #endregion
  7690. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7691. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7692. {
  7693. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7694. if (handlerUpdateInventoryFolder != null)
  7695. {
  7696. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7697. (ushort)invFolderx.FolderData[i].Type,
  7698. Util.FieldToString(invFolderx.FolderData[i].Name),
  7699. invFolderx.FolderData[i].ParentID);
  7700. }
  7701. }
  7702. }
  7703. return true;
  7704. }
  7705. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7706. {
  7707. if (OnMoveInventoryFolder != null)
  7708. {
  7709. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7710. #region Packet Session and User Check
  7711. if (m_checkPackets)
  7712. {
  7713. if (invFoldery.AgentData.SessionID != SessionId ||
  7714. invFoldery.AgentData.AgentID != AgentId)
  7715. return true;
  7716. }
  7717. #endregion
  7718. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7719. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7720. {
  7721. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7722. if (handlerMoveInventoryFolder != null)
  7723. {
  7724. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7725. invFoldery.InventoryData[i].ParentID);
  7726. }
  7727. }
  7728. }
  7729. return true;
  7730. }
  7731. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7732. {
  7733. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7734. #region Packet Session and User Check
  7735. if (m_checkPackets)
  7736. {
  7737. if (createItem.AgentData.SessionID != SessionId ||
  7738. createItem.AgentData.AgentID != AgentId)
  7739. return true;
  7740. }
  7741. #endregion
  7742. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7743. if (handlerCreateNewInventoryItem != null)
  7744. {
  7745. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7746. createItem.InventoryBlock.FolderID,
  7747. createItem.InventoryBlock.CallbackID,
  7748. Util.FieldToString(createItem.InventoryBlock.Description),
  7749. Util.FieldToString(createItem.InventoryBlock.Name),
  7750. createItem.InventoryBlock.InvType,
  7751. createItem.InventoryBlock.Type,
  7752. createItem.InventoryBlock.WearableType,
  7753. createItem.InventoryBlock.NextOwnerMask,
  7754. Util.UnixTimeSinceEpoch());
  7755. }
  7756. return true;
  7757. }
  7758. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7759. {
  7760. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7761. #region Packet Session and User Check
  7762. if (m_checkPackets)
  7763. {
  7764. if (createLink.AgentData.SessionID != SessionId ||
  7765. createLink.AgentData.AgentID != AgentId)
  7766. return true;
  7767. }
  7768. #endregion
  7769. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7770. if (linkInventoryItem != null)
  7771. {
  7772. linkInventoryItem(
  7773. this,
  7774. createLink.InventoryBlock.TransactionID,
  7775. createLink.InventoryBlock.FolderID,
  7776. createLink.InventoryBlock.CallbackID,
  7777. Util.FieldToString(createLink.InventoryBlock.Description),
  7778. Util.FieldToString(createLink.InventoryBlock.Name),
  7779. createLink.InventoryBlock.InvType,
  7780. createLink.InventoryBlock.Type,
  7781. createLink.InventoryBlock.OldItemID);
  7782. }
  7783. return true;
  7784. }
  7785. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7786. {
  7787. if (OnFetchInventory != null)
  7788. {
  7789. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7790. #region Packet Session and User Check
  7791. if (m_checkPackets)
  7792. {
  7793. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7794. FetchInventoryx.AgentData.AgentID != AgentId)
  7795. return true;
  7796. }
  7797. #endregion
  7798. FetchInventory handlerFetchInventory = null;
  7799. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7800. {
  7801. handlerFetchInventory = OnFetchInventory;
  7802. if (handlerFetchInventory != null)
  7803. {
  7804. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7805. FetchInventoryx.InventoryData[i].OwnerID);
  7806. }
  7807. }
  7808. }
  7809. return true;
  7810. }
  7811. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7812. {
  7813. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7814. #region Packet Session and User Check
  7815. if (m_checkPackets)
  7816. {
  7817. if (Fetch.AgentData.SessionID != SessionId ||
  7818. Fetch.AgentData.AgentID != AgentId)
  7819. return true;
  7820. }
  7821. #endregion
  7822. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7823. if (handlerFetchInventoryDescendents != null)
  7824. {
  7825. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7826. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7827. Fetch.InventoryData.SortOrder);
  7828. }
  7829. return true;
  7830. }
  7831. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7832. {
  7833. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7834. #region Packet Session and User Check
  7835. if (m_checkPackets)
  7836. {
  7837. if (Purge.AgentData.SessionID != SessionId ||
  7838. Purge.AgentData.AgentID != AgentId)
  7839. return true;
  7840. }
  7841. #endregion
  7842. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7843. if (handlerPurgeInventoryDescendents != null)
  7844. {
  7845. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7846. }
  7847. return true;
  7848. }
  7849. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7850. {
  7851. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7852. #region Packet Session and User Check
  7853. if (m_checkPackets)
  7854. {
  7855. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7856. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7857. return true;
  7858. }
  7859. #endregion
  7860. if (OnUpdateInventoryItem != null)
  7861. {
  7862. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7863. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7864. {
  7865. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7866. if (handlerUpdateInventoryItem != null)
  7867. {
  7868. InventoryItemBase itemUpd = new InventoryItemBase();
  7869. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7870. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7871. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7872. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7873. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7874. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7875. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7876. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7877. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7878. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7879. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7880. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7881. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7882. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7883. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7884. inventoryItemUpdate.InventoryData[i].ItemID,
  7885. itemUpd);
  7886. }
  7887. }
  7888. }
  7889. return true;
  7890. }
  7891. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7892. {
  7893. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7894. #region Packet Session and User Check
  7895. if (m_checkPackets)
  7896. {
  7897. if (copyitem.AgentData.SessionID != SessionId ||
  7898. copyitem.AgentData.AgentID != AgentId)
  7899. return true;
  7900. }
  7901. #endregion
  7902. CopyInventoryItem handlerCopyInventoryItem = null;
  7903. if (OnCopyInventoryItem != null)
  7904. {
  7905. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7906. {
  7907. handlerCopyInventoryItem = OnCopyInventoryItem;
  7908. if (handlerCopyInventoryItem != null)
  7909. {
  7910. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7911. datablock.OldItemID, datablock.NewFolderID,
  7912. Util.FieldToString(datablock.NewName));
  7913. }
  7914. }
  7915. }
  7916. return true;
  7917. }
  7918. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7919. {
  7920. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7921. #region Packet Session and User Check
  7922. if (m_checkPackets)
  7923. {
  7924. if (moveitem.AgentData.SessionID != SessionId ||
  7925. moveitem.AgentData.AgentID != AgentId)
  7926. return true;
  7927. }
  7928. #endregion
  7929. if (OnMoveInventoryItem != null)
  7930. {
  7931. MoveInventoryItem handlerMoveInventoryItem = null;
  7932. InventoryItemBase itm = null;
  7933. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7934. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7935. {
  7936. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7937. itm.Folder = datablock.FolderID;
  7938. itm.Name = Util.FieldToString(datablock.NewName);
  7939. // weird, comes out as empty string
  7940. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7941. items.Add(itm);
  7942. }
  7943. handlerMoveInventoryItem = OnMoveInventoryItem;
  7944. if (handlerMoveInventoryItem != null)
  7945. {
  7946. handlerMoveInventoryItem(this, items);
  7947. }
  7948. }
  7949. return true;
  7950. }
  7951. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7952. {
  7953. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7954. #region Packet Session and User Check
  7955. if (m_checkPackets)
  7956. {
  7957. if (removeItem.AgentData.SessionID != SessionId ||
  7958. removeItem.AgentData.AgentID != AgentId)
  7959. return true;
  7960. }
  7961. #endregion
  7962. if (OnRemoveInventoryItem != null)
  7963. {
  7964. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7965. List<UUID> uuids = new List<UUID>();
  7966. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7967. {
  7968. uuids.Add(datablock.ItemID);
  7969. }
  7970. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7971. if (handlerRemoveInventoryItem != null)
  7972. {
  7973. handlerRemoveInventoryItem(this, uuids);
  7974. }
  7975. }
  7976. return true;
  7977. }
  7978. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7979. {
  7980. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7981. #region Packet Session and User Check
  7982. if (m_checkPackets)
  7983. {
  7984. if (removeFolder.AgentData.SessionID != SessionId ||
  7985. removeFolder.AgentData.AgentID != AgentId)
  7986. return true;
  7987. }
  7988. #endregion
  7989. if (OnRemoveInventoryFolder != null)
  7990. {
  7991. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7992. List<UUID> uuids = new List<UUID>();
  7993. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7994. {
  7995. uuids.Add(datablock.FolderID);
  7996. }
  7997. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7998. if (handlerRemoveInventoryFolder != null)
  7999. {
  8000. handlerRemoveInventoryFolder(this, uuids);
  8001. }
  8002. }
  8003. return true;
  8004. }
  8005. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  8006. {
  8007. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  8008. #region Packet Session and User Check
  8009. if (m_checkPackets)
  8010. {
  8011. if (removeObject.AgentData.SessionID != SessionId ||
  8012. removeObject.AgentData.AgentID != AgentId)
  8013. return true;
  8014. }
  8015. #endregion
  8016. if (OnRemoveInventoryFolder != null)
  8017. {
  8018. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  8019. List<UUID> uuids = new List<UUID>();
  8020. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  8021. {
  8022. uuids.Add(datablock.FolderID);
  8023. }
  8024. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  8025. if (handlerRemoveInventoryFolder != null)
  8026. {
  8027. handlerRemoveInventoryFolder(this, uuids);
  8028. }
  8029. }
  8030. if (OnRemoveInventoryItem != null)
  8031. {
  8032. RemoveInventoryItem handlerRemoveInventoryItem = null;
  8033. List<UUID> uuids = new List<UUID>();
  8034. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  8035. {
  8036. uuids.Add(datablock.ItemID);
  8037. }
  8038. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  8039. if (handlerRemoveInventoryItem != null)
  8040. {
  8041. handlerRemoveInventoryItem(this, uuids);
  8042. }
  8043. }
  8044. return true;
  8045. }
  8046. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  8047. {
  8048. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  8049. #region Packet Session and User Check
  8050. if (m_checkPackets)
  8051. {
  8052. if (requesttask.AgentData.SessionID != SessionId ||
  8053. requesttask.AgentData.AgentID != AgentId)
  8054. return true;
  8055. }
  8056. #endregion
  8057. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  8058. if (handlerRequestTaskInventory != null)
  8059. {
  8060. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  8061. }
  8062. return true;
  8063. }
  8064. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  8065. {
  8066. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  8067. #region Packet Session and User Check
  8068. if (m_checkPackets)
  8069. {
  8070. if (updatetask.AgentData.SessionID != SessionId ||
  8071. updatetask.AgentData.AgentID != AgentId)
  8072. return true;
  8073. }
  8074. #endregion
  8075. if (OnUpdateTaskInventory != null)
  8076. {
  8077. if (updatetask.UpdateData.Key == 0)
  8078. {
  8079. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  8080. if (handlerUpdateTaskInventory != null)
  8081. {
  8082. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  8083. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  8084. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  8085. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  8086. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  8087. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  8088. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  8089. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  8090. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  8091. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  8092. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  8093. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  8094. // different
  8095. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  8096. newTaskItem.Type = updatetask.InventoryData.Type;
  8097. newTaskItem.InvType = updatetask.InventoryData.InvType;
  8098. newTaskItem.Flags = updatetask.InventoryData.Flags;
  8099. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  8100. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  8101. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  8102. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  8103. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  8104. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  8105. newTaskItem, updatetask.UpdateData.LocalID);
  8106. }
  8107. }
  8108. }
  8109. return true;
  8110. }
  8111. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  8112. {
  8113. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  8114. #region Packet Session and User Check
  8115. if (m_checkPackets)
  8116. {
  8117. if (removeTask.AgentData.SessionID != SessionId ||
  8118. removeTask.AgentData.AgentID != AgentId)
  8119. return true;
  8120. }
  8121. #endregion
  8122. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  8123. if (handlerRemoveTaskItem != null)
  8124. {
  8125. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  8126. }
  8127. return true;
  8128. }
  8129. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  8130. {
  8131. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  8132. #region Packet Session and User Check
  8133. if (m_checkPackets)
  8134. {
  8135. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  8136. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  8137. return true;
  8138. }
  8139. #endregion
  8140. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  8141. if (handlerMoveTaskItem != null)
  8142. {
  8143. handlerMoveTaskItem(
  8144. this, moveTaskInventoryPacket.AgentData.FolderID,
  8145. moveTaskInventoryPacket.InventoryData.LocalID,
  8146. moveTaskInventoryPacket.InventoryData.ItemID);
  8147. }
  8148. return true;
  8149. }
  8150. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  8151. {
  8152. //m_log.Debug(Pack.ToString());
  8153. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  8154. #region Packet Session and User Check
  8155. if (m_checkPackets)
  8156. {
  8157. if (rezScriptx.AgentData.SessionID != SessionId ||
  8158. rezScriptx.AgentData.AgentID != AgentId)
  8159. return true;
  8160. }
  8161. #endregion
  8162. RezScript handlerRezScript = OnRezScript;
  8163. InventoryItemBase item = new InventoryItemBase();
  8164. item.ID = rezScriptx.InventoryBlock.ItemID;
  8165. item.Folder = rezScriptx.InventoryBlock.FolderID;
  8166. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  8167. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  8168. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  8169. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  8170. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  8171. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  8172. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  8173. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  8174. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  8175. item.AssetType = rezScriptx.InventoryBlock.Type;
  8176. item.InvType = rezScriptx.InventoryBlock.InvType;
  8177. item.Flags = rezScriptx.InventoryBlock.Flags;
  8178. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  8179. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  8180. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  8181. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  8182. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  8183. if (handlerRezScript != null)
  8184. {
  8185. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  8186. }
  8187. return true;
  8188. }
  8189. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  8190. {
  8191. RequestMapLayer();
  8192. return true;
  8193. }
  8194. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  8195. {
  8196. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  8197. #region Packet Session and User Check
  8198. if (m_checkPackets)
  8199. {
  8200. if (MapRequest.AgentData.SessionID != SessionId ||
  8201. MapRequest.AgentData.AgentID != AgentId)
  8202. return true;
  8203. }
  8204. #endregion
  8205. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  8206. if (handlerRequestMapBlocks != null)
  8207. {
  8208. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  8209. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  8210. }
  8211. return true;
  8212. }
  8213. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  8214. {
  8215. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  8216. #region Packet Session and User Check
  8217. if (m_checkPackets)
  8218. {
  8219. if (map.AgentData.SessionID != SessionId ||
  8220. map.AgentData.AgentID != AgentId)
  8221. return true;
  8222. }
  8223. #endregion
  8224. string mapName = (map.NameData.Name.Length == 0) ? m_scene.RegionInfo.RegionName :
  8225. Util.UTF8.GetString(map.NameData.Name, 0, map.NameData.Name.Length - 1);
  8226. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  8227. if (handlerMapNameRequest != null)
  8228. {
  8229. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  8230. }
  8231. return true;
  8232. }
  8233. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  8234. {
  8235. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  8236. #region Packet Session and User Check
  8237. if (m_checkPackets)
  8238. {
  8239. if (tpReq.Info.SessionID != SessionId ||
  8240. tpReq.Info.AgentID != AgentId)
  8241. return true;
  8242. }
  8243. #endregion
  8244. UUID lmid = tpReq.Info.LandmarkID;
  8245. AssetLandmark lm;
  8246. if (lmid != UUID.Zero)
  8247. {
  8248. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  8249. AssetBase lma = m_assetService.Get(lmid.ToString());
  8250. if (lma == null)
  8251. {
  8252. // Failed to find landmark
  8253. // Let's try to search in the user's home asset server
  8254. lma = FindAssetInUserAssetServer(lmid.ToString());
  8255. if (lma == null)
  8256. {
  8257. // Really doesn't exist
  8258. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  8259. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  8260. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  8261. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  8262. }
  8263. }
  8264. try
  8265. {
  8266. lm = new AssetLandmark(lma);
  8267. }
  8268. catch (NullReferenceException)
  8269. {
  8270. // asset not found generates null ref inside the assetlandmark constructor.
  8271. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  8272. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  8273. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  8274. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  8275. return true;
  8276. }
  8277. }
  8278. else
  8279. {
  8280. // Teleport home request
  8281. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  8282. if (handlerTeleportHomeRequest != null)
  8283. {
  8284. handlerTeleportHomeRequest(AgentId, this);
  8285. }
  8286. return true;
  8287. }
  8288. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  8289. if (handlerTeleportLandmarkRequest != null)
  8290. {
  8291. handlerTeleportLandmarkRequest(this, lm);
  8292. }
  8293. else
  8294. {
  8295. //no event handler so cancel request
  8296. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  8297. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  8298. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  8299. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  8300. }
  8301. return true;
  8302. }
  8303. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  8304. {
  8305. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  8306. if (handlerTeleportCancel != null)
  8307. {
  8308. handlerTeleportCancel(this);
  8309. }
  8310. return true;
  8311. }
  8312. private AssetBase FindAssetInUserAssetServer(string id)
  8313. {
  8314. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  8315. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  8316. {
  8317. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  8318. if (!string.IsNullOrEmpty(assetServer))
  8319. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  8320. }
  8321. return null;
  8322. }
  8323. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  8324. {
  8325. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  8326. // m_log.Debug(tpLocReq.ToString());
  8327. #region Packet Session and User Check
  8328. if (m_checkPackets)
  8329. {
  8330. if (tpLocReq.AgentData.SessionID != SessionId ||
  8331. tpLocReq.AgentData.AgentID != AgentId)
  8332. return true;
  8333. }
  8334. #endregion
  8335. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  8336. if (handlerTeleportLocationRequest != null)
  8337. {
  8338. // Adjust teleport location to base of a larger region if requested to teleport to a sub-region
  8339. uint locX, locY;
  8340. Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out locX, out locY);
  8341. if ((locX >= m_scene.RegionInfo.WorldLocX)
  8342. && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX))
  8343. && (locY >= m_scene.RegionInfo.WorldLocY)
  8344. && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)))
  8345. {
  8346. tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle;
  8347. tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX;
  8348. tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY;
  8349. }
  8350. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  8351. tpLocReq.Info.LookAt, 16);
  8352. }
  8353. else
  8354. {
  8355. //no event handler so cancel request
  8356. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  8357. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  8358. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  8359. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  8360. }
  8361. return true;
  8362. }
  8363. #endregion Inventory/Asset/Other related packets
  8364. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  8365. {
  8366. ScenePresence sp = (ScenePresence)SceneAgent;
  8367. if(sp == null || sp.IsDeleted || (sp.IsInTransit && !sp.IsInLocalTransit))
  8368. return true;
  8369. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  8370. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  8371. {
  8372. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  8373. if (handlerNameRequest != null)
  8374. {
  8375. handlerNameRequest(UUIDBlock.ID, this);
  8376. }
  8377. }
  8378. return true;
  8379. }
  8380. #region Parcel related packets
  8381. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  8382. {
  8383. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  8384. if (handlerRegionHandleRequest != null)
  8385. {
  8386. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  8387. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  8388. }
  8389. return true;
  8390. }
  8391. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  8392. {
  8393. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  8394. #region Packet Session and User Check
  8395. if (m_checkPackets)
  8396. {
  8397. if (pirPack.AgentData.SessionID != SessionId ||
  8398. pirPack.AgentData.AgentID != AgentId)
  8399. return true;
  8400. }
  8401. #endregion
  8402. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  8403. if (handlerParcelInfoRequest != null)
  8404. {
  8405. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  8406. }
  8407. return true;
  8408. }
  8409. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  8410. {
  8411. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  8412. #region Packet Session and User Check
  8413. if (m_checkPackets)
  8414. {
  8415. if (requestPacket.AgentData.SessionID != SessionId ||
  8416. requestPacket.AgentData.AgentID != AgentId)
  8417. return true;
  8418. }
  8419. #endregion
  8420. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  8421. if (handlerParcelAccessListRequest != null)
  8422. {
  8423. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  8424. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  8425. requestPacket.Data.LocalID, this);
  8426. }
  8427. return true;
  8428. }
  8429. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  8430. {
  8431. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  8432. #region Packet Session and User Check
  8433. if (m_checkPackets)
  8434. {
  8435. if (updatePacket.AgentData.SessionID != SessionId ||
  8436. updatePacket.AgentData.AgentID != AgentId)
  8437. return true;
  8438. }
  8439. #endregion
  8440. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  8441. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  8442. {
  8443. LandAccessEntry entry = new LandAccessEntry();
  8444. entry.AgentID = block.ID;
  8445. entry.Flags = (AccessList)block.Flags;
  8446. entry.Expires = block.Time;
  8447. entries.Add(entry);
  8448. }
  8449. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  8450. if (handlerParcelAccessListUpdateRequest != null)
  8451. {
  8452. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  8453. updatePacket.Data.Flags,
  8454. updatePacket.Data.LocalID,
  8455. updatePacket.Data.TransactionID,
  8456. updatePacket.Data.SequenceID,
  8457. updatePacket.Data.Sections,
  8458. entries, this);
  8459. }
  8460. return true;
  8461. }
  8462. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  8463. {
  8464. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  8465. #region Packet Session and User Check
  8466. if (m_checkPackets)
  8467. {
  8468. if (propertiesRequest.AgentData.SessionID != SessionId ||
  8469. propertiesRequest.AgentData.AgentID != AgentId)
  8470. return true;
  8471. }
  8472. #endregion
  8473. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  8474. if (handlerParcelPropertiesRequest != null)
  8475. {
  8476. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  8477. (int)Math.Round(propertiesRequest.ParcelData.South),
  8478. (int)Math.Round(propertiesRequest.ParcelData.East),
  8479. (int)Math.Round(propertiesRequest.ParcelData.North),
  8480. propertiesRequest.ParcelData.SequenceID,
  8481. propertiesRequest.ParcelData.SnapSelection, this);
  8482. }
  8483. return true;
  8484. }
  8485. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  8486. {
  8487. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  8488. #region Packet Session and User Check
  8489. if (m_checkPackets)
  8490. {
  8491. if (landDivide.AgentData.SessionID != SessionId ||
  8492. landDivide.AgentData.AgentID != AgentId)
  8493. return true;
  8494. }
  8495. #endregion
  8496. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  8497. if (handlerParcelDivideRequest != null)
  8498. {
  8499. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  8500. (int)Math.Round(landDivide.ParcelData.South),
  8501. (int)Math.Round(landDivide.ParcelData.East),
  8502. (int)Math.Round(landDivide.ParcelData.North), this);
  8503. }
  8504. return true;
  8505. }
  8506. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  8507. {
  8508. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  8509. #region Packet Session and User Check
  8510. if (m_checkPackets)
  8511. {
  8512. if (landJoin.AgentData.SessionID != SessionId ||
  8513. landJoin.AgentData.AgentID != AgentId)
  8514. return true;
  8515. }
  8516. #endregion
  8517. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  8518. if (handlerParcelJoinRequest != null)
  8519. {
  8520. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  8521. (int)Math.Round(landJoin.ParcelData.South),
  8522. (int)Math.Round(landJoin.ParcelData.East),
  8523. (int)Math.Round(landJoin.ParcelData.North), this);
  8524. }
  8525. return true;
  8526. }
  8527. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  8528. {
  8529. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  8530. #region Packet Session and User Check
  8531. if (m_checkPackets)
  8532. {
  8533. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  8534. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  8535. return true;
  8536. }
  8537. #endregion
  8538. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  8539. if (handlerParcelPropertiesUpdateRequest != null)
  8540. {
  8541. LandUpdateArgs args = new LandUpdateArgs();
  8542. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  8543. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  8544. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  8545. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  8546. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  8547. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  8548. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  8549. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  8550. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  8551. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  8552. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  8553. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  8554. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  8555. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  8556. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  8557. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  8558. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  8559. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  8560. }
  8561. return true;
  8562. }
  8563. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  8564. {
  8565. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  8566. #region Packet Session and User Check
  8567. if (m_checkPackets)
  8568. {
  8569. if (selectPacket.AgentData.SessionID != SessionId ||
  8570. selectPacket.AgentData.AgentID != AgentId)
  8571. return true;
  8572. }
  8573. #endregion
  8574. List<UUID> returnIDs = new List<UUID>();
  8575. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  8576. selectPacket.ReturnIDs)
  8577. {
  8578. returnIDs.Add(rb.ReturnID);
  8579. }
  8580. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  8581. if (handlerParcelSelectObjects != null)
  8582. {
  8583. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  8584. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  8585. }
  8586. return true;
  8587. }
  8588. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  8589. {
  8590. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  8591. #region Packet Session and User Check
  8592. if (m_checkPackets)
  8593. {
  8594. if (reqPacket.AgentData.SessionID != SessionId ||
  8595. reqPacket.AgentData.AgentID != AgentId)
  8596. return true;
  8597. }
  8598. #endregion
  8599. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  8600. if (handlerParcelObjectOwnerRequest != null)
  8601. {
  8602. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  8603. }
  8604. return true;
  8605. }
  8606. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  8607. {
  8608. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  8609. #region Packet Session and User Check
  8610. if (m_checkPackets)
  8611. {
  8612. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  8613. godForceOwnerPacket.AgentData.AgentID != AgentId)
  8614. return true;
  8615. }
  8616. #endregion
  8617. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  8618. if (handlerParcelGodForceOwner != null)
  8619. {
  8620. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  8621. }
  8622. return true;
  8623. }
  8624. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  8625. {
  8626. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  8627. #region Packet Session and User Check
  8628. if (m_checkPackets)
  8629. {
  8630. if (releasePacket.AgentData.SessionID != SessionId ||
  8631. releasePacket.AgentData.AgentID != AgentId)
  8632. return true;
  8633. }
  8634. #endregion
  8635. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  8636. if (handlerParcelAbandonRequest != null)
  8637. {
  8638. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  8639. }
  8640. return true;
  8641. }
  8642. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  8643. {
  8644. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  8645. #region Packet Session and User Check
  8646. if (m_checkPackets)
  8647. {
  8648. if (reclaimPacket.AgentData.SessionID != SessionId ||
  8649. reclaimPacket.AgentData.AgentID != AgentId)
  8650. return true;
  8651. }
  8652. #endregion
  8653. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  8654. if (handlerParcelReclaim != null)
  8655. {
  8656. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  8657. }
  8658. return true;
  8659. }
  8660. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  8661. {
  8662. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  8663. #region Packet Session and User Check
  8664. if (m_checkPackets)
  8665. {
  8666. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  8667. parcelReturnObjects.AgentData.AgentID != AgentId)
  8668. return true;
  8669. }
  8670. #endregion
  8671. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8672. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8673. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8674. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8675. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8676. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8677. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8678. if (handlerParcelReturnObjectsRequest != null)
  8679. {
  8680. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8681. }
  8682. return true;
  8683. }
  8684. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8685. {
  8686. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8687. #region Packet Session and User Check
  8688. if (m_checkPackets)
  8689. {
  8690. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8691. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8692. return true;
  8693. }
  8694. #endregion
  8695. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8696. if (handlerParcelSetOtherCleanTime != null)
  8697. {
  8698. handlerParcelSetOtherCleanTime(this,
  8699. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8700. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8701. }
  8702. return true;
  8703. }
  8704. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8705. {
  8706. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8707. #region Packet Session and User Check
  8708. if (m_checkPackets)
  8709. {
  8710. if (lsrp.AgentData.SessionID != SessionId ||
  8711. lsrp.AgentData.AgentID != AgentId)
  8712. return true;
  8713. }
  8714. #endregion
  8715. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8716. if (handlerLandStatRequest != null)
  8717. {
  8718. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8719. }
  8720. return true;
  8721. }
  8722. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8723. {
  8724. ParcelDwellRequestPacket dwellrq =
  8725. (ParcelDwellRequestPacket)Pack;
  8726. #region Packet Session and User Check
  8727. if (m_checkPackets)
  8728. {
  8729. if (dwellrq.AgentData.SessionID != SessionId ||
  8730. dwellrq.AgentData.AgentID != AgentId)
  8731. return true;
  8732. }
  8733. #endregion
  8734. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8735. if (handlerParcelDwellRequest != null)
  8736. {
  8737. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8738. }
  8739. return true;
  8740. }
  8741. #endregion Parcel related packets
  8742. #region Estate Packets
  8743. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8744. {
  8745. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8746. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8747. GodLandStatRequest handlerLandStatRequest;
  8748. #region Packet Session and User Check
  8749. if (m_checkPackets)
  8750. {
  8751. if (messagePacket.AgentData.SessionID != SessionId ||
  8752. messagePacket.AgentData.AgentID != AgentId)
  8753. return true;
  8754. }
  8755. #endregion
  8756. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8757. switch (method)
  8758. {
  8759. case "getinfo":
  8760. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8761. {
  8762. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8763. }
  8764. return true;
  8765. case "setregioninfo":
  8766. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8767. {
  8768. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8769. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8770. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8771. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8772. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8773. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8774. }
  8775. return true;
  8776. // case "texturebase":
  8777. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8778. // {
  8779. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8780. // {
  8781. // string s = Utils.BytesToString(block.Parameter);
  8782. // string[] splitField = s.Split(' ');
  8783. // if (splitField.Length == 2)
  8784. // {
  8785. // UUID tempUUID = new UUID(splitField[1]);
  8786. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8787. // }
  8788. // }
  8789. // }
  8790. // break;
  8791. case "texturedetail":
  8792. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8793. {
  8794. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8795. {
  8796. string s = Utils.BytesToString(block.Parameter);
  8797. string[] splitField = s.Split(' ');
  8798. if (splitField.Length == 2)
  8799. {
  8800. Int16 corner = Convert.ToInt16(splitField[0]);
  8801. UUID textureUUID = new UUID(splitField[1]);
  8802. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8803. }
  8804. }
  8805. }
  8806. return true;
  8807. case "textureheights":
  8808. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8809. {
  8810. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8811. {
  8812. string s = Utils.BytesToString(block.Parameter);
  8813. string[] splitField = s.Split(' ');
  8814. if (splitField.Length == 3)
  8815. {
  8816. Int16 corner = Convert.ToInt16(splitField[0]);
  8817. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8818. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8819. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8820. }
  8821. }
  8822. }
  8823. return true;
  8824. case "texturecommit":
  8825. OnCommitEstateTerrainTextureRequest(this);
  8826. return true;
  8827. case "setregionterrain":
  8828. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8829. {
  8830. if (messagePacket.ParamList.Length != 9)
  8831. {
  8832. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8833. }
  8834. else
  8835. {
  8836. try
  8837. {
  8838. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8839. if (!tmp.Contains(".")) tmp += ".00";
  8840. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8841. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8842. if (!tmp.Contains(".")) tmp += ".00";
  8843. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8844. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8845. if (!tmp.Contains(".")) tmp += ".00";
  8846. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8847. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8848. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8849. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8850. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8851. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8852. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8853. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8854. }
  8855. catch (Exception ex)
  8856. {
  8857. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8858. }
  8859. }
  8860. }
  8861. return true;
  8862. case "restart":
  8863. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8864. {
  8865. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8866. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8867. {
  8868. float timeSeconds;
  8869. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8870. timeSeconds = (int)timeSeconds;
  8871. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8872. }
  8873. }
  8874. return true;
  8875. case "estatechangecovenantid":
  8876. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8877. {
  8878. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8879. {
  8880. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8881. OnEstateChangeCovenantRequest(this, newCovenantID);
  8882. }
  8883. }
  8884. return true;
  8885. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8886. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8887. {
  8888. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8889. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8890. }
  8891. return true;
  8892. case "simulatormessage":
  8893. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8894. {
  8895. UUID invoice = messagePacket.MethodData.Invoice;
  8896. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8897. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8898. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8899. UUID sessionID = messagePacket.AgentData.SessionID;
  8900. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8901. }
  8902. return true;
  8903. case "instantmessage":
  8904. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8905. {
  8906. if (messagePacket.ParamList.Length < 2)
  8907. return true;
  8908. UUID invoice = messagePacket.MethodData.Invoice;
  8909. UUID sessionID = messagePacket.AgentData.SessionID;
  8910. UUID SenderID;
  8911. string SenderName;
  8912. string Message;
  8913. if (messagePacket.ParamList.Length < 5)
  8914. {
  8915. SenderID = AgentId;
  8916. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8917. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8918. }
  8919. else
  8920. {
  8921. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8922. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8923. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8924. }
  8925. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8926. }
  8927. return true;
  8928. case "setregiondebug":
  8929. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8930. {
  8931. UUID invoice = messagePacket.MethodData.Invoice;
  8932. UUID SenderID = messagePacket.AgentData.AgentID;
  8933. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8934. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8935. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8936. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8937. }
  8938. return true;
  8939. case "teleporthomeuser":
  8940. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8941. {
  8942. UUID invoice = messagePacket.MethodData.Invoice;
  8943. UUID SenderID = messagePacket.AgentData.AgentID;
  8944. UUID Prey;
  8945. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8946. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8947. }
  8948. return true;
  8949. case "teleporthomeallusers":
  8950. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8951. {
  8952. UUID invoice = messagePacket.MethodData.Invoice;
  8953. UUID SenderID = messagePacket.AgentData.AgentID;
  8954. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8955. }
  8956. return true;
  8957. case "colliders":
  8958. handlerLandStatRequest = OnLandStatRequest;
  8959. if (handlerLandStatRequest != null)
  8960. {
  8961. handlerLandStatRequest(0, 1, 0, "", this);
  8962. }
  8963. return true;
  8964. case "scripts":
  8965. handlerLandStatRequest = OnLandStatRequest;
  8966. if (handlerLandStatRequest != null)
  8967. {
  8968. handlerLandStatRequest(0, 0, 0, "", this);
  8969. }
  8970. return true;
  8971. case "terrain":
  8972. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8973. {
  8974. if (messagePacket.ParamList.Length > 0)
  8975. {
  8976. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8977. {
  8978. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8979. if (handlerBakeTerrain != null)
  8980. {
  8981. handlerBakeTerrain(this);
  8982. }
  8983. }
  8984. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8985. {
  8986. if (messagePacket.ParamList.Length > 1)
  8987. {
  8988. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8989. if (handlerRequestTerrain != null)
  8990. {
  8991. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8992. }
  8993. }
  8994. }
  8995. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8996. {
  8997. if (messagePacket.ParamList.Length > 1)
  8998. {
  8999. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  9000. if (handlerUploadTerrain != null)
  9001. {
  9002. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  9003. }
  9004. }
  9005. }
  9006. }
  9007. }
  9008. return true;
  9009. case "estatechangeinfo":
  9010. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  9011. {
  9012. UUID invoice = messagePacket.MethodData.Invoice;
  9013. UUID SenderID = messagePacket.AgentData.AgentID;
  9014. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  9015. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  9016. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  9017. if (handlerEstateChangeInfo != null)
  9018. {
  9019. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  9020. }
  9021. }
  9022. return true;
  9023. case "telehub":
  9024. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  9025. {
  9026. UUID invoice = messagePacket.MethodData.Invoice;
  9027. UUID SenderID = messagePacket.AgentData.AgentID;
  9028. UInt32 param1 = 0u;
  9029. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  9030. if (command != "info ui")
  9031. {
  9032. try
  9033. {
  9034. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  9035. }
  9036. catch
  9037. {
  9038. }
  9039. }
  9040. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  9041. if (handlerEstateManageTelehub != null)
  9042. {
  9043. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  9044. }
  9045. }
  9046. return true;
  9047. case "kickestate":
  9048. if(((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  9049. {
  9050. UUID invoice = messagePacket.MethodData.Invoice;
  9051. UUID SenderID = messagePacket.AgentData.AgentID;
  9052. UUID Prey;
  9053. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[0].Parameter), out Prey);
  9054. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  9055. }
  9056. return true;
  9057. default:
  9058. m_log.WarnFormat(
  9059. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  9060. method, Name, Scene.Name);
  9061. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  9062. {
  9063. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  9064. string data = (string)Utils.BytesToString(block.Parameter);
  9065. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  9066. }
  9067. return true;
  9068. }
  9069. //int parcelID, uint reportType, uint requestflags, string filter
  9070. //lsrp.RequestData.ParcelLocalID;
  9071. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  9072. //lsrp.RequestData.RequestFlags;
  9073. //lsrp.RequestData.Filter;
  9074. }
  9075. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  9076. {
  9077. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  9078. #region Packet Session and User Check
  9079. if (m_checkPackets)
  9080. {
  9081. if (mPacket.SessionID != SessionId ||
  9082. mPacket.AgentID != AgentId)
  9083. return true;
  9084. }
  9085. #endregion
  9086. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  9087. if (handlerRegionInfoRequest != null)
  9088. {
  9089. handlerRegionInfoRequest(this);
  9090. }
  9091. return true;
  9092. }
  9093. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  9094. {
  9095. //EstateCovenantRequestPacket.AgentDataBlock epack =
  9096. // ((EstateCovenantRequestPacket)Pack).AgentData;
  9097. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  9098. if (handlerEstateCovenantRequest != null)
  9099. {
  9100. handlerEstateCovenantRequest(this);
  9101. }
  9102. return true;
  9103. }
  9104. #endregion Estate Packets
  9105. #region GodPackets
  9106. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  9107. {
  9108. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  9109. if (rglpPack.AgentData.SessionID != SessionId ||
  9110. rglpPack.AgentData.AgentID != AgentId)
  9111. return true;
  9112. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  9113. UUID token = rblock.Token;
  9114. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  9115. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  9116. if (handlerReqGodlikePowers != null)
  9117. {
  9118. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike);
  9119. }
  9120. return true;
  9121. }
  9122. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  9123. {
  9124. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  9125. (GodUpdateRegionInfoPacket)Packet;
  9126. if (GodUpdateRegionInfo.AgentData.SessionID != SessionId ||
  9127. GodUpdateRegionInfo.AgentData.AgentID != AgentId)
  9128. return true;
  9129. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  9130. if (handlerGodUpdateRegionInfo != null)
  9131. {
  9132. handlerGodUpdateRegionInfo(this,
  9133. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  9134. GodUpdateRegionInfo.RegionInfo.EstateID,
  9135. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  9136. GodUpdateRegionInfo.RegionInfo.SimName,
  9137. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  9138. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  9139. return true;
  9140. }
  9141. return false;
  9142. }
  9143. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  9144. {
  9145. SimWideDeletesPacket SimWideDeletesRequest =
  9146. (SimWideDeletesPacket)Packet;
  9147. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  9148. if (handlerSimWideDeletesRequest != null)
  9149. {
  9150. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  9151. return true;
  9152. }
  9153. return false;
  9154. }
  9155. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  9156. {
  9157. GodlikeMessagePacket GodlikeMessage =
  9158. (GodlikeMessagePacket)Packet;
  9159. if (GodlikeMessage.AgentData.SessionID != SessionId ||
  9160. GodlikeMessage.AgentData.AgentID != AgentId)
  9161. return true;
  9162. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  9163. if (handlerGodlikeMessage != null)
  9164. {
  9165. handlerGodlikeMessage(this,
  9166. GodlikeMessage.MethodData.Invoice,
  9167. GodlikeMessage.MethodData.Method,
  9168. GodlikeMessage.ParamList[0].Parameter);
  9169. return true;
  9170. }
  9171. return false;
  9172. }
  9173. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  9174. {
  9175. StateSavePacket SaveStateMessage =
  9176. (StateSavePacket)Packet;
  9177. if (SaveStateMessage.AgentData.SessionID != SessionId ||
  9178. SaveStateMessage.AgentData.AgentID != AgentId)
  9179. return true;
  9180. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  9181. if (handlerSaveStatePacket != null)
  9182. {
  9183. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  9184. return true;
  9185. }
  9186. return false;
  9187. }
  9188. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  9189. {
  9190. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  9191. if (gkupack.UserInfo.GodSessionID != SessionId ||
  9192. gkupack.UserInfo.GodID != AgentId)
  9193. return true;
  9194. GodKickUser handlerGodKickUser = OnGodKickUser;
  9195. if (handlerGodKickUser != null)
  9196. {
  9197. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  9198. }
  9199. return true;
  9200. }
  9201. #endregion GodPackets
  9202. #region Economy/Transaction Packets
  9203. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  9204. {
  9205. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  9206. #region Packet Session and User Check
  9207. if (m_checkPackets)
  9208. {
  9209. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  9210. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  9211. return true;
  9212. }
  9213. #endregion
  9214. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  9215. if (handlerMoneyBalanceRequest != null)
  9216. {
  9217. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  9218. }
  9219. return true;
  9220. }
  9221. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  9222. {
  9223. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  9224. if (handlerEconomoyDataRequest != null)
  9225. {
  9226. handlerEconomoyDataRequest(this);
  9227. }
  9228. return true;
  9229. }
  9230. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  9231. {
  9232. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  9233. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  9234. if (handlerRequestPayPrice != null)
  9235. {
  9236. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  9237. }
  9238. return true;
  9239. }
  9240. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  9241. {
  9242. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  9243. #region Packet Session and User Check
  9244. if (m_checkPackets)
  9245. {
  9246. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  9247. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  9248. return true;
  9249. }
  9250. #endregion
  9251. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  9252. if (handlerObjectSaleInfo != null)
  9253. {
  9254. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  9255. in objectSaleInfoPacket.ObjectData)
  9256. {
  9257. handlerObjectSaleInfo(this,
  9258. objectSaleInfoPacket.AgentData.AgentID,
  9259. objectSaleInfoPacket.AgentData.SessionID,
  9260. d.LocalID,
  9261. d.SaleType,
  9262. d.SalePrice);
  9263. }
  9264. }
  9265. return true;
  9266. }
  9267. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  9268. {
  9269. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  9270. #region Packet Session and User Check
  9271. if (m_checkPackets)
  9272. {
  9273. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  9274. objectBuyPacket.AgentData.AgentID != AgentId)
  9275. return true;
  9276. }
  9277. #endregion
  9278. ObjectBuy handlerObjectBuy = OnObjectBuy;
  9279. if (handlerObjectBuy != null)
  9280. {
  9281. foreach (ObjectBuyPacket.ObjectDataBlock d
  9282. in objectBuyPacket.ObjectData)
  9283. {
  9284. handlerObjectBuy(this,
  9285. objectBuyPacket.AgentData.AgentID,
  9286. objectBuyPacket.AgentData.SessionID,
  9287. objectBuyPacket.AgentData.GroupID,
  9288. objectBuyPacket.AgentData.CategoryID,
  9289. d.ObjectLocalID,
  9290. d.SaleType,
  9291. d.SalePrice);
  9292. }
  9293. }
  9294. return true;
  9295. }
  9296. #endregion Economy/Transaction Packets
  9297. #region Script Packets
  9298. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  9299. {
  9300. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  9301. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  9302. if (handlerGetScriptRunning != null)
  9303. {
  9304. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  9305. }
  9306. return true;
  9307. }
  9308. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  9309. {
  9310. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  9311. #region Packet Session and User Check
  9312. if (m_checkPackets)
  9313. {
  9314. if (setScriptRunning.AgentData.SessionID != SessionId ||
  9315. setScriptRunning.AgentData.AgentID != AgentId)
  9316. return true;
  9317. }
  9318. #endregion
  9319. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  9320. if (handlerSetScriptRunning != null)
  9321. {
  9322. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  9323. }
  9324. return true;
  9325. }
  9326. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  9327. {
  9328. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  9329. #region Packet Session and User Check
  9330. if (m_checkPackets)
  9331. {
  9332. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  9333. scriptResetPacket.AgentData.AgentID != AgentId)
  9334. return true;
  9335. }
  9336. #endregion
  9337. ScriptReset handlerScriptReset = OnScriptReset;
  9338. if (handlerScriptReset != null)
  9339. {
  9340. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  9341. }
  9342. return true;
  9343. }
  9344. #endregion Script Packets
  9345. #region Gesture Managment
  9346. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  9347. {
  9348. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  9349. #region Packet Session and User Check
  9350. if (m_checkPackets)
  9351. {
  9352. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  9353. activateGesturePacket.AgentData.AgentID != AgentId)
  9354. return true;
  9355. }
  9356. #endregion
  9357. ActivateGesture handlerActivateGesture = OnActivateGesture;
  9358. if (handlerActivateGesture != null)
  9359. {
  9360. handlerActivateGesture(this,
  9361. activateGesturePacket.Data[0].AssetID,
  9362. activateGesturePacket.Data[0].ItemID);
  9363. }
  9364. else m_log.Error("Null pointer for activateGesture");
  9365. return true;
  9366. }
  9367. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  9368. {
  9369. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  9370. #region Packet Session and User Check
  9371. if (m_checkPackets)
  9372. {
  9373. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  9374. deactivateGesturePacket.AgentData.AgentID != AgentId)
  9375. return true;
  9376. }
  9377. #endregion
  9378. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  9379. if (handlerDeactivateGesture != null)
  9380. {
  9381. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  9382. }
  9383. return true;
  9384. }
  9385. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  9386. {
  9387. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  9388. #region Packet Session and User Check
  9389. if (m_checkPackets)
  9390. {
  9391. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  9392. objectOwnerPacket.AgentData.AgentID != AgentId)
  9393. return true;
  9394. }
  9395. #endregion
  9396. List<uint> localIDs = new List<uint>();
  9397. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  9398. localIDs.Add(d.ObjectLocalID);
  9399. ObjectOwner handlerObjectOwner = OnObjectOwner;
  9400. if (handlerObjectOwner != null)
  9401. {
  9402. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  9403. }
  9404. return true;
  9405. }
  9406. #endregion Gesture Managment
  9407. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  9408. {
  9409. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  9410. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  9411. {
  9412. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  9413. AgentFOV handlerAgentFOV = OnAgentFOV;
  9414. if (handlerAgentFOV != null)
  9415. {
  9416. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  9417. }
  9418. }
  9419. return true;
  9420. }
  9421. #region unimplemented handlers
  9422. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  9423. {
  9424. // TODO: handle this packet
  9425. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  9426. return true;
  9427. }
  9428. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  9429. {
  9430. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  9431. #region Packet Session and User Check
  9432. if (m_checkPackets)
  9433. {
  9434. if (mirpk.AgentData.SessionID != SessionId ||
  9435. mirpk.AgentData.AgentID != AgentId)
  9436. return true;
  9437. }
  9438. #endregion
  9439. //m_log.Debug(mirpk.ToString());
  9440. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  9441. if (handlerMapItemRequest != null)
  9442. {
  9443. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  9444. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  9445. mirpk.RequestData.RegionHandle);
  9446. }
  9447. return true;
  9448. }
  9449. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  9450. {
  9451. return true;
  9452. }
  9453. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  9454. {
  9455. MuteListRequestPacket muteListRequest =
  9456. (MuteListRequestPacket)Pack;
  9457. #region Packet Session and User Check
  9458. if (m_checkPackets)
  9459. {
  9460. if (muteListRequest.AgentData.SessionID != SessionId ||
  9461. muteListRequest.AgentData.AgentID != AgentId)
  9462. return true;
  9463. }
  9464. #endregion
  9465. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  9466. if (handlerMuteListRequest != null)
  9467. {
  9468. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  9469. }
  9470. else
  9471. {
  9472. if(muteListRequest.MuteData.MuteCRC == 0)
  9473. SendEmpytMuteList();
  9474. else
  9475. SendUseCachedMuteList();
  9476. }
  9477. return true;
  9478. }
  9479. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  9480. {
  9481. UpdateMuteListEntryPacket UpdateMuteListEntry =
  9482. (UpdateMuteListEntryPacket)Packet;
  9483. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  9484. if (handlerUpdateMuteListEntry != null)
  9485. {
  9486. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  9487. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  9488. UpdateMuteListEntry.MuteData.MuteType,
  9489. UpdateMuteListEntry.MuteData.MuteFlags);
  9490. return true;
  9491. }
  9492. return false;
  9493. }
  9494. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  9495. {
  9496. RemoveMuteListEntryPacket RemoveMuteListEntry =
  9497. (RemoveMuteListEntryPacket)Packet;
  9498. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  9499. if (handlerRemoveMuteListEntry != null)
  9500. {
  9501. handlerRemoveMuteListEntry(this,
  9502. RemoveMuteListEntry.MuteData.MuteID,
  9503. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName));
  9504. return true;
  9505. }
  9506. return false;
  9507. }
  9508. private bool HandleUserReport(IClientAPI client, Packet Packet)
  9509. {
  9510. UserReportPacket UserReport =
  9511. (UserReportPacket)Packet;
  9512. NewUserReport handlerUserReport = OnUserReport;
  9513. if (handlerUserReport != null)
  9514. {
  9515. handlerUserReport(this,
  9516. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  9517. UserReport.ReportData.AbuserID,
  9518. UserReport.ReportData.Category,
  9519. UserReport.ReportData.CheckFlags,
  9520. Utils.BytesToString(UserReport.ReportData.Details),
  9521. UserReport.ReportData.ObjectID,
  9522. UserReport.ReportData.Position,
  9523. UserReport.ReportData.ReportType,
  9524. UserReport.ReportData.ScreenshotID,
  9525. Utils.BytesToString(UserReport.ReportData.Summary),
  9526. UserReport.AgentData.AgentID);
  9527. return true;
  9528. }
  9529. return false;
  9530. }
  9531. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  9532. {
  9533. // SendPostcardPacket SendPostcard =
  9534. // (SendPostcardPacket)packet;
  9535. SendPostcard handlerSendPostcard = OnSendPostcard;
  9536. if (handlerSendPostcard != null)
  9537. {
  9538. handlerSendPostcard(this);
  9539. return true;
  9540. }
  9541. return false;
  9542. }
  9543. private bool HandleChangeInventoryItemFlags(IClientAPI client, Packet packet)
  9544. {
  9545. ChangeInventoryItemFlagsPacket ChangeInventoryItemFlags =
  9546. (ChangeInventoryItemFlagsPacket)packet;
  9547. ChangeInventoryItemFlags handlerChangeInventoryItemFlags = OnChangeInventoryItemFlags;
  9548. if (handlerChangeInventoryItemFlags != null)
  9549. {
  9550. foreach(ChangeInventoryItemFlagsPacket.InventoryDataBlock b in ChangeInventoryItemFlags.InventoryData)
  9551. handlerChangeInventoryItemFlags(this, b.ItemID, b.Flags);
  9552. return true;
  9553. }
  9554. return false;
  9555. }
  9556. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  9557. {
  9558. return true;
  9559. }
  9560. private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
  9561. {
  9562. CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
  9563. #region Packet Session and User Check
  9564. if (m_checkPackets)
  9565. {
  9566. if (packet.AgentData.SessionID != SessionId ||
  9567. packet.AgentData.AgentID != AgentId)
  9568. return true;
  9569. }
  9570. #endregion
  9571. MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
  9572. List<InventoryItemBase> items = new List<InventoryItemBase>();
  9573. foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
  9574. {
  9575. InventoryItemBase b = new InventoryItemBase();
  9576. b.ID = n.OldItemID;
  9577. b.Folder = n.OldFolderID;
  9578. items.Add(b);
  9579. }
  9580. handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
  9581. if (handlerMoveItemsAndLeaveCopy != null)
  9582. {
  9583. handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
  9584. }
  9585. return true;
  9586. }
  9587. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  9588. {
  9589. return true;
  9590. }
  9591. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  9592. {
  9593. return true;
  9594. }
  9595. #endregion unimplemented handlers
  9596. #region Dir handlers
  9597. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  9598. {
  9599. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  9600. //m_log.Debug(dirPlacesQueryPacket.ToString());
  9601. #region Packet Session and User Check
  9602. if (m_checkPackets)
  9603. {
  9604. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  9605. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  9606. return true;
  9607. }
  9608. #endregion
  9609. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  9610. if (handlerDirPlacesQuery != null)
  9611. {
  9612. handlerDirPlacesQuery(this,
  9613. dirPlacesQueryPacket.QueryData.QueryID,
  9614. Utils.BytesToString(
  9615. dirPlacesQueryPacket.QueryData.QueryText),
  9616. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  9617. (int)dirPlacesQueryPacket.QueryData.Category,
  9618. Utils.BytesToString(
  9619. dirPlacesQueryPacket.QueryData.SimName),
  9620. dirPlacesQueryPacket.QueryData.QueryStart);
  9621. }
  9622. return true;
  9623. }
  9624. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  9625. {
  9626. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  9627. #region Packet Session and User Check
  9628. if (m_checkPackets)
  9629. {
  9630. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  9631. dirFindQueryPacket.AgentData.AgentID != AgentId)
  9632. return true;
  9633. }
  9634. #endregion
  9635. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  9636. if (handlerDirFindQuery != null)
  9637. {
  9638. handlerDirFindQuery(this,
  9639. dirFindQueryPacket.QueryData.QueryID,
  9640. Utils.BytesToString(
  9641. dirFindQueryPacket.QueryData.QueryText).Trim(),
  9642. dirFindQueryPacket.QueryData.QueryFlags,
  9643. dirFindQueryPacket.QueryData.QueryStart);
  9644. }
  9645. return true;
  9646. }
  9647. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  9648. {
  9649. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  9650. #region Packet Session and User Check
  9651. if (m_checkPackets)
  9652. {
  9653. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  9654. dirLandQueryPacket.AgentData.AgentID != AgentId)
  9655. return true;
  9656. }
  9657. #endregion
  9658. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  9659. if (handlerDirLandQuery != null)
  9660. {
  9661. handlerDirLandQuery(this,
  9662. dirLandQueryPacket.QueryData.QueryID,
  9663. dirLandQueryPacket.QueryData.QueryFlags,
  9664. dirLandQueryPacket.QueryData.SearchType,
  9665. dirLandQueryPacket.QueryData.Price,
  9666. dirLandQueryPacket.QueryData.Area,
  9667. dirLandQueryPacket.QueryData.QueryStart);
  9668. }
  9669. return true;
  9670. }
  9671. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  9672. {
  9673. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  9674. #region Packet Session and User Check
  9675. if (m_checkPackets)
  9676. {
  9677. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  9678. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  9679. return true;
  9680. }
  9681. #endregion
  9682. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  9683. if (handlerDirPopularQuery != null)
  9684. {
  9685. handlerDirPopularQuery(this,
  9686. dirPopularQueryPacket.QueryData.QueryID,
  9687. dirPopularQueryPacket.QueryData.QueryFlags);
  9688. }
  9689. return true;
  9690. }
  9691. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  9692. {
  9693. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  9694. #region Packet Session and User Check
  9695. if (m_checkPackets)
  9696. {
  9697. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  9698. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  9699. return true;
  9700. }
  9701. #endregion
  9702. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  9703. if (handlerDirClassifiedQuery != null)
  9704. {
  9705. handlerDirClassifiedQuery(this,
  9706. dirClassifiedQueryPacket.QueryData.QueryID,
  9707. Utils.BytesToString(
  9708. dirClassifiedQueryPacket.QueryData.QueryText),
  9709. dirClassifiedQueryPacket.QueryData.QueryFlags,
  9710. dirClassifiedQueryPacket.QueryData.Category,
  9711. dirClassifiedQueryPacket.QueryData.QueryStart);
  9712. }
  9713. return true;
  9714. }
  9715. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  9716. {
  9717. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  9718. #region Packet Session and User Check
  9719. if (m_checkPackets)
  9720. {
  9721. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9722. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9723. return true;
  9724. }
  9725. #endregion
  9726. if (OnEventInfoRequest != null)
  9727. {
  9728. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9729. }
  9730. return true;
  9731. }
  9732. #endregion
  9733. #region Calling Card
  9734. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9735. {
  9736. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9737. #region Packet Session and User Check
  9738. if (m_checkPackets)
  9739. {
  9740. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9741. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9742. return true;
  9743. }
  9744. #endregion
  9745. if (OnOfferCallingCard != null)
  9746. {
  9747. OnOfferCallingCard(this,
  9748. offerCallingCardPacket.AgentBlock.DestID,
  9749. offerCallingCardPacket.AgentBlock.TransactionID);
  9750. }
  9751. return true;
  9752. }
  9753. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9754. {
  9755. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9756. #region Packet Session and User Check
  9757. if (m_checkPackets)
  9758. {
  9759. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9760. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9761. return true;
  9762. }
  9763. #endregion
  9764. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9765. // contain exactly one entry
  9766. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9767. {
  9768. OnAcceptCallingCard(this,
  9769. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9770. acceptCallingCardPacket.FolderData[0].FolderID);
  9771. }
  9772. return true;
  9773. }
  9774. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9775. {
  9776. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9777. #region Packet Session and User Check
  9778. if (m_checkPackets)
  9779. {
  9780. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9781. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9782. return true;
  9783. }
  9784. #endregion
  9785. if (OnDeclineCallingCard != null)
  9786. {
  9787. OnDeclineCallingCard(this,
  9788. declineCallingCardPacket.TransactionBlock.TransactionID);
  9789. }
  9790. return true;
  9791. }
  9792. #endregion Calling Card
  9793. #region Groups
  9794. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9795. {
  9796. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9797. #region Packet Session and User Check
  9798. if (m_checkPackets)
  9799. {
  9800. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9801. activateGroupPacket.AgentData.AgentID != AgentId)
  9802. return true;
  9803. }
  9804. #endregion
  9805. if (m_GroupsModule != null)
  9806. {
  9807. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9808. }
  9809. return true;
  9810. }
  9811. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9812. {
  9813. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9814. (GroupVoteHistoryRequestPacket)Packet;
  9815. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9816. if (handlerGroupVoteHistoryRequest != null)
  9817. {
  9818. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9819. return true;
  9820. }
  9821. return false;
  9822. }
  9823. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9824. {
  9825. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9826. (GroupActiveProposalsRequestPacket)Packet;
  9827. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9828. if (handlerGroupActiveProposalsRequest != null)
  9829. {
  9830. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9831. return true;
  9832. }
  9833. return false;
  9834. }
  9835. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9836. {
  9837. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9838. (GroupAccountDetailsRequestPacket)Packet;
  9839. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9840. if (handlerGroupAccountDetailsRequest != null)
  9841. {
  9842. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9843. return true;
  9844. }
  9845. return false;
  9846. }
  9847. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9848. {
  9849. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9850. (GroupAccountSummaryRequestPacket)Packet;
  9851. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9852. if (handlerGroupAccountSummaryRequest != null)
  9853. {
  9854. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9855. return true;
  9856. }
  9857. return false;
  9858. }
  9859. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9860. {
  9861. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9862. (GroupAccountTransactionsRequestPacket)Packet;
  9863. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9864. if (handlerGroupAccountTransactionsRequest != null)
  9865. {
  9866. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9867. return true;
  9868. }
  9869. return false;
  9870. }
  9871. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9872. {
  9873. GroupTitlesRequestPacket groupTitlesRequest =
  9874. (GroupTitlesRequestPacket)Pack;
  9875. #region Packet Session and User Check
  9876. if (m_checkPackets)
  9877. {
  9878. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9879. groupTitlesRequest.AgentData.AgentID != AgentId)
  9880. return true;
  9881. }
  9882. #endregion
  9883. if (m_GroupsModule != null)
  9884. {
  9885. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9886. groupTitlesReply.AgentData =
  9887. new GroupTitlesReplyPacket.AgentDataBlock();
  9888. groupTitlesReply.AgentData.AgentID = AgentId;
  9889. groupTitlesReply.AgentData.GroupID =
  9890. groupTitlesRequest.AgentData.GroupID;
  9891. groupTitlesReply.AgentData.RequestID =
  9892. groupTitlesRequest.AgentData.RequestID;
  9893. List<GroupTitlesData> titles =
  9894. m_GroupsModule.GroupTitlesRequest(this,
  9895. groupTitlesRequest.AgentData.GroupID);
  9896. groupTitlesReply.GroupData =
  9897. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9898. int i = 0;
  9899. foreach (GroupTitlesData d in titles)
  9900. {
  9901. groupTitlesReply.GroupData[i] =
  9902. new GroupTitlesReplyPacket.GroupDataBlock();
  9903. groupTitlesReply.GroupData[i].Title =
  9904. Util.StringToBytes256(d.Name);
  9905. groupTitlesReply.GroupData[i].RoleID =
  9906. d.UUID;
  9907. groupTitlesReply.GroupData[i].Selected =
  9908. d.Selected;
  9909. i++;
  9910. }
  9911. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9912. }
  9913. return true;
  9914. }
  9915. UUID lastGroupProfileRequestID = UUID.Zero;
  9916. double lastGroupProfileRequestTS = Util.GetTimeStampMS();
  9917. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9918. {
  9919. if(m_GroupsModule == null)
  9920. return true;
  9921. GroupProfileRequestPacket groupProfileRequest =
  9922. (GroupProfileRequestPacket)Pack;
  9923. #region Packet Session and User Check
  9924. if (m_checkPackets)
  9925. {
  9926. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9927. groupProfileRequest.AgentData.AgentID != AgentId)
  9928. return true;
  9929. }
  9930. #endregion
  9931. UUID grpID = groupProfileRequest.GroupData.GroupID;
  9932. double ts = Util.GetTimeStampMS();
  9933. if(grpID == lastGroupProfileRequestID && ts - lastGroupProfileRequestTS < 10000)
  9934. return true;
  9935. lastGroupProfileRequestID = grpID;
  9936. lastGroupProfileRequestTS = ts;
  9937. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9938. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9939. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9940. groupProfileReply.AgentData.AgentID = AgentId;
  9941. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9942. groupProfileRequest.GroupData.GroupID);
  9943. if(d.GroupID == UUID.Zero) // don't send broken data
  9944. return true;
  9945. groupProfileReply.GroupData.GroupID = d.GroupID;
  9946. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9947. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9948. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9949. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9950. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9951. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9952. groupProfileReply.GroupData.FounderID = d.FounderID;
  9953. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9954. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9955. groupProfileReply.GroupData.Money = d.Money;
  9956. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9957. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9958. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9959. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9960. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9961. Scene scene = (Scene)m_scene;
  9962. if (scene.Permissions.IsGod(sender.AgentId) && (!sender.IsGroupMember(groupProfileRequest.GroupData.GroupID)))
  9963. {
  9964. ScenePresence p;
  9965. if (scene.TryGetScenePresence(sender.AgentId, out p))
  9966. {
  9967. if (p.IsViewerUIGod)
  9968. {
  9969. groupProfileReply.GroupData.OpenEnrollment = true;
  9970. groupProfileReply.GroupData.MembershipFee = 0;
  9971. }
  9972. }
  9973. }
  9974. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9975. if(grpID == lastGroupProfileRequestID)
  9976. lastGroupProfileRequestTS = Util.GetTimeStampMS() - 7000;
  9977. return true;
  9978. }
  9979. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9980. {
  9981. GroupMembersRequestPacket groupMembersRequestPacket =
  9982. (GroupMembersRequestPacket)Pack;
  9983. #region Packet Session and User Check
  9984. if (m_checkPackets)
  9985. {
  9986. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9987. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9988. return true;
  9989. }
  9990. #endregion
  9991. if (m_GroupsModule != null)
  9992. {
  9993. List<GroupMembersData> members =
  9994. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9995. int memberCount = members.Count;
  9996. int indx = 0;
  9997. while (indx < memberCount)
  9998. {
  9999. int blockCount = memberCount - indx;
  10000. if (blockCount > 25)
  10001. blockCount = 25;
  10002. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  10003. groupMembersReply.AgentData =
  10004. new GroupMembersReplyPacket.AgentDataBlock();
  10005. groupMembersReply.GroupData =
  10006. new GroupMembersReplyPacket.GroupDataBlock();
  10007. groupMembersReply.MemberData =
  10008. new GroupMembersReplyPacket.MemberDataBlock[
  10009. blockCount];
  10010. groupMembersReply.AgentData.AgentID = AgentId;
  10011. groupMembersReply.GroupData.GroupID =
  10012. groupMembersRequestPacket.GroupData.GroupID;
  10013. groupMembersReply.GroupData.RequestID =
  10014. groupMembersRequestPacket.GroupData.RequestID;
  10015. groupMembersReply.GroupData.MemberCount = memberCount;
  10016. for (int i = 0; i < blockCount; i++)
  10017. {
  10018. GroupMembersData m = members[indx++];
  10019. groupMembersReply.MemberData[i] =
  10020. new GroupMembersReplyPacket.MemberDataBlock();
  10021. groupMembersReply.MemberData[i].AgentID =
  10022. m.AgentID;
  10023. groupMembersReply.MemberData[i].Contribution =
  10024. m.Contribution;
  10025. groupMembersReply.MemberData[i].OnlineStatus =
  10026. Util.StringToBytes256(m.OnlineStatus);
  10027. groupMembersReply.MemberData[i].AgentPowers =
  10028. m.AgentPowers;
  10029. groupMembersReply.MemberData[i].Title =
  10030. Util.StringToBytes256(m.Title);
  10031. groupMembersReply.MemberData[i].IsOwner =
  10032. m.IsOwner;
  10033. }
  10034. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  10035. }
  10036. }
  10037. return true;
  10038. }
  10039. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  10040. {
  10041. GroupRoleDataRequestPacket groupRolesRequest =
  10042. (GroupRoleDataRequestPacket)Pack;
  10043. #region Packet Session and User Check
  10044. if (m_checkPackets)
  10045. {
  10046. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  10047. groupRolesRequest.AgentData.AgentID != AgentId)
  10048. return true;
  10049. }
  10050. #endregion
  10051. if (m_GroupsModule != null)
  10052. {
  10053. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  10054. groupRolesReply.AgentData =
  10055. new GroupRoleDataReplyPacket.AgentDataBlock();
  10056. groupRolesReply.AgentData.AgentID = AgentId;
  10057. groupRolesReply.GroupData =
  10058. new GroupRoleDataReplyPacket.GroupDataBlock();
  10059. groupRolesReply.GroupData.GroupID =
  10060. groupRolesRequest.GroupData.GroupID;
  10061. groupRolesReply.GroupData.RequestID =
  10062. groupRolesRequest.GroupData.RequestID;
  10063. List<GroupRolesData> titles =
  10064. m_GroupsModule.GroupRoleDataRequest(this,
  10065. groupRolesRequest.GroupData.GroupID);
  10066. groupRolesReply.GroupData.RoleCount =
  10067. titles.Count;
  10068. groupRolesReply.RoleData =
  10069. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  10070. int i = 0;
  10071. foreach (GroupRolesData d in titles)
  10072. {
  10073. groupRolesReply.RoleData[i] =
  10074. new GroupRoleDataReplyPacket.RoleDataBlock();
  10075. groupRolesReply.RoleData[i].RoleID =
  10076. d.RoleID;
  10077. groupRolesReply.RoleData[i].Name =
  10078. Util.StringToBytes256(d.Name);
  10079. groupRolesReply.RoleData[i].Title =
  10080. Util.StringToBytes256(d.Title);
  10081. groupRolesReply.RoleData[i].Description =
  10082. Util.StringToBytes1024(d.Description);
  10083. groupRolesReply.RoleData[i].Powers =
  10084. d.Powers;
  10085. groupRolesReply.RoleData[i].Members =
  10086. (uint)d.Members;
  10087. i++;
  10088. }
  10089. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  10090. }
  10091. return true;
  10092. }
  10093. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  10094. {
  10095. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  10096. (GroupRoleMembersRequestPacket)Pack;
  10097. #region Packet Session and User Check
  10098. if (m_checkPackets)
  10099. {
  10100. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  10101. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  10102. return true;
  10103. }
  10104. #endregion
  10105. if (m_GroupsModule != null)
  10106. {
  10107. List<GroupRoleMembersData> mappings =
  10108. m_GroupsModule.GroupRoleMembersRequest(this,
  10109. groupRoleMembersRequest.GroupData.GroupID);
  10110. int mappingsCount = mappings.Count;
  10111. while (mappings.Count > 0)
  10112. {
  10113. int pairs = mappings.Count;
  10114. if (pairs > 32)
  10115. pairs = 32;
  10116. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  10117. groupRoleMembersReply.AgentData =
  10118. new GroupRoleMembersReplyPacket.AgentDataBlock();
  10119. groupRoleMembersReply.AgentData.AgentID =
  10120. AgentId;
  10121. groupRoleMembersReply.AgentData.GroupID =
  10122. groupRoleMembersRequest.GroupData.GroupID;
  10123. groupRoleMembersReply.AgentData.RequestID =
  10124. groupRoleMembersRequest.GroupData.RequestID;
  10125. groupRoleMembersReply.AgentData.TotalPairs =
  10126. (uint)mappingsCount;
  10127. groupRoleMembersReply.MemberData =
  10128. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  10129. for (int i = 0; i < pairs; i++)
  10130. {
  10131. GroupRoleMembersData d = mappings[0];
  10132. mappings.RemoveAt(0);
  10133. groupRoleMembersReply.MemberData[i] =
  10134. new GroupRoleMembersReplyPacket.MemberDataBlock();
  10135. groupRoleMembersReply.MemberData[i].RoleID =
  10136. d.RoleID;
  10137. groupRoleMembersReply.MemberData[i].MemberID =
  10138. d.MemberID;
  10139. }
  10140. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  10141. }
  10142. }
  10143. return true;
  10144. }
  10145. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  10146. {
  10147. CreateGroupRequestPacket createGroupRequest =
  10148. (CreateGroupRequestPacket)Pack;
  10149. #region Packet Session and User Check
  10150. if (m_checkPackets)
  10151. {
  10152. if (createGroupRequest.AgentData.SessionID != SessionId ||
  10153. createGroupRequest.AgentData.AgentID != AgentId)
  10154. return true;
  10155. }
  10156. #endregion
  10157. if (m_GroupsModule != null)
  10158. {
  10159. m_GroupsModule.CreateGroup(this,
  10160. Utils.BytesToString(createGroupRequest.GroupData.Name),
  10161. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  10162. createGroupRequest.GroupData.ShowInList,
  10163. createGroupRequest.GroupData.InsigniaID,
  10164. createGroupRequest.GroupData.MembershipFee,
  10165. createGroupRequest.GroupData.OpenEnrollment,
  10166. createGroupRequest.GroupData.AllowPublish,
  10167. createGroupRequest.GroupData.MaturePublish);
  10168. }
  10169. return true;
  10170. }
  10171. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  10172. {
  10173. UpdateGroupInfoPacket updateGroupInfo =
  10174. (UpdateGroupInfoPacket)Pack;
  10175. #region Packet Session and User Check
  10176. if (m_checkPackets)
  10177. {
  10178. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  10179. updateGroupInfo.AgentData.AgentID != AgentId)
  10180. return true;
  10181. }
  10182. #endregion
  10183. if (m_GroupsModule != null)
  10184. {
  10185. m_GroupsModule.UpdateGroupInfo(this,
  10186. updateGroupInfo.GroupData.GroupID,
  10187. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  10188. updateGroupInfo.GroupData.ShowInList,
  10189. updateGroupInfo.GroupData.InsigniaID,
  10190. updateGroupInfo.GroupData.MembershipFee,
  10191. updateGroupInfo.GroupData.OpenEnrollment,
  10192. updateGroupInfo.GroupData.AllowPublish,
  10193. updateGroupInfo.GroupData.MaturePublish);
  10194. }
  10195. return true;
  10196. }
  10197. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  10198. {
  10199. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  10200. (SetGroupAcceptNoticesPacket)Pack;
  10201. #region Packet Session and User Check
  10202. if (m_checkPackets)
  10203. {
  10204. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  10205. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  10206. return true;
  10207. }
  10208. #endregion
  10209. if (m_GroupsModule != null)
  10210. {
  10211. m_GroupsModule.SetGroupAcceptNotices(this,
  10212. setGroupAcceptNotices.Data.GroupID,
  10213. setGroupAcceptNotices.Data.AcceptNotices,
  10214. setGroupAcceptNotices.NewData.ListInProfile);
  10215. }
  10216. return true;
  10217. }
  10218. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  10219. {
  10220. GroupTitleUpdatePacket groupTitleUpdate =
  10221. (GroupTitleUpdatePacket)Pack;
  10222. #region Packet Session and User Check
  10223. if (m_checkPackets)
  10224. {
  10225. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  10226. groupTitleUpdate.AgentData.AgentID != AgentId)
  10227. return true;
  10228. }
  10229. #endregion
  10230. if (m_GroupsModule != null)
  10231. {
  10232. m_GroupsModule.GroupTitleUpdate(this,
  10233. groupTitleUpdate.AgentData.GroupID,
  10234. groupTitleUpdate.AgentData.TitleRoleID);
  10235. }
  10236. return true;
  10237. }
  10238. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  10239. {
  10240. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  10241. if (m_GroupsModule != null)
  10242. {
  10243. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  10244. if (handlerParcelDeedToGroup != null)
  10245. {
  10246. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  10247. }
  10248. }
  10249. return true;
  10250. }
  10251. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  10252. {
  10253. GroupNoticesListRequestPacket groupNoticesListRequest =
  10254. (GroupNoticesListRequestPacket)Pack;
  10255. #region Packet Session and User Check
  10256. if (m_checkPackets)
  10257. {
  10258. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  10259. groupNoticesListRequest.AgentData.AgentID != AgentId)
  10260. return true;
  10261. }
  10262. #endregion
  10263. if (m_GroupsModule != null)
  10264. {
  10265. GroupNoticeData[] gn =
  10266. m_GroupsModule.GroupNoticesListRequest(this,
  10267. groupNoticesListRequest.Data.GroupID);
  10268. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  10269. groupNoticesListReply.AgentData =
  10270. new GroupNoticesListReplyPacket.AgentDataBlock();
  10271. groupNoticesListReply.AgentData.AgentID = AgentId;
  10272. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  10273. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  10274. int i = 0;
  10275. foreach (GroupNoticeData g in gn)
  10276. {
  10277. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  10278. groupNoticesListReply.Data[i].NoticeID =
  10279. g.NoticeID;
  10280. groupNoticesListReply.Data[i].Timestamp =
  10281. g.Timestamp;
  10282. groupNoticesListReply.Data[i].FromName =
  10283. Util.StringToBytes256(g.FromName);
  10284. groupNoticesListReply.Data[i].Subject =
  10285. Util.StringToBytes256(g.Subject);
  10286. groupNoticesListReply.Data[i].HasAttachment =
  10287. g.HasAttachment;
  10288. groupNoticesListReply.Data[i].AssetType =
  10289. g.AssetType;
  10290. i++;
  10291. }
  10292. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  10293. }
  10294. return true;
  10295. }
  10296. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  10297. {
  10298. GroupNoticeRequestPacket groupNoticeRequest =
  10299. (GroupNoticeRequestPacket)Pack;
  10300. #region Packet Session and User Check
  10301. if (m_checkPackets)
  10302. {
  10303. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  10304. groupNoticeRequest.AgentData.AgentID != AgentId)
  10305. return true;
  10306. }
  10307. #endregion
  10308. if (m_GroupsModule != null)
  10309. {
  10310. m_GroupsModule.GroupNoticeRequest(this,
  10311. groupNoticeRequest.Data.GroupNoticeID);
  10312. }
  10313. return true;
  10314. }
  10315. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  10316. {
  10317. GroupRoleUpdatePacket groupRoleUpdate =
  10318. (GroupRoleUpdatePacket)Pack;
  10319. #region Packet Session and User Check
  10320. if (m_checkPackets)
  10321. {
  10322. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  10323. groupRoleUpdate.AgentData.AgentID != AgentId)
  10324. return true;
  10325. }
  10326. #endregion
  10327. if (m_GroupsModule != null)
  10328. {
  10329. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  10330. groupRoleUpdate.RoleData)
  10331. {
  10332. m_GroupsModule.GroupRoleUpdate(this,
  10333. groupRoleUpdate.AgentData.GroupID,
  10334. d.RoleID,
  10335. Utils.BytesToString(d.Name),
  10336. Utils.BytesToString(d.Description),
  10337. Utils.BytesToString(d.Title),
  10338. d.Powers,
  10339. d.UpdateType);
  10340. }
  10341. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  10342. }
  10343. return true;
  10344. }
  10345. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  10346. {
  10347. GroupRoleChangesPacket groupRoleChanges =
  10348. (GroupRoleChangesPacket)Pack;
  10349. #region Packet Session and User Check
  10350. if (m_checkPackets)
  10351. {
  10352. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  10353. groupRoleChanges.AgentData.AgentID != AgentId)
  10354. return true;
  10355. }
  10356. #endregion
  10357. if (m_GroupsModule != null)
  10358. {
  10359. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  10360. groupRoleChanges.RoleChange)
  10361. {
  10362. m_GroupsModule.GroupRoleChanges(this,
  10363. groupRoleChanges.AgentData.GroupID,
  10364. d.RoleID,
  10365. d.MemberID,
  10366. d.Change);
  10367. }
  10368. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  10369. }
  10370. return true;
  10371. }
  10372. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  10373. {
  10374. JoinGroupRequestPacket joinGroupRequest =
  10375. (JoinGroupRequestPacket)Pack;
  10376. #region Packet Session and User Check
  10377. if (m_checkPackets)
  10378. {
  10379. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  10380. joinGroupRequest.AgentData.AgentID != AgentId)
  10381. return true;
  10382. }
  10383. #endregion
  10384. if (m_GroupsModule != null)
  10385. {
  10386. m_GroupsModule.JoinGroupRequest(this,
  10387. joinGroupRequest.GroupData.GroupID);
  10388. }
  10389. return true;
  10390. }
  10391. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  10392. {
  10393. LeaveGroupRequestPacket leaveGroupRequest =
  10394. (LeaveGroupRequestPacket)Pack;
  10395. #region Packet Session and User Check
  10396. if (m_checkPackets)
  10397. {
  10398. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  10399. leaveGroupRequest.AgentData.AgentID != AgentId)
  10400. return true;
  10401. }
  10402. #endregion
  10403. if (m_GroupsModule != null)
  10404. {
  10405. m_GroupsModule.LeaveGroupRequest(this,
  10406. leaveGroupRequest.GroupData.GroupID);
  10407. }
  10408. return true;
  10409. }
  10410. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  10411. {
  10412. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  10413. (EjectGroupMemberRequestPacket)Pack;
  10414. #region Packet Session and User Check
  10415. if (m_checkPackets)
  10416. {
  10417. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  10418. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  10419. return true;
  10420. }
  10421. #endregion
  10422. if (m_GroupsModule != null)
  10423. {
  10424. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  10425. in ejectGroupMemberRequest.EjectData)
  10426. {
  10427. m_GroupsModule.EjectGroupMemberRequest(this,
  10428. ejectGroupMemberRequest.GroupData.GroupID,
  10429. e.EjecteeID);
  10430. }
  10431. }
  10432. return true;
  10433. }
  10434. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  10435. {
  10436. InviteGroupRequestPacket inviteGroupRequest =
  10437. (InviteGroupRequestPacket)Pack;
  10438. #region Packet Session and User Check
  10439. if (m_checkPackets)
  10440. {
  10441. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  10442. inviteGroupRequest.AgentData.AgentID != AgentId)
  10443. return true;
  10444. }
  10445. #endregion
  10446. if (m_GroupsModule != null)
  10447. {
  10448. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  10449. inviteGroupRequest.InviteData)
  10450. {
  10451. m_GroupsModule.InviteGroupRequest(this,
  10452. inviteGroupRequest.GroupData.GroupID,
  10453. b.InviteeID,
  10454. b.RoleID);
  10455. }
  10456. }
  10457. return true;
  10458. }
  10459. #endregion Groups
  10460. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  10461. {
  10462. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  10463. #region Packet Session and User Check
  10464. if (m_checkPackets)
  10465. {
  10466. if (startLureRequest.AgentData.SessionID != SessionId ||
  10467. startLureRequest.AgentData.AgentID != AgentId)
  10468. return true;
  10469. }
  10470. #endregion
  10471. StartLure handlerStartLure = OnStartLure;
  10472. if (handlerStartLure != null)
  10473. {
  10474. for (int i = 0 ; i < startLureRequest.TargetData.Length ; i++)
  10475. {
  10476. handlerStartLure(startLureRequest.Info.LureType,
  10477. Utils.BytesToString(
  10478. startLureRequest.Info.Message),
  10479. startLureRequest.TargetData[i].TargetID,
  10480. this);
  10481. }
  10482. }
  10483. return true;
  10484. }
  10485. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  10486. {
  10487. TeleportLureRequestPacket teleportLureRequest =
  10488. (TeleportLureRequestPacket)Pack;
  10489. #region Packet Session and User Check
  10490. if (m_checkPackets)
  10491. {
  10492. if (teleportLureRequest.Info.SessionID != SessionId ||
  10493. teleportLureRequest.Info.AgentID != AgentId)
  10494. return true;
  10495. }
  10496. #endregion
  10497. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  10498. if (handlerTeleportLureRequest != null)
  10499. handlerTeleportLureRequest(
  10500. teleportLureRequest.Info.LureID,
  10501. teleportLureRequest.Info.TeleportFlags,
  10502. this);
  10503. return true;
  10504. }
  10505. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  10506. {
  10507. ClassifiedInfoRequestPacket classifiedInfoRequest =
  10508. (ClassifiedInfoRequestPacket)Pack;
  10509. #region Packet Session and User Check
  10510. if (m_checkPackets)
  10511. {
  10512. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  10513. classifiedInfoRequest.AgentData.AgentID != AgentId)
  10514. return true;
  10515. }
  10516. #endregion
  10517. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  10518. if (handlerClassifiedInfoRequest != null)
  10519. handlerClassifiedInfoRequest(
  10520. classifiedInfoRequest.Data.ClassifiedID,
  10521. this);
  10522. return true;
  10523. }
  10524. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  10525. {
  10526. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  10527. (ClassifiedInfoUpdatePacket)Pack;
  10528. #region Packet Session and User Check
  10529. if (m_checkPackets)
  10530. {
  10531. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  10532. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  10533. return true;
  10534. }
  10535. #endregion
  10536. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  10537. if (handlerClassifiedInfoUpdate != null)
  10538. handlerClassifiedInfoUpdate(
  10539. classifiedInfoUpdate.Data.ClassifiedID,
  10540. classifiedInfoUpdate.Data.Category,
  10541. Utils.BytesToString(
  10542. classifiedInfoUpdate.Data.Name),
  10543. Utils.BytesToString(
  10544. classifiedInfoUpdate.Data.Desc),
  10545. classifiedInfoUpdate.Data.ParcelID,
  10546. classifiedInfoUpdate.Data.ParentEstate,
  10547. classifiedInfoUpdate.Data.SnapshotID,
  10548. new Vector3(
  10549. classifiedInfoUpdate.Data.PosGlobal),
  10550. classifiedInfoUpdate.Data.ClassifiedFlags,
  10551. classifiedInfoUpdate.Data.PriceForListing,
  10552. this);
  10553. return true;
  10554. }
  10555. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  10556. {
  10557. ClassifiedDeletePacket classifiedDelete =
  10558. (ClassifiedDeletePacket)Pack;
  10559. #region Packet Session and User Check
  10560. if (m_checkPackets)
  10561. {
  10562. if (classifiedDelete.AgentData.SessionID != SessionId ||
  10563. classifiedDelete.AgentData.AgentID != AgentId)
  10564. return true;
  10565. }
  10566. #endregion
  10567. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  10568. if (handlerClassifiedDelete != null)
  10569. handlerClassifiedDelete(
  10570. classifiedDelete.Data.ClassifiedID,
  10571. this);
  10572. return true;
  10573. }
  10574. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  10575. {
  10576. ClassifiedGodDeletePacket classifiedGodDelete =
  10577. (ClassifiedGodDeletePacket)Pack;
  10578. #region Packet Session and User Check
  10579. if (m_checkPackets)
  10580. {
  10581. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  10582. classifiedGodDelete.AgentData.AgentID != AgentId)
  10583. return true;
  10584. }
  10585. #endregion
  10586. ClassifiedGodDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  10587. if (handlerClassifiedGodDelete != null)
  10588. handlerClassifiedGodDelete(
  10589. classifiedGodDelete.Data.ClassifiedID,
  10590. classifiedGodDelete.Data.QueryID,
  10591. this);
  10592. return true;
  10593. }
  10594. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  10595. {
  10596. EventGodDeletePacket eventGodDelete =
  10597. (EventGodDeletePacket)Pack;
  10598. #region Packet Session and User Check
  10599. if (m_checkPackets)
  10600. {
  10601. if (eventGodDelete.AgentData.SessionID != SessionId ||
  10602. eventGodDelete.AgentData.AgentID != AgentId)
  10603. return true;
  10604. }
  10605. #endregion
  10606. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  10607. if (handlerEventGodDelete != null)
  10608. handlerEventGodDelete(
  10609. eventGodDelete.EventData.EventID,
  10610. eventGodDelete.QueryData.QueryID,
  10611. Utils.BytesToString(
  10612. eventGodDelete.QueryData.QueryText),
  10613. eventGodDelete.QueryData.QueryFlags,
  10614. eventGodDelete.QueryData.QueryStart,
  10615. this);
  10616. return true;
  10617. }
  10618. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  10619. {
  10620. EventNotificationAddRequestPacket eventNotificationAdd =
  10621. (EventNotificationAddRequestPacket)Pack;
  10622. #region Packet Session and User Check
  10623. if (m_checkPackets)
  10624. {
  10625. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  10626. eventNotificationAdd.AgentData.AgentID != AgentId)
  10627. return true;
  10628. }
  10629. #endregion
  10630. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  10631. if (handlerEventNotificationAddRequest != null)
  10632. handlerEventNotificationAddRequest(
  10633. eventNotificationAdd.EventData.EventID, this);
  10634. return true;
  10635. }
  10636. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  10637. {
  10638. EventNotificationRemoveRequestPacket eventNotificationRemove =
  10639. (EventNotificationRemoveRequestPacket)Pack;
  10640. #region Packet Session and User Check
  10641. if (m_checkPackets)
  10642. {
  10643. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  10644. eventNotificationRemove.AgentData.AgentID != AgentId)
  10645. return true;
  10646. }
  10647. #endregion
  10648. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  10649. if (handlerEventNotificationRemoveRequest != null)
  10650. handlerEventNotificationRemoveRequest(
  10651. eventNotificationRemove.EventData.EventID, this);
  10652. return true;
  10653. }
  10654. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  10655. {
  10656. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  10657. #region Packet Session and User Check
  10658. if (m_checkPackets)
  10659. {
  10660. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  10661. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  10662. return true;
  10663. }
  10664. #endregion
  10665. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  10666. if (handlerRetrieveInstantMessages != null)
  10667. handlerRetrieveInstantMessages(this);
  10668. return true;
  10669. }
  10670. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  10671. {
  10672. PickDeletePacket pickDelete =
  10673. (PickDeletePacket)Pack;
  10674. #region Packet Session and User Check
  10675. if (m_checkPackets)
  10676. {
  10677. if (pickDelete.AgentData.SessionID != SessionId ||
  10678. pickDelete.AgentData.AgentID != AgentId)
  10679. return true;
  10680. }
  10681. #endregion
  10682. PickDelete handlerPickDelete = OnPickDelete;
  10683. if (handlerPickDelete != null)
  10684. handlerPickDelete(this, pickDelete.Data.PickID);
  10685. return true;
  10686. }
  10687. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  10688. {
  10689. PickGodDeletePacket pickGodDelete =
  10690. (PickGodDeletePacket)Pack;
  10691. #region Packet Session and User Check
  10692. if (m_checkPackets)
  10693. {
  10694. if (pickGodDelete.AgentData.SessionID != SessionId ||
  10695. pickGodDelete.AgentData.AgentID != AgentId)
  10696. return true;
  10697. }
  10698. #endregion
  10699. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  10700. if (handlerPickGodDelete != null)
  10701. handlerPickGodDelete(this,
  10702. pickGodDelete.AgentData.AgentID,
  10703. pickGodDelete.Data.PickID,
  10704. pickGodDelete.Data.QueryID);
  10705. return true;
  10706. }
  10707. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  10708. {
  10709. PickInfoUpdatePacket pickInfoUpdate =
  10710. (PickInfoUpdatePacket)Pack;
  10711. #region Packet Session and User Check
  10712. if (m_checkPackets)
  10713. {
  10714. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  10715. pickInfoUpdate.AgentData.AgentID != AgentId)
  10716. return true;
  10717. }
  10718. #endregion
  10719. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  10720. if (handlerPickInfoUpdate != null)
  10721. handlerPickInfoUpdate(this,
  10722. pickInfoUpdate.Data.PickID,
  10723. pickInfoUpdate.Data.CreatorID,
  10724. pickInfoUpdate.Data.TopPick,
  10725. Utils.BytesToString(pickInfoUpdate.Data.Name),
  10726. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  10727. pickInfoUpdate.Data.SnapshotID,
  10728. pickInfoUpdate.Data.SortOrder,
  10729. pickInfoUpdate.Data.Enabled);
  10730. return true;
  10731. }
  10732. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  10733. {
  10734. AvatarNotesUpdatePacket avatarNotesUpdate =
  10735. (AvatarNotesUpdatePacket)Pack;
  10736. #region Packet Session and User Check
  10737. if (m_checkPackets)
  10738. {
  10739. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  10740. avatarNotesUpdate.AgentData.AgentID != AgentId)
  10741. return true;
  10742. }
  10743. #endregion
  10744. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  10745. if (handlerAvatarNotesUpdate != null)
  10746. handlerAvatarNotesUpdate(this,
  10747. avatarNotesUpdate.Data.TargetID,
  10748. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10749. return true;
  10750. }
  10751. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10752. {
  10753. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10754. (AvatarInterestsUpdatePacket)Pack;
  10755. #region Packet Session and User Check
  10756. if (m_checkPackets)
  10757. {
  10758. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10759. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10760. return true;
  10761. }
  10762. #endregion
  10763. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10764. if (handlerAvatarInterestUpdate != null)
  10765. handlerAvatarInterestUpdate(this,
  10766. avatarInterestUpdate.PropertiesData.WantToMask,
  10767. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10768. avatarInterestUpdate.PropertiesData.SkillsMask,
  10769. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10770. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10771. return true;
  10772. }
  10773. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10774. {
  10775. GrantUserRightsPacket GrantUserRights =
  10776. (GrantUserRightsPacket)Pack;
  10777. #region Packet Session and User Check
  10778. if (m_checkPackets)
  10779. {
  10780. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10781. GrantUserRights.AgentData.AgentID != AgentId)
  10782. return true;
  10783. }
  10784. #endregion
  10785. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10786. if (GrantUserRightsHandler != null)
  10787. GrantUserRightsHandler(this,
  10788. GrantUserRights.Rights[0].AgentRelated,
  10789. GrantUserRights.Rights[0].RelatedRights);
  10790. return true;
  10791. }
  10792. private bool HandleRevokePermissions(IClientAPI sender, Packet Pack)
  10793. {
  10794. RevokePermissionsPacket pkt = (RevokePermissionsPacket)Pack;
  10795. if (pkt.AgentData.SessionID != SessionId ||
  10796. pkt .AgentData.AgentID != AgentId)
  10797. return true;
  10798. // don't use multidelegate "event"
  10799. ScenePresence sp = (ScenePresence)SceneAgent;
  10800. if(sp != null && !sp.IsDeleted && !sp.IsInTransit)
  10801. {
  10802. UUID objectID = pkt.Data.ObjectID;
  10803. uint permissions = pkt.Data.ObjectPermissions;
  10804. sp.HandleRevokePermissions(objectID , permissions);
  10805. }
  10806. return true;
  10807. }
  10808. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10809. {
  10810. PlacesQueryPacket placesQueryPacket =
  10811. (PlacesQueryPacket)Pack;
  10812. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10813. if (handlerPlacesQuery != null)
  10814. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10815. placesQueryPacket.TransactionData.TransactionID,
  10816. Utils.BytesToString(
  10817. placesQueryPacket.QueryData.QueryText),
  10818. placesQueryPacket.QueryData.QueryFlags,
  10819. (byte)placesQueryPacket.QueryData.Category,
  10820. Utils.BytesToString(
  10821. placesQueryPacket.QueryData.SimName),
  10822. this);
  10823. return true;
  10824. }
  10825. #endregion Packet Handlers
  10826. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10827. {
  10828. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10829. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10830. // TODO: don't create new blocks if recycling an old packet
  10831. scriptQuestion.Data.TaskID = taskID;
  10832. scriptQuestion.Data.ItemID = itemID;
  10833. scriptQuestion.Data.Questions = question;
  10834. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10835. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10836. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10837. }
  10838. /// <summary>
  10839. /// Handler called when we receive a logout packet.
  10840. /// </summary>
  10841. /// <param name="client"></param>
  10842. /// <param name="packet"></param>
  10843. /// <returns></returns>
  10844. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10845. {
  10846. if (packet.Type == PacketType.LogoutRequest)
  10847. {
  10848. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10849. }
  10850. return Logout(client);
  10851. }
  10852. /// <summary>
  10853. ///
  10854. /// </summary>
  10855. /// <param name="client"></param>
  10856. /// <returns></returns>
  10857. protected virtual bool Logout(IClientAPI client)
  10858. {
  10859. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10860. Action<IClientAPI> handlerLogout = OnLogout;
  10861. if (handlerLogout != null)
  10862. {
  10863. handlerLogout(client);
  10864. }
  10865. return true;
  10866. }
  10867. /// <summary>
  10868. /// </summary>
  10869. /// <remarks>
  10870. /// At the moment, we always reply that there is no cached texture.
  10871. /// </remarks>
  10872. /// <param name="simclient"></param>
  10873. /// <param name="packet"></param>
  10874. /// <returns></returns>
  10875. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10876. {
  10877. //m_log.Debug("texture cached: " + packet.ToString());
  10878. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10879. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10880. if (cachedtex.AgentData.SessionID != SessionId)
  10881. return false;
  10882. // TODO: don't create new blocks if recycling an old packet
  10883. cachedresp.AgentData.AgentID = AgentId;
  10884. cachedresp.AgentData.SessionID = m_sessionId;
  10885. cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum;
  10886. cachedresp.WearableData =
  10887. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  10888. int cacheHits = 0;
  10889. // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
  10890. WearableCacheItem[] cacheItems = null;
  10891. ScenePresence p = m_scene.GetScenePresence(AgentId);
  10892. if (p != null && p.Appearance != null)
  10893. {
  10894. cacheItems = p.Appearance.WearableCacheItems;
  10895. }
  10896. int maxWearablesLoop = cachedtex.WearableData.Length;
  10897. if (cacheItems != null)
  10898. {
  10899. if (maxWearablesLoop > cacheItems.Length)
  10900. maxWearablesLoop = cacheItems.Length;
  10901. for (int i = 0; i < maxWearablesLoop; i++)
  10902. {
  10903. int idx = cachedtex.WearableData[i].TextureIndex;
  10904. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10905. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10906. cachedresp.WearableData[i].HostName = new byte[0];
  10907. if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
  10908. {
  10909. cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
  10910. cacheHits++;
  10911. }
  10912. else
  10913. {
  10914. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10915. }
  10916. }
  10917. }
  10918. else
  10919. {
  10920. for (int i = 0; i < maxWearablesLoop; i++)
  10921. {
  10922. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10923. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10924. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10925. cachedresp.WearableData[i].HostName = new byte[0];
  10926. }
  10927. }
  10928. //m_log.DebugFormat("texture cached: hits {0}", cacheHits);
  10929. cachedresp.Header.Zerocoded = true;
  10930. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10931. return true;
  10932. }
  10933. /// <summary>
  10934. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10935. /// its appearance texture cached.
  10936. /// </summary>
  10937. /// <param name="avatar"></param>
  10938. /// <param name="serial"></param>
  10939. /// <param name="cachedTextures"></param>
  10940. /// <returns></returns>
  10941. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10942. {
  10943. ScenePresence presence = avatar as ScenePresence;
  10944. if (presence == null)
  10945. return;
  10946. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10947. // TODO: don't create new blocks if recycling an old packet
  10948. cachedresp.AgentData.AgentID = m_agentId;
  10949. cachedresp.AgentData.SessionID = m_sessionId;
  10950. cachedresp.AgentData.SerialNum = serial;
  10951. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10952. for (int i = 0; i < cachedTextures.Count; i++)
  10953. {
  10954. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10955. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10956. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10957. cachedresp.WearableData[i].HostName = new byte[0];
  10958. }
  10959. cachedresp.Header.Zerocoded = true;
  10960. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10961. }
  10962. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10963. {
  10964. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10965. if (multipleupdate.AgentData.SessionID != SessionId)
  10966. return false;
  10967. // m_log.DebugFormat(
  10968. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10969. Scene tScene = (Scene)m_scene;
  10970. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10971. {
  10972. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10973. // Can't act on Null Data
  10974. if (block.Data != null)
  10975. {
  10976. uint localId = block.ObjectLocalID;
  10977. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10978. if (part == null)
  10979. {
  10980. // It's a ghost! tell the client to delete it from view.
  10981. simClient.SendKillObject(new List<uint> { localId });
  10982. }
  10983. else
  10984. {
  10985. ClientChangeObject updatehandler = onClientChangeObject;
  10986. if (updatehandler != null)
  10987. {
  10988. ObjectChangeData udata = new ObjectChangeData();
  10989. /*ubit from ll JIRA:
  10990. * 0x01 position
  10991. * 0x02 rotation
  10992. * 0x04 scale
  10993. * 0x08 LINK_SET
  10994. * 0x10 UNIFORM for scale
  10995. */
  10996. // translate to internal changes
  10997. // not all cases .. just the ones older code did
  10998. switch (block.Type)
  10999. {
  11000. case 1: //change position sp
  11001. udata.position = new Vector3(block.Data, 0);
  11002. udata.change = ObjectChangeType.primP;
  11003. updatehandler(localId, udata, this);
  11004. break;
  11005. case 2: // rotation sp
  11006. udata.rotation = new Quaternion(block.Data, 0, true);
  11007. udata.change = ObjectChangeType.primR;
  11008. updatehandler(localId, udata, this);
  11009. break;
  11010. case 3: // position plus rotation
  11011. udata.position = new Vector3(block.Data, 0);
  11012. udata.rotation = new Quaternion(block.Data, 12, true);
  11013. udata.change = ObjectChangeType.primPR;
  11014. updatehandler(localId, udata, this);
  11015. break;
  11016. case 4: // scale sp
  11017. udata.scale = new Vector3(block.Data, 0);
  11018. udata.change = ObjectChangeType.primS;
  11019. updatehandler(localId, udata, this);
  11020. break;
  11021. case 0x14: // uniform scale sp
  11022. udata.scale = new Vector3(block.Data, 0);
  11023. udata.change = ObjectChangeType.primUS;
  11024. updatehandler(localId, udata, this);
  11025. break;
  11026. case 5: // scale and position sp
  11027. udata.position = new Vector3(block.Data, 0);
  11028. udata.scale = new Vector3(block.Data, 12);
  11029. udata.change = ObjectChangeType.primPS;
  11030. updatehandler(localId, udata, this);
  11031. break;
  11032. case 0x15: //uniform scale and position
  11033. udata.position = new Vector3(block.Data, 0);
  11034. udata.scale = new Vector3(block.Data, 12);
  11035. udata.change = ObjectChangeType.primPUS;
  11036. updatehandler(localId, udata, this);
  11037. break;
  11038. // now group related (bit 4)
  11039. case 9: //( 8 + 1 )group position
  11040. udata.position = new Vector3(block.Data, 0);
  11041. udata.change = ObjectChangeType.groupP;
  11042. updatehandler(localId, udata, this);
  11043. break;
  11044. case 0x0A: // (8 + 2) group rotation
  11045. udata.rotation = new Quaternion(block.Data, 0, true);
  11046. udata.change = ObjectChangeType.groupR;
  11047. updatehandler(localId, udata, this);
  11048. break;
  11049. case 0x0B: //( 8 + 2 + 1) group rotation and position
  11050. udata.position = new Vector3(block.Data, 0);
  11051. udata.rotation = new Quaternion(block.Data, 12, true);
  11052. udata.change = ObjectChangeType.groupPR;
  11053. updatehandler(localId, udata, this);
  11054. break;
  11055. case 0x0C: // (8 + 4) group scale
  11056. // only afects root prim and only sent by viewer editor object tab scaling
  11057. // mouse edition only allows uniform scaling
  11058. // SL MAY CHANGE THIS in viewers
  11059. udata.scale = new Vector3(block.Data, 0);
  11060. udata.change = ObjectChangeType.groupS;
  11061. updatehandler(localId, udata, this);
  11062. break;
  11063. case 0x0D: //(8 + 4 + 1) group scale and position
  11064. // exception as above
  11065. udata.position = new Vector3(block.Data, 0);
  11066. udata.scale = new Vector3(block.Data, 12);
  11067. udata.change = ObjectChangeType.groupPS;
  11068. updatehandler(localId, udata, this);
  11069. break;
  11070. case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM
  11071. udata.scale = new Vector3(block.Data, 0);
  11072. udata.change = ObjectChangeType.groupUS;
  11073. updatehandler(localId, udata, this);
  11074. break;
  11075. case 0x1D: // (UNIFORM + GROUP + SCALE + POS)
  11076. udata.position = new Vector3(block.Data, 0);
  11077. udata.scale = new Vector3(block.Data, 12);
  11078. udata.change = ObjectChangeType.groupPUS;
  11079. updatehandler(localId, udata, this);
  11080. break;
  11081. default:
  11082. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  11083. break;
  11084. }
  11085. }
  11086. }
  11087. }
  11088. }
  11089. return true;
  11090. }
  11091. public void RequestMapLayer()
  11092. {
  11093. //should be getting the map layer from the grid server
  11094. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  11095. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  11096. // TODO: don't create new blocks if recycling an old packet
  11097. mapReply.AgentData.AgentID = AgentId;
  11098. mapReply.AgentData.Flags = 0;
  11099. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  11100. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  11101. mapReply.LayerData[0].Bottom = 0;
  11102. mapReply.LayerData[0].Left = 0;
  11103. mapReply.LayerData[0].Top = 30000;
  11104. mapReply.LayerData[0].Right = 30000;
  11105. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  11106. mapReply.Header.Zerocoded = true;
  11107. OutPacket(mapReply, ThrottleOutPacketType.Land);
  11108. }
  11109. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  11110. {
  11111. /*
  11112. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  11113. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  11114. mbReply.AgentData.AgentId = AgentId;
  11115. int len;
  11116. if (simMapProfiles == null)
  11117. len = 0;
  11118. else
  11119. len = simMapProfiles.Count;
  11120. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  11121. int iii;
  11122. for (iii = 0; iii < len; iii++)
  11123. {
  11124. Hashtable mp = (Hashtable)simMapProfiles[iii];
  11125. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  11126. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  11127. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  11128. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  11129. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  11130. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  11131. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  11132. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  11133. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  11134. }
  11135. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  11136. */
  11137. }
  11138. /// <summary>
  11139. /// Sets the throttles from values supplied by the client
  11140. /// </summary>
  11141. /// <param name="throttles"></param>
  11142. public void SetChildAgentThrottle(byte[] throttles)
  11143. {
  11144. SetChildAgentThrottle(throttles, 1.0f);
  11145. }
  11146. public void SetChildAgentThrottle(byte[] throttles,float factor)
  11147. {
  11148. m_udpClient.SetThrottles(throttles, factor);
  11149. GenericCall2 handler = OnUpdateThrottles;
  11150. if (handler != null)
  11151. {
  11152. handler();
  11153. }
  11154. }
  11155. /// <summary>
  11156. /// Sets the throttles from values supplied caller
  11157. /// </summary>
  11158. /// <param name="throttles"></param>
  11159. public void SetAgentThrottleSilent(int throttle, int setting)
  11160. {
  11161. m_udpClient.ForceThrottleSetting(throttle,setting);
  11162. }
  11163. public int GetAgentThrottleSilent(int throttle)
  11164. {
  11165. return m_udpClient.GetThrottleSetting(throttle);
  11166. }
  11167. /// <summary>
  11168. /// Get the current throttles for this client as a packed byte array
  11169. /// </summary>
  11170. /// <param name="multiplier">Unused</param>
  11171. /// <returns></returns>
  11172. public byte[] GetThrottlesPacked(float multiplier)
  11173. {
  11174. return m_udpClient.GetThrottlesPacked(multiplier);
  11175. }
  11176. /// <summary>
  11177. /// Cruft?
  11178. /// </summary>
  11179. public virtual void InPacket(object NewPack)
  11180. {
  11181. throw new NotImplementedException();
  11182. }
  11183. /// <summary>
  11184. /// This is the starting point for sending a simulator packet out to the client
  11185. /// </summary>
  11186. /// <param name="packet">Packet to send</param>
  11187. /// <param name="throttlePacketType">Throttling category for the packet</param>
  11188. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  11189. {
  11190. #region BinaryStats
  11191. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  11192. #endregion BinaryStats
  11193. OutPacket(packet, throttlePacketType, true);
  11194. }
  11195. /// <summary>
  11196. /// This is the starting point for sending a simulator packet out to the client
  11197. /// </summary>
  11198. /// <param name="packet">Packet to send</param>
  11199. /// <param name="throttlePacketType">Throttling category for the packet</param>
  11200. /// <param name="doAutomaticSplitting">True to automatically split oversized
  11201. /// packets (the default), or false to disable splitting if the calling code
  11202. /// handles splitting manually</param>
  11203. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  11204. {
  11205. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  11206. }
  11207. /// <summary>
  11208. /// This is the starting point for sending a simulator packet out to the client
  11209. /// </summary>
  11210. /// <param name="packet">Packet to send</param>
  11211. /// <param name="throttlePacketType">Throttling category for the packet</param>
  11212. /// <param name="doAutomaticSplitting">True to automatically split oversized
  11213. /// packets (the default), or false to disable splitting if the calling code
  11214. /// handles splitting manually</param>
  11215. /// <param name="method">The method to be called in the event this packet is reliable
  11216. /// and unacknowledged. The server will provide normal resend capability if you do not
  11217. /// provide your own method.</param>
  11218. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  11219. {
  11220. /* this is causing packet loss for some reason
  11221. if(!m_udpClient.IsConnected)
  11222. {
  11223. PacketPool.Instance.ReturnPacket(packet);
  11224. return;
  11225. }
  11226. */
  11227. if (m_outPacketsToDrop != null)
  11228. {
  11229. if (m_outPacketsToDrop.Contains(packet.Type.ToString()))
  11230. {
  11231. PacketPool.Instance.ReturnPacket(packet);
  11232. return;
  11233. }
  11234. }
  11235. if (DebugPacketLevel > 0)
  11236. {
  11237. bool logPacket = true;
  11238. if (DebugPacketLevel <= 255
  11239. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  11240. logPacket = false;
  11241. if (DebugPacketLevel <= 200
  11242. && (packet.Type == PacketType.ImagePacket
  11243. || packet.Type == PacketType.ImageData
  11244. || packet.Type == PacketType.LayerData
  11245. || packet.Type == PacketType.CoarseLocationUpdate))
  11246. logPacket = false;
  11247. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  11248. logPacket = false;
  11249. if (DebugPacketLevel <= 50
  11250. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  11251. logPacket = false;
  11252. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  11253. logPacket = false;
  11254. if (logPacket)
  11255. m_log.DebugFormat(
  11256. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  11257. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  11258. }
  11259. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  11260. }
  11261. protected void HandleAutopilot(Object sender, string method, List<String> args)
  11262. {
  11263. float locx = 0;
  11264. float locy = 0;
  11265. float locz = 0;
  11266. uint regionX = 0;
  11267. uint regionY = 0;
  11268. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  11269. locx = (float)(Convert.ToDouble(args[0]) - (double)regionX);
  11270. locy = (float)(Convert.ToDouble(args[1]) - (double)regionY);
  11271. locz = Convert.ToSingle(args[2]);
  11272. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  11273. if (handlerAutoPilotGo != null)
  11274. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  11275. }
  11276. /// <summary>
  11277. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  11278. /// </summary>
  11279. /// <param name="Pack">OpenMetaverse.packet</param>
  11280. public void ProcessInPacket(Packet packet)
  11281. {
  11282. if (m_inPacketsToDrop != null)
  11283. if (m_inPacketsToDrop.Contains(packet.Type.ToString()))
  11284. return;
  11285. if (DebugPacketLevel > 0)
  11286. {
  11287. bool logPacket = true;
  11288. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  11289. logPacket = false;
  11290. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  11291. logPacket = false;
  11292. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  11293. logPacket = false;
  11294. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  11295. logPacket = false;
  11296. if (logPacket)
  11297. m_log.DebugFormat(
  11298. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  11299. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  11300. }
  11301. if (!ProcessPacketMethod(packet))
  11302. m_log.WarnFormat(
  11303. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  11304. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  11305. }
  11306. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  11307. {
  11308. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  11309. shape.PCode = addPacket.ObjectData.PCode;
  11310. shape.State = addPacket.ObjectData.State;
  11311. shape.LastAttachPoint = addPacket.ObjectData.State;
  11312. shape.PathBegin = addPacket.ObjectData.PathBegin;
  11313. shape.PathEnd = addPacket.ObjectData.PathEnd;
  11314. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  11315. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  11316. shape.PathShearX = addPacket.ObjectData.PathShearX;
  11317. shape.PathShearY = addPacket.ObjectData.PathShearY;
  11318. shape.PathSkew = addPacket.ObjectData.PathSkew;
  11319. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  11320. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  11321. shape.Scale = addPacket.ObjectData.Scale;
  11322. shape.PathCurve = addPacket.ObjectData.PathCurve;
  11323. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  11324. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  11325. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  11326. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  11327. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  11328. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  11329. shape.PathTwist = addPacket.ObjectData.PathTwist;
  11330. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  11331. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  11332. shape.TextureEntry = ntex.GetBytes();
  11333. //shape.Textures = ntex;
  11334. return shape;
  11335. }
  11336. public ClientInfo GetClientInfo()
  11337. {
  11338. ClientInfo info = m_udpClient.GetClientInfo();
  11339. info.proxyEP = null;
  11340. if (info.agentcircuit == null)
  11341. info.agentcircuit = RequestClientInfo();
  11342. return info;
  11343. }
  11344. public void SetClientInfo(ClientInfo info)
  11345. {
  11346. m_udpClient.SetClientInfo(info);
  11347. }
  11348. #region Media Parcel Members
  11349. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  11350. {
  11351. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  11352. commandMessagePacket.CommandBlock.Flags = flags;
  11353. commandMessagePacket.CommandBlock.Command = (uint)command;
  11354. commandMessagePacket.CommandBlock.Time = time;
  11355. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  11356. }
  11357. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  11358. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  11359. byte mediaLoop)
  11360. {
  11361. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  11362. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  11363. updatePacket.DataBlock.MediaID = mediaTextureID;
  11364. updatePacket.DataBlock.MediaAutoScale = autoScale;
  11365. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  11366. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  11367. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  11368. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  11369. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  11370. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  11371. }
  11372. #endregion
  11373. #region Camera
  11374. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  11375. {
  11376. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  11377. packet.ObjectData.ObjectID = objectID;
  11378. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  11379. uint idx = 0;
  11380. foreach (KeyValuePair<int, float> pair in parameters)
  11381. {
  11382. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  11383. block.Type = pair.Key;
  11384. block.Value = pair.Value;
  11385. camPropBlock[idx++] = block;
  11386. }
  11387. packet.CameraProperty = camPropBlock;
  11388. OutPacket(packet, ThrottleOutPacketType.Task);
  11389. }
  11390. public void SendClearFollowCamProperties(UUID objectID)
  11391. {
  11392. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  11393. packet.ObjectData.ObjectID = objectID;
  11394. OutPacket(packet, ThrottleOutPacketType.Task);
  11395. }
  11396. #endregion
  11397. public void SetClientOption(string option, string value)
  11398. {
  11399. switch (option)
  11400. {
  11401. default:
  11402. break;
  11403. }
  11404. }
  11405. public string GetClientOption(string option)
  11406. {
  11407. switch (option)
  11408. {
  11409. default:
  11410. break;
  11411. }
  11412. return string.Empty;
  11413. }
  11414. #region IClientCore
  11415. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  11416. /// <summary>
  11417. /// Register an interface on this client, should only be called in the constructor.
  11418. /// </summary>
  11419. /// <typeparam name="T"></typeparam>
  11420. /// <param name="iface"></param>
  11421. protected void RegisterInterface<T>(T iface)
  11422. {
  11423. lock (m_clientInterfaces)
  11424. {
  11425. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  11426. {
  11427. m_clientInterfaces.Add(typeof(T), iface);
  11428. }
  11429. }
  11430. }
  11431. public bool TryGet<T>(out T iface)
  11432. {
  11433. if (m_clientInterfaces.ContainsKey(typeof(T)))
  11434. {
  11435. iface = (T)m_clientInterfaces[typeof(T)];
  11436. return true;
  11437. }
  11438. iface = default(T);
  11439. return false;
  11440. }
  11441. public T Get<T>()
  11442. {
  11443. return (T)m_clientInterfaces[typeof(T)];
  11444. }
  11445. public void Disconnect(string reason)
  11446. {
  11447. Kick(reason);
  11448. Thread.Sleep(1000);
  11449. Disconnect();
  11450. }
  11451. public void Disconnect()
  11452. {
  11453. Close();
  11454. }
  11455. #endregion
  11456. public void RefreshGroupMembership()
  11457. {
  11458. lock(m_groupPowers)
  11459. {
  11460. GroupMembershipData activeMembership = null;
  11461. if (m_GroupsModule != null)
  11462. {
  11463. GroupMembershipData[] GroupMembership =
  11464. m_GroupsModule.GetMembershipData(AgentId);
  11465. m_groupPowers.Clear();
  11466. if (GroupMembership != null)
  11467. {
  11468. for (int i = 0; i < GroupMembership.Length; i++)
  11469. {
  11470. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  11471. }
  11472. }
  11473. activeMembership = m_GroupsModule.GetActiveMembershipData(AgentId);
  11474. if(activeMembership != null)
  11475. {
  11476. if(!m_groupPowers.ContainsKey(activeMembership.GroupID))
  11477. activeMembership = null;
  11478. else
  11479. {
  11480. m_activeGroupID = activeMembership.GroupID;
  11481. m_activeGroupName = activeMembership.GroupName;
  11482. m_activeGroupPowers = ActiveGroupPowers;
  11483. }
  11484. }
  11485. }
  11486. if(activeMembership == null)
  11487. {
  11488. m_activeGroupID = UUID.Zero;
  11489. m_activeGroupName = "";
  11490. m_activeGroupPowers = 0;
  11491. }
  11492. }
  11493. }
  11494. public void UpdateGroupMembership(GroupMembershipData[] data)
  11495. {
  11496. lock(m_groupPowers)
  11497. {
  11498. m_groupPowers.Clear();
  11499. if (data != null)
  11500. {
  11501. for (int i = 0; i < data.Length; i++)
  11502. m_groupPowers[data[i].GroupID] = data[i].GroupPowers;
  11503. }
  11504. }
  11505. }
  11506. public void GroupMembershipRemove(UUID GroupID)
  11507. {
  11508. lock(m_groupPowers)
  11509. {
  11510. if(m_groupPowers.ContainsKey(GroupID))
  11511. m_groupPowers.Remove(GroupID);
  11512. }
  11513. }
  11514. public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers)
  11515. {
  11516. lock(m_groupPowers)
  11517. {
  11518. m_groupPowers[GroupID] = GroupPowers;
  11519. }
  11520. }
  11521. public string Report()
  11522. {
  11523. return m_udpClient.GetStats();
  11524. }
  11525. public string XReport(string uptime, string version)
  11526. {
  11527. return String.Empty;
  11528. }
  11529. public OSDMap OReport(string uptime, string version)
  11530. {
  11531. return new OSDMap();
  11532. }
  11533. /// <summary>
  11534. /// Make an asset request to the asset service in response to a client request.
  11535. /// </summary>
  11536. /// <param name="transferRequest"></param>
  11537. /// <param name="taskID"></param>
  11538. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  11539. {
  11540. UUID requestID = UUID.Zero;
  11541. int sourceType = transferRequest.TransferInfo.SourceType;
  11542. if (sourceType == (int)SourceType.Asset)
  11543. {
  11544. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  11545. }
  11546. else if (sourceType == (int)SourceType.SimInventoryItem)
  11547. {
  11548. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  11549. }
  11550. else if (sourceType == (int)SourceType.SimEstate)
  11551. {
  11552. requestID = taskID;
  11553. }
  11554. // m_log.DebugFormat(
  11555. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  11556. // requestID, taskID, (SourceType)sourceType, Name);
  11557. //Note, the bool returned from the below function is useless since it is always false.
  11558. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  11559. }
  11560. /// <summary>
  11561. /// When we get a reply back from the asset service in response to a client request, send back the data.
  11562. /// </summary>
  11563. /// <param name="id"></param>
  11564. /// <param name="sender"></param>
  11565. /// <param name="asset"></param>
  11566. protected void AssetReceived(string id, Object sender, AssetBase asset)
  11567. {
  11568. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  11569. UUID requestID = UUID.Zero;
  11570. byte source = (byte)SourceType.Asset;
  11571. AssetRequestToClient req = new AssetRequestToClient();
  11572. if (asset == null)
  11573. {
  11574. // Try the user's asset server
  11575. IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface<IInventoryAccessModule>();
  11576. string assetServerURL = string.Empty;
  11577. if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL))
  11578. {
  11579. if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("="))
  11580. assetServerURL = assetServerURL + "/";
  11581. //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id);
  11582. asset = m_scene.AssetService.Get(assetServerURL + id);
  11583. }
  11584. if (asset == null)
  11585. {
  11586. req.AssetInf = null;
  11587. req.AssetRequestSource = source;
  11588. req.IsTextureRequest = false;
  11589. req.NumPackets = 0;
  11590. req.Params = transferRequest.TransferInfo.Params;
  11591. req.RequestAssetID = requestID;
  11592. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  11593. SendAssetNotFound(req);
  11594. return;
  11595. }
  11596. }
  11597. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  11598. {
  11599. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  11600. }
  11601. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  11602. {
  11603. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  11604. source = (byte)SourceType.SimInventoryItem;
  11605. //m_log.Debug("asset request " + requestID);
  11606. }
  11607. // Scripts cannot be retrieved by direct request
  11608. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  11609. return;
  11610. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  11611. req.AssetInf = asset;
  11612. req.AssetRequestSource = source;
  11613. req.IsTextureRequest = false;
  11614. req.NumPackets = CalculateNumPackets(asset.Data);
  11615. req.Params = transferRequest.TransferInfo.Params;
  11616. req.RequestAssetID = requestID;
  11617. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  11618. SendAsset(req);
  11619. }
  11620. /// <summary>
  11621. /// Calculate the number of packets required to send the asset to the client.
  11622. /// </summary>
  11623. /// <param name="data"></param>
  11624. /// <returns></returns>
  11625. private static int CalculateNumPackets(byte[] data)
  11626. {
  11627. // const uint m_maxPacketSize = 600;
  11628. uint m_maxPacketSize = MaxTransferBytesPerPacket;
  11629. int numPackets = 1;
  11630. if (data == null)
  11631. return 0;
  11632. if (data.LongLength > m_maxPacketSize)
  11633. {
  11634. // over max number of bytes so split up file
  11635. long restData = data.LongLength - m_maxPacketSize;
  11636. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  11637. numPackets += restPackets;
  11638. }
  11639. return numPackets;
  11640. }
  11641. public void SendRebakeAvatarTextures(UUID textureID)
  11642. {
  11643. RebakeAvatarTexturesPacket pack =
  11644. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  11645. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  11646. pack.TextureData.TextureID = textureID;
  11647. OutPacket(pack, ThrottleOutPacketType.Task);
  11648. }
  11649. public struct PacketProcessor
  11650. {
  11651. /// <summary>
  11652. /// Packet handling method.
  11653. /// </summary>
  11654. public PacketMethod method { get; set; }
  11655. /// <summary>
  11656. /// Should this packet be handled asynchronously?
  11657. /// </summary>
  11658. public bool Async { get; set; }
  11659. }
  11660. public class AsyncPacketProcess
  11661. {
  11662. public bool result = false;
  11663. public readonly LLClientView ClientView = null;
  11664. public readonly Packet Pack = null;
  11665. public readonly PacketMethod Method = null;
  11666. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  11667. {
  11668. ClientView = pClientview;
  11669. Method = pMethod;
  11670. Pack = pPack;
  11671. }
  11672. }
  11673. public static OSD BuildEvent(string eventName, OSD eventBody)
  11674. {
  11675. OSDMap osdEvent = new OSDMap(2);
  11676. osdEvent.Add("message", new OSDString(eventName));
  11677. osdEvent.Add("body", eventBody);
  11678. return osdEvent;
  11679. }
  11680. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  11681. {
  11682. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  11683. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  11684. packet.AgentData.AgentID = AgentId;
  11685. packet.AgentData.AvatarID = avatarID;
  11686. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  11687. packet.PropertiesData.WantToMask = wantMask;
  11688. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  11689. packet.PropertiesData.SkillsMask = skillsMask;
  11690. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  11691. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  11692. OutPacket(packet, ThrottleOutPacketType.Task);
  11693. }
  11694. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  11695. {
  11696. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  11697. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  11698. packet.AgentData.AgentID = agentID;
  11699. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  11700. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  11701. packet.Rights[0].AgentRelated = friendID;
  11702. packet.Rights[0].RelatedRights = rights;
  11703. OutPacket(packet, ThrottleOutPacketType.Task);
  11704. }
  11705. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  11706. {
  11707. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  11708. dialog.Data.ObjectID = objectId;
  11709. dialog.Data.ChatChannel = chatChannel;
  11710. dialog.Data.ImageID = UUID.Zero;
  11711. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  11712. // this is the username of the *owner*
  11713. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  11714. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  11715. dialog.Data.Message = Util.StringToBytes(message,512);
  11716. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  11717. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  11718. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  11719. dialog.Buttons = buttons;
  11720. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  11721. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  11722. dialog.OwnerData[0].OwnerID = ownerID;
  11723. OutPacket(dialog, ThrottleOutPacketType.Task);
  11724. }
  11725. public void SendAgentTerseUpdate(ISceneEntity p)
  11726. {
  11727. if (p is ScenePresence)
  11728. {
  11729. // m_log.DebugFormat(
  11730. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  11731. // p.Name, Name, Scene.Name);
  11732. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  11733. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  11734. // velocity, collision plane and avatar height
  11735. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  11736. // when the avatar stands up
  11737. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  11738. CreateImprovedTerseBlock(p, false);
  11739. // const float TIME_DILATION = 1.0f;
  11740. ushort timeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);;
  11741. ImprovedTerseObjectUpdatePacket packet
  11742. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  11743. PacketType.ImprovedTerseObjectUpdate);
  11744. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  11745. packet.RegionData.TimeDilation = timeDilation;
  11746. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  11747. packet.ObjectData[0] = block;
  11748. OutPacket(packet, ThrottleOutPacketType.Task, true);
  11749. }
  11750. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  11751. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  11752. }
  11753. public void SendPlacesReply(UUID queryID, UUID transactionID,
  11754. PlacesReplyData[] data)
  11755. {
  11756. PlacesReplyPacket reply = null;
  11757. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  11758. new PlacesReplyPacket.QueryDataBlock[0];
  11759. for (int i = 0 ; i < data.Length ; i++)
  11760. {
  11761. PlacesReplyPacket.QueryDataBlock block =
  11762. new PlacesReplyPacket.QueryDataBlock();
  11763. block.OwnerID = data[i].OwnerID;
  11764. block.Name = Util.StringToBytes256(data[i].Name);
  11765. block.Desc = Util.StringToBytes1024(data[i].Desc);
  11766. block.ActualArea = data[i].ActualArea;
  11767. block.BillableArea = data[i].BillableArea;
  11768. block.Flags = data[i].Flags;
  11769. block.GlobalX = data[i].GlobalX;
  11770. block.GlobalY = data[i].GlobalY;
  11771. block.GlobalZ = data[i].GlobalZ;
  11772. block.SimName = Util.StringToBytes256(data[i].SimName);
  11773. block.SnapshotID = data[i].SnapshotID;
  11774. block.Dwell = data[i].Dwell;
  11775. block.Price = data[i].Price;
  11776. if (reply != null && reply.Length + block.Length > 1400)
  11777. {
  11778. OutPacket(reply, ThrottleOutPacketType.Task);
  11779. reply = null;
  11780. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  11781. }
  11782. if (reply == null)
  11783. {
  11784. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  11785. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  11786. reply.AgentData.AgentID = AgentId;
  11787. reply.AgentData.QueryID = queryID;
  11788. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  11789. reply.TransactionData.TransactionID = transactionID;
  11790. reply.QueryData = dataBlocks;
  11791. }
  11792. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  11793. dataBlocks[dataBlocks.Length - 1] = block;
  11794. reply.QueryData = dataBlocks;
  11795. }
  11796. if (reply != null)
  11797. OutPacket(reply, ThrottleOutPacketType.Task);
  11798. }
  11799. public void SendRemoveInventoryItems(UUID[] items)
  11800. {
  11801. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11802. if (eq == null)
  11803. {
  11804. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11805. return;
  11806. }
  11807. OSDMap llsd = new OSDMap(3);
  11808. OSDMap AgentDataMap = new OSDMap(1);
  11809. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11810. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11811. OSDArray AgentData = new OSDArray(1);
  11812. AgentData.Add(AgentDataMap);
  11813. llsd.Add("AgentData", AgentData);
  11814. OSDArray ItemData = new OSDArray();
  11815. foreach (UUID item in items)
  11816. {
  11817. OSDMap ItemDataMap = new OSDMap(2);
  11818. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  11819. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11820. ItemData.Add(ItemDataMap);
  11821. }
  11822. llsd.Add("InventoryData", ItemData);
  11823. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  11824. llsd), AgentId);
  11825. }
  11826. public void SendRemoveInventoryFolders(UUID[] folders)
  11827. {
  11828. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11829. if (eq == null)
  11830. {
  11831. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11832. return;
  11833. }
  11834. OSDMap llsd = new OSDMap(3);
  11835. OSDMap AgentDataMap = new OSDMap(1);
  11836. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11837. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11838. OSDArray AgentData = new OSDArray(1);
  11839. AgentData.Add(AgentDataMap);
  11840. llsd.Add("AgentData", AgentData);
  11841. OSDArray FolderData = new OSDArray();
  11842. foreach (UUID folder in folders)
  11843. {
  11844. OSDMap FolderDataMap = new OSDMap(2);
  11845. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11846. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11847. FolderData.Add(FolderDataMap);
  11848. }
  11849. llsd.Add("FolderData", FolderData);
  11850. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11851. llsd), AgentId);
  11852. }
  11853. private byte[] EncodeU32(uint val)
  11854. {
  11855. byte[] ret = BitConverter.GetBytes(val);
  11856. if (BitConverter.IsLittleEndian)
  11857. Array.Reverse(ret);
  11858. return ret;
  11859. }
  11860. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11861. {
  11862. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11863. if (eq == null)
  11864. {
  11865. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11866. return;
  11867. }
  11868. OSDMap llsd = new OSDMap(3);
  11869. OSDMap AgentDataMap = new OSDMap(1);
  11870. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11871. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11872. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11873. OSDArray AgentData = new OSDArray(1);
  11874. AgentData.Add(AgentDataMap);
  11875. llsd.Add("AgentData", AgentData);
  11876. OSDArray FolderData = new OSDArray();
  11877. foreach (InventoryFolderBase folder in folders)
  11878. {
  11879. OSDMap FolderDataMap = new OSDMap(5);
  11880. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11881. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11882. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11883. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11884. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11885. FolderData.Add(FolderDataMap);
  11886. }
  11887. llsd.Add("FolderData", FolderData);
  11888. OSDArray ItemData = new OSDArray();
  11889. foreach (InventoryItemBase item in items)
  11890. {
  11891. OSDMap ItemDataMap = new OSDMap();
  11892. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11893. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11894. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11895. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11896. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11897. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11898. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11899. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11900. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11901. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11902. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11903. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11904. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11905. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11906. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11907. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11908. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11909. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11910. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11911. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11912. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11913. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11914. (sbyte)item.AssetType, item.AssetID,
  11915. item.GroupID, 100,
  11916. item.Owner, item.CreatorIdAsUuid,
  11917. item.ID, item.Folder,
  11918. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11919. (uint)PermissionMask.All)
  11920. )));
  11921. ItemDataMap.Add("CallbackID", 0);
  11922. ItemData.Add(ItemDataMap);
  11923. }
  11924. llsd.Add("ItemData", ItemData);
  11925. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11926. llsd), AgentId);
  11927. }
  11928. private HashSet<string> m_outPacketsToDrop;
  11929. public bool AddOutPacketToDropSet(string packetName)
  11930. {
  11931. if (m_outPacketsToDrop == null)
  11932. m_outPacketsToDrop = new HashSet<string>();
  11933. return m_outPacketsToDrop.Add(packetName);
  11934. }
  11935. public bool RemoveOutPacketFromDropSet(string packetName)
  11936. {
  11937. if (m_outPacketsToDrop == null)
  11938. return false;
  11939. return m_outPacketsToDrop.Remove(packetName);
  11940. }
  11941. public HashSet<string> GetOutPacketDropSet()
  11942. {
  11943. return new HashSet<string>(m_outPacketsToDrop);
  11944. }
  11945. private HashSet<string> m_inPacketsToDrop;
  11946. public bool AddInPacketToDropSet(string packetName)
  11947. {
  11948. if (m_inPacketsToDrop == null)
  11949. m_inPacketsToDrop = new HashSet<string>();
  11950. return m_inPacketsToDrop.Add(packetName);
  11951. }
  11952. public bool RemoveInPacketFromDropSet(string packetName)
  11953. {
  11954. if (m_inPacketsToDrop == null)
  11955. return false;
  11956. return m_inPacketsToDrop.Remove(packetName);
  11957. }
  11958. public HashSet<string> GetInPacketDropSet()
  11959. {
  11960. return new HashSet<string>(m_inPacketsToDrop);
  11961. }
  11962. }
  11963. }