LLClientView.cs 584 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256
  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
  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 ModifyTerrain OnModifyTerrain;
  76. public event Action<IClientAPI> OnRegionHandShakeReply;
  77. public event GenericCall1 OnRequestWearables;
  78. public event SetAppearance OnSetAppearance;
  79. public event AvatarNowWearing OnAvatarNowWearing;
  80. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  81. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  82. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  83. public event ObjectAttach OnObjectAttach;
  84. public event ObjectDeselect OnObjectDetach;
  85. public event ObjectDrop OnObjectDrop;
  86. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  87. public event UpdateAgent OnPreAgentUpdate;
  88. public event UpdateAgent OnAgentUpdate;
  89. public event UpdateAgent OnAgentCameraUpdate;
  90. public event AgentRequestSit OnAgentRequestSit;
  91. public event AgentSit OnAgentSit;
  92. public event AvatarPickerRequest OnAvatarPickerRequest;
  93. public event StartAnim OnStartAnim;
  94. public event StopAnim OnStopAnim;
  95. public event Action<IClientAPI> OnRequestAvatarsData;
  96. public event LinkObjects OnLinkObjects;
  97. public event DelinkObjects OnDelinkObjects;
  98. public event GrabObject OnGrabObject;
  99. public event DeGrabObject OnDeGrabObject;
  100. public event SpinStart OnSpinStart;
  101. public event SpinStop OnSpinStop;
  102. public event ObjectDuplicate OnObjectDuplicate;
  103. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  104. public event MoveObject OnGrabUpdate;
  105. public event SpinObject OnSpinUpdate;
  106. public event AddNewPrim OnAddPrim;
  107. public event RequestGodlikePowers OnRequestGodlikePowers;
  108. public event GodKickUser OnGodKickUser;
  109. public event ObjectExtraParams OnUpdateExtraParams;
  110. public event UpdateShape OnUpdatePrimShape;
  111. public event ObjectRequest OnObjectRequest;
  112. public event ObjectSelect OnObjectSelect;
  113. public event ObjectDeselect OnObjectDeselect;
  114. public event GenericCall7 OnObjectDescription;
  115. public event GenericCall7 OnObjectName;
  116. public event GenericCall7 OnObjectClickAction;
  117. public event GenericCall7 OnObjectMaterial;
  118. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  119. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  120. public event UpdatePrimFlags OnUpdatePrimFlags;
  121. public event UpdatePrimTexture OnUpdatePrimTexture;
  122. public event UpdateVector OnUpdatePrimGroupPosition;
  123. public event UpdateVector OnUpdatePrimSinglePosition;
  124. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  125. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  126. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  127. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  128. public event UpdateVector OnUpdatePrimScale;
  129. public event UpdateVector OnUpdatePrimGroupScale;
  130. public event RequestMapBlocks OnRequestMapBlocks;
  131. public event RequestMapName OnMapNameRequest;
  132. public event TeleportLocationRequest OnTeleportLocationRequest;
  133. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  134. public event TeleportCancel OnTeleportCancel;
  135. public event RequestAvatarProperties OnRequestAvatarProperties;
  136. public event SetAlwaysRun OnSetAlwaysRun;
  137. public event FetchInventory OnAgentDataUpdateRequest;
  138. public event TeleportLocationRequest OnSetStartLocationRequest;
  139. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  140. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  141. public event LinkInventoryItem OnLinkInventoryItem;
  142. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  143. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  144. public event MoveInventoryFolder OnMoveInventoryFolder;
  145. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  146. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  147. public event FetchInventory OnFetchInventory;
  148. public event RequestTaskInventory OnRequestTaskInventory;
  149. public event UpdateInventoryItem OnUpdateInventoryItem;
  150. public event CopyInventoryItem OnCopyInventoryItem;
  151. public event MoveInventoryItem OnMoveInventoryItem;
  152. public event RemoveInventoryItem OnRemoveInventoryItem;
  153. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  154. public event UDPAssetUploadRequest OnAssetUploadRequest;
  155. public event XferReceive OnXferReceive;
  156. public event RequestXfer OnRequestXfer;
  157. public event ConfirmXfer OnConfirmXfer;
  158. public event AbortXfer OnAbortXfer;
  159. public event RequestTerrain OnRequestTerrain;
  160. public event RezScript OnRezScript;
  161. public event UpdateTaskInventory OnUpdateTaskInventory;
  162. public event MoveTaskInventory OnMoveTaskItem;
  163. public event RemoveTaskInventory OnRemoveTaskItem;
  164. public event UUIDNameRequest OnNameFromUUIDRequest;
  165. public event ParcelAccessListRequest OnParcelAccessListRequest;
  166. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  167. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  168. public event ParcelDivideRequest OnParcelDivideRequest;
  169. public event ParcelJoinRequest OnParcelJoinRequest;
  170. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  171. public event ParcelSelectObjects OnParcelSelectObjects;
  172. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  173. public event ParcelAbandonRequest OnParcelAbandonRequest;
  174. public event ParcelGodForceOwner OnParcelGodForceOwner;
  175. public event ParcelReclaim OnParcelReclaim;
  176. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  177. public event ParcelDeedToGroup OnParcelDeedToGroup;
  178. public event RegionInfoRequest OnRegionInfoRequest;
  179. public event EstateCovenantRequest OnEstateCovenantRequest;
  180. public event FriendActionDelegate OnApproveFriendRequest;
  181. public event FriendActionDelegate OnDenyFriendRequest;
  182. public event FriendshipTermination OnTerminateFriendship;
  183. public event GrantUserFriendRights OnGrantUserRights;
  184. public event MoneyTransferRequest OnMoneyTransferRequest;
  185. public event EconomyDataRequest OnEconomyDataRequest;
  186. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  187. public event ParcelBuy OnParcelBuy;
  188. public event UUIDNameRequest OnTeleportHomeRequest;
  189. public event UUIDNameRequest OnUUIDGroupNameRequest;
  190. public event ScriptAnswer OnScriptAnswer;
  191. public event RequestPayPrice OnRequestPayPrice;
  192. public event ObjectSaleInfo OnObjectSaleInfo;
  193. public event ObjectBuy OnObjectBuy;
  194. public event AgentSit OnUndo;
  195. public event AgentSit OnRedo;
  196. public event LandUndo OnLandUndo;
  197. public event ForceReleaseControls OnForceReleaseControls;
  198. public event GodLandStatRequest OnLandStatRequest;
  199. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  200. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  201. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  202. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  203. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  204. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  205. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  206. public event BakeTerrain OnBakeTerrain;
  207. public event RequestTerrain OnUploadTerrain;
  208. public event EstateChangeInfo OnEstateChangeInfo;
  209. public event EstateManageTelehub OnEstateManageTelehub;
  210. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  211. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  212. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  213. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  214. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  215. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  216. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  217. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  218. public event RegionHandleRequest OnRegionHandleRequest;
  219. public event ParcelInfoRequest OnParcelInfoRequest;
  220. public event ScriptReset OnScriptReset;
  221. public event GetScriptRunning OnGetScriptRunning;
  222. public event SetScriptRunning OnSetScriptRunning;
  223. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  224. public event ActivateGesture OnActivateGesture;
  225. public event DeactivateGesture OnDeactivateGesture;
  226. public event ObjectOwner OnObjectOwner;
  227. public event DirPlacesQuery OnDirPlacesQuery;
  228. public event DirFindQuery OnDirFindQuery;
  229. public event DirLandQuery OnDirLandQuery;
  230. public event DirPopularQuery OnDirPopularQuery;
  231. public event DirClassifiedQuery OnDirClassifiedQuery;
  232. public event EventInfoRequest OnEventInfoRequest;
  233. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  234. public event MapItemRequest OnMapItemRequest;
  235. public event OfferCallingCard OnOfferCallingCard;
  236. public event AcceptCallingCard OnAcceptCallingCard;
  237. public event DeclineCallingCard OnDeclineCallingCard;
  238. public event SoundTrigger OnSoundTrigger;
  239. public event StartLure OnStartLure;
  240. public event TeleportLureRequest OnTeleportLureRequest;
  241. public event NetworkStats OnNetworkStatsUpdate;
  242. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  243. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  244. public event ClassifiedDelete OnClassifiedDelete;
  245. public event ClassifiedDelete OnClassifiedGodDelete;
  246. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  247. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  248. public event EventGodDelete OnEventGodDelete;
  249. public event ParcelDwellRequest OnParcelDwellRequest;
  250. public event UserInfoRequest OnUserInfoRequest;
  251. public event UpdateUserInfo OnUpdateUserInfo;
  252. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  253. public event PickDelete OnPickDelete;
  254. public event PickGodDelete OnPickGodDelete;
  255. public event PickInfoUpdate OnPickInfoUpdate;
  256. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  257. public event MuteListRequest OnMuteListRequest;
  258. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  259. public event PlacesQuery OnPlacesQuery;
  260. public event AgentFOV OnAgentFOV;
  261. public event FindAgentUpdate OnFindAgent;
  262. public event TrackAgentUpdate OnTrackAgent;
  263. public event NewUserReport OnUserReport;
  264. public event SaveStateHandler OnSaveState;
  265. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  266. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  267. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  268. public event FreezeUserUpdate OnParcelFreezeUser;
  269. public event EjectUserUpdate OnParcelEjectUser;
  270. public event ParcelBuyPass OnParcelBuyPass;
  271. public event ParcelGodMark OnParcelGodMark;
  272. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  273. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  274. public event SimWideDeletesDelegate OnSimWideDeletes;
  275. public event SendPostcard OnSendPostcard;
  276. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  277. public event MuteListEntryRemove OnRemoveMuteListEntry;
  278. public event GodlikeMessage onGodlikeMessage;
  279. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  280. #pragma warning disable 0067
  281. public event GenericMessage OnGenericMessage;
  282. public event TextureRequest OnRequestTexture;
  283. public event StatusChange OnChildAgentStatus;
  284. public event GenericCall2 OnStopMovement;
  285. public event Action<UUID> OnRemoveAvatar;
  286. public event DisconnectUser OnDisconnectUser;
  287. public event RequestAsset OnRequestAsset;
  288. public event BuyObjectInventory OnBuyObjectInventory;
  289. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  290. public event TerrainUnacked OnUnackedTerrain;
  291. public event CachedTextureRequest OnCachedTextureRequest;
  292. #pragma warning restore 0067
  293. #endregion Events
  294. #region Class Members
  295. // LLClientView Only
  296. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  297. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  298. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  299. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  300. private static string LogHeader = "[LLCLIENTVIEW]";
  301. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  302. /// <summary>
  303. /// Handles UDP texture download.
  304. /// </summary>
  305. public LLImageManager ImageManager { get; private set; }
  306. private readonly LLUDPServer m_udpServer;
  307. private readonly LLUDPClient m_udpClient;
  308. private readonly UUID m_sessionId;
  309. private readonly UUID m_secureSessionId;
  310. protected readonly UUID m_agentId;
  311. private readonly uint m_circuitCode;
  312. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  313. private readonly IGroupsModule m_GroupsModule;
  314. private int m_cachedTextureSerial;
  315. private PriorityQueue m_entityUpdates;
  316. private PriorityQueue m_entityProps;
  317. private Prioritizer m_prioritizer;
  318. private bool m_disableFacelights = false;
  319. private volatile bool m_justEditedTerrain = false;
  320. /// <value>
  321. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  322. /// continually recreate it.
  323. /// </value>
  324. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  325. /// <value>
  326. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  327. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  328. /// ownerless phantom.
  329. ///
  330. /// All manipulation of this set has to occur under a lock
  331. ///
  332. /// </value>
  333. protected HashSet<uint> m_killRecord;
  334. // protected HashSet<uint> m_attachmentsSent;
  335. private int m_animationSequenceNumber = 1;
  336. private bool m_SendLogoutPacketWhenClosing = true;
  337. /// <summary>
  338. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  339. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  340. /// is doing absolutely nothing.
  341. /// </summary>
  342. /// <remarks>
  343. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  344. /// cannot retain a reference to it outside of that method.
  345. /// </remarks>
  346. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  347. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  348. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  349. protected Scene m_scene;
  350. protected string m_firstName;
  351. protected string m_lastName;
  352. protected Thread m_clientThread;
  353. protected Vector3 m_startpos;
  354. protected UUID m_activeGroupID;
  355. protected string m_activeGroupName = String.Empty;
  356. protected ulong m_activeGroupPowers;
  357. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  358. protected int m_terrainCheckerCount;
  359. protected uint m_agentFOVCounter;
  360. protected IAssetService m_assetService;
  361. private const bool m_checkPackets = true;
  362. #endregion Class Members
  363. #region Properties
  364. public LLUDPClient UDPClient { get { return m_udpClient; } }
  365. public LLUDPServer UDPServer { get { return m_udpServer; } }
  366. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  367. public UUID SecureSessionId { get { return m_secureSessionId; } }
  368. public IScene Scene { get { return m_scene; } }
  369. public UUID SessionId { get { return m_sessionId; } }
  370. public Vector3 StartPos
  371. {
  372. get { return m_startpos; }
  373. set { m_startpos = value; }
  374. }
  375. public UUID AgentId { get { return m_agentId; } }
  376. public ISceneAgent SceneAgent { get; set; }
  377. public UUID ActiveGroupId { get { return m_activeGroupID; } private set { m_activeGroupID = value; } }
  378. public string ActiveGroupName { get { return m_activeGroupName; } private set { m_activeGroupName = value; } }
  379. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } private set { m_activeGroupPowers = value; } }
  380. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  381. /// <summary>
  382. /// Entity update queues
  383. /// </summary>
  384. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  385. /// <summary>
  386. /// First name of the agent/avatar represented by the client
  387. /// </summary>
  388. public string FirstName { get { return m_firstName; } }
  389. /// <summary>
  390. /// Last name of the agent/avatar represented by the client
  391. /// </summary>
  392. public string LastName { get { return m_lastName; } }
  393. /// <summary>
  394. /// Full name of the client (first name and last name)
  395. /// </summary>
  396. public string Name { get { return FirstName + " " + LastName; } }
  397. public uint CircuitCode { get { return m_circuitCode; } }
  398. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  399. /// <summary>
  400. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  401. /// prevent race conditions by different threads calling Close().
  402. /// </summary>
  403. public bool IsActive { get; set; }
  404. /// <summary>
  405. /// Used to synchronise threads when client is being closed.
  406. /// </summary>
  407. public Object CloseSyncLock { get; private set; }
  408. public bool IsLoggingOut { get; set; }
  409. public bool DisableFacelights
  410. {
  411. get { return m_disableFacelights; }
  412. set { m_disableFacelights = value; }
  413. }
  414. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  415. #endregion Properties
  416. // ~LLClientView()
  417. // {
  418. // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode);
  419. // }
  420. /// <summary>
  421. /// Constructor
  422. /// </summary>
  423. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  424. UUID agentId, UUID sessionId, uint circuitCode)
  425. {
  426. // DebugPacketLevel = 1;
  427. CloseSyncLock = new Object();
  428. RegisterInterface<IClientIM>(this);
  429. RegisterInterface<IClientInventory>(this);
  430. RegisterInterface<IClientChat>(this);
  431. m_scene = scene;
  432. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  433. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  434. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  435. m_killRecord = new HashSet<uint>();
  436. // m_attachmentsSent = new HashSet<uint>();
  437. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  438. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  439. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  440. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  441. m_agentId = agentId;
  442. m_sessionId = sessionId;
  443. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  444. m_circuitCode = circuitCode;
  445. m_firstName = sessionInfo.LoginInfo.First;
  446. m_lastName = sessionInfo.LoginInfo.Last;
  447. m_startpos = sessionInfo.LoginInfo.StartPos;
  448. m_udpServer = udpServer;
  449. m_udpClient = udpClient;
  450. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  451. m_udpClient.HasUpdates += HandleHasUpdates;
  452. m_udpClient.OnPacketStats += PopulateStats;
  453. m_prioritizer = new Prioritizer(m_scene);
  454. RegisterLocalPacketHandlers();
  455. IsActive = true;
  456. }
  457. #region Client Methods
  458. public void Close()
  459. {
  460. Close(false);
  461. }
  462. public void Close(bool force)
  463. {
  464. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  465. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  466. lock (CloseSyncLock)
  467. {
  468. // We still perform a force close inside the sync lock since this is intended to attempt close where
  469. // there is some unidentified connection problem, not where we have issues due to deadlock
  470. if (!IsActive && !force)
  471. {
  472. m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set",
  473. LogHeader, Name, m_scene.Name);
  474. return;
  475. }
  476. IsActive = false;
  477. CloseWithoutChecks();
  478. }
  479. }
  480. /// <summary>
  481. /// Closes down the client view without first checking whether it is active.
  482. /// </summary>
  483. /// <remarks>
  484. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  485. /// CloseWithoutIsActiveCheck asynchronously.
  486. ///
  487. /// Callers must lock ClosingSyncLock before calling.
  488. /// </remarks>
  489. public void CloseWithoutChecks()
  490. {
  491. m_log.DebugFormat(
  492. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  493. Name, m_scene.RegionInfo.RegionName);
  494. // Shutdown the image manager
  495. ImageManager.Close();
  496. // Fire the callback for this connection closing
  497. if (OnConnectionClosed != null)
  498. OnConnectionClosed(this);
  499. // Flush all of the packets out of the UDP server for this client
  500. if (m_udpServer != null)
  501. m_udpServer.Flush(m_udpClient);
  502. // Remove ourselves from the scene
  503. m_scene.RemoveClient(AgentId, true);
  504. SceneAgent = null;
  505. // We can't reach into other scenes and close the connection
  506. // We need to do this over grid communications
  507. //m_scene.CloseAllAgents(CircuitCode);
  508. // Disable UDP handling for this client
  509. m_udpClient.Shutdown();
  510. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  511. //GC.Collect();
  512. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  513. }
  514. public void Kick(string message)
  515. {
  516. if (!SceneAgent.IsChildAgent)
  517. {
  518. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  519. kupack.UserInfo.AgentID = AgentId;
  520. kupack.UserInfo.SessionID = SessionId;
  521. kupack.TargetBlock.TargetIP = 0;
  522. kupack.TargetBlock.TargetPort = 0;
  523. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  524. OutPacket(kupack, ThrottleOutPacketType.Task);
  525. // You must sleep here or users get no message!
  526. Thread.Sleep(500);
  527. }
  528. }
  529. public void Stop()
  530. {
  531. }
  532. #endregion Client Methods
  533. #region Packet Handling
  534. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  535. {
  536. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  537. if (handlerNetworkStatsUpdate != null)
  538. {
  539. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  540. }
  541. }
  542. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  543. {
  544. bool result = false;
  545. lock (PacketHandlers)
  546. {
  547. if (!PacketHandlers.ContainsKey(packetType))
  548. {
  549. PacketHandlers.Add(packetType, handler);
  550. result = true;
  551. }
  552. }
  553. return result;
  554. }
  555. /// <summary>
  556. /// Add a handler for the given packet type.
  557. /// </summary>
  558. /// <remarks>
  559. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  560. /// are received then please use the synchronous version of this method.
  561. /// </remarks>
  562. /// <param name="packetType"></param>
  563. /// <param name="handler"></param>
  564. /// <returns>true if the handler was added. This is currently always the case.</returns>
  565. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  566. {
  567. return AddLocalPacketHandler(packetType, handler, true);
  568. }
  569. /// <summary>
  570. /// Add a handler for the given packet type.
  571. /// </summary>
  572. /// <param name="packetType"></param>
  573. /// <param name="handler"></param>
  574. /// <param name="doAsync">
  575. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  576. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  577. /// synchronously.
  578. /// </param>
  579. /// <returns>true if the handler was added. This is currently always the case.</returns>
  580. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  581. {
  582. return AddLocalPacketHandler(packetType, handler, doAsync, false);
  583. }
  584. /// <summary>
  585. /// Add a handler for the given packet type.
  586. /// </summary>
  587. /// <param name="packetType"></param>
  588. /// <param name="handler"></param>
  589. /// <param name="doAsync">
  590. /// If true, when the packet is received handle it on a different thread. Whether this is given direct to
  591. /// a threadpool thread or placed in a queue depends on the inEngine parameter.
  592. /// </param>
  593. /// <param name="inEngine">
  594. /// If async is false then this parameter is ignored.
  595. /// If async is true and inEngine is false, then the packet is sent directly to a
  596. /// threadpool thread.
  597. /// If async is true and inEngine is true, then the packet is sent to the IncomingPacketAsyncHandlingEngine.
  598. /// This may result in slower handling but reduces the risk of overloading the simulator when there are many
  599. /// simultaneous async requests.
  600. /// </param>
  601. /// <returns>true if the handler was added. This is currently always the case.</returns>
  602. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync, bool inEngine)
  603. {
  604. bool result = false;
  605. lock (m_packetHandlers)
  606. {
  607. if (!m_packetHandlers.ContainsKey(packetType))
  608. {
  609. m_packetHandlers.Add(
  610. packetType, new PacketProcessor() { method = handler, Async = doAsync, InEngine = inEngine });
  611. result = true;
  612. }
  613. }
  614. return result;
  615. }
  616. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  617. {
  618. MethodName = MethodName.ToLower().Trim();
  619. bool result = false;
  620. lock (m_genericPacketHandlers)
  621. {
  622. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  623. {
  624. m_genericPacketHandlers.Add(MethodName, handler);
  625. result = true;
  626. }
  627. }
  628. return result;
  629. }
  630. /// <summary>
  631. /// Try to process a packet using registered packet handlers
  632. /// </summary>
  633. /// <param name="packet"></param>
  634. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  635. protected virtual bool ProcessPacketMethod(Packet packet)
  636. {
  637. bool result = false;
  638. PacketProcessor pprocessor;
  639. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  640. {
  641. ClientInfo cinfo = UDPClient.GetClientInfo();
  642. //there is a local handler for this packet type
  643. if (pprocessor.Async)
  644. {
  645. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  646. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  647. cinfo.AsyncRequests[packet.Type.ToString()]++;
  648. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  649. if (pprocessor.InEngine)
  650. m_udpServer.IpahEngine.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj));
  651. else
  652. Util.FireAndForget(ProcessSpecificPacketAsync, obj, packet.Type.ToString());
  653. result = true;
  654. }
  655. else
  656. {
  657. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  658. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  659. cinfo.SyncRequests[packet.Type.ToString()]++;
  660. result = pprocessor.method(this, packet);
  661. }
  662. }
  663. else
  664. {
  665. //there is not a local handler so see if there is a Global handler
  666. PacketMethod method = null;
  667. bool found;
  668. lock (PacketHandlers)
  669. {
  670. found = PacketHandlers.TryGetValue(packet.Type, out method);
  671. }
  672. if (found)
  673. {
  674. ClientInfo cinfo = UDPClient.GetClientInfo();
  675. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  676. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  677. cinfo.GenericRequests[packet.Type.ToString()]++;
  678. result = method(this, packet);
  679. }
  680. }
  681. return result;
  682. }
  683. public void ProcessSpecificPacketAsync(object state)
  684. {
  685. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  686. try
  687. {
  688. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  689. }
  690. catch (Exception e)
  691. {
  692. // Make sure that we see any exception caused by the asynchronous operation.
  693. m_log.Error(
  694. string.Format(
  695. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packetObject.Pack, Name),
  696. e);
  697. }
  698. }
  699. #endregion Packet Handling
  700. # region Setup
  701. public virtual void Start()
  702. {
  703. m_scene.AddNewAgent(this, PresenceType.User);
  704. RefreshGroupMembership();
  705. }
  706. # endregion
  707. public void ActivateGesture(UUID assetId, UUID gestureId)
  708. {
  709. }
  710. public void DeactivateGesture(UUID assetId, UUID gestureId)
  711. {
  712. }
  713. // Sound
  714. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  715. {
  716. }
  717. #region Scene/Avatar to Client
  718. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  719. {
  720. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  721. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  722. handshake.RegionInfo.BillableFactor = args.billableFactor;
  723. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  724. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  725. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  726. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  727. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  728. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  729. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  730. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  731. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  732. handshake.RegionInfo.SimAccess = args.simAccess;
  733. handshake.RegionInfo.WaterHeight = args.waterHeight;
  734. handshake.RegionInfo.RegionFlags = args.regionFlags;
  735. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  736. handshake.RegionInfo.SimOwner = args.SimOwner;
  737. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  738. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  739. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  740. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  741. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  742. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  743. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  744. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  745. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  746. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  747. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  748. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  749. handshake.RegionInfo3.CPUClassID = 9;
  750. handshake.RegionInfo3.CPURatio = 1;
  751. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  752. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  753. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  754. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  755. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  756. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  757. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  758. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  759. }
  760. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  761. {
  762. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  763. mov.SimData.ChannelVersion = m_channelVersion;
  764. mov.AgentData.SessionID = m_sessionId;
  765. mov.AgentData.AgentID = AgentId;
  766. mov.Data.RegionHandle = regInfo.RegionHandle;
  767. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  768. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  769. {
  770. mov.Data.Position = m_startpos;
  771. }
  772. else
  773. {
  774. mov.Data.Position = pos;
  775. }
  776. mov.Data.LookAt = look;
  777. // Hack to get this out immediately and skip the throttles
  778. OutPacket(mov, ThrottleOutPacketType.Unknown);
  779. }
  780. public void SendChatMessage(
  781. string message, byte type, Vector3 fromPos, string fromName,
  782. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  783. {
  784. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  785. reply.ChatData.Audible = audible;
  786. reply.ChatData.Message = Util.StringToBytes1024(message);
  787. reply.ChatData.ChatType = type;
  788. reply.ChatData.SourceType = source;
  789. reply.ChatData.Position = fromPos;
  790. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  791. reply.ChatData.OwnerID = ownerID;
  792. reply.ChatData.SourceID = fromAgentID;
  793. OutPacket(reply, ThrottleOutPacketType.Task);
  794. }
  795. /// <summary>
  796. /// Send an instant message to this client
  797. /// </summary>
  798. //
  799. // Don't remove transaction ID! Groups and item gives need to set it!
  800. public void SendInstantMessage(GridInstantMessage im)
  801. {
  802. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  803. {
  804. ImprovedInstantMessagePacket msg
  805. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  806. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  807. msg.AgentData.SessionID = UUID.Zero;
  808. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  809. msg.MessageBlock.Dialog = im.dialog;
  810. msg.MessageBlock.FromGroup = im.fromGroup;
  811. if (im.imSessionID == UUID.Zero.Guid)
  812. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  813. else
  814. msg.MessageBlock.ID = new UUID(im.imSessionID);
  815. msg.MessageBlock.Offline = im.offline;
  816. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  817. msg.MessageBlock.Position = im.Position;
  818. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  819. msg.MessageBlock.Timestamp = im.timestamp;
  820. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  821. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  822. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  823. if (im.message.StartsWith("[grouptest]"))
  824. { // this block is test code for implementing group IM - delete when group IM is finished
  825. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  826. if (eq != null)
  827. {
  828. im.dialog = 17;
  829. //eq.ChatterboxInvitation(
  830. // new UUID("00000000-68f9-1111-024e-222222111123"),
  831. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  832. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  833. eq.ChatterboxInvitation(
  834. new UUID("00000000-68f9-1111-024e-222222111123"),
  835. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  836. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  837. eq.ChatterBoxSessionAgentListUpdates(
  838. new UUID("00000000-68f9-1111-024e-222222111123"),
  839. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  840. }
  841. Console.WriteLine("SendInstantMessage: " + msg);
  842. }
  843. else
  844. OutPacket(msg, ThrottleOutPacketType.Task);
  845. }
  846. }
  847. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  848. {
  849. GenericMessagePacket gmp = new GenericMessagePacket();
  850. gmp.AgentData.AgentID = AgentId;
  851. gmp.AgentData.SessionID = m_sessionId;
  852. gmp.AgentData.TransactionID = invoice;
  853. gmp.MethodData.Method = Util.StringToBytes256(method);
  854. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  855. int i = 0;
  856. foreach (string val in message)
  857. {
  858. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  859. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  860. }
  861. OutPacket(gmp, ThrottleOutPacketType.Task);
  862. }
  863. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  864. {
  865. GenericMessagePacket gmp = new GenericMessagePacket();
  866. gmp.AgentData.AgentID = AgentId;
  867. gmp.AgentData.SessionID = m_sessionId;
  868. gmp.AgentData.TransactionID = invoice;
  869. gmp.MethodData.Method = Util.StringToBytes256(method);
  870. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  871. int i = 0;
  872. foreach (byte[] val in message)
  873. {
  874. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  875. gmp.ParamList[i++].Parameter = val;
  876. }
  877. OutPacket(gmp, ThrottleOutPacketType.Task);
  878. }
  879. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  880. {
  881. int i = 0;
  882. foreach (GroupActiveProposals Proposal in Proposals)
  883. {
  884. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  885. GAPIRP.AgentData.AgentID = AgentId;
  886. GAPIRP.AgentData.GroupID = groupID;
  887. GAPIRP.TransactionData.TransactionID = transactionID;
  888. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  889. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  890. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  891. ProposalData.VoteCast = Utils.StringToBytes("false");
  892. ProposalData.VoteID = new UUID(Proposal.VoteID);
  893. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  894. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  895. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  896. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  897. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  898. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  899. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  900. ProposalData.AlreadyVoted = false;
  901. GAPIRP.ProposalData[i] = ProposalData;
  902. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  903. i++;
  904. }
  905. if (Proposals.Length == 0)
  906. {
  907. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  908. GAPIRP.AgentData.AgentID = AgentId;
  909. GAPIRP.AgentData.GroupID = groupID;
  910. GAPIRP.TransactionData.TransactionID = transactionID;
  911. GAPIRP.TransactionData.TotalNumItems = 1;
  912. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  913. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  914. ProposalData.VoteCast = Utils.StringToBytes("false");
  915. ProposalData.VoteID = UUID.Zero;
  916. ProposalData.VoteInitiator = UUID.Zero;
  917. ProposalData.Majority = 0;
  918. ProposalData.Quorum = 0;
  919. ProposalData.TerseDateID = Utils.StringToBytes("");
  920. ProposalData.StartDateTime = Utils.StringToBytes("");
  921. ProposalData.EndDateTime = Utils.StringToBytes("");
  922. ProposalData.ProposalText = Utils.StringToBytes("");
  923. ProposalData.AlreadyVoted = false;
  924. GAPIRP.ProposalData[0] = ProposalData;
  925. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  926. }
  927. }
  928. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  929. {
  930. int i = 0;
  931. foreach (GroupVoteHistory Vote in Votes)
  932. {
  933. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  934. GVHIRP.AgentData.AgentID = AgentId;
  935. GVHIRP.AgentData.GroupID = groupID;
  936. GVHIRP.TransactionData.TransactionID = transactionID;
  937. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  938. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  939. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  940. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  941. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  942. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  943. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  944. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  945. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  946. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  947. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  948. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  949. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  950. VoteItem.CandidateID = UUID.Zero;
  951. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  952. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  953. GVHIRP.VoteItem[i] = VoteItem;
  954. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  955. i++;
  956. }
  957. if (Votes.Length == 0)
  958. {
  959. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  960. GVHIRP.AgentData.AgentID = AgentId;
  961. GVHIRP.AgentData.GroupID = groupID;
  962. GVHIRP.TransactionData.TransactionID = transactionID;
  963. GVHIRP.TransactionData.TotalNumItems = 0;
  964. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  965. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  966. GVHIRP.HistoryItemData.Majority = 0;
  967. GVHIRP.HistoryItemData.Quorum = 0;
  968. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  969. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  970. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  971. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  972. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  973. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  974. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  975. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  976. VoteItem.CandidateID = UUID.Zero;
  977. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  978. VoteItem.VoteCast = Utils.StringToBytes("No");
  979. GVHIRP.VoteItem[0] = VoteItem;
  980. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  981. }
  982. }
  983. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  984. {
  985. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  986. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  987. GADRP.AgentData.AgentID = sender.AgentId;
  988. GADRP.AgentData.GroupID = groupID;
  989. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  990. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  991. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  992. GADRP.MoneyData.CurrentInterval = 0;
  993. GADRP.MoneyData.IntervalDays = 7;
  994. GADRP.MoneyData.RequestID = transactionID;
  995. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  996. History.Amount = amt;
  997. History.Description = Utils.StringToBytes("");
  998. GADRP.HistoryData[0] = History;
  999. OutPacket(GADRP, ThrottleOutPacketType.Task);
  1000. }
  1001. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  1002. {
  1003. GroupAccountSummaryReplyPacket GASRP =
  1004. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  1005. PacketType.GroupAccountSummaryReply);
  1006. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  1007. GASRP.AgentData.AgentID = sender.AgentId;
  1008. GASRP.AgentData.GroupID = groupID;
  1009. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  1010. GASRP.MoneyData.Balance = (int)moneyAmt;
  1011. GASRP.MoneyData.TotalCredits = totalTier;
  1012. GASRP.MoneyData.TotalDebits = usedTier;
  1013. GASRP.MoneyData.StartDate = new byte[1];
  1014. GASRP.MoneyData.CurrentInterval = 1;
  1015. GASRP.MoneyData.GroupTaxCurrent = 0;
  1016. GASRP.MoneyData.GroupTaxEstimate = 0;
  1017. GASRP.MoneyData.IntervalDays = 0;
  1018. GASRP.MoneyData.LandTaxCurrent = 0;
  1019. GASRP.MoneyData.LandTaxEstimate = 0;
  1020. GASRP.MoneyData.LastTaxDate = new byte[1];
  1021. GASRP.MoneyData.LightTaxCurrent = 0;
  1022. GASRP.MoneyData.TaxDate = new byte[1];
  1023. GASRP.MoneyData.RequestID = sender.AgentId;
  1024. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  1025. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  1026. GASRP.MoneyData.ObjectTaxEstimate = 0;
  1027. GASRP.MoneyData.NonExemptMembers = 0;
  1028. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1029. GASRP.MoneyData.LightTaxEstimate = 0;
  1030. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1031. }
  1032. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1033. {
  1034. GroupAccountTransactionsReplyPacket GATRP =
  1035. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1036. PacketType.GroupAccountTransactionsReply);
  1037. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1038. GATRP.AgentData.AgentID = sender.AgentId;
  1039. GATRP.AgentData.GroupID = groupID;
  1040. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1041. GATRP.MoneyData.CurrentInterval = 0;
  1042. GATRP.MoneyData.IntervalDays = 7;
  1043. GATRP.MoneyData.RequestID = transactionID;
  1044. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1045. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1046. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1047. History.Amount = 0;
  1048. History.Item = Utils.StringToBytes("");
  1049. History.Time = Utils.StringToBytes("");
  1050. History.Type = 0;
  1051. History.User = Utils.StringToBytes("");
  1052. GATRP.HistoryData[0] = History;
  1053. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1054. }
  1055. /// <summary>
  1056. /// Send the region heightmap to the client
  1057. /// This method is only called when not doing intellegent terrain patch sending and
  1058. /// is only called when the scene presence is initially created and sends all of the
  1059. /// region's patches to the client.
  1060. /// </summary>
  1061. /// <param name="map">heightmap</param>
  1062. public virtual void SendLayerData(float[] map)
  1063. {
  1064. Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData(), "LLClientView.DoSendLayerData");
  1065. }
  1066. /// <summary>
  1067. /// Send terrain layer information to the client.
  1068. /// </summary>
  1069. /// <param name="o"></param>
  1070. private void DoSendLayerData(object o)
  1071. {
  1072. TerrainData map = (TerrainData)o;
  1073. try
  1074. {
  1075. // Send LayerData in typerwriter pattern
  1076. //for (int y = 0; y < 16; y++)
  1077. //{
  1078. // for (int x = 0; x < 16; x++)
  1079. // {
  1080. // SendLayerData(x, y, map);
  1081. // }
  1082. //}
  1083. // Send LayerData in a spiral pattern. Fun!
  1084. SendLayerTopRight(map, 0, 0, map.SizeX/Constants.TerrainPatchSize-1, map.SizeY/Constants.TerrainPatchSize-1);
  1085. }
  1086. catch (Exception e)
  1087. {
  1088. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1089. }
  1090. }
  1091. private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2)
  1092. {
  1093. // Row
  1094. for (int i = x1; i <= x2; i++)
  1095. SendLayerData(i, y1, map);
  1096. // Column
  1097. for (int j = y1 + 1; j <= y2; j++)
  1098. SendLayerData(x2, j, map);
  1099. if (x2 - x1 > 0 && y2 - y1 > 0)
  1100. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1101. }
  1102. void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2)
  1103. {
  1104. // Row in reverse
  1105. for (int i = x2; i >= x1; i--)
  1106. SendLayerData(i, y2, map);
  1107. // Column in reverse
  1108. for (int j = y2 - 1; j >= y1; j--)
  1109. SendLayerData(x1, j, map);
  1110. if (x2 - x1 > 0 && y2 - y1 > 0)
  1111. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1112. }
  1113. /// <summary>
  1114. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1115. /// </summary>
  1116. /// <param name="map">heightmap</param>
  1117. /// <param name="px">X coordinate for patches 0..12</param>
  1118. /// <param name="py">Y coordinate for patches 0..15</param>
  1119. // private void SendLayerPacket(float[] map, int y, int x)
  1120. // {
  1121. // int[] patches = new int[4];
  1122. // patches[0] = x + 0 + y * 16;
  1123. // patches[1] = x + 1 + y * 16;
  1124. // patches[2] = x + 2 + y * 16;
  1125. // patches[3] = x + 3 + y * 16;
  1126. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1127. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1128. // }
  1129. // Legacy form of invocation that passes around a bare data array.
  1130. // Just ignore what was passed and use the real terrain info that is part of the scene.
  1131. // As a HORRIBLE kludge in an attempt to not change the definition of IClientAPI,
  1132. // there is a special form for specifying multiple terrain patches to send.
  1133. // The form is to pass 'px' as negative the number of patches to send and to
  1134. // pass the float array as pairs of patch X and Y coordinates. So, passing 'px'
  1135. // as -2 and map= [3, 5, 8, 4] would mean to send two terrain heightmap patches
  1136. // and the patches to send are <3,5> and <8,4>.
  1137. public void SendLayerData(int px, int py, float[] map)
  1138. {
  1139. if (px >= 0)
  1140. {
  1141. SendLayerData(px, py, m_scene.Heightmap.GetTerrainData());
  1142. }
  1143. else
  1144. {
  1145. int numPatches = -px;
  1146. int[] xPatches = new int[numPatches];
  1147. int[] yPatches = new int[numPatches];
  1148. for (int pp = 0; pp < numPatches; pp++)
  1149. {
  1150. xPatches[pp] = (int)map[pp * 2];
  1151. yPatches[pp] = (int)map[pp * 2 + 1];
  1152. }
  1153. // DebugSendingPatches("SendLayerData", xPatches, yPatches);
  1154. SendLayerData(xPatches, yPatches, m_scene.Heightmap.GetTerrainData());
  1155. }
  1156. }
  1157. private void DebugSendingPatches(string pWho, int[] pX, int[] pY)
  1158. {
  1159. if (m_log.IsDebugEnabled)
  1160. {
  1161. int numPatches = pX.Length;
  1162. string Xs = "";
  1163. string Ys = "";
  1164. for (int pp = 0; pp < numPatches; pp++)
  1165. {
  1166. Xs += String.Format("{0}", (int)pX[pp]) + ",";
  1167. Ys += String.Format("{0}", (int)pY[pp]) + ",";
  1168. }
  1169. m_log.DebugFormat("{0} {1}: numPatches={2}, X={3}, Y={4}", LogHeader, pWho, numPatches, Xs, Ys);
  1170. }
  1171. }
  1172. /// <summary>
  1173. /// Sends a terrain packet for the point specified.
  1174. /// This is a legacy call that has refarbed the terrain into a flat map of floats.
  1175. /// We just use the terrain from the region we know about.
  1176. /// </summary>
  1177. /// <param name="px">Patch coordinate (x) 0..15</param>
  1178. /// <param name="py">Patch coordinate (y) 0..15</param>
  1179. /// <param name="map">heightmap</param>
  1180. public void SendLayerData(int px, int py, TerrainData terrData)
  1181. {
  1182. int[] xPatches = new[] { px };
  1183. int[] yPatches = new[] { py };
  1184. SendLayerData(xPatches, yPatches, terrData);
  1185. }
  1186. private void SendLayerData(int[] px, int[] py, TerrainData terrData)
  1187. {
  1188. try
  1189. {
  1190. /* test code using the terrain compressor in libOpenMetaverse
  1191. int[] patchInd = new int[1];
  1192. patchInd[0] = px + (py * Constants.TerrainPatchSize);
  1193. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(terrData.GetFloatsSerialized(), patchInd);
  1194. */
  1195. // Many, many patches could have been passed to us. Since the patches will be compressed
  1196. // into variable sized blocks, we cannot pre-compute how many will fit into one
  1197. // packet. While some fancy packing algorithm is possible, 4 seems to always fit.
  1198. int PatchesAssumedToFit = 4;
  1199. for (int pcnt = 0; pcnt < px.Length; pcnt += PatchesAssumedToFit)
  1200. {
  1201. int remaining = Math.Min(px.Length - pcnt, PatchesAssumedToFit);
  1202. int[] xPatches = new int[remaining];
  1203. int[] yPatches = new int[remaining];
  1204. for (int ii = 0; ii < remaining; ii++)
  1205. {
  1206. xPatches[ii] = px[pcnt + ii];
  1207. yPatches[ii] = py[pcnt + ii];
  1208. }
  1209. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, xPatches, yPatches);
  1210. // DebugSendingPatches("SendLayerDataInternal", xPatches, yPatches);
  1211. SendTheLayerPacket(layerpack);
  1212. }
  1213. // LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, px, py);
  1214. }
  1215. catch (Exception e)
  1216. {
  1217. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1218. }
  1219. }
  1220. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a
  1221. // sub optimal editing experience. To alleviate this issue, when the user edits the terrain, we
  1222. // start skipping the queues until they're done editing the terrain. We also make them
  1223. // unreliable because it's extremely likely that multiple packets will be sent for a terrain patch
  1224. // area invalidating previous packets for that area.
  1225. // It's possible for an editing user to flood themselves with edited packets but the majority
  1226. // of use cases are such that only a tiny percentage of users will be editing the terrain.
  1227. // Other, non-editing users will see the edits much slower.
  1228. // One last note on this topic, by the time users are going to be editing the terrain, it's
  1229. // extremely likely that the sim will have rezzed already and therefore this is not likely going
  1230. // to cause any additional issues with lost packets, objects or terrain patches.
  1231. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we
  1232. // only have one cache miss.
  1233. private void SendTheLayerPacket(LayerDataPacket layerpack)
  1234. {
  1235. if (m_justEditedTerrain)
  1236. {
  1237. layerpack.Header.Reliable = false;
  1238. OutPacket(layerpack, ThrottleOutPacketType.Unknown );
  1239. }
  1240. else
  1241. {
  1242. layerpack.Header.Reliable = true;
  1243. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1244. }
  1245. }
  1246. /// <summary>
  1247. /// Send the wind matrix to the client
  1248. /// </summary>
  1249. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1250. public virtual void SendWindData(Vector2[] windSpeeds)
  1251. {
  1252. Util.FireAndForget(DoSendWindData, windSpeeds, "LLClientView.SendWindData");
  1253. }
  1254. /// <summary>
  1255. /// Send the cloud matrix to the client
  1256. /// </summary>
  1257. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1258. public virtual void SendCloudData(float[] cloudDensity)
  1259. {
  1260. Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
  1261. }
  1262. /// <summary>
  1263. /// Send wind layer information to the client.
  1264. /// </summary>
  1265. /// <param name="o"></param>
  1266. private void DoSendWindData(object o)
  1267. {
  1268. Vector2[] windSpeeds = (Vector2[])o;
  1269. TerrainPatch[] patches = new TerrainPatch[2];
  1270. patches[0] = new TerrainPatch { Data = new float[16 * 16] };
  1271. patches[1] = new TerrainPatch { Data = new float[16 * 16] };
  1272. for (int x = 0; x < 16 * 16; x++)
  1273. {
  1274. patches[0].Data[x] = windSpeeds[x].X;
  1275. patches[1].Data[x] = windSpeeds[x].Y;
  1276. }
  1277. byte layerType = (byte)TerrainPatch.LayerType.Wind;
  1278. if (m_scene.RegionInfo.RegionSizeX > Constants.RegionSize || m_scene.RegionInfo.RegionSizeY > Constants.RegionSize)
  1279. layerType = (byte)TerrainPatch.LayerType.WindExtended;
  1280. // LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, (TerrainPatch.LayerType)layerType);
  1281. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacket(patches, layerType,
  1282. (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
  1283. layerpack.Header.Zerocoded = true;
  1284. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1285. }
  1286. /// <summary>
  1287. /// Send cloud layer information to the client.
  1288. /// </summary>
  1289. /// <param name="o"></param>
  1290. private void DoSendCloudData(object o)
  1291. {
  1292. float[] cloudCover = (float[])o;
  1293. TerrainPatch[] patches = new TerrainPatch[1];
  1294. patches[0] = new TerrainPatch();
  1295. patches[0].Data = new float[16 * 16];
  1296. for (int y = 0; y < 16; y++)
  1297. {
  1298. for (int x = 0; x < 16; x++)
  1299. {
  1300. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1301. }
  1302. }
  1303. byte layerType = (byte)TerrainPatch.LayerType.Cloud;
  1304. if (m_scene.RegionInfo.RegionSizeX > Constants.RegionSize || m_scene.RegionInfo.RegionSizeY > Constants.RegionSize)
  1305. layerType = (byte)TerrainPatch.LayerType.CloudExtended;
  1306. // LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, (TerrainPatch.LayerType)layerType);
  1307. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacket(patches, layerType,
  1308. (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
  1309. layerpack.Header.Zerocoded = true;
  1310. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1311. }
  1312. /// <summary>
  1313. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1314. /// </summary>
  1315. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1316. {
  1317. IPAddress neighbourIP = neighbourEndPoint.Address;
  1318. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1319. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1320. // TODO: don't create new blocks if recycling an old packet
  1321. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1322. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1323. byte[] byteIP = neighbourIP.GetAddressBytes();
  1324. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1325. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1326. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1327. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1328. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1329. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1330. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1331. }
  1332. public AgentCircuitData RequestClientInfo()
  1333. {
  1334. AgentCircuitData agentData = new AgentCircuitData();
  1335. agentData.AgentID = AgentId;
  1336. agentData.SessionID = m_sessionId;
  1337. agentData.SecureSessionID = SecureSessionId;
  1338. agentData.circuitcode = m_circuitCode;
  1339. agentData.child = false;
  1340. agentData.firstname = m_firstName;
  1341. agentData.lastname = m_lastName;
  1342. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1343. if (capsModule == null) // can happen when shutting down.
  1344. return agentData;
  1345. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1346. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1347. return agentData;
  1348. }
  1349. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1350. string capsURL)
  1351. {
  1352. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1353. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1354. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1355. // TODO: don't create new blocks if recycling an old packet
  1356. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1357. newSimPack.AgentData.AgentID = AgentId;
  1358. newSimPack.AgentData.SessionID = m_sessionId;
  1359. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1360. newSimPack.Info.Position = pos;
  1361. newSimPack.Info.LookAt = look;
  1362. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1363. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1364. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1365. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1366. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1367. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1368. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1369. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1370. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1371. // Hack to get this out immediately and skip throttles
  1372. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1373. }
  1374. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1375. {
  1376. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1377. // TODO: don't create new blocks if recycling an old packet
  1378. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1379. mapReply.AgentData.AgentID = AgentId;
  1380. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1381. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1382. mapReply.AgentData.Flags = flag;
  1383. for (int i = 0; i < mapBlocks2.Length; i++)
  1384. {
  1385. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1386. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1387. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1388. mapReply.Data[i].X = mapBlocks2[i].X;
  1389. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1390. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1391. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1392. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1393. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1394. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1395. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1396. mapReply.Size[i].SizeX = mapBlocks2[i].SizeX;
  1397. mapReply.Size[i].SizeY = mapBlocks2[i].SizeY;
  1398. }
  1399. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1400. }
  1401. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1402. {
  1403. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1404. int maxsend = 10;
  1405. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1406. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1407. for (int i = 0; i < mapBlocks2.Length; i++)
  1408. {
  1409. sendingBlocks.Add(mapBlocks2[i]);
  1410. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1411. {
  1412. SendMapBlockSplit(sendingBlocks, flag);
  1413. sendingBlocks = new List<MapBlockData>();
  1414. }
  1415. }
  1416. }
  1417. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1418. {
  1419. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1420. tpLocal.Info.AgentID = AgentId;
  1421. tpLocal.Info.TeleportFlags = flags;
  1422. tpLocal.Info.LocationID = 2;
  1423. tpLocal.Info.LookAt = lookAt;
  1424. tpLocal.Info.Position = position;
  1425. // Hack to get this out immediately and skip throttles
  1426. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1427. }
  1428. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1429. uint flags, string capsURL)
  1430. {
  1431. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1432. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1433. teleport.Info.AgentID = AgentId;
  1434. teleport.Info.RegionHandle = regionHandle;
  1435. teleport.Info.SimAccess = simAccess;
  1436. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1437. IPAddress oIP = newRegionEndPoint.Address;
  1438. byte[] byteIP = oIP.GetAddressBytes();
  1439. uint ip = (uint)byteIP[3] << 24;
  1440. ip += (uint)byteIP[2] << 16;
  1441. ip += (uint)byteIP[1] << 8;
  1442. ip += (uint)byteIP[0];
  1443. teleport.Info.SimIP = ip;
  1444. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1445. teleport.Info.LocationID = 4;
  1446. teleport.Info.TeleportFlags = 1 << 4;
  1447. // Hack to get this out immediately and skip throttles.
  1448. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1449. }
  1450. /// <summary>
  1451. /// Inform the client that a teleport attempt has failed
  1452. /// </summary>
  1453. public void SendTeleportFailed(string reason)
  1454. {
  1455. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1456. tpFailed.Info.AgentID = AgentId;
  1457. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1458. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1459. // Hack to get this out immediately and skip throttles
  1460. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1461. }
  1462. /// <summary>
  1463. ///
  1464. /// </summary>
  1465. public void SendTeleportStart(uint flags)
  1466. {
  1467. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1468. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1469. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1470. // Hack to get this out immediately and skip throttles
  1471. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1472. }
  1473. public void SendTeleportProgress(uint flags, string message)
  1474. {
  1475. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1476. tpProgress.AgentData.AgentID = this.AgentId;
  1477. tpProgress.Info.TeleportFlags = flags;
  1478. tpProgress.Info.Message = Util.StringToBytes256(message);
  1479. // Hack to get this out immediately and skip throttles
  1480. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1481. }
  1482. 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)
  1483. {
  1484. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1485. money.MoneyData.AgentID = AgentId;
  1486. money.MoneyData.TransactionID = transaction;
  1487. money.MoneyData.TransactionSuccess = success;
  1488. money.MoneyData.Description = description;
  1489. money.MoneyData.MoneyBalance = balance;
  1490. money.TransactionInfo.TransactionType = transactionType;
  1491. money.TransactionInfo.SourceID = sourceID;
  1492. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1493. money.TransactionInfo.DestID = destID;
  1494. money.TransactionInfo.IsDestGroup = destIsGroup;
  1495. money.TransactionInfo.Amount = amount;
  1496. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1497. OutPacket(money, ThrottleOutPacketType.Task);
  1498. }
  1499. public void SendPayPrice(UUID objectID, int[] payPrice)
  1500. {
  1501. if (payPrice[0] == 0 &&
  1502. payPrice[1] == 0 &&
  1503. payPrice[2] == 0 &&
  1504. payPrice[3] == 0 &&
  1505. payPrice[4] == 0)
  1506. return;
  1507. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1508. payPriceReply.ObjectData.ObjectID = objectID;
  1509. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1510. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1511. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1512. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1513. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1514. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1515. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1516. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1517. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1518. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1519. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1520. }
  1521. public void SendStartPingCheck(byte seq)
  1522. {
  1523. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1524. pc.Header.Reliable = false;
  1525. pc.PingID.PingID = seq;
  1526. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1527. pc.PingID.OldestUnacked = 0;
  1528. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1529. }
  1530. public void SendKillObject(List<uint> localIDs)
  1531. {
  1532. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1533. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1534. // TODO: don't create new blocks if recycling an old packet
  1535. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1536. for (int i = 0 ; i < localIDs.Count ; i++ )
  1537. {
  1538. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1539. kill.ObjectData[i].ID = localIDs[i];
  1540. }
  1541. kill.Header.Reliable = true;
  1542. kill.Header.Zerocoded = true;
  1543. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1544. {
  1545. OutPacket(kill, ThrottleOutPacketType.Task);
  1546. }
  1547. else
  1548. {
  1549. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1550. // condition where a kill can be processed before an out-of-date update for the same object.
  1551. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1552. lock (m_killRecord)
  1553. {
  1554. foreach (uint localID in localIDs)
  1555. m_killRecord.Add(localID);
  1556. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1557. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1558. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1559. // scene objects in a viewer until that viewer is relogged in.
  1560. OutPacket(kill, ThrottleOutPacketType.Task);
  1561. }
  1562. }
  1563. }
  1564. /// <summary>
  1565. /// Send information about the items contained in a folder to the client.
  1566. /// </summary>
  1567. /// <remarks>
  1568. /// XXX This method needs some refactoring loving
  1569. /// </remarks>
  1570. /// <param name="ownerID">The owner of the folder</param>
  1571. /// <param name="folderID">The id of the folder</param>
  1572. /// <param name="items">The items contained in the folder identified by folderID</param>
  1573. /// <param name="folders"></param>
  1574. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1575. /// <param name="fetchItems">Do we need to send item information?</param>
  1576. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1577. List<InventoryFolderBase> folders, int version,
  1578. bool fetchFolders, bool fetchItems)
  1579. {
  1580. // An inventory descendents packet consists of a single agent section and an inventory details
  1581. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1582. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1583. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1584. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1585. //
  1586. // http://opensimulator.org/mantis/view.php?id=226
  1587. //
  1588. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1589. // 6 to 7 items at a time, so let's stick with 6
  1590. int MAX_ITEMS_PER_PACKET = 5;
  1591. int MAX_FOLDERS_PER_PACKET = 6;
  1592. int totalItems = fetchItems ? items.Count : 0;
  1593. int totalFolders = fetchFolders ? folders.Count : 0;
  1594. int itemsSent = 0;
  1595. int foldersSent = 0;
  1596. int foldersToSend = 0;
  1597. int itemsToSend = 0;
  1598. InventoryDescendentsPacket currentPacket = null;
  1599. // Handle empty folders
  1600. //
  1601. if (totalItems == 0 && totalFolders == 0)
  1602. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1603. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1604. //
  1605. while (itemsSent < totalItems || foldersSent < totalFolders)
  1606. {
  1607. if (currentPacket == null) // Start a new packet
  1608. {
  1609. foldersToSend = totalFolders - foldersSent;
  1610. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1611. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1612. if (foldersToSend == 0)
  1613. {
  1614. itemsToSend = totalItems - itemsSent;
  1615. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1616. itemsToSend = MAX_ITEMS_PER_PACKET;
  1617. }
  1618. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1619. }
  1620. if (foldersToSend-- > 0)
  1621. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1622. else if (itemsToSend-- > 0)
  1623. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1624. else
  1625. {
  1626. // m_log.DebugFormat(
  1627. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1628. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1629. currentPacket = null;
  1630. }
  1631. }
  1632. if (currentPacket != null)
  1633. {
  1634. // m_log.DebugFormat(
  1635. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1636. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1637. }
  1638. }
  1639. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1640. {
  1641. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1642. newBlock.FolderID = folder.ID;
  1643. newBlock.Name = Util.StringToBytes256(folder.Name);
  1644. newBlock.ParentID = folder.ParentID;
  1645. newBlock.Type = (sbyte)folder.Type;
  1646. //if (newBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
  1647. // newBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
  1648. return newBlock;
  1649. }
  1650. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1651. {
  1652. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1653. newBlock.ItemID = item.ID;
  1654. newBlock.AssetID = item.AssetID;
  1655. newBlock.CreatorID = item.CreatorIdAsUuid;
  1656. newBlock.BaseMask = item.BasePermissions;
  1657. newBlock.Description = Util.StringToBytes256(item.Description);
  1658. newBlock.EveryoneMask = item.EveryOnePermissions;
  1659. newBlock.OwnerMask = item.CurrentPermissions;
  1660. newBlock.FolderID = item.Folder;
  1661. newBlock.InvType = (sbyte)item.InvType;
  1662. newBlock.Name = Util.StringToBytes256(item.Name);
  1663. newBlock.NextOwnerMask = item.NextPermissions;
  1664. newBlock.OwnerID = item.Owner;
  1665. newBlock.Type = (sbyte)item.AssetType;
  1666. newBlock.GroupID = item.GroupID;
  1667. newBlock.GroupOwned = item.GroupOwned;
  1668. newBlock.GroupMask = item.GroupPermissions;
  1669. newBlock.CreationDate = item.CreationDate;
  1670. newBlock.SalePrice = item.SalePrice;
  1671. newBlock.SaleType = item.SaleType;
  1672. newBlock.Flags = item.Flags;
  1673. newBlock.CRC =
  1674. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1675. newBlock.InvType, newBlock.Type,
  1676. newBlock.AssetID, newBlock.GroupID,
  1677. newBlock.SalePrice,
  1678. newBlock.OwnerID, newBlock.CreatorID,
  1679. newBlock.ItemID, newBlock.FolderID,
  1680. newBlock.EveryoneMask,
  1681. newBlock.Flags, newBlock.OwnerMask,
  1682. newBlock.GroupMask, newBlock.NextOwnerMask);
  1683. return newBlock;
  1684. }
  1685. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1686. {
  1687. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1688. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1689. packet.FolderData[0].FolderID = UUID.Zero;
  1690. packet.FolderData[0].ParentID = UUID.Zero;
  1691. packet.FolderData[0].Type = -1;
  1692. packet.FolderData[0].Name = new byte[0];
  1693. }
  1694. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1695. {
  1696. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1697. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1698. packet.ItemData[0].ItemID = UUID.Zero;
  1699. packet.ItemData[0].AssetID = UUID.Zero;
  1700. packet.ItemData[0].CreatorID = UUID.Zero;
  1701. packet.ItemData[0].BaseMask = 0;
  1702. packet.ItemData[0].Description = new byte[0];
  1703. packet.ItemData[0].EveryoneMask = 0;
  1704. packet.ItemData[0].OwnerMask = 0;
  1705. packet.ItemData[0].FolderID = UUID.Zero;
  1706. packet.ItemData[0].InvType = (sbyte)0;
  1707. packet.ItemData[0].Name = new byte[0];
  1708. packet.ItemData[0].NextOwnerMask = 0;
  1709. packet.ItemData[0].OwnerID = UUID.Zero;
  1710. packet.ItemData[0].Type = -1;
  1711. packet.ItemData[0].GroupID = UUID.Zero;
  1712. packet.ItemData[0].GroupOwned = false;
  1713. packet.ItemData[0].GroupMask = 0;
  1714. packet.ItemData[0].CreationDate = 0;
  1715. packet.ItemData[0].SalePrice = 0;
  1716. packet.ItemData[0].SaleType = 0;
  1717. packet.ItemData[0].Flags = 0;
  1718. // No need to add CRC
  1719. }
  1720. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1721. {
  1722. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1723. descend.Header.Zerocoded = true;
  1724. descend.AgentData.AgentID = AgentId;
  1725. descend.AgentData.OwnerID = ownerID;
  1726. descend.AgentData.FolderID = folderID;
  1727. descend.AgentData.Version = version;
  1728. descend.AgentData.Descendents = descendents;
  1729. if (folders > 0)
  1730. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1731. else
  1732. AddNullFolderBlockToDecendentsPacket(ref descend);
  1733. if (items > 0)
  1734. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1735. else
  1736. AddNullItemBlockToDescendentsPacket(ref descend);
  1737. return descend;
  1738. }
  1739. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1740. {
  1741. // Fudge this value. It's only needed to make the CRC anyway
  1742. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1743. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1744. // TODO: don't create new blocks if recycling an old packet
  1745. inventoryReply.AgentData.AgentID = AgentId;
  1746. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1747. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1748. inventoryReply.InventoryData[0].ItemID = item.ID;
  1749. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1750. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1751. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1752. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1753. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1754. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1755. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1756. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1757. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1758. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1759. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1760. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1761. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1762. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1763. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1764. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1765. inventoryReply.InventoryData[0].Flags = item.Flags;
  1766. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1767. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1768. inventoryReply.InventoryData[0].CRC =
  1769. Helpers.InventoryCRC(
  1770. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1771. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1772. inventoryReply.InventoryData[0].GroupID, 100,
  1773. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1774. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1775. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1776. FULL_MASK_PERMISSIONS);
  1777. inventoryReply.Header.Zerocoded = true;
  1778. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1779. }
  1780. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1781. {
  1782. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1783. UUID transactionId = UUID.Random();
  1784. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1785. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1786. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1787. if (folderDataBlocks.Count > 0)
  1788. {
  1789. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1790. // Send these now
  1791. BulkUpdateInventoryPacket bulkUpdate
  1792. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1793. bulkUpdate.Header.Zerocoded = true;
  1794. bulkUpdate.AgentData.AgentID = AgentId;
  1795. bulkUpdate.AgentData.TransactionID = transactionId;
  1796. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1797. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1798. bulkUpdate.ItemData = foo.ToArray();
  1799. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1800. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1801. }
  1802. }
  1803. /// <summary>
  1804. /// Recursively construct bulk update packets to send folders and items
  1805. /// </summary>
  1806. /// <param name="folder"></param>
  1807. /// <param name="folderDataBlocks"></param>
  1808. /// <param name="transactionId"></param>
  1809. private void SendBulkUpdateInventoryFolderRecursive(
  1810. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1811. UUID transactionId)
  1812. {
  1813. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1814. const int MAX_ITEMS_PER_PACKET = 5;
  1815. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1816. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1817. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1818. // being used on the Linden grid at 20081203).
  1819. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1820. List<InventoryItemBase> items = contents.Items;
  1821. while (items.Count > 0)
  1822. {
  1823. BulkUpdateInventoryPacket bulkUpdate
  1824. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1825. bulkUpdate.Header.Zerocoded = true;
  1826. bulkUpdate.AgentData.AgentID = AgentId;
  1827. bulkUpdate.AgentData.TransactionID = transactionId;
  1828. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1829. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1830. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1831. for (int i = 0; i < itemsToSend; i++)
  1832. {
  1833. // Remove from the end of the list so that we don't incur a performance penalty
  1834. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1835. items.RemoveAt(items.Count - 1);
  1836. }
  1837. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1838. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1839. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1840. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1841. // items belong.
  1842. if (items.Count > 0)
  1843. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1844. }
  1845. List<InventoryFolderBase> subFolders = contents.Folders;
  1846. foreach (InventoryFolderBase subFolder in subFolders)
  1847. {
  1848. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1849. }
  1850. }
  1851. /// <summary>
  1852. /// Generate a bulk update inventory data block for the given folder
  1853. /// </summary>
  1854. /// <param name="folder"></param>
  1855. /// <returns></returns>
  1856. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1857. {
  1858. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1859. folderBlock.FolderID = folder.ID;
  1860. folderBlock.ParentID = folder.ParentID;
  1861. folderBlock.Type = (sbyte)folder.Type;
  1862. // Leaving this here for now, just in case we need to do this for a while
  1863. //if (folderBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
  1864. // folderBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
  1865. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1866. return folderBlock;
  1867. }
  1868. /// <summary>
  1869. /// Generate a bulk update inventory data block for the given item
  1870. /// </summary>
  1871. /// <param name="item"></param>
  1872. /// <returns></returns>
  1873. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1874. {
  1875. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1876. itemBlock.ItemID = item.ID;
  1877. itemBlock.AssetID = item.AssetID;
  1878. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1879. itemBlock.BaseMask = item.BasePermissions;
  1880. itemBlock.Description = Util.StringToBytes256(item.Description);
  1881. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1882. itemBlock.FolderID = item.Folder;
  1883. itemBlock.InvType = (sbyte)item.InvType;
  1884. itemBlock.Name = Util.StringToBytes256(item.Name);
  1885. itemBlock.NextOwnerMask = item.NextPermissions;
  1886. itemBlock.OwnerID = item.Owner;
  1887. itemBlock.OwnerMask = item.CurrentPermissions;
  1888. itemBlock.Type = (sbyte)item.AssetType;
  1889. itemBlock.GroupID = item.GroupID;
  1890. itemBlock.GroupOwned = item.GroupOwned;
  1891. itemBlock.GroupMask = item.GroupPermissions;
  1892. itemBlock.Flags = item.Flags;
  1893. itemBlock.SalePrice = item.SalePrice;
  1894. itemBlock.SaleType = item.SaleType;
  1895. itemBlock.CreationDate = item.CreationDate;
  1896. itemBlock.CRC =
  1897. Helpers.InventoryCRC(
  1898. 1000, 0, itemBlock.InvType,
  1899. itemBlock.Type, itemBlock.AssetID,
  1900. itemBlock.GroupID, 100,
  1901. itemBlock.OwnerID, itemBlock.CreatorID,
  1902. itemBlock.ItemID, itemBlock.FolderID,
  1903. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1904. (uint)PermissionMask.All);
  1905. return itemBlock;
  1906. }
  1907. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1908. {
  1909. if (node is InventoryItemBase)
  1910. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1911. else if (node is InventoryFolderBase)
  1912. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1913. else if (node != null)
  1914. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1915. else
  1916. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1917. }
  1918. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1919. {
  1920. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1921. BulkUpdateInventoryPacket bulkUpdate
  1922. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1923. bulkUpdate.AgentData.AgentID = AgentId;
  1924. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1925. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1926. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1927. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1928. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1929. bulkUpdate.FolderData[0].Type = -1;
  1930. bulkUpdate.FolderData[0].Name = new byte[0];
  1931. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1932. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1933. bulkUpdate.ItemData[0].ItemID = item.ID;
  1934. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1935. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1936. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1937. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1938. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1939. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1940. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1941. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1942. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1943. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1944. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1945. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1946. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1947. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1948. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1949. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1950. bulkUpdate.ItemData[0].Flags = item.Flags;
  1951. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1952. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1953. bulkUpdate.ItemData[0].CRC =
  1954. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1955. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1956. bulkUpdate.ItemData[0].GroupID, 100,
  1957. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1958. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1959. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1960. FULL_MASK_PERMISSIONS);
  1961. bulkUpdate.Header.Zerocoded = true;
  1962. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1963. }
  1964. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1965. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1966. {
  1967. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1968. UpdateCreateInventoryItemPacket InventoryReply
  1969. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1970. PacketType.UpdateCreateInventoryItem);
  1971. // TODO: don't create new blocks if recycling an old packet
  1972. InventoryReply.AgentData.AgentID = AgentId;
  1973. InventoryReply.AgentData.SimApproved = true;
  1974. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1975. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1976. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1977. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1978. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1979. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1980. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1981. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1982. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1983. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1984. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1985. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1986. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1987. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1988. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1989. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1990. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1991. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1992. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1993. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1994. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1995. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1996. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1997. InventoryReply.InventoryData[0].CRC =
  1998. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1999. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  2000. InventoryReply.InventoryData[0].GroupID, 100,
  2001. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  2002. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  2003. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  2004. FULL_MASK_PERMISSIONS);
  2005. InventoryReply.Header.Zerocoded = true;
  2006. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  2007. }
  2008. public void SendRemoveInventoryItem(UUID itemID)
  2009. {
  2010. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  2011. // TODO: don't create new blocks if recycling an old packet
  2012. remove.AgentData.AgentID = AgentId;
  2013. remove.AgentData.SessionID = m_sessionId;
  2014. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  2015. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  2016. remove.InventoryData[0].ItemID = itemID;
  2017. remove.Header.Zerocoded = true;
  2018. OutPacket(remove, ThrottleOutPacketType.Asset);
  2019. }
  2020. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  2021. {
  2022. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  2023. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  2024. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  2025. ddata.Controls = (uint)controls;
  2026. ddata.PassToAgent = passToAgent;
  2027. ddata.TakeControls = TakeControls;
  2028. data[0] = ddata;
  2029. scriptcontrol.Data = data;
  2030. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  2031. }
  2032. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  2033. {
  2034. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  2035. replytask.InventoryData.TaskID = taskID;
  2036. replytask.InventoryData.Serial = serial;
  2037. replytask.InventoryData.Filename = fileName;
  2038. OutPacket(replytask, ThrottleOutPacketType.Asset);
  2039. }
  2040. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  2041. {
  2042. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  2043. sendXfer.XferID.ID = xferID;
  2044. sendXfer.XferID.Packet = packet;
  2045. sendXfer.DataPacket.Data = data;
  2046. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  2047. }
  2048. public void SendAbortXferPacket(ulong xferID)
  2049. {
  2050. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  2051. xferItem.XferID.ID = xferID;
  2052. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  2053. }
  2054. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  2055. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  2056. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  2057. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  2058. {
  2059. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  2060. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  2061. economyData.Info.ObjectCapacity = ObjectCapacity;
  2062. economyData.Info.ObjectCount = ObjectCount;
  2063. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  2064. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  2065. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  2066. economyData.Info.PriceObjectRent = PriceObjectRent;
  2067. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  2068. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  2069. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  2070. economyData.Info.PriceParcelRent = PriceParcelRent;
  2071. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  2072. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  2073. economyData.Info.PriceRentLight = PriceRentLight;
  2074. economyData.Info.PriceUpload = PriceUpload;
  2075. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  2076. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  2077. economyData.Header.Reliable = true;
  2078. OutPacket(economyData, ThrottleOutPacketType.Task);
  2079. }
  2080. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  2081. {
  2082. //construct the AvatarPickerReply packet.
  2083. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  2084. replyPacket.AgentData.AgentID = AgentData.AgentID;
  2085. replyPacket.AgentData.QueryID = AgentData.QueryID;
  2086. //int i = 0;
  2087. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  2088. foreach (AvatarPickerReplyDataArgs arg in Data)
  2089. {
  2090. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  2091. db.AvatarID = arg.AvatarID;
  2092. db.FirstName = arg.FirstName;
  2093. db.LastName = arg.LastName;
  2094. data_block.Add(db);
  2095. }
  2096. replyPacket.Data = data_block.ToArray();
  2097. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  2098. }
  2099. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  2100. {
  2101. if (agentid == AgentId)
  2102. {
  2103. ActiveGroupId = activegroupid;
  2104. ActiveGroupName = groupname;
  2105. ActiveGroupPowers = grouppowers;
  2106. }
  2107. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  2108. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  2109. sendAgentDataUpdate.AgentData.AgentID = agentid;
  2110. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2111. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2112. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2113. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2114. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2115. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2116. }
  2117. /// <summary>
  2118. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2119. /// blue information box in the bottom right hand corner.
  2120. /// </summary>
  2121. /// <param name="message"></param>
  2122. public void SendAlertMessage(string message)
  2123. {
  2124. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2125. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2126. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2127. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2128. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2129. }
  2130. /// <summary>
  2131. /// Send an agent alert message to the client.
  2132. /// </summary>
  2133. /// <param name="message"></param>
  2134. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2135. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2136. /// the AlertMessage packet).</param>
  2137. public void SendAgentAlertMessage(string message, bool modal)
  2138. {
  2139. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2140. }
  2141. /// <summary>
  2142. /// Construct an agent alert packet
  2143. /// </summary>
  2144. /// <param name="message"></param>
  2145. /// <param name="modal"></param>
  2146. /// <returns></returns>
  2147. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2148. {
  2149. // Prepend a slash to make the message come up in the top right
  2150. // again.
  2151. // Allow special formats to be sent from aware modules.
  2152. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2153. message = "/" + message;
  2154. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2155. alertPack.AgentData.AgentID = AgentId;
  2156. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2157. alertPack.AlertData.Modal = modal;
  2158. return alertPack;
  2159. }
  2160. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2161. string url)
  2162. {
  2163. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2164. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2165. loadURL.Data.ObjectID = objectID;
  2166. loadURL.Data.OwnerID = ownerID;
  2167. loadURL.Data.OwnerIsGroup = groupOwned;
  2168. loadURL.Data.Message = Util.StringToBytes256(message);
  2169. loadURL.Data.URL = Util.StringToBytes256(url);
  2170. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2171. }
  2172. public void SendDialog(
  2173. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2174. UUID textureID, int ch, string[] buttonlabels)
  2175. {
  2176. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2177. dialog.Data.ObjectID = objectID;
  2178. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2179. // this is the username of the *owner*
  2180. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2181. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2182. dialog.Data.Message = Util.StringToBytes1024(msg);
  2183. dialog.Data.ImageID = textureID;
  2184. dialog.Data.ChatChannel = ch;
  2185. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2186. for (int i = 0; i < buttonlabels.Length; i++)
  2187. {
  2188. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2189. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2190. }
  2191. dialog.Buttons = buttons;
  2192. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2193. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2194. dialog.OwnerData[0].OwnerID = ownerID;
  2195. OutPacket(dialog, ThrottleOutPacketType.Task);
  2196. }
  2197. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2198. {
  2199. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2200. // TODO: don't create new blocks if recycling an old packet
  2201. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2202. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2203. preSound.DataBlock[0].ObjectID = objectID;
  2204. preSound.DataBlock[0].OwnerID = ownerID;
  2205. preSound.DataBlock[0].SoundID = soundID;
  2206. preSound.Header.Zerocoded = true;
  2207. OutPacket(preSound, ThrottleOutPacketType.Task);
  2208. }
  2209. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2210. {
  2211. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2212. sound.DataBlock.SoundID = soundID;
  2213. sound.DataBlock.ObjectID = objectID;
  2214. sound.DataBlock.OwnerID = ownerID;
  2215. sound.DataBlock.Gain = gain;
  2216. sound.DataBlock.Flags = flags;
  2217. OutPacket(sound, ThrottleOutPacketType.Task);
  2218. }
  2219. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2220. {
  2221. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2222. sound.SoundData.SoundID = soundID;
  2223. sound.SoundData.OwnerID = ownerID;
  2224. sound.SoundData.ObjectID = objectID;
  2225. sound.SoundData.ParentID = parentID;
  2226. sound.SoundData.Handle = handle;
  2227. sound.SoundData.Position = position;
  2228. sound.SoundData.Gain = gain;
  2229. OutPacket(sound, ThrottleOutPacketType.Task);
  2230. }
  2231. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2232. {
  2233. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2234. sound.DataBlock.ObjectID = objectID;
  2235. sound.DataBlock.Gain = gain;
  2236. OutPacket(sound, ThrottleOutPacketType.Task);
  2237. }
  2238. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2239. {
  2240. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2241. // So adjust for that
  2242. // Contributed by: Godfrey
  2243. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2244. {
  2245. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2246. }
  2247. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2248. viewertime.TimeInfo.SunDirection = Position;
  2249. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2250. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2251. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2252. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2253. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2254. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2255. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2256. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2257. viewertime.Header.Reliable = false;
  2258. viewertime.Header.Zerocoded = true;
  2259. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2260. }
  2261. // Currently Deprecated
  2262. public void SendViewerTime(int phase)
  2263. {
  2264. /*
  2265. Console.WriteLine("SunPhase: {0}", phase);
  2266. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2267. //viewertime.TimeInfo.SecPerDay = 86400;
  2268. //viewertime.TimeInfo.SecPerYear = 31536000;
  2269. viewertime.TimeInfo.SecPerDay = 1000;
  2270. viewertime.TimeInfo.SecPerYear = 365000;
  2271. viewertime.TimeInfo.SunPhase = 1;
  2272. int sunPhase = (phase + 2) / 2;
  2273. if ((sunPhase < 6) || (sunPhase > 36))
  2274. {
  2275. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2276. Console.WriteLine("sending night");
  2277. }
  2278. else
  2279. {
  2280. if (sunPhase < 12)
  2281. {
  2282. sunPhase = 12;
  2283. }
  2284. sunPhase = sunPhase - 12;
  2285. float yValue = 0.1f * (sunPhase);
  2286. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2287. if (yValue > 1.2f)
  2288. {
  2289. yValue = yValue - 1.2f;
  2290. }
  2291. yValue = Util.Clip(yValue, 0, 1);
  2292. if (sunPhase < 14)
  2293. {
  2294. yValue = 1 - yValue;
  2295. }
  2296. if (sunPhase < 12)
  2297. {
  2298. yValue *= -1;
  2299. }
  2300. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2301. Console.WriteLine("sending sun update " + yValue);
  2302. }
  2303. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2304. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2305. viewertime.Header.Reliable = false;
  2306. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2307. */
  2308. }
  2309. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2310. {
  2311. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2312. packet.Header.Reliable = false;
  2313. packet.Header.Zerocoded = true;
  2314. packet.AgentData.AgentID = AgentId;
  2315. packet.AgentData.SessionID = SessionId;
  2316. packet.Effect = effectBlocks;
  2317. // OutPacket(packet, ThrottleOutPacketType.State);
  2318. OutPacket(packet, ThrottleOutPacketType.Task);
  2319. }
  2320. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2321. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2322. UUID partnerID)
  2323. {
  2324. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2325. avatarReply.AgentData.AgentID = AgentId;
  2326. avatarReply.AgentData.AvatarID = avatarID;
  2327. if (aboutText != null)
  2328. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2329. else
  2330. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2331. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2332. avatarReply.PropertiesData.CharterMember = charterMember;
  2333. if (flAbout != null)
  2334. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2335. else
  2336. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2337. avatarReply.PropertiesData.Flags = flags;
  2338. avatarReply.PropertiesData.FLImageID = flImageID;
  2339. avatarReply.PropertiesData.ImageID = imageID;
  2340. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2341. avatarReply.PropertiesData.PartnerID = partnerID;
  2342. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2343. }
  2344. /// <summary>
  2345. /// Send the client an Estate message blue box pop-down with a single OK button
  2346. /// </summary>
  2347. /// <param name="FromAvatarID"></param>
  2348. /// <param name="fromSessionID"></param>
  2349. /// <param name="FromAvatarName"></param>
  2350. /// <param name="Message"></param>
  2351. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2352. {
  2353. if (!SceneAgent.IsChildAgent)
  2354. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2355. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2356. }
  2357. public void SendLogoutPacket()
  2358. {
  2359. // I know this is a bit of a hack, however there are times when you don't
  2360. // want to send this, but still need to do the rest of the shutdown process
  2361. // this method gets called from the packet server.. which makes it practically
  2362. // impossible to do any other way.
  2363. if (m_SendLogoutPacketWhenClosing)
  2364. {
  2365. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2366. // TODO: don't create new blocks if recycling an old packet
  2367. logReply.AgentData.AgentID = AgentId;
  2368. logReply.AgentData.SessionID = SessionId;
  2369. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2370. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2371. logReply.InventoryData[0].ItemID = UUID.Zero;
  2372. OutPacket(logReply, ThrottleOutPacketType.Task);
  2373. }
  2374. }
  2375. public void SendHealth(float health)
  2376. {
  2377. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2378. healthpacket.HealthData.Health = health;
  2379. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2380. }
  2381. public void SendAgentOnline(UUID[] agentIDs)
  2382. {
  2383. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2384. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2385. for (int i = 0; i < agentIDs.Length; i++)
  2386. {
  2387. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2388. onpbl.AgentID = agentIDs[i];
  2389. onpb[i] = onpbl;
  2390. }
  2391. onp.AgentBlock = onpb;
  2392. onp.Header.Reliable = true;
  2393. OutPacket(onp, ThrottleOutPacketType.Task);
  2394. }
  2395. public void SendAgentOffline(UUID[] agentIDs)
  2396. {
  2397. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2398. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2399. for (int i = 0; i < agentIDs.Length; i++)
  2400. {
  2401. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2402. onpbl.AgentID = agentIDs[i];
  2403. offpb[i] = onpbl;
  2404. }
  2405. offp.AgentBlock = offpb;
  2406. offp.Header.Reliable = true;
  2407. OutPacket(offp, ThrottleOutPacketType.Task);
  2408. }
  2409. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2410. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2411. {
  2412. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2413. avatarSitResponse.SitObject.ID = TargetID;
  2414. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2415. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2416. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2417. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2418. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2419. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2420. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2421. }
  2422. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2423. {
  2424. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2425. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2426. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2427. adb.AgentID = AgentId;
  2428. adb.SessionID = SessionId; // More security
  2429. gdb.GodLevel = (byte)AdminLevel;
  2430. gdb.Token = Token;
  2431. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2432. respondPacket.GrantData = gdb;
  2433. respondPacket.AgentData = adb;
  2434. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2435. }
  2436. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2437. {
  2438. m_groupPowers.Clear();
  2439. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2440. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2441. for (int i = 0; i < GroupMembership.Length; i++)
  2442. {
  2443. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2444. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2445. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2446. Group.Contribution = GroupMembership[i].Contribution;
  2447. Group.GroupID = GroupMembership[i].GroupID;
  2448. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2449. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2450. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2451. Groups[i] = Group;
  2452. }
  2453. Groupupdate.GroupData = Groups;
  2454. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2455. Groupupdate.AgentData.AgentID = AgentId;
  2456. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2457. try
  2458. {
  2459. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2460. if (eq != null)
  2461. {
  2462. eq.GroupMembership(Groupupdate, this.AgentId);
  2463. }
  2464. }
  2465. catch (Exception ex)
  2466. {
  2467. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2468. m_log.Warn("sending group membership data via UDP");
  2469. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2470. }
  2471. }
  2472. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2473. {
  2474. SceneObjectPart part = (SceneObjectPart)entity;
  2475. if (part != null && AgentId != UUID.Zero)
  2476. {
  2477. try
  2478. {
  2479. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2480. if (eq != null)
  2481. {
  2482. uint localid = part.LocalId;
  2483. byte physshapetype = part.PhysicsShapeType;
  2484. float density = part.Density;
  2485. float friction = part.Friction;
  2486. float bounce = part.Restitution;
  2487. float gravmod = part.GravityModifier;
  2488. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2489. }
  2490. }
  2491. catch (Exception ex)
  2492. {
  2493. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2494. }
  2495. part.UpdatePhysRequired = false;
  2496. }
  2497. }
  2498. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2499. {
  2500. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2501. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2502. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2503. uidnamebloc.ID = groupLLUID;
  2504. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2505. uidnameblock[0] = uidnamebloc;
  2506. pack.UUIDNameBlock = uidnameblock;
  2507. OutPacket(pack, ThrottleOutPacketType.Task);
  2508. }
  2509. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2510. {
  2511. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2512. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2513. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2514. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2515. // lsrepdb.
  2516. lsrp.RequestData.ReportType = reportType;
  2517. lsrp.RequestData.RequestFlags = requestFlags;
  2518. lsrp.RequestData.TotalObjectCount = resultCount;
  2519. for (int i = 0; i < lsrpia.Length; i++)
  2520. {
  2521. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2522. lsrepdb.LocationX = lsrpia[i].LocationX;
  2523. lsrepdb.LocationY = lsrpia[i].LocationY;
  2524. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2525. lsrepdb.Score = lsrpia[i].Score;
  2526. lsrepdb.TaskID = lsrpia[i].TaskID;
  2527. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2528. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2529. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2530. lsrepdba[i] = lsrepdb;
  2531. }
  2532. lsrp.ReportData = lsrepdba;
  2533. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2534. }
  2535. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2536. {
  2537. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2538. scriptRunningReply.Script.ObjectID = objectID;
  2539. scriptRunningReply.Script.ItemID = itemID;
  2540. scriptRunningReply.Script.Running = running;
  2541. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2542. }
  2543. public void SendAsset(AssetRequestToClient req)
  2544. {
  2545. if (req.AssetInf.Data == null)
  2546. {
  2547. m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
  2548. LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2549. return;
  2550. }
  2551. //m_log.Debug("sending asset " + req.RequestAssetID);
  2552. TransferInfoPacket Transfer = new TransferInfoPacket();
  2553. Transfer.TransferInfo.ChannelType = 2;
  2554. Transfer.TransferInfo.Status = 0;
  2555. Transfer.TransferInfo.TargetType = 0;
  2556. if (req.AssetRequestSource == 2)
  2557. {
  2558. Transfer.TransferInfo.Params = new byte[20];
  2559. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2560. int assType = req.AssetInf.Type;
  2561. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2562. }
  2563. else if (req.AssetRequestSource == 3)
  2564. {
  2565. Transfer.TransferInfo.Params = req.Params;
  2566. // Transfer.TransferInfo.Params = new byte[100];
  2567. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2568. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2569. }
  2570. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2571. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2572. Transfer.Header.Zerocoded = true;
  2573. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2574. if (req.NumPackets == 1)
  2575. {
  2576. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2577. TransferPacket.TransferData.Packet = 0;
  2578. TransferPacket.TransferData.ChannelType = 2;
  2579. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2580. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2581. TransferPacket.TransferData.Status = 1;
  2582. TransferPacket.Header.Zerocoded = true;
  2583. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2584. }
  2585. else
  2586. {
  2587. int processedLength = 0;
  2588. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2589. int packetNumber = 0;
  2590. while (processedLength < req.AssetInf.Data.Length)
  2591. {
  2592. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2593. TransferPacket.TransferData.Packet = packetNumber;
  2594. TransferPacket.TransferData.ChannelType = 2;
  2595. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2596. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2597. byte[] chunk = new byte[chunkSize];
  2598. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2599. TransferPacket.TransferData.Data = chunk;
  2600. // 0 indicates more packets to come, 1 indicates last packet
  2601. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2602. {
  2603. TransferPacket.TransferData.Status = 0;
  2604. }
  2605. else
  2606. {
  2607. TransferPacket.TransferData.Status = 1;
  2608. }
  2609. TransferPacket.Header.Zerocoded = true;
  2610. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2611. processedLength += chunkSize;
  2612. packetNumber++;
  2613. }
  2614. }
  2615. }
  2616. public void SendAssetNotFound(AssetRequestToClient req)
  2617. {
  2618. TransferInfoPacket Transfer = new TransferInfoPacket();
  2619. Transfer.TransferInfo.ChannelType = 2;
  2620. Transfer.TransferInfo.Status = -2;
  2621. Transfer.TransferInfo.TargetType = 0;
  2622. Transfer.TransferInfo.Params = req.Params;
  2623. Transfer.TransferInfo.Size = 0;
  2624. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2625. Transfer.Header.Zerocoded = true;
  2626. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2627. }
  2628. public void SendTexture(AssetBase TextureAsset)
  2629. {
  2630. }
  2631. public void SendRegionHandle(UUID regionID, ulong handle)
  2632. {
  2633. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2634. reply.ReplyBlock.RegionID = regionID;
  2635. reply.ReplyBlock.RegionHandle = handle;
  2636. OutPacket(reply, ThrottleOutPacketType.Land);
  2637. }
  2638. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2639. {
  2640. float dwell = 0.0f;
  2641. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2642. if (dwellModule != null)
  2643. dwell = dwellModule.GetDwell(land.GlobalID);
  2644. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2645. reply.AgentData.AgentID = m_agentId;
  2646. reply.Data.ParcelID = parcelID;
  2647. reply.Data.OwnerID = land.OwnerID;
  2648. reply.Data.Name = Utils.StringToBytes(land.Name);
  2649. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2650. reply.Data.ActualArea = land.Area;
  2651. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2652. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2653. reply.Data.Flags = (byte)(
  2654. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2655. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2656. Vector3 pos = land.UserLocation;
  2657. if (pos.Equals(Vector3.Zero))
  2658. {
  2659. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2660. }
  2661. reply.Data.GlobalX = info.RegionLocX + x;
  2662. reply.Data.GlobalY = info.RegionLocY + y;
  2663. reply.Data.GlobalZ = pos.Z;
  2664. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2665. reply.Data.SnapshotID = land.SnapshotID;
  2666. reply.Data.Dwell = dwell;
  2667. reply.Data.SalePrice = land.SalePrice;
  2668. reply.Data.AuctionID = (int)land.AuctionID;
  2669. OutPacket(reply, ThrottleOutPacketType.Land);
  2670. }
  2671. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2672. {
  2673. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2674. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2675. packet.Data.SimName = Utils.StringToBytes(simName);
  2676. packet.Data.SimPosition = pos;
  2677. packet.Data.LookAt = lookAt;
  2678. OutPacket(packet, ThrottleOutPacketType.Task);
  2679. }
  2680. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2681. {
  2682. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2683. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2684. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2685. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2686. packet.AgentData.AgentID = AgentId;
  2687. packet.QueryData[0].QueryID = queryID;
  2688. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2689. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2690. DirPlacesReplyPacket.StatusDataBlock[] status =
  2691. new DirPlacesReplyPacket.StatusDataBlock[0];
  2692. packet.QueryReplies = replies;
  2693. packet.StatusData = status;
  2694. foreach (DirPlacesReplyData d in data)
  2695. {
  2696. int idx = replies.Length;
  2697. Array.Resize(ref replies, idx + 1);
  2698. Array.Resize(ref status, idx + 1);
  2699. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2700. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2701. replies[idx].ParcelID = d.parcelID;
  2702. replies[idx].Name = Utils.StringToBytes(d.name);
  2703. replies[idx].ForSale = d.forSale;
  2704. replies[idx].Auction = d.auction;
  2705. replies[idx].Dwell = d.dwell;
  2706. status[idx].Status = d.Status;
  2707. packet.QueryReplies = replies;
  2708. packet.StatusData = status;
  2709. if (packet.Length >= 1000)
  2710. {
  2711. OutPacket(packet, ThrottleOutPacketType.Task);
  2712. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2713. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2714. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2715. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2716. packet.AgentData.AgentID = AgentId;
  2717. packet.QueryData[0].QueryID = queryID;
  2718. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2719. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2720. }
  2721. }
  2722. if (replies.Length > 0 || data.Length == 0)
  2723. OutPacket(packet, ThrottleOutPacketType.Task);
  2724. }
  2725. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2726. {
  2727. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2728. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2729. packet.AgentData.AgentID = AgentId;
  2730. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2731. packet.QueryData.QueryID = queryID;
  2732. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2733. data.Length];
  2734. int i = 0;
  2735. foreach (DirPeopleReplyData d in data)
  2736. {
  2737. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2738. packet.QueryReplies[i].AgentID = d.agentID;
  2739. packet.QueryReplies[i].FirstName =
  2740. Utils.StringToBytes(d.firstName);
  2741. packet.QueryReplies[i].LastName =
  2742. Utils.StringToBytes(d.lastName);
  2743. packet.QueryReplies[i].Group =
  2744. Utils.StringToBytes(d.group);
  2745. packet.QueryReplies[i].Online = d.online;
  2746. packet.QueryReplies[i].Reputation = d.reputation;
  2747. i++;
  2748. }
  2749. OutPacket(packet, ThrottleOutPacketType.Task);
  2750. }
  2751. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2752. {
  2753. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2754. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2755. packet.AgentData.AgentID = AgentId;
  2756. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2757. packet.QueryData.QueryID = queryID;
  2758. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2759. data.Length];
  2760. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2761. data.Length];
  2762. int i = 0;
  2763. foreach (DirEventsReplyData d in data)
  2764. {
  2765. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2766. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2767. packet.QueryReplies[i].OwnerID = d.ownerID;
  2768. packet.QueryReplies[i].Name =
  2769. Utils.StringToBytes(d.name);
  2770. packet.QueryReplies[i].EventID = d.eventID;
  2771. packet.QueryReplies[i].Date =
  2772. Utils.StringToBytes(d.date);
  2773. packet.QueryReplies[i].UnixTime = d.unixTime;
  2774. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2775. packet.StatusData[i].Status = d.Status;
  2776. i++;
  2777. }
  2778. OutPacket(packet, ThrottleOutPacketType.Task);
  2779. }
  2780. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2781. {
  2782. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2783. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2784. packet.AgentData.AgentID = AgentId;
  2785. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2786. packet.QueryData.QueryID = queryID;
  2787. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2788. data.Length];
  2789. int i = 0;
  2790. foreach (DirGroupsReplyData d in data)
  2791. {
  2792. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2793. packet.QueryReplies[i].GroupID = d.groupID;
  2794. packet.QueryReplies[i].GroupName =
  2795. Utils.StringToBytes(d.groupName);
  2796. packet.QueryReplies[i].Members = d.members;
  2797. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2798. i++;
  2799. }
  2800. OutPacket(packet, ThrottleOutPacketType.Task);
  2801. }
  2802. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2803. {
  2804. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2805. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2806. packet.AgentData.AgentID = AgentId;
  2807. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2808. packet.QueryData.QueryID = queryID;
  2809. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2810. data.Length];
  2811. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2812. data.Length];
  2813. int i = 0;
  2814. foreach (DirClassifiedReplyData d in data)
  2815. {
  2816. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2817. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2818. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2819. packet.QueryReplies[i].Name =
  2820. Utils.StringToBytes(d.name);
  2821. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2822. packet.QueryReplies[i].CreationDate = d.creationDate;
  2823. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2824. packet.QueryReplies[i].PriceForListing = d.price;
  2825. packet.StatusData[i].Status = d.Status;
  2826. i++;
  2827. }
  2828. OutPacket(packet, ThrottleOutPacketType.Task);
  2829. }
  2830. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2831. {
  2832. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2833. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2834. packet.AgentData.AgentID = AgentId;
  2835. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2836. packet.QueryData.QueryID = queryID;
  2837. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2838. data.Length];
  2839. int i = 0;
  2840. foreach (DirLandReplyData d in data)
  2841. {
  2842. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2843. packet.QueryReplies[i].ParcelID = d.parcelID;
  2844. packet.QueryReplies[i].Name =
  2845. Utils.StringToBytes(d.name);
  2846. packet.QueryReplies[i].Auction = d.auction;
  2847. packet.QueryReplies[i].ForSale = d.forSale;
  2848. packet.QueryReplies[i].SalePrice = d.salePrice;
  2849. packet.QueryReplies[i].ActualArea = d.actualArea;
  2850. i++;
  2851. }
  2852. OutPacket(packet, ThrottleOutPacketType.Task);
  2853. }
  2854. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2855. {
  2856. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2857. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2858. packet.AgentData.AgentID = AgentId;
  2859. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2860. packet.QueryData.QueryID = queryID;
  2861. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2862. data.Length];
  2863. int i = 0;
  2864. foreach (DirPopularReplyData d in data)
  2865. {
  2866. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2867. packet.QueryReplies[i].ParcelID = d.parcelID;
  2868. packet.QueryReplies[i].Name =
  2869. Utils.StringToBytes(d.name);
  2870. packet.QueryReplies[i].Dwell = d.dwell;
  2871. i++;
  2872. }
  2873. OutPacket(packet, ThrottleOutPacketType.Task);
  2874. }
  2875. public void SendEventInfoReply(EventData data)
  2876. {
  2877. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2878. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2879. packet.AgentData.AgentID = AgentId;
  2880. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2881. packet.EventData.EventID = data.eventID;
  2882. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2883. packet.EventData.Name = Utils.StringToBytes(data.name);
  2884. packet.EventData.Category = Utils.StringToBytes(data.category);
  2885. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2886. packet.EventData.Date = Utils.StringToBytes(data.date);
  2887. packet.EventData.DateUTC = data.dateUTC;
  2888. packet.EventData.Duration = data.duration;
  2889. packet.EventData.Cover = data.cover;
  2890. packet.EventData.Amount = data.amount;
  2891. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2892. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2893. packet.EventData.EventFlags = data.eventFlags;
  2894. OutPacket(packet, ThrottleOutPacketType.Task);
  2895. }
  2896. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2897. {
  2898. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2899. mirplk.AgentData.AgentID = AgentId;
  2900. mirplk.RequestData.ItemType = mapitemtype;
  2901. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2902. for (int i = 0; i < replies.Length; i++)
  2903. {
  2904. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2905. mrdata.X = replies[i].x;
  2906. mrdata.Y = replies[i].y;
  2907. mrdata.ID = replies[i].id;
  2908. mrdata.Extra = replies[i].Extra;
  2909. mrdata.Extra2 = replies[i].Extra2;
  2910. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2911. mirplk.Data[i] = mrdata;
  2912. }
  2913. //m_log.Debug(mirplk.ToString());
  2914. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2915. }
  2916. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2917. {
  2918. // a bit special, as this uses AgentID to store the source instead
  2919. // of the destination. The destination (the receiver) goes into destID
  2920. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2921. p.AgentData.AgentID = srcID;
  2922. p.AgentData.SessionID = UUID.Zero;
  2923. p.AgentBlock.DestID = AgentId;
  2924. p.AgentBlock.TransactionID = transactionID;
  2925. OutPacket(p, ThrottleOutPacketType.Task);
  2926. }
  2927. public void SendAcceptCallingCard(UUID transactionID)
  2928. {
  2929. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2930. p.AgentData.AgentID = AgentId;
  2931. p.AgentData.SessionID = UUID.Zero;
  2932. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2933. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2934. p.FolderData[0].FolderID = UUID.Zero;
  2935. OutPacket(p, ThrottleOutPacketType.Task);
  2936. }
  2937. public void SendDeclineCallingCard(UUID transactionID)
  2938. {
  2939. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2940. p.AgentData.AgentID = AgentId;
  2941. p.AgentData.SessionID = UUID.Zero;
  2942. p.TransactionBlock.TransactionID = transactionID;
  2943. OutPacket(p, ThrottleOutPacketType.Task);
  2944. }
  2945. public void SendTerminateFriend(UUID exFriendID)
  2946. {
  2947. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2948. p.AgentData.AgentID = AgentId;
  2949. p.AgentData.SessionID = SessionId;
  2950. p.ExBlock.OtherID = exFriendID;
  2951. OutPacket(p, ThrottleOutPacketType.Task);
  2952. }
  2953. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2954. {
  2955. OSDMap llsd = new OSDMap(3);
  2956. OSDArray AgentData = new OSDArray(1);
  2957. OSDMap AgentDataMap = new OSDMap(1);
  2958. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2959. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2960. AgentData.Add(AgentDataMap);
  2961. llsd.Add("AgentData", AgentData);
  2962. OSDArray GroupData = new OSDArray(data.Length);
  2963. OSDArray NewGroupData = new OSDArray(data.Length);
  2964. foreach (GroupMembershipData m in data)
  2965. {
  2966. OSDMap GroupDataMap = new OSDMap(6);
  2967. OSDMap NewGroupDataMap = new OSDMap(1);
  2968. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2969. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2970. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2971. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2972. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2973. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2974. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2975. GroupData.Add(GroupDataMap);
  2976. NewGroupData.Add(NewGroupDataMap);
  2977. }
  2978. llsd.Add("GroupData", GroupData);
  2979. llsd.Add("NewGroupData", NewGroupData);
  2980. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2981. if (eq != null)
  2982. {
  2983. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2984. }
  2985. }
  2986. public void SendJoinGroupReply(UUID groupID, bool success)
  2987. {
  2988. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2989. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2990. p.AgentData.AgentID = AgentId;
  2991. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2992. p.GroupData.GroupID = groupID;
  2993. p.GroupData.Success = success;
  2994. OutPacket(p, ThrottleOutPacketType.Task);
  2995. }
  2996. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2997. {
  2998. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2999. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  3000. p.AgentData.AgentID = agentID;
  3001. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  3002. p.GroupData.GroupID = groupID;
  3003. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  3004. p.EjectData.Success = success;
  3005. OutPacket(p, ThrottleOutPacketType.Task);
  3006. }
  3007. public void SendLeaveGroupReply(UUID groupID, bool success)
  3008. {
  3009. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  3010. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  3011. p.AgentData.AgentID = AgentId;
  3012. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  3013. p.GroupData.GroupID = groupID;
  3014. p.GroupData.Success = success;
  3015. OutPacket(p, ThrottleOutPacketType.Task);
  3016. }
  3017. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  3018. {
  3019. if (classifiedID.Length != name.Length)
  3020. return;
  3021. AvatarClassifiedReplyPacket ac =
  3022. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3023. PacketType.AvatarClassifiedReply);
  3024. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3025. ac.AgentData.AgentID = AgentId;
  3026. ac.AgentData.TargetID = targetID;
  3027. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  3028. int i;
  3029. for (i = 0; i < classifiedID.Length; i++)
  3030. {
  3031. ac.Data[i].ClassifiedID = classifiedID[i];
  3032. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  3033. }
  3034. OutPacket(ac, ThrottleOutPacketType.Task);
  3035. }
  3036. 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)
  3037. {
  3038. ClassifiedInfoReplyPacket cr =
  3039. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  3040. PacketType.ClassifiedInfoReply);
  3041. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  3042. cr.AgentData.AgentID = AgentId;
  3043. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  3044. cr.Data.ClassifiedID = classifiedID;
  3045. cr.Data.CreatorID = creatorID;
  3046. cr.Data.CreationDate = creationDate;
  3047. cr.Data.ExpirationDate = expirationDate;
  3048. cr.Data.Category = category;
  3049. cr.Data.Name = Utils.StringToBytes(name);
  3050. cr.Data.Desc = Utils.StringToBytes(description);
  3051. cr.Data.ParcelID = parcelID;
  3052. cr.Data.ParentEstate = parentEstate;
  3053. cr.Data.SnapshotID = snapshotID;
  3054. cr.Data.SimName = Utils.StringToBytes(simName);
  3055. cr.Data.PosGlobal = new Vector3d(globalPos);
  3056. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  3057. cr.Data.ClassifiedFlags = classifiedFlags;
  3058. cr.Data.PriceForListing = price;
  3059. OutPacket(cr, ThrottleOutPacketType.Task);
  3060. }
  3061. public void SendAgentDropGroup(UUID groupID)
  3062. {
  3063. AgentDropGroupPacket dg =
  3064. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  3065. PacketType.AgentDropGroup);
  3066. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  3067. dg.AgentData.AgentID = AgentId;
  3068. dg.AgentData.GroupID = groupID;
  3069. OutPacket(dg, ThrottleOutPacketType.Task);
  3070. }
  3071. public void SendAvatarNotesReply(UUID targetID, string text)
  3072. {
  3073. AvatarNotesReplyPacket an =
  3074. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  3075. PacketType.AvatarNotesReply);
  3076. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  3077. an.AgentData.AgentID = AgentId;
  3078. an.Data = new AvatarNotesReplyPacket.DataBlock();
  3079. an.Data.TargetID = targetID;
  3080. an.Data.Notes = Utils.StringToBytes(text);
  3081. OutPacket(an, ThrottleOutPacketType.Task);
  3082. }
  3083. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  3084. {
  3085. AvatarPicksReplyPacket ap =
  3086. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  3087. PacketType.AvatarPicksReply);
  3088. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  3089. ap.AgentData.AgentID = AgentId;
  3090. ap.AgentData.TargetID = targetID;
  3091. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  3092. int i = 0;
  3093. foreach (KeyValuePair<UUID, string> pick in picks)
  3094. {
  3095. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  3096. ap.Data[i].PickID = pick.Key;
  3097. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  3098. i++;
  3099. }
  3100. OutPacket(ap, ThrottleOutPacketType.Task);
  3101. }
  3102. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  3103. {
  3104. AvatarClassifiedReplyPacket ac =
  3105. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3106. PacketType.AvatarClassifiedReply);
  3107. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3108. ac.AgentData.AgentID = AgentId;
  3109. ac.AgentData.TargetID = targetID;
  3110. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3111. int i = 0;
  3112. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3113. {
  3114. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3115. ac.Data[i].ClassifiedID = classified.Key;
  3116. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3117. i++;
  3118. }
  3119. OutPacket(ac, ThrottleOutPacketType.Task);
  3120. }
  3121. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3122. {
  3123. ParcelDwellReplyPacket pd =
  3124. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3125. PacketType.ParcelDwellReply);
  3126. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3127. pd.AgentData.AgentID = AgentId;
  3128. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3129. pd.Data.LocalID = localID;
  3130. pd.Data.ParcelID = parcelID;
  3131. pd.Data.Dwell = dwell;
  3132. OutPacket(pd, ThrottleOutPacketType.Land);
  3133. }
  3134. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3135. {
  3136. UserInfoReplyPacket ur =
  3137. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3138. PacketType.UserInfoReply);
  3139. string Visible = "hidden";
  3140. if (visible)
  3141. Visible = "default";
  3142. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3143. ur.AgentData.AgentID = AgentId;
  3144. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3145. ur.UserData.IMViaEMail = imViaEmail;
  3146. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3147. ur.UserData.EMail = Utils.StringToBytes(email);
  3148. OutPacket(ur, ThrottleOutPacketType.Task);
  3149. }
  3150. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3151. {
  3152. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3153. createGroupReply.AgentData =
  3154. new CreateGroupReplyPacket.AgentDataBlock();
  3155. createGroupReply.ReplyData =
  3156. new CreateGroupReplyPacket.ReplyDataBlock();
  3157. createGroupReply.AgentData.AgentID = AgentId;
  3158. createGroupReply.ReplyData.GroupID = groupID;
  3159. createGroupReply.ReplyData.Success = success;
  3160. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3161. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3162. }
  3163. public void SendUseCachedMuteList()
  3164. {
  3165. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3166. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3167. useCachedMuteList.AgentData.AgentID = AgentId;
  3168. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3169. }
  3170. public void SendMuteListUpdate(string filename)
  3171. {
  3172. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3173. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3174. muteListUpdate.MuteData.AgentID = AgentId;
  3175. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3176. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3177. }
  3178. 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)
  3179. {
  3180. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3181. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3182. pickInfoReply.AgentData.AgentID = AgentId;
  3183. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3184. pickInfoReply.Data.PickID = pickID;
  3185. pickInfoReply.Data.CreatorID = creatorID;
  3186. pickInfoReply.Data.TopPick = topPick;
  3187. pickInfoReply.Data.ParcelID = parcelID;
  3188. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3189. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3190. pickInfoReply.Data.SnapshotID = snapshotID;
  3191. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3192. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3193. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3194. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3195. pickInfoReply.Data.SortOrder = sortOrder;
  3196. pickInfoReply.Data.Enabled = enabled;
  3197. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3198. }
  3199. #endregion Scene/Avatar to Client
  3200. // Gesture
  3201. #region Appearance/ Wearables Methods
  3202. public void SendWearables(AvatarWearable[] wearables, int serial)
  3203. {
  3204. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3205. aw.AgentData.AgentID = AgentId;
  3206. aw.AgentData.SerialNum = (uint)serial;
  3207. aw.AgentData.SessionID = m_sessionId;
  3208. int count = 0;
  3209. for (int i = 0; i < wearables.Length; i++)
  3210. count += wearables[i].Count;
  3211. // TODO: don't create new blocks if recycling an old packet
  3212. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3213. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3214. int idx = 0;
  3215. for (int i = 0; i < wearables.Length; i++)
  3216. {
  3217. for (int j = 0; j < wearables[i].Count; j++)
  3218. {
  3219. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3220. awb.WearableType = (byte)i;
  3221. awb.AssetID = wearables[i][j].AssetID;
  3222. awb.ItemID = wearables[i][j].ItemID;
  3223. aw.WearableData[idx] = awb;
  3224. idx++;
  3225. // m_log.DebugFormat(
  3226. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3227. // awb.ItemID, awb.AssetID, i, Name);
  3228. }
  3229. }
  3230. OutPacket(aw, ThrottleOutPacketType.Task);
  3231. }
  3232. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3233. {
  3234. // m_log.DebugFormat(
  3235. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3236. // agentID, textureEntry.Length, Name, AgentId);
  3237. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3238. // TODO: don't create new blocks if recycling an old packet
  3239. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
  3240. avp.ObjectData.TextureEntry = textureEntry;
  3241. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3242. for (int i = 0; i < visualParams.Length; i++)
  3243. {
  3244. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3245. avblock.ParamValue = visualParams[i];
  3246. avp.VisualParam[i] = avblock;
  3247. }
  3248. avp.Sender.IsTrial = false;
  3249. avp.Sender.ID = agentID;
  3250. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3251. avp.AppearanceHover = new AvatarAppearancePacket.AppearanceHoverBlock[0];
  3252. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3253. OutPacket(avp, ThrottleOutPacketType.Task);
  3254. }
  3255. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3256. {
  3257. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3258. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3259. // TODO: don't create new blocks if recycling an old packet
  3260. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3261. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3262. ani.Sender.ID = sourceAgentId;
  3263. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3264. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3265. for (int i = 0; i < animations.Length; ++i)
  3266. {
  3267. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3268. ani.AnimationList[i].AnimID = animations[i];
  3269. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3270. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3271. if (objectIDs[i].Equals(sourceAgentId))
  3272. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3273. else
  3274. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3275. }
  3276. ani.Header.Reliable = false;
  3277. OutPacket(ani, ThrottleOutPacketType.Task);
  3278. }
  3279. #endregion
  3280. #region Avatar Packet/Data Sending Methods
  3281. /// <summary>
  3282. /// Send an ObjectUpdate packet with information about an avatar
  3283. /// </summary>
  3284. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3285. {
  3286. // m_log.DebugFormat(
  3287. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3288. // avatar.Name, avatar.UUID, Name, AgentId);
  3289. ScenePresence presence = avatar as ScenePresence;
  3290. if (presence == null)
  3291. return;
  3292. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3293. objupdate.Header.Zerocoded = true;
  3294. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3295. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3296. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3297. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3298. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3299. // We need to record the avatar local id since the root prim of an attachment points to this.
  3300. // m_attachmentsSent.Add(avatar.LocalId);
  3301. }
  3302. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3303. {
  3304. // We don't need to update inactive clients.
  3305. if (!IsActive)
  3306. return;
  3307. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3308. loc.Header.Reliable = false;
  3309. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3310. // a CoarseLocationUpdate packet is received. Oh well.
  3311. int total = Math.Min(CoarseLocations.Count, 60);
  3312. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3313. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3314. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3315. int selfindex = -1;
  3316. for (int i = 0; i < total; i++)
  3317. {
  3318. CoarseLocationUpdatePacket.LocationBlock lb =
  3319. new CoarseLocationUpdatePacket.LocationBlock();
  3320. lb.X = (byte)CoarseLocations[i].X;
  3321. lb.Y = (byte)CoarseLocations[i].Y;
  3322. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3323. loc.Location[i] = lb;
  3324. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3325. loc.AgentData[i].AgentID = users[i];
  3326. if (users[i] == AgentId)
  3327. selfindex = i;
  3328. }
  3329. ib.You = (short)selfindex;
  3330. ib.Prey = -1;
  3331. loc.Index = ib;
  3332. OutPacket(loc, ThrottleOutPacketType.Task);
  3333. }
  3334. #endregion Avatar Packet/Data Sending Methods
  3335. #region Primitive Packet/Data Sending Methods
  3336. /// <summary>
  3337. /// Generate one of the object update packets based on PrimUpdateFlags
  3338. /// and broadcast the packet to clients
  3339. /// </summary>
  3340. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3341. {
  3342. if (entity.UUID == m_agentId && !updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3343. {
  3344. ImprovedTerseObjectUpdatePacket packet
  3345. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3346. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3347. packet.RegionData.TimeDilation = Utils.FloatToUInt16(1, 0.0f, 1.0f);
  3348. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  3349. packet.ObjectData[0] = CreateImprovedTerseBlock(entity, false);
  3350. OutPacket(packet, ThrottleOutPacketType.Unknown, true);
  3351. }
  3352. else
  3353. {
  3354. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3355. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3356. lock (m_entityUpdates.SyncRoot)
  3357. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3358. }
  3359. }
  3360. /// <summary>
  3361. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3362. /// We will update the priority and put it in the correct queue, merging update flags
  3363. /// with any other updates that may be queued for the same entity.
  3364. /// The original update time is used for the merged update.
  3365. /// </summary>
  3366. private void ResendPrimUpdate(EntityUpdate update)
  3367. {
  3368. // If the update exists in priority queue, it will be updated.
  3369. // If it does not exist then it will be added with the current (rather than its original) priority
  3370. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3371. lock (m_entityUpdates.SyncRoot)
  3372. m_entityUpdates.Enqueue(priority, update);
  3373. }
  3374. /// <summary>
  3375. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3376. /// We will update the priority and put it in the correct queue, merging update flags
  3377. /// with any other updates that may be queued for the same entity.
  3378. /// The original update time is used for the merged update.
  3379. /// </summary>
  3380. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3381. {
  3382. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3383. // Remove the update packet from the list of packets waiting for acknowledgement
  3384. // because we are requeuing the list of updates. They will be resent in new packets
  3385. // with the most recent state and priority.
  3386. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3387. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3388. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3389. // We're not going to worry about interlock yet since its not currently critical that this total count
  3390. // is 100% correct
  3391. m_udpServer.PacketsResentCount++;
  3392. foreach (EntityUpdate update in updates)
  3393. ResendPrimUpdate(update);
  3394. }
  3395. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3396. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3397. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3398. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3399. //
  3400. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3401. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3402. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3403. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3404. private void ProcessEntityUpdates(int maxUpdates)
  3405. {
  3406. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3407. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3408. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3409. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3410. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3411. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3412. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3413. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3414. // objectUpdateBlocks.Value.Clear();
  3415. // compressedUpdateBlocks.Value.Clear();
  3416. // terseUpdateBlocks.Value.Clear();
  3417. // terseAgentUpdateBlocks.Value.Clear();
  3418. // objectUpdates.Value.Clear();
  3419. // compressedUpdates.Value.Clear();
  3420. // terseUpdates.Value.Clear();
  3421. // terseAgentUpdates.Value.Clear();
  3422. // Check to see if this is a flush
  3423. if (maxUpdates <= 0)
  3424. {
  3425. maxUpdates = Int32.MaxValue;
  3426. }
  3427. int updatesThisCall = 0;
  3428. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3429. // condition where a kill can be processed before an out-of-date update for the same object.
  3430. lock (m_killRecord)
  3431. {
  3432. float avgTimeDilation = 1.0f;
  3433. IEntityUpdate iupdate;
  3434. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3435. while (updatesThisCall < maxUpdates)
  3436. {
  3437. lock (m_entityUpdates.SyncRoot)
  3438. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3439. break;
  3440. EntityUpdate update = (EntityUpdate)iupdate;
  3441. avgTimeDilation += update.TimeDilation;
  3442. avgTimeDilation *= 0.5f;
  3443. if (update.Entity is SceneObjectPart)
  3444. {
  3445. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3446. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3447. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3448. // safety measure.
  3449. //
  3450. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3451. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3452. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3453. //
  3454. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3455. // after the root prim has been deleted.
  3456. if (m_killRecord.Contains(part.LocalId))
  3457. {
  3458. // m_log.WarnFormat(
  3459. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3460. // part.LocalId, Name);
  3461. continue;
  3462. }
  3463. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3464. {
  3465. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3466. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3467. {
  3468. part.Shape.LightEntry = false;
  3469. }
  3470. }
  3471. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3472. {
  3473. // Ensure that mesh has at least 8 valid faces
  3474. part.Shape.ProfileBegin = 12500;
  3475. part.Shape.ProfileEnd = 0;
  3476. part.Shape.ProfileHollow = 27500;
  3477. }
  3478. }
  3479. #region UpdateFlags to packet type conversion
  3480. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3481. bool canUseCompressed = true;
  3482. bool canUseImproved = true;
  3483. // Compressed object updates only make sense for LL primitives
  3484. if (!(update.Entity is SceneObjectPart))
  3485. {
  3486. canUseCompressed = false;
  3487. }
  3488. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3489. {
  3490. canUseCompressed = false;
  3491. canUseImproved = false;
  3492. }
  3493. else
  3494. {
  3495. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3496. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3497. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3498. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3499. {
  3500. canUseCompressed = false;
  3501. }
  3502. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3503. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3504. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3505. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3506. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3507. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3508. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3509. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3510. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3511. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3512. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3513. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3514. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3515. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3516. {
  3517. canUseImproved = false;
  3518. }
  3519. }
  3520. #endregion UpdateFlags to packet type conversion
  3521. #region Block Construction
  3522. // TODO: Remove this once we can build compressed updates
  3523. canUseCompressed = false;
  3524. if (!canUseImproved && !canUseCompressed)
  3525. {
  3526. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3527. if (update.Entity is ScenePresence)
  3528. {
  3529. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3530. }
  3531. else
  3532. {
  3533. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3534. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3535. // If the part has become a private hud since the update was scheduled then we do not
  3536. // want to send it to other avatars.
  3537. if (part.ParentGroup.IsAttachment
  3538. && part.ParentGroup.HasPrivateAttachmentPoint
  3539. && part.ParentGroup.AttachedAvatar != AgentId)
  3540. continue;
  3541. // If the part has since been deleted, then drop the update. In the case of attachments,
  3542. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3543. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3544. // of the test above).
  3545. //
  3546. // Actual deletions (kills) happen in another method.
  3547. if (part.ParentGroup.IsDeleted)
  3548. continue;
  3549. }
  3550. objectUpdateBlocks.Value.Add(updateBlock);
  3551. objectUpdates.Value.Add(update);
  3552. }
  3553. else if (!canUseImproved)
  3554. {
  3555. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3556. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3557. = CreateCompressedUpdateBlock(part, updateFlags);
  3558. // If the part has since been deleted, then drop the update. In the case of attachments,
  3559. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3560. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3561. // of the test above).
  3562. //
  3563. // Actual deletions (kills) happen in another method.
  3564. if (part.ParentGroup.IsDeleted)
  3565. continue;
  3566. compressedUpdateBlocks.Value.Add(compressedBlock);
  3567. compressedUpdates.Value.Add(update);
  3568. }
  3569. else
  3570. {
  3571. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3572. {
  3573. // Self updates go into a special list
  3574. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3575. terseAgentUpdates.Value.Add(update);
  3576. }
  3577. else
  3578. {
  3579. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3580. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3581. // Everything else goes here
  3582. if (update.Entity is SceneObjectPart)
  3583. {
  3584. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3585. // If the part has become a private hud since the update was scheduled then we do not
  3586. // want to send it to other avatars.
  3587. if (part.ParentGroup.IsAttachment
  3588. && part.ParentGroup.HasPrivateAttachmentPoint
  3589. && part.ParentGroup.AttachedAvatar != AgentId)
  3590. continue;
  3591. // If the part has since been deleted, then drop the update. In the case of attachments,
  3592. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3593. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3594. // of the test above).
  3595. //
  3596. // Actual deletions (kills) happen in another method.
  3597. if (part.ParentGroup.IsDeleted)
  3598. continue;
  3599. }
  3600. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3601. terseUpdates.Value.Add(update);
  3602. }
  3603. }
  3604. ++updatesThisCall;
  3605. #endregion Block Construction
  3606. }
  3607. #region Packet Sending
  3608. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3609. if (terseAgentUpdateBlocks.IsValueCreated)
  3610. {
  3611. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3612. ImprovedTerseObjectUpdatePacket packet
  3613. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3614. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3615. packet.RegionData.TimeDilation = timeDilation;
  3616. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3617. for (int i = 0; i < blocks.Count; i++)
  3618. packet.ObjectData[i] = blocks[i];
  3619. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3620. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3621. }
  3622. if (objectUpdateBlocks.IsValueCreated)
  3623. {
  3624. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3625. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3626. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3627. packet.RegionData.TimeDilation = timeDilation;
  3628. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3629. for (int i = 0; i < blocks.Count; i++)
  3630. packet.ObjectData[i] = blocks[i];
  3631. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3632. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3633. }
  3634. if (compressedUpdateBlocks.IsValueCreated)
  3635. {
  3636. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3637. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3638. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3639. packet.RegionData.TimeDilation = timeDilation;
  3640. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3641. for (int i = 0; i < blocks.Count; i++)
  3642. packet.ObjectData[i] = blocks[i];
  3643. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3644. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3645. }
  3646. if (terseUpdateBlocks.IsValueCreated)
  3647. {
  3648. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3649. ImprovedTerseObjectUpdatePacket packet
  3650. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3651. PacketType.ImprovedTerseObjectUpdate);
  3652. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3653. packet.RegionData.TimeDilation = timeDilation;
  3654. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3655. for (int i = 0; i < blocks.Count; i++)
  3656. packet.ObjectData[i] = blocks[i];
  3657. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3658. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3659. }
  3660. }
  3661. // m_log.DebugFormat(
  3662. // "[LLCLIENTVIEW]: Sent {0} updates in ProcessEntityUpdates() for {1} {2} in {3}",
  3663. // updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name);
  3664. //
  3665. #endregion Packet Sending
  3666. }
  3667. public void ReprioritizeUpdates()
  3668. {
  3669. lock (m_entityUpdates.SyncRoot)
  3670. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3671. }
  3672. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3673. {
  3674. if (entity != null)
  3675. {
  3676. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3677. return true;
  3678. }
  3679. return false;
  3680. }
  3681. public void FlushPrimUpdates()
  3682. {
  3683. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3684. while (m_entityUpdates.Count > 0)
  3685. ProcessEntityUpdates(-1);
  3686. }
  3687. #endregion Primitive Packet/Data Sending Methods
  3688. // These are used to implement an adaptive backoff in the number
  3689. // of updates converted to packets. Since we don't want packets
  3690. // to sit in the queue with old data, only convert enough updates
  3691. // to packets that can be sent in 200ms.
  3692. private Int32 m_LastQueueFill = 0;
  3693. private Int32 m_maxUpdates = 0;
  3694. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3695. {
  3696. // if (!m_udpServer.IsRunningOutbound)
  3697. // return;
  3698. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3699. {
  3700. // if (!m_udpServer.IsRunningOutbound)
  3701. // return;
  3702. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3703. {
  3704. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3705. }
  3706. else
  3707. {
  3708. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3709. m_maxUpdates += 5;
  3710. else
  3711. m_maxUpdates = m_maxUpdates >> 1;
  3712. }
  3713. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3714. m_LastQueueFill = Util.EnvironmentTickCount();
  3715. if (m_entityUpdates.Count > 0)
  3716. ProcessEntityUpdates(m_maxUpdates);
  3717. if (m_entityProps.Count > 0)
  3718. ProcessEntityPropertyRequests(m_maxUpdates);
  3719. }
  3720. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3721. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3722. }
  3723. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3724. {
  3725. bool hasUpdates = false;
  3726. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3727. {
  3728. if (m_entityUpdates.Count > 0)
  3729. hasUpdates = true;
  3730. else if (m_entityProps.Count > 0)
  3731. hasUpdates = true;
  3732. }
  3733. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3734. {
  3735. if (ImageManager.HasUpdates())
  3736. hasUpdates = true;
  3737. }
  3738. return hasUpdates;
  3739. }
  3740. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3741. {
  3742. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3743. newPack.AssetBlock.Type = AssetType;
  3744. newPack.AssetBlock.Success = Success;
  3745. newPack.AssetBlock.UUID = AssetFullID;
  3746. newPack.Header.Zerocoded = true;
  3747. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3748. }
  3749. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3750. {
  3751. RequestXferPacket newPack = new RequestXferPacket();
  3752. newPack.XferID.ID = XferID;
  3753. newPack.XferID.VFileType = AssetType;
  3754. newPack.XferID.VFileID = vFileID;
  3755. newPack.XferID.FilePath = FilePath;
  3756. newPack.XferID.Filename = FileName;
  3757. newPack.Header.Zerocoded = true;
  3758. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3759. }
  3760. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3761. {
  3762. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3763. newPack.XferID.ID = xferID;
  3764. newPack.XferID.Packet = PacketID;
  3765. newPack.Header.Zerocoded = true;
  3766. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3767. }
  3768. public void SendInitiateDownload(string simFileName, string clientFileName)
  3769. {
  3770. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3771. newPack.AgentData.AgentID = AgentId;
  3772. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3773. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3774. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3775. }
  3776. public void SendImageFirstPart(
  3777. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3778. {
  3779. ImageDataPacket im = new ImageDataPacket();
  3780. im.Header.Reliable = false;
  3781. im.ImageID.Packets = numParts;
  3782. im.ImageID.ID = ImageUUID;
  3783. if (ImageSize > 0)
  3784. im.ImageID.Size = ImageSize;
  3785. im.ImageData.Data = ImageData;
  3786. im.ImageID.Codec = imageCodec;
  3787. im.Header.Zerocoded = true;
  3788. OutPacket(im, ThrottleOutPacketType.Texture);
  3789. }
  3790. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3791. {
  3792. ImagePacketPacket im = new ImagePacketPacket();
  3793. im.Header.Reliable = false;
  3794. im.ImageID.Packet = partNumber;
  3795. im.ImageID.ID = imageUuid;
  3796. im.ImageData.Data = imageData;
  3797. OutPacket(im, ThrottleOutPacketType.Texture);
  3798. }
  3799. public void SendImageNotFound(UUID imageid)
  3800. {
  3801. ImageNotInDatabasePacket notFoundPacket
  3802. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3803. notFoundPacket.ImageID.ID = imageid;
  3804. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3805. }
  3806. public void SendShutdownConnectionNotice()
  3807. {
  3808. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3809. }
  3810. public void SendSimStats(SimStats stats)
  3811. {
  3812. SimStatsPacket pack = new SimStatsPacket();
  3813. pack.Region = new SimStatsPacket.RegionBlock();
  3814. pack.Region.RegionX = stats.RegionX;
  3815. pack.Region.RegionY = stats.RegionY;
  3816. pack.Region.RegionFlags = stats.RegionFlags;
  3817. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3818. //pack.Region = //stats.RegionBlock;
  3819. pack.Stat = stats.StatsBlock;
  3820. pack.Header.Reliable = false;
  3821. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3822. OutPacket(pack, ThrottleOutPacketType.Task);
  3823. }
  3824. private class ObjectPropertyUpdate : IEntityUpdate
  3825. {
  3826. internal bool SendFamilyProps;
  3827. internal bool SendObjectProps;
  3828. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3829. : base(entity,flags)
  3830. {
  3831. SendFamilyProps = sendfam;
  3832. SendObjectProps = sendobj;
  3833. }
  3834. public void Update(ObjectPropertyUpdate update)
  3835. {
  3836. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3837. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3838. // other properties may need to be updated by base class
  3839. base.Update(update);
  3840. }
  3841. }
  3842. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3843. {
  3844. uint priority = 0; // time based ordering only
  3845. lock (m_entityProps.SyncRoot)
  3846. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3847. }
  3848. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3849. {
  3850. uint priority = 0;
  3851. lock (m_entityProps.SyncRoot)
  3852. m_entityProps.Enqueue(priority, update);
  3853. }
  3854. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3855. {
  3856. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3857. // Remove the update packet from the list of packets waiting for acknowledgement
  3858. // because we are requeuing the list of updates. They will be resent in new packets
  3859. // with the most recent state.
  3860. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3861. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3862. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3863. // We're not going to worry about interlock yet since its not currently critical that this total count
  3864. // is 100% correct
  3865. m_udpServer.PacketsResentCount++;
  3866. foreach (ObjectPropertyUpdate update in updates)
  3867. ResendPropertyUpdate(update);
  3868. }
  3869. public void SendObjectPropertiesReply(ISceneEntity entity)
  3870. {
  3871. uint priority = 0; // time based ordering only
  3872. lock (m_entityProps.SyncRoot)
  3873. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3874. }
  3875. private void ProcessEntityPropertyRequests(int maxUpdates)
  3876. {
  3877. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3878. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3879. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3880. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3881. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3882. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3883. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3884. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3885. IEntityUpdate iupdate;
  3886. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3887. int updatesThisCall = 0;
  3888. while (updatesThisCall < m_maxUpdates)
  3889. {
  3890. lock (m_entityProps.SyncRoot)
  3891. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3892. break;
  3893. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3894. if (update.SendFamilyProps)
  3895. {
  3896. if (update.Entity is SceneObjectPart)
  3897. {
  3898. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3899. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3900. objectFamilyBlocks.Value.Add(objPropDB);
  3901. familyUpdates.Value.Add(update);
  3902. }
  3903. }
  3904. if (update.SendObjectProps)
  3905. {
  3906. if (update.Entity is SceneObjectPart)
  3907. {
  3908. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3909. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3910. objectPropertiesBlocks.Value.Add(objPropDB);
  3911. propertyUpdates.Value.Add(update);
  3912. }
  3913. }
  3914. updatesThisCall++;
  3915. }
  3916. // Int32 ppcnt = 0;
  3917. // Int32 pbcnt = 0;
  3918. if (objectPropertiesBlocks.IsValueCreated)
  3919. {
  3920. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3921. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3922. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3923. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3924. for (int i = 0; i < blocks.Count; i++)
  3925. packet.ObjectData[i] = blocks[i];
  3926. packet.Header.Zerocoded = true;
  3927. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3928. // of the object rather than the properties when the packet was created
  3929. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3930. delegate(OutgoingPacket oPacket)
  3931. {
  3932. ResendPropertyUpdates(updates, oPacket);
  3933. });
  3934. // pbcnt += blocks.Count;
  3935. // ppcnt++;
  3936. }
  3937. // Int32 fpcnt = 0;
  3938. // Int32 fbcnt = 0;
  3939. if (objectFamilyBlocks.IsValueCreated)
  3940. {
  3941. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3942. // one packet per object block... uggh...
  3943. for (int i = 0; i < blocks.Count; i++)
  3944. {
  3945. ObjectPropertiesFamilyPacket packet =
  3946. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3947. packet.ObjectData = blocks[i];
  3948. packet.Header.Zerocoded = true;
  3949. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3950. // of the object rather than the properties when the packet was created
  3951. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3952. updates.Add(familyUpdates.Value[i]);
  3953. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3954. delegate(OutgoingPacket oPacket)
  3955. {
  3956. ResendPropertyUpdates(updates, oPacket);
  3957. });
  3958. // fpcnt++;
  3959. // fbcnt++;
  3960. }
  3961. }
  3962. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3963. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3964. }
  3965. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3966. {
  3967. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3968. block.RequestFlags = requestFlags;
  3969. block.ObjectID = sop.UUID;
  3970. if (sop.OwnerID == sop.GroupID)
  3971. block.OwnerID = UUID.Zero;
  3972. else
  3973. block.OwnerID = sop.OwnerID;
  3974. block.GroupID = sop.GroupID;
  3975. block.BaseMask = sop.BaseMask;
  3976. block.OwnerMask = sop.OwnerMask;
  3977. block.GroupMask = sop.GroupMask;
  3978. block.EveryoneMask = sop.EveryoneMask;
  3979. block.NextOwnerMask = sop.NextOwnerMask;
  3980. // TODO: More properties are needed in SceneObjectPart!
  3981. block.OwnershipCost = sop.OwnershipCost;
  3982. block.SaleType = sop.ObjectSaleType;
  3983. block.SalePrice = sop.SalePrice;
  3984. block.Category = sop.Category;
  3985. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3986. block.Name = Util.StringToBytes256(sop.Name);
  3987. block.Description = Util.StringToBytes256(sop.Description);
  3988. return block;
  3989. }
  3990. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3991. {
  3992. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3993. // TODO: don't create new blocks if recycling an old packet
  3994. ObjectPropertiesPacket.ObjectDataBlock block =
  3995. new ObjectPropertiesPacket.ObjectDataBlock();
  3996. block.ObjectID = sop.UUID;
  3997. block.Name = Util.StringToBytes256(sop.Name);
  3998. block.Description = Util.StringToBytes256(sop.Description);
  3999. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  4000. block.CreatorID = sop.CreatorID;
  4001. block.GroupID = sop.GroupID;
  4002. block.LastOwnerID = sop.LastOwnerID;
  4003. if (sop.OwnerID == sop.GroupID)
  4004. block.OwnerID = UUID.Zero;
  4005. else
  4006. block.OwnerID = sop.OwnerID;
  4007. block.ItemID = sop.FromUserInventoryItemID;
  4008. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  4009. block.FromTaskID = UUID.Zero; // ???
  4010. block.InventorySerial = (short)sop.InventorySerial;
  4011. SceneObjectPart root = sop.ParentGroup.RootPart;
  4012. block.TouchName = Util.StringToBytes256(root.TouchName);
  4013. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  4014. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  4015. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  4016. // using (MemoryStream memStream = new MemoryStream())
  4017. // {
  4018. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  4019. // {
  4020. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  4021. // {
  4022. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  4023. //
  4024. // UUID textureID;
  4025. //
  4026. // if (teFace != null)
  4027. // textureID = teFace.TextureID;
  4028. // else
  4029. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  4030. //
  4031. // binWriter.Write(textureID.GetBytes());
  4032. // }
  4033. //
  4034. // block.TextureID = memStream.ToArray();
  4035. // }
  4036. // }
  4037. block.TextureID = new byte[0]; // TextureID ???
  4038. block.SitName = Util.StringToBytes256(root.SitName);
  4039. block.OwnerMask = root.OwnerMask;
  4040. block.NextOwnerMask = root.NextOwnerMask;
  4041. block.GroupMask = root.GroupMask;
  4042. block.EveryoneMask = root.EveryoneMask;
  4043. block.BaseMask = root.BaseMask;
  4044. block.SaleType = root.ObjectSaleType;
  4045. block.SalePrice = root.SalePrice;
  4046. return block;
  4047. }
  4048. #region Estate Data Sending Methods
  4049. private static bool convertParamStringToBool(byte[] field)
  4050. {
  4051. string s = Utils.BytesToString(field);
  4052. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  4053. {
  4054. return true;
  4055. }
  4056. return false;
  4057. }
  4058. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  4059. {
  4060. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4061. packet.AgentData.TransactionID = UUID.Random();
  4062. packet.AgentData.AgentID = AgentId;
  4063. packet.AgentData.SessionID = SessionId;
  4064. packet.MethodData.Invoice = invoice;
  4065. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  4066. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  4067. for (int i = 0; i < (6 + Data.Length); i++)
  4068. {
  4069. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4070. }
  4071. int j = 0;
  4072. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  4073. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  4074. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4075. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4076. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4077. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4078. j = 2; // Agents
  4079. if ((code & 2) != 0)
  4080. j = 3; // Groups
  4081. if ((code & 8) != 0)
  4082. j = 5; // Managers
  4083. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  4084. j = 6;
  4085. for (int i = 0; i < Data.Length; i++)
  4086. {
  4087. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  4088. }
  4089. packet.ParamList = returnblock;
  4090. packet.Header.Reliable = true;
  4091. OutPacket(packet, ThrottleOutPacketType.Task);
  4092. }
  4093. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  4094. {
  4095. List<UUID> BannedUsers = new List<UUID>();
  4096. for (int i = 0; i < bl.Length; i++)
  4097. {
  4098. if (bl[i] == null)
  4099. continue;
  4100. if (bl[i].BannedUserID == UUID.Zero)
  4101. continue;
  4102. BannedUsers.Add(bl[i].BannedUserID);
  4103. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  4104. {
  4105. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4106. packet.AgentData.TransactionID = UUID.Random();
  4107. packet.AgentData.AgentID = AgentId;
  4108. packet.AgentData.SessionID = SessionId;
  4109. packet.MethodData.Invoice = invoice;
  4110. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  4111. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  4112. int j;
  4113. for (j = 0; j < (6 + BannedUsers.Count); j++)
  4114. {
  4115. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  4116. }
  4117. j = 0;
  4118. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  4119. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  4120. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4121. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4122. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  4123. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4124. foreach (UUID banned in BannedUsers)
  4125. {
  4126. returnblock[j].Parameter = banned.GetBytes(); j++;
  4127. }
  4128. packet.ParamList = returnblock;
  4129. packet.Header.Reliable = true;
  4130. OutPacket(packet, ThrottleOutPacketType.Task);
  4131. BannedUsers.Clear();
  4132. }
  4133. }
  4134. }
  4135. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4136. {
  4137. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4138. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4139. rinfopack.AgentData.AgentID = AgentId;
  4140. rinfopack.AgentData.SessionID = SessionId;
  4141. rinfoblk.BillableFactor = args.billableFactor;
  4142. rinfoblk.EstateID = args.estateID;
  4143. rinfoblk.MaxAgents = args.maxAgents;
  4144. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4145. rinfoblk.ParentEstateID = args.parentEstateID;
  4146. rinfoblk.PricePerMeter = args.pricePerMeter;
  4147. rinfoblk.RedirectGridX = args.redirectGridX;
  4148. rinfoblk.RedirectGridY = args.redirectGridY;
  4149. rinfoblk.RegionFlags = args.regionFlags;
  4150. rinfoblk.SimAccess = args.simAccess;
  4151. rinfoblk.SunHour = args.sunHour;
  4152. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4153. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4154. rinfoblk.UseEstateSun = args.useEstateSun;
  4155. rinfoblk.WaterHeight = args.waterHeight;
  4156. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4157. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4158. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4159. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4160. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4161. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4162. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4163. rinfopack.HasVariableBlocks = true;
  4164. rinfopack.RegionInfo = rinfoblk;
  4165. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4166. rinfopack.AgentData.AgentID = AgentId;
  4167. rinfopack.AgentData.SessionID = SessionId;
  4168. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4169. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4170. }
  4171. public void SendEstateCovenantInformation(UUID covenant)
  4172. {
  4173. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4174. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4175. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4176. edata.CovenantID = covenant;
  4177. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4178. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4179. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4180. einfopack.Data = edata;
  4181. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4182. }
  4183. public void SendDetailedEstateData(
  4184. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4185. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4186. {
  4187. // m_log.DebugFormat(
  4188. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4189. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4190. packet.MethodData.Invoice = invoice;
  4191. packet.AgentData.TransactionID = UUID.Random();
  4192. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4193. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4194. for (int i = 0; i < 10; i++)
  4195. {
  4196. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4197. }
  4198. //Sending Estate Settings
  4199. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4200. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4201. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4202. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4203. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4204. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4205. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4206. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4207. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4208. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4209. packet.ParamList = returnblock;
  4210. packet.Header.Reliable = false;
  4211. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4212. OutPacket(packet, ThrottleOutPacketType.Task);
  4213. }
  4214. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4215. {
  4216. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4217. packet.TelehubBlock.ObjectID = ObjectID;
  4218. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4219. packet.TelehubBlock.TelehubPos = ObjectPos;
  4220. packet.TelehubBlock.TelehubRot = ObjectRot;
  4221. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4222. for (int n = 0; n < SpawnPoint.Count; n++)
  4223. {
  4224. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4225. }
  4226. OutPacket(packet, ThrottleOutPacketType.Task);
  4227. }
  4228. #endregion
  4229. #region Land Data Sending Methods
  4230. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4231. {
  4232. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4233. packet.ParcelData.Data = data;
  4234. packet.ParcelData.SequenceID = sequence_id;
  4235. packet.Header.Zerocoded = true;
  4236. OutPacket(packet, ThrottleOutPacketType.Task);
  4237. }
  4238. public void SendLandProperties(
  4239. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4240. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4241. {
  4242. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4243. LandData landData = lo.LandData;
  4244. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4245. updateMessage.AABBMax = landData.AABBMax;
  4246. updateMessage.AABBMin = landData.AABBMin;
  4247. updateMessage.Area = landData.Area;
  4248. updateMessage.AuctionID = landData.AuctionID;
  4249. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4250. updateMessage.Bitmap = landData.Bitmap;
  4251. updateMessage.Desc = landData.Description;
  4252. updateMessage.Category = landData.Category;
  4253. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4254. updateMessage.ClaimPrice = landData.ClaimPrice;
  4255. updateMessage.GroupID = landData.GroupID;
  4256. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4257. updateMessage.LandingType = (LandingType) landData.LandingType;
  4258. updateMessage.LocalID = landData.LocalID;
  4259. if (landData.Area > 0)
  4260. {
  4261. updateMessage.MaxPrims = parcelObjectCapacity;
  4262. }
  4263. else
  4264. {
  4265. updateMessage.MaxPrims = 0;
  4266. }
  4267. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4268. updateMessage.MediaID = landData.MediaID;
  4269. updateMessage.MediaURL = landData.MediaURL;
  4270. updateMessage.MusicURL = landData.MusicURL;
  4271. updateMessage.Name = landData.Name;
  4272. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4273. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4274. updateMessage.OwnerID = landData.OwnerID;
  4275. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4276. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4277. updateMessage.PassHours = landData.PassHours;
  4278. updateMessage.PassPrice = landData.PassPrice;
  4279. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4280. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4281. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4282. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4283. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4284. updateMessage.RentPrice = 0;
  4285. updateMessage.RequestResult = (ParcelResult) request_result;
  4286. updateMessage.SalePrice = landData.SalePrice;
  4287. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4288. updateMessage.SequenceID = sequence_id;
  4289. if (landData.SimwideArea > 0)
  4290. {
  4291. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4292. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4293. }
  4294. else
  4295. {
  4296. updateMessage.SimWideMaxPrims = 0;
  4297. }
  4298. updateMessage.SnapSelection = snap_selection;
  4299. updateMessage.SnapshotID = landData.SnapshotID;
  4300. updateMessage.Status = (ParcelStatus) landData.Status;
  4301. updateMessage.UserLocation = landData.UserLocation;
  4302. updateMessage.UserLookAt = landData.UserLookAt;
  4303. updateMessage.MediaType = landData.MediaType;
  4304. updateMessage.MediaDesc = landData.MediaDescription;
  4305. updateMessage.MediaWidth = landData.MediaWidth;
  4306. updateMessage.MediaHeight = landData.MediaHeight;
  4307. updateMessage.MediaLoop = landData.MediaLoop;
  4308. updateMessage.ObscureMusic = landData.ObscureMusic;
  4309. updateMessage.ObscureMedia = landData.ObscureMedia;
  4310. IPrimCounts pc = lo.PrimCounts;
  4311. updateMessage.OwnerPrims = pc.Owner;
  4312. updateMessage.GroupPrims = pc.Group;
  4313. updateMessage.OtherPrims = pc.Others;
  4314. updateMessage.SelectedPrims = pc.Selected;
  4315. updateMessage.TotalPrims = pc.Total;
  4316. updateMessage.SimWideTotalPrims = pc.Simulator;
  4317. try
  4318. {
  4319. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4320. if (eq != null)
  4321. {
  4322. eq.ParcelProperties(updateMessage, this.AgentId);
  4323. }
  4324. else
  4325. {
  4326. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4327. }
  4328. }
  4329. catch (Exception ex)
  4330. {
  4331. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4332. }
  4333. }
  4334. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4335. {
  4336. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4337. replyPacket.Data.AgentID = AgentId;
  4338. replyPacket.Data.Flags = accessFlag;
  4339. replyPacket.Data.LocalID = localLandID;
  4340. replyPacket.Data.SequenceID = 0;
  4341. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4342. foreach (LandAccessEntry entry in accessList)
  4343. {
  4344. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4345. block.Flags = accessFlag;
  4346. block.ID = entry.AgentID;
  4347. block.Time = entry.Expires;
  4348. list.Add(block);
  4349. }
  4350. replyPacket.List = list.ToArray();
  4351. replyPacket.Header.Zerocoded = true;
  4352. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4353. }
  4354. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4355. {
  4356. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4357. bool firstCall = true;
  4358. const int MAX_OBJECTS_PER_PACKET = 251;
  4359. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4360. ForceObjectSelectPacket.DataBlock[] data;
  4361. while (ObjectIDs.Count > 0)
  4362. {
  4363. if (firstCall)
  4364. {
  4365. pack._Header.ResetList = true;
  4366. firstCall = false;
  4367. }
  4368. else
  4369. {
  4370. pack._Header.ResetList = false;
  4371. }
  4372. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4373. {
  4374. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4375. }
  4376. else
  4377. {
  4378. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4379. }
  4380. int i;
  4381. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4382. {
  4383. data[i] = new ForceObjectSelectPacket.DataBlock();
  4384. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4385. ObjectIDs.RemoveAt(0);
  4386. }
  4387. pack.Data = data;
  4388. pack.Header.Zerocoded = true;
  4389. OutPacket(pack, ThrottleOutPacketType.Task);
  4390. }
  4391. }
  4392. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4393. {
  4394. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4395. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4396. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4397. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4398. OutPacket(cpack, ThrottleOutPacketType.Task);
  4399. }
  4400. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4401. {
  4402. int notifyCount = ownersAndCount.Count;
  4403. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4404. if (notifyCount > 0)
  4405. {
  4406. if (notifyCount > 32)
  4407. {
  4408. m_log.InfoFormat(
  4409. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4410. + " - a developer might want to investigate whether this is a hard limit", 32);
  4411. notifyCount = 32;
  4412. }
  4413. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4414. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4415. int num = 0;
  4416. foreach (UUID owner in ownersAndCount.Keys)
  4417. {
  4418. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4419. dataBlock[num].Count = ownersAndCount[owner];
  4420. if (land.GroupID == owner || groups.Contains(owner))
  4421. dataBlock[num].IsGroupOwned = true;
  4422. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4423. dataBlock[num].OwnerID = owner;
  4424. num++;
  4425. if (num >= notifyCount)
  4426. {
  4427. break;
  4428. }
  4429. }
  4430. pack.Data = dataBlock;
  4431. }
  4432. else
  4433. {
  4434. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4435. }
  4436. pack.Header.Zerocoded = true;
  4437. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4438. }
  4439. #endregion
  4440. #region Helper Methods
  4441. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4442. {
  4443. #region ScenePresence/SOP Handling
  4444. bool avatar = (entity is ScenePresence);
  4445. uint localID = entity.LocalId;
  4446. uint attachPoint;
  4447. Vector4 collisionPlane;
  4448. Vector3 position, velocity, acceleration, angularVelocity;
  4449. Quaternion rotation;
  4450. byte[] textureEntry;
  4451. if (entity is ScenePresence)
  4452. {
  4453. ScenePresence presence = (ScenePresence)entity;
  4454. // m_log.DebugFormat(
  4455. // "[LLCLIENTVIEW]: Sending terse update to {0} with pos {1}, vel {2} in {3}",
  4456. // Name, presence.OffsetPosition, presence.Velocity, m_scene.Name);
  4457. attachPoint = presence.State;
  4458. collisionPlane = presence.CollisionPlane;
  4459. position = presence.OffsetPosition;
  4460. velocity = presence.Velocity;
  4461. acceleration = Vector3.Zero;
  4462. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4463. // in that direction, even though we don't model this on the server. Implementing this in the future
  4464. // may improve movement smoothness.
  4465. // acceleration = new Vector3(1, 0, 0);
  4466. angularVelocity = presence.AngularVelocity;
  4467. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4468. // it rotates around.
  4469. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4470. // excessive up and down movements of the camera when looking up and down.
  4471. // See http://opensimulator.org/mantis/view.php?id=3274
  4472. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4473. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4474. // the rotation in this case.
  4475. rotation = presence.Rotation;
  4476. if (!presence.IsSatOnObject)
  4477. {
  4478. rotation.X = 0;
  4479. rotation.Y = 0;
  4480. }
  4481. if (sendTexture)
  4482. textureEntry = presence.Appearance.Texture.GetBytes();
  4483. else
  4484. textureEntry = null;
  4485. }
  4486. else
  4487. {
  4488. SceneObjectPart part = (SceneObjectPart)entity;
  4489. attachPoint = part.ParentGroup.AttachmentPoint;
  4490. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4491. // m_log.DebugFormat(
  4492. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4493. // attachPoint, part.Name, part.LocalId, Name);
  4494. collisionPlane = Vector4.Zero;
  4495. position = part.RelativePosition;
  4496. velocity = part.Velocity;
  4497. acceleration = part.Acceleration;
  4498. angularVelocity = part.AngularVelocity;
  4499. rotation = part.RotationOffset;
  4500. if (sendTexture)
  4501. textureEntry = part.Shape.TextureEntry;
  4502. else
  4503. textureEntry = null;
  4504. }
  4505. #endregion ScenePresence/SOP Handling
  4506. int pos = 0;
  4507. byte[] data = new byte[(avatar ? 60 : 44)];
  4508. // LocalID
  4509. Utils.UIntToBytes(localID, data, pos);
  4510. pos += 4;
  4511. // Avatar/CollisionPlane
  4512. data[pos++] = (byte) attachPoint;
  4513. if (avatar)
  4514. {
  4515. data[pos++] = 1;
  4516. if (collisionPlane == Vector4.Zero)
  4517. collisionPlane = Vector4.UnitW;
  4518. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4519. collisionPlane.ToBytes(data, pos);
  4520. pos += 16;
  4521. }
  4522. else
  4523. {
  4524. ++pos;
  4525. }
  4526. // Position
  4527. position.ToBytes(data, pos);
  4528. pos += 12;
  4529. // Velocity
  4530. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4531. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4532. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4533. // Acceleration
  4534. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4535. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4536. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4537. // Rotation
  4538. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4539. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4540. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4541. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4542. // Angular Velocity
  4543. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4544. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4545. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4546. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4547. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4548. block.Data = data;
  4549. if (textureEntry != null && textureEntry.Length > 0)
  4550. {
  4551. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4552. // Texture Length
  4553. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4554. // Texture
  4555. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4556. block.TextureEntry = teBytesFinal;
  4557. }
  4558. else
  4559. {
  4560. block.TextureEntry = Utils.EmptyBytes;
  4561. }
  4562. return block;
  4563. }
  4564. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4565. {
  4566. // m_log.DebugFormat(
  4567. // "[LLCLIENTVIEW]: Sending full update to {0} with pos {1}, vel {2} in {3}", Name, data.OffsetPosition, data.Velocity, m_scene.Name);
  4568. byte[] objectData = new byte[76];
  4569. data.CollisionPlane.ToBytes(objectData, 0);
  4570. data.OffsetPosition.ToBytes(objectData, 16);
  4571. data.Velocity.ToBytes(objectData, 28);
  4572. // data.Acceleration.ToBytes(objectData, 40);
  4573. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4574. // it rotates around.
  4575. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4576. // excessive up and down movements of the camera when looking up and down.
  4577. // See http://opensimulator.org/mantis/view.php?id=3274
  4578. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4579. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4580. // the rotation in this case.
  4581. Quaternion rot = data.Rotation;
  4582. if (!data.IsSatOnObject)
  4583. {
  4584. rot.X = 0;
  4585. rot.Y = 0;
  4586. }
  4587. rot.ToBytes(objectData, 52);
  4588. //data.AngularVelocity.ToBytes(objectData, 64);
  4589. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4590. update.Data = Utils.EmptyBytes;
  4591. update.ExtraParams = new byte[1];
  4592. update.FullID = data.UUID;
  4593. update.ID = data.LocalId;
  4594. update.Material = (byte)Material.Flesh;
  4595. update.MediaURL = Utils.EmptyBytes;
  4596. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4597. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4598. update.ObjectData = objectData;
  4599. SceneObjectPart parentPart = data.ParentPart;
  4600. if (parentPart != null)
  4601. update.ParentID = parentPart.ParentGroup.LocalId;
  4602. else
  4603. update.ParentID = 0;
  4604. update.PathCurve = 16;
  4605. update.PathScaleX = 100;
  4606. update.PathScaleY = 100;
  4607. update.PCode = (byte)PCode.Avatar;
  4608. update.ProfileCurve = 1;
  4609. update.PSBlock = Utils.EmptyBytes;
  4610. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4611. update.Text = Utils.EmptyBytes;
  4612. update.TextColor = new byte[4];
  4613. // Don't send texture anim for avatars - this has no meaning for them.
  4614. update.TextureAnim = Utils.EmptyBytes;
  4615. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4616. update.TextureEntry = Utils.EmptyBytes;
  4617. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4618. update.UpdateFlags = (uint)(
  4619. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4620. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4621. PrimFlags.ObjectOwnerModify);
  4622. return update;
  4623. }
  4624. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4625. {
  4626. byte[] objectData = new byte[60];
  4627. data.RelativePosition.ToBytes(objectData, 0);
  4628. data.Velocity.ToBytes(objectData, 12);
  4629. data.Acceleration.ToBytes(objectData, 24);
  4630. try
  4631. {
  4632. data.RotationOffset.ToBytes(objectData, 36);
  4633. }
  4634. catch (Exception e)
  4635. {
  4636. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4637. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4638. }
  4639. data.AngularVelocity.ToBytes(objectData, 48);
  4640. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4641. update.ClickAction = (byte)data.ClickAction;
  4642. update.CRC = 0;
  4643. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4644. update.FullID = data.UUID;
  4645. update.ID = data.LocalId;
  4646. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4647. //update.JointPivot = Vector3.Zero;
  4648. //update.JointType = 0;
  4649. update.Material = data.Material;
  4650. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4651. if (data.ParentGroup.IsAttachment)
  4652. {
  4653. update.NameValue
  4654. = Util.StringToBytes256(
  4655. string.Format("AttachItemID STRING RW SV {0}", data.ParentGroup.FromItemID));
  4656. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4657. // m_log.DebugFormat(
  4658. // "[LLCLIENTVIEW]: Sending NameValue {0} for {1} {2} to {3}",
  4659. // Util.UTF8.GetString(update.NameValue), data.Name, data.LocalId, Name);
  4660. //
  4661. // m_log.DebugFormat(
  4662. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4663. // update.State, data.Name, data.LocalId, Name);
  4664. }
  4665. else
  4666. {
  4667. update.NameValue = Utils.EmptyBytes;
  4668. // The root part state is the canonical state for all parts of the object. The other part states in the
  4669. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4670. update.State = data.ParentGroup.RootPart.Shape.State;
  4671. }
  4672. update.ObjectData = objectData;
  4673. update.ParentID = data.ParentID;
  4674. update.PathBegin = data.Shape.PathBegin;
  4675. update.PathCurve = data.Shape.PathCurve;
  4676. update.PathEnd = data.Shape.PathEnd;
  4677. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4678. update.PathRevolutions = data.Shape.PathRevolutions;
  4679. update.PathScaleX = data.Shape.PathScaleX;
  4680. update.PathScaleY = data.Shape.PathScaleY;
  4681. update.PathShearX = data.Shape.PathShearX;
  4682. update.PathShearY = data.Shape.PathShearY;
  4683. update.PathSkew = data.Shape.PathSkew;
  4684. update.PathTaperX = data.Shape.PathTaperX;
  4685. update.PathTaperY = data.Shape.PathTaperY;
  4686. update.PathTwist = data.Shape.PathTwist;
  4687. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4688. update.PCode = data.Shape.PCode;
  4689. update.ProfileBegin = data.Shape.ProfileBegin;
  4690. update.ProfileCurve = data.Shape.ProfileCurve;
  4691. update.ProfileEnd = data.Shape.ProfileEnd;
  4692. update.ProfileHollow = data.Shape.ProfileHollow;
  4693. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4694. update.TextColor = data.GetTextColor().GetBytes(false);
  4695. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4696. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4697. update.Scale = data.Shape.Scale;
  4698. update.Text = Util.StringToBytes256(data.Text);
  4699. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4700. #region PrimFlags
  4701. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4702. // Don't send the CreateSelected flag to everyone
  4703. flags &= ~PrimFlags.CreateSelected;
  4704. if (recipientID == data.OwnerID)
  4705. {
  4706. if (data.CreateSelected)
  4707. {
  4708. // Only send this flag once, then unset it
  4709. flags |= PrimFlags.CreateSelected;
  4710. data.CreateSelected = false;
  4711. }
  4712. }
  4713. // m_log.DebugFormat(
  4714. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4715. // data.Name, update.FullID, flags, update.ID);
  4716. update.UpdateFlags = (uint)flags;
  4717. #endregion PrimFlags
  4718. if (data.Sound != UUID.Zero)
  4719. {
  4720. update.Sound = data.Sound;
  4721. update.OwnerID = data.OwnerID;
  4722. update.Gain = (float)data.SoundGain;
  4723. update.Radius = (float)data.SoundRadius;
  4724. update.Flags = data.SoundFlags;
  4725. }
  4726. switch ((PCode)data.Shape.PCode)
  4727. {
  4728. case PCode.Grass:
  4729. case PCode.Tree:
  4730. case PCode.NewTree:
  4731. update.Data = new byte[] { data.Shape.State };
  4732. break;
  4733. default:
  4734. update.Data = Utils.EmptyBytes;
  4735. break;
  4736. }
  4737. return update;
  4738. }
  4739. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4740. {
  4741. // TODO: Implement this
  4742. return null;
  4743. }
  4744. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4745. {
  4746. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4747. // TODO: don't create new blocks if recycling an old packet
  4748. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4749. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4750. packet.UUIDNameBlock[0].ID = profileId;
  4751. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4752. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4753. OutPacket(packet, ThrottleOutPacketType.Task);
  4754. }
  4755. public ulong GetGroupPowers(UUID groupID)
  4756. {
  4757. if (groupID == ActiveGroupId)
  4758. return ActiveGroupPowers;
  4759. if (m_groupPowers.ContainsKey(groupID))
  4760. return m_groupPowers[groupID];
  4761. return 0;
  4762. }
  4763. #endregion
  4764. /// <summary>
  4765. /// This is a different way of processing packets then ProcessInPacket
  4766. /// </summary>
  4767. protected virtual void RegisterLocalPacketHandlers()
  4768. {
  4769. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4770. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4771. // for each AgentUpdate packet.
  4772. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4773. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4774. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4775. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4776. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4777. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4778. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4779. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4780. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage, true, true);
  4781. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest, true, true);
  4782. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4783. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate, true, true);
  4784. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4785. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4786. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4787. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4788. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4789. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4790. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4791. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4792. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4793. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4794. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4795. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4796. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4797. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4798. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4799. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4800. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4801. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4802. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4803. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4804. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4805. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4806. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4807. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4808. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4809. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4810. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4811. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4812. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4813. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4814. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4815. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4816. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4817. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4818. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4819. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4820. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4821. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4822. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4823. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4824. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4825. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4826. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4827. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4828. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4829. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4830. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4831. // some clients will send out a separate ObjectImage packet for each face
  4832. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4833. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4834. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4835. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4836. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4837. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4838. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4839. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4840. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4841. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4842. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4843. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4844. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4845. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4846. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4847. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4848. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4849. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4850. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4851. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4852. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4853. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4854. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4855. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4856. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4857. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4858. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4859. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4860. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4861. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4862. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4863. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4864. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4865. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4866. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4867. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4868. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4869. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4870. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4871. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4872. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4873. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4874. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4875. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4876. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4877. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4878. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4879. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4880. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4881. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4882. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4883. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4884. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4885. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4886. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4887. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4888. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4889. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4890. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4891. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4892. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4893. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4894. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4895. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4896. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4897. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4898. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4899. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4900. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4901. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4902. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4903. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4904. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4905. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4906. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4907. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4908. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4909. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4910. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4911. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4912. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4913. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4914. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4915. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4916. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4917. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4918. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4919. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4920. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4921. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4922. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4923. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4924. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4925. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4926. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4927. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4928. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4929. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4930. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4931. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4932. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4933. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4934. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4935. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4936. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4937. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4938. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4939. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4940. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4941. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4942. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4943. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4944. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4945. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4946. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4947. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4948. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4949. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4950. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4951. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4952. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4953. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4954. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4955. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4956. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4957. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4958. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4959. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4960. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4961. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4962. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4963. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4964. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4965. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4966. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate, true, true);
  4967. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate, true, true);
  4968. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4969. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4970. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4971. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4972. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4973. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4974. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4975. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4976. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4977. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4978. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4979. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4980. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4981. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4982. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4983. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4984. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4985. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4986. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4987. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4988. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4989. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4990. }
  4991. #region Packet Handlers
  4992. public int TotalAgentUpdates { get; set; }
  4993. #region Scene/Avatar
  4994. // Threshold for body rotation to be a significant agent update
  4995. private const float QDELTA = 0.000001f;
  4996. // Threshold for camera rotation to be a significant agent update
  4997. private const float VDELTA = 0.01f;
  4998. /// <summary>
  4999. /// This checks the update significance against the last update made.
  5000. /// </summary>
  5001. /// <remarks>Can only be called by one thread at a time</remarks>
  5002. /// <returns></returns>
  5003. /// <param name='x'></param>
  5004. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5005. {
  5006. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  5007. }
  5008. /// <summary>
  5009. /// This checks the movement/state update significance against the last update made.
  5010. /// </summary>
  5011. /// <remarks>Can only be called by one thread at a time</remarks>
  5012. /// <returns></returns>
  5013. /// <param name='x'></param>
  5014. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5015. {
  5016. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  5017. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  5018. bool movementSignificant =
  5019. (qdelta1 > QDELTA) // significant if body rotation above threshold
  5020. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  5021. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  5022. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  5023. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  5024. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  5025. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  5026. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  5027. ;
  5028. //if (movementSignificant)
  5029. //{
  5030. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  5031. // qdelta1, qdelta2);
  5032. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  5033. // x.ControlFlags, x.Flags, x.Far, x.State);
  5034. //}
  5035. return movementSignificant;
  5036. }
  5037. /// <summary>
  5038. /// This checks the camera update significance against the last update made.
  5039. /// </summary>
  5040. /// <remarks>Can only be called by one thread at a time</remarks>
  5041. /// <returns></returns>
  5042. /// <param name='x'></param>
  5043. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  5044. {
  5045. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  5046. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  5047. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  5048. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  5049. bool cameraSignificant =
  5050. (vdelta1 > VDELTA) ||
  5051. (vdelta2 > VDELTA) ||
  5052. (vdelta3 > VDELTA) ||
  5053. (vdelta4 > VDELTA)
  5054. ;
  5055. //if (cameraSignificant)
  5056. //{
  5057. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  5058. // x.CameraAtAxis, x.CameraCenter);
  5059. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  5060. // x.CameraLeftAxis, x.CameraUpAxis);
  5061. //}
  5062. return cameraSignificant;
  5063. }
  5064. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  5065. {
  5066. // We got here, which means that something in agent update was significant
  5067. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  5068. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  5069. if (x.AgentID != AgentId || x.SessionID != SessionId)
  5070. return false;
  5071. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  5072. // to see what exactly changed
  5073. bool movement = CheckAgentMovementUpdateSignificance(x);
  5074. bool camera = CheckAgentCameraUpdateSignificance(x);
  5075. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  5076. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  5077. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  5078. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  5079. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  5080. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  5081. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  5082. m_thisAgentUpdateArgs.Far = x.Far;
  5083. m_thisAgentUpdateArgs.Flags = x.Flags;
  5084. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  5085. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  5086. m_thisAgentUpdateArgs.State = x.State;
  5087. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  5088. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  5089. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  5090. // Was there a significant movement/state change?
  5091. if (movement)
  5092. {
  5093. if (handlerPreAgentUpdate != null)
  5094. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  5095. if (handlerAgentUpdate != null)
  5096. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  5097. }
  5098. // Was there a significant camera(s) change?
  5099. if (camera)
  5100. if (handlerAgentCameraUpdate != null)
  5101. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  5102. handlerAgentUpdate = null;
  5103. handlerPreAgentUpdate = null;
  5104. handlerAgentCameraUpdate = null;
  5105. PacketPool.Instance.ReturnPacket(packet);
  5106. return true;
  5107. }
  5108. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  5109. {
  5110. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  5111. // validate the agent owns the agentID and sessionID
  5112. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  5113. money.AgentData.SessionID == sender.SessionId)
  5114. {
  5115. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  5116. if (handlerMoneyTransferRequest != null)
  5117. {
  5118. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  5119. money.MoneyData.Amount, money.MoneyData.TransactionType,
  5120. Util.FieldToString(money.MoneyData.Description));
  5121. }
  5122. return true;
  5123. }
  5124. return false;
  5125. }
  5126. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  5127. {
  5128. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  5129. (ParcelGodMarkAsContentPacket)Packet;
  5130. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  5131. if (ParcelGodMarkAsContentHandler != null)
  5132. {
  5133. ParcelGodMarkAsContentHandler(this,
  5134. ParcelGodMarkAsContent.AgentData.AgentID,
  5135. ParcelGodMarkAsContent.ParcelData.LocalID);
  5136. return true;
  5137. }
  5138. return false;
  5139. }
  5140. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  5141. {
  5142. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5143. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5144. if (FreezeUserHandler != null)
  5145. {
  5146. FreezeUserHandler(this,
  5147. FreezeUser.AgentData.AgentID,
  5148. FreezeUser.Data.Flags,
  5149. FreezeUser.Data.TargetID);
  5150. return true;
  5151. }
  5152. return false;
  5153. }
  5154. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5155. {
  5156. EjectUserPacket EjectUser =
  5157. (EjectUserPacket)Packet;
  5158. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5159. if (EjectUserHandler != null)
  5160. {
  5161. EjectUserHandler(this,
  5162. EjectUser.AgentData.AgentID,
  5163. EjectUser.Data.Flags,
  5164. EjectUser.Data.TargetID);
  5165. return true;
  5166. }
  5167. return false;
  5168. }
  5169. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5170. {
  5171. ParcelBuyPassPacket ParcelBuyPass =
  5172. (ParcelBuyPassPacket)Packet;
  5173. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5174. if (ParcelBuyPassHandler != null)
  5175. {
  5176. ParcelBuyPassHandler(this,
  5177. ParcelBuyPass.AgentData.AgentID,
  5178. ParcelBuyPass.ParcelData.LocalID);
  5179. return true;
  5180. }
  5181. return false;
  5182. }
  5183. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5184. {
  5185. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5186. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5187. {
  5188. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5189. if (handlerParcelBuy != null)
  5190. {
  5191. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5192. parcel.Data.IsGroupOwned,
  5193. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5194. parcel.ParcelData.Price,
  5195. false);
  5196. }
  5197. return true;
  5198. }
  5199. return false;
  5200. }
  5201. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5202. {
  5203. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5204. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5205. {
  5206. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5207. if (handlerUUIDGroupNameRequest != null)
  5208. {
  5209. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5210. }
  5211. }
  5212. return true;
  5213. }
  5214. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5215. {
  5216. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5217. if (m_genericPacketHandlers.Count == 0) return false;
  5218. if (gmpack.AgentData.SessionID != SessionId) return false;
  5219. GenericMessage handlerGenericMessage = null;
  5220. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5221. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5222. {
  5223. List<string> msg = new List<string>();
  5224. List<byte[]> msgBytes = new List<byte[]>();
  5225. if (handlerGenericMessage != null)
  5226. {
  5227. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5228. {
  5229. msg.Add(Util.FieldToString(block.Parameter));
  5230. msgBytes.Add(block.Parameter);
  5231. }
  5232. try
  5233. {
  5234. if (OnBinaryGenericMessage != null)
  5235. {
  5236. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5237. }
  5238. handlerGenericMessage(sender, method, msg);
  5239. return true;
  5240. }
  5241. catch (Exception e)
  5242. {
  5243. m_log.ErrorFormat(
  5244. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5245. }
  5246. }
  5247. }
  5248. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5249. return false;
  5250. }
  5251. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5252. {
  5253. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5254. if (ogpack.AgentData.SessionID != SessionId) return false;
  5255. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5256. if (handlerObjectGroupRequest != null)
  5257. {
  5258. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5259. {
  5260. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5261. }
  5262. }
  5263. return true;
  5264. }
  5265. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5266. {
  5267. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5268. if (viewer.AgentData.SessionID != SessionId) return false;
  5269. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5270. if (handlerViewerEffect != null)
  5271. {
  5272. int length = viewer.Effect.Length;
  5273. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5274. for (int i = 0; i < length; i++)
  5275. {
  5276. //copy the effects block arguments into the event handler arg.
  5277. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5278. argument.AgentID = viewer.Effect[i].AgentID;
  5279. argument.Color = viewer.Effect[i].Color;
  5280. argument.Duration = viewer.Effect[i].Duration;
  5281. argument.ID = viewer.Effect[i].ID;
  5282. argument.Type = viewer.Effect[i].Type;
  5283. argument.TypeData = viewer.Effect[i].TypeData;
  5284. args.Add(argument);
  5285. }
  5286. handlerViewerEffect(sender, args);
  5287. }
  5288. return true;
  5289. }
  5290. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5291. {
  5292. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5293. #region Packet Session and User Check
  5294. if (m_checkPackets)
  5295. {
  5296. if (avatarProperties.AgentData.SessionID != SessionId ||
  5297. avatarProperties.AgentData.AgentID != AgentId)
  5298. return true;
  5299. }
  5300. #endregion
  5301. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5302. if (handlerRequestAvatarProperties != null)
  5303. {
  5304. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5305. }
  5306. return true;
  5307. }
  5308. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5309. {
  5310. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5311. #region Packet Session and User Check
  5312. if (m_checkPackets)
  5313. {
  5314. if (inchatpack.AgentData.SessionID != SessionId ||
  5315. inchatpack.AgentData.AgentID != AgentId)
  5316. return true;
  5317. }
  5318. #endregion
  5319. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5320. byte[] message = inchatpack.ChatData.Message;
  5321. byte type = inchatpack.ChatData.Type;
  5322. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5323. // UUID fromAgentID = AgentId;
  5324. int channel = inchatpack.ChatData.Channel;
  5325. if (OnChatFromClient != null)
  5326. {
  5327. OSChatMessage args = new OSChatMessage();
  5328. args.Channel = channel;
  5329. args.From = fromName;
  5330. args.Message = Utils.BytesToString(message);
  5331. args.Type = (ChatTypeEnum)type;
  5332. args.Position = fromPos;
  5333. args.Scene = Scene;
  5334. args.Sender = this;
  5335. args.SenderUUID = this.AgentId;
  5336. ChatMessage handlerChatFromClient = OnChatFromClient;
  5337. if (handlerChatFromClient != null)
  5338. handlerChatFromClient(this, args);
  5339. }
  5340. return true;
  5341. }
  5342. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5343. {
  5344. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5345. #region Packet Session and User Check
  5346. if (m_checkPackets)
  5347. {
  5348. if (avatarProps.AgentData.SessionID != SessionId ||
  5349. avatarProps.AgentData.AgentID != AgentId)
  5350. return true;
  5351. }
  5352. #endregion
  5353. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5354. if (handlerUpdateAvatarProperties != null)
  5355. {
  5356. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5357. UserProfileData UserProfile = new UserProfileData();
  5358. UserProfile.ID = AgentId;
  5359. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5360. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5361. UserProfile.FirstLifeImage = Properties.FLImageID;
  5362. UserProfile.Image = Properties.ImageID;
  5363. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5364. UserProfile.UserFlags &= ~3;
  5365. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5366. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5367. handlerUpdateAvatarProperties(this, UserProfile);
  5368. }
  5369. return true;
  5370. }
  5371. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5372. {
  5373. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5374. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5375. #region Packet Session and User Check
  5376. if (m_checkPackets)
  5377. {
  5378. if (rdialog.AgentData.SessionID != SessionId ||
  5379. rdialog.AgentData.AgentID != AgentId)
  5380. return true;
  5381. }
  5382. #endregion
  5383. int ch = rdialog.Data.ChatChannel;
  5384. byte[] msg = rdialog.Data.ButtonLabel;
  5385. if (OnChatFromClient != null)
  5386. {
  5387. OSChatMessage args = new OSChatMessage();
  5388. args.Channel = ch;
  5389. args.From = String.Empty;
  5390. args.Message = Utils.BytesToString(msg);
  5391. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5392. args.Position = new Vector3();
  5393. args.Scene = Scene;
  5394. args.Sender = this;
  5395. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5396. if (handlerChatFromClient2 != null)
  5397. handlerChatFromClient2(this, args);
  5398. }
  5399. return true;
  5400. }
  5401. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5402. {
  5403. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5404. #region Packet Session and User Check
  5405. if (m_checkPackets)
  5406. {
  5407. if (msgpack.AgentData.SessionID != SessionId ||
  5408. msgpack.AgentData.AgentID != AgentId)
  5409. return true;
  5410. }
  5411. #endregion
  5412. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5413. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5414. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5415. if (handlerInstantMessage != null)
  5416. {
  5417. GridInstantMessage im = new GridInstantMessage(Scene,
  5418. msgpack.AgentData.AgentID,
  5419. IMfromName,
  5420. msgpack.MessageBlock.ToAgentID,
  5421. msgpack.MessageBlock.Dialog,
  5422. msgpack.MessageBlock.FromGroup,
  5423. IMmessage,
  5424. msgpack.MessageBlock.ID,
  5425. msgpack.MessageBlock.Offline != 0 ? true : false,
  5426. msgpack.MessageBlock.Position,
  5427. msgpack.MessageBlock.BinaryBucket,
  5428. true);
  5429. handlerInstantMessage(this, im);
  5430. }
  5431. return true;
  5432. }
  5433. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5434. {
  5435. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5436. #region Packet Session and User Check
  5437. if (m_checkPackets)
  5438. {
  5439. if (afriendpack.AgentData.SessionID != SessionId ||
  5440. afriendpack.AgentData.AgentID != AgentId)
  5441. return true;
  5442. }
  5443. #endregion
  5444. // My guess is this is the folder to stick the calling card into
  5445. List<UUID> callingCardFolders = new List<UUID>();
  5446. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5447. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5448. {
  5449. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5450. }
  5451. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5452. if (handlerApproveFriendRequest != null)
  5453. {
  5454. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5455. }
  5456. return true;
  5457. }
  5458. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5459. {
  5460. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5461. #region Packet Session and User Check
  5462. if (m_checkPackets)
  5463. {
  5464. if (dfriendpack.AgentData.SessionID != SessionId ||
  5465. dfriendpack.AgentData.AgentID != AgentId)
  5466. return true;
  5467. }
  5468. #endregion
  5469. if (OnDenyFriendRequest != null)
  5470. {
  5471. OnDenyFriendRequest(this,
  5472. dfriendpack.TransactionBlock.TransactionID,
  5473. null);
  5474. }
  5475. return true;
  5476. }
  5477. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5478. {
  5479. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5480. #region Packet Session and User Check
  5481. if (m_checkPackets)
  5482. {
  5483. if (tfriendpack.AgentData.SessionID != SessionId ||
  5484. tfriendpack.AgentData.AgentID != AgentId)
  5485. return true;
  5486. }
  5487. #endregion
  5488. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5489. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5490. if (TerminateFriendshipHandler != null)
  5491. {
  5492. TerminateFriendshipHandler(this, exFriendID);
  5493. return true;
  5494. }
  5495. return false;
  5496. }
  5497. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5498. {
  5499. FindAgentPacket FindAgent =
  5500. (FindAgentPacket)Packet;
  5501. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5502. if (FindAgentHandler != null)
  5503. {
  5504. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5505. return true;
  5506. }
  5507. return false;
  5508. }
  5509. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5510. {
  5511. TrackAgentPacket TrackAgent =
  5512. (TrackAgentPacket)Packet;
  5513. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5514. if (TrackAgentHandler != null)
  5515. {
  5516. TrackAgentHandler(this,
  5517. TrackAgent.AgentData.AgentID,
  5518. TrackAgent.TargetData.PreyID);
  5519. return true;
  5520. }
  5521. return false;
  5522. }
  5523. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5524. {
  5525. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5526. #region Packet Session and User Check
  5527. if (m_checkPackets)
  5528. {
  5529. if (rezPacket.AgentData.SessionID != SessionId ||
  5530. rezPacket.AgentData.AgentID != AgentId)
  5531. return true;
  5532. }
  5533. #endregion
  5534. RezObject handlerRezObject = OnRezObject;
  5535. if (handlerRezObject != null)
  5536. {
  5537. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5538. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5539. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5540. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5541. rezPacket.RezData.FromTaskID);
  5542. }
  5543. return true;
  5544. }
  5545. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5546. {
  5547. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5548. #region Packet Session and User Check
  5549. if (m_checkPackets)
  5550. {
  5551. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5552. DeRezPacket.AgentData.AgentID != AgentId)
  5553. return true;
  5554. }
  5555. #endregion
  5556. DeRezObject handlerDeRezObject = OnDeRezObject;
  5557. if (handlerDeRezObject != null)
  5558. {
  5559. List<uint> deRezIDs = new List<uint>();
  5560. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5561. DeRezPacket.ObjectData)
  5562. {
  5563. deRezIDs.Add(data.ObjectLocalID);
  5564. }
  5565. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5566. // values given by a Second Life client
  5567. handlerDeRezObject(this, deRezIDs,
  5568. DeRezPacket.AgentBlock.GroupID,
  5569. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5570. DeRezPacket.AgentBlock.DestinationID);
  5571. }
  5572. return true;
  5573. }
  5574. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5575. {
  5576. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5577. #region Packet Session and User Check
  5578. if (m_checkPackets)
  5579. {
  5580. if (modify.AgentData.SessionID != SessionId ||
  5581. modify.AgentData.AgentID != AgentId)
  5582. return true;
  5583. }
  5584. #endregion
  5585. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5586. if (modify.ParcelData.Length > 0)
  5587. {
  5588. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5589. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5590. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5591. if (OnModifyTerrain != null)
  5592. {
  5593. for (int i = 0; i < modify.ParcelData.Length; i++)
  5594. {
  5595. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5596. if (handlerModifyTerrain != null)
  5597. {
  5598. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5599. modify.ModifyBlock.BrushSize,
  5600. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5601. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5602. modify.ParcelData[i].East, AgentId);
  5603. }
  5604. }
  5605. }
  5606. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5607. }
  5608. return true;
  5609. }
  5610. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5611. {
  5612. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5613. if (handlerRegionHandShakeReply != null)
  5614. {
  5615. handlerRegionHandShakeReply(this);
  5616. }
  5617. return true;
  5618. }
  5619. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5620. {
  5621. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5622. if (handlerRequestWearables != null)
  5623. {
  5624. handlerRequestWearables(sender);
  5625. }
  5626. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5627. if (handlerRequestAvatarsData != null)
  5628. {
  5629. handlerRequestAvatarsData(this);
  5630. }
  5631. return true;
  5632. }
  5633. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5634. {
  5635. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5636. #region Packet Session and User Check
  5637. if (m_checkPackets)
  5638. {
  5639. if (appear.AgentData.SessionID != SessionId ||
  5640. appear.AgentData.AgentID != AgentId)
  5641. return true;
  5642. }
  5643. #endregion
  5644. SetAppearance handlerSetAppearance = OnSetAppearance;
  5645. if (handlerSetAppearance != null)
  5646. {
  5647. // Temporarily protect ourselves from the mantis #951 failure.
  5648. // However, we could do this for several other handlers where a failure isn't terminal
  5649. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5650. Vector3 avSize = appear.AgentData.Size;
  5651. try
  5652. {
  5653. byte[] visualparams = new byte[appear.VisualParam.Length];
  5654. for (int i = 0; i < appear.VisualParam.Length; i++)
  5655. visualparams[i] = appear.VisualParam[i].ParamValue;
  5656. //var b = appear.WearableData[0];
  5657. Primitive.TextureEntry te = null;
  5658. if (appear.ObjectData.TextureEntry.Length > 1)
  5659. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5660. WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
  5661. for (int i=0; i<appear.WearableData.Length;i++)
  5662. cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)};
  5663. handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
  5664. }
  5665. catch (Exception e)
  5666. {
  5667. m_log.ErrorFormat(
  5668. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5669. e);
  5670. }
  5671. }
  5672. return true;
  5673. }
  5674. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5675. {
  5676. if (OnAvatarNowWearing != null)
  5677. {
  5678. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5679. #region Packet Session and User Check
  5680. if (m_checkPackets)
  5681. {
  5682. if (nowWearing.AgentData.SessionID != SessionId ||
  5683. nowWearing.AgentData.AgentID != AgentId)
  5684. return true;
  5685. }
  5686. #endregion
  5687. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5688. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5689. {
  5690. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5691. AvatarWearingArgs.Wearable wearable =
  5692. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5693. nowWearing.WearableData[i].WearableType);
  5694. wearingArgs.NowWearing.Add(wearable);
  5695. }
  5696. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5697. if (handlerAvatarNowWearing != null)
  5698. {
  5699. handlerAvatarNowWearing(this, wearingArgs);
  5700. }
  5701. }
  5702. return true;
  5703. }
  5704. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5705. {
  5706. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5707. if (handlerRezSingleAttachment != null)
  5708. {
  5709. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5710. #region Packet Session and User Check
  5711. if (m_checkPackets)
  5712. {
  5713. if (rez.AgentData.SessionID != SessionId ||
  5714. rez.AgentData.AgentID != AgentId)
  5715. return true;
  5716. }
  5717. #endregion
  5718. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5719. rez.ObjectData.AttachmentPt);
  5720. }
  5721. return true;
  5722. }
  5723. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5724. {
  5725. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5726. if (handlerRezMultipleAttachments != null)
  5727. {
  5728. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5729. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5730. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5731. handlerRezMultipleAttachments(this, rezlist);
  5732. }
  5733. return true;
  5734. }
  5735. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5736. {
  5737. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5738. if (handlerDetachAttachmentIntoInv != null)
  5739. {
  5740. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5741. #region Packet Session and User Check
  5742. // UNSUPPORTED ON THIS PACKET
  5743. #endregion
  5744. UUID itemID = detachtoInv.ObjectData.ItemID;
  5745. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5746. handlerDetachAttachmentIntoInv(itemID, this);
  5747. }
  5748. return true;
  5749. }
  5750. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5751. {
  5752. if (OnObjectAttach != null)
  5753. {
  5754. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5755. #region Packet Session and User Check
  5756. if (m_checkPackets)
  5757. {
  5758. if (att.AgentData.SessionID != SessionId ||
  5759. att.AgentData.AgentID != AgentId)
  5760. return true;
  5761. }
  5762. #endregion
  5763. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5764. if (handlerObjectAttach != null)
  5765. {
  5766. if (att.ObjectData.Length > 0)
  5767. {
  5768. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5769. }
  5770. }
  5771. }
  5772. return true;
  5773. }
  5774. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5775. {
  5776. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5777. #region Packet Session and User Check
  5778. if (m_checkPackets)
  5779. {
  5780. if (dett.AgentData.SessionID != SessionId ||
  5781. dett.AgentData.AgentID != AgentId)
  5782. return true;
  5783. }
  5784. #endregion
  5785. for (int j = 0; j < dett.ObjectData.Length; j++)
  5786. {
  5787. uint obj = dett.ObjectData[j].ObjectLocalID;
  5788. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5789. if (handlerObjectDetach != null)
  5790. {
  5791. handlerObjectDetach(obj, this);
  5792. }
  5793. }
  5794. return true;
  5795. }
  5796. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5797. {
  5798. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5799. #region Packet Session and User Check
  5800. if (m_checkPackets)
  5801. {
  5802. if (dropp.AgentData.SessionID != SessionId ||
  5803. dropp.AgentData.AgentID != AgentId)
  5804. return true;
  5805. }
  5806. #endregion
  5807. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5808. {
  5809. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5810. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5811. if (handlerObjectDrop != null)
  5812. {
  5813. handlerObjectDrop(obj, this);
  5814. }
  5815. }
  5816. return true;
  5817. }
  5818. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5819. {
  5820. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5821. #region Packet Session and User Check
  5822. if (m_checkPackets)
  5823. {
  5824. if (run.AgentData.SessionID != SessionId ||
  5825. run.AgentData.AgentID != AgentId)
  5826. return true;
  5827. }
  5828. #endregion
  5829. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5830. if (handlerSetAlwaysRun != null)
  5831. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5832. return true;
  5833. }
  5834. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5835. {
  5836. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5837. if (handlerCompleteMovementToRegion != null)
  5838. {
  5839. handlerCompleteMovementToRegion(sender, true);
  5840. }
  5841. handlerCompleteMovementToRegion = null;
  5842. return true;
  5843. }
  5844. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5845. {
  5846. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5847. #region Packet Session and User Check
  5848. if (m_checkPackets)
  5849. {
  5850. if (AgentAni.AgentData.SessionID != SessionId ||
  5851. AgentAni.AgentData.AgentID != AgentId)
  5852. return true;
  5853. }
  5854. #endregion
  5855. StartAnim handlerStartAnim = null;
  5856. StopAnim handlerStopAnim = null;
  5857. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5858. {
  5859. if (AgentAni.AnimationList[i].StartAnim)
  5860. {
  5861. handlerStartAnim = OnStartAnim;
  5862. if (handlerStartAnim != null)
  5863. {
  5864. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5865. }
  5866. }
  5867. else
  5868. {
  5869. handlerStopAnim = OnStopAnim;
  5870. if (handlerStopAnim != null)
  5871. {
  5872. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5873. }
  5874. }
  5875. }
  5876. return true;
  5877. }
  5878. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5879. {
  5880. if (OnAgentRequestSit != null)
  5881. {
  5882. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5883. #region Packet Session and User Check
  5884. if (m_checkPackets)
  5885. {
  5886. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5887. agentRequestSit.AgentData.AgentID != AgentId)
  5888. return true;
  5889. }
  5890. #endregion
  5891. if (SceneAgent.IsChildAgent)
  5892. {
  5893. SendCantSitBecauseChildAgentResponse();
  5894. return true;
  5895. }
  5896. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5897. if (handlerAgentRequestSit != null)
  5898. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5899. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5900. }
  5901. return true;
  5902. }
  5903. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5904. {
  5905. if (OnAgentSit != null)
  5906. {
  5907. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5908. #region Packet Session and User Check
  5909. if (m_checkPackets)
  5910. {
  5911. if (agentSit.AgentData.SessionID != SessionId ||
  5912. agentSit.AgentData.AgentID != AgentId)
  5913. return true;
  5914. }
  5915. #endregion
  5916. if (SceneAgent.IsChildAgent)
  5917. {
  5918. SendCantSitBecauseChildAgentResponse();
  5919. return true;
  5920. }
  5921. AgentSit handlerAgentSit = OnAgentSit;
  5922. if (handlerAgentSit != null)
  5923. {
  5924. OnAgentSit(this, agentSit.AgentData.AgentID);
  5925. }
  5926. }
  5927. return true;
  5928. }
  5929. /// <summary>
  5930. /// Used when a child agent gets a sit response which should not be fulfilled.
  5931. /// </summary>
  5932. private void SendCantSitBecauseChildAgentResponse()
  5933. {
  5934. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5935. }
  5936. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5937. {
  5938. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5939. #region Packet Session and User Check
  5940. if (m_checkPackets)
  5941. {
  5942. // UNSUPPORTED ON THIS PACKET
  5943. }
  5944. #endregion
  5945. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5946. if (handlerSoundTrigger != null)
  5947. {
  5948. // UUIDS are sent as zeroes by the client, substitute agent's id
  5949. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5950. AgentId, AgentId,
  5951. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5952. soundTriggerPacket.SoundData.Handle, 0);
  5953. }
  5954. return true;
  5955. }
  5956. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5957. {
  5958. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5959. #region Packet Session and User Check
  5960. if (m_checkPackets)
  5961. {
  5962. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5963. avRequestQuery.AgentData.AgentID != AgentId)
  5964. return true;
  5965. }
  5966. #endregion
  5967. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5968. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5969. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5970. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5971. if (handlerAvatarPickerRequest != null)
  5972. {
  5973. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5974. Utils.BytesToString(querydata.Name));
  5975. }
  5976. return true;
  5977. }
  5978. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5979. {
  5980. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5981. #region Packet Session and User Check
  5982. if (m_checkPackets)
  5983. {
  5984. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5985. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5986. return true;
  5987. }
  5988. #endregion
  5989. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5990. if (handlerAgentDataUpdateRequest != null)
  5991. {
  5992. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5993. }
  5994. return true;
  5995. }
  5996. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5997. {
  5998. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5999. if (handlerUserInfoRequest != null)
  6000. {
  6001. handlerUserInfoRequest(this);
  6002. }
  6003. else
  6004. {
  6005. SendUserInfoReply(false, true, "");
  6006. }
  6007. return true;
  6008. }
  6009. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  6010. {
  6011. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  6012. #region Packet Session and User Check
  6013. if (m_checkPackets)
  6014. {
  6015. if (updateUserInfo.AgentData.SessionID != SessionId ||
  6016. updateUserInfo.AgentData.AgentID != AgentId)
  6017. return true;
  6018. }
  6019. #endregion
  6020. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  6021. if (handlerUpdateUserInfo != null)
  6022. {
  6023. bool visible = true;
  6024. string DirectoryVisibility =
  6025. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  6026. if (DirectoryVisibility == "hidden")
  6027. visible = false;
  6028. handlerUpdateUserInfo(
  6029. updateUserInfo.UserData.IMViaEMail,
  6030. visible, this);
  6031. }
  6032. return true;
  6033. }
  6034. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  6035. {
  6036. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  6037. #region Packet Session and User Check
  6038. if (m_checkPackets)
  6039. {
  6040. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  6041. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  6042. return true;
  6043. }
  6044. #endregion
  6045. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  6046. {
  6047. // Linden Client limitation..
  6048. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  6049. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  6050. {
  6051. ScenePresence avatar = null;
  6052. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  6053. {
  6054. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  6055. {
  6056. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  6057. }
  6058. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  6059. {
  6060. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  6061. }
  6062. }
  6063. }
  6064. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  6065. if (handlerSetStartLocationRequest != null)
  6066. {
  6067. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  6068. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  6069. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  6070. }
  6071. }
  6072. return true;
  6073. }
  6074. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  6075. {
  6076. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  6077. #region Packet Session and User Check
  6078. if (m_checkPackets)
  6079. {
  6080. if (atpack.AgentData.SessionID != SessionId ||
  6081. atpack.AgentData.AgentID != AgentId)
  6082. return true;
  6083. }
  6084. #endregion
  6085. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  6086. return true;
  6087. }
  6088. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  6089. {
  6090. m_udpClient.IsPaused = true;
  6091. return true;
  6092. }
  6093. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  6094. {
  6095. m_udpClient.IsPaused = false;
  6096. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  6097. return true;
  6098. }
  6099. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  6100. {
  6101. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  6102. if (handlerForceReleaseControls != null)
  6103. {
  6104. handlerForceReleaseControls(this, AgentId);
  6105. }
  6106. return true;
  6107. }
  6108. #endregion Scene/Avatar
  6109. #region Objects/m_sceneObjects
  6110. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  6111. {
  6112. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  6113. #region Packet Session and User Check
  6114. if (m_checkPackets)
  6115. {
  6116. if (link.AgentData.SessionID != SessionId ||
  6117. link.AgentData.AgentID != AgentId)
  6118. return true;
  6119. }
  6120. #endregion
  6121. uint parentprimid = 0;
  6122. List<uint> childrenprims = new List<uint>();
  6123. if (link.ObjectData.Length > 1)
  6124. {
  6125. parentprimid = link.ObjectData[0].ObjectLocalID;
  6126. for (int i = 1; i < link.ObjectData.Length; i++)
  6127. {
  6128. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  6129. }
  6130. }
  6131. LinkObjects handlerLinkObjects = OnLinkObjects;
  6132. if (handlerLinkObjects != null)
  6133. {
  6134. handlerLinkObjects(this, parentprimid, childrenprims);
  6135. }
  6136. return true;
  6137. }
  6138. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  6139. {
  6140. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6141. #region Packet Session and User Check
  6142. if (m_checkPackets)
  6143. {
  6144. if (delink.AgentData.SessionID != SessionId ||
  6145. delink.AgentData.AgentID != AgentId)
  6146. return true;
  6147. }
  6148. #endregion
  6149. // It appears the prim at index 0 is not always the root prim (for
  6150. // instance, when one prim of a link set has been edited independently
  6151. // of the others). Therefore, we'll pass all the ids onto the delink
  6152. // method for it to decide which is the root.
  6153. List<uint> prims = new List<uint>();
  6154. for (int i = 0; i < delink.ObjectData.Length; i++)
  6155. {
  6156. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6157. }
  6158. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6159. if (handlerDelinkObjects != null)
  6160. {
  6161. handlerDelinkObjects(prims, this);
  6162. }
  6163. return true;
  6164. }
  6165. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6166. {
  6167. if (OnAddPrim != null)
  6168. {
  6169. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6170. #region Packet Session and User Check
  6171. if (m_checkPackets)
  6172. {
  6173. if (addPacket.AgentData.SessionID != SessionId ||
  6174. addPacket.AgentData.AgentID != AgentId)
  6175. return true;
  6176. }
  6177. #endregion
  6178. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6179. // m_log.Info("[REZData]: " + addPacket.ToString());
  6180. //BypassRaycast: 1
  6181. //RayStart: <69.79469, 158.2652, 98.40343>
  6182. //RayEnd: <61.97724, 141.995, 92.58341>
  6183. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6184. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6185. //object from rezing initially
  6186. AddNewPrim handlerAddPrim = OnAddPrim;
  6187. if (handlerAddPrim != null)
  6188. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6189. }
  6190. return true;
  6191. }
  6192. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6193. {
  6194. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6195. #region Packet Session and User Check
  6196. if (m_checkPackets)
  6197. {
  6198. if (shapePacket.AgentData.SessionID != SessionId ||
  6199. shapePacket.AgentData.AgentID != AgentId)
  6200. return true;
  6201. }
  6202. #endregion
  6203. UpdateShape handlerUpdatePrimShape = null;
  6204. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6205. {
  6206. handlerUpdatePrimShape = OnUpdatePrimShape;
  6207. if (handlerUpdatePrimShape != null)
  6208. {
  6209. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6210. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6211. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6212. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6213. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6214. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6215. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6216. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6217. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6218. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6219. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6220. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6221. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6222. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6223. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6224. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6225. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6226. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6227. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6228. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6229. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6230. shapeData);
  6231. }
  6232. }
  6233. return true;
  6234. }
  6235. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6236. {
  6237. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6238. #region Packet Session and User Check
  6239. if (m_checkPackets)
  6240. {
  6241. if (extraPar.AgentData.SessionID != SessionId ||
  6242. extraPar.AgentData.AgentID != AgentId)
  6243. return true;
  6244. }
  6245. #endregion
  6246. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6247. if (handlerUpdateExtraParams != null)
  6248. {
  6249. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6250. {
  6251. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6252. extraPar.ObjectData[i].ParamType,
  6253. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6254. }
  6255. }
  6256. return true;
  6257. }
  6258. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6259. {
  6260. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6261. #region Packet Session and User Check
  6262. if (m_checkPackets)
  6263. {
  6264. if (dupe.AgentData.SessionID != SessionId ||
  6265. dupe.AgentData.AgentID != AgentId)
  6266. return true;
  6267. }
  6268. #endregion
  6269. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6270. ObjectDuplicate handlerObjectDuplicate = null;
  6271. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6272. {
  6273. handlerObjectDuplicate = OnObjectDuplicate;
  6274. if (handlerObjectDuplicate != null)
  6275. {
  6276. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6277. dupe.SharedData.DuplicateFlags, AgentId,
  6278. ActiveGroupId);
  6279. }
  6280. }
  6281. return true;
  6282. }
  6283. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6284. {
  6285. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6286. #region Packet Session and User Check
  6287. if (m_checkPackets)
  6288. {
  6289. if (incomingRequest.AgentData.SessionID != SessionId ||
  6290. incomingRequest.AgentData.AgentID != AgentId)
  6291. return true;
  6292. }
  6293. #endregion
  6294. ObjectRequest handlerObjectRequest = null;
  6295. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6296. {
  6297. handlerObjectRequest = OnObjectRequest;
  6298. if (handlerObjectRequest != null)
  6299. {
  6300. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6301. }
  6302. }
  6303. return true;
  6304. }
  6305. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6306. {
  6307. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6308. #region Packet Session and User Check
  6309. if (m_checkPackets)
  6310. {
  6311. if (incomingselect.AgentData.SessionID != SessionId ||
  6312. incomingselect.AgentData.AgentID != AgentId)
  6313. return true;
  6314. }
  6315. #endregion
  6316. ObjectSelect handlerObjectSelect = null;
  6317. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6318. {
  6319. handlerObjectSelect = OnObjectSelect;
  6320. if (handlerObjectSelect != null)
  6321. {
  6322. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6323. }
  6324. }
  6325. return true;
  6326. }
  6327. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6328. {
  6329. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6330. #region Packet Session and User Check
  6331. if (m_checkPackets)
  6332. {
  6333. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6334. incomingdeselect.AgentData.AgentID != AgentId)
  6335. return true;
  6336. }
  6337. #endregion
  6338. ObjectDeselect handlerObjectDeselect = null;
  6339. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6340. {
  6341. handlerObjectDeselect = OnObjectDeselect;
  6342. if (handlerObjectDeselect != null)
  6343. {
  6344. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6345. }
  6346. }
  6347. return true;
  6348. }
  6349. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6350. {
  6351. // DEPRECATED: but till libsecondlife removes it, people will use it
  6352. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6353. #region Packet Session and User Check
  6354. if (m_checkPackets)
  6355. {
  6356. if (position.AgentData.SessionID != SessionId ||
  6357. position.AgentData.AgentID != AgentId)
  6358. return true;
  6359. }
  6360. #endregion
  6361. for (int i = 0; i < position.ObjectData.Length; i++)
  6362. {
  6363. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6364. if (handlerUpdateVector != null)
  6365. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6366. }
  6367. return true;
  6368. }
  6369. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6370. {
  6371. // DEPRECATED: but till libsecondlife removes it, people will use it
  6372. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6373. #region Packet Session and User Check
  6374. if (m_checkPackets)
  6375. {
  6376. if (scale.AgentData.SessionID != SessionId ||
  6377. scale.AgentData.AgentID != AgentId)
  6378. return true;
  6379. }
  6380. #endregion
  6381. for (int i = 0; i < scale.ObjectData.Length; i++)
  6382. {
  6383. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6384. if (handlerUpdatePrimGroupScale != null)
  6385. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6386. }
  6387. return true;
  6388. }
  6389. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6390. {
  6391. // DEPRECATED: but till libsecondlife removes it, people will use it
  6392. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6393. #region Packet Session and User Check
  6394. if (m_checkPackets)
  6395. {
  6396. if (rotation.AgentData.SessionID != SessionId ||
  6397. rotation.AgentData.AgentID != AgentId)
  6398. return true;
  6399. }
  6400. #endregion
  6401. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6402. {
  6403. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6404. if (handlerUpdatePrimRotation != null)
  6405. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6406. }
  6407. return true;
  6408. }
  6409. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6410. {
  6411. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6412. #region Packet Session and User Check
  6413. if (m_checkPackets)
  6414. {
  6415. if (flags.AgentData.SessionID != SessionId ||
  6416. flags.AgentData.AgentID != AgentId)
  6417. return true;
  6418. }
  6419. #endregion
  6420. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6421. if (handlerUpdatePrimFlags != null)
  6422. {
  6423. // byte[] data = Pack.ToBytes();
  6424. // 46,47,48 are special positions within the packet
  6425. // This may change so perhaps we need a better way
  6426. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6427. /*
  6428. bool UsePhysics = (data[46] != 0) ? true : false;
  6429. bool IsTemporary = (data[47] != 0) ? true : false;
  6430. bool IsPhantom = (data[48] != 0) ? true : false;
  6431. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6432. */
  6433. bool UsePhysics = flags.AgentData.UsePhysics;
  6434. bool IsPhantom = flags.AgentData.IsPhantom;
  6435. bool IsTemporary = flags.AgentData.IsTemporary;
  6436. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6437. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6438. if (blocks == null || blocks.Length == 0)
  6439. {
  6440. physdata.PhysShapeType = PhysShapeType.invalid;
  6441. }
  6442. else
  6443. {
  6444. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6445. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6446. physdata.Bounce = phsblock.Restitution;
  6447. physdata.Density = phsblock.Density;
  6448. physdata.Friction = phsblock.Friction;
  6449. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6450. }
  6451. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6452. }
  6453. return true;
  6454. }
  6455. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6456. {
  6457. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6458. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6459. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6460. {
  6461. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6462. if (handlerUpdatePrimTexture != null)
  6463. {
  6464. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6465. imagePack.ObjectData[i].TextureEntry, this);
  6466. }
  6467. }
  6468. return true;
  6469. }
  6470. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6471. {
  6472. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6473. #region Packet Session and User Check
  6474. if (m_checkPackets)
  6475. {
  6476. if (grab.AgentData.SessionID != SessionId ||
  6477. grab.AgentData.AgentID != AgentId)
  6478. return true;
  6479. }
  6480. #endregion
  6481. GrabObject handlerGrabObject = OnGrabObject;
  6482. if (handlerGrabObject != null)
  6483. {
  6484. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6485. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6486. {
  6487. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6488. {
  6489. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6490. arg.Binormal = surfaceInfo.Binormal;
  6491. arg.FaceIndex = surfaceInfo.FaceIndex;
  6492. arg.Normal = surfaceInfo.Normal;
  6493. arg.Position = surfaceInfo.Position;
  6494. arg.STCoord = surfaceInfo.STCoord;
  6495. arg.UVCoord = surfaceInfo.UVCoord;
  6496. touchArgs.Add(arg);
  6497. }
  6498. }
  6499. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6500. }
  6501. return true;
  6502. }
  6503. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6504. {
  6505. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6506. #region Packet Session and User Check
  6507. if (m_checkPackets)
  6508. {
  6509. if (grabUpdate.AgentData.SessionID != SessionId ||
  6510. grabUpdate.AgentData.AgentID != AgentId)
  6511. return true;
  6512. }
  6513. #endregion
  6514. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6515. if (handlerGrabUpdate != null)
  6516. {
  6517. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6518. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6519. {
  6520. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6521. {
  6522. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6523. arg.Binormal = surfaceInfo.Binormal;
  6524. arg.FaceIndex = surfaceInfo.FaceIndex;
  6525. arg.Normal = surfaceInfo.Normal;
  6526. arg.Position = surfaceInfo.Position;
  6527. arg.STCoord = surfaceInfo.STCoord;
  6528. arg.UVCoord = surfaceInfo.UVCoord;
  6529. touchArgs.Add(arg);
  6530. }
  6531. }
  6532. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6533. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6534. }
  6535. return true;
  6536. }
  6537. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6538. {
  6539. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6540. #region Packet Session and User Check
  6541. if (m_checkPackets)
  6542. {
  6543. if (deGrab.AgentData.SessionID != SessionId ||
  6544. deGrab.AgentData.AgentID != AgentId)
  6545. return true;
  6546. }
  6547. #endregion
  6548. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6549. if (handlerDeGrabObject != null)
  6550. {
  6551. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6552. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6553. {
  6554. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6555. {
  6556. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6557. arg.Binormal = surfaceInfo.Binormal;
  6558. arg.FaceIndex = surfaceInfo.FaceIndex;
  6559. arg.Normal = surfaceInfo.Normal;
  6560. arg.Position = surfaceInfo.Position;
  6561. arg.STCoord = surfaceInfo.STCoord;
  6562. arg.UVCoord = surfaceInfo.UVCoord;
  6563. touchArgs.Add(arg);
  6564. }
  6565. }
  6566. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6567. }
  6568. return true;
  6569. }
  6570. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6571. {
  6572. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6573. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6574. #region Packet Session and User Check
  6575. if (m_checkPackets)
  6576. {
  6577. if (spinStart.AgentData.SessionID != SessionId ||
  6578. spinStart.AgentData.AgentID != AgentId)
  6579. return true;
  6580. }
  6581. #endregion
  6582. SpinStart handlerSpinStart = OnSpinStart;
  6583. if (handlerSpinStart != null)
  6584. {
  6585. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6586. }
  6587. return true;
  6588. }
  6589. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6590. {
  6591. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6592. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6593. #region Packet Session and User Check
  6594. if (m_checkPackets)
  6595. {
  6596. if (spinUpdate.AgentData.SessionID != SessionId ||
  6597. spinUpdate.AgentData.AgentID != AgentId)
  6598. return true;
  6599. }
  6600. #endregion
  6601. Vector3 axis;
  6602. float angle;
  6603. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6604. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6605. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6606. if (handlerSpinUpdate != null)
  6607. {
  6608. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6609. }
  6610. return true;
  6611. }
  6612. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6613. {
  6614. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6615. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6616. #region Packet Session and User Check
  6617. if (m_checkPackets)
  6618. {
  6619. if (spinStop.AgentData.SessionID != SessionId ||
  6620. spinStop.AgentData.AgentID != AgentId)
  6621. return true;
  6622. }
  6623. #endregion
  6624. SpinStop handlerSpinStop = OnSpinStop;
  6625. if (handlerSpinStop != null)
  6626. {
  6627. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6628. }
  6629. return true;
  6630. }
  6631. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6632. {
  6633. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6634. #region Packet Session and User Check
  6635. if (m_checkPackets)
  6636. {
  6637. if (objDes.AgentData.SessionID != SessionId ||
  6638. objDes.AgentData.AgentID != AgentId)
  6639. return true;
  6640. }
  6641. #endregion
  6642. GenericCall7 handlerObjectDescription = null;
  6643. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6644. {
  6645. handlerObjectDescription = OnObjectDescription;
  6646. if (handlerObjectDescription != null)
  6647. {
  6648. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6649. Util.FieldToString(objDes.ObjectData[i].Description));
  6650. }
  6651. }
  6652. return true;
  6653. }
  6654. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6655. {
  6656. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6657. #region Packet Session and User Check
  6658. if (m_checkPackets)
  6659. {
  6660. if (objName.AgentData.SessionID != SessionId ||
  6661. objName.AgentData.AgentID != AgentId)
  6662. return true;
  6663. }
  6664. #endregion
  6665. GenericCall7 handlerObjectName = null;
  6666. for (int i = 0; i < objName.ObjectData.Length; i++)
  6667. {
  6668. handlerObjectName = OnObjectName;
  6669. if (handlerObjectName != null)
  6670. {
  6671. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6672. Util.FieldToString(objName.ObjectData[i].Name));
  6673. }
  6674. }
  6675. return true;
  6676. }
  6677. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6678. {
  6679. if (OnObjectPermissions != null)
  6680. {
  6681. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6682. #region Packet Session and User Check
  6683. if (m_checkPackets)
  6684. {
  6685. if (newobjPerms.AgentData.SessionID != SessionId ||
  6686. newobjPerms.AgentData.AgentID != AgentId)
  6687. return true;
  6688. }
  6689. #endregion
  6690. UUID AgentID = newobjPerms.AgentData.AgentID;
  6691. UUID SessionID = newobjPerms.AgentData.SessionID;
  6692. ObjectPermissions handlerObjectPermissions = null;
  6693. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6694. {
  6695. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6696. byte field = permChanges.Field;
  6697. uint localID = permChanges.ObjectLocalID;
  6698. uint mask = permChanges.Mask;
  6699. byte set = permChanges.Set;
  6700. handlerObjectPermissions = OnObjectPermissions;
  6701. if (handlerObjectPermissions != null)
  6702. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6703. }
  6704. }
  6705. // Here's our data,
  6706. // PermField contains the field the info goes into
  6707. // PermField determines which mask we're changing
  6708. //
  6709. // chmask is the mask of the change
  6710. // setTF is whether we're adding it or taking it away
  6711. //
  6712. // objLocalID is the localID of the object.
  6713. // Unfortunately, we have to pass the event the packet because objData is an array
  6714. // That means multiple object perms may be updated in a single packet.
  6715. return true;
  6716. }
  6717. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6718. {
  6719. UndoPacket undoitem = (UndoPacket)Pack;
  6720. #region Packet Session and User Check
  6721. if (m_checkPackets)
  6722. {
  6723. if (undoitem.AgentData.SessionID != SessionId ||
  6724. undoitem.AgentData.AgentID != AgentId)
  6725. return true;
  6726. }
  6727. #endregion
  6728. if (undoitem.ObjectData.Length > 0)
  6729. {
  6730. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6731. {
  6732. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6733. AgentSit handlerOnUndo = OnUndo;
  6734. if (handlerOnUndo != null)
  6735. {
  6736. handlerOnUndo(this, objiD);
  6737. }
  6738. }
  6739. }
  6740. return true;
  6741. }
  6742. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6743. {
  6744. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6745. #region Packet Session and User Check
  6746. if (m_checkPackets)
  6747. {
  6748. if (undolanditem.AgentData.SessionID != SessionId ||
  6749. undolanditem.AgentData.AgentID != AgentId)
  6750. return true;
  6751. }
  6752. #endregion
  6753. LandUndo handlerOnUndo = OnLandUndo;
  6754. if (handlerOnUndo != null)
  6755. {
  6756. handlerOnUndo(this);
  6757. }
  6758. return true;
  6759. }
  6760. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6761. {
  6762. RedoPacket redoitem = (RedoPacket)Pack;
  6763. #region Packet Session and User Check
  6764. if (m_checkPackets)
  6765. {
  6766. if (redoitem.AgentData.SessionID != SessionId ||
  6767. redoitem.AgentData.AgentID != AgentId)
  6768. return true;
  6769. }
  6770. #endregion
  6771. if (redoitem.ObjectData.Length > 0)
  6772. {
  6773. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6774. {
  6775. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6776. AgentSit handlerOnRedo = OnRedo;
  6777. if (handlerOnRedo != null)
  6778. {
  6779. handlerOnRedo(this, objiD);
  6780. }
  6781. }
  6782. }
  6783. return true;
  6784. }
  6785. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6786. {
  6787. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6788. #region Packet Session and User Check
  6789. if (m_checkPackets)
  6790. {
  6791. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6792. dupeOnRay.AgentData.AgentID != AgentId)
  6793. return true;
  6794. }
  6795. #endregion
  6796. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6797. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6798. {
  6799. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6800. if (handlerObjectDuplicateOnRay != null)
  6801. {
  6802. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6803. AgentId, ActiveGroupId, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6804. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6805. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6806. }
  6807. }
  6808. return true;
  6809. }
  6810. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6811. {
  6812. //This powers the little tooltip that appears when you move your mouse over an object
  6813. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6814. #region Packet Session and User Check
  6815. if (m_checkPackets)
  6816. {
  6817. if (packToolTip.AgentData.SessionID != SessionId ||
  6818. packToolTip.AgentData.AgentID != AgentId)
  6819. return true;
  6820. }
  6821. #endregion
  6822. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6823. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6824. if (handlerRequestObjectPropertiesFamily != null)
  6825. {
  6826. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6827. packObjBlock.ObjectID);
  6828. }
  6829. return true;
  6830. }
  6831. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6832. {
  6833. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6834. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6835. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6836. #region Packet Session and User Check
  6837. if (m_checkPackets)
  6838. {
  6839. if (packInSearch.AgentData.SessionID != SessionId ||
  6840. packInSearch.AgentData.AgentID != AgentId)
  6841. return true;
  6842. }
  6843. #endregion
  6844. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6845. {
  6846. bool inSearch = objData.IncludeInSearch;
  6847. uint localID = objData.ObjectLocalID;
  6848. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6849. if (handlerObjectIncludeInSearch != null)
  6850. {
  6851. handlerObjectIncludeInSearch(this, inSearch, localID);
  6852. }
  6853. }
  6854. return true;
  6855. }
  6856. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6857. {
  6858. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6859. #region Packet Session and User Check
  6860. if (m_checkPackets)
  6861. {
  6862. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6863. scriptAnswer.AgentData.AgentID != AgentId)
  6864. return true;
  6865. }
  6866. #endregion
  6867. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6868. if (handlerScriptAnswer != null)
  6869. {
  6870. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6871. }
  6872. return true;
  6873. }
  6874. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6875. {
  6876. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6877. #region Packet Session and User Check
  6878. if (m_checkPackets)
  6879. {
  6880. if (ocpacket.AgentData.SessionID != SessionId ||
  6881. ocpacket.AgentData.AgentID != AgentId)
  6882. return true;
  6883. }
  6884. #endregion
  6885. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6886. if (handlerObjectClickAction != null)
  6887. {
  6888. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6889. {
  6890. byte action = odata.ClickAction;
  6891. uint localID = odata.ObjectLocalID;
  6892. handlerObjectClickAction(this, localID, action.ToString());
  6893. }
  6894. }
  6895. return true;
  6896. }
  6897. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6898. {
  6899. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6900. #region Packet Session and User Check
  6901. if (m_checkPackets)
  6902. {
  6903. if (ompacket.AgentData.SessionID != SessionId ||
  6904. ompacket.AgentData.AgentID != AgentId)
  6905. return true;
  6906. }
  6907. #endregion
  6908. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6909. if (handlerObjectMaterial != null)
  6910. {
  6911. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6912. {
  6913. byte material = odata.Material;
  6914. uint localID = odata.ObjectLocalID;
  6915. handlerObjectMaterial(this, localID, material.ToString());
  6916. }
  6917. }
  6918. return true;
  6919. }
  6920. #endregion Objects/m_sceneObjects
  6921. #region Inventory/Asset/Other related packets
  6922. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6923. {
  6924. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6925. //m_log.Debug("image request: " + Pack.ToString());
  6926. #region Packet Session and User Check
  6927. if (m_checkPackets)
  6928. {
  6929. if (imageRequest.AgentData.SessionID != SessionId ||
  6930. imageRequest.AgentData.AgentID != AgentId)
  6931. return true;
  6932. }
  6933. #endregion
  6934. //handlerTextureRequest = null;
  6935. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6936. {
  6937. TextureRequestArgs args = new TextureRequestArgs();
  6938. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6939. args.RequestedAssetID = block.Image;
  6940. args.DiscardLevel = block.DiscardLevel;
  6941. args.PacketNumber = block.Packet;
  6942. args.Priority = block.DownloadPriority;
  6943. args.requestSequence = imageRequest.Header.Sequence;
  6944. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6945. // priority of avatar textures to get avatars rezzing in faster than the
  6946. // surrounding scene
  6947. if ((ImageType)block.Type == ImageType.Baked)
  6948. args.Priority *= 2.0f;
  6949. ImageManager.EnqueueReq(args);
  6950. }
  6951. return true;
  6952. }
  6953. /// <summary>
  6954. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6955. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6956. /// </summary>
  6957. /// <param name="sender"></param>
  6958. /// <param name="Pack"></param>
  6959. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6960. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6961. {
  6962. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6963. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6964. UUID taskID = UUID.Zero;
  6965. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6966. {
  6967. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6968. {
  6969. // We're spawning a thread because the permissions check can block this thread
  6970. Util.FireAndForget(delegate
  6971. {
  6972. // This requests the asset if needed
  6973. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6974. }, null, "LLClientView.HandleTransferRequest");
  6975. return true;
  6976. }
  6977. }
  6978. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6979. {
  6980. //TransferRequestPacket does not include covenant uuid?
  6981. //get scene covenant uuid
  6982. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6983. }
  6984. // This is non-blocking
  6985. MakeAssetRequest(transfer, taskID);
  6986. return true;
  6987. }
  6988. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6989. {
  6990. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6991. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6992. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6993. //m_log.DebugFormat(
  6994. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6995. // requestID, itemID, taskID, Name);
  6996. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6997. // Validate inventory transfers
  6998. // Has to be done here, because AssetCache can't do it
  6999. //
  7000. if (taskID != UUID.Zero) // Prim
  7001. {
  7002. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  7003. if (part == null)
  7004. {
  7005. m_log.WarnFormat(
  7006. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  7007. Name, requestID, itemID, taskID);
  7008. return;
  7009. }
  7010. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  7011. if (tii == null)
  7012. {
  7013. m_log.WarnFormat(
  7014. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  7015. Name, requestID, itemID, taskID);
  7016. return;
  7017. }
  7018. if (tii.Type == (int)AssetType.LSLText)
  7019. {
  7020. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  7021. return;
  7022. }
  7023. else if (tii.Type == (int)AssetType.Notecard)
  7024. {
  7025. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  7026. return;
  7027. }
  7028. else
  7029. {
  7030. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  7031. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  7032. if (part.OwnerID != AgentId)
  7033. {
  7034. m_log.WarnFormat(
  7035. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  7036. Name, requestID, itemID, taskID, part.OwnerID);
  7037. return;
  7038. }
  7039. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  7040. {
  7041. m_log.WarnFormat(
  7042. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  7043. Name, requestID, itemID, taskID);
  7044. return;
  7045. }
  7046. if (tii.OwnerID != AgentId)
  7047. {
  7048. m_log.WarnFormat(
  7049. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  7050. Name, requestID, itemID, taskID, tii.OwnerID);
  7051. return;
  7052. }
  7053. if ((
  7054. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  7055. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  7056. {
  7057. m_log.WarnFormat(
  7058. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  7059. Name, requestID, itemID, taskID);
  7060. return;
  7061. }
  7062. if (tii.AssetID != requestID)
  7063. {
  7064. m_log.WarnFormat(
  7065. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  7066. Name, requestID, itemID, taskID, tii.AssetID);
  7067. return;
  7068. }
  7069. }
  7070. }
  7071. else // Agent
  7072. {
  7073. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  7074. if (invAccess != null)
  7075. {
  7076. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  7077. return;
  7078. }
  7079. else
  7080. {
  7081. return;
  7082. }
  7083. }
  7084. // Permissions out of the way, let's request the asset
  7085. MakeAssetRequest(transfer, taskID);
  7086. }
  7087. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  7088. {
  7089. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  7090. // m_log.Debug("upload request " + request.ToString());
  7091. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  7092. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  7093. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  7094. if (handlerAssetUploadRequest != null)
  7095. {
  7096. handlerAssetUploadRequest(this, temp,
  7097. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  7098. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  7099. request.AssetBlock.Tempfile);
  7100. }
  7101. return true;
  7102. }
  7103. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  7104. {
  7105. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  7106. RequestXfer handlerRequestXfer = OnRequestXfer;
  7107. if (handlerRequestXfer != null)
  7108. {
  7109. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  7110. }
  7111. return true;
  7112. }
  7113. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  7114. {
  7115. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  7116. XferReceive handlerXferReceive = OnXferReceive;
  7117. if (handlerXferReceive != null)
  7118. {
  7119. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  7120. }
  7121. return true;
  7122. }
  7123. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  7124. {
  7125. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  7126. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  7127. if (handlerConfirmXfer != null)
  7128. {
  7129. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  7130. }
  7131. return true;
  7132. }
  7133. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  7134. {
  7135. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  7136. AbortXfer handlerAbortXfer = OnAbortXfer;
  7137. if (handlerAbortXfer != null)
  7138. {
  7139. handlerAbortXfer(this, abortXfer.XferID.ID);
  7140. }
  7141. return true;
  7142. }
  7143. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7144. {
  7145. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7146. #region Packet Session and User Check
  7147. if (m_checkPackets)
  7148. {
  7149. if (invFolder.AgentData.SessionID != SessionId ||
  7150. invFolder.AgentData.AgentID != AgentId)
  7151. return true;
  7152. }
  7153. #endregion
  7154. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7155. if (handlerCreateInventoryFolder != null)
  7156. {
  7157. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7158. (ushort)invFolder.FolderData.Type,
  7159. Util.FieldToString(invFolder.FolderData.Name),
  7160. invFolder.FolderData.ParentID);
  7161. }
  7162. return true;
  7163. }
  7164. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7165. {
  7166. if (OnUpdateInventoryFolder != null)
  7167. {
  7168. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7169. #region Packet Session and User Check
  7170. if (m_checkPackets)
  7171. {
  7172. if (invFolderx.AgentData.SessionID != SessionId ||
  7173. invFolderx.AgentData.AgentID != AgentId)
  7174. return true;
  7175. }
  7176. #endregion
  7177. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7178. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7179. {
  7180. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7181. if (handlerUpdateInventoryFolder != null)
  7182. {
  7183. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7184. (ushort)invFolderx.FolderData[i].Type,
  7185. Util.FieldToString(invFolderx.FolderData[i].Name),
  7186. invFolderx.FolderData[i].ParentID);
  7187. }
  7188. }
  7189. }
  7190. return true;
  7191. }
  7192. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7193. {
  7194. if (OnMoveInventoryFolder != null)
  7195. {
  7196. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7197. #region Packet Session and User Check
  7198. if (m_checkPackets)
  7199. {
  7200. if (invFoldery.AgentData.SessionID != SessionId ||
  7201. invFoldery.AgentData.AgentID != AgentId)
  7202. return true;
  7203. }
  7204. #endregion
  7205. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7206. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7207. {
  7208. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7209. if (handlerMoveInventoryFolder != null)
  7210. {
  7211. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7212. invFoldery.InventoryData[i].ParentID);
  7213. }
  7214. }
  7215. }
  7216. return true;
  7217. }
  7218. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7219. {
  7220. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7221. #region Packet Session and User Check
  7222. if (m_checkPackets)
  7223. {
  7224. if (createItem.AgentData.SessionID != SessionId ||
  7225. createItem.AgentData.AgentID != AgentId)
  7226. return true;
  7227. }
  7228. #endregion
  7229. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7230. if (handlerCreateNewInventoryItem != null)
  7231. {
  7232. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7233. createItem.InventoryBlock.FolderID,
  7234. createItem.InventoryBlock.CallbackID,
  7235. Util.FieldToString(createItem.InventoryBlock.Description),
  7236. Util.FieldToString(createItem.InventoryBlock.Name),
  7237. createItem.InventoryBlock.InvType,
  7238. createItem.InventoryBlock.Type,
  7239. createItem.InventoryBlock.WearableType,
  7240. createItem.InventoryBlock.NextOwnerMask,
  7241. Util.UnixTimeSinceEpoch());
  7242. }
  7243. return true;
  7244. }
  7245. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7246. {
  7247. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7248. #region Packet Session and User Check
  7249. if (m_checkPackets)
  7250. {
  7251. if (createLink.AgentData.SessionID != SessionId ||
  7252. createLink.AgentData.AgentID != AgentId)
  7253. return true;
  7254. }
  7255. #endregion
  7256. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7257. if (linkInventoryItem != null)
  7258. {
  7259. linkInventoryItem(
  7260. this,
  7261. createLink.InventoryBlock.TransactionID,
  7262. createLink.InventoryBlock.FolderID,
  7263. createLink.InventoryBlock.CallbackID,
  7264. Util.FieldToString(createLink.InventoryBlock.Description),
  7265. Util.FieldToString(createLink.InventoryBlock.Name),
  7266. createLink.InventoryBlock.InvType,
  7267. createLink.InventoryBlock.Type,
  7268. createLink.InventoryBlock.OldItemID);
  7269. }
  7270. return true;
  7271. }
  7272. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7273. {
  7274. if (OnFetchInventory != null)
  7275. {
  7276. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7277. #region Packet Session and User Check
  7278. if (m_checkPackets)
  7279. {
  7280. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7281. FetchInventoryx.AgentData.AgentID != AgentId)
  7282. return true;
  7283. }
  7284. #endregion
  7285. FetchInventory handlerFetchInventory = null;
  7286. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7287. {
  7288. handlerFetchInventory = OnFetchInventory;
  7289. if (handlerFetchInventory != null)
  7290. {
  7291. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7292. FetchInventoryx.InventoryData[i].OwnerID);
  7293. }
  7294. }
  7295. }
  7296. return true;
  7297. }
  7298. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7299. {
  7300. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7301. #region Packet Session and User Check
  7302. if (m_checkPackets)
  7303. {
  7304. if (Fetch.AgentData.SessionID != SessionId ||
  7305. Fetch.AgentData.AgentID != AgentId)
  7306. return true;
  7307. }
  7308. #endregion
  7309. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7310. if (handlerFetchInventoryDescendents != null)
  7311. {
  7312. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7313. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7314. Fetch.InventoryData.SortOrder);
  7315. }
  7316. return true;
  7317. }
  7318. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7319. {
  7320. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7321. #region Packet Session and User Check
  7322. if (m_checkPackets)
  7323. {
  7324. if (Purge.AgentData.SessionID != SessionId ||
  7325. Purge.AgentData.AgentID != AgentId)
  7326. return true;
  7327. }
  7328. #endregion
  7329. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7330. if (handlerPurgeInventoryDescendents != null)
  7331. {
  7332. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7333. }
  7334. return true;
  7335. }
  7336. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7337. {
  7338. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7339. #region Packet Session and User Check
  7340. if (m_checkPackets)
  7341. {
  7342. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7343. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7344. return true;
  7345. }
  7346. #endregion
  7347. if (OnUpdateInventoryItem != null)
  7348. {
  7349. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7350. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7351. {
  7352. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7353. if (handlerUpdateInventoryItem != null)
  7354. {
  7355. InventoryItemBase itemUpd = new InventoryItemBase();
  7356. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7357. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7358. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7359. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7360. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7361. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7362. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7363. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7364. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7365. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7366. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7367. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7368. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7369. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7370. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7371. inventoryItemUpdate.InventoryData[i].ItemID,
  7372. itemUpd);
  7373. }
  7374. }
  7375. }
  7376. return true;
  7377. }
  7378. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7379. {
  7380. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7381. #region Packet Session and User Check
  7382. if (m_checkPackets)
  7383. {
  7384. if (copyitem.AgentData.SessionID != SessionId ||
  7385. copyitem.AgentData.AgentID != AgentId)
  7386. return true;
  7387. }
  7388. #endregion
  7389. CopyInventoryItem handlerCopyInventoryItem = null;
  7390. if (OnCopyInventoryItem != null)
  7391. {
  7392. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7393. {
  7394. handlerCopyInventoryItem = OnCopyInventoryItem;
  7395. if (handlerCopyInventoryItem != null)
  7396. {
  7397. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7398. datablock.OldItemID, datablock.NewFolderID,
  7399. Util.FieldToString(datablock.NewName));
  7400. }
  7401. }
  7402. }
  7403. return true;
  7404. }
  7405. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7406. {
  7407. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7408. #region Packet Session and User Check
  7409. if (m_checkPackets)
  7410. {
  7411. if (moveitem.AgentData.SessionID != SessionId ||
  7412. moveitem.AgentData.AgentID != AgentId)
  7413. return true;
  7414. }
  7415. #endregion
  7416. if (OnMoveInventoryItem != null)
  7417. {
  7418. MoveInventoryItem handlerMoveInventoryItem = null;
  7419. InventoryItemBase itm = null;
  7420. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7421. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7422. {
  7423. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7424. itm.Folder = datablock.FolderID;
  7425. itm.Name = Util.FieldToString(datablock.NewName);
  7426. // weird, comes out as empty string
  7427. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7428. items.Add(itm);
  7429. }
  7430. handlerMoveInventoryItem = OnMoveInventoryItem;
  7431. if (handlerMoveInventoryItem != null)
  7432. {
  7433. handlerMoveInventoryItem(this, items);
  7434. }
  7435. }
  7436. return true;
  7437. }
  7438. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7439. {
  7440. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7441. #region Packet Session and User Check
  7442. if (m_checkPackets)
  7443. {
  7444. if (removeItem.AgentData.SessionID != SessionId ||
  7445. removeItem.AgentData.AgentID != AgentId)
  7446. return true;
  7447. }
  7448. #endregion
  7449. if (OnRemoveInventoryItem != null)
  7450. {
  7451. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7452. List<UUID> uuids = new List<UUID>();
  7453. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7454. {
  7455. uuids.Add(datablock.ItemID);
  7456. }
  7457. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7458. if (handlerRemoveInventoryItem != null)
  7459. {
  7460. handlerRemoveInventoryItem(this, uuids);
  7461. }
  7462. }
  7463. return true;
  7464. }
  7465. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7466. {
  7467. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7468. #region Packet Session and User Check
  7469. if (m_checkPackets)
  7470. {
  7471. if (removeFolder.AgentData.SessionID != SessionId ||
  7472. removeFolder.AgentData.AgentID != AgentId)
  7473. return true;
  7474. }
  7475. #endregion
  7476. if (OnRemoveInventoryFolder != null)
  7477. {
  7478. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7479. List<UUID> uuids = new List<UUID>();
  7480. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7481. {
  7482. uuids.Add(datablock.FolderID);
  7483. }
  7484. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7485. if (handlerRemoveInventoryFolder != null)
  7486. {
  7487. handlerRemoveInventoryFolder(this, uuids);
  7488. }
  7489. }
  7490. return true;
  7491. }
  7492. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7493. {
  7494. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7495. #region Packet Session and User Check
  7496. if (m_checkPackets)
  7497. {
  7498. if (removeObject.AgentData.SessionID != SessionId ||
  7499. removeObject.AgentData.AgentID != AgentId)
  7500. return true;
  7501. }
  7502. #endregion
  7503. if (OnRemoveInventoryFolder != null)
  7504. {
  7505. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7506. List<UUID> uuids = new List<UUID>();
  7507. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7508. {
  7509. uuids.Add(datablock.FolderID);
  7510. }
  7511. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7512. if (handlerRemoveInventoryFolder != null)
  7513. {
  7514. handlerRemoveInventoryFolder(this, uuids);
  7515. }
  7516. }
  7517. if (OnRemoveInventoryItem != null)
  7518. {
  7519. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7520. List<UUID> uuids = new List<UUID>();
  7521. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7522. {
  7523. uuids.Add(datablock.ItemID);
  7524. }
  7525. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7526. if (handlerRemoveInventoryItem != null)
  7527. {
  7528. handlerRemoveInventoryItem(this, uuids);
  7529. }
  7530. }
  7531. return true;
  7532. }
  7533. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7534. {
  7535. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7536. #region Packet Session and User Check
  7537. if (m_checkPackets)
  7538. {
  7539. if (requesttask.AgentData.SessionID != SessionId ||
  7540. requesttask.AgentData.AgentID != AgentId)
  7541. return true;
  7542. }
  7543. #endregion
  7544. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7545. if (handlerRequestTaskInventory != null)
  7546. {
  7547. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7548. }
  7549. return true;
  7550. }
  7551. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7552. {
  7553. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7554. #region Packet Session and User Check
  7555. if (m_checkPackets)
  7556. {
  7557. if (updatetask.AgentData.SessionID != SessionId ||
  7558. updatetask.AgentData.AgentID != AgentId)
  7559. return true;
  7560. }
  7561. #endregion
  7562. if (OnUpdateTaskInventory != null)
  7563. {
  7564. if (updatetask.UpdateData.Key == 0)
  7565. {
  7566. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7567. if (handlerUpdateTaskInventory != null)
  7568. {
  7569. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7570. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7571. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7572. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7573. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7574. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7575. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7576. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7577. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7578. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7579. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7580. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7581. // different
  7582. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7583. newTaskItem.Type = updatetask.InventoryData.Type;
  7584. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7585. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7586. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7587. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7588. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7589. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7590. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7591. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7592. newTaskItem, updatetask.UpdateData.LocalID);
  7593. }
  7594. }
  7595. }
  7596. return true;
  7597. }
  7598. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7599. {
  7600. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7601. #region Packet Session and User Check
  7602. if (m_checkPackets)
  7603. {
  7604. if (removeTask.AgentData.SessionID != SessionId ||
  7605. removeTask.AgentData.AgentID != AgentId)
  7606. return true;
  7607. }
  7608. #endregion
  7609. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7610. if (handlerRemoveTaskItem != null)
  7611. {
  7612. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7613. }
  7614. return true;
  7615. }
  7616. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7617. {
  7618. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7619. #region Packet Session and User Check
  7620. if (m_checkPackets)
  7621. {
  7622. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7623. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7624. return true;
  7625. }
  7626. #endregion
  7627. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7628. if (handlerMoveTaskItem != null)
  7629. {
  7630. handlerMoveTaskItem(
  7631. this, moveTaskInventoryPacket.AgentData.FolderID,
  7632. moveTaskInventoryPacket.InventoryData.LocalID,
  7633. moveTaskInventoryPacket.InventoryData.ItemID);
  7634. }
  7635. return true;
  7636. }
  7637. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7638. {
  7639. //m_log.Debug(Pack.ToString());
  7640. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7641. #region Packet Session and User Check
  7642. if (m_checkPackets)
  7643. {
  7644. if (rezScriptx.AgentData.SessionID != SessionId ||
  7645. rezScriptx.AgentData.AgentID != AgentId)
  7646. return true;
  7647. }
  7648. #endregion
  7649. RezScript handlerRezScript = OnRezScript;
  7650. InventoryItemBase item = new InventoryItemBase();
  7651. item.ID = rezScriptx.InventoryBlock.ItemID;
  7652. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7653. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7654. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7655. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7656. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7657. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7658. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7659. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7660. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7661. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7662. item.AssetType = rezScriptx.InventoryBlock.Type;
  7663. item.InvType = rezScriptx.InventoryBlock.InvType;
  7664. item.Flags = rezScriptx.InventoryBlock.Flags;
  7665. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7666. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7667. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7668. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7669. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7670. if (handlerRezScript != null)
  7671. {
  7672. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7673. }
  7674. return true;
  7675. }
  7676. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7677. {
  7678. RequestMapLayer();
  7679. return true;
  7680. }
  7681. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7682. {
  7683. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7684. #region Packet Session and User Check
  7685. if (m_checkPackets)
  7686. {
  7687. if (MapRequest.AgentData.SessionID != SessionId ||
  7688. MapRequest.AgentData.AgentID != AgentId)
  7689. return true;
  7690. }
  7691. #endregion
  7692. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7693. if (handlerRequestMapBlocks != null)
  7694. {
  7695. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7696. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7697. }
  7698. return true;
  7699. }
  7700. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7701. {
  7702. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7703. #region Packet Session and User Check
  7704. if (m_checkPackets)
  7705. {
  7706. if (map.AgentData.SessionID != SessionId ||
  7707. map.AgentData.AgentID != AgentId)
  7708. return true;
  7709. }
  7710. #endregion
  7711. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7712. map.NameData.Name.Length - 1);
  7713. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7714. if (handlerMapNameRequest != null)
  7715. {
  7716. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7717. }
  7718. return true;
  7719. }
  7720. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7721. {
  7722. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7723. #region Packet Session and User Check
  7724. if (m_checkPackets)
  7725. {
  7726. if (tpReq.Info.SessionID != SessionId ||
  7727. tpReq.Info.AgentID != AgentId)
  7728. return true;
  7729. }
  7730. #endregion
  7731. UUID lmid = tpReq.Info.LandmarkID;
  7732. AssetLandmark lm;
  7733. if (lmid != UUID.Zero)
  7734. {
  7735. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7736. AssetBase lma = m_assetService.Get(lmid.ToString());
  7737. if (lma == null)
  7738. {
  7739. // Failed to find landmark
  7740. // Let's try to search in the user's home asset server
  7741. lma = FindAssetInUserAssetServer(lmid.ToString());
  7742. if (lma == null)
  7743. {
  7744. // Really doesn't exist
  7745. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7746. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7747. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7748. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7749. }
  7750. }
  7751. try
  7752. {
  7753. lm = new AssetLandmark(lma);
  7754. }
  7755. catch (NullReferenceException)
  7756. {
  7757. // asset not found generates null ref inside the assetlandmark constructor.
  7758. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7759. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7760. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7761. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7762. return true;
  7763. }
  7764. }
  7765. else
  7766. {
  7767. // Teleport home request
  7768. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7769. if (handlerTeleportHomeRequest != null)
  7770. {
  7771. handlerTeleportHomeRequest(AgentId, this);
  7772. }
  7773. return true;
  7774. }
  7775. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7776. if (handlerTeleportLandmarkRequest != null)
  7777. {
  7778. handlerTeleportLandmarkRequest(this, lm);
  7779. }
  7780. else
  7781. {
  7782. //no event handler so cancel request
  7783. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7784. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7785. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7786. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7787. }
  7788. return true;
  7789. }
  7790. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7791. {
  7792. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7793. if (handlerTeleportCancel != null)
  7794. {
  7795. handlerTeleportCancel(this);
  7796. }
  7797. return true;
  7798. }
  7799. private AssetBase FindAssetInUserAssetServer(string id)
  7800. {
  7801. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7802. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7803. {
  7804. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7805. if (!string.IsNullOrEmpty(assetServer))
  7806. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7807. }
  7808. return null;
  7809. }
  7810. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7811. {
  7812. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7813. // m_log.Debug(tpLocReq.ToString());
  7814. #region Packet Session and User Check
  7815. if (m_checkPackets)
  7816. {
  7817. if (tpLocReq.AgentData.SessionID != SessionId ||
  7818. tpLocReq.AgentData.AgentID != AgentId)
  7819. return true;
  7820. }
  7821. #endregion
  7822. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7823. if (handlerTeleportLocationRequest != null)
  7824. {
  7825. // Adjust teleport location to base of a larger region if requested to teleport to a sub-region
  7826. uint locX, locY;
  7827. Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out locX, out locY);
  7828. if ((locX >= m_scene.RegionInfo.WorldLocX)
  7829. && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX))
  7830. && (locY >= m_scene.RegionInfo.WorldLocY)
  7831. && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)) )
  7832. {
  7833. tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle;
  7834. tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX;
  7835. tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY;
  7836. }
  7837. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7838. tpLocReq.Info.LookAt, 16);
  7839. }
  7840. else
  7841. {
  7842. //no event handler so cancel request
  7843. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7844. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7845. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7846. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7847. }
  7848. return true;
  7849. }
  7850. #endregion Inventory/Asset/Other related packets
  7851. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7852. {
  7853. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7854. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7855. {
  7856. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7857. if (handlerNameRequest != null)
  7858. {
  7859. handlerNameRequest(UUIDBlock.ID, this);
  7860. }
  7861. }
  7862. return true;
  7863. }
  7864. #region Parcel related packets
  7865. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7866. {
  7867. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7868. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7869. if (handlerRegionHandleRequest != null)
  7870. {
  7871. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7872. }
  7873. return true;
  7874. }
  7875. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7876. {
  7877. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7878. #region Packet Session and User Check
  7879. if (m_checkPackets)
  7880. {
  7881. if (pirPack.AgentData.SessionID != SessionId ||
  7882. pirPack.AgentData.AgentID != AgentId)
  7883. return true;
  7884. }
  7885. #endregion
  7886. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7887. if (handlerParcelInfoRequest != null)
  7888. {
  7889. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7890. }
  7891. return true;
  7892. }
  7893. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7894. {
  7895. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7896. #region Packet Session and User Check
  7897. if (m_checkPackets)
  7898. {
  7899. if (requestPacket.AgentData.SessionID != SessionId ||
  7900. requestPacket.AgentData.AgentID != AgentId)
  7901. return true;
  7902. }
  7903. #endregion
  7904. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7905. if (handlerParcelAccessListRequest != null)
  7906. {
  7907. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7908. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7909. requestPacket.Data.LocalID, this);
  7910. }
  7911. return true;
  7912. }
  7913. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7914. {
  7915. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7916. #region Packet Session and User Check
  7917. if (m_checkPackets)
  7918. {
  7919. if (updatePacket.AgentData.SessionID != SessionId ||
  7920. updatePacket.AgentData.AgentID != AgentId)
  7921. return true;
  7922. }
  7923. #endregion
  7924. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7925. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7926. {
  7927. LandAccessEntry entry = new LandAccessEntry();
  7928. entry.AgentID = block.ID;
  7929. entry.Flags = (AccessList)block.Flags;
  7930. entry.Expires = block.Time;
  7931. entries.Add(entry);
  7932. }
  7933. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7934. if (handlerParcelAccessListUpdateRequest != null)
  7935. {
  7936. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7937. updatePacket.Data.Flags,
  7938. updatePacket.Data.LocalID,
  7939. updatePacket.Data.TransactionID,
  7940. updatePacket.Data.SequenceID,
  7941. updatePacket.Data.Sections,
  7942. entries, this);
  7943. }
  7944. return true;
  7945. }
  7946. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7947. {
  7948. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7949. #region Packet Session and User Check
  7950. if (m_checkPackets)
  7951. {
  7952. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7953. propertiesRequest.AgentData.AgentID != AgentId)
  7954. return true;
  7955. }
  7956. #endregion
  7957. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7958. if (handlerParcelPropertiesRequest != null)
  7959. {
  7960. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7961. (int)Math.Round(propertiesRequest.ParcelData.South),
  7962. (int)Math.Round(propertiesRequest.ParcelData.East),
  7963. (int)Math.Round(propertiesRequest.ParcelData.North),
  7964. propertiesRequest.ParcelData.SequenceID,
  7965. propertiesRequest.ParcelData.SnapSelection, this);
  7966. }
  7967. return true;
  7968. }
  7969. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7970. {
  7971. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7972. #region Packet Session and User Check
  7973. if (m_checkPackets)
  7974. {
  7975. if (landDivide.AgentData.SessionID != SessionId ||
  7976. landDivide.AgentData.AgentID != AgentId)
  7977. return true;
  7978. }
  7979. #endregion
  7980. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7981. if (handlerParcelDivideRequest != null)
  7982. {
  7983. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7984. (int)Math.Round(landDivide.ParcelData.South),
  7985. (int)Math.Round(landDivide.ParcelData.East),
  7986. (int)Math.Round(landDivide.ParcelData.North), this);
  7987. }
  7988. return true;
  7989. }
  7990. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7991. {
  7992. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7993. #region Packet Session and User Check
  7994. if (m_checkPackets)
  7995. {
  7996. if (landJoin.AgentData.SessionID != SessionId ||
  7997. landJoin.AgentData.AgentID != AgentId)
  7998. return true;
  7999. }
  8000. #endregion
  8001. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  8002. if (handlerParcelJoinRequest != null)
  8003. {
  8004. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  8005. (int)Math.Round(landJoin.ParcelData.South),
  8006. (int)Math.Round(landJoin.ParcelData.East),
  8007. (int)Math.Round(landJoin.ParcelData.North), this);
  8008. }
  8009. return true;
  8010. }
  8011. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  8012. {
  8013. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  8014. #region Packet Session and User Check
  8015. if (m_checkPackets)
  8016. {
  8017. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  8018. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  8019. return true;
  8020. }
  8021. #endregion
  8022. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  8023. if (handlerParcelPropertiesUpdateRequest != null)
  8024. {
  8025. LandUpdateArgs args = new LandUpdateArgs();
  8026. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  8027. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  8028. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  8029. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  8030. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  8031. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  8032. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  8033. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  8034. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  8035. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  8036. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  8037. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  8038. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  8039. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  8040. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  8041. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  8042. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  8043. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  8044. }
  8045. return true;
  8046. }
  8047. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  8048. {
  8049. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  8050. #region Packet Session and User Check
  8051. if (m_checkPackets)
  8052. {
  8053. if (selectPacket.AgentData.SessionID != SessionId ||
  8054. selectPacket.AgentData.AgentID != AgentId)
  8055. return true;
  8056. }
  8057. #endregion
  8058. List<UUID> returnIDs = new List<UUID>();
  8059. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  8060. selectPacket.ReturnIDs)
  8061. {
  8062. returnIDs.Add(rb.ReturnID);
  8063. }
  8064. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  8065. if (handlerParcelSelectObjects != null)
  8066. {
  8067. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  8068. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  8069. }
  8070. return true;
  8071. }
  8072. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  8073. {
  8074. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  8075. #region Packet Session and User Check
  8076. if (m_checkPackets)
  8077. {
  8078. if (reqPacket.AgentData.SessionID != SessionId ||
  8079. reqPacket.AgentData.AgentID != AgentId)
  8080. return true;
  8081. }
  8082. #endregion
  8083. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  8084. if (handlerParcelObjectOwnerRequest != null)
  8085. {
  8086. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  8087. }
  8088. return true;
  8089. }
  8090. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  8091. {
  8092. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  8093. #region Packet Session and User Check
  8094. if (m_checkPackets)
  8095. {
  8096. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  8097. godForceOwnerPacket.AgentData.AgentID != AgentId)
  8098. return true;
  8099. }
  8100. #endregion
  8101. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  8102. if (handlerParcelGodForceOwner != null)
  8103. {
  8104. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  8105. }
  8106. return true;
  8107. }
  8108. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  8109. {
  8110. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  8111. #region Packet Session and User Check
  8112. if (m_checkPackets)
  8113. {
  8114. if (releasePacket.AgentData.SessionID != SessionId ||
  8115. releasePacket.AgentData.AgentID != AgentId)
  8116. return true;
  8117. }
  8118. #endregion
  8119. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  8120. if (handlerParcelAbandonRequest != null)
  8121. {
  8122. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  8123. }
  8124. return true;
  8125. }
  8126. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  8127. {
  8128. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  8129. #region Packet Session and User Check
  8130. if (m_checkPackets)
  8131. {
  8132. if (reclaimPacket.AgentData.SessionID != SessionId ||
  8133. reclaimPacket.AgentData.AgentID != AgentId)
  8134. return true;
  8135. }
  8136. #endregion
  8137. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  8138. if (handlerParcelReclaim != null)
  8139. {
  8140. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  8141. }
  8142. return true;
  8143. }
  8144. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  8145. {
  8146. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  8147. #region Packet Session and User Check
  8148. if (m_checkPackets)
  8149. {
  8150. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  8151. parcelReturnObjects.AgentData.AgentID != AgentId)
  8152. return true;
  8153. }
  8154. #endregion
  8155. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8156. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8157. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8158. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8159. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8160. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8161. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8162. if (handlerParcelReturnObjectsRequest != null)
  8163. {
  8164. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8165. }
  8166. return true;
  8167. }
  8168. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8169. {
  8170. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8171. #region Packet Session and User Check
  8172. if (m_checkPackets)
  8173. {
  8174. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8175. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8176. return true;
  8177. }
  8178. #endregion
  8179. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8180. if (handlerParcelSetOtherCleanTime != null)
  8181. {
  8182. handlerParcelSetOtherCleanTime(this,
  8183. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8184. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8185. }
  8186. return true;
  8187. }
  8188. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8189. {
  8190. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8191. #region Packet Session and User Check
  8192. if (m_checkPackets)
  8193. {
  8194. if (lsrp.AgentData.SessionID != SessionId ||
  8195. lsrp.AgentData.AgentID != AgentId)
  8196. return true;
  8197. }
  8198. #endregion
  8199. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8200. if (handlerLandStatRequest != null)
  8201. {
  8202. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8203. }
  8204. return true;
  8205. }
  8206. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8207. {
  8208. ParcelDwellRequestPacket dwellrq =
  8209. (ParcelDwellRequestPacket)Pack;
  8210. #region Packet Session and User Check
  8211. if (m_checkPackets)
  8212. {
  8213. if (dwellrq.AgentData.SessionID != SessionId ||
  8214. dwellrq.AgentData.AgentID != AgentId)
  8215. return true;
  8216. }
  8217. #endregion
  8218. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8219. if (handlerParcelDwellRequest != null)
  8220. {
  8221. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8222. }
  8223. return true;
  8224. }
  8225. #endregion Parcel related packets
  8226. #region Estate Packets
  8227. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8228. {
  8229. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8230. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8231. GodLandStatRequest handlerLandStatRequest;
  8232. #region Packet Session and User Check
  8233. if (m_checkPackets)
  8234. {
  8235. if (messagePacket.AgentData.SessionID != SessionId ||
  8236. messagePacket.AgentData.AgentID != AgentId)
  8237. return true;
  8238. }
  8239. #endregion
  8240. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8241. switch (method)
  8242. {
  8243. case "getinfo":
  8244. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8245. {
  8246. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8247. }
  8248. return true;
  8249. case "setregioninfo":
  8250. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8251. {
  8252. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8253. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8254. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8255. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8256. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8257. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8258. }
  8259. return true;
  8260. // case "texturebase":
  8261. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8262. // {
  8263. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8264. // {
  8265. // string s = Utils.BytesToString(block.Parameter);
  8266. // string[] splitField = s.Split(' ');
  8267. // if (splitField.Length == 2)
  8268. // {
  8269. // UUID tempUUID = new UUID(splitField[1]);
  8270. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8271. // }
  8272. // }
  8273. // }
  8274. // break;
  8275. case "texturedetail":
  8276. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8277. {
  8278. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8279. {
  8280. string s = Utils.BytesToString(block.Parameter);
  8281. string[] splitField = s.Split(' ');
  8282. if (splitField.Length == 2)
  8283. {
  8284. Int16 corner = Convert.ToInt16(splitField[0]);
  8285. UUID textureUUID = new UUID(splitField[1]);
  8286. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8287. }
  8288. }
  8289. }
  8290. return true;
  8291. case "textureheights":
  8292. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8293. {
  8294. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8295. {
  8296. string s = Utils.BytesToString(block.Parameter);
  8297. string[] splitField = s.Split(' ');
  8298. if (splitField.Length == 3)
  8299. {
  8300. Int16 corner = Convert.ToInt16(splitField[0]);
  8301. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8302. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8303. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8304. }
  8305. }
  8306. }
  8307. return true;
  8308. case "texturecommit":
  8309. OnCommitEstateTerrainTextureRequest(this);
  8310. return true;
  8311. case "setregionterrain":
  8312. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8313. {
  8314. if (messagePacket.ParamList.Length != 9)
  8315. {
  8316. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8317. }
  8318. else
  8319. {
  8320. try
  8321. {
  8322. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8323. if (!tmp.Contains(".")) tmp += ".00";
  8324. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8325. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8326. if (!tmp.Contains(".")) tmp += ".00";
  8327. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8328. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8329. if (!tmp.Contains(".")) tmp += ".00";
  8330. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8331. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8332. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8333. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8334. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8335. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8336. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8337. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8338. }
  8339. catch (Exception ex)
  8340. {
  8341. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8342. }
  8343. }
  8344. }
  8345. return true;
  8346. case "restart":
  8347. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8348. {
  8349. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8350. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8351. {
  8352. float timeSeconds;
  8353. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8354. timeSeconds = (int)timeSeconds;
  8355. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8356. }
  8357. }
  8358. return true;
  8359. case "estatechangecovenantid":
  8360. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8361. {
  8362. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8363. {
  8364. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8365. OnEstateChangeCovenantRequest(this, newCovenantID);
  8366. }
  8367. }
  8368. return true;
  8369. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8370. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8371. {
  8372. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8373. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8374. }
  8375. return true;
  8376. case "simulatormessage":
  8377. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8378. {
  8379. UUID invoice = messagePacket.MethodData.Invoice;
  8380. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8381. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8382. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8383. UUID sessionID = messagePacket.AgentData.SessionID;
  8384. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8385. }
  8386. return true;
  8387. case "instantmessage":
  8388. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8389. {
  8390. if (messagePacket.ParamList.Length < 2)
  8391. return true;
  8392. UUID invoice = messagePacket.MethodData.Invoice;
  8393. UUID sessionID = messagePacket.AgentData.SessionID;
  8394. UUID SenderID;
  8395. string SenderName;
  8396. string Message;
  8397. if (messagePacket.ParamList.Length < 5)
  8398. {
  8399. SenderID = AgentId;
  8400. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8401. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8402. }
  8403. else
  8404. {
  8405. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8406. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8407. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8408. }
  8409. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8410. }
  8411. return true;
  8412. case "setregiondebug":
  8413. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8414. {
  8415. UUID invoice = messagePacket.MethodData.Invoice;
  8416. UUID SenderID = messagePacket.AgentData.AgentID;
  8417. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8418. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8419. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8420. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8421. }
  8422. return true;
  8423. case "teleporthomeuser":
  8424. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8425. {
  8426. UUID invoice = messagePacket.MethodData.Invoice;
  8427. UUID SenderID = messagePacket.AgentData.AgentID;
  8428. UUID Prey;
  8429. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8430. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8431. }
  8432. return true;
  8433. case "teleporthomeallusers":
  8434. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8435. {
  8436. UUID invoice = messagePacket.MethodData.Invoice;
  8437. UUID SenderID = messagePacket.AgentData.AgentID;
  8438. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8439. }
  8440. return true;
  8441. case "colliders":
  8442. handlerLandStatRequest = OnLandStatRequest;
  8443. if (handlerLandStatRequest != null)
  8444. {
  8445. handlerLandStatRequest(0, 1, 0, "", this);
  8446. }
  8447. return true;
  8448. case "scripts":
  8449. handlerLandStatRequest = OnLandStatRequest;
  8450. if (handlerLandStatRequest != null)
  8451. {
  8452. handlerLandStatRequest(0, 0, 0, "", this);
  8453. }
  8454. return true;
  8455. case "terrain":
  8456. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8457. {
  8458. if (messagePacket.ParamList.Length > 0)
  8459. {
  8460. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8461. {
  8462. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8463. if (handlerBakeTerrain != null)
  8464. {
  8465. handlerBakeTerrain(this);
  8466. }
  8467. }
  8468. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8469. {
  8470. if (messagePacket.ParamList.Length > 1)
  8471. {
  8472. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8473. if (handlerRequestTerrain != null)
  8474. {
  8475. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8476. }
  8477. }
  8478. }
  8479. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8480. {
  8481. if (messagePacket.ParamList.Length > 1)
  8482. {
  8483. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8484. if (handlerUploadTerrain != null)
  8485. {
  8486. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8487. }
  8488. }
  8489. }
  8490. }
  8491. }
  8492. return true;
  8493. case "estatechangeinfo":
  8494. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8495. {
  8496. UUID invoice = messagePacket.MethodData.Invoice;
  8497. UUID SenderID = messagePacket.AgentData.AgentID;
  8498. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8499. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8500. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8501. if (handlerEstateChangeInfo != null)
  8502. {
  8503. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8504. }
  8505. }
  8506. return true;
  8507. case "telehub":
  8508. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8509. {
  8510. UUID invoice = messagePacket.MethodData.Invoice;
  8511. UUID SenderID = messagePacket.AgentData.AgentID;
  8512. UInt32 param1 = 0u;
  8513. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8514. if (command != "info ui")
  8515. {
  8516. try
  8517. {
  8518. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8519. }
  8520. catch
  8521. {
  8522. }
  8523. }
  8524. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8525. if (handlerEstateManageTelehub != null)
  8526. {
  8527. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8528. }
  8529. }
  8530. return true;
  8531. case "kickestate":
  8532. if(((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8533. {
  8534. UUID invoice = messagePacket.MethodData.Invoice;
  8535. UUID SenderID = messagePacket.AgentData.AgentID;
  8536. UUID Prey;
  8537. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[0].Parameter), out Prey);
  8538. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8539. }
  8540. return true;
  8541. default:
  8542. m_log.WarnFormat(
  8543. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8544. method, Name, Scene.Name);
  8545. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8546. {
  8547. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8548. string data = (string)Utils.BytesToString(block.Parameter);
  8549. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8550. }
  8551. return true;
  8552. }
  8553. //int parcelID, uint reportType, uint requestflags, string filter
  8554. //lsrp.RequestData.ParcelLocalID;
  8555. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8556. //lsrp.RequestData.RequestFlags;
  8557. //lsrp.RequestData.Filter;
  8558. }
  8559. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8560. {
  8561. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8562. #region Packet Session and User Check
  8563. if (m_checkPackets)
  8564. {
  8565. if (mPacket.SessionID != SessionId ||
  8566. mPacket.AgentID != AgentId)
  8567. return true;
  8568. }
  8569. #endregion
  8570. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8571. if (handlerRegionInfoRequest != null)
  8572. {
  8573. handlerRegionInfoRequest(this);
  8574. }
  8575. return true;
  8576. }
  8577. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8578. {
  8579. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8580. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8581. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8582. if (handlerEstateCovenantRequest != null)
  8583. {
  8584. handlerEstateCovenantRequest(this);
  8585. }
  8586. return true;
  8587. }
  8588. #endregion Estate Packets
  8589. #region GodPackets
  8590. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8591. {
  8592. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8593. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8594. UUID token = rblock.Token;
  8595. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8596. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8597. if (handlerReqGodlikePowers != null)
  8598. {
  8599. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8600. }
  8601. return true;
  8602. }
  8603. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8604. {
  8605. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8606. (GodUpdateRegionInfoPacket)Packet;
  8607. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8608. if (handlerGodUpdateRegionInfo != null)
  8609. {
  8610. handlerGodUpdateRegionInfo(this,
  8611. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8612. GodUpdateRegionInfo.RegionInfo.EstateID,
  8613. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8614. GodUpdateRegionInfo.RegionInfo.SimName,
  8615. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8616. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8617. return true;
  8618. }
  8619. return false;
  8620. }
  8621. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8622. {
  8623. SimWideDeletesPacket SimWideDeletesRequest =
  8624. (SimWideDeletesPacket)Packet;
  8625. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8626. if (handlerSimWideDeletesRequest != null)
  8627. {
  8628. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8629. return true;
  8630. }
  8631. return false;
  8632. }
  8633. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8634. {
  8635. GodlikeMessagePacket GodlikeMessage =
  8636. (GodlikeMessagePacket)Packet;
  8637. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8638. if (handlerGodlikeMessage != null)
  8639. {
  8640. handlerGodlikeMessage(this,
  8641. GodlikeMessage.MethodData.Invoice,
  8642. GodlikeMessage.MethodData.Method,
  8643. GodlikeMessage.ParamList[0].Parameter);
  8644. return true;
  8645. }
  8646. return false;
  8647. }
  8648. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8649. {
  8650. StateSavePacket SaveStateMessage =
  8651. (StateSavePacket)Packet;
  8652. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8653. if (handlerSaveStatePacket != null)
  8654. {
  8655. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8656. return true;
  8657. }
  8658. return false;
  8659. }
  8660. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8661. {
  8662. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8663. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8664. {
  8665. GodKickUser handlerGodKickUser = OnGodKickUser;
  8666. if (handlerGodKickUser != null)
  8667. {
  8668. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8669. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8670. }
  8671. }
  8672. else
  8673. {
  8674. SendAgentAlertMessage("Kick request denied", false);
  8675. }
  8676. //KickUserPacket kupack = new KickUserPacket();
  8677. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8678. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8679. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8680. //kupack.TargetBlock.TargetIP = (uint)0;
  8681. //kupack.TargetBlock.TargetPort = (ushort)0;
  8682. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8683. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8684. return true;
  8685. }
  8686. #endregion GodPackets
  8687. #region Economy/Transaction Packets
  8688. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8689. {
  8690. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8691. #region Packet Session and User Check
  8692. if (m_checkPackets)
  8693. {
  8694. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8695. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8696. return true;
  8697. }
  8698. #endregion
  8699. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8700. if (handlerMoneyBalanceRequest != null)
  8701. {
  8702. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8703. }
  8704. return true;
  8705. }
  8706. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8707. {
  8708. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8709. if (handlerEconomoyDataRequest != null)
  8710. {
  8711. handlerEconomoyDataRequest(this);
  8712. }
  8713. return true;
  8714. }
  8715. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8716. {
  8717. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8718. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8719. if (handlerRequestPayPrice != null)
  8720. {
  8721. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8722. }
  8723. return true;
  8724. }
  8725. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8726. {
  8727. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8728. #region Packet Session and User Check
  8729. if (m_checkPackets)
  8730. {
  8731. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8732. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8733. return true;
  8734. }
  8735. #endregion
  8736. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8737. if (handlerObjectSaleInfo != null)
  8738. {
  8739. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8740. in objectSaleInfoPacket.ObjectData)
  8741. {
  8742. handlerObjectSaleInfo(this,
  8743. objectSaleInfoPacket.AgentData.AgentID,
  8744. objectSaleInfoPacket.AgentData.SessionID,
  8745. d.LocalID,
  8746. d.SaleType,
  8747. d.SalePrice);
  8748. }
  8749. }
  8750. return true;
  8751. }
  8752. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8753. {
  8754. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8755. #region Packet Session and User Check
  8756. if (m_checkPackets)
  8757. {
  8758. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8759. objectBuyPacket.AgentData.AgentID != AgentId)
  8760. return true;
  8761. }
  8762. #endregion
  8763. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8764. if (handlerObjectBuy != null)
  8765. {
  8766. foreach (ObjectBuyPacket.ObjectDataBlock d
  8767. in objectBuyPacket.ObjectData)
  8768. {
  8769. handlerObjectBuy(this,
  8770. objectBuyPacket.AgentData.AgentID,
  8771. objectBuyPacket.AgentData.SessionID,
  8772. objectBuyPacket.AgentData.GroupID,
  8773. objectBuyPacket.AgentData.CategoryID,
  8774. d.ObjectLocalID,
  8775. d.SaleType,
  8776. d.SalePrice);
  8777. }
  8778. }
  8779. return true;
  8780. }
  8781. #endregion Economy/Transaction Packets
  8782. #region Script Packets
  8783. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8784. {
  8785. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8786. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8787. if (handlerGetScriptRunning != null)
  8788. {
  8789. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8790. }
  8791. return true;
  8792. }
  8793. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8794. {
  8795. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8796. #region Packet Session and User Check
  8797. if (m_checkPackets)
  8798. {
  8799. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8800. setScriptRunning.AgentData.AgentID != AgentId)
  8801. return true;
  8802. }
  8803. #endregion
  8804. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8805. if (handlerSetScriptRunning != null)
  8806. {
  8807. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8808. }
  8809. return true;
  8810. }
  8811. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8812. {
  8813. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8814. #region Packet Session and User Check
  8815. if (m_checkPackets)
  8816. {
  8817. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8818. scriptResetPacket.AgentData.AgentID != AgentId)
  8819. return true;
  8820. }
  8821. #endregion
  8822. ScriptReset handlerScriptReset = OnScriptReset;
  8823. if (handlerScriptReset != null)
  8824. {
  8825. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8826. }
  8827. return true;
  8828. }
  8829. #endregion Script Packets
  8830. #region Gesture Managment
  8831. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8832. {
  8833. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8834. #region Packet Session and User Check
  8835. if (m_checkPackets)
  8836. {
  8837. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8838. activateGesturePacket.AgentData.AgentID != AgentId)
  8839. return true;
  8840. }
  8841. #endregion
  8842. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8843. if (handlerActivateGesture != null)
  8844. {
  8845. handlerActivateGesture(this,
  8846. activateGesturePacket.Data[0].AssetID,
  8847. activateGesturePacket.Data[0].ItemID);
  8848. }
  8849. else m_log.Error("Null pointer for activateGesture");
  8850. return true;
  8851. }
  8852. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8853. {
  8854. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8855. #region Packet Session and User Check
  8856. if (m_checkPackets)
  8857. {
  8858. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8859. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8860. return true;
  8861. }
  8862. #endregion
  8863. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8864. if (handlerDeactivateGesture != null)
  8865. {
  8866. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8867. }
  8868. return true;
  8869. }
  8870. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8871. {
  8872. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8873. #region Packet Session and User Check
  8874. if (m_checkPackets)
  8875. {
  8876. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8877. objectOwnerPacket.AgentData.AgentID != AgentId)
  8878. return true;
  8879. }
  8880. #endregion
  8881. List<uint> localIDs = new List<uint>();
  8882. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8883. localIDs.Add(d.ObjectLocalID);
  8884. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8885. if (handlerObjectOwner != null)
  8886. {
  8887. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8888. }
  8889. return true;
  8890. }
  8891. #endregion Gesture Managment
  8892. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8893. {
  8894. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8895. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8896. {
  8897. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8898. AgentFOV handlerAgentFOV = OnAgentFOV;
  8899. if (handlerAgentFOV != null)
  8900. {
  8901. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8902. }
  8903. }
  8904. return true;
  8905. }
  8906. #region unimplemented handlers
  8907. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8908. {
  8909. // TODO: handle this packet
  8910. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8911. return true;
  8912. }
  8913. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8914. {
  8915. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8916. #region Packet Session and User Check
  8917. if (m_checkPackets)
  8918. {
  8919. if (mirpk.AgentData.SessionID != SessionId ||
  8920. mirpk.AgentData.AgentID != AgentId)
  8921. return true;
  8922. }
  8923. #endregion
  8924. //m_log.Debug(mirpk.ToString());
  8925. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8926. if (handlerMapItemRequest != null)
  8927. {
  8928. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8929. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8930. mirpk.RequestData.RegionHandle);
  8931. }
  8932. return true;
  8933. }
  8934. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8935. {
  8936. return true;
  8937. }
  8938. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8939. {
  8940. MuteListRequestPacket muteListRequest =
  8941. (MuteListRequestPacket)Pack;
  8942. #region Packet Session and User Check
  8943. if (m_checkPackets)
  8944. {
  8945. if (muteListRequest.AgentData.SessionID != SessionId ||
  8946. muteListRequest.AgentData.AgentID != AgentId)
  8947. return true;
  8948. }
  8949. #endregion
  8950. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8951. if (handlerMuteListRequest != null)
  8952. {
  8953. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8954. }
  8955. else
  8956. {
  8957. SendUseCachedMuteList();
  8958. }
  8959. return true;
  8960. }
  8961. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8962. {
  8963. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8964. (UpdateMuteListEntryPacket)Packet;
  8965. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8966. if (handlerUpdateMuteListEntry != null)
  8967. {
  8968. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8969. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8970. UpdateMuteListEntry.MuteData.MuteType,
  8971. UpdateMuteListEntry.AgentData.AgentID);
  8972. return true;
  8973. }
  8974. return false;
  8975. }
  8976. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8977. {
  8978. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8979. (RemoveMuteListEntryPacket)Packet;
  8980. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8981. if (handlerRemoveMuteListEntry != null)
  8982. {
  8983. handlerRemoveMuteListEntry(this,
  8984. RemoveMuteListEntry.MuteData.MuteID,
  8985. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8986. RemoveMuteListEntry.AgentData.AgentID);
  8987. return true;
  8988. }
  8989. return false;
  8990. }
  8991. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8992. {
  8993. UserReportPacket UserReport =
  8994. (UserReportPacket)Packet;
  8995. NewUserReport handlerUserReport = OnUserReport;
  8996. if (handlerUserReport != null)
  8997. {
  8998. handlerUserReport(this,
  8999. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  9000. UserReport.ReportData.AbuserID,
  9001. UserReport.ReportData.Category,
  9002. UserReport.ReportData.CheckFlags,
  9003. Utils.BytesToString(UserReport.ReportData.Details),
  9004. UserReport.ReportData.ObjectID,
  9005. UserReport.ReportData.Position,
  9006. UserReport.ReportData.ReportType,
  9007. UserReport.ReportData.ScreenshotID,
  9008. Utils.BytesToString(UserReport.ReportData.Summary),
  9009. UserReport.AgentData.AgentID);
  9010. return true;
  9011. }
  9012. return false;
  9013. }
  9014. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  9015. {
  9016. // SendPostcardPacket SendPostcard =
  9017. // (SendPostcardPacket)packet;
  9018. SendPostcard handlerSendPostcard = OnSendPostcard;
  9019. if (handlerSendPostcard != null)
  9020. {
  9021. handlerSendPostcard(this);
  9022. return true;
  9023. }
  9024. return false;
  9025. }
  9026. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  9027. {
  9028. return true;
  9029. }
  9030. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  9031. {
  9032. return true;
  9033. }
  9034. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  9035. {
  9036. return true;
  9037. }
  9038. #endregion unimplemented handlers
  9039. #region Dir handlers
  9040. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  9041. {
  9042. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  9043. //m_log.Debug(dirPlacesQueryPacket.ToString());
  9044. #region Packet Session and User Check
  9045. if (m_checkPackets)
  9046. {
  9047. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  9048. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  9049. return true;
  9050. }
  9051. #endregion
  9052. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  9053. if (handlerDirPlacesQuery != null)
  9054. {
  9055. handlerDirPlacesQuery(this,
  9056. dirPlacesQueryPacket.QueryData.QueryID,
  9057. Utils.BytesToString(
  9058. dirPlacesQueryPacket.QueryData.QueryText),
  9059. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  9060. (int)dirPlacesQueryPacket.QueryData.Category,
  9061. Utils.BytesToString(
  9062. dirPlacesQueryPacket.QueryData.SimName),
  9063. dirPlacesQueryPacket.QueryData.QueryStart);
  9064. }
  9065. return true;
  9066. }
  9067. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  9068. {
  9069. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  9070. #region Packet Session and User Check
  9071. if (m_checkPackets)
  9072. {
  9073. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  9074. dirFindQueryPacket.AgentData.AgentID != AgentId)
  9075. return true;
  9076. }
  9077. #endregion
  9078. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  9079. if (handlerDirFindQuery != null)
  9080. {
  9081. handlerDirFindQuery(this,
  9082. dirFindQueryPacket.QueryData.QueryID,
  9083. Utils.BytesToString(
  9084. dirFindQueryPacket.QueryData.QueryText).Trim(),
  9085. dirFindQueryPacket.QueryData.QueryFlags,
  9086. dirFindQueryPacket.QueryData.QueryStart);
  9087. }
  9088. return true;
  9089. }
  9090. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  9091. {
  9092. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  9093. #region Packet Session and User Check
  9094. if (m_checkPackets)
  9095. {
  9096. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  9097. dirLandQueryPacket.AgentData.AgentID != AgentId)
  9098. return true;
  9099. }
  9100. #endregion
  9101. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  9102. if (handlerDirLandQuery != null)
  9103. {
  9104. handlerDirLandQuery(this,
  9105. dirLandQueryPacket.QueryData.QueryID,
  9106. dirLandQueryPacket.QueryData.QueryFlags,
  9107. dirLandQueryPacket.QueryData.SearchType,
  9108. dirLandQueryPacket.QueryData.Price,
  9109. dirLandQueryPacket.QueryData.Area,
  9110. dirLandQueryPacket.QueryData.QueryStart);
  9111. }
  9112. return true;
  9113. }
  9114. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  9115. {
  9116. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  9117. #region Packet Session and User Check
  9118. if (m_checkPackets)
  9119. {
  9120. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  9121. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  9122. return true;
  9123. }
  9124. #endregion
  9125. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  9126. if (handlerDirPopularQuery != null)
  9127. {
  9128. handlerDirPopularQuery(this,
  9129. dirPopularQueryPacket.QueryData.QueryID,
  9130. dirPopularQueryPacket.QueryData.QueryFlags);
  9131. }
  9132. return true;
  9133. }
  9134. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  9135. {
  9136. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  9137. #region Packet Session and User Check
  9138. if (m_checkPackets)
  9139. {
  9140. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  9141. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  9142. return true;
  9143. }
  9144. #endregion
  9145. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  9146. if (handlerDirClassifiedQuery != null)
  9147. {
  9148. handlerDirClassifiedQuery(this,
  9149. dirClassifiedQueryPacket.QueryData.QueryID,
  9150. Utils.BytesToString(
  9151. dirClassifiedQueryPacket.QueryData.QueryText),
  9152. dirClassifiedQueryPacket.QueryData.QueryFlags,
  9153. dirClassifiedQueryPacket.QueryData.Category,
  9154. dirClassifiedQueryPacket.QueryData.QueryStart);
  9155. }
  9156. return true;
  9157. }
  9158. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  9159. {
  9160. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  9161. #region Packet Session and User Check
  9162. if (m_checkPackets)
  9163. {
  9164. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9165. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9166. return true;
  9167. }
  9168. #endregion
  9169. if (OnEventInfoRequest != null)
  9170. {
  9171. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9172. }
  9173. return true;
  9174. }
  9175. #endregion
  9176. #region Calling Card
  9177. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9178. {
  9179. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9180. #region Packet Session and User Check
  9181. if (m_checkPackets)
  9182. {
  9183. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9184. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9185. return true;
  9186. }
  9187. #endregion
  9188. if (OnOfferCallingCard != null)
  9189. {
  9190. OnOfferCallingCard(this,
  9191. offerCallingCardPacket.AgentBlock.DestID,
  9192. offerCallingCardPacket.AgentBlock.TransactionID);
  9193. }
  9194. return true;
  9195. }
  9196. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9197. {
  9198. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9199. #region Packet Session and User Check
  9200. if (m_checkPackets)
  9201. {
  9202. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9203. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9204. return true;
  9205. }
  9206. #endregion
  9207. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9208. // contain exactly one entry
  9209. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9210. {
  9211. OnAcceptCallingCard(this,
  9212. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9213. acceptCallingCardPacket.FolderData[0].FolderID);
  9214. }
  9215. return true;
  9216. }
  9217. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9218. {
  9219. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9220. #region Packet Session and User Check
  9221. if (m_checkPackets)
  9222. {
  9223. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9224. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9225. return true;
  9226. }
  9227. #endregion
  9228. if (OnDeclineCallingCard != null)
  9229. {
  9230. OnDeclineCallingCard(this,
  9231. declineCallingCardPacket.TransactionBlock.TransactionID);
  9232. }
  9233. return true;
  9234. }
  9235. #endregion Calling Card
  9236. #region Groups
  9237. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9238. {
  9239. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9240. #region Packet Session and User Check
  9241. if (m_checkPackets)
  9242. {
  9243. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9244. activateGroupPacket.AgentData.AgentID != AgentId)
  9245. return true;
  9246. }
  9247. #endregion
  9248. if (m_GroupsModule != null)
  9249. {
  9250. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9251. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9252. }
  9253. return true;
  9254. }
  9255. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9256. {
  9257. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9258. (GroupVoteHistoryRequestPacket)Packet;
  9259. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9260. if (handlerGroupVoteHistoryRequest != null)
  9261. {
  9262. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9263. return true;
  9264. }
  9265. return false;
  9266. }
  9267. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9268. {
  9269. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9270. (GroupActiveProposalsRequestPacket)Packet;
  9271. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9272. if (handlerGroupActiveProposalsRequest != null)
  9273. {
  9274. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9275. return true;
  9276. }
  9277. return false;
  9278. }
  9279. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9280. {
  9281. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9282. (GroupAccountDetailsRequestPacket)Packet;
  9283. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9284. if (handlerGroupAccountDetailsRequest != null)
  9285. {
  9286. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9287. return true;
  9288. }
  9289. return false;
  9290. }
  9291. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9292. {
  9293. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9294. (GroupAccountSummaryRequestPacket)Packet;
  9295. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9296. if (handlerGroupAccountSummaryRequest != null)
  9297. {
  9298. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9299. return true;
  9300. }
  9301. return false;
  9302. }
  9303. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9304. {
  9305. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9306. (GroupAccountTransactionsRequestPacket)Packet;
  9307. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9308. if (handlerGroupAccountTransactionsRequest != null)
  9309. {
  9310. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9311. return true;
  9312. }
  9313. return false;
  9314. }
  9315. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9316. {
  9317. GroupTitlesRequestPacket groupTitlesRequest =
  9318. (GroupTitlesRequestPacket)Pack;
  9319. #region Packet Session and User Check
  9320. if (m_checkPackets)
  9321. {
  9322. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9323. groupTitlesRequest.AgentData.AgentID != AgentId)
  9324. return true;
  9325. }
  9326. #endregion
  9327. if (m_GroupsModule != null)
  9328. {
  9329. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9330. groupTitlesReply.AgentData =
  9331. new GroupTitlesReplyPacket.AgentDataBlock();
  9332. groupTitlesReply.AgentData.AgentID = AgentId;
  9333. groupTitlesReply.AgentData.GroupID =
  9334. groupTitlesRequest.AgentData.GroupID;
  9335. groupTitlesReply.AgentData.RequestID =
  9336. groupTitlesRequest.AgentData.RequestID;
  9337. List<GroupTitlesData> titles =
  9338. m_GroupsModule.GroupTitlesRequest(this,
  9339. groupTitlesRequest.AgentData.GroupID);
  9340. groupTitlesReply.GroupData =
  9341. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9342. int i = 0;
  9343. foreach (GroupTitlesData d in titles)
  9344. {
  9345. groupTitlesReply.GroupData[i] =
  9346. new GroupTitlesReplyPacket.GroupDataBlock();
  9347. groupTitlesReply.GroupData[i].Title =
  9348. Util.StringToBytes256(d.Name);
  9349. groupTitlesReply.GroupData[i].RoleID =
  9350. d.UUID;
  9351. groupTitlesReply.GroupData[i].Selected =
  9352. d.Selected;
  9353. i++;
  9354. }
  9355. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9356. }
  9357. return true;
  9358. }
  9359. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9360. {
  9361. GroupProfileRequestPacket groupProfileRequest =
  9362. (GroupProfileRequestPacket)Pack;
  9363. #region Packet Session and User Check
  9364. if (m_checkPackets)
  9365. {
  9366. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9367. groupProfileRequest.AgentData.AgentID != AgentId)
  9368. return true;
  9369. }
  9370. #endregion
  9371. if (m_GroupsModule != null)
  9372. {
  9373. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9374. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9375. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9376. groupProfileReply.AgentData.AgentID = AgentId;
  9377. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9378. groupProfileRequest.GroupData.GroupID);
  9379. groupProfileReply.GroupData.GroupID = d.GroupID;
  9380. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9381. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9382. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9383. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9384. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9385. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9386. groupProfileReply.GroupData.FounderID = d.FounderID;
  9387. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9388. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9389. groupProfileReply.GroupData.Money = d.Money;
  9390. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9391. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9392. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9393. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9394. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9395. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9396. }
  9397. return true;
  9398. }
  9399. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9400. {
  9401. GroupMembersRequestPacket groupMembersRequestPacket =
  9402. (GroupMembersRequestPacket)Pack;
  9403. #region Packet Session and User Check
  9404. if (m_checkPackets)
  9405. {
  9406. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9407. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9408. return true;
  9409. }
  9410. #endregion
  9411. if (m_GroupsModule != null)
  9412. {
  9413. List<GroupMembersData> members =
  9414. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9415. int memberCount = members.Count;
  9416. while (true)
  9417. {
  9418. int blockCount = members.Count;
  9419. if (blockCount > 40)
  9420. blockCount = 40;
  9421. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9422. groupMembersReply.AgentData =
  9423. new GroupMembersReplyPacket.AgentDataBlock();
  9424. groupMembersReply.GroupData =
  9425. new GroupMembersReplyPacket.GroupDataBlock();
  9426. groupMembersReply.MemberData =
  9427. new GroupMembersReplyPacket.MemberDataBlock[
  9428. blockCount];
  9429. groupMembersReply.AgentData.AgentID = AgentId;
  9430. groupMembersReply.GroupData.GroupID =
  9431. groupMembersRequestPacket.GroupData.GroupID;
  9432. groupMembersReply.GroupData.RequestID =
  9433. groupMembersRequestPacket.GroupData.RequestID;
  9434. groupMembersReply.GroupData.MemberCount = memberCount;
  9435. for (int i = 0; i < blockCount; i++)
  9436. {
  9437. GroupMembersData m = members[0];
  9438. members.RemoveAt(0);
  9439. groupMembersReply.MemberData[i] =
  9440. new GroupMembersReplyPacket.MemberDataBlock();
  9441. groupMembersReply.MemberData[i].AgentID =
  9442. m.AgentID;
  9443. groupMembersReply.MemberData[i].Contribution =
  9444. m.Contribution;
  9445. groupMembersReply.MemberData[i].OnlineStatus =
  9446. Util.StringToBytes256(m.OnlineStatus);
  9447. groupMembersReply.MemberData[i].AgentPowers =
  9448. m.AgentPowers;
  9449. groupMembersReply.MemberData[i].Title =
  9450. Util.StringToBytes256(m.Title);
  9451. groupMembersReply.MemberData[i].IsOwner =
  9452. m.IsOwner;
  9453. }
  9454. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9455. if (members.Count == 0)
  9456. return true;
  9457. }
  9458. }
  9459. return true;
  9460. }
  9461. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9462. {
  9463. GroupRoleDataRequestPacket groupRolesRequest =
  9464. (GroupRoleDataRequestPacket)Pack;
  9465. #region Packet Session and User Check
  9466. if (m_checkPackets)
  9467. {
  9468. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9469. groupRolesRequest.AgentData.AgentID != AgentId)
  9470. return true;
  9471. }
  9472. #endregion
  9473. if (m_GroupsModule != null)
  9474. {
  9475. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9476. groupRolesReply.AgentData =
  9477. new GroupRoleDataReplyPacket.AgentDataBlock();
  9478. groupRolesReply.AgentData.AgentID = AgentId;
  9479. groupRolesReply.GroupData =
  9480. new GroupRoleDataReplyPacket.GroupDataBlock();
  9481. groupRolesReply.GroupData.GroupID =
  9482. groupRolesRequest.GroupData.GroupID;
  9483. groupRolesReply.GroupData.RequestID =
  9484. groupRolesRequest.GroupData.RequestID;
  9485. List<GroupRolesData> titles =
  9486. m_GroupsModule.GroupRoleDataRequest(this,
  9487. groupRolesRequest.GroupData.GroupID);
  9488. groupRolesReply.GroupData.RoleCount =
  9489. titles.Count;
  9490. groupRolesReply.RoleData =
  9491. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9492. int i = 0;
  9493. foreach (GroupRolesData d in titles)
  9494. {
  9495. groupRolesReply.RoleData[i] =
  9496. new GroupRoleDataReplyPacket.RoleDataBlock();
  9497. groupRolesReply.RoleData[i].RoleID =
  9498. d.RoleID;
  9499. groupRolesReply.RoleData[i].Name =
  9500. Util.StringToBytes256(d.Name);
  9501. groupRolesReply.RoleData[i].Title =
  9502. Util.StringToBytes256(d.Title);
  9503. groupRolesReply.RoleData[i].Description =
  9504. Util.StringToBytes1024(d.Description);
  9505. groupRolesReply.RoleData[i].Powers =
  9506. d.Powers;
  9507. groupRolesReply.RoleData[i].Members =
  9508. (uint)d.Members;
  9509. i++;
  9510. }
  9511. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9512. }
  9513. return true;
  9514. }
  9515. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9516. {
  9517. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9518. (GroupRoleMembersRequestPacket)Pack;
  9519. #region Packet Session and User Check
  9520. if (m_checkPackets)
  9521. {
  9522. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9523. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9524. return true;
  9525. }
  9526. #endregion
  9527. if (m_GroupsModule != null)
  9528. {
  9529. List<GroupRoleMembersData> mappings =
  9530. m_GroupsModule.GroupRoleMembersRequest(this,
  9531. groupRoleMembersRequest.GroupData.GroupID);
  9532. int mappingsCount = mappings.Count;
  9533. while (mappings.Count > 0)
  9534. {
  9535. int pairs = mappings.Count;
  9536. if (pairs > 32)
  9537. pairs = 32;
  9538. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9539. groupRoleMembersReply.AgentData =
  9540. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9541. groupRoleMembersReply.AgentData.AgentID =
  9542. AgentId;
  9543. groupRoleMembersReply.AgentData.GroupID =
  9544. groupRoleMembersRequest.GroupData.GroupID;
  9545. groupRoleMembersReply.AgentData.RequestID =
  9546. groupRoleMembersRequest.GroupData.RequestID;
  9547. groupRoleMembersReply.AgentData.TotalPairs =
  9548. (uint)mappingsCount;
  9549. groupRoleMembersReply.MemberData =
  9550. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9551. for (int i = 0; i < pairs; i++)
  9552. {
  9553. GroupRoleMembersData d = mappings[0];
  9554. mappings.RemoveAt(0);
  9555. groupRoleMembersReply.MemberData[i] =
  9556. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9557. groupRoleMembersReply.MemberData[i].RoleID =
  9558. d.RoleID;
  9559. groupRoleMembersReply.MemberData[i].MemberID =
  9560. d.MemberID;
  9561. }
  9562. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9563. }
  9564. }
  9565. return true;
  9566. }
  9567. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9568. {
  9569. CreateGroupRequestPacket createGroupRequest =
  9570. (CreateGroupRequestPacket)Pack;
  9571. #region Packet Session and User Check
  9572. if (m_checkPackets)
  9573. {
  9574. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9575. createGroupRequest.AgentData.AgentID != AgentId)
  9576. return true;
  9577. }
  9578. #endregion
  9579. if (m_GroupsModule != null)
  9580. {
  9581. m_GroupsModule.CreateGroup(this,
  9582. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9583. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9584. createGroupRequest.GroupData.ShowInList,
  9585. createGroupRequest.GroupData.InsigniaID,
  9586. createGroupRequest.GroupData.MembershipFee,
  9587. createGroupRequest.GroupData.OpenEnrollment,
  9588. createGroupRequest.GroupData.AllowPublish,
  9589. createGroupRequest.GroupData.MaturePublish);
  9590. }
  9591. return true;
  9592. }
  9593. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9594. {
  9595. UpdateGroupInfoPacket updateGroupInfo =
  9596. (UpdateGroupInfoPacket)Pack;
  9597. #region Packet Session and User Check
  9598. if (m_checkPackets)
  9599. {
  9600. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9601. updateGroupInfo.AgentData.AgentID != AgentId)
  9602. return true;
  9603. }
  9604. #endregion
  9605. if (m_GroupsModule != null)
  9606. {
  9607. m_GroupsModule.UpdateGroupInfo(this,
  9608. updateGroupInfo.GroupData.GroupID,
  9609. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9610. updateGroupInfo.GroupData.ShowInList,
  9611. updateGroupInfo.GroupData.InsigniaID,
  9612. updateGroupInfo.GroupData.MembershipFee,
  9613. updateGroupInfo.GroupData.OpenEnrollment,
  9614. updateGroupInfo.GroupData.AllowPublish,
  9615. updateGroupInfo.GroupData.MaturePublish);
  9616. }
  9617. return true;
  9618. }
  9619. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9620. {
  9621. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9622. (SetGroupAcceptNoticesPacket)Pack;
  9623. #region Packet Session and User Check
  9624. if (m_checkPackets)
  9625. {
  9626. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9627. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9628. return true;
  9629. }
  9630. #endregion
  9631. if (m_GroupsModule != null)
  9632. {
  9633. m_GroupsModule.SetGroupAcceptNotices(this,
  9634. setGroupAcceptNotices.Data.GroupID,
  9635. setGroupAcceptNotices.Data.AcceptNotices,
  9636. setGroupAcceptNotices.NewData.ListInProfile);
  9637. }
  9638. return true;
  9639. }
  9640. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9641. {
  9642. GroupTitleUpdatePacket groupTitleUpdate =
  9643. (GroupTitleUpdatePacket)Pack;
  9644. #region Packet Session and User Check
  9645. if (m_checkPackets)
  9646. {
  9647. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9648. groupTitleUpdate.AgentData.AgentID != AgentId)
  9649. return true;
  9650. }
  9651. #endregion
  9652. if (m_GroupsModule != null)
  9653. {
  9654. m_GroupsModule.GroupTitleUpdate(this,
  9655. groupTitleUpdate.AgentData.GroupID,
  9656. groupTitleUpdate.AgentData.TitleRoleID);
  9657. }
  9658. return true;
  9659. }
  9660. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9661. {
  9662. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9663. if (m_GroupsModule != null)
  9664. {
  9665. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9666. if (handlerParcelDeedToGroup != null)
  9667. {
  9668. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9669. }
  9670. }
  9671. return true;
  9672. }
  9673. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9674. {
  9675. GroupNoticesListRequestPacket groupNoticesListRequest =
  9676. (GroupNoticesListRequestPacket)Pack;
  9677. #region Packet Session and User Check
  9678. if (m_checkPackets)
  9679. {
  9680. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9681. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9682. return true;
  9683. }
  9684. #endregion
  9685. if (m_GroupsModule != null)
  9686. {
  9687. GroupNoticeData[] gn =
  9688. m_GroupsModule.GroupNoticesListRequest(this,
  9689. groupNoticesListRequest.Data.GroupID);
  9690. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9691. groupNoticesListReply.AgentData =
  9692. new GroupNoticesListReplyPacket.AgentDataBlock();
  9693. groupNoticesListReply.AgentData.AgentID = AgentId;
  9694. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9695. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9696. int i = 0;
  9697. foreach (GroupNoticeData g in gn)
  9698. {
  9699. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9700. groupNoticesListReply.Data[i].NoticeID =
  9701. g.NoticeID;
  9702. groupNoticesListReply.Data[i].Timestamp =
  9703. g.Timestamp;
  9704. groupNoticesListReply.Data[i].FromName =
  9705. Util.StringToBytes256(g.FromName);
  9706. groupNoticesListReply.Data[i].Subject =
  9707. Util.StringToBytes256(g.Subject);
  9708. groupNoticesListReply.Data[i].HasAttachment =
  9709. g.HasAttachment;
  9710. groupNoticesListReply.Data[i].AssetType =
  9711. g.AssetType;
  9712. i++;
  9713. }
  9714. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9715. }
  9716. return true;
  9717. }
  9718. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9719. {
  9720. GroupNoticeRequestPacket groupNoticeRequest =
  9721. (GroupNoticeRequestPacket)Pack;
  9722. #region Packet Session and User Check
  9723. if (m_checkPackets)
  9724. {
  9725. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9726. groupNoticeRequest.AgentData.AgentID != AgentId)
  9727. return true;
  9728. }
  9729. #endregion
  9730. if (m_GroupsModule != null)
  9731. {
  9732. m_GroupsModule.GroupNoticeRequest(this,
  9733. groupNoticeRequest.Data.GroupNoticeID);
  9734. }
  9735. return true;
  9736. }
  9737. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9738. {
  9739. GroupRoleUpdatePacket groupRoleUpdate =
  9740. (GroupRoleUpdatePacket)Pack;
  9741. #region Packet Session and User Check
  9742. if (m_checkPackets)
  9743. {
  9744. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9745. groupRoleUpdate.AgentData.AgentID != AgentId)
  9746. return true;
  9747. }
  9748. #endregion
  9749. if (m_GroupsModule != null)
  9750. {
  9751. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9752. groupRoleUpdate.RoleData)
  9753. {
  9754. m_GroupsModule.GroupRoleUpdate(this,
  9755. groupRoleUpdate.AgentData.GroupID,
  9756. d.RoleID,
  9757. Utils.BytesToString(d.Name),
  9758. Utils.BytesToString(d.Description),
  9759. Utils.BytesToString(d.Title),
  9760. d.Powers,
  9761. d.UpdateType);
  9762. }
  9763. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9764. }
  9765. return true;
  9766. }
  9767. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9768. {
  9769. GroupRoleChangesPacket groupRoleChanges =
  9770. (GroupRoleChangesPacket)Pack;
  9771. #region Packet Session and User Check
  9772. if (m_checkPackets)
  9773. {
  9774. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9775. groupRoleChanges.AgentData.AgentID != AgentId)
  9776. return true;
  9777. }
  9778. #endregion
  9779. if (m_GroupsModule != null)
  9780. {
  9781. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9782. groupRoleChanges.RoleChange)
  9783. {
  9784. m_GroupsModule.GroupRoleChanges(this,
  9785. groupRoleChanges.AgentData.GroupID,
  9786. d.RoleID,
  9787. d.MemberID,
  9788. d.Change);
  9789. }
  9790. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9791. }
  9792. return true;
  9793. }
  9794. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9795. {
  9796. JoinGroupRequestPacket joinGroupRequest =
  9797. (JoinGroupRequestPacket)Pack;
  9798. #region Packet Session and User Check
  9799. if (m_checkPackets)
  9800. {
  9801. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9802. joinGroupRequest.AgentData.AgentID != AgentId)
  9803. return true;
  9804. }
  9805. #endregion
  9806. if (m_GroupsModule != null)
  9807. {
  9808. m_GroupsModule.JoinGroupRequest(this,
  9809. joinGroupRequest.GroupData.GroupID);
  9810. }
  9811. return true;
  9812. }
  9813. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9814. {
  9815. LeaveGroupRequestPacket leaveGroupRequest =
  9816. (LeaveGroupRequestPacket)Pack;
  9817. #region Packet Session and User Check
  9818. if (m_checkPackets)
  9819. {
  9820. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9821. leaveGroupRequest.AgentData.AgentID != AgentId)
  9822. return true;
  9823. }
  9824. #endregion
  9825. if (m_GroupsModule != null)
  9826. {
  9827. m_GroupsModule.LeaveGroupRequest(this,
  9828. leaveGroupRequest.GroupData.GroupID);
  9829. }
  9830. return true;
  9831. }
  9832. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9833. {
  9834. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9835. (EjectGroupMemberRequestPacket)Pack;
  9836. #region Packet Session and User Check
  9837. if (m_checkPackets)
  9838. {
  9839. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9840. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9841. return true;
  9842. }
  9843. #endregion
  9844. if (m_GroupsModule != null)
  9845. {
  9846. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9847. in ejectGroupMemberRequest.EjectData)
  9848. {
  9849. m_GroupsModule.EjectGroupMemberRequest(this,
  9850. ejectGroupMemberRequest.GroupData.GroupID,
  9851. e.EjecteeID);
  9852. }
  9853. }
  9854. return true;
  9855. }
  9856. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9857. {
  9858. InviteGroupRequestPacket inviteGroupRequest =
  9859. (InviteGroupRequestPacket)Pack;
  9860. #region Packet Session and User Check
  9861. if (m_checkPackets)
  9862. {
  9863. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9864. inviteGroupRequest.AgentData.AgentID != AgentId)
  9865. return true;
  9866. }
  9867. #endregion
  9868. if (m_GroupsModule != null)
  9869. {
  9870. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9871. inviteGroupRequest.InviteData)
  9872. {
  9873. m_GroupsModule.InviteGroupRequest(this,
  9874. inviteGroupRequest.GroupData.GroupID,
  9875. b.InviteeID,
  9876. b.RoleID);
  9877. }
  9878. }
  9879. return true;
  9880. }
  9881. #endregion Groups
  9882. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9883. {
  9884. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9885. #region Packet Session and User Check
  9886. if (m_checkPackets)
  9887. {
  9888. if (startLureRequest.AgentData.SessionID != SessionId ||
  9889. startLureRequest.AgentData.AgentID != AgentId)
  9890. return true;
  9891. }
  9892. #endregion
  9893. StartLure handlerStartLure = OnStartLure;
  9894. if (handlerStartLure != null)
  9895. handlerStartLure(startLureRequest.Info.LureType,
  9896. Utils.BytesToString(
  9897. startLureRequest.Info.Message),
  9898. startLureRequest.TargetData[0].TargetID,
  9899. this);
  9900. return true;
  9901. }
  9902. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9903. {
  9904. TeleportLureRequestPacket teleportLureRequest =
  9905. (TeleportLureRequestPacket)Pack;
  9906. #region Packet Session and User Check
  9907. if (m_checkPackets)
  9908. {
  9909. if (teleportLureRequest.Info.SessionID != SessionId ||
  9910. teleportLureRequest.Info.AgentID != AgentId)
  9911. return true;
  9912. }
  9913. #endregion
  9914. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9915. if (handlerTeleportLureRequest != null)
  9916. handlerTeleportLureRequest(
  9917. teleportLureRequest.Info.LureID,
  9918. teleportLureRequest.Info.TeleportFlags,
  9919. this);
  9920. return true;
  9921. }
  9922. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9923. {
  9924. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9925. (ClassifiedInfoRequestPacket)Pack;
  9926. #region Packet Session and User Check
  9927. if (m_checkPackets)
  9928. {
  9929. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9930. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9931. return true;
  9932. }
  9933. #endregion
  9934. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9935. if (handlerClassifiedInfoRequest != null)
  9936. handlerClassifiedInfoRequest(
  9937. classifiedInfoRequest.Data.ClassifiedID,
  9938. this);
  9939. return true;
  9940. }
  9941. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9942. {
  9943. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9944. (ClassifiedInfoUpdatePacket)Pack;
  9945. #region Packet Session and User Check
  9946. if (m_checkPackets)
  9947. {
  9948. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9949. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9950. return true;
  9951. }
  9952. #endregion
  9953. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9954. if (handlerClassifiedInfoUpdate != null)
  9955. handlerClassifiedInfoUpdate(
  9956. classifiedInfoUpdate.Data.ClassifiedID,
  9957. classifiedInfoUpdate.Data.Category,
  9958. Utils.BytesToString(
  9959. classifiedInfoUpdate.Data.Name),
  9960. Utils.BytesToString(
  9961. classifiedInfoUpdate.Data.Desc),
  9962. classifiedInfoUpdate.Data.ParcelID,
  9963. classifiedInfoUpdate.Data.ParentEstate,
  9964. classifiedInfoUpdate.Data.SnapshotID,
  9965. new Vector3(
  9966. classifiedInfoUpdate.Data.PosGlobal),
  9967. classifiedInfoUpdate.Data.ClassifiedFlags,
  9968. classifiedInfoUpdate.Data.PriceForListing,
  9969. this);
  9970. return true;
  9971. }
  9972. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9973. {
  9974. ClassifiedDeletePacket classifiedDelete =
  9975. (ClassifiedDeletePacket)Pack;
  9976. #region Packet Session and User Check
  9977. if (m_checkPackets)
  9978. {
  9979. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9980. classifiedDelete.AgentData.AgentID != AgentId)
  9981. return true;
  9982. }
  9983. #endregion
  9984. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9985. if (handlerClassifiedDelete != null)
  9986. handlerClassifiedDelete(
  9987. classifiedDelete.Data.ClassifiedID,
  9988. this);
  9989. return true;
  9990. }
  9991. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9992. {
  9993. ClassifiedGodDeletePacket classifiedGodDelete =
  9994. (ClassifiedGodDeletePacket)Pack;
  9995. #region Packet Session and User Check
  9996. if (m_checkPackets)
  9997. {
  9998. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9999. classifiedGodDelete.AgentData.AgentID != AgentId)
  10000. return true;
  10001. }
  10002. #endregion
  10003. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  10004. if (handlerClassifiedGodDelete != null)
  10005. handlerClassifiedGodDelete(
  10006. classifiedGodDelete.Data.ClassifiedID,
  10007. this);
  10008. return true;
  10009. }
  10010. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  10011. {
  10012. EventGodDeletePacket eventGodDelete =
  10013. (EventGodDeletePacket)Pack;
  10014. #region Packet Session and User Check
  10015. if (m_checkPackets)
  10016. {
  10017. if (eventGodDelete.AgentData.SessionID != SessionId ||
  10018. eventGodDelete.AgentData.AgentID != AgentId)
  10019. return true;
  10020. }
  10021. #endregion
  10022. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  10023. if (handlerEventGodDelete != null)
  10024. handlerEventGodDelete(
  10025. eventGodDelete.EventData.EventID,
  10026. eventGodDelete.QueryData.QueryID,
  10027. Utils.BytesToString(
  10028. eventGodDelete.QueryData.QueryText),
  10029. eventGodDelete.QueryData.QueryFlags,
  10030. eventGodDelete.QueryData.QueryStart,
  10031. this);
  10032. return true;
  10033. }
  10034. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  10035. {
  10036. EventNotificationAddRequestPacket eventNotificationAdd =
  10037. (EventNotificationAddRequestPacket)Pack;
  10038. #region Packet Session and User Check
  10039. if (m_checkPackets)
  10040. {
  10041. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  10042. eventNotificationAdd.AgentData.AgentID != AgentId)
  10043. return true;
  10044. }
  10045. #endregion
  10046. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  10047. if (handlerEventNotificationAddRequest != null)
  10048. handlerEventNotificationAddRequest(
  10049. eventNotificationAdd.EventData.EventID, this);
  10050. return true;
  10051. }
  10052. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  10053. {
  10054. EventNotificationRemoveRequestPacket eventNotificationRemove =
  10055. (EventNotificationRemoveRequestPacket)Pack;
  10056. #region Packet Session and User Check
  10057. if (m_checkPackets)
  10058. {
  10059. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  10060. eventNotificationRemove.AgentData.AgentID != AgentId)
  10061. return true;
  10062. }
  10063. #endregion
  10064. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  10065. if (handlerEventNotificationRemoveRequest != null)
  10066. handlerEventNotificationRemoveRequest(
  10067. eventNotificationRemove.EventData.EventID, this);
  10068. return true;
  10069. }
  10070. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  10071. {
  10072. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  10073. #region Packet Session and User Check
  10074. if (m_checkPackets)
  10075. {
  10076. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  10077. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  10078. return true;
  10079. }
  10080. #endregion
  10081. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  10082. if (handlerRetrieveInstantMessages != null)
  10083. handlerRetrieveInstantMessages(this);
  10084. return true;
  10085. }
  10086. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  10087. {
  10088. PickDeletePacket pickDelete =
  10089. (PickDeletePacket)Pack;
  10090. #region Packet Session and User Check
  10091. if (m_checkPackets)
  10092. {
  10093. if (pickDelete.AgentData.SessionID != SessionId ||
  10094. pickDelete.AgentData.AgentID != AgentId)
  10095. return true;
  10096. }
  10097. #endregion
  10098. PickDelete handlerPickDelete = OnPickDelete;
  10099. if (handlerPickDelete != null)
  10100. handlerPickDelete(this, pickDelete.Data.PickID);
  10101. return true;
  10102. }
  10103. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  10104. {
  10105. PickGodDeletePacket pickGodDelete =
  10106. (PickGodDeletePacket)Pack;
  10107. #region Packet Session and User Check
  10108. if (m_checkPackets)
  10109. {
  10110. if (pickGodDelete.AgentData.SessionID != SessionId ||
  10111. pickGodDelete.AgentData.AgentID != AgentId)
  10112. return true;
  10113. }
  10114. #endregion
  10115. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  10116. if (handlerPickGodDelete != null)
  10117. handlerPickGodDelete(this,
  10118. pickGodDelete.AgentData.AgentID,
  10119. pickGodDelete.Data.PickID,
  10120. pickGodDelete.Data.QueryID);
  10121. return true;
  10122. }
  10123. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  10124. {
  10125. PickInfoUpdatePacket pickInfoUpdate =
  10126. (PickInfoUpdatePacket)Pack;
  10127. #region Packet Session and User Check
  10128. if (m_checkPackets)
  10129. {
  10130. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  10131. pickInfoUpdate.AgentData.AgentID != AgentId)
  10132. return true;
  10133. }
  10134. #endregion
  10135. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  10136. if (handlerPickInfoUpdate != null)
  10137. handlerPickInfoUpdate(this,
  10138. pickInfoUpdate.Data.PickID,
  10139. pickInfoUpdate.Data.CreatorID,
  10140. pickInfoUpdate.Data.TopPick,
  10141. Utils.BytesToString(pickInfoUpdate.Data.Name),
  10142. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  10143. pickInfoUpdate.Data.SnapshotID,
  10144. pickInfoUpdate.Data.SortOrder,
  10145. pickInfoUpdate.Data.Enabled);
  10146. return true;
  10147. }
  10148. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  10149. {
  10150. AvatarNotesUpdatePacket avatarNotesUpdate =
  10151. (AvatarNotesUpdatePacket)Pack;
  10152. #region Packet Session and User Check
  10153. if (m_checkPackets)
  10154. {
  10155. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  10156. avatarNotesUpdate.AgentData.AgentID != AgentId)
  10157. return true;
  10158. }
  10159. #endregion
  10160. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  10161. if (handlerAvatarNotesUpdate != null)
  10162. handlerAvatarNotesUpdate(this,
  10163. avatarNotesUpdate.Data.TargetID,
  10164. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10165. return true;
  10166. }
  10167. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10168. {
  10169. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10170. (AvatarInterestsUpdatePacket)Pack;
  10171. #region Packet Session and User Check
  10172. if (m_checkPackets)
  10173. {
  10174. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10175. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10176. return true;
  10177. }
  10178. #endregion
  10179. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10180. if (handlerAvatarInterestUpdate != null)
  10181. handlerAvatarInterestUpdate(this,
  10182. avatarInterestUpdate.PropertiesData.WantToMask,
  10183. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10184. avatarInterestUpdate.PropertiesData.SkillsMask,
  10185. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10186. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10187. return true;
  10188. }
  10189. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10190. {
  10191. GrantUserRightsPacket GrantUserRights =
  10192. (GrantUserRightsPacket)Pack;
  10193. #region Packet Session and User Check
  10194. if (m_checkPackets)
  10195. {
  10196. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10197. GrantUserRights.AgentData.AgentID != AgentId)
  10198. return true;
  10199. }
  10200. #endregion
  10201. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10202. if (GrantUserRightsHandler != null)
  10203. GrantUserRightsHandler(this,
  10204. GrantUserRights.Rights[0].AgentRelated,
  10205. GrantUserRights.Rights[0].RelatedRights);
  10206. return true;
  10207. }
  10208. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10209. {
  10210. PlacesQueryPacket placesQueryPacket =
  10211. (PlacesQueryPacket)Pack;
  10212. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10213. if (handlerPlacesQuery != null)
  10214. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10215. placesQueryPacket.TransactionData.TransactionID,
  10216. Utils.BytesToString(
  10217. placesQueryPacket.QueryData.QueryText),
  10218. placesQueryPacket.QueryData.QueryFlags,
  10219. (byte)placesQueryPacket.QueryData.Category,
  10220. Utils.BytesToString(
  10221. placesQueryPacket.QueryData.SimName),
  10222. this);
  10223. return true;
  10224. }
  10225. #endregion Packet Handlers
  10226. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10227. {
  10228. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10229. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10230. // TODO: don't create new blocks if recycling an old packet
  10231. scriptQuestion.Data.TaskID = taskID;
  10232. scriptQuestion.Data.ItemID = itemID;
  10233. scriptQuestion.Data.Questions = question;
  10234. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10235. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10236. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10237. }
  10238. /// <summary>
  10239. /// Handler called when we receive a logout packet.
  10240. /// </summary>
  10241. /// <param name="client"></param>
  10242. /// <param name="packet"></param>
  10243. /// <returns></returns>
  10244. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10245. {
  10246. if (packet.Type == PacketType.LogoutRequest)
  10247. {
  10248. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10249. }
  10250. return Logout(client);
  10251. }
  10252. /// <summary>
  10253. ///
  10254. /// </summary>
  10255. /// <param name="client"></param>
  10256. /// <returns></returns>
  10257. protected virtual bool Logout(IClientAPI client)
  10258. {
  10259. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10260. Action<IClientAPI> handlerLogout = OnLogout;
  10261. if (handlerLogout != null)
  10262. {
  10263. handlerLogout(client);
  10264. }
  10265. return true;
  10266. }
  10267. /// <summary>
  10268. /// </summary>
  10269. /// <remarks>
  10270. /// At the moment, we always reply that there is no cached texture.
  10271. /// </remarks>
  10272. /// <param name="simclient"></param>
  10273. /// <param name="packet"></param>
  10274. /// <returns></returns>
  10275. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10276. {
  10277. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10278. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10279. if (cachedtex.AgentData.SessionID != SessionId)
  10280. return false;
  10281. // TODO: don't create new blocks if recycling an old packet
  10282. cachedresp.AgentData.AgentID = AgentId;
  10283. cachedresp.AgentData.SessionID = m_sessionId;
  10284. cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
  10285. m_cachedTextureSerial++;
  10286. cachedresp.WearableData =
  10287. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  10288. int maxWearablesLoop = cachedtex.WearableData.Length;
  10289. if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
  10290. maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
  10291. // Find the cached baked textures for this user, if they're available
  10292. IAssetService cache = m_scene.AssetService;
  10293. IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
  10294. WearableCacheItem[] cacheItems = null;
  10295. if (bakedTextureModule != null && cache != null)
  10296. {
  10297. ScenePresence p = m_scene.GetScenePresence(AgentId);
  10298. if (p.Appearance != null)
  10299. {
  10300. if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
  10301. {
  10302. try
  10303. {
  10304. cacheItems = bakedTextureModule.Get(AgentId);
  10305. p.Appearance.WearableCacheItems = cacheItems;
  10306. p.Appearance.WearableCacheItemsDirty = false;
  10307. }
  10308. catch (Exception)
  10309. {
  10310. cacheItems = null;
  10311. }
  10312. }
  10313. else if (p.Appearance.WearableCacheItems != null)
  10314. {
  10315. cacheItems = p.Appearance.WearableCacheItems;
  10316. }
  10317. }
  10318. }
  10319. if (cacheItems != null)
  10320. {
  10321. // We need to make sure the asset stored in the bake is available on this server also by its assetid before we map it to a Cacheid.
  10322. // Copy the baked textures to the sim's assets cache (local only).
  10323. foreach (WearableCacheItem item in cacheItems)
  10324. {
  10325. if (cache.GetCached(item.TextureID.ToString()) == null)
  10326. {
  10327. item.TextureAsset.Temporary = true;
  10328. item.TextureAsset.Local = true;
  10329. cache.Store(item.TextureAsset);
  10330. }
  10331. }
  10332. // Return the cached textures
  10333. for (int i = 0; i < maxWearablesLoop; i++)
  10334. {
  10335. WearableCacheItem item =
  10336. WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex, cacheItems);
  10337. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10338. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10339. cachedresp.WearableData[i].HostName = new byte[0];
  10340. if (item != null && cachedtex.WearableData[i].ID == item.CacheId)
  10341. {
  10342. cachedresp.WearableData[i].TextureID = item.TextureID;
  10343. }
  10344. else
  10345. {
  10346. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10347. }
  10348. }
  10349. }
  10350. else
  10351. {
  10352. // Cached textures not available
  10353. for (int i = 0; i < maxWearablesLoop; i++)
  10354. {
  10355. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10356. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10357. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10358. cachedresp.WearableData[i].HostName = new byte[0];
  10359. }
  10360. }
  10361. cachedresp.Header.Zerocoded = true;
  10362. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10363. return true;
  10364. }
  10365. /// <summary>
  10366. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10367. /// its appearance texture cached.
  10368. /// </summary>
  10369. /// <param name="avatar"></param>
  10370. /// <param name="serial"></param>
  10371. /// <param name="cachedTextures"></param>
  10372. /// <returns></returns>
  10373. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10374. {
  10375. ScenePresence presence = avatar as ScenePresence;
  10376. if (presence == null)
  10377. return;
  10378. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10379. // TODO: don't create new blocks if recycling an old packet
  10380. cachedresp.AgentData.AgentID = m_agentId;
  10381. cachedresp.AgentData.SessionID = m_sessionId;
  10382. cachedresp.AgentData.SerialNum = serial;
  10383. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10384. for (int i = 0; i < cachedTextures.Count; i++)
  10385. {
  10386. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10387. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10388. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10389. cachedresp.WearableData[i].HostName = new byte[0];
  10390. }
  10391. cachedresp.Header.Zerocoded = true;
  10392. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10393. }
  10394. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10395. {
  10396. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10397. if (multipleupdate.AgentData.SessionID != SessionId)
  10398. return false;
  10399. // m_log.DebugFormat(
  10400. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10401. Scene tScene = (Scene)m_scene;
  10402. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10403. {
  10404. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10405. // Can't act on Null Data
  10406. if (block.Data != null)
  10407. {
  10408. uint localId = block.ObjectLocalID;
  10409. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10410. if (part == null)
  10411. {
  10412. // It's a ghost! tell the client to delete it from view.
  10413. simClient.SendKillObject(new List<uint> { localId });
  10414. }
  10415. else
  10416. {
  10417. // m_log.DebugFormat(
  10418. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10419. // i, block.Type, part.Name, part.LocalId);
  10420. // // Do this once since fetch parts creates a new array.
  10421. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10422. // for (int j = 0; j < parts.Length; j++)
  10423. // {
  10424. // part.StoreUndoState();
  10425. // parts[j].IgnoreUndoUpdate = true;
  10426. // }
  10427. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10428. switch (block.Type)
  10429. {
  10430. case 1:
  10431. Vector3 pos1 = new Vector3(block.Data, 0);
  10432. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10433. if (handlerUpdatePrimSinglePosition != null)
  10434. {
  10435. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10436. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10437. }
  10438. break;
  10439. case 2:
  10440. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10441. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10442. if (handlerUpdatePrimSingleRotation != null)
  10443. {
  10444. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10445. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10446. }
  10447. break;
  10448. case 3:
  10449. Vector3 rotPos = new Vector3(block.Data, 0);
  10450. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10451. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10452. if (handlerUpdatePrimSingleRotationPosition != null)
  10453. {
  10454. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10455. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10456. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10457. }
  10458. break;
  10459. case 4:
  10460. case 20:
  10461. Vector3 scale4 = new Vector3(block.Data, 0);
  10462. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10463. if (handlerUpdatePrimScale != null)
  10464. {
  10465. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10466. handlerUpdatePrimScale(localId, scale4, this);
  10467. }
  10468. break;
  10469. case 5:
  10470. Vector3 scale1 = new Vector3(block.Data, 12);
  10471. Vector3 pos11 = new Vector3(block.Data, 0);
  10472. handlerUpdatePrimScale = OnUpdatePrimScale;
  10473. if (handlerUpdatePrimScale != null)
  10474. {
  10475. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10476. handlerUpdatePrimScale(localId, scale1, this);
  10477. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10478. if (handlerUpdatePrimSinglePosition != null)
  10479. {
  10480. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10481. }
  10482. }
  10483. break;
  10484. case 9:
  10485. Vector3 pos2 = new Vector3(block.Data, 0);
  10486. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10487. if (handlerUpdateVector != null)
  10488. {
  10489. handlerUpdateVector(localId, pos2, this);
  10490. }
  10491. break;
  10492. case 10:
  10493. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10494. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10495. if (handlerUpdatePrimRotation != null)
  10496. {
  10497. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10498. handlerUpdatePrimRotation(localId, rot3, this);
  10499. }
  10500. break;
  10501. case 11:
  10502. Vector3 pos3 = new Vector3(block.Data, 0);
  10503. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10504. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10505. if (handlerUpdatePrimGroupRotation != null)
  10506. {
  10507. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10508. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10509. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10510. }
  10511. break;
  10512. case 12:
  10513. case 28:
  10514. Vector3 scale7 = new Vector3(block.Data, 0);
  10515. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10516. if (handlerUpdatePrimGroupScale != null)
  10517. {
  10518. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10519. handlerUpdatePrimGroupScale(localId, scale7, this);
  10520. }
  10521. break;
  10522. case 13:
  10523. Vector3 scale2 = new Vector3(block.Data, 12);
  10524. Vector3 pos4 = new Vector3(block.Data, 0);
  10525. handlerUpdatePrimScale = OnUpdatePrimScale;
  10526. if (handlerUpdatePrimScale != null)
  10527. {
  10528. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10529. handlerUpdatePrimScale(localId, scale2, this);
  10530. // Change the position based on scale (for bug number 246)
  10531. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10532. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10533. if (handlerUpdatePrimSinglePosition != null)
  10534. {
  10535. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10536. }
  10537. }
  10538. break;
  10539. case 29:
  10540. Vector3 scale5 = new Vector3(block.Data, 12);
  10541. Vector3 pos5 = new Vector3(block.Data, 0);
  10542. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10543. if (handlerUpdatePrimGroupScale != null)
  10544. {
  10545. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10546. part.StoreUndoState(true);
  10547. part.IgnoreUndoUpdate = true;
  10548. handlerUpdatePrimGroupScale(localId, scale5, this);
  10549. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10550. if (handlerUpdateVector != null)
  10551. {
  10552. handlerUpdateVector(localId, pos5, this);
  10553. }
  10554. part.IgnoreUndoUpdate = false;
  10555. }
  10556. break;
  10557. case 21:
  10558. Vector3 scale6 = new Vector3(block.Data, 12);
  10559. Vector3 pos6 = new Vector3(block.Data, 0);
  10560. handlerUpdatePrimScale = OnUpdatePrimScale;
  10561. if (handlerUpdatePrimScale != null)
  10562. {
  10563. part.StoreUndoState(false);
  10564. part.IgnoreUndoUpdate = true;
  10565. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10566. handlerUpdatePrimScale(localId, scale6, this);
  10567. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10568. if (handlerUpdatePrimSinglePosition != null)
  10569. {
  10570. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10571. }
  10572. part.IgnoreUndoUpdate = false;
  10573. }
  10574. break;
  10575. default:
  10576. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10577. break;
  10578. }
  10579. // for (int j = 0; j < parts.Length; j++)
  10580. // parts[j].IgnoreUndoUpdate = false;
  10581. }
  10582. }
  10583. }
  10584. return true;
  10585. }
  10586. public void RequestMapLayer()
  10587. {
  10588. //should be getting the map layer from the grid server
  10589. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10590. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10591. // TODO: don't create new blocks if recycling an old packet
  10592. mapReply.AgentData.AgentID = AgentId;
  10593. mapReply.AgentData.Flags = 0;
  10594. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10595. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10596. mapReply.LayerData[0].Bottom = 0;
  10597. mapReply.LayerData[0].Left = 0;
  10598. mapReply.LayerData[0].Top = 30000;
  10599. mapReply.LayerData[0].Right = 30000;
  10600. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10601. mapReply.Header.Zerocoded = true;
  10602. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10603. }
  10604. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10605. {
  10606. /*
  10607. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10608. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10609. mbReply.AgentData.AgentId = AgentId;
  10610. int len;
  10611. if (simMapProfiles == null)
  10612. len = 0;
  10613. else
  10614. len = simMapProfiles.Count;
  10615. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10616. int iii;
  10617. for (iii = 0; iii < len; iii++)
  10618. {
  10619. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10620. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10621. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10622. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10623. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10624. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10625. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10626. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10627. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10628. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10629. }
  10630. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10631. */
  10632. }
  10633. /// <summary>
  10634. /// Sets the throttles from values supplied by the client
  10635. /// </summary>
  10636. /// <param name="throttles"></param>
  10637. public void SetChildAgentThrottle(byte[] throttles)
  10638. {
  10639. m_udpClient.SetThrottles(throttles);
  10640. }
  10641. /// <summary>
  10642. /// Get the current throttles for this client as a packed byte array
  10643. /// </summary>
  10644. /// <param name="multiplier">Unused</param>
  10645. /// <returns></returns>
  10646. public byte[] GetThrottlesPacked(float multiplier)
  10647. {
  10648. return m_udpClient.GetThrottlesPacked(multiplier);
  10649. }
  10650. /// <summary>
  10651. /// Cruft?
  10652. /// </summary>
  10653. public virtual void InPacket(object NewPack)
  10654. {
  10655. throw new NotImplementedException();
  10656. }
  10657. /// <summary>
  10658. /// This is the starting point for sending a simulator packet out to the client
  10659. /// </summary>
  10660. /// <param name="packet">Packet to send</param>
  10661. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10662. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10663. {
  10664. #region BinaryStats
  10665. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10666. #endregion BinaryStats
  10667. OutPacket(packet, throttlePacketType, true);
  10668. }
  10669. /// <summary>
  10670. /// This is the starting point for sending a simulator packet out to the client
  10671. /// </summary>
  10672. /// <param name="packet">Packet to send</param>
  10673. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10674. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10675. /// packets (the default), or false to disable splitting if the calling code
  10676. /// handles splitting manually</param>
  10677. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10678. {
  10679. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10680. }
  10681. /// <summary>
  10682. /// This is the starting point for sending a simulator packet out to the client
  10683. /// </summary>
  10684. /// <param name="packet">Packet to send</param>
  10685. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10686. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10687. /// packets (the default), or false to disable splitting if the calling code
  10688. /// handles splitting manually</param>
  10689. /// <param name="method">The method to be called in the event this packet is reliable
  10690. /// and unacknowledged. The server will provide normal resend capability if you do not
  10691. /// provide your own method.</param>
  10692. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10693. {
  10694. if (m_outPacketsToDrop != null)
  10695. if (m_outPacketsToDrop.Contains(packet.Type.ToString()))
  10696. return;
  10697. if (DebugPacketLevel > 0)
  10698. {
  10699. bool logPacket = true;
  10700. if (DebugPacketLevel <= 255
  10701. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10702. logPacket = false;
  10703. if (DebugPacketLevel <= 200
  10704. && (packet.Type == PacketType.ImagePacket
  10705. || packet.Type == PacketType.ImageData
  10706. || packet.Type == PacketType.LayerData
  10707. || packet.Type == PacketType.CoarseLocationUpdate))
  10708. logPacket = false;
  10709. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10710. logPacket = false;
  10711. if (DebugPacketLevel <= 50
  10712. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10713. logPacket = false;
  10714. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10715. logPacket = false;
  10716. if (logPacket)
  10717. m_log.DebugFormat(
  10718. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10719. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10720. }
  10721. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10722. }
  10723. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10724. {
  10725. float locx = 0;
  10726. float locy = 0;
  10727. float locz = 0;
  10728. uint regionX = 0;
  10729. uint regionY = 0;
  10730. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10731. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10732. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10733. locz = Convert.ToSingle(args[2]);
  10734. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10735. if (handlerAutoPilotGo != null)
  10736. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10737. }
  10738. /// <summary>
  10739. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10740. /// </summary>
  10741. /// <param name="Pack">OpenMetaverse.packet</param>
  10742. public void ProcessInPacket(Packet packet)
  10743. {
  10744. if (m_inPacketsToDrop != null)
  10745. if (m_inPacketsToDrop.Contains(packet.Type.ToString()))
  10746. return;
  10747. if (DebugPacketLevel > 0)
  10748. {
  10749. bool logPacket = true;
  10750. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10751. logPacket = false;
  10752. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10753. logPacket = false;
  10754. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10755. logPacket = false;
  10756. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10757. logPacket = false;
  10758. if (logPacket)
  10759. m_log.DebugFormat(
  10760. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10761. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10762. }
  10763. if (!ProcessPacketMethod(packet))
  10764. m_log.WarnFormat(
  10765. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10766. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10767. }
  10768. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10769. {
  10770. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10771. shape.PCode = addPacket.ObjectData.PCode;
  10772. shape.State = addPacket.ObjectData.State;
  10773. shape.LastAttachPoint = addPacket.ObjectData.State;
  10774. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10775. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10776. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10777. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10778. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10779. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10780. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10781. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10782. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10783. shape.Scale = addPacket.ObjectData.Scale;
  10784. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10785. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10786. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10787. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10788. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10789. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10790. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10791. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10792. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10793. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10794. shape.TextureEntry = ntex.GetBytes();
  10795. //shape.Textures = ntex;
  10796. return shape;
  10797. }
  10798. public ClientInfo GetClientInfo()
  10799. {
  10800. ClientInfo info = m_udpClient.GetClientInfo();
  10801. info.proxyEP = null;
  10802. if (info.agentcircuit == null)
  10803. info.agentcircuit = RequestClientInfo();
  10804. return info;
  10805. }
  10806. public void SetClientInfo(ClientInfo info)
  10807. {
  10808. m_udpClient.SetClientInfo(info);
  10809. }
  10810. #region Media Parcel Members
  10811. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10812. {
  10813. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10814. commandMessagePacket.CommandBlock.Flags = flags;
  10815. commandMessagePacket.CommandBlock.Command = (uint)command;
  10816. commandMessagePacket.CommandBlock.Time = time;
  10817. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10818. }
  10819. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10820. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10821. byte mediaLoop)
  10822. {
  10823. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10824. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10825. updatePacket.DataBlock.MediaID = mediaTextureID;
  10826. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10827. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10828. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10829. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10830. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10831. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10832. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10833. }
  10834. #endregion
  10835. #region Camera
  10836. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10837. {
  10838. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10839. packet.ObjectData.ObjectID = objectID;
  10840. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10841. uint idx = 0;
  10842. foreach (KeyValuePair<int, float> pair in parameters)
  10843. {
  10844. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10845. block.Type = pair.Key;
  10846. block.Value = pair.Value;
  10847. camPropBlock[idx++] = block;
  10848. }
  10849. packet.CameraProperty = camPropBlock;
  10850. OutPacket(packet, ThrottleOutPacketType.Task);
  10851. }
  10852. public void SendClearFollowCamProperties(UUID objectID)
  10853. {
  10854. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10855. packet.ObjectData.ObjectID = objectID;
  10856. OutPacket(packet, ThrottleOutPacketType.Task);
  10857. }
  10858. #endregion
  10859. public void SetClientOption(string option, string value)
  10860. {
  10861. switch (option)
  10862. {
  10863. default:
  10864. break;
  10865. }
  10866. }
  10867. public string GetClientOption(string option)
  10868. {
  10869. switch (option)
  10870. {
  10871. default:
  10872. break;
  10873. }
  10874. return string.Empty;
  10875. }
  10876. #region IClientCore
  10877. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10878. /// <summary>
  10879. /// Register an interface on this client, should only be called in the constructor.
  10880. /// </summary>
  10881. /// <typeparam name="T"></typeparam>
  10882. /// <param name="iface"></param>
  10883. protected void RegisterInterface<T>(T iface)
  10884. {
  10885. lock (m_clientInterfaces)
  10886. {
  10887. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10888. {
  10889. m_clientInterfaces.Add(typeof(T), iface);
  10890. }
  10891. }
  10892. }
  10893. public bool TryGet<T>(out T iface)
  10894. {
  10895. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10896. {
  10897. iface = (T)m_clientInterfaces[typeof(T)];
  10898. return true;
  10899. }
  10900. iface = default(T);
  10901. return false;
  10902. }
  10903. public T Get<T>()
  10904. {
  10905. return (T)m_clientInterfaces[typeof(T)];
  10906. }
  10907. public void Disconnect(string reason)
  10908. {
  10909. Kick(reason);
  10910. Thread.Sleep(1000);
  10911. Disconnect();
  10912. }
  10913. public void Disconnect()
  10914. {
  10915. Close();
  10916. }
  10917. #endregion
  10918. public void RefreshGroupMembership()
  10919. {
  10920. if (m_GroupsModule != null)
  10921. {
  10922. GroupMembershipData[] GroupMembership =
  10923. m_GroupsModule.GetMembershipData(AgentId);
  10924. m_groupPowers.Clear();
  10925. if (GroupMembership != null)
  10926. {
  10927. for (int i = 0; i < GroupMembership.Length; i++)
  10928. {
  10929. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10930. }
  10931. }
  10932. }
  10933. }
  10934. public string Report()
  10935. {
  10936. return m_udpClient.GetStats();
  10937. }
  10938. public string XReport(string uptime, string version)
  10939. {
  10940. return String.Empty;
  10941. }
  10942. public OSDMap OReport(string uptime, string version)
  10943. {
  10944. return new OSDMap();
  10945. }
  10946. /// <summary>
  10947. /// Make an asset request to the asset service in response to a client request.
  10948. /// </summary>
  10949. /// <param name="transferRequest"></param>
  10950. /// <param name="taskID"></param>
  10951. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10952. {
  10953. UUID requestID = UUID.Zero;
  10954. int sourceType = transferRequest.TransferInfo.SourceType;
  10955. if (sourceType == (int)SourceType.Asset)
  10956. {
  10957. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10958. }
  10959. else if (sourceType == (int)SourceType.SimInventoryItem)
  10960. {
  10961. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10962. }
  10963. else if (sourceType == (int)SourceType.SimEstate)
  10964. {
  10965. requestID = taskID;
  10966. }
  10967. // m_log.DebugFormat(
  10968. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10969. // requestID, taskID, (SourceType)sourceType, Name);
  10970. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10971. }
  10972. /// <summary>
  10973. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10974. /// </summary>
  10975. /// <param name="id"></param>
  10976. /// <param name="sender"></param>
  10977. /// <param name="asset"></param>
  10978. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10979. {
  10980. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10981. UUID requestID = UUID.Zero;
  10982. byte source = (byte)SourceType.Asset;
  10983. AssetRequestToClient req = new AssetRequestToClient();
  10984. if (asset == null)
  10985. {
  10986. // Try the user's asset server
  10987. IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface<IInventoryAccessModule>();
  10988. string assetServerURL = string.Empty;
  10989. if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL))
  10990. {
  10991. if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("="))
  10992. assetServerURL = assetServerURL + "/";
  10993. //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id);
  10994. asset = m_scene.AssetService.Get(assetServerURL + id);
  10995. }
  10996. if (asset == null)
  10997. {
  10998. req.AssetInf = null;
  10999. req.AssetRequestSource = source;
  11000. req.IsTextureRequest = false;
  11001. req.NumPackets = 0;
  11002. req.Params = transferRequest.TransferInfo.Params;
  11003. req.RequestAssetID = requestID;
  11004. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  11005. SendAssetNotFound(req);
  11006. return;
  11007. }
  11008. }
  11009. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  11010. {
  11011. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  11012. }
  11013. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  11014. {
  11015. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  11016. source = (byte)SourceType.SimInventoryItem;
  11017. //m_log.Debug("asset request " + requestID);
  11018. }
  11019. // Scripts cannot be retrieved by direct request
  11020. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  11021. return;
  11022. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  11023. req.AssetInf = asset;
  11024. req.AssetRequestSource = source;
  11025. req.IsTextureRequest = false;
  11026. req.NumPackets = CalculateNumPackets(asset.Data);
  11027. req.Params = transferRequest.TransferInfo.Params;
  11028. req.RequestAssetID = requestID;
  11029. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  11030. SendAsset(req);
  11031. }
  11032. /// <summary>
  11033. /// Calculate the number of packets required to send the asset to the client.
  11034. /// </summary>
  11035. /// <param name="data"></param>
  11036. /// <returns></returns>
  11037. private static int CalculateNumPackets(byte[] data)
  11038. {
  11039. const uint m_maxPacketSize = 600;
  11040. int numPackets = 1;
  11041. if (data == null)
  11042. return 0;
  11043. if (data.LongLength > m_maxPacketSize)
  11044. {
  11045. // over max number of bytes so split up file
  11046. long restData = data.LongLength - m_maxPacketSize;
  11047. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  11048. numPackets += restPackets;
  11049. }
  11050. return numPackets;
  11051. }
  11052. public void SendRebakeAvatarTextures(UUID textureID)
  11053. {
  11054. RebakeAvatarTexturesPacket pack =
  11055. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  11056. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  11057. pack.TextureData.TextureID = textureID;
  11058. OutPacket(pack, ThrottleOutPacketType.Task);
  11059. }
  11060. public struct PacketProcessor
  11061. {
  11062. /// <summary>
  11063. /// Packet handling method.
  11064. /// </summary>
  11065. public PacketMethod method { get; set; }
  11066. /// <summary>
  11067. /// Should this packet be handled asynchronously?
  11068. /// </summary>
  11069. public bool Async { get; set; }
  11070. /// <summary>
  11071. /// If async is true, should this packet be handled in the async engine or given directly to a threadpool
  11072. /// thread?
  11073. /// </summary>
  11074. public bool InEngine { get; set; }
  11075. }
  11076. public class AsyncPacketProcess
  11077. {
  11078. public bool result = false;
  11079. public readonly LLClientView ClientView = null;
  11080. public readonly Packet Pack = null;
  11081. public readonly PacketMethod Method = null;
  11082. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  11083. {
  11084. ClientView = pClientview;
  11085. Method = pMethod;
  11086. Pack = pPack;
  11087. }
  11088. }
  11089. public static OSD BuildEvent(string eventName, OSD eventBody)
  11090. {
  11091. OSDMap osdEvent = new OSDMap(2);
  11092. osdEvent.Add("message", new OSDString(eventName));
  11093. osdEvent.Add("body", eventBody);
  11094. return osdEvent;
  11095. }
  11096. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  11097. {
  11098. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  11099. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  11100. packet.AgentData.AgentID = AgentId;
  11101. packet.AgentData.AvatarID = avatarID;
  11102. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  11103. packet.PropertiesData.WantToMask = wantMask;
  11104. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  11105. packet.PropertiesData.SkillsMask = skillsMask;
  11106. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  11107. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  11108. OutPacket(packet, ThrottleOutPacketType.Task);
  11109. }
  11110. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  11111. {
  11112. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  11113. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  11114. packet.AgentData.AgentID = agentID;
  11115. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  11116. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  11117. packet.Rights[0].AgentRelated = friendID;
  11118. packet.Rights[0].RelatedRights = rights;
  11119. OutPacket(packet, ThrottleOutPacketType.Task);
  11120. }
  11121. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  11122. {
  11123. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  11124. dialog.Data.ObjectID = objectId;
  11125. dialog.Data.ChatChannel = chatChannel;
  11126. dialog.Data.ImageID = UUID.Zero;
  11127. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  11128. // this is the username of the *owner*
  11129. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  11130. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  11131. dialog.Data.Message = Util.StringToBytes256(message);
  11132. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  11133. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  11134. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  11135. dialog.Buttons = buttons;
  11136. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  11137. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  11138. dialog.OwnerData[0].OwnerID = ownerID;
  11139. OutPacket(dialog, ThrottleOutPacketType.Task);
  11140. }
  11141. public void SendAgentTerseUpdate(ISceneEntity p)
  11142. {
  11143. if (p is ScenePresence)
  11144. {
  11145. // m_log.DebugFormat(
  11146. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  11147. // p.Name, Name, Scene.Name);
  11148. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  11149. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  11150. // velocity, collision plane and avatar height
  11151. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  11152. // when the avatar stands up
  11153. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  11154. CreateImprovedTerseBlock(p, false);
  11155. const float TIME_DILATION = 1.0f;
  11156. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  11157. ImprovedTerseObjectUpdatePacket packet
  11158. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  11159. PacketType.ImprovedTerseObjectUpdate);
  11160. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  11161. packet.RegionData.TimeDilation = timeDilation;
  11162. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  11163. packet.ObjectData[0] = block;
  11164. OutPacket(packet, ThrottleOutPacketType.Task, true);
  11165. }
  11166. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  11167. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  11168. }
  11169. public void SendPlacesReply(UUID queryID, UUID transactionID,
  11170. PlacesReplyData[] data)
  11171. {
  11172. PlacesReplyPacket reply = null;
  11173. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  11174. new PlacesReplyPacket.QueryDataBlock[0];
  11175. for (int i = 0 ; i < data.Length ; i++)
  11176. {
  11177. PlacesReplyPacket.QueryDataBlock block =
  11178. new PlacesReplyPacket.QueryDataBlock();
  11179. block.OwnerID = data[i].OwnerID;
  11180. block.Name = Util.StringToBytes256(data[i].Name);
  11181. block.Desc = Util.StringToBytes1024(data[i].Desc);
  11182. block.ActualArea = data[i].ActualArea;
  11183. block.BillableArea = data[i].BillableArea;
  11184. block.Flags = data[i].Flags;
  11185. block.GlobalX = data[i].GlobalX;
  11186. block.GlobalY = data[i].GlobalY;
  11187. block.GlobalZ = data[i].GlobalZ;
  11188. block.SimName = Util.StringToBytes256(data[i].SimName);
  11189. block.SnapshotID = data[i].SnapshotID;
  11190. block.Dwell = data[i].Dwell;
  11191. block.Price = data[i].Price;
  11192. if (reply != null && reply.Length + block.Length > 1400)
  11193. {
  11194. OutPacket(reply, ThrottleOutPacketType.Task);
  11195. reply = null;
  11196. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  11197. }
  11198. if (reply == null)
  11199. {
  11200. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  11201. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  11202. reply.AgentData.AgentID = AgentId;
  11203. reply.AgentData.QueryID = queryID;
  11204. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  11205. reply.TransactionData.TransactionID = transactionID;
  11206. reply.QueryData = dataBlocks;
  11207. }
  11208. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  11209. dataBlocks[dataBlocks.Length - 1] = block;
  11210. reply.QueryData = dataBlocks;
  11211. }
  11212. if (reply != null)
  11213. OutPacket(reply, ThrottleOutPacketType.Task);
  11214. }
  11215. public void SendRemoveInventoryItems(UUID[] items)
  11216. {
  11217. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11218. if (eq == null)
  11219. {
  11220. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11221. return;
  11222. }
  11223. OSDMap llsd = new OSDMap(3);
  11224. OSDMap AgentDataMap = new OSDMap(1);
  11225. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11226. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11227. OSDArray AgentData = new OSDArray(1);
  11228. AgentData.Add(AgentDataMap);
  11229. llsd.Add("AgentData", AgentData);
  11230. OSDArray ItemData = new OSDArray();
  11231. foreach (UUID item in items)
  11232. {
  11233. OSDMap ItemDataMap = new OSDMap(2);
  11234. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  11235. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11236. ItemData.Add(ItemDataMap);
  11237. }
  11238. llsd.Add("InventoryData", ItemData);
  11239. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  11240. llsd), AgentId);
  11241. }
  11242. public void SendRemoveInventoryFolders(UUID[] folders)
  11243. {
  11244. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11245. if (eq == null)
  11246. {
  11247. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11248. return;
  11249. }
  11250. OSDMap llsd = new OSDMap(3);
  11251. OSDMap AgentDataMap = new OSDMap(1);
  11252. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11253. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11254. OSDArray AgentData = new OSDArray(1);
  11255. AgentData.Add(AgentDataMap);
  11256. llsd.Add("AgentData", AgentData);
  11257. OSDArray FolderData = new OSDArray();
  11258. foreach (UUID folder in folders)
  11259. {
  11260. OSDMap FolderDataMap = new OSDMap(2);
  11261. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11262. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11263. FolderData.Add(FolderDataMap);
  11264. }
  11265. llsd.Add("FolderData", FolderData);
  11266. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11267. llsd), AgentId);
  11268. }
  11269. private byte[] EncodeU32(uint val)
  11270. {
  11271. byte[] ret = BitConverter.GetBytes(val);
  11272. if (BitConverter.IsLittleEndian)
  11273. Array.Reverse(ret);
  11274. return ret;
  11275. }
  11276. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11277. {
  11278. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11279. if (eq == null)
  11280. {
  11281. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11282. return;
  11283. }
  11284. OSDMap llsd = new OSDMap(3);
  11285. OSDMap AgentDataMap = new OSDMap(1);
  11286. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11287. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11288. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11289. OSDArray AgentData = new OSDArray(1);
  11290. AgentData.Add(AgentDataMap);
  11291. llsd.Add("AgentData", AgentData);
  11292. OSDArray FolderData = new OSDArray();
  11293. foreach (InventoryFolderBase folder in folders)
  11294. {
  11295. OSDMap FolderDataMap = new OSDMap(5);
  11296. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11297. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11298. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11299. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11300. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11301. FolderData.Add(FolderDataMap);
  11302. }
  11303. llsd.Add("FolderData", FolderData);
  11304. OSDArray ItemData = new OSDArray();
  11305. foreach (InventoryItemBase item in items)
  11306. {
  11307. OSDMap ItemDataMap = new OSDMap();
  11308. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11309. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11310. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11311. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11312. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11313. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11314. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11315. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11316. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11317. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11318. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11319. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11320. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11321. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11322. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11323. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11324. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11325. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11326. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11327. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11328. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11329. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11330. (sbyte)item.AssetType, item.AssetID,
  11331. item.GroupID, 100,
  11332. item.Owner, item.CreatorIdAsUuid,
  11333. item.ID, item.Folder,
  11334. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11335. (uint)PermissionMask.All)
  11336. )));
  11337. ItemDataMap.Add("CallbackID", 0);
  11338. ItemData.Add(ItemDataMap);
  11339. }
  11340. llsd.Add("ItemData", ItemData);
  11341. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11342. llsd), AgentId);
  11343. }
  11344. private HashSet<string> m_outPacketsToDrop;
  11345. public bool AddOutPacketToDropSet(string packetName)
  11346. {
  11347. if (m_outPacketsToDrop == null)
  11348. m_outPacketsToDrop = new HashSet<string>();
  11349. return m_outPacketsToDrop.Add(packetName);
  11350. }
  11351. public bool RemoveOutPacketFromDropSet(string packetName)
  11352. {
  11353. if (m_outPacketsToDrop == null)
  11354. return false;
  11355. return m_outPacketsToDrop.Remove(packetName);
  11356. }
  11357. public HashSet<string> GetOutPacketDropSet()
  11358. {
  11359. return new HashSet<string>(m_outPacketsToDrop);
  11360. }
  11361. private HashSet<string> m_inPacketsToDrop;
  11362. public bool AddInPacketToDropSet(string packetName)
  11363. {
  11364. if (m_inPacketsToDrop == null)
  11365. m_inPacketsToDrop = new HashSet<string>();
  11366. return m_inPacketsToDrop.Add(packetName);
  11367. }
  11368. public bool RemoveInPacketFromDropSet(string packetName)
  11369. {
  11370. if (m_inPacketsToDrop == null)
  11371. return false;
  11372. return m_inPacketsToDrop.Remove(packetName);
  11373. }
  11374. public HashSet<string> GetInPacketDropSet()
  11375. {
  11376. return new HashSet<string>(m_inPacketsToDrop);
  11377. }
  11378. }
  11379. }