LLClientView.cs 575 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058
  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 GenericMessage OnGenericMessage;
  67. public event BinaryGenericMessage OnBinaryGenericMessage;
  68. public event Action<IClientAPI> OnLogout;
  69. public event ObjectPermissions OnObjectPermissions;
  70. public event Action<IClientAPI> OnConnectionClosed;
  71. public event ViewerEffectEventHandler OnViewerEffect;
  72. public event ImprovedInstantMessage OnInstantMessage;
  73. public event ChatMessage OnChatFromClient;
  74. public event TextureRequest OnRequestTexture;
  75. public event RezObject OnRezObject;
  76. public event DeRezObject OnDeRezObject;
  77. public event ModifyTerrain OnModifyTerrain;
  78. public event Action<IClientAPI> OnRegionHandShakeReply;
  79. public event GenericCall1 OnRequestWearables;
  80. public event CachedTextureRequest OnCachedTextureRequest;
  81. public event SetAppearance OnSetAppearance;
  82. public event AvatarNowWearing OnAvatarNowWearing;
  83. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  84. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  85. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  86. public event ObjectAttach OnObjectAttach;
  87. public event ObjectDeselect OnObjectDetach;
  88. public event ObjectDrop OnObjectDrop;
  89. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  90. public event UpdateAgent OnPreAgentUpdate;
  91. public event UpdateAgent OnAgentUpdate;
  92. public event UpdateAgent OnAgentCameraUpdate;
  93. public event AgentRequestSit OnAgentRequestSit;
  94. public event AgentSit OnAgentSit;
  95. public event AvatarPickerRequest OnAvatarPickerRequest;
  96. public event StartAnim OnStartAnim;
  97. public event StopAnim OnStopAnim;
  98. public event Action<IClientAPI> OnRequestAvatarsData;
  99. public event LinkObjects OnLinkObjects;
  100. public event DelinkObjects OnDelinkObjects;
  101. public event GrabObject OnGrabObject;
  102. public event DeGrabObject OnDeGrabObject;
  103. public event SpinStart OnSpinStart;
  104. public event SpinStop OnSpinStop;
  105. public event ObjectDuplicate OnObjectDuplicate;
  106. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  107. public event MoveObject OnGrabUpdate;
  108. public event SpinObject OnSpinUpdate;
  109. public event AddNewPrim OnAddPrim;
  110. public event RequestGodlikePowers OnRequestGodlikePowers;
  111. public event GodKickUser OnGodKickUser;
  112. public event ObjectExtraParams OnUpdateExtraParams;
  113. public event UpdateShape OnUpdatePrimShape;
  114. public event ObjectRequest OnObjectRequest;
  115. public event ObjectSelect OnObjectSelect;
  116. public event ObjectDeselect OnObjectDeselect;
  117. public event GenericCall7 OnObjectDescription;
  118. public event GenericCall7 OnObjectName;
  119. public event GenericCall7 OnObjectClickAction;
  120. public event GenericCall7 OnObjectMaterial;
  121. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  122. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  123. public event UpdatePrimFlags OnUpdatePrimFlags;
  124. public event UpdatePrimTexture OnUpdatePrimTexture;
  125. public event UpdateVector OnUpdatePrimGroupPosition;
  126. public event UpdateVector OnUpdatePrimSinglePosition;
  127. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  128. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  129. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  130. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  131. public event UpdateVector OnUpdatePrimScale;
  132. public event UpdateVector OnUpdatePrimGroupScale;
  133. public event StatusChange OnChildAgentStatus;
  134. public event GenericCall2 OnStopMovement;
  135. public event Action<UUID> OnRemoveAvatar;
  136. public event RequestMapBlocks OnRequestMapBlocks;
  137. public event RequestMapName OnMapNameRequest;
  138. public event TeleportLocationRequest OnTeleportLocationRequest;
  139. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  140. public event TeleportCancel OnTeleportCancel;
  141. public event DisconnectUser OnDisconnectUser;
  142. public event RequestAvatarProperties OnRequestAvatarProperties;
  143. public event SetAlwaysRun OnSetAlwaysRun;
  144. public event FetchInventory OnAgentDataUpdateRequest;
  145. public event TeleportLocationRequest OnSetStartLocationRequest;
  146. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  147. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  148. public event LinkInventoryItem OnLinkInventoryItem;
  149. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  150. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  151. public event MoveInventoryFolder OnMoveInventoryFolder;
  152. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  153. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  154. public event FetchInventory OnFetchInventory;
  155. public event RequestTaskInventory OnRequestTaskInventory;
  156. public event UpdateInventoryItem OnUpdateInventoryItem;
  157. public event CopyInventoryItem OnCopyInventoryItem;
  158. public event MoveInventoryItem OnMoveInventoryItem;
  159. public event RemoveInventoryItem OnRemoveInventoryItem;
  160. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  161. public event UDPAssetUploadRequest OnAssetUploadRequest;
  162. public event XferReceive OnXferReceive;
  163. public event RequestXfer OnRequestXfer;
  164. public event ConfirmXfer OnConfirmXfer;
  165. public event AbortXfer OnAbortXfer;
  166. public event RequestTerrain OnRequestTerrain;
  167. public event RezScript OnRezScript;
  168. public event UpdateTaskInventory OnUpdateTaskInventory;
  169. public event MoveTaskInventory OnMoveTaskItem;
  170. public event RemoveTaskInventory OnRemoveTaskItem;
  171. public event RequestAsset OnRequestAsset;
  172. public event UUIDNameRequest OnNameFromUUIDRequest;
  173. public event ParcelAccessListRequest OnParcelAccessListRequest;
  174. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  175. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  176. public event ParcelDivideRequest OnParcelDivideRequest;
  177. public event ParcelJoinRequest OnParcelJoinRequest;
  178. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  179. public event ParcelSelectObjects OnParcelSelectObjects;
  180. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  181. public event ParcelAbandonRequest OnParcelAbandonRequest;
  182. public event ParcelGodForceOwner OnParcelGodForceOwner;
  183. public event ParcelReclaim OnParcelReclaim;
  184. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  185. public event ParcelDeedToGroup OnParcelDeedToGroup;
  186. public event RegionInfoRequest OnRegionInfoRequest;
  187. public event EstateCovenantRequest OnEstateCovenantRequest;
  188. public event FriendActionDelegate OnApproveFriendRequest;
  189. public event FriendActionDelegate OnDenyFriendRequest;
  190. public event FriendshipTermination OnTerminateFriendship;
  191. public event GrantUserFriendRights OnGrantUserRights;
  192. public event MoneyTransferRequest OnMoneyTransferRequest;
  193. public event EconomyDataRequest OnEconomyDataRequest;
  194. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  195. public event ParcelBuy OnParcelBuy;
  196. public event UUIDNameRequest OnTeleportHomeRequest;
  197. public event UUIDNameRequest OnUUIDGroupNameRequest;
  198. public event ScriptAnswer OnScriptAnswer;
  199. public event RequestPayPrice OnRequestPayPrice;
  200. public event ObjectSaleInfo OnObjectSaleInfo;
  201. public event ObjectBuy OnObjectBuy;
  202. public event BuyObjectInventory OnBuyObjectInventory;
  203. public event AgentSit OnUndo;
  204. public event AgentSit OnRedo;
  205. public event LandUndo OnLandUndo;
  206. public event ForceReleaseControls OnForceReleaseControls;
  207. public event GodLandStatRequest OnLandStatRequest;
  208. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  209. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  210. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  211. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  212. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  213. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  214. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  215. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  216. public event BakeTerrain OnBakeTerrain;
  217. public event RequestTerrain OnUploadTerrain;
  218. public event EstateChangeInfo OnEstateChangeInfo;
  219. public event EstateManageTelehub OnEstateManageTelehub;
  220. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  221. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  222. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  223. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  224. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  225. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  226. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  227. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  228. public event RegionHandleRequest OnRegionHandleRequest;
  229. public event ParcelInfoRequest OnParcelInfoRequest;
  230. public event ScriptReset OnScriptReset;
  231. public event GetScriptRunning OnGetScriptRunning;
  232. public event SetScriptRunning OnSetScriptRunning;
  233. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  234. public event TerrainUnacked OnUnackedTerrain;
  235. public event ActivateGesture OnActivateGesture;
  236. public event DeactivateGesture OnDeactivateGesture;
  237. public event ObjectOwner OnObjectOwner;
  238. public event DirPlacesQuery OnDirPlacesQuery;
  239. public event DirFindQuery OnDirFindQuery;
  240. public event DirLandQuery OnDirLandQuery;
  241. public event DirPopularQuery OnDirPopularQuery;
  242. public event DirClassifiedQuery OnDirClassifiedQuery;
  243. public event EventInfoRequest OnEventInfoRequest;
  244. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  245. public event MapItemRequest OnMapItemRequest;
  246. public event OfferCallingCard OnOfferCallingCard;
  247. public event AcceptCallingCard OnAcceptCallingCard;
  248. public event DeclineCallingCard OnDeclineCallingCard;
  249. public event SoundTrigger OnSoundTrigger;
  250. public event StartLure OnStartLure;
  251. public event TeleportLureRequest OnTeleportLureRequest;
  252. public event NetworkStats OnNetworkStatsUpdate;
  253. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  254. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  255. public event ClassifiedDelete OnClassifiedDelete;
  256. public event ClassifiedDelete OnClassifiedGodDelete;
  257. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  258. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  259. public event EventGodDelete OnEventGodDelete;
  260. public event ParcelDwellRequest OnParcelDwellRequest;
  261. public event UserInfoRequest OnUserInfoRequest;
  262. public event UpdateUserInfo OnUpdateUserInfo;
  263. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  264. public event PickDelete OnPickDelete;
  265. public event PickGodDelete OnPickGodDelete;
  266. public event PickInfoUpdate OnPickInfoUpdate;
  267. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  268. public event MuteListRequest OnMuteListRequest;
  269. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  270. public event PlacesQuery OnPlacesQuery;
  271. public event AgentFOV OnAgentFOV;
  272. public event FindAgentUpdate OnFindAgent;
  273. public event TrackAgentUpdate OnTrackAgent;
  274. public event NewUserReport OnUserReport;
  275. public event SaveStateHandler OnSaveState;
  276. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  277. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  278. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  279. public event FreezeUserUpdate OnParcelFreezeUser;
  280. public event EjectUserUpdate OnParcelEjectUser;
  281. public event ParcelBuyPass OnParcelBuyPass;
  282. public event ParcelGodMark OnParcelGodMark;
  283. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  284. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  285. public event SimWideDeletesDelegate OnSimWideDeletes;
  286. public event SendPostcard OnSendPostcard;
  287. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  288. public event MuteListEntryRemove OnRemoveMuteListEntry;
  289. public event GodlikeMessage onGodlikeMessage;
  290. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  291. #endregion Events
  292. #region Class Members
  293. // LLClientView Only
  294. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  295. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  296. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  297. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  298. private static string LogHeader = "[LLCLIENTVIEW]";
  299. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  300. /// <summary>
  301. /// Handles UDP texture download.
  302. /// </summary>
  303. public LLImageManager ImageManager { get; private set; }
  304. private readonly LLUDPServer m_udpServer;
  305. private readonly LLUDPClient m_udpClient;
  306. private readonly UUID m_sessionId;
  307. private readonly UUID m_secureSessionId;
  308. protected readonly UUID m_agentId;
  309. private readonly uint m_circuitCode;
  310. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  311. private readonly IGroupsModule m_GroupsModule;
  312. private int m_cachedTextureSerial;
  313. private PriorityQueue m_entityUpdates;
  314. private PriorityQueue m_entityProps;
  315. private Prioritizer m_prioritizer;
  316. private bool m_disableFacelights = false;
  317. private volatile bool m_justEditedTerrain = false;
  318. /// <value>
  319. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  320. /// continually recreate it.
  321. /// </value>
  322. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  323. /// <value>
  324. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  325. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  326. /// ownerless phantom.
  327. ///
  328. /// All manipulation of this set has to occur under a lock
  329. ///
  330. /// </value>
  331. protected HashSet<uint> m_killRecord;
  332. // protected HashSet<uint> m_attachmentsSent;
  333. private int m_animationSequenceNumber = 1;
  334. private bool m_SendLogoutPacketWhenClosing = true;
  335. /// <summary>
  336. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  337. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  338. /// is doing absolutely nothing.
  339. /// </summary>
  340. /// <remarks>
  341. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  342. /// cannot retain a reference to it outside of that method.
  343. /// </remarks>
  344. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  345. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  346. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  347. protected Scene m_scene;
  348. protected string m_firstName;
  349. protected string m_lastName;
  350. protected Thread m_clientThread;
  351. protected Vector3 m_startpos;
  352. protected UUID m_activeGroupID;
  353. protected string m_activeGroupName = String.Empty;
  354. protected ulong m_activeGroupPowers;
  355. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  356. protected int m_terrainCheckerCount;
  357. protected uint m_agentFOVCounter;
  358. protected IAssetService m_assetService;
  359. private const bool m_checkPackets = true;
  360. #endregion Class Members
  361. #region Properties
  362. public LLUDPClient UDPClient { get { return m_udpClient; } }
  363. public LLUDPServer UDPServer { get { return m_udpServer; } }
  364. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  365. public UUID SecureSessionId { get { return m_secureSessionId; } }
  366. public IScene Scene { get { return m_scene; } }
  367. public UUID SessionId { get { return m_sessionId; } }
  368. public Vector3 StartPos
  369. {
  370. get { return m_startpos; }
  371. set { m_startpos = value; }
  372. }
  373. public UUID AgentId { get { return m_agentId; } }
  374. public ISceneAgent SceneAgent { get; set; }
  375. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  376. public string ActiveGroupName { get { return m_activeGroupName; } }
  377. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  378. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  379. /// <summary>
  380. /// Entity update queues
  381. /// </summary>
  382. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  383. /// <summary>
  384. /// First name of the agent/avatar represented by the client
  385. /// </summary>
  386. public string FirstName { get { return m_firstName; } }
  387. /// <summary>
  388. /// Last name of the agent/avatar represented by the client
  389. /// </summary>
  390. public string LastName { get { return m_lastName; } }
  391. /// <summary>
  392. /// Full name of the client (first name and last name)
  393. /// </summary>
  394. public string Name { get { return FirstName + " " + LastName; } }
  395. public uint CircuitCode { get { return m_circuitCode; } }
  396. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  397. /// <summary>
  398. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  399. /// prevent race conditions by different threads calling Close().
  400. /// </summary>
  401. public bool IsActive { get; set; }
  402. /// <summary>
  403. /// Used to synchronise threads when client is being closed.
  404. /// </summary>
  405. public Object CloseSyncLock { get; private set; }
  406. public bool IsLoggingOut { get; set; }
  407. public bool DisableFacelights
  408. {
  409. get { return m_disableFacelights; }
  410. set { m_disableFacelights = value; }
  411. }
  412. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  413. #endregion Properties
  414. // ~LLClientView()
  415. // {
  416. // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode);
  417. // }
  418. /// <summary>
  419. /// Constructor
  420. /// </summary>
  421. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  422. UUID agentId, UUID sessionId, uint circuitCode)
  423. {
  424. // DebugPacketLevel = 1;
  425. CloseSyncLock = new Object();
  426. RegisterInterface<IClientIM>(this);
  427. RegisterInterface<IClientInventory>(this);
  428. RegisterInterface<IClientChat>(this);
  429. m_scene = scene;
  430. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  431. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  432. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  433. m_killRecord = new HashSet<uint>();
  434. // m_attachmentsSent = new HashSet<uint>();
  435. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  436. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  437. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  438. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  439. m_agentId = agentId;
  440. m_sessionId = sessionId;
  441. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  442. m_circuitCode = circuitCode;
  443. m_firstName = sessionInfo.LoginInfo.First;
  444. m_lastName = sessionInfo.LoginInfo.Last;
  445. m_startpos = sessionInfo.LoginInfo.StartPos;
  446. m_udpServer = udpServer;
  447. m_udpClient = udpClient;
  448. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  449. m_udpClient.HasUpdates += HandleHasUpdates;
  450. m_udpClient.OnPacketStats += PopulateStats;
  451. m_prioritizer = new Prioritizer(m_scene);
  452. RegisterLocalPacketHandlers();
  453. IsActive = true;
  454. }
  455. #region Client Methods
  456. public void Close()
  457. {
  458. Close(false);
  459. }
  460. public void Close(bool force)
  461. {
  462. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  463. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  464. lock (CloseSyncLock)
  465. {
  466. // We still perform a force close inside the sync lock since this is intended to attempt close where
  467. // there is some unidentified connection problem, not where we have issues due to deadlock
  468. if (!IsActive && !force)
  469. {
  470. m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set",
  471. LogHeader, Name, m_scene.Name);
  472. return;
  473. }
  474. IsActive = false;
  475. CloseWithoutChecks();
  476. }
  477. }
  478. /// <summary>
  479. /// Closes down the client view without first checking whether it is active.
  480. /// </summary>
  481. /// <remarks>
  482. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  483. /// CloseWithoutIsActiveCheck asynchronously.
  484. ///
  485. /// Callers must lock ClosingSyncLock before calling.
  486. /// </remarks>
  487. public void CloseWithoutChecks()
  488. {
  489. m_log.DebugFormat(
  490. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  491. Name, m_scene.RegionInfo.RegionName);
  492. // Shutdown the image manager
  493. ImageManager.Close();
  494. // Fire the callback for this connection closing
  495. if (OnConnectionClosed != null)
  496. OnConnectionClosed(this);
  497. // Flush all of the packets out of the UDP server for this client
  498. if (m_udpServer != null)
  499. m_udpServer.Flush(m_udpClient);
  500. // Remove ourselves from the scene
  501. m_scene.RemoveClient(AgentId, true);
  502. SceneAgent = null;
  503. // We can't reach into other scenes and close the connection
  504. // We need to do this over grid communications
  505. //m_scene.CloseAllAgents(CircuitCode);
  506. // Disable UDP handling for this client
  507. m_udpClient.Shutdown();
  508. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  509. //GC.Collect();
  510. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  511. }
  512. public void Kick(string message)
  513. {
  514. if (!SceneAgent.IsChildAgent)
  515. {
  516. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  517. kupack.UserInfo.AgentID = AgentId;
  518. kupack.UserInfo.SessionID = SessionId;
  519. kupack.TargetBlock.TargetIP = 0;
  520. kupack.TargetBlock.TargetPort = 0;
  521. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  522. OutPacket(kupack, ThrottleOutPacketType.Task);
  523. // You must sleep here or users get no message!
  524. Thread.Sleep(500);
  525. }
  526. }
  527. public void Stop()
  528. {
  529. }
  530. #endregion Client Methods
  531. #region Packet Handling
  532. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  533. {
  534. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  535. if (handlerNetworkStatsUpdate != null)
  536. {
  537. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  538. }
  539. }
  540. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  541. {
  542. bool result = false;
  543. lock (PacketHandlers)
  544. {
  545. if (!PacketHandlers.ContainsKey(packetType))
  546. {
  547. PacketHandlers.Add(packetType, handler);
  548. result = true;
  549. }
  550. }
  551. return result;
  552. }
  553. /// <summary>
  554. /// Add a handler for the given packet type.
  555. /// </summary>
  556. /// <remarks>
  557. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  558. /// are received then please use the synchronous version of this method.
  559. /// </remarks>
  560. /// <param name="packetType"></param>
  561. /// <param name="handler"></param>
  562. /// <returns>true if the handler was added. This is currently always the case.</returns>
  563. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  564. {
  565. return AddLocalPacketHandler(packetType, handler, true);
  566. }
  567. /// <summary>
  568. /// Add a handler for the given packet type.
  569. /// </summary>
  570. /// <param name="packetType"></param>
  571. /// <param name="handler"></param>
  572. /// <param name="doAsync">
  573. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  574. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  575. /// synchronously.
  576. /// </param>
  577. /// <returns>true if the handler was added. This is currently always the case.</returns>
  578. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  579. {
  580. bool result = false;
  581. lock (m_packetHandlers)
  582. {
  583. if (!m_packetHandlers.ContainsKey(packetType))
  584. {
  585. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  586. result = true;
  587. }
  588. }
  589. return result;
  590. }
  591. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  592. {
  593. MethodName = MethodName.ToLower().Trim();
  594. bool result = false;
  595. lock (m_genericPacketHandlers)
  596. {
  597. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  598. {
  599. m_genericPacketHandlers.Add(MethodName, handler);
  600. result = true;
  601. }
  602. }
  603. return result;
  604. }
  605. /// <summary>
  606. /// Try to process a packet using registered packet handlers
  607. /// </summary>
  608. /// <param name="packet"></param>
  609. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  610. protected virtual bool ProcessPacketMethod(Packet packet)
  611. {
  612. bool result = false;
  613. PacketProcessor pprocessor;
  614. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  615. {
  616. //there is a local handler for this packet type
  617. if (pprocessor.Async)
  618. {
  619. ClientInfo cinfo = UDPClient.GetClientInfo();
  620. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  621. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  622. cinfo.AsyncRequests[packet.Type.ToString()]++;
  623. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  624. Util.FireAndForget(ProcessSpecificPacketAsync, obj, packet.Type.ToString());
  625. result = true;
  626. }
  627. else
  628. {
  629. ClientInfo cinfo = UDPClient.GetClientInfo();
  630. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  631. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  632. cinfo.SyncRequests[packet.Type.ToString()]++;
  633. result = pprocessor.method(this, packet);
  634. }
  635. }
  636. else
  637. {
  638. //there is not a local handler so see if there is a Global handler
  639. PacketMethod method = null;
  640. bool found;
  641. lock (PacketHandlers)
  642. {
  643. found = PacketHandlers.TryGetValue(packet.Type, out method);
  644. }
  645. if (found)
  646. {
  647. ClientInfo cinfo = UDPClient.GetClientInfo();
  648. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  649. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  650. cinfo.GenericRequests[packet.Type.ToString()]++;
  651. result = method(this, packet);
  652. }
  653. }
  654. return result;
  655. }
  656. public void ProcessSpecificPacketAsync(object state)
  657. {
  658. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  659. try
  660. {
  661. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  662. }
  663. catch (Exception e)
  664. {
  665. // Make sure that we see any exception caused by the asynchronous operation.
  666. m_log.ErrorFormat(
  667. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  668. packetObject.Pack, Name, e.Message, e.StackTrace);
  669. }
  670. }
  671. #endregion Packet Handling
  672. # region Setup
  673. public virtual void Start()
  674. {
  675. m_scene.AddNewAgent(this, PresenceType.User);
  676. RefreshGroupMembership();
  677. }
  678. # endregion
  679. public void ActivateGesture(UUID assetId, UUID gestureId)
  680. {
  681. }
  682. public void DeactivateGesture(UUID assetId, UUID gestureId)
  683. {
  684. }
  685. // Sound
  686. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  687. {
  688. }
  689. #region Scene/Avatar to Client
  690. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  691. {
  692. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  693. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  694. handshake.RegionInfo.BillableFactor = args.billableFactor;
  695. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  696. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  697. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  698. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  699. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  700. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  701. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  702. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  703. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  704. handshake.RegionInfo.SimAccess = args.simAccess;
  705. handshake.RegionInfo.WaterHeight = args.waterHeight;
  706. handshake.RegionInfo.RegionFlags = args.regionFlags;
  707. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  708. handshake.RegionInfo.SimOwner = args.SimOwner;
  709. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  710. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  711. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  712. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  713. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  714. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  715. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  716. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  717. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  718. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  719. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  720. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  721. handshake.RegionInfo3.CPUClassID = 9;
  722. handshake.RegionInfo3.CPURatio = 1;
  723. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  724. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  725. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  726. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  727. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  728. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  729. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  730. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  731. }
  732. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  733. {
  734. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  735. mov.SimData.ChannelVersion = m_channelVersion;
  736. mov.AgentData.SessionID = m_sessionId;
  737. mov.AgentData.AgentID = AgentId;
  738. mov.Data.RegionHandle = regInfo.RegionHandle;
  739. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  740. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  741. {
  742. mov.Data.Position = m_startpos;
  743. }
  744. else
  745. {
  746. mov.Data.Position = pos;
  747. }
  748. mov.Data.LookAt = look;
  749. // Hack to get this out immediately and skip the throttles
  750. OutPacket(mov, ThrottleOutPacketType.Unknown);
  751. }
  752. public void SendChatMessage(
  753. string message, byte type, Vector3 fromPos, string fromName,
  754. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  755. {
  756. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  757. reply.ChatData.Audible = audible;
  758. reply.ChatData.Message = Util.StringToBytes1024(message);
  759. reply.ChatData.ChatType = type;
  760. reply.ChatData.SourceType = source;
  761. reply.ChatData.Position = fromPos;
  762. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  763. reply.ChatData.OwnerID = ownerID;
  764. reply.ChatData.SourceID = fromAgentID;
  765. OutPacket(reply, ThrottleOutPacketType.Task);
  766. }
  767. /// <summary>
  768. /// Send an instant message to this client
  769. /// </summary>
  770. //
  771. // Don't remove transaction ID! Groups and item gives need to set it!
  772. public void SendInstantMessage(GridInstantMessage im)
  773. {
  774. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  775. {
  776. ImprovedInstantMessagePacket msg
  777. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  778. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  779. msg.AgentData.SessionID = UUID.Zero;
  780. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  781. msg.MessageBlock.Dialog = im.dialog;
  782. msg.MessageBlock.FromGroup = im.fromGroup;
  783. if (im.imSessionID == UUID.Zero.Guid)
  784. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  785. else
  786. msg.MessageBlock.ID = new UUID(im.imSessionID);
  787. msg.MessageBlock.Offline = im.offline;
  788. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  789. msg.MessageBlock.Position = im.Position;
  790. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  791. msg.MessageBlock.Timestamp = im.timestamp;
  792. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  793. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  794. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  795. if (im.message.StartsWith("[grouptest]"))
  796. { // this block is test code for implementing group IM - delete when group IM is finished
  797. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  798. if (eq != null)
  799. {
  800. im.dialog = 17;
  801. //eq.ChatterboxInvitation(
  802. // new UUID("00000000-68f9-1111-024e-222222111123"),
  803. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  804. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  805. eq.ChatterboxInvitation(
  806. new UUID("00000000-68f9-1111-024e-222222111123"),
  807. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  808. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  809. eq.ChatterBoxSessionAgentListUpdates(
  810. new UUID("00000000-68f9-1111-024e-222222111123"),
  811. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  812. }
  813. Console.WriteLine("SendInstantMessage: " + msg);
  814. }
  815. else
  816. OutPacket(msg, ThrottleOutPacketType.Task);
  817. }
  818. }
  819. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  820. {
  821. GenericMessagePacket gmp = new GenericMessagePacket();
  822. gmp.AgentData.AgentID = AgentId;
  823. gmp.AgentData.SessionID = m_sessionId;
  824. gmp.AgentData.TransactionID = invoice;
  825. gmp.MethodData.Method = Util.StringToBytes256(method);
  826. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  827. int i = 0;
  828. foreach (string val in message)
  829. {
  830. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  831. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  832. }
  833. OutPacket(gmp, ThrottleOutPacketType.Task);
  834. }
  835. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  836. {
  837. GenericMessagePacket gmp = new GenericMessagePacket();
  838. gmp.AgentData.AgentID = AgentId;
  839. gmp.AgentData.SessionID = m_sessionId;
  840. gmp.AgentData.TransactionID = invoice;
  841. gmp.MethodData.Method = Util.StringToBytes256(method);
  842. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  843. int i = 0;
  844. foreach (byte[] val in message)
  845. {
  846. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  847. gmp.ParamList[i++].Parameter = val;
  848. }
  849. OutPacket(gmp, ThrottleOutPacketType.Task);
  850. }
  851. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  852. {
  853. int i = 0;
  854. foreach (GroupActiveProposals Proposal in Proposals)
  855. {
  856. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  857. GAPIRP.AgentData.AgentID = AgentId;
  858. GAPIRP.AgentData.GroupID = groupID;
  859. GAPIRP.TransactionData.TransactionID = transactionID;
  860. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  861. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  862. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  863. ProposalData.VoteCast = Utils.StringToBytes("false");
  864. ProposalData.VoteID = new UUID(Proposal.VoteID);
  865. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  866. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  867. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  868. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  869. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  870. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  871. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  872. ProposalData.AlreadyVoted = false;
  873. GAPIRP.ProposalData[i] = ProposalData;
  874. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  875. i++;
  876. }
  877. if (Proposals.Length == 0)
  878. {
  879. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  880. GAPIRP.AgentData.AgentID = AgentId;
  881. GAPIRP.AgentData.GroupID = groupID;
  882. GAPIRP.TransactionData.TransactionID = transactionID;
  883. GAPIRP.TransactionData.TotalNumItems = 1;
  884. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  885. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  886. ProposalData.VoteCast = Utils.StringToBytes("false");
  887. ProposalData.VoteID = UUID.Zero;
  888. ProposalData.VoteInitiator = UUID.Zero;
  889. ProposalData.Majority = 0;
  890. ProposalData.Quorum = 0;
  891. ProposalData.TerseDateID = Utils.StringToBytes("");
  892. ProposalData.StartDateTime = Utils.StringToBytes("");
  893. ProposalData.EndDateTime = Utils.StringToBytes("");
  894. ProposalData.ProposalText = Utils.StringToBytes("");
  895. ProposalData.AlreadyVoted = false;
  896. GAPIRP.ProposalData[0] = ProposalData;
  897. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  898. }
  899. }
  900. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  901. {
  902. int i = 0;
  903. foreach (GroupVoteHistory Vote in Votes)
  904. {
  905. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  906. GVHIRP.AgentData.AgentID = AgentId;
  907. GVHIRP.AgentData.GroupID = groupID;
  908. GVHIRP.TransactionData.TransactionID = transactionID;
  909. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  910. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  911. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  912. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  913. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  914. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  915. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  916. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  917. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  918. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  919. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  920. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  921. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  922. VoteItem.CandidateID = UUID.Zero;
  923. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  924. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  925. GVHIRP.VoteItem[i] = VoteItem;
  926. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  927. i++;
  928. }
  929. if (Votes.Length == 0)
  930. {
  931. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  932. GVHIRP.AgentData.AgentID = AgentId;
  933. GVHIRP.AgentData.GroupID = groupID;
  934. GVHIRP.TransactionData.TransactionID = transactionID;
  935. GVHIRP.TransactionData.TotalNumItems = 0;
  936. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  937. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  938. GVHIRP.HistoryItemData.Majority = 0;
  939. GVHIRP.HistoryItemData.Quorum = 0;
  940. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  941. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  942. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  943. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  944. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  945. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  946. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  947. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  948. VoteItem.CandidateID = UUID.Zero;
  949. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  950. VoteItem.VoteCast = Utils.StringToBytes("No");
  951. GVHIRP.VoteItem[0] = VoteItem;
  952. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  953. }
  954. }
  955. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  956. {
  957. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  958. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  959. GADRP.AgentData.AgentID = sender.AgentId;
  960. GADRP.AgentData.GroupID = groupID;
  961. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  962. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  963. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  964. GADRP.MoneyData.CurrentInterval = 0;
  965. GADRP.MoneyData.IntervalDays = 7;
  966. GADRP.MoneyData.RequestID = transactionID;
  967. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  968. History.Amount = amt;
  969. History.Description = Utils.StringToBytes("");
  970. GADRP.HistoryData[0] = History;
  971. OutPacket(GADRP, ThrottleOutPacketType.Task);
  972. }
  973. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  974. {
  975. GroupAccountSummaryReplyPacket GASRP =
  976. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  977. PacketType.GroupAccountSummaryReply);
  978. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  979. GASRP.AgentData.AgentID = sender.AgentId;
  980. GASRP.AgentData.GroupID = groupID;
  981. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  982. GASRP.MoneyData.Balance = (int)moneyAmt;
  983. GASRP.MoneyData.TotalCredits = totalTier;
  984. GASRP.MoneyData.TotalDebits = usedTier;
  985. GASRP.MoneyData.StartDate = new byte[1];
  986. GASRP.MoneyData.CurrentInterval = 1;
  987. GASRP.MoneyData.GroupTaxCurrent = 0;
  988. GASRP.MoneyData.GroupTaxEstimate = 0;
  989. GASRP.MoneyData.IntervalDays = 0;
  990. GASRP.MoneyData.LandTaxCurrent = 0;
  991. GASRP.MoneyData.LandTaxEstimate = 0;
  992. GASRP.MoneyData.LastTaxDate = new byte[1];
  993. GASRP.MoneyData.LightTaxCurrent = 0;
  994. GASRP.MoneyData.TaxDate = new byte[1];
  995. GASRP.MoneyData.RequestID = sender.AgentId;
  996. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  997. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  998. GASRP.MoneyData.ObjectTaxEstimate = 0;
  999. GASRP.MoneyData.NonExemptMembers = 0;
  1000. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1001. GASRP.MoneyData.LightTaxEstimate = 0;
  1002. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1003. }
  1004. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1005. {
  1006. GroupAccountTransactionsReplyPacket GATRP =
  1007. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1008. PacketType.GroupAccountTransactionsReply);
  1009. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1010. GATRP.AgentData.AgentID = sender.AgentId;
  1011. GATRP.AgentData.GroupID = groupID;
  1012. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1013. GATRP.MoneyData.CurrentInterval = 0;
  1014. GATRP.MoneyData.IntervalDays = 7;
  1015. GATRP.MoneyData.RequestID = transactionID;
  1016. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1017. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1018. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1019. History.Amount = 0;
  1020. History.Item = Utils.StringToBytes("");
  1021. History.Time = Utils.StringToBytes("");
  1022. History.Type = 0;
  1023. History.User = Utils.StringToBytes("");
  1024. GATRP.HistoryData[0] = History;
  1025. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1026. }
  1027. /// <summary>
  1028. /// Send the region heightmap to the client
  1029. /// </summary>
  1030. /// <param name="map">heightmap</param>
  1031. public virtual void SendLayerData(float[] map)
  1032. {
  1033. Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData());
  1034. }
  1035. /// <summary>
  1036. /// Send terrain layer information to the client.
  1037. /// </summary>
  1038. /// <param name="o"></param>
  1039. private void DoSendLayerData(object o)
  1040. {
  1041. TerrainData map = (TerrainData)o;
  1042. try
  1043. {
  1044. // Send LayerData in typerwriter pattern
  1045. //for (int y = 0; y < 16; y++)
  1046. //{
  1047. // for (int x = 0; x < 16; x++)
  1048. // {
  1049. // SendLayerData(x, y, map);
  1050. // }
  1051. //}
  1052. // Send LayerData in a spiral pattern. Fun!
  1053. SendLayerTopRight(map, 0, 0, map.SizeX/Constants.TerrainPatchSize-1, map.SizeY/Constants.TerrainPatchSize-1);
  1054. }
  1055. catch (Exception e)
  1056. {
  1057. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1058. }
  1059. }
  1060. private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2)
  1061. {
  1062. // Row
  1063. for (int i = x1; i <= x2; i++)
  1064. SendLayerData(i, y1, map);
  1065. // Column
  1066. for (int j = y1 + 1; j <= y2; j++)
  1067. SendLayerData(x2, j, map);
  1068. if (x2 - x1 > 0 && y2 - y1 > 0)
  1069. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1070. }
  1071. void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2)
  1072. {
  1073. // Row in reverse
  1074. for (int i = x2; i >= x1; i--)
  1075. SendLayerData(i, y2, map);
  1076. // Column in reverse
  1077. for (int j = y2 - 1; j >= y1; j--)
  1078. SendLayerData(x1, j, map);
  1079. if (x2 - x1 > 0 && y2 - y1 > 0)
  1080. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1081. }
  1082. /// <summary>
  1083. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1084. /// </summary>
  1085. /// <param name="map">heightmap</param>
  1086. /// <param name="px">X coordinate for patches 0..12</param>
  1087. /// <param name="py">Y coordinate for patches 0..15</param>
  1088. // private void SendLayerPacket(float[] map, int y, int x)
  1089. // {
  1090. // int[] patches = new int[4];
  1091. // patches[0] = x + 0 + y * 16;
  1092. // patches[1] = x + 1 + y * 16;
  1093. // patches[2] = x + 2 + y * 16;
  1094. // patches[3] = x + 3 + y * 16;
  1095. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1096. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1097. // }
  1098. // Legacy form of invocation that passes around a bare data array.
  1099. // Just ignore what was passed and use the real terrain info that is part of the scene.
  1100. public void SendLayerData(int px, int py, float[] map)
  1101. {
  1102. SendLayerData(px, py, m_scene.Heightmap.GetTerrainData());
  1103. }
  1104. /// <summary>
  1105. /// Sends a terrain packet for the point specified.
  1106. /// This is a legacy call that has refarbed the terrain into a flat map of floats.
  1107. /// We just use the terrain from the region we know about.
  1108. /// </summary>
  1109. /// <param name="px">Patch coordinate (x) 0..15</param>
  1110. /// <param name="py">Patch coordinate (y) 0..15</param>
  1111. /// <param name="map">heightmap</param>
  1112. public void SendLayerData(int px, int py, TerrainData terrData)
  1113. {
  1114. try
  1115. {
  1116. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLandPacket(terrData, px, py);
  1117. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
  1118. // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
  1119. // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
  1120. // invalidating previous packets for that area.
  1121. // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
  1122. // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
  1123. // One last note on this topic, by the time users are going to be editing the terrain, it's extremely likely that the sim will
  1124. // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
  1125. // patches.
  1126. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
  1127. if (m_justEditedTerrain)
  1128. {
  1129. layerpack.Header.Reliable = false;
  1130. OutPacket(layerpack, ThrottleOutPacketType.Unknown );
  1131. }
  1132. else
  1133. {
  1134. layerpack.Header.Reliable = true;
  1135. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1136. }
  1137. }
  1138. catch (Exception e)
  1139. {
  1140. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1141. }
  1142. }
  1143. /// <summary>
  1144. /// Send the wind matrix to the client
  1145. /// </summary>
  1146. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1147. public virtual void SendWindData(Vector2[] windSpeeds)
  1148. {
  1149. Util.FireAndForget(DoSendWindData, windSpeeds);
  1150. }
  1151. /// <summary>
  1152. /// Send the cloud matrix to the client
  1153. /// </summary>
  1154. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1155. public virtual void SendCloudData(float[] cloudDensity)
  1156. {
  1157. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1158. }
  1159. /// <summary>
  1160. /// Send wind layer information to the client.
  1161. /// </summary>
  1162. /// <param name="o"></param>
  1163. private void DoSendWindData(object o)
  1164. {
  1165. Vector2[] windSpeeds = (Vector2[])o;
  1166. TerrainPatch[] patches = new TerrainPatch[2];
  1167. patches[0] = new TerrainPatch { Data = new float[16 * 16] };
  1168. patches[1] = new TerrainPatch { Data = new float[16 * 16] };
  1169. for (int x = 0; x < 16 * 16; x++)
  1170. {
  1171. patches[0].Data[x] = windSpeeds[x].X;
  1172. patches[1].Data[x] = windSpeeds[x].Y;
  1173. }
  1174. byte layerType = (byte)TerrainPatch.LayerType.Wind;
  1175. if (m_scene.RegionInfo.RegionSizeX > Constants.RegionSize || m_scene.RegionInfo.RegionSizeY > Constants.RegionSize)
  1176. layerType = (byte)TerrainPatch.LayerType.WindExtended;
  1177. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacket(patches, layerType,
  1178. (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
  1179. layerpack.Header.Zerocoded = true;
  1180. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1181. }
  1182. /// <summary>
  1183. /// Send cloud layer information to the client.
  1184. /// </summary>
  1185. /// <param name="o"></param>
  1186. private void DoSendCloudData(object o)
  1187. {
  1188. float[] cloudCover = (float[])o;
  1189. TerrainPatch[] patches = new TerrainPatch[1];
  1190. patches[0] = new TerrainPatch();
  1191. patches[0].Data = new float[16 * 16];
  1192. for (int y = 0; y < 16; y++)
  1193. {
  1194. for (int x = 0; x < 16; x++)
  1195. {
  1196. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1197. }
  1198. }
  1199. byte layerType = (byte)TerrainPatch.LayerType.Cloud;
  1200. if (m_scene.RegionInfo.RegionSizeX > Constants.RegionSize || m_scene.RegionInfo.RegionSizeY > Constants.RegionSize)
  1201. layerType = (byte)TerrainPatch.LayerType.CloudExtended;
  1202. LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacket(patches, layerType,
  1203. (int)m_scene.RegionInfo.RegionSizeX, (int)m_scene.RegionInfo.RegionSizeY);
  1204. layerpack.Header.Zerocoded = true;
  1205. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1206. }
  1207. /// <summary>
  1208. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1209. /// </summary>
  1210. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1211. {
  1212. IPAddress neighbourIP = neighbourEndPoint.Address;
  1213. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1214. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1215. // TODO: don't create new blocks if recycling an old packet
  1216. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1217. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1218. byte[] byteIP = neighbourIP.GetAddressBytes();
  1219. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1220. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1221. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1222. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1223. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1224. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1225. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1226. }
  1227. public AgentCircuitData RequestClientInfo()
  1228. {
  1229. AgentCircuitData agentData = new AgentCircuitData();
  1230. agentData.AgentID = AgentId;
  1231. agentData.SessionID = m_sessionId;
  1232. agentData.SecureSessionID = SecureSessionId;
  1233. agentData.circuitcode = m_circuitCode;
  1234. agentData.child = false;
  1235. agentData.firstname = m_firstName;
  1236. agentData.lastname = m_lastName;
  1237. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1238. if (capsModule == null) // can happen when shutting down.
  1239. return agentData;
  1240. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1241. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1242. return agentData;
  1243. }
  1244. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1245. string capsURL)
  1246. {
  1247. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1248. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1249. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1250. // TODO: don't create new blocks if recycling an old packet
  1251. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1252. newSimPack.AgentData.AgentID = AgentId;
  1253. newSimPack.AgentData.SessionID = m_sessionId;
  1254. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1255. newSimPack.Info.Position = pos;
  1256. newSimPack.Info.LookAt = look;
  1257. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1258. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1259. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1260. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1261. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1262. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1263. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1264. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1265. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1266. // Hack to get this out immediately and skip throttles
  1267. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1268. }
  1269. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1270. {
  1271. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1272. // TODO: don't create new blocks if recycling an old packet
  1273. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1274. mapReply.AgentData.AgentID = AgentId;
  1275. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1276. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1277. mapReply.AgentData.Flags = flag;
  1278. for (int i = 0; i < mapBlocks2.Length; i++)
  1279. {
  1280. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1281. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1282. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1283. mapReply.Data[i].X = mapBlocks2[i].X;
  1284. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1285. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1286. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1287. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1288. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1289. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1290. // TODO: hookup varregion sim size here
  1291. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1292. mapReply.Size[i].SizeX = 256;
  1293. mapReply.Size[i].SizeY = 256;
  1294. }
  1295. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1296. }
  1297. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1298. {
  1299. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1300. int maxsend = 10;
  1301. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1302. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1303. for (int i = 0; i < mapBlocks2.Length; i++)
  1304. {
  1305. sendingBlocks.Add(mapBlocks2[i]);
  1306. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1307. {
  1308. SendMapBlockSplit(sendingBlocks, flag);
  1309. sendingBlocks = new List<MapBlockData>();
  1310. }
  1311. }
  1312. }
  1313. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1314. {
  1315. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1316. tpLocal.Info.AgentID = AgentId;
  1317. tpLocal.Info.TeleportFlags = flags;
  1318. tpLocal.Info.LocationID = 2;
  1319. tpLocal.Info.LookAt = lookAt;
  1320. tpLocal.Info.Position = position;
  1321. // Hack to get this out immediately and skip throttles
  1322. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1323. }
  1324. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1325. uint flags, string capsURL)
  1326. {
  1327. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1328. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1329. teleport.Info.AgentID = AgentId;
  1330. teleport.Info.RegionHandle = regionHandle;
  1331. teleport.Info.SimAccess = simAccess;
  1332. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1333. IPAddress oIP = newRegionEndPoint.Address;
  1334. byte[] byteIP = oIP.GetAddressBytes();
  1335. uint ip = (uint)byteIP[3] << 24;
  1336. ip += (uint)byteIP[2] << 16;
  1337. ip += (uint)byteIP[1] << 8;
  1338. ip += (uint)byteIP[0];
  1339. teleport.Info.SimIP = ip;
  1340. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1341. teleport.Info.LocationID = 4;
  1342. teleport.Info.TeleportFlags = 1 << 4;
  1343. // Hack to get this out immediately and skip throttles.
  1344. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1345. }
  1346. /// <summary>
  1347. /// Inform the client that a teleport attempt has failed
  1348. /// </summary>
  1349. public void SendTeleportFailed(string reason)
  1350. {
  1351. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1352. tpFailed.Info.AgentID = AgentId;
  1353. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1354. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1355. // Hack to get this out immediately and skip throttles
  1356. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1357. }
  1358. /// <summary>
  1359. ///
  1360. /// </summary>
  1361. public void SendTeleportStart(uint flags)
  1362. {
  1363. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1364. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1365. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1366. // Hack to get this out immediately and skip throttles
  1367. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1368. }
  1369. public void SendTeleportProgress(uint flags, string message)
  1370. {
  1371. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1372. tpProgress.AgentData.AgentID = this.AgentId;
  1373. tpProgress.Info.TeleportFlags = flags;
  1374. tpProgress.Info.Message = Util.StringToBytes256(message);
  1375. // Hack to get this out immediately and skip throttles
  1376. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1377. }
  1378. 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)
  1379. {
  1380. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1381. money.MoneyData.AgentID = AgentId;
  1382. money.MoneyData.TransactionID = transaction;
  1383. money.MoneyData.TransactionSuccess = success;
  1384. money.MoneyData.Description = description;
  1385. money.MoneyData.MoneyBalance = balance;
  1386. money.TransactionInfo.TransactionType = transactionType;
  1387. money.TransactionInfo.SourceID = sourceID;
  1388. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1389. money.TransactionInfo.DestID = destID;
  1390. money.TransactionInfo.IsDestGroup = destIsGroup;
  1391. money.TransactionInfo.Amount = amount;
  1392. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1393. OutPacket(money, ThrottleOutPacketType.Task);
  1394. }
  1395. public void SendPayPrice(UUID objectID, int[] payPrice)
  1396. {
  1397. if (payPrice[0] == 0 &&
  1398. payPrice[1] == 0 &&
  1399. payPrice[2] == 0 &&
  1400. payPrice[3] == 0 &&
  1401. payPrice[4] == 0)
  1402. return;
  1403. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1404. payPriceReply.ObjectData.ObjectID = objectID;
  1405. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1406. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1407. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1408. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1409. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1410. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1411. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1412. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1413. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1414. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1415. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1416. }
  1417. public void SendStartPingCheck(byte seq)
  1418. {
  1419. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1420. pc.Header.Reliable = false;
  1421. pc.PingID.PingID = seq;
  1422. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1423. pc.PingID.OldestUnacked = 0;
  1424. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1425. }
  1426. public void SendKillObject(List<uint> localIDs)
  1427. {
  1428. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1429. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1430. // TODO: don't create new blocks if recycling an old packet
  1431. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1432. for (int i = 0 ; i < localIDs.Count ; i++ )
  1433. {
  1434. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1435. kill.ObjectData[i].ID = localIDs[i];
  1436. }
  1437. kill.Header.Reliable = true;
  1438. kill.Header.Zerocoded = true;
  1439. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1440. {
  1441. OutPacket(kill, ThrottleOutPacketType.Task);
  1442. }
  1443. else
  1444. {
  1445. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1446. // condition where a kill can be processed before an out-of-date update for the same object.
  1447. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1448. lock (m_killRecord)
  1449. {
  1450. foreach (uint localID in localIDs)
  1451. m_killRecord.Add(localID);
  1452. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1453. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1454. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1455. // scene objects in a viewer until that viewer is relogged in.
  1456. OutPacket(kill, ThrottleOutPacketType.Task);
  1457. }
  1458. }
  1459. }
  1460. /// <summary>
  1461. /// Send information about the items contained in a folder to the client.
  1462. /// </summary>
  1463. /// <remarks>
  1464. /// XXX This method needs some refactoring loving
  1465. /// </remarks>
  1466. /// <param name="ownerID">The owner of the folder</param>
  1467. /// <param name="folderID">The id of the folder</param>
  1468. /// <param name="items">The items contained in the folder identified by folderID</param>
  1469. /// <param name="folders"></param>
  1470. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1471. /// <param name="fetchItems">Do we need to send item information?</param>
  1472. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1473. List<InventoryFolderBase> folders, int version,
  1474. bool fetchFolders, bool fetchItems)
  1475. {
  1476. // An inventory descendents packet consists of a single agent section and an inventory details
  1477. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1478. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1479. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1480. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1481. //
  1482. // http://opensimulator.org/mantis/view.php?id=226
  1483. //
  1484. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1485. // 6 to 7 items at a time, so let's stick with 6
  1486. int MAX_ITEMS_PER_PACKET = 5;
  1487. int MAX_FOLDERS_PER_PACKET = 6;
  1488. int totalItems = fetchItems ? items.Count : 0;
  1489. int totalFolders = fetchFolders ? folders.Count : 0;
  1490. int itemsSent = 0;
  1491. int foldersSent = 0;
  1492. int foldersToSend = 0;
  1493. int itemsToSend = 0;
  1494. InventoryDescendentsPacket currentPacket = null;
  1495. // Handle empty folders
  1496. //
  1497. if (totalItems == 0 && totalFolders == 0)
  1498. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1499. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1500. //
  1501. while (itemsSent < totalItems || foldersSent < totalFolders)
  1502. {
  1503. if (currentPacket == null) // Start a new packet
  1504. {
  1505. foldersToSend = totalFolders - foldersSent;
  1506. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1507. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1508. if (foldersToSend == 0)
  1509. {
  1510. itemsToSend = totalItems - itemsSent;
  1511. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1512. itemsToSend = MAX_ITEMS_PER_PACKET;
  1513. }
  1514. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1515. }
  1516. if (foldersToSend-- > 0)
  1517. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1518. else if (itemsToSend-- > 0)
  1519. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1520. else
  1521. {
  1522. // m_log.DebugFormat(
  1523. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1524. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1525. currentPacket = null;
  1526. }
  1527. }
  1528. if (currentPacket != null)
  1529. {
  1530. // m_log.DebugFormat(
  1531. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1532. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1533. }
  1534. }
  1535. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1536. {
  1537. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1538. newBlock.FolderID = folder.ID;
  1539. newBlock.Name = Util.StringToBytes256(folder.Name);
  1540. newBlock.ParentID = folder.ParentID;
  1541. newBlock.Type = (sbyte)folder.Type;
  1542. return newBlock;
  1543. }
  1544. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1545. {
  1546. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1547. newBlock.ItemID = item.ID;
  1548. newBlock.AssetID = item.AssetID;
  1549. newBlock.CreatorID = item.CreatorIdAsUuid;
  1550. newBlock.BaseMask = item.BasePermissions;
  1551. newBlock.Description = Util.StringToBytes256(item.Description);
  1552. newBlock.EveryoneMask = item.EveryOnePermissions;
  1553. newBlock.OwnerMask = item.CurrentPermissions;
  1554. newBlock.FolderID = item.Folder;
  1555. newBlock.InvType = (sbyte)item.InvType;
  1556. newBlock.Name = Util.StringToBytes256(item.Name);
  1557. newBlock.NextOwnerMask = item.NextPermissions;
  1558. newBlock.OwnerID = item.Owner;
  1559. newBlock.Type = (sbyte)item.AssetType;
  1560. newBlock.GroupID = item.GroupID;
  1561. newBlock.GroupOwned = item.GroupOwned;
  1562. newBlock.GroupMask = item.GroupPermissions;
  1563. newBlock.CreationDate = item.CreationDate;
  1564. newBlock.SalePrice = item.SalePrice;
  1565. newBlock.SaleType = item.SaleType;
  1566. newBlock.Flags = item.Flags;
  1567. newBlock.CRC =
  1568. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1569. newBlock.InvType, newBlock.Type,
  1570. newBlock.AssetID, newBlock.GroupID,
  1571. newBlock.SalePrice,
  1572. newBlock.OwnerID, newBlock.CreatorID,
  1573. newBlock.ItemID, newBlock.FolderID,
  1574. newBlock.EveryoneMask,
  1575. newBlock.Flags, newBlock.OwnerMask,
  1576. newBlock.GroupMask, newBlock.NextOwnerMask);
  1577. return newBlock;
  1578. }
  1579. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1580. {
  1581. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1582. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1583. packet.FolderData[0].FolderID = UUID.Zero;
  1584. packet.FolderData[0].ParentID = UUID.Zero;
  1585. packet.FolderData[0].Type = -1;
  1586. packet.FolderData[0].Name = new byte[0];
  1587. }
  1588. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1589. {
  1590. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1591. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1592. packet.ItemData[0].ItemID = UUID.Zero;
  1593. packet.ItemData[0].AssetID = UUID.Zero;
  1594. packet.ItemData[0].CreatorID = UUID.Zero;
  1595. packet.ItemData[0].BaseMask = 0;
  1596. packet.ItemData[0].Description = new byte[0];
  1597. packet.ItemData[0].EveryoneMask = 0;
  1598. packet.ItemData[0].OwnerMask = 0;
  1599. packet.ItemData[0].FolderID = UUID.Zero;
  1600. packet.ItemData[0].InvType = (sbyte)0;
  1601. packet.ItemData[0].Name = new byte[0];
  1602. packet.ItemData[0].NextOwnerMask = 0;
  1603. packet.ItemData[0].OwnerID = UUID.Zero;
  1604. packet.ItemData[0].Type = -1;
  1605. packet.ItemData[0].GroupID = UUID.Zero;
  1606. packet.ItemData[0].GroupOwned = false;
  1607. packet.ItemData[0].GroupMask = 0;
  1608. packet.ItemData[0].CreationDate = 0;
  1609. packet.ItemData[0].SalePrice = 0;
  1610. packet.ItemData[0].SaleType = 0;
  1611. packet.ItemData[0].Flags = 0;
  1612. // No need to add CRC
  1613. }
  1614. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1615. {
  1616. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1617. descend.Header.Zerocoded = true;
  1618. descend.AgentData.AgentID = AgentId;
  1619. descend.AgentData.OwnerID = ownerID;
  1620. descend.AgentData.FolderID = folderID;
  1621. descend.AgentData.Version = version;
  1622. descend.AgentData.Descendents = descendents;
  1623. if (folders > 0)
  1624. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1625. else
  1626. AddNullFolderBlockToDecendentsPacket(ref descend);
  1627. if (items > 0)
  1628. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1629. else
  1630. AddNullItemBlockToDescendentsPacket(ref descend);
  1631. return descend;
  1632. }
  1633. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1634. {
  1635. // Fudge this value. It's only needed to make the CRC anyway
  1636. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1637. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1638. // TODO: don't create new blocks if recycling an old packet
  1639. inventoryReply.AgentData.AgentID = AgentId;
  1640. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1641. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1642. inventoryReply.InventoryData[0].ItemID = item.ID;
  1643. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1644. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1645. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1646. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1647. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1648. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1649. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1650. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1651. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1652. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1653. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1654. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1655. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1656. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1657. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1658. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1659. inventoryReply.InventoryData[0].Flags = item.Flags;
  1660. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1661. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1662. inventoryReply.InventoryData[0].CRC =
  1663. Helpers.InventoryCRC(
  1664. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1665. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1666. inventoryReply.InventoryData[0].GroupID, 100,
  1667. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1668. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1669. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1670. FULL_MASK_PERMISSIONS);
  1671. inventoryReply.Header.Zerocoded = true;
  1672. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1673. }
  1674. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1675. {
  1676. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1677. UUID transactionId = UUID.Random();
  1678. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1679. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1680. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1681. if (folderDataBlocks.Count > 0)
  1682. {
  1683. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1684. // Send these now
  1685. BulkUpdateInventoryPacket bulkUpdate
  1686. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1687. bulkUpdate.Header.Zerocoded = true;
  1688. bulkUpdate.AgentData.AgentID = AgentId;
  1689. bulkUpdate.AgentData.TransactionID = transactionId;
  1690. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1691. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1692. bulkUpdate.ItemData = foo.ToArray();
  1693. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1694. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1695. }
  1696. }
  1697. /// <summary>
  1698. /// Recursively construct bulk update packets to send folders and items
  1699. /// </summary>
  1700. /// <param name="folder"></param>
  1701. /// <param name="folderDataBlocks"></param>
  1702. /// <param name="transactionId"></param>
  1703. private void SendBulkUpdateInventoryFolderRecursive(
  1704. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1705. UUID transactionId)
  1706. {
  1707. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1708. const int MAX_ITEMS_PER_PACKET = 5;
  1709. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1710. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1711. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1712. // being used on the Linden grid at 20081203).
  1713. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1714. List<InventoryItemBase> items = contents.Items;
  1715. while (items.Count > 0)
  1716. {
  1717. BulkUpdateInventoryPacket bulkUpdate
  1718. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1719. bulkUpdate.Header.Zerocoded = true;
  1720. bulkUpdate.AgentData.AgentID = AgentId;
  1721. bulkUpdate.AgentData.TransactionID = transactionId;
  1722. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1723. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1724. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1725. for (int i = 0; i < itemsToSend; i++)
  1726. {
  1727. // Remove from the end of the list so that we don't incur a performance penalty
  1728. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1729. items.RemoveAt(items.Count - 1);
  1730. }
  1731. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1732. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1733. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1734. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1735. // items belong.
  1736. if (items.Count > 0)
  1737. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1738. }
  1739. List<InventoryFolderBase> subFolders = contents.Folders;
  1740. foreach (InventoryFolderBase subFolder in subFolders)
  1741. {
  1742. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1743. }
  1744. }
  1745. /// <summary>
  1746. /// Generate a bulk update inventory data block for the given folder
  1747. /// </summary>
  1748. /// <param name="folder"></param>
  1749. /// <returns></returns>
  1750. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1751. {
  1752. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1753. folderBlock.FolderID = folder.ID;
  1754. folderBlock.ParentID = folder.ParentID;
  1755. //folderBlock.Type = -1;
  1756. folderBlock.Type = (sbyte)folder.Type;
  1757. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1758. return folderBlock;
  1759. }
  1760. /// <summary>
  1761. /// Generate a bulk update inventory data block for the given item
  1762. /// </summary>
  1763. /// <param name="item"></param>
  1764. /// <returns></returns>
  1765. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1766. {
  1767. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1768. itemBlock.ItemID = item.ID;
  1769. itemBlock.AssetID = item.AssetID;
  1770. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1771. itemBlock.BaseMask = item.BasePermissions;
  1772. itemBlock.Description = Util.StringToBytes256(item.Description);
  1773. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1774. itemBlock.FolderID = item.Folder;
  1775. itemBlock.InvType = (sbyte)item.InvType;
  1776. itemBlock.Name = Util.StringToBytes256(item.Name);
  1777. itemBlock.NextOwnerMask = item.NextPermissions;
  1778. itemBlock.OwnerID = item.Owner;
  1779. itemBlock.OwnerMask = item.CurrentPermissions;
  1780. itemBlock.Type = (sbyte)item.AssetType;
  1781. itemBlock.GroupID = item.GroupID;
  1782. itemBlock.GroupOwned = item.GroupOwned;
  1783. itemBlock.GroupMask = item.GroupPermissions;
  1784. itemBlock.Flags = item.Flags;
  1785. itemBlock.SalePrice = item.SalePrice;
  1786. itemBlock.SaleType = item.SaleType;
  1787. itemBlock.CreationDate = item.CreationDate;
  1788. itemBlock.CRC =
  1789. Helpers.InventoryCRC(
  1790. 1000, 0, itemBlock.InvType,
  1791. itemBlock.Type, itemBlock.AssetID,
  1792. itemBlock.GroupID, 100,
  1793. itemBlock.OwnerID, itemBlock.CreatorID,
  1794. itemBlock.ItemID, itemBlock.FolderID,
  1795. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1796. (uint)PermissionMask.All);
  1797. return itemBlock;
  1798. }
  1799. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1800. {
  1801. if (node is InventoryItemBase)
  1802. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1803. else if (node is InventoryFolderBase)
  1804. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1805. else if (node != null)
  1806. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1807. else
  1808. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1809. }
  1810. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1811. {
  1812. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1813. BulkUpdateInventoryPacket bulkUpdate
  1814. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1815. bulkUpdate.AgentData.AgentID = AgentId;
  1816. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1817. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1818. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1819. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1820. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1821. bulkUpdate.FolderData[0].Type = -1;
  1822. bulkUpdate.FolderData[0].Name = new byte[0];
  1823. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1824. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1825. bulkUpdate.ItemData[0].ItemID = item.ID;
  1826. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1827. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1828. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1829. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1830. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1831. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1832. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1833. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1834. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1835. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1836. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1837. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1838. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1839. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1840. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1841. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1842. bulkUpdate.ItemData[0].Flags = item.Flags;
  1843. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1844. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1845. bulkUpdate.ItemData[0].CRC =
  1846. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1847. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1848. bulkUpdate.ItemData[0].GroupID, 100,
  1849. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1850. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1851. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1852. FULL_MASK_PERMISSIONS);
  1853. bulkUpdate.Header.Zerocoded = true;
  1854. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1855. }
  1856. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1857. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1858. {
  1859. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1860. UpdateCreateInventoryItemPacket InventoryReply
  1861. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1862. PacketType.UpdateCreateInventoryItem);
  1863. // TODO: don't create new blocks if recycling an old packet
  1864. InventoryReply.AgentData.AgentID = AgentId;
  1865. InventoryReply.AgentData.SimApproved = true;
  1866. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1867. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1868. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1869. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1870. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1871. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1872. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1873. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1874. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1875. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1876. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1877. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1878. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1879. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1880. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1881. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1882. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1883. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1884. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1885. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1886. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1887. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1888. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1889. InventoryReply.InventoryData[0].CRC =
  1890. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1891. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1892. InventoryReply.InventoryData[0].GroupID, 100,
  1893. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1894. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1895. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1896. FULL_MASK_PERMISSIONS);
  1897. InventoryReply.Header.Zerocoded = true;
  1898. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1899. }
  1900. public void SendRemoveInventoryItem(UUID itemID)
  1901. {
  1902. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1903. // TODO: don't create new blocks if recycling an old packet
  1904. remove.AgentData.AgentID = AgentId;
  1905. remove.AgentData.SessionID = m_sessionId;
  1906. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1907. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1908. remove.InventoryData[0].ItemID = itemID;
  1909. remove.Header.Zerocoded = true;
  1910. OutPacket(remove, ThrottleOutPacketType.Asset);
  1911. }
  1912. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1913. {
  1914. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1915. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1916. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1917. ddata.Controls = (uint)controls;
  1918. ddata.PassToAgent = passToAgent;
  1919. ddata.TakeControls = TakeControls;
  1920. data[0] = ddata;
  1921. scriptcontrol.Data = data;
  1922. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1923. }
  1924. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1925. {
  1926. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1927. replytask.InventoryData.TaskID = taskID;
  1928. replytask.InventoryData.Serial = serial;
  1929. replytask.InventoryData.Filename = fileName;
  1930. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1931. }
  1932. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1933. {
  1934. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1935. sendXfer.XferID.ID = xferID;
  1936. sendXfer.XferID.Packet = packet;
  1937. sendXfer.DataPacket.Data = data;
  1938. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1939. }
  1940. public void SendAbortXferPacket(ulong xferID)
  1941. {
  1942. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1943. xferItem.XferID.ID = xferID;
  1944. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1945. }
  1946. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1947. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1948. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1949. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1950. {
  1951. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1952. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1953. economyData.Info.ObjectCapacity = ObjectCapacity;
  1954. economyData.Info.ObjectCount = ObjectCount;
  1955. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1956. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1957. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1958. economyData.Info.PriceObjectRent = PriceObjectRent;
  1959. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1960. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1961. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1962. economyData.Info.PriceParcelRent = PriceParcelRent;
  1963. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1964. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1965. economyData.Info.PriceRentLight = PriceRentLight;
  1966. economyData.Info.PriceUpload = PriceUpload;
  1967. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1968. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1969. economyData.Header.Reliable = true;
  1970. OutPacket(economyData, ThrottleOutPacketType.Task);
  1971. }
  1972. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1973. {
  1974. //construct the AvatarPickerReply packet.
  1975. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1976. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1977. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1978. //int i = 0;
  1979. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1980. foreach (AvatarPickerReplyDataArgs arg in Data)
  1981. {
  1982. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1983. db.AvatarID = arg.AvatarID;
  1984. db.FirstName = arg.FirstName;
  1985. db.LastName = arg.LastName;
  1986. data_block.Add(db);
  1987. }
  1988. replyPacket.Data = data_block.ToArray();
  1989. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  1990. }
  1991. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  1992. {
  1993. m_activeGroupID = activegroupid;
  1994. m_activeGroupName = groupname;
  1995. m_activeGroupPowers = grouppowers;
  1996. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  1997. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  1998. sendAgentDataUpdate.AgentData.AgentID = agentid;
  1999. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2000. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2001. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2002. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2003. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2004. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2005. }
  2006. /// <summary>
  2007. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2008. /// blue information box in the bottom right hand corner.
  2009. /// </summary>
  2010. /// <param name="message"></param>
  2011. public void SendAlertMessage(string message)
  2012. {
  2013. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2014. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2015. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2016. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2017. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2018. }
  2019. /// <summary>
  2020. /// Send an agent alert message to the client.
  2021. /// </summary>
  2022. /// <param name="message"></param>
  2023. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2024. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2025. /// the AlertMessage packet).</param>
  2026. public void SendAgentAlertMessage(string message, bool modal)
  2027. {
  2028. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2029. }
  2030. /// <summary>
  2031. /// Construct an agent alert packet
  2032. /// </summary>
  2033. /// <param name="message"></param>
  2034. /// <param name="modal"></param>
  2035. /// <returns></returns>
  2036. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2037. {
  2038. // Prepend a slash to make the message come up in the top right
  2039. // again.
  2040. // Allow special formats to be sent from aware modules.
  2041. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2042. message = "/" + message;
  2043. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2044. alertPack.AgentData.AgentID = AgentId;
  2045. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2046. alertPack.AlertData.Modal = modal;
  2047. return alertPack;
  2048. }
  2049. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2050. string url)
  2051. {
  2052. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2053. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2054. loadURL.Data.ObjectID = objectID;
  2055. loadURL.Data.OwnerID = ownerID;
  2056. loadURL.Data.OwnerIsGroup = groupOwned;
  2057. loadURL.Data.Message = Util.StringToBytes256(message);
  2058. loadURL.Data.URL = Util.StringToBytes256(url);
  2059. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2060. }
  2061. public void SendDialog(
  2062. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2063. UUID textureID, int ch, string[] buttonlabels)
  2064. {
  2065. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2066. dialog.Data.ObjectID = objectID;
  2067. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2068. // this is the username of the *owner*
  2069. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2070. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2071. dialog.Data.Message = Util.StringToBytes1024(msg);
  2072. dialog.Data.ImageID = textureID;
  2073. dialog.Data.ChatChannel = ch;
  2074. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2075. for (int i = 0; i < buttonlabels.Length; i++)
  2076. {
  2077. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2078. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2079. }
  2080. dialog.Buttons = buttons;
  2081. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2082. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2083. dialog.OwnerData[0].OwnerID = ownerID;
  2084. OutPacket(dialog, ThrottleOutPacketType.Task);
  2085. }
  2086. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2087. {
  2088. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2089. // TODO: don't create new blocks if recycling an old packet
  2090. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2091. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2092. preSound.DataBlock[0].ObjectID = objectID;
  2093. preSound.DataBlock[0].OwnerID = ownerID;
  2094. preSound.DataBlock[0].SoundID = soundID;
  2095. preSound.Header.Zerocoded = true;
  2096. OutPacket(preSound, ThrottleOutPacketType.Task);
  2097. }
  2098. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2099. {
  2100. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2101. sound.DataBlock.SoundID = soundID;
  2102. sound.DataBlock.ObjectID = objectID;
  2103. sound.DataBlock.OwnerID = ownerID;
  2104. sound.DataBlock.Gain = gain;
  2105. sound.DataBlock.Flags = flags;
  2106. OutPacket(sound, ThrottleOutPacketType.Task);
  2107. }
  2108. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2109. {
  2110. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2111. sound.SoundData.SoundID = soundID;
  2112. sound.SoundData.OwnerID = ownerID;
  2113. sound.SoundData.ObjectID = objectID;
  2114. sound.SoundData.ParentID = parentID;
  2115. sound.SoundData.Handle = handle;
  2116. sound.SoundData.Position = position;
  2117. sound.SoundData.Gain = gain;
  2118. OutPacket(sound, ThrottleOutPacketType.Task);
  2119. }
  2120. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2121. {
  2122. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2123. sound.DataBlock.ObjectID = objectID;
  2124. sound.DataBlock.Gain = gain;
  2125. OutPacket(sound, ThrottleOutPacketType.Task);
  2126. }
  2127. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2128. {
  2129. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2130. // So adjust for that
  2131. // Contributed by: Godfrey
  2132. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2133. {
  2134. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2135. }
  2136. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2137. viewertime.TimeInfo.SunDirection = Position;
  2138. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2139. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2140. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2141. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2142. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2143. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2144. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2145. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2146. viewertime.Header.Reliable = false;
  2147. viewertime.Header.Zerocoded = true;
  2148. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2149. }
  2150. // Currently Deprecated
  2151. public void SendViewerTime(int phase)
  2152. {
  2153. /*
  2154. Console.WriteLine("SunPhase: {0}", phase);
  2155. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2156. //viewertime.TimeInfo.SecPerDay = 86400;
  2157. //viewertime.TimeInfo.SecPerYear = 31536000;
  2158. viewertime.TimeInfo.SecPerDay = 1000;
  2159. viewertime.TimeInfo.SecPerYear = 365000;
  2160. viewertime.TimeInfo.SunPhase = 1;
  2161. int sunPhase = (phase + 2) / 2;
  2162. if ((sunPhase < 6) || (sunPhase > 36))
  2163. {
  2164. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2165. Console.WriteLine("sending night");
  2166. }
  2167. else
  2168. {
  2169. if (sunPhase < 12)
  2170. {
  2171. sunPhase = 12;
  2172. }
  2173. sunPhase = sunPhase - 12;
  2174. float yValue = 0.1f * (sunPhase);
  2175. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2176. if (yValue > 1.2f)
  2177. {
  2178. yValue = yValue - 1.2f;
  2179. }
  2180. yValue = Util.Clip(yValue, 0, 1);
  2181. if (sunPhase < 14)
  2182. {
  2183. yValue = 1 - yValue;
  2184. }
  2185. if (sunPhase < 12)
  2186. {
  2187. yValue *= -1;
  2188. }
  2189. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2190. Console.WriteLine("sending sun update " + yValue);
  2191. }
  2192. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2193. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2194. viewertime.Header.Reliable = false;
  2195. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2196. */
  2197. }
  2198. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2199. {
  2200. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2201. packet.Header.Reliable = false;
  2202. packet.Header.Zerocoded = true;
  2203. packet.AgentData.AgentID = AgentId;
  2204. packet.AgentData.SessionID = SessionId;
  2205. packet.Effect = effectBlocks;
  2206. // OutPacket(packet, ThrottleOutPacketType.State);
  2207. OutPacket(packet, ThrottleOutPacketType.Task);
  2208. }
  2209. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2210. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2211. UUID partnerID)
  2212. {
  2213. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2214. avatarReply.AgentData.AgentID = AgentId;
  2215. avatarReply.AgentData.AvatarID = avatarID;
  2216. if (aboutText != null)
  2217. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2218. else
  2219. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2220. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2221. avatarReply.PropertiesData.CharterMember = charterMember;
  2222. if (flAbout != null)
  2223. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2224. else
  2225. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2226. avatarReply.PropertiesData.Flags = flags;
  2227. avatarReply.PropertiesData.FLImageID = flImageID;
  2228. avatarReply.PropertiesData.ImageID = imageID;
  2229. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2230. avatarReply.PropertiesData.PartnerID = partnerID;
  2231. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2232. }
  2233. /// <summary>
  2234. /// Send the client an Estate message blue box pop-down with a single OK button
  2235. /// </summary>
  2236. /// <param name="FromAvatarID"></param>
  2237. /// <param name="fromSessionID"></param>
  2238. /// <param name="FromAvatarName"></param>
  2239. /// <param name="Message"></param>
  2240. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2241. {
  2242. if (!SceneAgent.IsChildAgent)
  2243. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2244. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2245. }
  2246. public void SendLogoutPacket()
  2247. {
  2248. // I know this is a bit of a hack, however there are times when you don't
  2249. // want to send this, but still need to do the rest of the shutdown process
  2250. // this method gets called from the packet server.. which makes it practically
  2251. // impossible to do any other way.
  2252. if (m_SendLogoutPacketWhenClosing)
  2253. {
  2254. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2255. // TODO: don't create new blocks if recycling an old packet
  2256. logReply.AgentData.AgentID = AgentId;
  2257. logReply.AgentData.SessionID = SessionId;
  2258. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2259. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2260. logReply.InventoryData[0].ItemID = UUID.Zero;
  2261. OutPacket(logReply, ThrottleOutPacketType.Task);
  2262. }
  2263. }
  2264. public void SendHealth(float health)
  2265. {
  2266. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2267. healthpacket.HealthData.Health = health;
  2268. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2269. }
  2270. public void SendAgentOnline(UUID[] agentIDs)
  2271. {
  2272. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2273. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2274. for (int i = 0; i < agentIDs.Length; i++)
  2275. {
  2276. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2277. onpbl.AgentID = agentIDs[i];
  2278. onpb[i] = onpbl;
  2279. }
  2280. onp.AgentBlock = onpb;
  2281. onp.Header.Reliable = true;
  2282. OutPacket(onp, ThrottleOutPacketType.Task);
  2283. }
  2284. public void SendAgentOffline(UUID[] agentIDs)
  2285. {
  2286. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2287. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2288. for (int i = 0; i < agentIDs.Length; i++)
  2289. {
  2290. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2291. onpbl.AgentID = agentIDs[i];
  2292. offpb[i] = onpbl;
  2293. }
  2294. offp.AgentBlock = offpb;
  2295. offp.Header.Reliable = true;
  2296. OutPacket(offp, ThrottleOutPacketType.Task);
  2297. }
  2298. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2299. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2300. {
  2301. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2302. avatarSitResponse.SitObject.ID = TargetID;
  2303. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2304. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2305. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2306. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2307. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2308. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2309. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2310. }
  2311. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2312. {
  2313. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2314. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2315. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2316. adb.AgentID = AgentId;
  2317. adb.SessionID = SessionId; // More security
  2318. gdb.GodLevel = (byte)AdminLevel;
  2319. gdb.Token = Token;
  2320. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2321. respondPacket.GrantData = gdb;
  2322. respondPacket.AgentData = adb;
  2323. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2324. }
  2325. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2326. {
  2327. m_groupPowers.Clear();
  2328. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2329. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2330. for (int i = 0; i < GroupMembership.Length; i++)
  2331. {
  2332. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2333. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2334. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2335. Group.Contribution = GroupMembership[i].Contribution;
  2336. Group.GroupID = GroupMembership[i].GroupID;
  2337. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2338. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2339. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2340. Groups[i] = Group;
  2341. }
  2342. Groupupdate.GroupData = Groups;
  2343. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2344. Groupupdate.AgentData.AgentID = AgentId;
  2345. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2346. try
  2347. {
  2348. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2349. if (eq != null)
  2350. {
  2351. eq.GroupMembership(Groupupdate, this.AgentId);
  2352. }
  2353. }
  2354. catch (Exception ex)
  2355. {
  2356. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2357. m_log.Warn("sending group membership data via UDP");
  2358. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2359. }
  2360. }
  2361. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2362. {
  2363. SceneObjectPart part = (SceneObjectPart)entity;
  2364. if (part != null && AgentId != UUID.Zero)
  2365. {
  2366. try
  2367. {
  2368. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2369. if (eq != null)
  2370. {
  2371. uint localid = part.LocalId;
  2372. byte physshapetype = part.PhysicsShapeType;
  2373. float density = part.Density;
  2374. float friction = part.Friction;
  2375. float bounce = part.Restitution;
  2376. float gravmod = part.GravityModifier;
  2377. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2378. }
  2379. }
  2380. catch (Exception ex)
  2381. {
  2382. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2383. }
  2384. part.UpdatePhysRequired = false;
  2385. }
  2386. }
  2387. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2388. {
  2389. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2390. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2391. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2392. uidnamebloc.ID = groupLLUID;
  2393. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2394. uidnameblock[0] = uidnamebloc;
  2395. pack.UUIDNameBlock = uidnameblock;
  2396. OutPacket(pack, ThrottleOutPacketType.Task);
  2397. }
  2398. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2399. {
  2400. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2401. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2402. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2403. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2404. // lsrepdb.
  2405. lsrp.RequestData.ReportType = reportType;
  2406. lsrp.RequestData.RequestFlags = requestFlags;
  2407. lsrp.RequestData.TotalObjectCount = resultCount;
  2408. for (int i = 0; i < lsrpia.Length; i++)
  2409. {
  2410. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2411. lsrepdb.LocationX = lsrpia[i].LocationX;
  2412. lsrepdb.LocationY = lsrpia[i].LocationY;
  2413. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2414. lsrepdb.Score = lsrpia[i].Score;
  2415. lsrepdb.TaskID = lsrpia[i].TaskID;
  2416. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2417. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2418. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2419. lsrepdba[i] = lsrepdb;
  2420. }
  2421. lsrp.ReportData = lsrepdba;
  2422. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2423. }
  2424. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2425. {
  2426. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2427. scriptRunningReply.Script.ObjectID = objectID;
  2428. scriptRunningReply.Script.ItemID = itemID;
  2429. scriptRunningReply.Script.Running = running;
  2430. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2431. }
  2432. public void SendAsset(AssetRequestToClient req)
  2433. {
  2434. if (req.AssetInf.Data == null)
  2435. {
  2436. m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
  2437. LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2438. return;
  2439. }
  2440. //m_log.Debug("sending asset " + req.RequestAssetID);
  2441. TransferInfoPacket Transfer = new TransferInfoPacket();
  2442. Transfer.TransferInfo.ChannelType = 2;
  2443. Transfer.TransferInfo.Status = 0;
  2444. Transfer.TransferInfo.TargetType = 0;
  2445. if (req.AssetRequestSource == 2)
  2446. {
  2447. Transfer.TransferInfo.Params = new byte[20];
  2448. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2449. int assType = req.AssetInf.Type;
  2450. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2451. }
  2452. else if (req.AssetRequestSource == 3)
  2453. {
  2454. Transfer.TransferInfo.Params = req.Params;
  2455. // Transfer.TransferInfo.Params = new byte[100];
  2456. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2457. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2458. }
  2459. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2460. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2461. Transfer.Header.Zerocoded = true;
  2462. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2463. if (req.NumPackets == 1)
  2464. {
  2465. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2466. TransferPacket.TransferData.Packet = 0;
  2467. TransferPacket.TransferData.ChannelType = 2;
  2468. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2469. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2470. TransferPacket.TransferData.Status = 1;
  2471. TransferPacket.Header.Zerocoded = true;
  2472. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2473. }
  2474. else
  2475. {
  2476. int processedLength = 0;
  2477. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2478. int packetNumber = 0;
  2479. while (processedLength < req.AssetInf.Data.Length)
  2480. {
  2481. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2482. TransferPacket.TransferData.Packet = packetNumber;
  2483. TransferPacket.TransferData.ChannelType = 2;
  2484. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2485. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2486. byte[] chunk = new byte[chunkSize];
  2487. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2488. TransferPacket.TransferData.Data = chunk;
  2489. // 0 indicates more packets to come, 1 indicates last packet
  2490. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2491. {
  2492. TransferPacket.TransferData.Status = 0;
  2493. }
  2494. else
  2495. {
  2496. TransferPacket.TransferData.Status = 1;
  2497. }
  2498. TransferPacket.Header.Zerocoded = true;
  2499. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2500. processedLength += chunkSize;
  2501. packetNumber++;
  2502. }
  2503. }
  2504. }
  2505. public void SendAssetNotFound(AssetRequestToClient req)
  2506. {
  2507. TransferInfoPacket Transfer = new TransferInfoPacket();
  2508. Transfer.TransferInfo.ChannelType = 2;
  2509. Transfer.TransferInfo.Status = -2;
  2510. Transfer.TransferInfo.TargetType = 0;
  2511. Transfer.TransferInfo.Params = req.Params;
  2512. Transfer.TransferInfo.Size = 0;
  2513. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2514. Transfer.Header.Zerocoded = true;
  2515. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2516. }
  2517. public void SendTexture(AssetBase TextureAsset)
  2518. {
  2519. }
  2520. public void SendRegionHandle(UUID regionID, ulong handle)
  2521. {
  2522. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2523. reply.ReplyBlock.RegionID = regionID;
  2524. reply.ReplyBlock.RegionHandle = handle;
  2525. OutPacket(reply, ThrottleOutPacketType.Land);
  2526. }
  2527. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2528. {
  2529. float dwell = 0.0f;
  2530. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2531. if (dwellModule != null)
  2532. dwell = dwellModule.GetDwell(land.GlobalID);
  2533. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2534. reply.AgentData.AgentID = m_agentId;
  2535. reply.Data.ParcelID = parcelID;
  2536. reply.Data.OwnerID = land.OwnerID;
  2537. reply.Data.Name = Utils.StringToBytes(land.Name);
  2538. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2539. reply.Data.ActualArea = land.Area;
  2540. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2541. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2542. reply.Data.Flags = (byte)(
  2543. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2544. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2545. Vector3 pos = land.UserLocation;
  2546. if (pos.Equals(Vector3.Zero))
  2547. {
  2548. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2549. }
  2550. reply.Data.GlobalX = info.RegionLocX + x;
  2551. reply.Data.GlobalY = info.RegionLocY + y;
  2552. reply.Data.GlobalZ = pos.Z;
  2553. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2554. reply.Data.SnapshotID = land.SnapshotID;
  2555. reply.Data.Dwell = dwell;
  2556. reply.Data.SalePrice = land.SalePrice;
  2557. reply.Data.AuctionID = (int)land.AuctionID;
  2558. OutPacket(reply, ThrottleOutPacketType.Land);
  2559. }
  2560. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2561. {
  2562. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2563. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2564. packet.Data.SimName = Utils.StringToBytes(simName);
  2565. packet.Data.SimPosition = pos;
  2566. packet.Data.LookAt = lookAt;
  2567. OutPacket(packet, ThrottleOutPacketType.Task);
  2568. }
  2569. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2570. {
  2571. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2572. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2573. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2574. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2575. packet.AgentData.AgentID = AgentId;
  2576. packet.QueryData[0].QueryID = queryID;
  2577. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2578. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2579. DirPlacesReplyPacket.StatusDataBlock[] status =
  2580. new DirPlacesReplyPacket.StatusDataBlock[0];
  2581. packet.QueryReplies = replies;
  2582. packet.StatusData = status;
  2583. foreach (DirPlacesReplyData d in data)
  2584. {
  2585. int idx = replies.Length;
  2586. Array.Resize(ref replies, idx + 1);
  2587. Array.Resize(ref status, idx + 1);
  2588. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2589. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2590. replies[idx].ParcelID = d.parcelID;
  2591. replies[idx].Name = Utils.StringToBytes(d.name);
  2592. replies[idx].ForSale = d.forSale;
  2593. replies[idx].Auction = d.auction;
  2594. replies[idx].Dwell = d.dwell;
  2595. status[idx].Status = d.Status;
  2596. packet.QueryReplies = replies;
  2597. packet.StatusData = status;
  2598. if (packet.Length >= 1000)
  2599. {
  2600. OutPacket(packet, ThrottleOutPacketType.Task);
  2601. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2602. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2603. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2604. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2605. packet.AgentData.AgentID = AgentId;
  2606. packet.QueryData[0].QueryID = queryID;
  2607. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2608. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2609. }
  2610. }
  2611. if (replies.Length > 0 || data.Length == 0)
  2612. OutPacket(packet, ThrottleOutPacketType.Task);
  2613. }
  2614. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2615. {
  2616. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2617. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2618. packet.AgentData.AgentID = AgentId;
  2619. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2620. packet.QueryData.QueryID = queryID;
  2621. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2622. data.Length];
  2623. int i = 0;
  2624. foreach (DirPeopleReplyData d in data)
  2625. {
  2626. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2627. packet.QueryReplies[i].AgentID = d.agentID;
  2628. packet.QueryReplies[i].FirstName =
  2629. Utils.StringToBytes(d.firstName);
  2630. packet.QueryReplies[i].LastName =
  2631. Utils.StringToBytes(d.lastName);
  2632. packet.QueryReplies[i].Group =
  2633. Utils.StringToBytes(d.group);
  2634. packet.QueryReplies[i].Online = d.online;
  2635. packet.QueryReplies[i].Reputation = d.reputation;
  2636. i++;
  2637. }
  2638. OutPacket(packet, ThrottleOutPacketType.Task);
  2639. }
  2640. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2641. {
  2642. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2643. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2644. packet.AgentData.AgentID = AgentId;
  2645. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2646. packet.QueryData.QueryID = queryID;
  2647. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2648. data.Length];
  2649. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2650. data.Length];
  2651. int i = 0;
  2652. foreach (DirEventsReplyData d in data)
  2653. {
  2654. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2655. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2656. packet.QueryReplies[i].OwnerID = d.ownerID;
  2657. packet.QueryReplies[i].Name =
  2658. Utils.StringToBytes(d.name);
  2659. packet.QueryReplies[i].EventID = d.eventID;
  2660. packet.QueryReplies[i].Date =
  2661. Utils.StringToBytes(d.date);
  2662. packet.QueryReplies[i].UnixTime = d.unixTime;
  2663. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2664. packet.StatusData[i].Status = d.Status;
  2665. i++;
  2666. }
  2667. OutPacket(packet, ThrottleOutPacketType.Task);
  2668. }
  2669. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2670. {
  2671. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2672. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2673. packet.AgentData.AgentID = AgentId;
  2674. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2675. packet.QueryData.QueryID = queryID;
  2676. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2677. data.Length];
  2678. int i = 0;
  2679. foreach (DirGroupsReplyData d in data)
  2680. {
  2681. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2682. packet.QueryReplies[i].GroupID = d.groupID;
  2683. packet.QueryReplies[i].GroupName =
  2684. Utils.StringToBytes(d.groupName);
  2685. packet.QueryReplies[i].Members = d.members;
  2686. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2687. i++;
  2688. }
  2689. OutPacket(packet, ThrottleOutPacketType.Task);
  2690. }
  2691. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2692. {
  2693. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2694. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2695. packet.AgentData.AgentID = AgentId;
  2696. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2697. packet.QueryData.QueryID = queryID;
  2698. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2699. data.Length];
  2700. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2701. data.Length];
  2702. int i = 0;
  2703. foreach (DirClassifiedReplyData d in data)
  2704. {
  2705. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2706. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2707. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2708. packet.QueryReplies[i].Name =
  2709. Utils.StringToBytes(d.name);
  2710. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2711. packet.QueryReplies[i].CreationDate = d.creationDate;
  2712. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2713. packet.QueryReplies[i].PriceForListing = d.price;
  2714. packet.StatusData[i].Status = d.Status;
  2715. i++;
  2716. }
  2717. OutPacket(packet, ThrottleOutPacketType.Task);
  2718. }
  2719. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2720. {
  2721. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2722. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2723. packet.AgentData.AgentID = AgentId;
  2724. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2725. packet.QueryData.QueryID = queryID;
  2726. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2727. data.Length];
  2728. int i = 0;
  2729. foreach (DirLandReplyData d in data)
  2730. {
  2731. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2732. packet.QueryReplies[i].ParcelID = d.parcelID;
  2733. packet.QueryReplies[i].Name =
  2734. Utils.StringToBytes(d.name);
  2735. packet.QueryReplies[i].Auction = d.auction;
  2736. packet.QueryReplies[i].ForSale = d.forSale;
  2737. packet.QueryReplies[i].SalePrice = d.salePrice;
  2738. packet.QueryReplies[i].ActualArea = d.actualArea;
  2739. i++;
  2740. }
  2741. OutPacket(packet, ThrottleOutPacketType.Task);
  2742. }
  2743. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2744. {
  2745. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2746. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2747. packet.AgentData.AgentID = AgentId;
  2748. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2749. packet.QueryData.QueryID = queryID;
  2750. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2751. data.Length];
  2752. int i = 0;
  2753. foreach (DirPopularReplyData d in data)
  2754. {
  2755. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2756. packet.QueryReplies[i].ParcelID = d.parcelID;
  2757. packet.QueryReplies[i].Name =
  2758. Utils.StringToBytes(d.name);
  2759. packet.QueryReplies[i].Dwell = d.dwell;
  2760. i++;
  2761. }
  2762. OutPacket(packet, ThrottleOutPacketType.Task);
  2763. }
  2764. public void SendEventInfoReply(EventData data)
  2765. {
  2766. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2767. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2768. packet.AgentData.AgentID = AgentId;
  2769. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2770. packet.EventData.EventID = data.eventID;
  2771. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2772. packet.EventData.Name = Utils.StringToBytes(data.name);
  2773. packet.EventData.Category = Utils.StringToBytes(data.category);
  2774. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2775. packet.EventData.Date = Utils.StringToBytes(data.date);
  2776. packet.EventData.DateUTC = data.dateUTC;
  2777. packet.EventData.Duration = data.duration;
  2778. packet.EventData.Cover = data.cover;
  2779. packet.EventData.Amount = data.amount;
  2780. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2781. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2782. packet.EventData.EventFlags = data.eventFlags;
  2783. OutPacket(packet, ThrottleOutPacketType.Task);
  2784. }
  2785. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2786. {
  2787. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2788. mirplk.AgentData.AgentID = AgentId;
  2789. mirplk.RequestData.ItemType = mapitemtype;
  2790. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2791. for (int i = 0; i < replies.Length; i++)
  2792. {
  2793. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2794. mrdata.X = replies[i].x;
  2795. mrdata.Y = replies[i].y;
  2796. mrdata.ID = replies[i].id;
  2797. mrdata.Extra = replies[i].Extra;
  2798. mrdata.Extra2 = replies[i].Extra2;
  2799. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2800. mirplk.Data[i] = mrdata;
  2801. }
  2802. //m_log.Debug(mirplk.ToString());
  2803. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2804. }
  2805. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2806. {
  2807. // a bit special, as this uses AgentID to store the source instead
  2808. // of the destination. The destination (the receiver) goes into destID
  2809. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2810. p.AgentData.AgentID = srcID;
  2811. p.AgentData.SessionID = UUID.Zero;
  2812. p.AgentBlock.DestID = AgentId;
  2813. p.AgentBlock.TransactionID = transactionID;
  2814. OutPacket(p, ThrottleOutPacketType.Task);
  2815. }
  2816. public void SendAcceptCallingCard(UUID transactionID)
  2817. {
  2818. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2819. p.AgentData.AgentID = AgentId;
  2820. p.AgentData.SessionID = UUID.Zero;
  2821. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2822. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2823. p.FolderData[0].FolderID = UUID.Zero;
  2824. OutPacket(p, ThrottleOutPacketType.Task);
  2825. }
  2826. public void SendDeclineCallingCard(UUID transactionID)
  2827. {
  2828. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2829. p.AgentData.AgentID = AgentId;
  2830. p.AgentData.SessionID = UUID.Zero;
  2831. p.TransactionBlock.TransactionID = transactionID;
  2832. OutPacket(p, ThrottleOutPacketType.Task);
  2833. }
  2834. public void SendTerminateFriend(UUID exFriendID)
  2835. {
  2836. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2837. p.AgentData.AgentID = AgentId;
  2838. p.AgentData.SessionID = SessionId;
  2839. p.ExBlock.OtherID = exFriendID;
  2840. OutPacket(p, ThrottleOutPacketType.Task);
  2841. }
  2842. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2843. {
  2844. OSDMap llsd = new OSDMap(3);
  2845. OSDArray AgentData = new OSDArray(1);
  2846. OSDMap AgentDataMap = new OSDMap(1);
  2847. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2848. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2849. AgentData.Add(AgentDataMap);
  2850. llsd.Add("AgentData", AgentData);
  2851. OSDArray GroupData = new OSDArray(data.Length);
  2852. OSDArray NewGroupData = new OSDArray(data.Length);
  2853. foreach (GroupMembershipData m in data)
  2854. {
  2855. OSDMap GroupDataMap = new OSDMap(6);
  2856. OSDMap NewGroupDataMap = new OSDMap(1);
  2857. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2858. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2859. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2860. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2861. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2862. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2863. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2864. GroupData.Add(GroupDataMap);
  2865. NewGroupData.Add(NewGroupDataMap);
  2866. }
  2867. llsd.Add("GroupData", GroupData);
  2868. llsd.Add("NewGroupData", NewGroupData);
  2869. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2870. if (eq != null)
  2871. {
  2872. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2873. }
  2874. }
  2875. public void SendJoinGroupReply(UUID groupID, bool success)
  2876. {
  2877. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2878. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2879. p.AgentData.AgentID = AgentId;
  2880. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2881. p.GroupData.GroupID = groupID;
  2882. p.GroupData.Success = success;
  2883. OutPacket(p, ThrottleOutPacketType.Task);
  2884. }
  2885. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2886. {
  2887. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2888. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2889. p.AgentData.AgentID = agentID;
  2890. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2891. p.GroupData.GroupID = groupID;
  2892. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2893. p.EjectData.Success = success;
  2894. OutPacket(p, ThrottleOutPacketType.Task);
  2895. }
  2896. public void SendLeaveGroupReply(UUID groupID, bool success)
  2897. {
  2898. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2899. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2900. p.AgentData.AgentID = AgentId;
  2901. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2902. p.GroupData.GroupID = groupID;
  2903. p.GroupData.Success = success;
  2904. OutPacket(p, ThrottleOutPacketType.Task);
  2905. }
  2906. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2907. {
  2908. if (classifiedID.Length != name.Length)
  2909. return;
  2910. AvatarClassifiedReplyPacket ac =
  2911. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2912. PacketType.AvatarClassifiedReply);
  2913. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2914. ac.AgentData.AgentID = AgentId;
  2915. ac.AgentData.TargetID = targetID;
  2916. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2917. int i;
  2918. for (i = 0; i < classifiedID.Length; i++)
  2919. {
  2920. ac.Data[i].ClassifiedID = classifiedID[i];
  2921. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2922. }
  2923. OutPacket(ac, ThrottleOutPacketType.Task);
  2924. }
  2925. 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)
  2926. {
  2927. ClassifiedInfoReplyPacket cr =
  2928. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2929. PacketType.ClassifiedInfoReply);
  2930. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2931. cr.AgentData.AgentID = AgentId;
  2932. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2933. cr.Data.ClassifiedID = classifiedID;
  2934. cr.Data.CreatorID = creatorID;
  2935. cr.Data.CreationDate = creationDate;
  2936. cr.Data.ExpirationDate = expirationDate;
  2937. cr.Data.Category = category;
  2938. cr.Data.Name = Utils.StringToBytes(name);
  2939. cr.Data.Desc = Utils.StringToBytes(description);
  2940. cr.Data.ParcelID = parcelID;
  2941. cr.Data.ParentEstate = parentEstate;
  2942. cr.Data.SnapshotID = snapshotID;
  2943. cr.Data.SimName = Utils.StringToBytes(simName);
  2944. cr.Data.PosGlobal = new Vector3d(globalPos);
  2945. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2946. cr.Data.ClassifiedFlags = classifiedFlags;
  2947. cr.Data.PriceForListing = price;
  2948. OutPacket(cr, ThrottleOutPacketType.Task);
  2949. }
  2950. public void SendAgentDropGroup(UUID groupID)
  2951. {
  2952. AgentDropGroupPacket dg =
  2953. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2954. PacketType.AgentDropGroup);
  2955. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2956. dg.AgentData.AgentID = AgentId;
  2957. dg.AgentData.GroupID = groupID;
  2958. OutPacket(dg, ThrottleOutPacketType.Task);
  2959. }
  2960. public void SendAvatarNotesReply(UUID targetID, string text)
  2961. {
  2962. AvatarNotesReplyPacket an =
  2963. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2964. PacketType.AvatarNotesReply);
  2965. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2966. an.AgentData.AgentID = AgentId;
  2967. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2968. an.Data.TargetID = targetID;
  2969. an.Data.Notes = Utils.StringToBytes(text);
  2970. OutPacket(an, ThrottleOutPacketType.Task);
  2971. }
  2972. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2973. {
  2974. AvatarPicksReplyPacket ap =
  2975. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2976. PacketType.AvatarPicksReply);
  2977. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2978. ap.AgentData.AgentID = AgentId;
  2979. ap.AgentData.TargetID = targetID;
  2980. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  2981. int i = 0;
  2982. foreach (KeyValuePair<UUID, string> pick in picks)
  2983. {
  2984. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  2985. ap.Data[i].PickID = pick.Key;
  2986. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  2987. i++;
  2988. }
  2989. OutPacket(ap, ThrottleOutPacketType.Task);
  2990. }
  2991. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  2992. {
  2993. AvatarClassifiedReplyPacket ac =
  2994. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2995. PacketType.AvatarClassifiedReply);
  2996. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2997. ac.AgentData.AgentID = AgentId;
  2998. ac.AgentData.TargetID = targetID;
  2999. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3000. int i = 0;
  3001. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3002. {
  3003. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3004. ac.Data[i].ClassifiedID = classified.Key;
  3005. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3006. i++;
  3007. }
  3008. OutPacket(ac, ThrottleOutPacketType.Task);
  3009. }
  3010. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3011. {
  3012. ParcelDwellReplyPacket pd =
  3013. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3014. PacketType.ParcelDwellReply);
  3015. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3016. pd.AgentData.AgentID = AgentId;
  3017. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3018. pd.Data.LocalID = localID;
  3019. pd.Data.ParcelID = parcelID;
  3020. pd.Data.Dwell = dwell;
  3021. OutPacket(pd, ThrottleOutPacketType.Land);
  3022. }
  3023. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3024. {
  3025. UserInfoReplyPacket ur =
  3026. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3027. PacketType.UserInfoReply);
  3028. string Visible = "hidden";
  3029. if (visible)
  3030. Visible = "default";
  3031. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3032. ur.AgentData.AgentID = AgentId;
  3033. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3034. ur.UserData.IMViaEMail = imViaEmail;
  3035. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3036. ur.UserData.EMail = Utils.StringToBytes(email);
  3037. OutPacket(ur, ThrottleOutPacketType.Task);
  3038. }
  3039. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3040. {
  3041. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3042. createGroupReply.AgentData =
  3043. new CreateGroupReplyPacket.AgentDataBlock();
  3044. createGroupReply.ReplyData =
  3045. new CreateGroupReplyPacket.ReplyDataBlock();
  3046. createGroupReply.AgentData.AgentID = AgentId;
  3047. createGroupReply.ReplyData.GroupID = groupID;
  3048. createGroupReply.ReplyData.Success = success;
  3049. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3050. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3051. }
  3052. public void SendUseCachedMuteList()
  3053. {
  3054. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3055. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3056. useCachedMuteList.AgentData.AgentID = AgentId;
  3057. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3058. }
  3059. public void SendMuteListUpdate(string filename)
  3060. {
  3061. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3062. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3063. muteListUpdate.MuteData.AgentID = AgentId;
  3064. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3065. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3066. }
  3067. 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)
  3068. {
  3069. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3070. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3071. pickInfoReply.AgentData.AgentID = AgentId;
  3072. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3073. pickInfoReply.Data.PickID = pickID;
  3074. pickInfoReply.Data.CreatorID = creatorID;
  3075. pickInfoReply.Data.TopPick = topPick;
  3076. pickInfoReply.Data.ParcelID = parcelID;
  3077. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3078. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3079. pickInfoReply.Data.SnapshotID = snapshotID;
  3080. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3081. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3082. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3083. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3084. pickInfoReply.Data.SortOrder = sortOrder;
  3085. pickInfoReply.Data.Enabled = enabled;
  3086. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3087. }
  3088. #endregion Scene/Avatar to Client
  3089. // Gesture
  3090. #region Appearance/ Wearables Methods
  3091. public void SendWearables(AvatarWearable[] wearables, int serial)
  3092. {
  3093. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3094. aw.AgentData.AgentID = AgentId;
  3095. aw.AgentData.SerialNum = (uint)serial;
  3096. aw.AgentData.SessionID = m_sessionId;
  3097. int count = 0;
  3098. for (int i = 0; i < wearables.Length; i++)
  3099. count += wearables[i].Count;
  3100. // TODO: don't create new blocks if recycling an old packet
  3101. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3102. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3103. int idx = 0;
  3104. for (int i = 0; i < wearables.Length; i++)
  3105. {
  3106. for (int j = 0; j < wearables[i].Count; j++)
  3107. {
  3108. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3109. awb.WearableType = (byte)i;
  3110. awb.AssetID = wearables[i][j].AssetID;
  3111. awb.ItemID = wearables[i][j].ItemID;
  3112. aw.WearableData[idx] = awb;
  3113. idx++;
  3114. // m_log.DebugFormat(
  3115. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3116. // awb.ItemID, awb.AssetID, i, Name);
  3117. }
  3118. }
  3119. OutPacket(aw, ThrottleOutPacketType.Task);
  3120. }
  3121. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3122. {
  3123. // m_log.DebugFormat(
  3124. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3125. // agentID, textureEntry.Length, Name, AgentId);
  3126. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3127. // TODO: don't create new blocks if recycling an old packet
  3128. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
  3129. avp.ObjectData.TextureEntry = textureEntry;
  3130. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3131. for (int i = 0; i < visualParams.Length; i++)
  3132. {
  3133. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3134. avblock.ParamValue = visualParams[i];
  3135. avp.VisualParam[i] = avblock;
  3136. }
  3137. avp.Sender.IsTrial = false;
  3138. avp.Sender.ID = agentID;
  3139. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3140. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3141. OutPacket(avp, ThrottleOutPacketType.Task);
  3142. }
  3143. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3144. {
  3145. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3146. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3147. // TODO: don't create new blocks if recycling an old packet
  3148. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3149. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3150. ani.Sender.ID = sourceAgentId;
  3151. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3152. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3153. for (int i = 0; i < animations.Length; ++i)
  3154. {
  3155. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3156. ani.AnimationList[i].AnimID = animations[i];
  3157. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3158. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3159. if (objectIDs[i].Equals(sourceAgentId))
  3160. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3161. else
  3162. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3163. }
  3164. ani.Header.Reliable = false;
  3165. OutPacket(ani, ThrottleOutPacketType.Task);
  3166. }
  3167. #endregion
  3168. #region Avatar Packet/Data Sending Methods
  3169. /// <summary>
  3170. /// Send an ObjectUpdate packet with information about an avatar
  3171. /// </summary>
  3172. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3173. {
  3174. // m_log.DebugFormat(
  3175. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3176. // avatar.Name, avatar.UUID, Name, AgentId);
  3177. ScenePresence presence = avatar as ScenePresence;
  3178. if (presence == null)
  3179. return;
  3180. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3181. objupdate.Header.Zerocoded = true;
  3182. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3183. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3184. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3185. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3186. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3187. // We need to record the avatar local id since the root prim of an attachment points to this.
  3188. // m_attachmentsSent.Add(avatar.LocalId);
  3189. }
  3190. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3191. {
  3192. // We don't need to update inactive clients.
  3193. if (!IsActive)
  3194. return;
  3195. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3196. loc.Header.Reliable = false;
  3197. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3198. // a CoarseLocationUpdate packet is received. Oh well.
  3199. int total = Math.Min(CoarseLocations.Count, 60);
  3200. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3201. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3202. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3203. int selfindex = -1;
  3204. for (int i = 0; i < total; i++)
  3205. {
  3206. CoarseLocationUpdatePacket.LocationBlock lb =
  3207. new CoarseLocationUpdatePacket.LocationBlock();
  3208. lb.X = (byte)CoarseLocations[i].X;
  3209. lb.Y = (byte)CoarseLocations[i].Y;
  3210. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3211. loc.Location[i] = lb;
  3212. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3213. loc.AgentData[i].AgentID = users[i];
  3214. if (users[i] == AgentId)
  3215. selfindex = i;
  3216. }
  3217. ib.You = (short)selfindex;
  3218. ib.Prey = -1;
  3219. loc.Index = ib;
  3220. OutPacket(loc, ThrottleOutPacketType.Task);
  3221. }
  3222. #endregion Avatar Packet/Data Sending Methods
  3223. #region Primitive Packet/Data Sending Methods
  3224. /// <summary>
  3225. /// Generate one of the object update packets based on PrimUpdateFlags
  3226. /// and broadcast the packet to clients
  3227. /// </summary>
  3228. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3229. {
  3230. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3231. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3232. lock (m_entityUpdates.SyncRoot)
  3233. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3234. }
  3235. /// <summary>
  3236. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3237. /// We will update the priority and put it in the correct queue, merging update flags
  3238. /// with any other updates that may be queued for the same entity.
  3239. /// The original update time is used for the merged update.
  3240. /// </summary>
  3241. private void ResendPrimUpdate(EntityUpdate update)
  3242. {
  3243. // If the update exists in priority queue, it will be updated.
  3244. // If it does not exist then it will be added with the current (rather than its original) priority
  3245. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3246. lock (m_entityUpdates.SyncRoot)
  3247. m_entityUpdates.Enqueue(priority, update);
  3248. }
  3249. /// <summary>
  3250. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3251. /// We will update the priority and put it in the correct queue, merging update flags
  3252. /// with any other updates that may be queued for the same entity.
  3253. /// The original update time is used for the merged update.
  3254. /// </summary>
  3255. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3256. {
  3257. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3258. // Remove the update packet from the list of packets waiting for acknowledgement
  3259. // because we are requeuing the list of updates. They will be resent in new packets
  3260. // with the most recent state and priority.
  3261. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3262. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3263. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3264. // We're not going to worry about interlock yet since its not currently critical that this total count
  3265. // is 100% correct
  3266. m_udpServer.PacketsResentCount++;
  3267. foreach (EntityUpdate update in updates)
  3268. ResendPrimUpdate(update);
  3269. }
  3270. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3271. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3272. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3273. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3274. //
  3275. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3276. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3277. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3278. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3279. private void ProcessEntityUpdates(int maxUpdates)
  3280. {
  3281. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3282. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3283. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3284. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3285. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3286. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3287. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3288. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3289. // objectUpdateBlocks.Value.Clear();
  3290. // compressedUpdateBlocks.Value.Clear();
  3291. // terseUpdateBlocks.Value.Clear();
  3292. // terseAgentUpdateBlocks.Value.Clear();
  3293. // objectUpdates.Value.Clear();
  3294. // compressedUpdates.Value.Clear();
  3295. // terseUpdates.Value.Clear();
  3296. // terseAgentUpdates.Value.Clear();
  3297. // Check to see if this is a flush
  3298. if (maxUpdates <= 0)
  3299. {
  3300. maxUpdates = Int32.MaxValue;
  3301. }
  3302. int updatesThisCall = 0;
  3303. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3304. // condition where a kill can be processed before an out-of-date update for the same object.
  3305. lock (m_killRecord)
  3306. {
  3307. float avgTimeDilation = 1.0f;
  3308. IEntityUpdate iupdate;
  3309. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3310. while (updatesThisCall < maxUpdates)
  3311. {
  3312. lock (m_entityUpdates.SyncRoot)
  3313. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3314. break;
  3315. EntityUpdate update = (EntityUpdate)iupdate;
  3316. avgTimeDilation += update.TimeDilation;
  3317. avgTimeDilation *= 0.5f;
  3318. if (update.Entity is SceneObjectPart)
  3319. {
  3320. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3321. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3322. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3323. // safety measure.
  3324. //
  3325. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3326. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3327. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3328. //
  3329. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3330. // after the root prim has been deleted.
  3331. if (m_killRecord.Contains(part.LocalId))
  3332. {
  3333. // m_log.WarnFormat(
  3334. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3335. // part.LocalId, Name);
  3336. continue;
  3337. }
  3338. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3339. {
  3340. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3341. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3342. {
  3343. part.Shape.LightEntry = false;
  3344. }
  3345. }
  3346. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3347. {
  3348. // Ensure that mesh has at least 8 valid faces
  3349. part.Shape.ProfileBegin = 12500;
  3350. part.Shape.ProfileEnd = 0;
  3351. part.Shape.ProfileHollow = 27500;
  3352. }
  3353. }
  3354. #region UpdateFlags to packet type conversion
  3355. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3356. bool canUseCompressed = true;
  3357. bool canUseImproved = true;
  3358. // Compressed object updates only make sense for LL primitives
  3359. if (!(update.Entity is SceneObjectPart))
  3360. {
  3361. canUseCompressed = false;
  3362. }
  3363. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3364. {
  3365. canUseCompressed = false;
  3366. canUseImproved = false;
  3367. }
  3368. else
  3369. {
  3370. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3371. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3372. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3373. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3374. {
  3375. canUseCompressed = false;
  3376. }
  3377. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3378. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3379. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3380. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3381. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3382. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3383. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3384. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3385. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3386. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3387. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3388. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3389. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3390. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3391. {
  3392. canUseImproved = false;
  3393. }
  3394. }
  3395. #endregion UpdateFlags to packet type conversion
  3396. #region Block Construction
  3397. // TODO: Remove this once we can build compressed updates
  3398. canUseCompressed = false;
  3399. if (!canUseImproved && !canUseCompressed)
  3400. {
  3401. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3402. if (update.Entity is ScenePresence)
  3403. {
  3404. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3405. }
  3406. else
  3407. {
  3408. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3409. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3410. // If the part has become a private hud since the update was scheduled then we do not
  3411. // want to send it to other avatars.
  3412. if (part.ParentGroup.IsAttachment
  3413. && part.ParentGroup.HasPrivateAttachmentPoint
  3414. && part.ParentGroup.AttachedAvatar != AgentId)
  3415. continue;
  3416. // If the part has since been deleted, then drop the update. In the case of attachments,
  3417. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3418. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3419. // of the test above).
  3420. //
  3421. // Actual deletions (kills) happen in another method.
  3422. if (part.ParentGroup.IsDeleted)
  3423. continue;
  3424. }
  3425. objectUpdateBlocks.Value.Add(updateBlock);
  3426. objectUpdates.Value.Add(update);
  3427. }
  3428. else if (!canUseImproved)
  3429. {
  3430. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3431. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3432. = CreateCompressedUpdateBlock(part, updateFlags);
  3433. // If the part has since been deleted, then drop the update. In the case of attachments,
  3434. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3435. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3436. // of the test above).
  3437. //
  3438. // Actual deletions (kills) happen in another method.
  3439. if (part.ParentGroup.IsDeleted)
  3440. continue;
  3441. compressedUpdateBlocks.Value.Add(compressedBlock);
  3442. compressedUpdates.Value.Add(update);
  3443. }
  3444. else
  3445. {
  3446. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3447. {
  3448. // Self updates go into a special list
  3449. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3450. terseAgentUpdates.Value.Add(update);
  3451. }
  3452. else
  3453. {
  3454. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3455. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3456. // Everything else goes here
  3457. if (update.Entity is SceneObjectPart)
  3458. {
  3459. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3460. // If the part has become a private hud since the update was scheduled then we do not
  3461. // want to send it to other avatars.
  3462. if (part.ParentGroup.IsAttachment
  3463. && part.ParentGroup.HasPrivateAttachmentPoint
  3464. && part.ParentGroup.AttachedAvatar != AgentId)
  3465. continue;
  3466. // If the part has since been deleted, then drop the update. In the case of attachments,
  3467. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3468. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3469. // of the test above).
  3470. //
  3471. // Actual deletions (kills) happen in another method.
  3472. if (part.ParentGroup.IsDeleted)
  3473. continue;
  3474. }
  3475. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3476. terseUpdates.Value.Add(update);
  3477. }
  3478. }
  3479. ++updatesThisCall;
  3480. #endregion Block Construction
  3481. }
  3482. #region Packet Sending
  3483. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3484. if (terseAgentUpdateBlocks.IsValueCreated)
  3485. {
  3486. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3487. ImprovedTerseObjectUpdatePacket packet
  3488. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3489. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3490. packet.RegionData.TimeDilation = timeDilation;
  3491. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3492. for (int i = 0; i < blocks.Count; i++)
  3493. packet.ObjectData[i] = blocks[i];
  3494. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3495. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3496. }
  3497. if (objectUpdateBlocks.IsValueCreated)
  3498. {
  3499. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3500. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3501. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3502. packet.RegionData.TimeDilation = timeDilation;
  3503. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3504. for (int i = 0; i < blocks.Count; i++)
  3505. packet.ObjectData[i] = blocks[i];
  3506. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3507. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3508. }
  3509. if (compressedUpdateBlocks.IsValueCreated)
  3510. {
  3511. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3512. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3513. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3514. packet.RegionData.TimeDilation = timeDilation;
  3515. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3516. for (int i = 0; i < blocks.Count; i++)
  3517. packet.ObjectData[i] = blocks[i];
  3518. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3519. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3520. }
  3521. if (terseUpdateBlocks.IsValueCreated)
  3522. {
  3523. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3524. ImprovedTerseObjectUpdatePacket packet
  3525. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3526. PacketType.ImprovedTerseObjectUpdate);
  3527. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3528. packet.RegionData.TimeDilation = timeDilation;
  3529. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3530. for (int i = 0; i < blocks.Count; i++)
  3531. packet.ObjectData[i] = blocks[i];
  3532. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3533. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3534. }
  3535. }
  3536. #endregion Packet Sending
  3537. }
  3538. public void ReprioritizeUpdates()
  3539. {
  3540. lock (m_entityUpdates.SyncRoot)
  3541. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3542. }
  3543. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3544. {
  3545. if (entity != null)
  3546. {
  3547. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3548. return true;
  3549. }
  3550. return false;
  3551. }
  3552. public void FlushPrimUpdates()
  3553. {
  3554. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3555. while (m_entityUpdates.Count > 0)
  3556. ProcessEntityUpdates(-1);
  3557. }
  3558. #endregion Primitive Packet/Data Sending Methods
  3559. // These are used to implement an adaptive backoff in the number
  3560. // of updates converted to packets. Since we don't want packets
  3561. // to sit in the queue with old data, only convert enough updates
  3562. // to packets that can be sent in 200ms.
  3563. private Int32 m_LastQueueFill = 0;
  3564. private Int32 m_maxUpdates = 0;
  3565. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3566. {
  3567. // if (!m_udpServer.IsRunningOutbound)
  3568. // return;
  3569. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3570. {
  3571. // if (!m_udpServer.IsRunningOutbound)
  3572. // return;
  3573. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3574. {
  3575. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3576. }
  3577. else
  3578. {
  3579. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3580. m_maxUpdates += 5;
  3581. else
  3582. m_maxUpdates = m_maxUpdates >> 1;
  3583. }
  3584. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3585. m_LastQueueFill = Util.EnvironmentTickCount();
  3586. if (m_entityUpdates.Count > 0)
  3587. ProcessEntityUpdates(m_maxUpdates);
  3588. if (m_entityProps.Count > 0)
  3589. ProcessEntityPropertyRequests(m_maxUpdates);
  3590. }
  3591. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3592. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3593. }
  3594. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3595. {
  3596. bool hasUpdates = false;
  3597. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3598. {
  3599. if (m_entityUpdates.Count > 0)
  3600. hasUpdates = true;
  3601. else if (m_entityProps.Count > 0)
  3602. hasUpdates = true;
  3603. }
  3604. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3605. {
  3606. if (ImageManager.HasUpdates())
  3607. hasUpdates = true;
  3608. }
  3609. return hasUpdates;
  3610. }
  3611. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3612. {
  3613. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3614. newPack.AssetBlock.Type = AssetType;
  3615. newPack.AssetBlock.Success = Success;
  3616. newPack.AssetBlock.UUID = AssetFullID;
  3617. newPack.Header.Zerocoded = true;
  3618. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3619. }
  3620. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3621. {
  3622. RequestXferPacket newPack = new RequestXferPacket();
  3623. newPack.XferID.ID = XferID;
  3624. newPack.XferID.VFileType = AssetType;
  3625. newPack.XferID.VFileID = vFileID;
  3626. newPack.XferID.FilePath = FilePath;
  3627. newPack.XferID.Filename = FileName;
  3628. newPack.Header.Zerocoded = true;
  3629. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3630. }
  3631. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3632. {
  3633. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3634. newPack.XferID.ID = xferID;
  3635. newPack.XferID.Packet = PacketID;
  3636. newPack.Header.Zerocoded = true;
  3637. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3638. }
  3639. public void SendInitiateDownload(string simFileName, string clientFileName)
  3640. {
  3641. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3642. newPack.AgentData.AgentID = AgentId;
  3643. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3644. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3645. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3646. }
  3647. public void SendImageFirstPart(
  3648. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3649. {
  3650. ImageDataPacket im = new ImageDataPacket();
  3651. im.Header.Reliable = false;
  3652. im.ImageID.Packets = numParts;
  3653. im.ImageID.ID = ImageUUID;
  3654. if (ImageSize > 0)
  3655. im.ImageID.Size = ImageSize;
  3656. im.ImageData.Data = ImageData;
  3657. im.ImageID.Codec = imageCodec;
  3658. im.Header.Zerocoded = true;
  3659. OutPacket(im, ThrottleOutPacketType.Texture);
  3660. }
  3661. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3662. {
  3663. ImagePacketPacket im = new ImagePacketPacket();
  3664. im.Header.Reliable = false;
  3665. im.ImageID.Packet = partNumber;
  3666. im.ImageID.ID = imageUuid;
  3667. im.ImageData.Data = imageData;
  3668. OutPacket(im, ThrottleOutPacketType.Texture);
  3669. }
  3670. public void SendImageNotFound(UUID imageid)
  3671. {
  3672. ImageNotInDatabasePacket notFoundPacket
  3673. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3674. notFoundPacket.ImageID.ID = imageid;
  3675. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3676. }
  3677. public void SendShutdownConnectionNotice()
  3678. {
  3679. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3680. }
  3681. public void SendSimStats(SimStats stats)
  3682. {
  3683. SimStatsPacket pack = new SimStatsPacket();
  3684. pack.Region = new SimStatsPacket.RegionBlock();
  3685. pack.Region.RegionX = stats.RegionX;
  3686. pack.Region.RegionY = stats.RegionY;
  3687. pack.Region.RegionFlags = stats.RegionFlags;
  3688. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3689. //pack.Region = //stats.RegionBlock;
  3690. pack.Stat = stats.StatsBlock;
  3691. pack.Header.Reliable = false;
  3692. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3693. OutPacket(pack, ThrottleOutPacketType.Task);
  3694. }
  3695. private class ObjectPropertyUpdate : IEntityUpdate
  3696. {
  3697. internal bool SendFamilyProps;
  3698. internal bool SendObjectProps;
  3699. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3700. : base(entity,flags)
  3701. {
  3702. SendFamilyProps = sendfam;
  3703. SendObjectProps = sendobj;
  3704. }
  3705. public void Update(ObjectPropertyUpdate update)
  3706. {
  3707. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3708. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3709. // other properties may need to be updated by base class
  3710. base.Update(update);
  3711. }
  3712. }
  3713. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3714. {
  3715. uint priority = 0; // time based ordering only
  3716. lock (m_entityProps.SyncRoot)
  3717. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3718. }
  3719. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3720. {
  3721. uint priority = 0;
  3722. lock (m_entityProps.SyncRoot)
  3723. m_entityProps.Enqueue(priority, update);
  3724. }
  3725. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3726. {
  3727. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3728. // Remove the update packet from the list of packets waiting for acknowledgement
  3729. // because we are requeuing the list of updates. They will be resent in new packets
  3730. // with the most recent state.
  3731. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3732. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3733. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3734. // We're not going to worry about interlock yet since its not currently critical that this total count
  3735. // is 100% correct
  3736. m_udpServer.PacketsResentCount++;
  3737. foreach (ObjectPropertyUpdate update in updates)
  3738. ResendPropertyUpdate(update);
  3739. }
  3740. public void SendObjectPropertiesReply(ISceneEntity entity)
  3741. {
  3742. uint priority = 0; // time based ordering only
  3743. lock (m_entityProps.SyncRoot)
  3744. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3745. }
  3746. private void ProcessEntityPropertyRequests(int maxUpdates)
  3747. {
  3748. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3749. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3750. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3751. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3752. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3753. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3754. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3755. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3756. IEntityUpdate iupdate;
  3757. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3758. int updatesThisCall = 0;
  3759. while (updatesThisCall < m_maxUpdates)
  3760. {
  3761. lock (m_entityProps.SyncRoot)
  3762. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3763. break;
  3764. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3765. if (update.SendFamilyProps)
  3766. {
  3767. if (update.Entity is SceneObjectPart)
  3768. {
  3769. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3770. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3771. objectFamilyBlocks.Value.Add(objPropDB);
  3772. familyUpdates.Value.Add(update);
  3773. }
  3774. }
  3775. if (update.SendObjectProps)
  3776. {
  3777. if (update.Entity is SceneObjectPart)
  3778. {
  3779. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3780. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3781. objectPropertiesBlocks.Value.Add(objPropDB);
  3782. propertyUpdates.Value.Add(update);
  3783. }
  3784. }
  3785. updatesThisCall++;
  3786. }
  3787. // Int32 ppcnt = 0;
  3788. // Int32 pbcnt = 0;
  3789. if (objectPropertiesBlocks.IsValueCreated)
  3790. {
  3791. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3792. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3793. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3794. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3795. for (int i = 0; i < blocks.Count; i++)
  3796. packet.ObjectData[i] = blocks[i];
  3797. packet.Header.Zerocoded = true;
  3798. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3799. // of the object rather than the properties when the packet was created
  3800. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3801. delegate(OutgoingPacket oPacket)
  3802. {
  3803. ResendPropertyUpdates(updates, oPacket);
  3804. });
  3805. // pbcnt += blocks.Count;
  3806. // ppcnt++;
  3807. }
  3808. // Int32 fpcnt = 0;
  3809. // Int32 fbcnt = 0;
  3810. if (objectFamilyBlocks.IsValueCreated)
  3811. {
  3812. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3813. // one packet per object block... uggh...
  3814. for (int i = 0; i < blocks.Count; i++)
  3815. {
  3816. ObjectPropertiesFamilyPacket packet =
  3817. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3818. packet.ObjectData = blocks[i];
  3819. packet.Header.Zerocoded = true;
  3820. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3821. // of the object rather than the properties when the packet was created
  3822. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3823. updates.Add(familyUpdates.Value[i]);
  3824. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3825. delegate(OutgoingPacket oPacket)
  3826. {
  3827. ResendPropertyUpdates(updates, oPacket);
  3828. });
  3829. // fpcnt++;
  3830. // fbcnt++;
  3831. }
  3832. }
  3833. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3834. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3835. }
  3836. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3837. {
  3838. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3839. block.RequestFlags = requestFlags;
  3840. block.ObjectID = sop.UUID;
  3841. if (sop.OwnerID == sop.GroupID)
  3842. block.OwnerID = UUID.Zero;
  3843. else
  3844. block.OwnerID = sop.OwnerID;
  3845. block.GroupID = sop.GroupID;
  3846. block.BaseMask = sop.BaseMask;
  3847. block.OwnerMask = sop.OwnerMask;
  3848. block.GroupMask = sop.GroupMask;
  3849. block.EveryoneMask = sop.EveryoneMask;
  3850. block.NextOwnerMask = sop.NextOwnerMask;
  3851. // TODO: More properties are needed in SceneObjectPart!
  3852. block.OwnershipCost = sop.OwnershipCost;
  3853. block.SaleType = sop.ObjectSaleType;
  3854. block.SalePrice = sop.SalePrice;
  3855. block.Category = sop.Category;
  3856. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3857. block.Name = Util.StringToBytes256(sop.Name);
  3858. block.Description = Util.StringToBytes256(sop.Description);
  3859. return block;
  3860. }
  3861. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3862. {
  3863. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3864. // TODO: don't create new blocks if recycling an old packet
  3865. ObjectPropertiesPacket.ObjectDataBlock block =
  3866. new ObjectPropertiesPacket.ObjectDataBlock();
  3867. block.ObjectID = sop.UUID;
  3868. block.Name = Util.StringToBytes256(sop.Name);
  3869. block.Description = Util.StringToBytes256(sop.Description);
  3870. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3871. block.CreatorID = sop.CreatorID;
  3872. block.GroupID = sop.GroupID;
  3873. block.LastOwnerID = sop.LastOwnerID;
  3874. if (sop.OwnerID == sop.GroupID)
  3875. block.OwnerID = UUID.Zero;
  3876. else
  3877. block.OwnerID = sop.OwnerID;
  3878. block.ItemID = sop.FromUserInventoryItemID;
  3879. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3880. block.FromTaskID = UUID.Zero; // ???
  3881. block.InventorySerial = (short)sop.InventorySerial;
  3882. SceneObjectPart root = sop.ParentGroup.RootPart;
  3883. block.TouchName = Util.StringToBytes256(root.TouchName);
  3884. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  3885. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  3886. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  3887. // using (MemoryStream memStream = new MemoryStream())
  3888. // {
  3889. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  3890. // {
  3891. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  3892. // {
  3893. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  3894. //
  3895. // UUID textureID;
  3896. //
  3897. // if (teFace != null)
  3898. // textureID = teFace.TextureID;
  3899. // else
  3900. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  3901. //
  3902. // binWriter.Write(textureID.GetBytes());
  3903. // }
  3904. //
  3905. // block.TextureID = memStream.ToArray();
  3906. // }
  3907. // }
  3908. block.TextureID = new byte[0]; // TextureID ???
  3909. block.SitName = Util.StringToBytes256(root.SitName);
  3910. block.OwnerMask = root.OwnerMask;
  3911. block.NextOwnerMask = root.NextOwnerMask;
  3912. block.GroupMask = root.GroupMask;
  3913. block.EveryoneMask = root.EveryoneMask;
  3914. block.BaseMask = root.BaseMask;
  3915. block.SaleType = root.ObjectSaleType;
  3916. block.SalePrice = root.SalePrice;
  3917. return block;
  3918. }
  3919. #region Estate Data Sending Methods
  3920. private static bool convertParamStringToBool(byte[] field)
  3921. {
  3922. string s = Utils.BytesToString(field);
  3923. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3924. {
  3925. return true;
  3926. }
  3927. return false;
  3928. }
  3929. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3930. {
  3931. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3932. packet.AgentData.TransactionID = UUID.Random();
  3933. packet.AgentData.AgentID = AgentId;
  3934. packet.AgentData.SessionID = SessionId;
  3935. packet.MethodData.Invoice = invoice;
  3936. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3937. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3938. for (int i = 0; i < (6 + Data.Length); i++)
  3939. {
  3940. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3941. }
  3942. int j = 0;
  3943. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3944. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3945. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3946. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3947. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3948. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3949. j = 2; // Agents
  3950. if ((code & 2) != 0)
  3951. j = 3; // Groups
  3952. if ((code & 8) != 0)
  3953. j = 5; // Managers
  3954. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3955. j = 6;
  3956. for (int i = 0; i < Data.Length; i++)
  3957. {
  3958. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3959. }
  3960. packet.ParamList = returnblock;
  3961. packet.Header.Reliable = true;
  3962. OutPacket(packet, ThrottleOutPacketType.Task);
  3963. }
  3964. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3965. {
  3966. List<UUID> BannedUsers = new List<UUID>();
  3967. for (int i = 0; i < bl.Length; i++)
  3968. {
  3969. if (bl[i] == null)
  3970. continue;
  3971. if (bl[i].BannedUserID == UUID.Zero)
  3972. continue;
  3973. BannedUsers.Add(bl[i].BannedUserID);
  3974. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3975. {
  3976. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3977. packet.AgentData.TransactionID = UUID.Random();
  3978. packet.AgentData.AgentID = AgentId;
  3979. packet.AgentData.SessionID = SessionId;
  3980. packet.MethodData.Invoice = invoice;
  3981. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3982. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3983. int j;
  3984. for (j = 0; j < (6 + BannedUsers.Count); j++)
  3985. {
  3986. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  3987. }
  3988. j = 0;
  3989. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3990. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3991. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3992. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3993. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3994. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3995. foreach (UUID banned in BannedUsers)
  3996. {
  3997. returnblock[j].Parameter = banned.GetBytes(); j++;
  3998. }
  3999. packet.ParamList = returnblock;
  4000. packet.Header.Reliable = true;
  4001. OutPacket(packet, ThrottleOutPacketType.Task);
  4002. BannedUsers.Clear();
  4003. }
  4004. }
  4005. }
  4006. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4007. {
  4008. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4009. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4010. rinfopack.AgentData.AgentID = AgentId;
  4011. rinfopack.AgentData.SessionID = SessionId;
  4012. rinfoblk.BillableFactor = args.billableFactor;
  4013. rinfoblk.EstateID = args.estateID;
  4014. rinfoblk.MaxAgents = args.maxAgents;
  4015. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4016. rinfoblk.ParentEstateID = args.parentEstateID;
  4017. rinfoblk.PricePerMeter = args.pricePerMeter;
  4018. rinfoblk.RedirectGridX = args.redirectGridX;
  4019. rinfoblk.RedirectGridY = args.redirectGridY;
  4020. rinfoblk.RegionFlags = args.regionFlags;
  4021. rinfoblk.SimAccess = args.simAccess;
  4022. rinfoblk.SunHour = args.sunHour;
  4023. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4024. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4025. rinfoblk.UseEstateSun = args.useEstateSun;
  4026. rinfoblk.WaterHeight = args.waterHeight;
  4027. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4028. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4029. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4030. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4031. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4032. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4033. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4034. rinfopack.HasVariableBlocks = true;
  4035. rinfopack.RegionInfo = rinfoblk;
  4036. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4037. rinfopack.AgentData.AgentID = AgentId;
  4038. rinfopack.AgentData.SessionID = SessionId;
  4039. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4040. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4041. }
  4042. public void SendEstateCovenantInformation(UUID covenant)
  4043. {
  4044. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4045. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4046. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4047. edata.CovenantID = covenant;
  4048. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4049. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4050. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4051. einfopack.Data = edata;
  4052. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4053. }
  4054. public void SendDetailedEstateData(
  4055. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4056. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4057. {
  4058. // m_log.DebugFormat(
  4059. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4060. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4061. packet.MethodData.Invoice = invoice;
  4062. packet.AgentData.TransactionID = UUID.Random();
  4063. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4064. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4065. for (int i = 0; i < 10; i++)
  4066. {
  4067. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4068. }
  4069. //Sending Estate Settings
  4070. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4071. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4072. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4073. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4074. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4075. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4076. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4077. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4078. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4079. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4080. packet.ParamList = returnblock;
  4081. packet.Header.Reliable = false;
  4082. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4083. OutPacket(packet, ThrottleOutPacketType.Task);
  4084. }
  4085. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4086. {
  4087. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4088. packet.TelehubBlock.ObjectID = ObjectID;
  4089. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4090. packet.TelehubBlock.TelehubPos = ObjectPos;
  4091. packet.TelehubBlock.TelehubRot = ObjectRot;
  4092. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4093. for (int n = 0; n < SpawnPoint.Count; n++)
  4094. {
  4095. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4096. }
  4097. OutPacket(packet, ThrottleOutPacketType.Task);
  4098. }
  4099. #endregion
  4100. #region Land Data Sending Methods
  4101. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4102. {
  4103. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4104. packet.ParcelData.Data = data;
  4105. packet.ParcelData.SequenceID = sequence_id;
  4106. packet.Header.Zerocoded = true;
  4107. OutPacket(packet, ThrottleOutPacketType.Task);
  4108. }
  4109. public void SendLandProperties(
  4110. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4111. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4112. {
  4113. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4114. LandData landData = lo.LandData;
  4115. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4116. updateMessage.AABBMax = landData.AABBMax;
  4117. updateMessage.AABBMin = landData.AABBMin;
  4118. updateMessage.Area = landData.Area;
  4119. updateMessage.AuctionID = landData.AuctionID;
  4120. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4121. updateMessage.Bitmap = landData.Bitmap;
  4122. updateMessage.Desc = landData.Description;
  4123. updateMessage.Category = landData.Category;
  4124. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4125. updateMessage.ClaimPrice = landData.ClaimPrice;
  4126. updateMessage.GroupID = landData.GroupID;
  4127. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4128. updateMessage.LandingType = (LandingType) landData.LandingType;
  4129. updateMessage.LocalID = landData.LocalID;
  4130. if (landData.Area > 0)
  4131. {
  4132. updateMessage.MaxPrims = parcelObjectCapacity;
  4133. }
  4134. else
  4135. {
  4136. updateMessage.MaxPrims = 0;
  4137. }
  4138. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4139. updateMessage.MediaID = landData.MediaID;
  4140. updateMessage.MediaURL = landData.MediaURL;
  4141. updateMessage.MusicURL = landData.MusicURL;
  4142. updateMessage.Name = landData.Name;
  4143. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4144. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4145. updateMessage.OwnerID = landData.OwnerID;
  4146. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4147. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4148. updateMessage.PassHours = landData.PassHours;
  4149. updateMessage.PassPrice = landData.PassPrice;
  4150. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4151. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4152. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4153. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4154. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4155. updateMessage.RentPrice = 0;
  4156. updateMessage.RequestResult = (ParcelResult) request_result;
  4157. updateMessage.SalePrice = landData.SalePrice;
  4158. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4159. updateMessage.SequenceID = sequence_id;
  4160. if (landData.SimwideArea > 0)
  4161. {
  4162. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4163. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4164. }
  4165. else
  4166. {
  4167. updateMessage.SimWideMaxPrims = 0;
  4168. }
  4169. updateMessage.SnapSelection = snap_selection;
  4170. updateMessage.SnapshotID = landData.SnapshotID;
  4171. updateMessage.Status = (ParcelStatus) landData.Status;
  4172. updateMessage.UserLocation = landData.UserLocation;
  4173. updateMessage.UserLookAt = landData.UserLookAt;
  4174. updateMessage.MediaType = landData.MediaType;
  4175. updateMessage.MediaDesc = landData.MediaDescription;
  4176. updateMessage.MediaWidth = landData.MediaWidth;
  4177. updateMessage.MediaHeight = landData.MediaHeight;
  4178. updateMessage.MediaLoop = landData.MediaLoop;
  4179. updateMessage.ObscureMusic = landData.ObscureMusic;
  4180. updateMessage.ObscureMedia = landData.ObscureMedia;
  4181. IPrimCounts pc = lo.PrimCounts;
  4182. updateMessage.OwnerPrims = pc.Owner;
  4183. updateMessage.GroupPrims = pc.Group;
  4184. updateMessage.OtherPrims = pc.Others;
  4185. updateMessage.SelectedPrims = pc.Selected;
  4186. updateMessage.TotalPrims = pc.Total;
  4187. updateMessage.SimWideTotalPrims = pc.Simulator;
  4188. try
  4189. {
  4190. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4191. if (eq != null)
  4192. {
  4193. eq.ParcelProperties(updateMessage, this.AgentId);
  4194. }
  4195. else
  4196. {
  4197. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4198. }
  4199. }
  4200. catch (Exception ex)
  4201. {
  4202. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4203. }
  4204. }
  4205. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4206. {
  4207. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4208. replyPacket.Data.AgentID = AgentId;
  4209. replyPacket.Data.Flags = accessFlag;
  4210. replyPacket.Data.LocalID = localLandID;
  4211. replyPacket.Data.SequenceID = 0;
  4212. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4213. foreach (LandAccessEntry entry in accessList)
  4214. {
  4215. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4216. block.Flags = accessFlag;
  4217. block.ID = entry.AgentID;
  4218. block.Time = entry.Expires;
  4219. list.Add(block);
  4220. }
  4221. replyPacket.List = list.ToArray();
  4222. replyPacket.Header.Zerocoded = true;
  4223. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4224. }
  4225. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4226. {
  4227. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4228. bool firstCall = true;
  4229. const int MAX_OBJECTS_PER_PACKET = 251;
  4230. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4231. ForceObjectSelectPacket.DataBlock[] data;
  4232. while (ObjectIDs.Count > 0)
  4233. {
  4234. if (firstCall)
  4235. {
  4236. pack._Header.ResetList = true;
  4237. firstCall = false;
  4238. }
  4239. else
  4240. {
  4241. pack._Header.ResetList = false;
  4242. }
  4243. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4244. {
  4245. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4246. }
  4247. else
  4248. {
  4249. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4250. }
  4251. int i;
  4252. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4253. {
  4254. data[i] = new ForceObjectSelectPacket.DataBlock();
  4255. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4256. ObjectIDs.RemoveAt(0);
  4257. }
  4258. pack.Data = data;
  4259. pack.Header.Zerocoded = true;
  4260. OutPacket(pack, ThrottleOutPacketType.Task);
  4261. }
  4262. }
  4263. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4264. {
  4265. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4266. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4267. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4268. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4269. OutPacket(cpack, ThrottleOutPacketType.Task);
  4270. }
  4271. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4272. {
  4273. int notifyCount = ownersAndCount.Count;
  4274. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4275. if (notifyCount > 0)
  4276. {
  4277. if (notifyCount > 32)
  4278. {
  4279. m_log.InfoFormat(
  4280. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4281. + " - a developer might want to investigate whether this is a hard limit", 32);
  4282. notifyCount = 32;
  4283. }
  4284. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4285. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4286. int num = 0;
  4287. foreach (UUID owner in ownersAndCount.Keys)
  4288. {
  4289. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4290. dataBlock[num].Count = ownersAndCount[owner];
  4291. if (land.GroupID == owner || groups.Contains(owner))
  4292. dataBlock[num].IsGroupOwned = true;
  4293. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4294. dataBlock[num].OwnerID = owner;
  4295. num++;
  4296. if (num >= notifyCount)
  4297. {
  4298. break;
  4299. }
  4300. }
  4301. pack.Data = dataBlock;
  4302. }
  4303. else
  4304. {
  4305. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4306. }
  4307. pack.Header.Zerocoded = true;
  4308. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4309. }
  4310. #endregion
  4311. #region Helper Methods
  4312. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4313. {
  4314. #region ScenePresence/SOP Handling
  4315. bool avatar = (entity is ScenePresence);
  4316. uint localID = entity.LocalId;
  4317. uint attachPoint;
  4318. Vector4 collisionPlane;
  4319. Vector3 position, velocity, acceleration, angularVelocity;
  4320. Quaternion rotation;
  4321. byte[] textureEntry;
  4322. if (entity is ScenePresence)
  4323. {
  4324. ScenePresence presence = (ScenePresence)entity;
  4325. // m_log.DebugFormat(
  4326. // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
  4327. attachPoint = presence.State;
  4328. collisionPlane = presence.CollisionPlane;
  4329. position = presence.OffsetPosition;
  4330. velocity = presence.Velocity;
  4331. acceleration = Vector3.Zero;
  4332. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4333. // in that direction, even though we don't model this on the server. Implementing this in the future
  4334. // may improve movement smoothness.
  4335. // acceleration = new Vector3(1, 0, 0);
  4336. angularVelocity = presence.AngularVelocity;
  4337. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4338. // it rotates around.
  4339. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4340. // excessive up and down movements of the camera when looking up and down.
  4341. // See http://opensimulator.org/mantis/view.php?id=3274
  4342. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4343. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4344. // the rotation in this case.
  4345. rotation = presence.Rotation;
  4346. if (!presence.IsSatOnObject)
  4347. {
  4348. rotation.X = 0;
  4349. rotation.Y = 0;
  4350. }
  4351. if (sendTexture)
  4352. textureEntry = presence.Appearance.Texture.GetBytes();
  4353. else
  4354. textureEntry = null;
  4355. }
  4356. else
  4357. {
  4358. SceneObjectPart part = (SceneObjectPart)entity;
  4359. attachPoint = part.ParentGroup.AttachmentPoint;
  4360. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4361. // m_log.DebugFormat(
  4362. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4363. // attachPoint, part.Name, part.LocalId, Name);
  4364. collisionPlane = Vector4.Zero;
  4365. position = part.RelativePosition;
  4366. velocity = part.Velocity;
  4367. acceleration = part.Acceleration;
  4368. angularVelocity = part.AngularVelocity;
  4369. rotation = part.RotationOffset;
  4370. if (sendTexture)
  4371. textureEntry = part.Shape.TextureEntry;
  4372. else
  4373. textureEntry = null;
  4374. }
  4375. #endregion ScenePresence/SOP Handling
  4376. int pos = 0;
  4377. byte[] data = new byte[(avatar ? 60 : 44)];
  4378. // LocalID
  4379. Utils.UIntToBytes(localID, data, pos);
  4380. pos += 4;
  4381. // Avatar/CollisionPlane
  4382. data[pos++] = (byte) attachPoint;
  4383. if (avatar)
  4384. {
  4385. data[pos++] = 1;
  4386. if (collisionPlane == Vector4.Zero)
  4387. collisionPlane = Vector4.UnitW;
  4388. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4389. collisionPlane.ToBytes(data, pos);
  4390. pos += 16;
  4391. }
  4392. else
  4393. {
  4394. ++pos;
  4395. }
  4396. // Position
  4397. position.ToBytes(data, pos);
  4398. pos += 12;
  4399. // Velocity
  4400. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4401. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4402. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4403. // Acceleration
  4404. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4405. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4406. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4407. // Rotation
  4408. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4409. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4410. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4411. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4412. // Angular Velocity
  4413. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4414. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4415. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4416. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4417. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4418. block.Data = data;
  4419. if (textureEntry != null && textureEntry.Length > 0)
  4420. {
  4421. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4422. // Texture Length
  4423. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4424. // Texture
  4425. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4426. block.TextureEntry = teBytesFinal;
  4427. }
  4428. else
  4429. {
  4430. block.TextureEntry = Utils.EmptyBytes;
  4431. }
  4432. return block;
  4433. }
  4434. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4435. {
  4436. // m_log.DebugFormat(
  4437. // "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name);
  4438. byte[] objectData = new byte[76];
  4439. data.CollisionPlane.ToBytes(objectData, 0);
  4440. data.OffsetPosition.ToBytes(objectData, 16);
  4441. // data.Velocity.ToBytes(objectData, 28);
  4442. // data.Acceleration.ToBytes(objectData, 40);
  4443. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4444. // it rotates around.
  4445. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4446. // excessive up and down movements of the camera when looking up and down.
  4447. // See http://opensimulator.org/mantis/view.php?id=3274
  4448. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4449. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4450. // the rotation in this case.
  4451. Quaternion rot = data.Rotation;
  4452. if (!data.IsSatOnObject)
  4453. {
  4454. rot.X = 0;
  4455. rot.Y = 0;
  4456. }
  4457. rot.ToBytes(objectData, 52);
  4458. //data.AngularVelocity.ToBytes(objectData, 64);
  4459. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4460. update.Data = Utils.EmptyBytes;
  4461. update.ExtraParams = new byte[1];
  4462. update.FullID = data.UUID;
  4463. update.ID = data.LocalId;
  4464. update.Material = (byte)Material.Flesh;
  4465. update.MediaURL = Utils.EmptyBytes;
  4466. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4467. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4468. update.ObjectData = objectData;
  4469. SceneObjectPart parentPart = data.ParentPart;
  4470. if (parentPart != null)
  4471. update.ParentID = parentPart.ParentGroup.LocalId;
  4472. else
  4473. update.ParentID = 0;
  4474. update.PathCurve = 16;
  4475. update.PathScaleX = 100;
  4476. update.PathScaleY = 100;
  4477. update.PCode = (byte)PCode.Avatar;
  4478. update.ProfileCurve = 1;
  4479. update.PSBlock = Utils.EmptyBytes;
  4480. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4481. update.Text = Utils.EmptyBytes;
  4482. update.TextColor = new byte[4];
  4483. // Don't send texture anim for avatars - this has no meaning for them.
  4484. update.TextureAnim = Utils.EmptyBytes;
  4485. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4486. update.TextureEntry = Utils.EmptyBytes;
  4487. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4488. update.UpdateFlags = (uint)(
  4489. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4490. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4491. PrimFlags.ObjectOwnerModify);
  4492. return update;
  4493. }
  4494. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4495. {
  4496. byte[] objectData = new byte[60];
  4497. data.RelativePosition.ToBytes(objectData, 0);
  4498. data.Velocity.ToBytes(objectData, 12);
  4499. data.Acceleration.ToBytes(objectData, 24);
  4500. try
  4501. {
  4502. data.RotationOffset.ToBytes(objectData, 36);
  4503. }
  4504. catch (Exception e)
  4505. {
  4506. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4507. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4508. }
  4509. data.AngularVelocity.ToBytes(objectData, 48);
  4510. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4511. update.ClickAction = (byte)data.ClickAction;
  4512. update.CRC = 0;
  4513. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4514. update.FullID = data.UUID;
  4515. update.ID = data.LocalId;
  4516. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4517. //update.JointPivot = Vector3.Zero;
  4518. //update.JointType = 0;
  4519. update.Material = data.Material;
  4520. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4521. if (data.ParentGroup.IsAttachment)
  4522. {
  4523. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4524. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4525. }
  4526. else
  4527. {
  4528. update.NameValue = Utils.EmptyBytes;
  4529. // The root part state is the canonical state for all parts of the object. The other part states in the
  4530. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4531. update.State = data.ParentGroup.RootPart.Shape.State;
  4532. }
  4533. // m_log.DebugFormat(
  4534. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4535. // update.State, data.Name, data.LocalId, Name);
  4536. update.ObjectData = objectData;
  4537. update.ParentID = data.ParentID;
  4538. update.PathBegin = data.Shape.PathBegin;
  4539. update.PathCurve = data.Shape.PathCurve;
  4540. update.PathEnd = data.Shape.PathEnd;
  4541. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4542. update.PathRevolutions = data.Shape.PathRevolutions;
  4543. update.PathScaleX = data.Shape.PathScaleX;
  4544. update.PathScaleY = data.Shape.PathScaleY;
  4545. update.PathShearX = data.Shape.PathShearX;
  4546. update.PathShearY = data.Shape.PathShearY;
  4547. update.PathSkew = data.Shape.PathSkew;
  4548. update.PathTaperX = data.Shape.PathTaperX;
  4549. update.PathTaperY = data.Shape.PathTaperY;
  4550. update.PathTwist = data.Shape.PathTwist;
  4551. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4552. update.PCode = data.Shape.PCode;
  4553. update.ProfileBegin = data.Shape.ProfileBegin;
  4554. update.ProfileCurve = data.Shape.ProfileCurve;
  4555. update.ProfileEnd = data.Shape.ProfileEnd;
  4556. update.ProfileHollow = data.Shape.ProfileHollow;
  4557. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4558. update.TextColor = data.GetTextColor().GetBytes(false);
  4559. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4560. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4561. update.Scale = data.Shape.Scale;
  4562. update.Text = Util.StringToBytes256(data.Text);
  4563. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4564. #region PrimFlags
  4565. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4566. // Don't send the CreateSelected flag to everyone
  4567. flags &= ~PrimFlags.CreateSelected;
  4568. if (recipientID == data.OwnerID)
  4569. {
  4570. if (data.CreateSelected)
  4571. {
  4572. // Only send this flag once, then unset it
  4573. flags |= PrimFlags.CreateSelected;
  4574. data.CreateSelected = false;
  4575. }
  4576. }
  4577. // m_log.DebugFormat(
  4578. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4579. // data.Name, update.FullID, flags, update.ID);
  4580. update.UpdateFlags = (uint)flags;
  4581. #endregion PrimFlags
  4582. if (data.Sound != UUID.Zero)
  4583. {
  4584. update.Sound = data.Sound;
  4585. update.OwnerID = data.OwnerID;
  4586. update.Gain = (float)data.SoundGain;
  4587. update.Radius = (float)data.SoundRadius;
  4588. update.Flags = data.SoundFlags;
  4589. }
  4590. switch ((PCode)data.Shape.PCode)
  4591. {
  4592. case PCode.Grass:
  4593. case PCode.Tree:
  4594. case PCode.NewTree:
  4595. update.Data = new byte[] { data.Shape.State };
  4596. break;
  4597. default:
  4598. update.Data = Utils.EmptyBytes;
  4599. break;
  4600. }
  4601. return update;
  4602. }
  4603. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4604. {
  4605. // TODO: Implement this
  4606. return null;
  4607. }
  4608. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4609. {
  4610. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4611. // TODO: don't create new blocks if recycling an old packet
  4612. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4613. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4614. packet.UUIDNameBlock[0].ID = profileId;
  4615. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4616. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4617. OutPacket(packet, ThrottleOutPacketType.Task);
  4618. }
  4619. public ulong GetGroupPowers(UUID groupID)
  4620. {
  4621. if (groupID == m_activeGroupID)
  4622. return m_activeGroupPowers;
  4623. if (m_groupPowers.ContainsKey(groupID))
  4624. return m_groupPowers[groupID];
  4625. return 0;
  4626. }
  4627. #endregion
  4628. /// <summary>
  4629. /// This is a different way of processing packets then ProcessInPacket
  4630. /// </summary>
  4631. protected virtual void RegisterLocalPacketHandlers()
  4632. {
  4633. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4634. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4635. // for each AgentUpdate packet.
  4636. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4637. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4638. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4639. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4640. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4641. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4642. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4643. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4644. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4645. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4646. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4647. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4648. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4649. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4650. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4651. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4652. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4653. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4654. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4655. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4656. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4657. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4658. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4659. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4660. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4661. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4662. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4663. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4664. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4665. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4666. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4667. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4668. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4669. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4670. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4671. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4672. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4673. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4674. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4675. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4676. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4677. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4678. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4679. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4680. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4681. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4682. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4683. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4684. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4685. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4686. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4687. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4688. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4689. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4690. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4691. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4692. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4693. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4694. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4695. // some clients will send out a separate ObjectImage packet for each face
  4696. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4697. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4698. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4699. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4700. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4701. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4702. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4703. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4704. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4705. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4706. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4707. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4708. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4709. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4710. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4711. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4712. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4713. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4714. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4715. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4716. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4717. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4718. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4719. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4720. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4721. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4722. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4723. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4724. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4725. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4726. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4727. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4728. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4729. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4730. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4731. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4732. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4733. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4734. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4735. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4736. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4737. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4738. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4739. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4740. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4741. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4742. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4743. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4744. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4745. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4746. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4747. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4748. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4749. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4750. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4751. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4752. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4753. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4754. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4755. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4756. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4757. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4758. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4759. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4760. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4761. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4762. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4763. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4764. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4765. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4766. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4767. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4768. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4769. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4770. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4771. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4772. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4773. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4774. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4775. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4776. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4777. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4778. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4779. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4780. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4781. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4782. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4783. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4784. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4785. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4786. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4787. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4788. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4789. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4790. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4791. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4792. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4793. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4794. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4795. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4796. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4797. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4798. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4799. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4800. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4801. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4802. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4803. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4804. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4805. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4806. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4807. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4808. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4809. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4810. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4811. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4812. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4813. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4814. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4815. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4816. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4817. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4818. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4819. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4820. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4821. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4822. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4823. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4824. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4825. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4826. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4827. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4828. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4829. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4830. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4831. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4832. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4833. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4834. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4835. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4836. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4837. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4838. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4839. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4840. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4841. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4842. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4843. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4844. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4845. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4846. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4847. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4848. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4849. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4850. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4851. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4852. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4853. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4854. }
  4855. #region Packet Handlers
  4856. public int TotalAgentUpdates { get; set; }
  4857. #region Scene/Avatar
  4858. // Threshold for body rotation to be a significant agent update
  4859. private const float QDELTA = 0.000001f;
  4860. // Threshold for camera rotation to be a significant agent update
  4861. private const float VDELTA = 0.01f;
  4862. /// <summary>
  4863. /// This checks the update significance against the last update made.
  4864. /// </summary>
  4865. /// <remarks>Can only be called by one thread at a time</remarks>
  4866. /// <returns></returns>
  4867. /// <param name='x'></param>
  4868. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4869. {
  4870. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  4871. }
  4872. /// <summary>
  4873. /// This checks the movement/state update significance against the last update made.
  4874. /// </summary>
  4875. /// <remarks>Can only be called by one thread at a time</remarks>
  4876. /// <returns></returns>
  4877. /// <param name='x'></param>
  4878. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4879. {
  4880. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  4881. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  4882. bool movementSignificant =
  4883. (qdelta1 > QDELTA) // significant if body rotation above threshold
  4884. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  4885. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  4886. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  4887. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  4888. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  4889. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  4890. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  4891. ;
  4892. //if (movementSignificant)
  4893. //{
  4894. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  4895. // qdelta1, qdelta2);
  4896. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  4897. // x.ControlFlags, x.Flags, x.Far, x.State);
  4898. //}
  4899. return movementSignificant;
  4900. }
  4901. /// <summary>
  4902. /// This checks the camera update significance against the last update made.
  4903. /// </summary>
  4904. /// <remarks>Can only be called by one thread at a time</remarks>
  4905. /// <returns></returns>
  4906. /// <param name='x'></param>
  4907. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4908. {
  4909. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  4910. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  4911. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  4912. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  4913. bool cameraSignificant =
  4914. (vdelta1 > VDELTA) ||
  4915. (vdelta2 > VDELTA) ||
  4916. (vdelta3 > VDELTA) ||
  4917. (vdelta4 > VDELTA)
  4918. ;
  4919. //if (cameraSignificant)
  4920. //{
  4921. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  4922. // x.CameraAtAxis, x.CameraCenter);
  4923. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  4924. // x.CameraLeftAxis, x.CameraUpAxis);
  4925. //}
  4926. return cameraSignificant;
  4927. }
  4928. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4929. {
  4930. // We got here, which means that something in agent update was significant
  4931. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4932. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4933. if (x.AgentID != AgentId || x.SessionID != SessionId)
  4934. return false;
  4935. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  4936. // to see what exactly changed
  4937. bool movement = CheckAgentMovementUpdateSignificance(x);
  4938. bool camera = CheckAgentCameraUpdateSignificance(x);
  4939. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  4940. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4941. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4942. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4943. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4944. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4945. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4946. m_thisAgentUpdateArgs.Far = x.Far;
  4947. m_thisAgentUpdateArgs.Flags = x.Flags;
  4948. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4949. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  4950. m_thisAgentUpdateArgs.State = x.State;
  4951. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4952. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4953. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  4954. // Was there a significant movement/state change?
  4955. if (movement)
  4956. {
  4957. if (handlerPreAgentUpdate != null)
  4958. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  4959. if (handlerAgentUpdate != null)
  4960. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  4961. }
  4962. // Was there a significant camera(s) change?
  4963. if (camera)
  4964. if (handlerAgentCameraUpdate != null)
  4965. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  4966. handlerAgentUpdate = null;
  4967. handlerPreAgentUpdate = null;
  4968. handlerAgentCameraUpdate = null;
  4969. PacketPool.Instance.ReturnPacket(packet);
  4970. return true;
  4971. }
  4972. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4973. {
  4974. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4975. // validate the agent owns the agentID and sessionID
  4976. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4977. money.AgentData.SessionID == sender.SessionId)
  4978. {
  4979. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4980. if (handlerMoneyTransferRequest != null)
  4981. {
  4982. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4983. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4984. Util.FieldToString(money.MoneyData.Description));
  4985. }
  4986. return true;
  4987. }
  4988. return false;
  4989. }
  4990. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4991. {
  4992. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4993. (ParcelGodMarkAsContentPacket)Packet;
  4994. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4995. if (ParcelGodMarkAsContentHandler != null)
  4996. {
  4997. ParcelGodMarkAsContentHandler(this,
  4998. ParcelGodMarkAsContent.AgentData.AgentID,
  4999. ParcelGodMarkAsContent.ParcelData.LocalID);
  5000. return true;
  5001. }
  5002. return false;
  5003. }
  5004. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  5005. {
  5006. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5007. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5008. if (FreezeUserHandler != null)
  5009. {
  5010. FreezeUserHandler(this,
  5011. FreezeUser.AgentData.AgentID,
  5012. FreezeUser.Data.Flags,
  5013. FreezeUser.Data.TargetID);
  5014. return true;
  5015. }
  5016. return false;
  5017. }
  5018. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5019. {
  5020. EjectUserPacket EjectUser =
  5021. (EjectUserPacket)Packet;
  5022. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5023. if (EjectUserHandler != null)
  5024. {
  5025. EjectUserHandler(this,
  5026. EjectUser.AgentData.AgentID,
  5027. EjectUser.Data.Flags,
  5028. EjectUser.Data.TargetID);
  5029. return true;
  5030. }
  5031. return false;
  5032. }
  5033. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5034. {
  5035. ParcelBuyPassPacket ParcelBuyPass =
  5036. (ParcelBuyPassPacket)Packet;
  5037. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5038. if (ParcelBuyPassHandler != null)
  5039. {
  5040. ParcelBuyPassHandler(this,
  5041. ParcelBuyPass.AgentData.AgentID,
  5042. ParcelBuyPass.ParcelData.LocalID);
  5043. return true;
  5044. }
  5045. return false;
  5046. }
  5047. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5048. {
  5049. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5050. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5051. {
  5052. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5053. if (handlerParcelBuy != null)
  5054. {
  5055. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5056. parcel.Data.IsGroupOwned,
  5057. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5058. parcel.ParcelData.Price,
  5059. false);
  5060. }
  5061. return true;
  5062. }
  5063. return false;
  5064. }
  5065. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5066. {
  5067. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5068. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5069. {
  5070. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5071. if (handlerUUIDGroupNameRequest != null)
  5072. {
  5073. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5074. }
  5075. }
  5076. return true;
  5077. }
  5078. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5079. {
  5080. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5081. if (m_genericPacketHandlers.Count == 0) return false;
  5082. if (gmpack.AgentData.SessionID != SessionId) return false;
  5083. GenericMessage handlerGenericMessage = null;
  5084. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5085. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5086. {
  5087. List<string> msg = new List<string>();
  5088. List<byte[]> msgBytes = new List<byte[]>();
  5089. if (handlerGenericMessage != null)
  5090. {
  5091. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5092. {
  5093. msg.Add(Util.FieldToString(block.Parameter));
  5094. msgBytes.Add(block.Parameter);
  5095. }
  5096. try
  5097. {
  5098. if (OnBinaryGenericMessage != null)
  5099. {
  5100. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5101. }
  5102. handlerGenericMessage(sender, method, msg);
  5103. return true;
  5104. }
  5105. catch (Exception e)
  5106. {
  5107. m_log.ErrorFormat(
  5108. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5109. }
  5110. }
  5111. }
  5112. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5113. return false;
  5114. }
  5115. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5116. {
  5117. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5118. if (ogpack.AgentData.SessionID != SessionId) return false;
  5119. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5120. if (handlerObjectGroupRequest != null)
  5121. {
  5122. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5123. {
  5124. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5125. }
  5126. }
  5127. return true;
  5128. }
  5129. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5130. {
  5131. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5132. if (viewer.AgentData.SessionID != SessionId) return false;
  5133. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5134. if (handlerViewerEffect != null)
  5135. {
  5136. int length = viewer.Effect.Length;
  5137. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5138. for (int i = 0; i < length; i++)
  5139. {
  5140. //copy the effects block arguments into the event handler arg.
  5141. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5142. argument.AgentID = viewer.Effect[i].AgentID;
  5143. argument.Color = viewer.Effect[i].Color;
  5144. argument.Duration = viewer.Effect[i].Duration;
  5145. argument.ID = viewer.Effect[i].ID;
  5146. argument.Type = viewer.Effect[i].Type;
  5147. argument.TypeData = viewer.Effect[i].TypeData;
  5148. args.Add(argument);
  5149. }
  5150. handlerViewerEffect(sender, args);
  5151. }
  5152. return true;
  5153. }
  5154. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5155. {
  5156. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5157. #region Packet Session and User Check
  5158. if (m_checkPackets)
  5159. {
  5160. if (avatarProperties.AgentData.SessionID != SessionId ||
  5161. avatarProperties.AgentData.AgentID != AgentId)
  5162. return true;
  5163. }
  5164. #endregion
  5165. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5166. if (handlerRequestAvatarProperties != null)
  5167. {
  5168. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5169. }
  5170. return true;
  5171. }
  5172. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5173. {
  5174. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5175. #region Packet Session and User Check
  5176. if (m_checkPackets)
  5177. {
  5178. if (inchatpack.AgentData.SessionID != SessionId ||
  5179. inchatpack.AgentData.AgentID != AgentId)
  5180. return true;
  5181. }
  5182. #endregion
  5183. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5184. byte[] message = inchatpack.ChatData.Message;
  5185. byte type = inchatpack.ChatData.Type;
  5186. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5187. // UUID fromAgentID = AgentId;
  5188. int channel = inchatpack.ChatData.Channel;
  5189. if (OnChatFromClient != null)
  5190. {
  5191. OSChatMessage args = new OSChatMessage();
  5192. args.Channel = channel;
  5193. args.From = fromName;
  5194. args.Message = Utils.BytesToString(message);
  5195. args.Type = (ChatTypeEnum)type;
  5196. args.Position = fromPos;
  5197. args.Scene = Scene;
  5198. args.Sender = this;
  5199. args.SenderUUID = this.AgentId;
  5200. ChatMessage handlerChatFromClient = OnChatFromClient;
  5201. if (handlerChatFromClient != null)
  5202. handlerChatFromClient(this, args);
  5203. }
  5204. return true;
  5205. }
  5206. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5207. {
  5208. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5209. #region Packet Session and User Check
  5210. if (m_checkPackets)
  5211. {
  5212. if (avatarProps.AgentData.SessionID != SessionId ||
  5213. avatarProps.AgentData.AgentID != AgentId)
  5214. return true;
  5215. }
  5216. #endregion
  5217. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5218. if (handlerUpdateAvatarProperties != null)
  5219. {
  5220. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5221. UserProfileData UserProfile = new UserProfileData();
  5222. UserProfile.ID = AgentId;
  5223. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5224. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5225. UserProfile.FirstLifeImage = Properties.FLImageID;
  5226. UserProfile.Image = Properties.ImageID;
  5227. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5228. UserProfile.UserFlags &= ~3;
  5229. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5230. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5231. handlerUpdateAvatarProperties(this, UserProfile);
  5232. }
  5233. return true;
  5234. }
  5235. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5236. {
  5237. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5238. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5239. #region Packet Session and User Check
  5240. if (m_checkPackets)
  5241. {
  5242. if (rdialog.AgentData.SessionID != SessionId ||
  5243. rdialog.AgentData.AgentID != AgentId)
  5244. return true;
  5245. }
  5246. #endregion
  5247. int ch = rdialog.Data.ChatChannel;
  5248. byte[] msg = rdialog.Data.ButtonLabel;
  5249. if (OnChatFromClient != null)
  5250. {
  5251. OSChatMessage args = new OSChatMessage();
  5252. args.Channel = ch;
  5253. args.From = String.Empty;
  5254. args.Message = Utils.BytesToString(msg);
  5255. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5256. args.Position = new Vector3();
  5257. args.Scene = Scene;
  5258. args.Sender = this;
  5259. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5260. if (handlerChatFromClient2 != null)
  5261. handlerChatFromClient2(this, args);
  5262. }
  5263. return true;
  5264. }
  5265. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5266. {
  5267. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5268. #region Packet Session and User Check
  5269. if (m_checkPackets)
  5270. {
  5271. if (msgpack.AgentData.SessionID != SessionId ||
  5272. msgpack.AgentData.AgentID != AgentId)
  5273. return true;
  5274. }
  5275. #endregion
  5276. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5277. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5278. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5279. if (handlerInstantMessage != null)
  5280. {
  5281. GridInstantMessage im = new GridInstantMessage(Scene,
  5282. msgpack.AgentData.AgentID,
  5283. IMfromName,
  5284. msgpack.MessageBlock.ToAgentID,
  5285. msgpack.MessageBlock.Dialog,
  5286. msgpack.MessageBlock.FromGroup,
  5287. IMmessage,
  5288. msgpack.MessageBlock.ID,
  5289. msgpack.MessageBlock.Offline != 0 ? true : false,
  5290. msgpack.MessageBlock.Position,
  5291. msgpack.MessageBlock.BinaryBucket,
  5292. true);
  5293. handlerInstantMessage(this, im);
  5294. }
  5295. return true;
  5296. }
  5297. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5298. {
  5299. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5300. #region Packet Session and User Check
  5301. if (m_checkPackets)
  5302. {
  5303. if (afriendpack.AgentData.SessionID != SessionId ||
  5304. afriendpack.AgentData.AgentID != AgentId)
  5305. return true;
  5306. }
  5307. #endregion
  5308. // My guess is this is the folder to stick the calling card into
  5309. List<UUID> callingCardFolders = new List<UUID>();
  5310. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5311. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5312. {
  5313. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5314. }
  5315. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5316. if (handlerApproveFriendRequest != null)
  5317. {
  5318. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5319. }
  5320. return true;
  5321. }
  5322. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5323. {
  5324. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5325. #region Packet Session and User Check
  5326. if (m_checkPackets)
  5327. {
  5328. if (dfriendpack.AgentData.SessionID != SessionId ||
  5329. dfriendpack.AgentData.AgentID != AgentId)
  5330. return true;
  5331. }
  5332. #endregion
  5333. if (OnDenyFriendRequest != null)
  5334. {
  5335. OnDenyFriendRequest(this,
  5336. dfriendpack.TransactionBlock.TransactionID,
  5337. null);
  5338. }
  5339. return true;
  5340. }
  5341. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5342. {
  5343. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5344. #region Packet Session and User Check
  5345. if (m_checkPackets)
  5346. {
  5347. if (tfriendpack.AgentData.SessionID != SessionId ||
  5348. tfriendpack.AgentData.AgentID != AgentId)
  5349. return true;
  5350. }
  5351. #endregion
  5352. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5353. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5354. if (TerminateFriendshipHandler != null)
  5355. {
  5356. TerminateFriendshipHandler(this, exFriendID);
  5357. return true;
  5358. }
  5359. return false;
  5360. }
  5361. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5362. {
  5363. FindAgentPacket FindAgent =
  5364. (FindAgentPacket)Packet;
  5365. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5366. if (FindAgentHandler != null)
  5367. {
  5368. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5369. return true;
  5370. }
  5371. return false;
  5372. }
  5373. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5374. {
  5375. TrackAgentPacket TrackAgent =
  5376. (TrackAgentPacket)Packet;
  5377. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5378. if (TrackAgentHandler != null)
  5379. {
  5380. TrackAgentHandler(this,
  5381. TrackAgent.AgentData.AgentID,
  5382. TrackAgent.TargetData.PreyID);
  5383. return true;
  5384. }
  5385. return false;
  5386. }
  5387. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5388. {
  5389. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5390. #region Packet Session and User Check
  5391. if (m_checkPackets)
  5392. {
  5393. if (rezPacket.AgentData.SessionID != SessionId ||
  5394. rezPacket.AgentData.AgentID != AgentId)
  5395. return true;
  5396. }
  5397. #endregion
  5398. RezObject handlerRezObject = OnRezObject;
  5399. if (handlerRezObject != null)
  5400. {
  5401. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5402. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5403. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5404. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5405. rezPacket.RezData.FromTaskID);
  5406. }
  5407. return true;
  5408. }
  5409. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5410. {
  5411. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5412. #region Packet Session and User Check
  5413. if (m_checkPackets)
  5414. {
  5415. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5416. DeRezPacket.AgentData.AgentID != AgentId)
  5417. return true;
  5418. }
  5419. #endregion
  5420. DeRezObject handlerDeRezObject = OnDeRezObject;
  5421. if (handlerDeRezObject != null)
  5422. {
  5423. List<uint> deRezIDs = new List<uint>();
  5424. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5425. DeRezPacket.ObjectData)
  5426. {
  5427. deRezIDs.Add(data.ObjectLocalID);
  5428. }
  5429. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5430. // values given by a Second Life client
  5431. handlerDeRezObject(this, deRezIDs,
  5432. DeRezPacket.AgentBlock.GroupID,
  5433. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5434. DeRezPacket.AgentBlock.DestinationID);
  5435. }
  5436. return true;
  5437. }
  5438. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5439. {
  5440. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5441. #region Packet Session and User Check
  5442. if (m_checkPackets)
  5443. {
  5444. if (modify.AgentData.SessionID != SessionId ||
  5445. modify.AgentData.AgentID != AgentId)
  5446. return true;
  5447. }
  5448. #endregion
  5449. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5450. if (modify.ParcelData.Length > 0)
  5451. {
  5452. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5453. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5454. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5455. if (OnModifyTerrain != null)
  5456. {
  5457. for (int i = 0; i < modify.ParcelData.Length; i++)
  5458. {
  5459. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5460. if (handlerModifyTerrain != null)
  5461. {
  5462. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5463. modify.ModifyBlock.BrushSize,
  5464. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5465. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5466. modify.ParcelData[i].East, AgentId);
  5467. }
  5468. }
  5469. }
  5470. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5471. }
  5472. return true;
  5473. }
  5474. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5475. {
  5476. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5477. if (handlerRegionHandShakeReply != null)
  5478. {
  5479. handlerRegionHandShakeReply(this);
  5480. }
  5481. return true;
  5482. }
  5483. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5484. {
  5485. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5486. if (handlerRequestWearables != null)
  5487. {
  5488. handlerRequestWearables(sender);
  5489. }
  5490. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5491. if (handlerRequestAvatarsData != null)
  5492. {
  5493. handlerRequestAvatarsData(this);
  5494. }
  5495. return true;
  5496. }
  5497. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5498. {
  5499. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5500. #region Packet Session and User Check
  5501. if (m_checkPackets)
  5502. {
  5503. if (appear.AgentData.SessionID != SessionId ||
  5504. appear.AgentData.AgentID != AgentId)
  5505. return true;
  5506. }
  5507. #endregion
  5508. SetAppearance handlerSetAppearance = OnSetAppearance;
  5509. if (handlerSetAppearance != null)
  5510. {
  5511. // Temporarily protect ourselves from the mantis #951 failure.
  5512. // However, we could do this for several other handlers where a failure isn't terminal
  5513. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5514. Vector3 avSize = appear.AgentData.Size;
  5515. try
  5516. {
  5517. byte[] visualparams = new byte[appear.VisualParam.Length];
  5518. for (int i = 0; i < appear.VisualParam.Length; i++)
  5519. visualparams[i] = appear.VisualParam[i].ParamValue;
  5520. //var b = appear.WearableData[0];
  5521. Primitive.TextureEntry te = null;
  5522. if (appear.ObjectData.TextureEntry.Length > 1)
  5523. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5524. WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
  5525. for (int i=0; i<appear.WearableData.Length;i++)
  5526. cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)};
  5527. handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
  5528. }
  5529. catch (Exception e)
  5530. {
  5531. m_log.ErrorFormat(
  5532. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5533. e);
  5534. }
  5535. }
  5536. return true;
  5537. }
  5538. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5539. {
  5540. if (OnAvatarNowWearing != null)
  5541. {
  5542. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5543. #region Packet Session and User Check
  5544. if (m_checkPackets)
  5545. {
  5546. if (nowWearing.AgentData.SessionID != SessionId ||
  5547. nowWearing.AgentData.AgentID != AgentId)
  5548. return true;
  5549. }
  5550. #endregion
  5551. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5552. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5553. {
  5554. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5555. AvatarWearingArgs.Wearable wearable =
  5556. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5557. nowWearing.WearableData[i].WearableType);
  5558. wearingArgs.NowWearing.Add(wearable);
  5559. }
  5560. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5561. if (handlerAvatarNowWearing != null)
  5562. {
  5563. handlerAvatarNowWearing(this, wearingArgs);
  5564. }
  5565. }
  5566. return true;
  5567. }
  5568. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5569. {
  5570. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5571. if (handlerRezSingleAttachment != null)
  5572. {
  5573. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5574. #region Packet Session and User Check
  5575. if (m_checkPackets)
  5576. {
  5577. if (rez.AgentData.SessionID != SessionId ||
  5578. rez.AgentData.AgentID != AgentId)
  5579. return true;
  5580. }
  5581. #endregion
  5582. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5583. rez.ObjectData.AttachmentPt);
  5584. }
  5585. return true;
  5586. }
  5587. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5588. {
  5589. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5590. if (handlerRezMultipleAttachments != null)
  5591. {
  5592. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5593. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5594. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5595. handlerRezMultipleAttachments(this, rezlist);
  5596. }
  5597. return true;
  5598. }
  5599. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5600. {
  5601. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5602. if (handlerDetachAttachmentIntoInv != null)
  5603. {
  5604. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5605. #region Packet Session and User Check
  5606. // UNSUPPORTED ON THIS PACKET
  5607. #endregion
  5608. UUID itemID = detachtoInv.ObjectData.ItemID;
  5609. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5610. handlerDetachAttachmentIntoInv(itemID, this);
  5611. }
  5612. return true;
  5613. }
  5614. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5615. {
  5616. if (OnObjectAttach != null)
  5617. {
  5618. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5619. #region Packet Session and User Check
  5620. if (m_checkPackets)
  5621. {
  5622. if (att.AgentData.SessionID != SessionId ||
  5623. att.AgentData.AgentID != AgentId)
  5624. return true;
  5625. }
  5626. #endregion
  5627. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5628. if (handlerObjectAttach != null)
  5629. {
  5630. if (att.ObjectData.Length > 0)
  5631. {
  5632. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5633. }
  5634. }
  5635. }
  5636. return true;
  5637. }
  5638. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5639. {
  5640. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5641. #region Packet Session and User Check
  5642. if (m_checkPackets)
  5643. {
  5644. if (dett.AgentData.SessionID != SessionId ||
  5645. dett.AgentData.AgentID != AgentId)
  5646. return true;
  5647. }
  5648. #endregion
  5649. for (int j = 0; j < dett.ObjectData.Length; j++)
  5650. {
  5651. uint obj = dett.ObjectData[j].ObjectLocalID;
  5652. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5653. if (handlerObjectDetach != null)
  5654. {
  5655. handlerObjectDetach(obj, this);
  5656. }
  5657. }
  5658. return true;
  5659. }
  5660. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5661. {
  5662. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5663. #region Packet Session and User Check
  5664. if (m_checkPackets)
  5665. {
  5666. if (dropp.AgentData.SessionID != SessionId ||
  5667. dropp.AgentData.AgentID != AgentId)
  5668. return true;
  5669. }
  5670. #endregion
  5671. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5672. {
  5673. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5674. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5675. if (handlerObjectDrop != null)
  5676. {
  5677. handlerObjectDrop(obj, this);
  5678. }
  5679. }
  5680. return true;
  5681. }
  5682. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5683. {
  5684. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5685. #region Packet Session and User Check
  5686. if (m_checkPackets)
  5687. {
  5688. if (run.AgentData.SessionID != SessionId ||
  5689. run.AgentData.AgentID != AgentId)
  5690. return true;
  5691. }
  5692. #endregion
  5693. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5694. if (handlerSetAlwaysRun != null)
  5695. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5696. return true;
  5697. }
  5698. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5699. {
  5700. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5701. if (handlerCompleteMovementToRegion != null)
  5702. {
  5703. handlerCompleteMovementToRegion(sender, true);
  5704. }
  5705. handlerCompleteMovementToRegion = null;
  5706. return true;
  5707. }
  5708. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5709. {
  5710. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5711. #region Packet Session and User Check
  5712. if (m_checkPackets)
  5713. {
  5714. if (AgentAni.AgentData.SessionID != SessionId ||
  5715. AgentAni.AgentData.AgentID != AgentId)
  5716. return true;
  5717. }
  5718. #endregion
  5719. StartAnim handlerStartAnim = null;
  5720. StopAnim handlerStopAnim = null;
  5721. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5722. {
  5723. if (AgentAni.AnimationList[i].StartAnim)
  5724. {
  5725. handlerStartAnim = OnStartAnim;
  5726. if (handlerStartAnim != null)
  5727. {
  5728. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5729. }
  5730. }
  5731. else
  5732. {
  5733. handlerStopAnim = OnStopAnim;
  5734. if (handlerStopAnim != null)
  5735. {
  5736. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5737. }
  5738. }
  5739. }
  5740. return true;
  5741. }
  5742. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5743. {
  5744. if (OnAgentRequestSit != null)
  5745. {
  5746. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5747. #region Packet Session and User Check
  5748. if (m_checkPackets)
  5749. {
  5750. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5751. agentRequestSit.AgentData.AgentID != AgentId)
  5752. return true;
  5753. }
  5754. #endregion
  5755. if (SceneAgent.IsChildAgent)
  5756. {
  5757. SendCantSitBecauseChildAgentResponse();
  5758. return true;
  5759. }
  5760. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5761. if (handlerAgentRequestSit != null)
  5762. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5763. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5764. }
  5765. return true;
  5766. }
  5767. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5768. {
  5769. if (OnAgentSit != null)
  5770. {
  5771. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5772. #region Packet Session and User Check
  5773. if (m_checkPackets)
  5774. {
  5775. if (agentSit.AgentData.SessionID != SessionId ||
  5776. agentSit.AgentData.AgentID != AgentId)
  5777. return true;
  5778. }
  5779. #endregion
  5780. if (SceneAgent.IsChildAgent)
  5781. {
  5782. SendCantSitBecauseChildAgentResponse();
  5783. return true;
  5784. }
  5785. AgentSit handlerAgentSit = OnAgentSit;
  5786. if (handlerAgentSit != null)
  5787. {
  5788. OnAgentSit(this, agentSit.AgentData.AgentID);
  5789. }
  5790. }
  5791. return true;
  5792. }
  5793. /// <summary>
  5794. /// Used when a child agent gets a sit response which should not be fulfilled.
  5795. /// </summary>
  5796. private void SendCantSitBecauseChildAgentResponse()
  5797. {
  5798. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5799. }
  5800. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5801. {
  5802. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5803. #region Packet Session and User Check
  5804. if (m_checkPackets)
  5805. {
  5806. // UNSUPPORTED ON THIS PACKET
  5807. }
  5808. #endregion
  5809. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5810. if (handlerSoundTrigger != null)
  5811. {
  5812. // UUIDS are sent as zeroes by the client, substitute agent's id
  5813. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5814. AgentId, AgentId,
  5815. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5816. soundTriggerPacket.SoundData.Handle, 0);
  5817. }
  5818. return true;
  5819. }
  5820. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5821. {
  5822. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5823. #region Packet Session and User Check
  5824. if (m_checkPackets)
  5825. {
  5826. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5827. avRequestQuery.AgentData.AgentID != AgentId)
  5828. return true;
  5829. }
  5830. #endregion
  5831. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5832. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5833. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5834. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5835. if (handlerAvatarPickerRequest != null)
  5836. {
  5837. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5838. Utils.BytesToString(querydata.Name));
  5839. }
  5840. return true;
  5841. }
  5842. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5843. {
  5844. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5845. #region Packet Session and User Check
  5846. if (m_checkPackets)
  5847. {
  5848. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5849. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5850. return true;
  5851. }
  5852. #endregion
  5853. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5854. if (handlerAgentDataUpdateRequest != null)
  5855. {
  5856. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5857. }
  5858. return true;
  5859. }
  5860. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5861. {
  5862. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5863. if (handlerUserInfoRequest != null)
  5864. {
  5865. handlerUserInfoRequest(this);
  5866. }
  5867. else
  5868. {
  5869. SendUserInfoReply(false, true, "");
  5870. }
  5871. return true;
  5872. }
  5873. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5874. {
  5875. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5876. #region Packet Session and User Check
  5877. if (m_checkPackets)
  5878. {
  5879. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5880. updateUserInfo.AgentData.AgentID != AgentId)
  5881. return true;
  5882. }
  5883. #endregion
  5884. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5885. if (handlerUpdateUserInfo != null)
  5886. {
  5887. bool visible = true;
  5888. string DirectoryVisibility =
  5889. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5890. if (DirectoryVisibility == "hidden")
  5891. visible = false;
  5892. handlerUpdateUserInfo(
  5893. updateUserInfo.UserData.IMViaEMail,
  5894. visible, this);
  5895. }
  5896. return true;
  5897. }
  5898. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5899. {
  5900. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5901. #region Packet Session and User Check
  5902. if (m_checkPackets)
  5903. {
  5904. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5905. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5906. return true;
  5907. }
  5908. #endregion
  5909. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5910. {
  5911. // Linden Client limitation..
  5912. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5913. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5914. {
  5915. ScenePresence avatar = null;
  5916. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5917. {
  5918. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5919. {
  5920. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5921. }
  5922. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5923. {
  5924. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5925. }
  5926. }
  5927. }
  5928. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5929. if (handlerSetStartLocationRequest != null)
  5930. {
  5931. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5932. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5933. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5934. }
  5935. }
  5936. return true;
  5937. }
  5938. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5939. {
  5940. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5941. #region Packet Session and User Check
  5942. if (m_checkPackets)
  5943. {
  5944. if (atpack.AgentData.SessionID != SessionId ||
  5945. atpack.AgentData.AgentID != AgentId)
  5946. return true;
  5947. }
  5948. #endregion
  5949. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5950. return true;
  5951. }
  5952. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5953. {
  5954. m_udpClient.IsPaused = true;
  5955. return true;
  5956. }
  5957. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5958. {
  5959. m_udpClient.IsPaused = false;
  5960. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5961. return true;
  5962. }
  5963. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5964. {
  5965. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5966. if (handlerForceReleaseControls != null)
  5967. {
  5968. handlerForceReleaseControls(this, AgentId);
  5969. }
  5970. return true;
  5971. }
  5972. #endregion Scene/Avatar
  5973. #region Objects/m_sceneObjects
  5974. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5975. {
  5976. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5977. #region Packet Session and User Check
  5978. if (m_checkPackets)
  5979. {
  5980. if (link.AgentData.SessionID != SessionId ||
  5981. link.AgentData.AgentID != AgentId)
  5982. return true;
  5983. }
  5984. #endregion
  5985. uint parentprimid = 0;
  5986. List<uint> childrenprims = new List<uint>();
  5987. if (link.ObjectData.Length > 1)
  5988. {
  5989. parentprimid = link.ObjectData[0].ObjectLocalID;
  5990. for (int i = 1; i < link.ObjectData.Length; i++)
  5991. {
  5992. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5993. }
  5994. }
  5995. LinkObjects handlerLinkObjects = OnLinkObjects;
  5996. if (handlerLinkObjects != null)
  5997. {
  5998. handlerLinkObjects(this, parentprimid, childrenprims);
  5999. }
  6000. return true;
  6001. }
  6002. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  6003. {
  6004. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6005. #region Packet Session and User Check
  6006. if (m_checkPackets)
  6007. {
  6008. if (delink.AgentData.SessionID != SessionId ||
  6009. delink.AgentData.AgentID != AgentId)
  6010. return true;
  6011. }
  6012. #endregion
  6013. // It appears the prim at index 0 is not always the root prim (for
  6014. // instance, when one prim of a link set has been edited independently
  6015. // of the others). Therefore, we'll pass all the ids onto the delink
  6016. // method for it to decide which is the root.
  6017. List<uint> prims = new List<uint>();
  6018. for (int i = 0; i < delink.ObjectData.Length; i++)
  6019. {
  6020. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6021. }
  6022. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6023. if (handlerDelinkObjects != null)
  6024. {
  6025. handlerDelinkObjects(prims, this);
  6026. }
  6027. return true;
  6028. }
  6029. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6030. {
  6031. if (OnAddPrim != null)
  6032. {
  6033. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6034. #region Packet Session and User Check
  6035. if (m_checkPackets)
  6036. {
  6037. if (addPacket.AgentData.SessionID != SessionId ||
  6038. addPacket.AgentData.AgentID != AgentId)
  6039. return true;
  6040. }
  6041. #endregion
  6042. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6043. // m_log.Info("[REZData]: " + addPacket.ToString());
  6044. //BypassRaycast: 1
  6045. //RayStart: <69.79469, 158.2652, 98.40343>
  6046. //RayEnd: <61.97724, 141.995, 92.58341>
  6047. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6048. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6049. //object from rezing initially
  6050. AddNewPrim handlerAddPrim = OnAddPrim;
  6051. if (handlerAddPrim != null)
  6052. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6053. }
  6054. return true;
  6055. }
  6056. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6057. {
  6058. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6059. #region Packet Session and User Check
  6060. if (m_checkPackets)
  6061. {
  6062. if (shapePacket.AgentData.SessionID != SessionId ||
  6063. shapePacket.AgentData.AgentID != AgentId)
  6064. return true;
  6065. }
  6066. #endregion
  6067. UpdateShape handlerUpdatePrimShape = null;
  6068. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6069. {
  6070. handlerUpdatePrimShape = OnUpdatePrimShape;
  6071. if (handlerUpdatePrimShape != null)
  6072. {
  6073. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6074. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6075. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6076. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6077. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6078. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6079. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6080. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6081. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6082. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6083. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6084. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6085. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6086. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6087. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6088. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6089. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6090. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6091. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6092. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6093. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6094. shapeData);
  6095. }
  6096. }
  6097. return true;
  6098. }
  6099. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6100. {
  6101. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6102. #region Packet Session and User Check
  6103. if (m_checkPackets)
  6104. {
  6105. if (extraPar.AgentData.SessionID != SessionId ||
  6106. extraPar.AgentData.AgentID != AgentId)
  6107. return true;
  6108. }
  6109. #endregion
  6110. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6111. if (handlerUpdateExtraParams != null)
  6112. {
  6113. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6114. {
  6115. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6116. extraPar.ObjectData[i].ParamType,
  6117. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6118. }
  6119. }
  6120. return true;
  6121. }
  6122. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6123. {
  6124. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6125. #region Packet Session and User Check
  6126. if (m_checkPackets)
  6127. {
  6128. if (dupe.AgentData.SessionID != SessionId ||
  6129. dupe.AgentData.AgentID != AgentId)
  6130. return true;
  6131. }
  6132. #endregion
  6133. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6134. ObjectDuplicate handlerObjectDuplicate = null;
  6135. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6136. {
  6137. handlerObjectDuplicate = OnObjectDuplicate;
  6138. if (handlerObjectDuplicate != null)
  6139. {
  6140. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6141. dupe.SharedData.DuplicateFlags, AgentId,
  6142. m_activeGroupID);
  6143. }
  6144. }
  6145. return true;
  6146. }
  6147. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6148. {
  6149. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6150. #region Packet Session and User Check
  6151. if (m_checkPackets)
  6152. {
  6153. if (incomingRequest.AgentData.SessionID != SessionId ||
  6154. incomingRequest.AgentData.AgentID != AgentId)
  6155. return true;
  6156. }
  6157. #endregion
  6158. ObjectRequest handlerObjectRequest = null;
  6159. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6160. {
  6161. handlerObjectRequest = OnObjectRequest;
  6162. if (handlerObjectRequest != null)
  6163. {
  6164. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6165. }
  6166. }
  6167. return true;
  6168. }
  6169. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6170. {
  6171. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6172. #region Packet Session and User Check
  6173. if (m_checkPackets)
  6174. {
  6175. if (incomingselect.AgentData.SessionID != SessionId ||
  6176. incomingselect.AgentData.AgentID != AgentId)
  6177. return true;
  6178. }
  6179. #endregion
  6180. ObjectSelect handlerObjectSelect = null;
  6181. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6182. {
  6183. handlerObjectSelect = OnObjectSelect;
  6184. if (handlerObjectSelect != null)
  6185. {
  6186. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6187. }
  6188. }
  6189. return true;
  6190. }
  6191. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6192. {
  6193. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6194. #region Packet Session and User Check
  6195. if (m_checkPackets)
  6196. {
  6197. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6198. incomingdeselect.AgentData.AgentID != AgentId)
  6199. return true;
  6200. }
  6201. #endregion
  6202. ObjectDeselect handlerObjectDeselect = null;
  6203. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6204. {
  6205. handlerObjectDeselect = OnObjectDeselect;
  6206. if (handlerObjectDeselect != null)
  6207. {
  6208. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6209. }
  6210. }
  6211. return true;
  6212. }
  6213. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6214. {
  6215. // DEPRECATED: but till libsecondlife removes it, people will use it
  6216. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6217. #region Packet Session and User Check
  6218. if (m_checkPackets)
  6219. {
  6220. if (position.AgentData.SessionID != SessionId ||
  6221. position.AgentData.AgentID != AgentId)
  6222. return true;
  6223. }
  6224. #endregion
  6225. for (int i = 0; i < position.ObjectData.Length; i++)
  6226. {
  6227. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6228. if (handlerUpdateVector != null)
  6229. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6230. }
  6231. return true;
  6232. }
  6233. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6234. {
  6235. // DEPRECATED: but till libsecondlife removes it, people will use it
  6236. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6237. #region Packet Session and User Check
  6238. if (m_checkPackets)
  6239. {
  6240. if (scale.AgentData.SessionID != SessionId ||
  6241. scale.AgentData.AgentID != AgentId)
  6242. return true;
  6243. }
  6244. #endregion
  6245. for (int i = 0; i < scale.ObjectData.Length; i++)
  6246. {
  6247. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6248. if (handlerUpdatePrimGroupScale != null)
  6249. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6250. }
  6251. return true;
  6252. }
  6253. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6254. {
  6255. // DEPRECATED: but till libsecondlife removes it, people will use it
  6256. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6257. #region Packet Session and User Check
  6258. if (m_checkPackets)
  6259. {
  6260. if (rotation.AgentData.SessionID != SessionId ||
  6261. rotation.AgentData.AgentID != AgentId)
  6262. return true;
  6263. }
  6264. #endregion
  6265. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6266. {
  6267. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6268. if (handlerUpdatePrimRotation != null)
  6269. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6270. }
  6271. return true;
  6272. }
  6273. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6274. {
  6275. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6276. #region Packet Session and User Check
  6277. if (m_checkPackets)
  6278. {
  6279. if (flags.AgentData.SessionID != SessionId ||
  6280. flags.AgentData.AgentID != AgentId)
  6281. return true;
  6282. }
  6283. #endregion
  6284. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6285. if (handlerUpdatePrimFlags != null)
  6286. {
  6287. // byte[] data = Pack.ToBytes();
  6288. // 46,47,48 are special positions within the packet
  6289. // This may change so perhaps we need a better way
  6290. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6291. /*
  6292. bool UsePhysics = (data[46] != 0) ? true : false;
  6293. bool IsTemporary = (data[47] != 0) ? true : false;
  6294. bool IsPhantom = (data[48] != 0) ? true : false;
  6295. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6296. */
  6297. bool UsePhysics = flags.AgentData.UsePhysics;
  6298. bool IsPhantom = flags.AgentData.IsPhantom;
  6299. bool IsTemporary = flags.AgentData.IsTemporary;
  6300. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6301. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6302. if (blocks == null || blocks.Length == 0)
  6303. {
  6304. physdata.PhysShapeType = PhysShapeType.invalid;
  6305. }
  6306. else
  6307. {
  6308. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6309. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6310. physdata.Bounce = phsblock.Restitution;
  6311. physdata.Density = phsblock.Density;
  6312. physdata.Friction = phsblock.Friction;
  6313. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6314. }
  6315. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6316. }
  6317. return true;
  6318. }
  6319. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6320. {
  6321. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6322. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6323. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6324. {
  6325. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6326. if (handlerUpdatePrimTexture != null)
  6327. {
  6328. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6329. imagePack.ObjectData[i].TextureEntry, this);
  6330. }
  6331. }
  6332. return true;
  6333. }
  6334. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6335. {
  6336. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6337. #region Packet Session and User Check
  6338. if (m_checkPackets)
  6339. {
  6340. if (grab.AgentData.SessionID != SessionId ||
  6341. grab.AgentData.AgentID != AgentId)
  6342. return true;
  6343. }
  6344. #endregion
  6345. GrabObject handlerGrabObject = OnGrabObject;
  6346. if (handlerGrabObject != null)
  6347. {
  6348. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6349. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6350. {
  6351. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6352. {
  6353. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6354. arg.Binormal = surfaceInfo.Binormal;
  6355. arg.FaceIndex = surfaceInfo.FaceIndex;
  6356. arg.Normal = surfaceInfo.Normal;
  6357. arg.Position = surfaceInfo.Position;
  6358. arg.STCoord = surfaceInfo.STCoord;
  6359. arg.UVCoord = surfaceInfo.UVCoord;
  6360. touchArgs.Add(arg);
  6361. }
  6362. }
  6363. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6364. }
  6365. return true;
  6366. }
  6367. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6368. {
  6369. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6370. #region Packet Session and User Check
  6371. if (m_checkPackets)
  6372. {
  6373. if (grabUpdate.AgentData.SessionID != SessionId ||
  6374. grabUpdate.AgentData.AgentID != AgentId)
  6375. return true;
  6376. }
  6377. #endregion
  6378. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6379. if (handlerGrabUpdate != null)
  6380. {
  6381. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6382. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6383. {
  6384. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6385. {
  6386. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6387. arg.Binormal = surfaceInfo.Binormal;
  6388. arg.FaceIndex = surfaceInfo.FaceIndex;
  6389. arg.Normal = surfaceInfo.Normal;
  6390. arg.Position = surfaceInfo.Position;
  6391. arg.STCoord = surfaceInfo.STCoord;
  6392. arg.UVCoord = surfaceInfo.UVCoord;
  6393. touchArgs.Add(arg);
  6394. }
  6395. }
  6396. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6397. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6398. }
  6399. return true;
  6400. }
  6401. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6402. {
  6403. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6404. #region Packet Session and User Check
  6405. if (m_checkPackets)
  6406. {
  6407. if (deGrab.AgentData.SessionID != SessionId ||
  6408. deGrab.AgentData.AgentID != AgentId)
  6409. return true;
  6410. }
  6411. #endregion
  6412. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6413. if (handlerDeGrabObject != null)
  6414. {
  6415. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6416. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6417. {
  6418. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6419. {
  6420. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6421. arg.Binormal = surfaceInfo.Binormal;
  6422. arg.FaceIndex = surfaceInfo.FaceIndex;
  6423. arg.Normal = surfaceInfo.Normal;
  6424. arg.Position = surfaceInfo.Position;
  6425. arg.STCoord = surfaceInfo.STCoord;
  6426. arg.UVCoord = surfaceInfo.UVCoord;
  6427. touchArgs.Add(arg);
  6428. }
  6429. }
  6430. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6431. }
  6432. return true;
  6433. }
  6434. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6435. {
  6436. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6437. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6438. #region Packet Session and User Check
  6439. if (m_checkPackets)
  6440. {
  6441. if (spinStart.AgentData.SessionID != SessionId ||
  6442. spinStart.AgentData.AgentID != AgentId)
  6443. return true;
  6444. }
  6445. #endregion
  6446. SpinStart handlerSpinStart = OnSpinStart;
  6447. if (handlerSpinStart != null)
  6448. {
  6449. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6450. }
  6451. return true;
  6452. }
  6453. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6454. {
  6455. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6456. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6457. #region Packet Session and User Check
  6458. if (m_checkPackets)
  6459. {
  6460. if (spinUpdate.AgentData.SessionID != SessionId ||
  6461. spinUpdate.AgentData.AgentID != AgentId)
  6462. return true;
  6463. }
  6464. #endregion
  6465. Vector3 axis;
  6466. float angle;
  6467. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6468. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6469. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6470. if (handlerSpinUpdate != null)
  6471. {
  6472. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6473. }
  6474. return true;
  6475. }
  6476. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6477. {
  6478. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6479. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6480. #region Packet Session and User Check
  6481. if (m_checkPackets)
  6482. {
  6483. if (spinStop.AgentData.SessionID != SessionId ||
  6484. spinStop.AgentData.AgentID != AgentId)
  6485. return true;
  6486. }
  6487. #endregion
  6488. SpinStop handlerSpinStop = OnSpinStop;
  6489. if (handlerSpinStop != null)
  6490. {
  6491. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6492. }
  6493. return true;
  6494. }
  6495. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6496. {
  6497. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6498. #region Packet Session and User Check
  6499. if (m_checkPackets)
  6500. {
  6501. if (objDes.AgentData.SessionID != SessionId ||
  6502. objDes.AgentData.AgentID != AgentId)
  6503. return true;
  6504. }
  6505. #endregion
  6506. GenericCall7 handlerObjectDescription = null;
  6507. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6508. {
  6509. handlerObjectDescription = OnObjectDescription;
  6510. if (handlerObjectDescription != null)
  6511. {
  6512. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6513. Util.FieldToString(objDes.ObjectData[i].Description));
  6514. }
  6515. }
  6516. return true;
  6517. }
  6518. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6519. {
  6520. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6521. #region Packet Session and User Check
  6522. if (m_checkPackets)
  6523. {
  6524. if (objName.AgentData.SessionID != SessionId ||
  6525. objName.AgentData.AgentID != AgentId)
  6526. return true;
  6527. }
  6528. #endregion
  6529. GenericCall7 handlerObjectName = null;
  6530. for (int i = 0; i < objName.ObjectData.Length; i++)
  6531. {
  6532. handlerObjectName = OnObjectName;
  6533. if (handlerObjectName != null)
  6534. {
  6535. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6536. Util.FieldToString(objName.ObjectData[i].Name));
  6537. }
  6538. }
  6539. return true;
  6540. }
  6541. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6542. {
  6543. if (OnObjectPermissions != null)
  6544. {
  6545. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6546. #region Packet Session and User Check
  6547. if (m_checkPackets)
  6548. {
  6549. if (newobjPerms.AgentData.SessionID != SessionId ||
  6550. newobjPerms.AgentData.AgentID != AgentId)
  6551. return true;
  6552. }
  6553. #endregion
  6554. UUID AgentID = newobjPerms.AgentData.AgentID;
  6555. UUID SessionID = newobjPerms.AgentData.SessionID;
  6556. ObjectPermissions handlerObjectPermissions = null;
  6557. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6558. {
  6559. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6560. byte field = permChanges.Field;
  6561. uint localID = permChanges.ObjectLocalID;
  6562. uint mask = permChanges.Mask;
  6563. byte set = permChanges.Set;
  6564. handlerObjectPermissions = OnObjectPermissions;
  6565. if (handlerObjectPermissions != null)
  6566. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6567. }
  6568. }
  6569. // Here's our data,
  6570. // PermField contains the field the info goes into
  6571. // PermField determines which mask we're changing
  6572. //
  6573. // chmask is the mask of the change
  6574. // setTF is whether we're adding it or taking it away
  6575. //
  6576. // objLocalID is the localID of the object.
  6577. // Unfortunately, we have to pass the event the packet because objData is an array
  6578. // That means multiple object perms may be updated in a single packet.
  6579. return true;
  6580. }
  6581. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6582. {
  6583. UndoPacket undoitem = (UndoPacket)Pack;
  6584. #region Packet Session and User Check
  6585. if (m_checkPackets)
  6586. {
  6587. if (undoitem.AgentData.SessionID != SessionId ||
  6588. undoitem.AgentData.AgentID != AgentId)
  6589. return true;
  6590. }
  6591. #endregion
  6592. if (undoitem.ObjectData.Length > 0)
  6593. {
  6594. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6595. {
  6596. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6597. AgentSit handlerOnUndo = OnUndo;
  6598. if (handlerOnUndo != null)
  6599. {
  6600. handlerOnUndo(this, objiD);
  6601. }
  6602. }
  6603. }
  6604. return true;
  6605. }
  6606. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6607. {
  6608. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6609. #region Packet Session and User Check
  6610. if (m_checkPackets)
  6611. {
  6612. if (undolanditem.AgentData.SessionID != SessionId ||
  6613. undolanditem.AgentData.AgentID != AgentId)
  6614. return true;
  6615. }
  6616. #endregion
  6617. LandUndo handlerOnUndo = OnLandUndo;
  6618. if (handlerOnUndo != null)
  6619. {
  6620. handlerOnUndo(this);
  6621. }
  6622. return true;
  6623. }
  6624. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6625. {
  6626. RedoPacket redoitem = (RedoPacket)Pack;
  6627. #region Packet Session and User Check
  6628. if (m_checkPackets)
  6629. {
  6630. if (redoitem.AgentData.SessionID != SessionId ||
  6631. redoitem.AgentData.AgentID != AgentId)
  6632. return true;
  6633. }
  6634. #endregion
  6635. if (redoitem.ObjectData.Length > 0)
  6636. {
  6637. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6638. {
  6639. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6640. AgentSit handlerOnRedo = OnRedo;
  6641. if (handlerOnRedo != null)
  6642. {
  6643. handlerOnRedo(this, objiD);
  6644. }
  6645. }
  6646. }
  6647. return true;
  6648. }
  6649. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6650. {
  6651. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6652. #region Packet Session and User Check
  6653. if (m_checkPackets)
  6654. {
  6655. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6656. dupeOnRay.AgentData.AgentID != AgentId)
  6657. return true;
  6658. }
  6659. #endregion
  6660. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6661. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6662. {
  6663. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6664. if (handlerObjectDuplicateOnRay != null)
  6665. {
  6666. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6667. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6668. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6669. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6670. }
  6671. }
  6672. return true;
  6673. }
  6674. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6675. {
  6676. //This powers the little tooltip that appears when you move your mouse over an object
  6677. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6678. #region Packet Session and User Check
  6679. if (m_checkPackets)
  6680. {
  6681. if (packToolTip.AgentData.SessionID != SessionId ||
  6682. packToolTip.AgentData.AgentID != AgentId)
  6683. return true;
  6684. }
  6685. #endregion
  6686. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6687. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6688. if (handlerRequestObjectPropertiesFamily != null)
  6689. {
  6690. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6691. packObjBlock.ObjectID);
  6692. }
  6693. return true;
  6694. }
  6695. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6696. {
  6697. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6698. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6699. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6700. #region Packet Session and User Check
  6701. if (m_checkPackets)
  6702. {
  6703. if (packInSearch.AgentData.SessionID != SessionId ||
  6704. packInSearch.AgentData.AgentID != AgentId)
  6705. return true;
  6706. }
  6707. #endregion
  6708. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6709. {
  6710. bool inSearch = objData.IncludeInSearch;
  6711. uint localID = objData.ObjectLocalID;
  6712. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6713. if (handlerObjectIncludeInSearch != null)
  6714. {
  6715. handlerObjectIncludeInSearch(this, inSearch, localID);
  6716. }
  6717. }
  6718. return true;
  6719. }
  6720. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6721. {
  6722. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6723. #region Packet Session and User Check
  6724. if (m_checkPackets)
  6725. {
  6726. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6727. scriptAnswer.AgentData.AgentID != AgentId)
  6728. return true;
  6729. }
  6730. #endregion
  6731. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6732. if (handlerScriptAnswer != null)
  6733. {
  6734. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6735. }
  6736. return true;
  6737. }
  6738. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6739. {
  6740. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6741. #region Packet Session and User Check
  6742. if (m_checkPackets)
  6743. {
  6744. if (ocpacket.AgentData.SessionID != SessionId ||
  6745. ocpacket.AgentData.AgentID != AgentId)
  6746. return true;
  6747. }
  6748. #endregion
  6749. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6750. if (handlerObjectClickAction != null)
  6751. {
  6752. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6753. {
  6754. byte action = odata.ClickAction;
  6755. uint localID = odata.ObjectLocalID;
  6756. handlerObjectClickAction(this, localID, action.ToString());
  6757. }
  6758. }
  6759. return true;
  6760. }
  6761. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6762. {
  6763. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6764. #region Packet Session and User Check
  6765. if (m_checkPackets)
  6766. {
  6767. if (ompacket.AgentData.SessionID != SessionId ||
  6768. ompacket.AgentData.AgentID != AgentId)
  6769. return true;
  6770. }
  6771. #endregion
  6772. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6773. if (handlerObjectMaterial != null)
  6774. {
  6775. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6776. {
  6777. byte material = odata.Material;
  6778. uint localID = odata.ObjectLocalID;
  6779. handlerObjectMaterial(this, localID, material.ToString());
  6780. }
  6781. }
  6782. return true;
  6783. }
  6784. #endregion Objects/m_sceneObjects
  6785. #region Inventory/Asset/Other related packets
  6786. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6787. {
  6788. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6789. //m_log.Debug("image request: " + Pack.ToString());
  6790. #region Packet Session and User Check
  6791. if (m_checkPackets)
  6792. {
  6793. if (imageRequest.AgentData.SessionID != SessionId ||
  6794. imageRequest.AgentData.AgentID != AgentId)
  6795. return true;
  6796. }
  6797. #endregion
  6798. //handlerTextureRequest = null;
  6799. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6800. {
  6801. TextureRequestArgs args = new TextureRequestArgs();
  6802. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6803. args.RequestedAssetID = block.Image;
  6804. args.DiscardLevel = block.DiscardLevel;
  6805. args.PacketNumber = block.Packet;
  6806. args.Priority = block.DownloadPriority;
  6807. args.requestSequence = imageRequest.Header.Sequence;
  6808. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6809. // priority of avatar textures to get avatars rezzing in faster than the
  6810. // surrounding scene
  6811. if ((ImageType)block.Type == ImageType.Baked)
  6812. args.Priority *= 2.0f;
  6813. ImageManager.EnqueueReq(args);
  6814. }
  6815. return true;
  6816. }
  6817. /// <summary>
  6818. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6819. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6820. /// </summary>
  6821. /// <param name="sender"></param>
  6822. /// <param name="Pack"></param>
  6823. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6824. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6825. {
  6826. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6827. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6828. UUID taskID = UUID.Zero;
  6829. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6830. {
  6831. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6832. {
  6833. // We're spawning a thread because the permissions check can block this thread
  6834. Util.FireAndForget(delegate
  6835. {
  6836. // This requests the asset if needed
  6837. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6838. });
  6839. return true;
  6840. }
  6841. }
  6842. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6843. {
  6844. //TransferRequestPacket does not include covenant uuid?
  6845. //get scene covenant uuid
  6846. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6847. }
  6848. // This is non-blocking
  6849. MakeAssetRequest(transfer, taskID);
  6850. return true;
  6851. }
  6852. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6853. {
  6854. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6855. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6856. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6857. //m_log.DebugFormat(
  6858. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6859. // requestID, itemID, taskID, Name);
  6860. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6861. // Validate inventory transfers
  6862. // Has to be done here, because AssetCache can't do it
  6863. //
  6864. if (taskID != UUID.Zero) // Prim
  6865. {
  6866. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6867. if (part == null)
  6868. {
  6869. m_log.WarnFormat(
  6870. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6871. Name, requestID, itemID, taskID);
  6872. return;
  6873. }
  6874. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6875. if (tii == null)
  6876. {
  6877. m_log.WarnFormat(
  6878. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6879. Name, requestID, itemID, taskID);
  6880. return;
  6881. }
  6882. if (tii.Type == (int)AssetType.LSLText)
  6883. {
  6884. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6885. return;
  6886. }
  6887. else if (tii.Type == (int)AssetType.Notecard)
  6888. {
  6889. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6890. return;
  6891. }
  6892. else
  6893. {
  6894. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6895. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6896. if (part.OwnerID != AgentId)
  6897. {
  6898. m_log.WarnFormat(
  6899. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6900. Name, requestID, itemID, taskID, part.OwnerID);
  6901. return;
  6902. }
  6903. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6904. {
  6905. m_log.WarnFormat(
  6906. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6907. Name, requestID, itemID, taskID);
  6908. return;
  6909. }
  6910. if (tii.OwnerID != AgentId)
  6911. {
  6912. m_log.WarnFormat(
  6913. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6914. Name, requestID, itemID, taskID, tii.OwnerID);
  6915. return;
  6916. }
  6917. if ((
  6918. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6919. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6920. {
  6921. m_log.WarnFormat(
  6922. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6923. Name, requestID, itemID, taskID);
  6924. return;
  6925. }
  6926. if (tii.AssetID != requestID)
  6927. {
  6928. m_log.WarnFormat(
  6929. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6930. Name, requestID, itemID, taskID, tii.AssetID);
  6931. return;
  6932. }
  6933. }
  6934. }
  6935. else // Agent
  6936. {
  6937. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6938. if (invAccess != null)
  6939. {
  6940. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6941. return;
  6942. }
  6943. else
  6944. {
  6945. return;
  6946. }
  6947. }
  6948. // Permissions out of the way, let's request the asset
  6949. MakeAssetRequest(transfer, taskID);
  6950. }
  6951. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6952. {
  6953. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6954. // m_log.Debug("upload request " + request.ToString());
  6955. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6956. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6957. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6958. if (handlerAssetUploadRequest != null)
  6959. {
  6960. handlerAssetUploadRequest(this, temp,
  6961. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6962. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6963. request.AssetBlock.Tempfile);
  6964. }
  6965. return true;
  6966. }
  6967. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6968. {
  6969. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6970. RequestXfer handlerRequestXfer = OnRequestXfer;
  6971. if (handlerRequestXfer != null)
  6972. {
  6973. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6974. }
  6975. return true;
  6976. }
  6977. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6978. {
  6979. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6980. XferReceive handlerXferReceive = OnXferReceive;
  6981. if (handlerXferReceive != null)
  6982. {
  6983. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6984. }
  6985. return true;
  6986. }
  6987. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6988. {
  6989. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6990. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6991. if (handlerConfirmXfer != null)
  6992. {
  6993. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6994. }
  6995. return true;
  6996. }
  6997. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6998. {
  6999. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  7000. AbortXfer handlerAbortXfer = OnAbortXfer;
  7001. if (handlerAbortXfer != null)
  7002. {
  7003. handlerAbortXfer(this, abortXfer.XferID.ID);
  7004. }
  7005. return true;
  7006. }
  7007. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7008. {
  7009. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7010. #region Packet Session and User Check
  7011. if (m_checkPackets)
  7012. {
  7013. if (invFolder.AgentData.SessionID != SessionId ||
  7014. invFolder.AgentData.AgentID != AgentId)
  7015. return true;
  7016. }
  7017. #endregion
  7018. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7019. if (handlerCreateInventoryFolder != null)
  7020. {
  7021. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7022. (ushort)invFolder.FolderData.Type,
  7023. Util.FieldToString(invFolder.FolderData.Name),
  7024. invFolder.FolderData.ParentID);
  7025. }
  7026. return true;
  7027. }
  7028. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7029. {
  7030. if (OnUpdateInventoryFolder != null)
  7031. {
  7032. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7033. #region Packet Session and User Check
  7034. if (m_checkPackets)
  7035. {
  7036. if (invFolderx.AgentData.SessionID != SessionId ||
  7037. invFolderx.AgentData.AgentID != AgentId)
  7038. return true;
  7039. }
  7040. #endregion
  7041. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7042. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7043. {
  7044. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7045. if (handlerUpdateInventoryFolder != null)
  7046. {
  7047. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7048. (ushort)invFolderx.FolderData[i].Type,
  7049. Util.FieldToString(invFolderx.FolderData[i].Name),
  7050. invFolderx.FolderData[i].ParentID);
  7051. }
  7052. }
  7053. }
  7054. return true;
  7055. }
  7056. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7057. {
  7058. if (OnMoveInventoryFolder != null)
  7059. {
  7060. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7061. #region Packet Session and User Check
  7062. if (m_checkPackets)
  7063. {
  7064. if (invFoldery.AgentData.SessionID != SessionId ||
  7065. invFoldery.AgentData.AgentID != AgentId)
  7066. return true;
  7067. }
  7068. #endregion
  7069. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7070. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7071. {
  7072. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7073. if (handlerMoveInventoryFolder != null)
  7074. {
  7075. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7076. invFoldery.InventoryData[i].ParentID);
  7077. }
  7078. }
  7079. }
  7080. return true;
  7081. }
  7082. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7083. {
  7084. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7085. #region Packet Session and User Check
  7086. if (m_checkPackets)
  7087. {
  7088. if (createItem.AgentData.SessionID != SessionId ||
  7089. createItem.AgentData.AgentID != AgentId)
  7090. return true;
  7091. }
  7092. #endregion
  7093. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7094. if (handlerCreateNewInventoryItem != null)
  7095. {
  7096. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7097. createItem.InventoryBlock.FolderID,
  7098. createItem.InventoryBlock.CallbackID,
  7099. Util.FieldToString(createItem.InventoryBlock.Description),
  7100. Util.FieldToString(createItem.InventoryBlock.Name),
  7101. createItem.InventoryBlock.InvType,
  7102. createItem.InventoryBlock.Type,
  7103. createItem.InventoryBlock.WearableType,
  7104. createItem.InventoryBlock.NextOwnerMask,
  7105. Util.UnixTimeSinceEpoch());
  7106. }
  7107. return true;
  7108. }
  7109. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7110. {
  7111. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7112. #region Packet Session and User Check
  7113. if (m_checkPackets)
  7114. {
  7115. if (createLink.AgentData.SessionID != SessionId ||
  7116. createLink.AgentData.AgentID != AgentId)
  7117. return true;
  7118. }
  7119. #endregion
  7120. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7121. if (linkInventoryItem != null)
  7122. {
  7123. linkInventoryItem(
  7124. this,
  7125. createLink.InventoryBlock.TransactionID,
  7126. createLink.InventoryBlock.FolderID,
  7127. createLink.InventoryBlock.CallbackID,
  7128. Util.FieldToString(createLink.InventoryBlock.Description),
  7129. Util.FieldToString(createLink.InventoryBlock.Name),
  7130. createLink.InventoryBlock.InvType,
  7131. createLink.InventoryBlock.Type,
  7132. createLink.InventoryBlock.OldItemID);
  7133. }
  7134. return true;
  7135. }
  7136. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7137. {
  7138. if (OnFetchInventory != null)
  7139. {
  7140. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7141. #region Packet Session and User Check
  7142. if (m_checkPackets)
  7143. {
  7144. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7145. FetchInventoryx.AgentData.AgentID != AgentId)
  7146. return true;
  7147. }
  7148. #endregion
  7149. FetchInventory handlerFetchInventory = null;
  7150. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7151. {
  7152. handlerFetchInventory = OnFetchInventory;
  7153. if (handlerFetchInventory != null)
  7154. {
  7155. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7156. FetchInventoryx.InventoryData[i].OwnerID);
  7157. }
  7158. }
  7159. }
  7160. return true;
  7161. }
  7162. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7163. {
  7164. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7165. #region Packet Session and User Check
  7166. if (m_checkPackets)
  7167. {
  7168. if (Fetch.AgentData.SessionID != SessionId ||
  7169. Fetch.AgentData.AgentID != AgentId)
  7170. return true;
  7171. }
  7172. #endregion
  7173. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7174. if (handlerFetchInventoryDescendents != null)
  7175. {
  7176. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7177. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7178. Fetch.InventoryData.SortOrder);
  7179. }
  7180. return true;
  7181. }
  7182. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7183. {
  7184. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7185. #region Packet Session and User Check
  7186. if (m_checkPackets)
  7187. {
  7188. if (Purge.AgentData.SessionID != SessionId ||
  7189. Purge.AgentData.AgentID != AgentId)
  7190. return true;
  7191. }
  7192. #endregion
  7193. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7194. if (handlerPurgeInventoryDescendents != null)
  7195. {
  7196. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7197. }
  7198. return true;
  7199. }
  7200. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7201. {
  7202. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7203. #region Packet Session and User Check
  7204. if (m_checkPackets)
  7205. {
  7206. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7207. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7208. return true;
  7209. }
  7210. #endregion
  7211. if (OnUpdateInventoryItem != null)
  7212. {
  7213. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7214. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7215. {
  7216. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7217. if (handlerUpdateInventoryItem != null)
  7218. {
  7219. InventoryItemBase itemUpd = new InventoryItemBase();
  7220. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7221. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7222. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7223. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7224. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7225. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7226. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7227. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7228. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7229. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7230. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7231. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7232. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7233. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7234. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7235. inventoryItemUpdate.InventoryData[i].ItemID,
  7236. itemUpd);
  7237. }
  7238. }
  7239. }
  7240. return true;
  7241. }
  7242. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7243. {
  7244. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7245. #region Packet Session and User Check
  7246. if (m_checkPackets)
  7247. {
  7248. if (copyitem.AgentData.SessionID != SessionId ||
  7249. copyitem.AgentData.AgentID != AgentId)
  7250. return true;
  7251. }
  7252. #endregion
  7253. CopyInventoryItem handlerCopyInventoryItem = null;
  7254. if (OnCopyInventoryItem != null)
  7255. {
  7256. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7257. {
  7258. handlerCopyInventoryItem = OnCopyInventoryItem;
  7259. if (handlerCopyInventoryItem != null)
  7260. {
  7261. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7262. datablock.OldItemID, datablock.NewFolderID,
  7263. Util.FieldToString(datablock.NewName));
  7264. }
  7265. }
  7266. }
  7267. return true;
  7268. }
  7269. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7270. {
  7271. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7272. #region Packet Session and User Check
  7273. if (m_checkPackets)
  7274. {
  7275. if (moveitem.AgentData.SessionID != SessionId ||
  7276. moveitem.AgentData.AgentID != AgentId)
  7277. return true;
  7278. }
  7279. #endregion
  7280. if (OnMoveInventoryItem != null)
  7281. {
  7282. MoveInventoryItem handlerMoveInventoryItem = null;
  7283. InventoryItemBase itm = null;
  7284. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7285. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7286. {
  7287. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7288. itm.Folder = datablock.FolderID;
  7289. itm.Name = Util.FieldToString(datablock.NewName);
  7290. // weird, comes out as empty string
  7291. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7292. items.Add(itm);
  7293. }
  7294. handlerMoveInventoryItem = OnMoveInventoryItem;
  7295. if (handlerMoveInventoryItem != null)
  7296. {
  7297. handlerMoveInventoryItem(this, items);
  7298. }
  7299. }
  7300. return true;
  7301. }
  7302. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7303. {
  7304. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7305. #region Packet Session and User Check
  7306. if (m_checkPackets)
  7307. {
  7308. if (removeItem.AgentData.SessionID != SessionId ||
  7309. removeItem.AgentData.AgentID != AgentId)
  7310. return true;
  7311. }
  7312. #endregion
  7313. if (OnRemoveInventoryItem != null)
  7314. {
  7315. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7316. List<UUID> uuids = new List<UUID>();
  7317. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7318. {
  7319. uuids.Add(datablock.ItemID);
  7320. }
  7321. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7322. if (handlerRemoveInventoryItem != null)
  7323. {
  7324. handlerRemoveInventoryItem(this, uuids);
  7325. }
  7326. }
  7327. return true;
  7328. }
  7329. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7330. {
  7331. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7332. #region Packet Session and User Check
  7333. if (m_checkPackets)
  7334. {
  7335. if (removeFolder.AgentData.SessionID != SessionId ||
  7336. removeFolder.AgentData.AgentID != AgentId)
  7337. return true;
  7338. }
  7339. #endregion
  7340. if (OnRemoveInventoryFolder != null)
  7341. {
  7342. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7343. List<UUID> uuids = new List<UUID>();
  7344. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7345. {
  7346. uuids.Add(datablock.FolderID);
  7347. }
  7348. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7349. if (handlerRemoveInventoryFolder != null)
  7350. {
  7351. handlerRemoveInventoryFolder(this, uuids);
  7352. }
  7353. }
  7354. return true;
  7355. }
  7356. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7357. {
  7358. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7359. #region Packet Session and User Check
  7360. if (m_checkPackets)
  7361. {
  7362. if (removeObject.AgentData.SessionID != SessionId ||
  7363. removeObject.AgentData.AgentID != AgentId)
  7364. return true;
  7365. }
  7366. #endregion
  7367. if (OnRemoveInventoryFolder != null)
  7368. {
  7369. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7370. List<UUID> uuids = new List<UUID>();
  7371. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7372. {
  7373. uuids.Add(datablock.FolderID);
  7374. }
  7375. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7376. if (handlerRemoveInventoryFolder != null)
  7377. {
  7378. handlerRemoveInventoryFolder(this, uuids);
  7379. }
  7380. }
  7381. if (OnRemoveInventoryItem != null)
  7382. {
  7383. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7384. List<UUID> uuids = new List<UUID>();
  7385. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7386. {
  7387. uuids.Add(datablock.ItemID);
  7388. }
  7389. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7390. if (handlerRemoveInventoryItem != null)
  7391. {
  7392. handlerRemoveInventoryItem(this, uuids);
  7393. }
  7394. }
  7395. return true;
  7396. }
  7397. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7398. {
  7399. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7400. #region Packet Session and User Check
  7401. if (m_checkPackets)
  7402. {
  7403. if (requesttask.AgentData.SessionID != SessionId ||
  7404. requesttask.AgentData.AgentID != AgentId)
  7405. return true;
  7406. }
  7407. #endregion
  7408. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7409. if (handlerRequestTaskInventory != null)
  7410. {
  7411. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7412. }
  7413. return true;
  7414. }
  7415. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7416. {
  7417. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7418. #region Packet Session and User Check
  7419. if (m_checkPackets)
  7420. {
  7421. if (updatetask.AgentData.SessionID != SessionId ||
  7422. updatetask.AgentData.AgentID != AgentId)
  7423. return true;
  7424. }
  7425. #endregion
  7426. if (OnUpdateTaskInventory != null)
  7427. {
  7428. if (updatetask.UpdateData.Key == 0)
  7429. {
  7430. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7431. if (handlerUpdateTaskInventory != null)
  7432. {
  7433. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7434. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7435. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7436. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7437. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7438. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7439. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7440. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7441. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7442. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7443. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7444. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7445. // different
  7446. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7447. newTaskItem.Type = updatetask.InventoryData.Type;
  7448. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7449. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7450. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7451. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7452. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7453. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7454. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7455. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7456. newTaskItem, updatetask.UpdateData.LocalID);
  7457. }
  7458. }
  7459. }
  7460. return true;
  7461. }
  7462. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7463. {
  7464. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7465. #region Packet Session and User Check
  7466. if (m_checkPackets)
  7467. {
  7468. if (removeTask.AgentData.SessionID != SessionId ||
  7469. removeTask.AgentData.AgentID != AgentId)
  7470. return true;
  7471. }
  7472. #endregion
  7473. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7474. if (handlerRemoveTaskItem != null)
  7475. {
  7476. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7477. }
  7478. return true;
  7479. }
  7480. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7481. {
  7482. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7483. #region Packet Session and User Check
  7484. if (m_checkPackets)
  7485. {
  7486. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7487. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7488. return true;
  7489. }
  7490. #endregion
  7491. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7492. if (handlerMoveTaskItem != null)
  7493. {
  7494. handlerMoveTaskItem(
  7495. this, moveTaskInventoryPacket.AgentData.FolderID,
  7496. moveTaskInventoryPacket.InventoryData.LocalID,
  7497. moveTaskInventoryPacket.InventoryData.ItemID);
  7498. }
  7499. return true;
  7500. }
  7501. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7502. {
  7503. //m_log.Debug(Pack.ToString());
  7504. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7505. #region Packet Session and User Check
  7506. if (m_checkPackets)
  7507. {
  7508. if (rezScriptx.AgentData.SessionID != SessionId ||
  7509. rezScriptx.AgentData.AgentID != AgentId)
  7510. return true;
  7511. }
  7512. #endregion
  7513. RezScript handlerRezScript = OnRezScript;
  7514. InventoryItemBase item = new InventoryItemBase();
  7515. item.ID = rezScriptx.InventoryBlock.ItemID;
  7516. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7517. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7518. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7519. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7520. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7521. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7522. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7523. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7524. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7525. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7526. item.AssetType = rezScriptx.InventoryBlock.Type;
  7527. item.InvType = rezScriptx.InventoryBlock.InvType;
  7528. item.Flags = rezScriptx.InventoryBlock.Flags;
  7529. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7530. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7531. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7532. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7533. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7534. if (handlerRezScript != null)
  7535. {
  7536. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7537. }
  7538. return true;
  7539. }
  7540. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7541. {
  7542. RequestMapLayer();
  7543. return true;
  7544. }
  7545. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7546. {
  7547. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7548. #region Packet Session and User Check
  7549. if (m_checkPackets)
  7550. {
  7551. if (MapRequest.AgentData.SessionID != SessionId ||
  7552. MapRequest.AgentData.AgentID != AgentId)
  7553. return true;
  7554. }
  7555. #endregion
  7556. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7557. if (handlerRequestMapBlocks != null)
  7558. {
  7559. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7560. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7561. }
  7562. return true;
  7563. }
  7564. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7565. {
  7566. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7567. #region Packet Session and User Check
  7568. if (m_checkPackets)
  7569. {
  7570. if (map.AgentData.SessionID != SessionId ||
  7571. map.AgentData.AgentID != AgentId)
  7572. return true;
  7573. }
  7574. #endregion
  7575. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7576. map.NameData.Name.Length - 1);
  7577. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7578. if (handlerMapNameRequest != null)
  7579. {
  7580. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7581. }
  7582. return true;
  7583. }
  7584. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7585. {
  7586. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7587. #region Packet Session and User Check
  7588. if (m_checkPackets)
  7589. {
  7590. if (tpReq.Info.SessionID != SessionId ||
  7591. tpReq.Info.AgentID != AgentId)
  7592. return true;
  7593. }
  7594. #endregion
  7595. UUID lmid = tpReq.Info.LandmarkID;
  7596. AssetLandmark lm;
  7597. if (lmid != UUID.Zero)
  7598. {
  7599. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7600. AssetBase lma = m_assetService.Get(lmid.ToString());
  7601. if (lma == null)
  7602. {
  7603. // Failed to find landmark
  7604. // Let's try to search in the user's home asset server
  7605. lma = FindAssetInUserAssetServer(lmid.ToString());
  7606. if (lma == null)
  7607. {
  7608. // Really doesn't exist
  7609. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7610. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7611. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7612. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7613. }
  7614. }
  7615. try
  7616. {
  7617. lm = new AssetLandmark(lma);
  7618. }
  7619. catch (NullReferenceException)
  7620. {
  7621. // asset not found generates null ref inside the assetlandmark constructor.
  7622. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7623. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7624. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7625. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7626. return true;
  7627. }
  7628. }
  7629. else
  7630. {
  7631. // Teleport home request
  7632. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7633. if (handlerTeleportHomeRequest != null)
  7634. {
  7635. handlerTeleportHomeRequest(AgentId, this);
  7636. }
  7637. return true;
  7638. }
  7639. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7640. if (handlerTeleportLandmarkRequest != null)
  7641. {
  7642. handlerTeleportLandmarkRequest(this, lm);
  7643. }
  7644. else
  7645. {
  7646. //no event handler so cancel request
  7647. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7648. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7649. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7650. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7651. }
  7652. return true;
  7653. }
  7654. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7655. {
  7656. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7657. if (handlerTeleportCancel != null)
  7658. {
  7659. handlerTeleportCancel(this);
  7660. }
  7661. return true;
  7662. }
  7663. private AssetBase FindAssetInUserAssetServer(string id)
  7664. {
  7665. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7666. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7667. {
  7668. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7669. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7670. }
  7671. return null;
  7672. }
  7673. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7674. {
  7675. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7676. // m_log.Debug(tpLocReq.ToString());
  7677. #region Packet Session and User Check
  7678. if (m_checkPackets)
  7679. {
  7680. if (tpLocReq.AgentData.SessionID != SessionId ||
  7681. tpLocReq.AgentData.AgentID != AgentId)
  7682. return true;
  7683. }
  7684. #endregion
  7685. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7686. if (handlerTeleportLocationRequest != null)
  7687. {
  7688. // Adjust teleport location to base of a larger region if requested to teleport to a sub-region
  7689. uint locX, locY;
  7690. Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out locX, out locY);
  7691. if ((locX >= m_scene.RegionInfo.WorldLocX)
  7692. && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX))
  7693. && (locY >= m_scene.RegionInfo.WorldLocY)
  7694. && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)) )
  7695. {
  7696. tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle;
  7697. tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX;
  7698. tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY;
  7699. }
  7700. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7701. tpLocReq.Info.LookAt, 16);
  7702. }
  7703. else
  7704. {
  7705. //no event handler so cancel request
  7706. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7707. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7708. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7709. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7710. }
  7711. return true;
  7712. }
  7713. #endregion Inventory/Asset/Other related packets
  7714. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7715. {
  7716. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7717. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7718. {
  7719. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7720. if (handlerNameRequest != null)
  7721. {
  7722. handlerNameRequest(UUIDBlock.ID, this);
  7723. }
  7724. }
  7725. return true;
  7726. }
  7727. #region Parcel related packets
  7728. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7729. {
  7730. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7731. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7732. if (handlerRegionHandleRequest != null)
  7733. {
  7734. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7735. }
  7736. return true;
  7737. }
  7738. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7739. {
  7740. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7741. #region Packet Session and User Check
  7742. if (m_checkPackets)
  7743. {
  7744. if (pirPack.AgentData.SessionID != SessionId ||
  7745. pirPack.AgentData.AgentID != AgentId)
  7746. return true;
  7747. }
  7748. #endregion
  7749. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7750. if (handlerParcelInfoRequest != null)
  7751. {
  7752. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7753. }
  7754. return true;
  7755. }
  7756. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7757. {
  7758. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7759. #region Packet Session and User Check
  7760. if (m_checkPackets)
  7761. {
  7762. if (requestPacket.AgentData.SessionID != SessionId ||
  7763. requestPacket.AgentData.AgentID != AgentId)
  7764. return true;
  7765. }
  7766. #endregion
  7767. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7768. if (handlerParcelAccessListRequest != null)
  7769. {
  7770. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7771. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7772. requestPacket.Data.LocalID, this);
  7773. }
  7774. return true;
  7775. }
  7776. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7777. {
  7778. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7779. #region Packet Session and User Check
  7780. if (m_checkPackets)
  7781. {
  7782. if (updatePacket.AgentData.SessionID != SessionId ||
  7783. updatePacket.AgentData.AgentID != AgentId)
  7784. return true;
  7785. }
  7786. #endregion
  7787. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7788. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7789. {
  7790. LandAccessEntry entry = new LandAccessEntry();
  7791. entry.AgentID = block.ID;
  7792. entry.Flags = (AccessList)block.Flags;
  7793. entry.Expires = block.Time;
  7794. entries.Add(entry);
  7795. }
  7796. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7797. if (handlerParcelAccessListUpdateRequest != null)
  7798. {
  7799. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7800. updatePacket.Data.Flags,
  7801. updatePacket.Data.LocalID,
  7802. updatePacket.Data.TransactionID,
  7803. updatePacket.Data.SequenceID,
  7804. updatePacket.Data.Sections,
  7805. entries, this);
  7806. }
  7807. return true;
  7808. }
  7809. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7810. {
  7811. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7812. #region Packet Session and User Check
  7813. if (m_checkPackets)
  7814. {
  7815. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7816. propertiesRequest.AgentData.AgentID != AgentId)
  7817. return true;
  7818. }
  7819. #endregion
  7820. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7821. if (handlerParcelPropertiesRequest != null)
  7822. {
  7823. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7824. (int)Math.Round(propertiesRequest.ParcelData.South),
  7825. (int)Math.Round(propertiesRequest.ParcelData.East),
  7826. (int)Math.Round(propertiesRequest.ParcelData.North),
  7827. propertiesRequest.ParcelData.SequenceID,
  7828. propertiesRequest.ParcelData.SnapSelection, this);
  7829. }
  7830. return true;
  7831. }
  7832. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7833. {
  7834. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7835. #region Packet Session and User Check
  7836. if (m_checkPackets)
  7837. {
  7838. if (landDivide.AgentData.SessionID != SessionId ||
  7839. landDivide.AgentData.AgentID != AgentId)
  7840. return true;
  7841. }
  7842. #endregion
  7843. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7844. if (handlerParcelDivideRequest != null)
  7845. {
  7846. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7847. (int)Math.Round(landDivide.ParcelData.South),
  7848. (int)Math.Round(landDivide.ParcelData.East),
  7849. (int)Math.Round(landDivide.ParcelData.North), this);
  7850. }
  7851. return true;
  7852. }
  7853. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7854. {
  7855. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7856. #region Packet Session and User Check
  7857. if (m_checkPackets)
  7858. {
  7859. if (landJoin.AgentData.SessionID != SessionId ||
  7860. landJoin.AgentData.AgentID != AgentId)
  7861. return true;
  7862. }
  7863. #endregion
  7864. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7865. if (handlerParcelJoinRequest != null)
  7866. {
  7867. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7868. (int)Math.Round(landJoin.ParcelData.South),
  7869. (int)Math.Round(landJoin.ParcelData.East),
  7870. (int)Math.Round(landJoin.ParcelData.North), this);
  7871. }
  7872. return true;
  7873. }
  7874. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7875. {
  7876. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7877. #region Packet Session and User Check
  7878. if (m_checkPackets)
  7879. {
  7880. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7881. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7882. return true;
  7883. }
  7884. #endregion
  7885. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7886. if (handlerParcelPropertiesUpdateRequest != null)
  7887. {
  7888. LandUpdateArgs args = new LandUpdateArgs();
  7889. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7890. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7891. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7892. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7893. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7894. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7895. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7896. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7897. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7898. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7899. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7900. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7901. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7902. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7903. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7904. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7905. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7906. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7907. }
  7908. return true;
  7909. }
  7910. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7911. {
  7912. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7913. #region Packet Session and User Check
  7914. if (m_checkPackets)
  7915. {
  7916. if (selectPacket.AgentData.SessionID != SessionId ||
  7917. selectPacket.AgentData.AgentID != AgentId)
  7918. return true;
  7919. }
  7920. #endregion
  7921. List<UUID> returnIDs = new List<UUID>();
  7922. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7923. selectPacket.ReturnIDs)
  7924. {
  7925. returnIDs.Add(rb.ReturnID);
  7926. }
  7927. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7928. if (handlerParcelSelectObjects != null)
  7929. {
  7930. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7931. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7932. }
  7933. return true;
  7934. }
  7935. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7936. {
  7937. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7938. #region Packet Session and User Check
  7939. if (m_checkPackets)
  7940. {
  7941. if (reqPacket.AgentData.SessionID != SessionId ||
  7942. reqPacket.AgentData.AgentID != AgentId)
  7943. return true;
  7944. }
  7945. #endregion
  7946. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7947. if (handlerParcelObjectOwnerRequest != null)
  7948. {
  7949. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7950. }
  7951. return true;
  7952. }
  7953. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7954. {
  7955. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7956. #region Packet Session and User Check
  7957. if (m_checkPackets)
  7958. {
  7959. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7960. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7961. return true;
  7962. }
  7963. #endregion
  7964. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7965. if (handlerParcelGodForceOwner != null)
  7966. {
  7967. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7968. }
  7969. return true;
  7970. }
  7971. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7972. {
  7973. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7974. #region Packet Session and User Check
  7975. if (m_checkPackets)
  7976. {
  7977. if (releasePacket.AgentData.SessionID != SessionId ||
  7978. releasePacket.AgentData.AgentID != AgentId)
  7979. return true;
  7980. }
  7981. #endregion
  7982. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7983. if (handlerParcelAbandonRequest != null)
  7984. {
  7985. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7986. }
  7987. return true;
  7988. }
  7989. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7990. {
  7991. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7992. #region Packet Session and User Check
  7993. if (m_checkPackets)
  7994. {
  7995. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7996. reclaimPacket.AgentData.AgentID != AgentId)
  7997. return true;
  7998. }
  7999. #endregion
  8000. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  8001. if (handlerParcelReclaim != null)
  8002. {
  8003. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  8004. }
  8005. return true;
  8006. }
  8007. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  8008. {
  8009. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  8010. #region Packet Session and User Check
  8011. if (m_checkPackets)
  8012. {
  8013. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  8014. parcelReturnObjects.AgentData.AgentID != AgentId)
  8015. return true;
  8016. }
  8017. #endregion
  8018. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8019. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8020. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8021. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8022. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8023. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8024. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8025. if (handlerParcelReturnObjectsRequest != null)
  8026. {
  8027. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8028. }
  8029. return true;
  8030. }
  8031. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8032. {
  8033. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8034. #region Packet Session and User Check
  8035. if (m_checkPackets)
  8036. {
  8037. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8038. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8039. return true;
  8040. }
  8041. #endregion
  8042. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8043. if (handlerParcelSetOtherCleanTime != null)
  8044. {
  8045. handlerParcelSetOtherCleanTime(this,
  8046. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8047. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8048. }
  8049. return true;
  8050. }
  8051. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8052. {
  8053. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8054. #region Packet Session and User Check
  8055. if (m_checkPackets)
  8056. {
  8057. if (lsrp.AgentData.SessionID != SessionId ||
  8058. lsrp.AgentData.AgentID != AgentId)
  8059. return true;
  8060. }
  8061. #endregion
  8062. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8063. if (handlerLandStatRequest != null)
  8064. {
  8065. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8066. }
  8067. return true;
  8068. }
  8069. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8070. {
  8071. ParcelDwellRequestPacket dwellrq =
  8072. (ParcelDwellRequestPacket)Pack;
  8073. #region Packet Session and User Check
  8074. if (m_checkPackets)
  8075. {
  8076. if (dwellrq.AgentData.SessionID != SessionId ||
  8077. dwellrq.AgentData.AgentID != AgentId)
  8078. return true;
  8079. }
  8080. #endregion
  8081. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8082. if (handlerParcelDwellRequest != null)
  8083. {
  8084. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8085. }
  8086. return true;
  8087. }
  8088. #endregion Parcel related packets
  8089. #region Estate Packets
  8090. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8091. {
  8092. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8093. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8094. GodLandStatRequest handlerLandStatRequest;
  8095. #region Packet Session and User Check
  8096. if (m_checkPackets)
  8097. {
  8098. if (messagePacket.AgentData.SessionID != SessionId ||
  8099. messagePacket.AgentData.AgentID != AgentId)
  8100. return true;
  8101. }
  8102. #endregion
  8103. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8104. switch (method)
  8105. {
  8106. case "getinfo":
  8107. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8108. {
  8109. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8110. }
  8111. return true;
  8112. case "setregioninfo":
  8113. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8114. {
  8115. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8116. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8117. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8118. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8119. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8120. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8121. }
  8122. return true;
  8123. // case "texturebase":
  8124. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8125. // {
  8126. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8127. // {
  8128. // string s = Utils.BytesToString(block.Parameter);
  8129. // string[] splitField = s.Split(' ');
  8130. // if (splitField.Length == 2)
  8131. // {
  8132. // UUID tempUUID = new UUID(splitField[1]);
  8133. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8134. // }
  8135. // }
  8136. // }
  8137. // break;
  8138. case "texturedetail":
  8139. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8140. {
  8141. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8142. {
  8143. string s = Utils.BytesToString(block.Parameter);
  8144. string[] splitField = s.Split(' ');
  8145. if (splitField.Length == 2)
  8146. {
  8147. Int16 corner = Convert.ToInt16(splitField[0]);
  8148. UUID textureUUID = new UUID(splitField[1]);
  8149. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8150. }
  8151. }
  8152. }
  8153. return true;
  8154. case "textureheights":
  8155. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8156. {
  8157. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8158. {
  8159. string s = Utils.BytesToString(block.Parameter);
  8160. string[] splitField = s.Split(' ');
  8161. if (splitField.Length == 3)
  8162. {
  8163. Int16 corner = Convert.ToInt16(splitField[0]);
  8164. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8165. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8166. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8167. }
  8168. }
  8169. }
  8170. return true;
  8171. case "texturecommit":
  8172. OnCommitEstateTerrainTextureRequest(this);
  8173. return true;
  8174. case "setregionterrain":
  8175. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8176. {
  8177. if (messagePacket.ParamList.Length != 9)
  8178. {
  8179. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8180. }
  8181. else
  8182. {
  8183. try
  8184. {
  8185. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8186. if (!tmp.Contains(".")) tmp += ".00";
  8187. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8188. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8189. if (!tmp.Contains(".")) tmp += ".00";
  8190. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8191. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8192. if (!tmp.Contains(".")) tmp += ".00";
  8193. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8194. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8195. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8196. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8197. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8198. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8199. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8200. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8201. }
  8202. catch (Exception ex)
  8203. {
  8204. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8205. }
  8206. }
  8207. }
  8208. return true;
  8209. case "restart":
  8210. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8211. {
  8212. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8213. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8214. {
  8215. float timeSeconds;
  8216. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8217. timeSeconds = (int)timeSeconds;
  8218. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8219. }
  8220. }
  8221. return true;
  8222. case "estatechangecovenantid":
  8223. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8224. {
  8225. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8226. {
  8227. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8228. OnEstateChangeCovenantRequest(this, newCovenantID);
  8229. }
  8230. }
  8231. return true;
  8232. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8233. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8234. {
  8235. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8236. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8237. }
  8238. return true;
  8239. case "simulatormessage":
  8240. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8241. {
  8242. UUID invoice = messagePacket.MethodData.Invoice;
  8243. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8244. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8245. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8246. UUID sessionID = messagePacket.AgentData.SessionID;
  8247. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8248. }
  8249. return true;
  8250. case "instantmessage":
  8251. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8252. {
  8253. if (messagePacket.ParamList.Length < 2)
  8254. return true;
  8255. UUID invoice = messagePacket.MethodData.Invoice;
  8256. UUID sessionID = messagePacket.AgentData.SessionID;
  8257. UUID SenderID;
  8258. string SenderName;
  8259. string Message;
  8260. if (messagePacket.ParamList.Length < 5)
  8261. {
  8262. SenderID = AgentId;
  8263. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8264. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8265. }
  8266. else
  8267. {
  8268. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8269. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8270. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8271. }
  8272. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8273. }
  8274. return true;
  8275. case "setregiondebug":
  8276. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8277. {
  8278. UUID invoice = messagePacket.MethodData.Invoice;
  8279. UUID SenderID = messagePacket.AgentData.AgentID;
  8280. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8281. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8282. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8283. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8284. }
  8285. return true;
  8286. case "teleporthomeuser":
  8287. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8288. {
  8289. UUID invoice = messagePacket.MethodData.Invoice;
  8290. UUID SenderID = messagePacket.AgentData.AgentID;
  8291. UUID Prey;
  8292. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8293. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8294. }
  8295. return true;
  8296. case "teleporthomeallusers":
  8297. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8298. {
  8299. UUID invoice = messagePacket.MethodData.Invoice;
  8300. UUID SenderID = messagePacket.AgentData.AgentID;
  8301. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8302. }
  8303. return true;
  8304. case "colliders":
  8305. handlerLandStatRequest = OnLandStatRequest;
  8306. if (handlerLandStatRequest != null)
  8307. {
  8308. handlerLandStatRequest(0, 1, 0, "", this);
  8309. }
  8310. return true;
  8311. case "scripts":
  8312. handlerLandStatRequest = OnLandStatRequest;
  8313. if (handlerLandStatRequest != null)
  8314. {
  8315. handlerLandStatRequest(0, 0, 0, "", this);
  8316. }
  8317. return true;
  8318. case "terrain":
  8319. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8320. {
  8321. if (messagePacket.ParamList.Length > 0)
  8322. {
  8323. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8324. {
  8325. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8326. if (handlerBakeTerrain != null)
  8327. {
  8328. handlerBakeTerrain(this);
  8329. }
  8330. }
  8331. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8332. {
  8333. if (messagePacket.ParamList.Length > 1)
  8334. {
  8335. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8336. if (handlerRequestTerrain != null)
  8337. {
  8338. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8339. }
  8340. }
  8341. }
  8342. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8343. {
  8344. if (messagePacket.ParamList.Length > 1)
  8345. {
  8346. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8347. if (handlerUploadTerrain != null)
  8348. {
  8349. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8350. }
  8351. }
  8352. }
  8353. }
  8354. }
  8355. return true;
  8356. case "estatechangeinfo":
  8357. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8358. {
  8359. UUID invoice = messagePacket.MethodData.Invoice;
  8360. UUID SenderID = messagePacket.AgentData.AgentID;
  8361. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8362. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8363. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8364. if (handlerEstateChangeInfo != null)
  8365. {
  8366. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8367. }
  8368. }
  8369. return true;
  8370. case "telehub":
  8371. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8372. {
  8373. UUID invoice = messagePacket.MethodData.Invoice;
  8374. UUID SenderID = messagePacket.AgentData.AgentID;
  8375. UInt32 param1 = 0u;
  8376. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8377. if (command != "info ui")
  8378. {
  8379. try
  8380. {
  8381. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8382. }
  8383. catch
  8384. {
  8385. }
  8386. }
  8387. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8388. if (handlerEstateManageTelehub != null)
  8389. {
  8390. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8391. }
  8392. }
  8393. return true;
  8394. default:
  8395. m_log.WarnFormat(
  8396. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8397. method, Name, Scene.Name);
  8398. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8399. {
  8400. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8401. string data = (string)Utils.BytesToString(block.Parameter);
  8402. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8403. }
  8404. return true;
  8405. }
  8406. //int parcelID, uint reportType, uint requestflags, string filter
  8407. //lsrp.RequestData.ParcelLocalID;
  8408. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8409. //lsrp.RequestData.RequestFlags;
  8410. //lsrp.RequestData.Filter;
  8411. }
  8412. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8413. {
  8414. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8415. #region Packet Session and User Check
  8416. if (m_checkPackets)
  8417. {
  8418. if (mPacket.SessionID != SessionId ||
  8419. mPacket.AgentID != AgentId)
  8420. return true;
  8421. }
  8422. #endregion
  8423. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8424. if (handlerRegionInfoRequest != null)
  8425. {
  8426. handlerRegionInfoRequest(this);
  8427. }
  8428. return true;
  8429. }
  8430. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8431. {
  8432. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8433. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8434. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8435. if (handlerEstateCovenantRequest != null)
  8436. {
  8437. handlerEstateCovenantRequest(this);
  8438. }
  8439. return true;
  8440. }
  8441. #endregion Estate Packets
  8442. #region GodPackets
  8443. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8444. {
  8445. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8446. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8447. UUID token = rblock.Token;
  8448. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8449. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8450. if (handlerReqGodlikePowers != null)
  8451. {
  8452. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8453. }
  8454. return true;
  8455. }
  8456. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8457. {
  8458. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8459. (GodUpdateRegionInfoPacket)Packet;
  8460. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8461. if (handlerGodUpdateRegionInfo != null)
  8462. {
  8463. handlerGodUpdateRegionInfo(this,
  8464. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8465. GodUpdateRegionInfo.RegionInfo.EstateID,
  8466. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8467. GodUpdateRegionInfo.RegionInfo.SimName,
  8468. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8469. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8470. return true;
  8471. }
  8472. return false;
  8473. }
  8474. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8475. {
  8476. SimWideDeletesPacket SimWideDeletesRequest =
  8477. (SimWideDeletesPacket)Packet;
  8478. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8479. if (handlerSimWideDeletesRequest != null)
  8480. {
  8481. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8482. return true;
  8483. }
  8484. return false;
  8485. }
  8486. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8487. {
  8488. GodlikeMessagePacket GodlikeMessage =
  8489. (GodlikeMessagePacket)Packet;
  8490. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8491. if (handlerGodlikeMessage != null)
  8492. {
  8493. handlerGodlikeMessage(this,
  8494. GodlikeMessage.MethodData.Invoice,
  8495. GodlikeMessage.MethodData.Method,
  8496. GodlikeMessage.ParamList[0].Parameter);
  8497. return true;
  8498. }
  8499. return false;
  8500. }
  8501. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8502. {
  8503. StateSavePacket SaveStateMessage =
  8504. (StateSavePacket)Packet;
  8505. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8506. if (handlerSaveStatePacket != null)
  8507. {
  8508. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8509. return true;
  8510. }
  8511. return false;
  8512. }
  8513. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8514. {
  8515. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8516. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8517. {
  8518. GodKickUser handlerGodKickUser = OnGodKickUser;
  8519. if (handlerGodKickUser != null)
  8520. {
  8521. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8522. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8523. }
  8524. }
  8525. else
  8526. {
  8527. SendAgentAlertMessage("Kick request denied", false);
  8528. }
  8529. //KickUserPacket kupack = new KickUserPacket();
  8530. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8531. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8532. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8533. //kupack.TargetBlock.TargetIP = (uint)0;
  8534. //kupack.TargetBlock.TargetPort = (ushort)0;
  8535. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8536. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8537. return true;
  8538. }
  8539. #endregion GodPackets
  8540. #region Economy/Transaction Packets
  8541. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8542. {
  8543. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8544. #region Packet Session and User Check
  8545. if (m_checkPackets)
  8546. {
  8547. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8548. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8549. return true;
  8550. }
  8551. #endregion
  8552. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8553. if (handlerMoneyBalanceRequest != null)
  8554. {
  8555. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8556. }
  8557. return true;
  8558. }
  8559. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8560. {
  8561. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8562. if (handlerEconomoyDataRequest != null)
  8563. {
  8564. handlerEconomoyDataRequest(this);
  8565. }
  8566. return true;
  8567. }
  8568. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8569. {
  8570. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8571. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8572. if (handlerRequestPayPrice != null)
  8573. {
  8574. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8575. }
  8576. return true;
  8577. }
  8578. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8579. {
  8580. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8581. #region Packet Session and User Check
  8582. if (m_checkPackets)
  8583. {
  8584. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8585. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8586. return true;
  8587. }
  8588. #endregion
  8589. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8590. if (handlerObjectSaleInfo != null)
  8591. {
  8592. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8593. in objectSaleInfoPacket.ObjectData)
  8594. {
  8595. handlerObjectSaleInfo(this,
  8596. objectSaleInfoPacket.AgentData.AgentID,
  8597. objectSaleInfoPacket.AgentData.SessionID,
  8598. d.LocalID,
  8599. d.SaleType,
  8600. d.SalePrice);
  8601. }
  8602. }
  8603. return true;
  8604. }
  8605. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8606. {
  8607. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8608. #region Packet Session and User Check
  8609. if (m_checkPackets)
  8610. {
  8611. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8612. objectBuyPacket.AgentData.AgentID != AgentId)
  8613. return true;
  8614. }
  8615. #endregion
  8616. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8617. if (handlerObjectBuy != null)
  8618. {
  8619. foreach (ObjectBuyPacket.ObjectDataBlock d
  8620. in objectBuyPacket.ObjectData)
  8621. {
  8622. handlerObjectBuy(this,
  8623. objectBuyPacket.AgentData.AgentID,
  8624. objectBuyPacket.AgentData.SessionID,
  8625. objectBuyPacket.AgentData.GroupID,
  8626. objectBuyPacket.AgentData.CategoryID,
  8627. d.ObjectLocalID,
  8628. d.SaleType,
  8629. d.SalePrice);
  8630. }
  8631. }
  8632. return true;
  8633. }
  8634. #endregion Economy/Transaction Packets
  8635. #region Script Packets
  8636. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8637. {
  8638. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8639. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8640. if (handlerGetScriptRunning != null)
  8641. {
  8642. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8643. }
  8644. return true;
  8645. }
  8646. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8647. {
  8648. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8649. #region Packet Session and User Check
  8650. if (m_checkPackets)
  8651. {
  8652. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8653. setScriptRunning.AgentData.AgentID != AgentId)
  8654. return true;
  8655. }
  8656. #endregion
  8657. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8658. if (handlerSetScriptRunning != null)
  8659. {
  8660. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8661. }
  8662. return true;
  8663. }
  8664. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8665. {
  8666. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8667. #region Packet Session and User Check
  8668. if (m_checkPackets)
  8669. {
  8670. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8671. scriptResetPacket.AgentData.AgentID != AgentId)
  8672. return true;
  8673. }
  8674. #endregion
  8675. ScriptReset handlerScriptReset = OnScriptReset;
  8676. if (handlerScriptReset != null)
  8677. {
  8678. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8679. }
  8680. return true;
  8681. }
  8682. #endregion Script Packets
  8683. #region Gesture Managment
  8684. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8685. {
  8686. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8687. #region Packet Session and User Check
  8688. if (m_checkPackets)
  8689. {
  8690. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8691. activateGesturePacket.AgentData.AgentID != AgentId)
  8692. return true;
  8693. }
  8694. #endregion
  8695. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8696. if (handlerActivateGesture != null)
  8697. {
  8698. handlerActivateGesture(this,
  8699. activateGesturePacket.Data[0].AssetID,
  8700. activateGesturePacket.Data[0].ItemID);
  8701. }
  8702. else m_log.Error("Null pointer for activateGesture");
  8703. return true;
  8704. }
  8705. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8706. {
  8707. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8708. #region Packet Session and User Check
  8709. if (m_checkPackets)
  8710. {
  8711. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8712. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8713. return true;
  8714. }
  8715. #endregion
  8716. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8717. if (handlerDeactivateGesture != null)
  8718. {
  8719. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8720. }
  8721. return true;
  8722. }
  8723. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8724. {
  8725. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8726. #region Packet Session and User Check
  8727. if (m_checkPackets)
  8728. {
  8729. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8730. objectOwnerPacket.AgentData.AgentID != AgentId)
  8731. return true;
  8732. }
  8733. #endregion
  8734. List<uint> localIDs = new List<uint>();
  8735. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8736. localIDs.Add(d.ObjectLocalID);
  8737. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8738. if (handlerObjectOwner != null)
  8739. {
  8740. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8741. }
  8742. return true;
  8743. }
  8744. #endregion Gesture Managment
  8745. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8746. {
  8747. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8748. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8749. {
  8750. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8751. AgentFOV handlerAgentFOV = OnAgentFOV;
  8752. if (handlerAgentFOV != null)
  8753. {
  8754. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8755. }
  8756. }
  8757. return true;
  8758. }
  8759. #region unimplemented handlers
  8760. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8761. {
  8762. // TODO: handle this packet
  8763. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8764. return true;
  8765. }
  8766. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8767. {
  8768. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8769. #region Packet Session and User Check
  8770. if (m_checkPackets)
  8771. {
  8772. if (mirpk.AgentData.SessionID != SessionId ||
  8773. mirpk.AgentData.AgentID != AgentId)
  8774. return true;
  8775. }
  8776. #endregion
  8777. //m_log.Debug(mirpk.ToString());
  8778. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8779. if (handlerMapItemRequest != null)
  8780. {
  8781. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8782. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8783. mirpk.RequestData.RegionHandle);
  8784. }
  8785. return true;
  8786. }
  8787. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8788. {
  8789. return true;
  8790. }
  8791. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8792. {
  8793. MuteListRequestPacket muteListRequest =
  8794. (MuteListRequestPacket)Pack;
  8795. #region Packet Session and User Check
  8796. if (m_checkPackets)
  8797. {
  8798. if (muteListRequest.AgentData.SessionID != SessionId ||
  8799. muteListRequest.AgentData.AgentID != AgentId)
  8800. return true;
  8801. }
  8802. #endregion
  8803. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8804. if (handlerMuteListRequest != null)
  8805. {
  8806. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8807. }
  8808. else
  8809. {
  8810. SendUseCachedMuteList();
  8811. }
  8812. return true;
  8813. }
  8814. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8815. {
  8816. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8817. (UpdateMuteListEntryPacket)Packet;
  8818. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8819. if (handlerUpdateMuteListEntry != null)
  8820. {
  8821. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8822. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8823. UpdateMuteListEntry.MuteData.MuteType,
  8824. UpdateMuteListEntry.AgentData.AgentID);
  8825. return true;
  8826. }
  8827. return false;
  8828. }
  8829. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8830. {
  8831. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8832. (RemoveMuteListEntryPacket)Packet;
  8833. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8834. if (handlerRemoveMuteListEntry != null)
  8835. {
  8836. handlerRemoveMuteListEntry(this,
  8837. RemoveMuteListEntry.MuteData.MuteID,
  8838. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8839. RemoveMuteListEntry.AgentData.AgentID);
  8840. return true;
  8841. }
  8842. return false;
  8843. }
  8844. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8845. {
  8846. UserReportPacket UserReport =
  8847. (UserReportPacket)Packet;
  8848. NewUserReport handlerUserReport = OnUserReport;
  8849. if (handlerUserReport != null)
  8850. {
  8851. handlerUserReport(this,
  8852. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8853. UserReport.ReportData.AbuserID,
  8854. UserReport.ReportData.Category,
  8855. UserReport.ReportData.CheckFlags,
  8856. Utils.BytesToString(UserReport.ReportData.Details),
  8857. UserReport.ReportData.ObjectID,
  8858. UserReport.ReportData.Position,
  8859. UserReport.ReportData.ReportType,
  8860. UserReport.ReportData.ScreenshotID,
  8861. Utils.BytesToString(UserReport.ReportData.Summary),
  8862. UserReport.AgentData.AgentID);
  8863. return true;
  8864. }
  8865. return false;
  8866. }
  8867. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8868. {
  8869. // SendPostcardPacket SendPostcard =
  8870. // (SendPostcardPacket)packet;
  8871. SendPostcard handlerSendPostcard = OnSendPostcard;
  8872. if (handlerSendPostcard != null)
  8873. {
  8874. handlerSendPostcard(this);
  8875. return true;
  8876. }
  8877. return false;
  8878. }
  8879. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8880. {
  8881. return true;
  8882. }
  8883. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8884. {
  8885. return true;
  8886. }
  8887. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8888. {
  8889. return true;
  8890. }
  8891. #endregion unimplemented handlers
  8892. #region Dir handlers
  8893. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8894. {
  8895. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8896. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8897. #region Packet Session and User Check
  8898. if (m_checkPackets)
  8899. {
  8900. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8901. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8902. return true;
  8903. }
  8904. #endregion
  8905. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8906. if (handlerDirPlacesQuery != null)
  8907. {
  8908. handlerDirPlacesQuery(this,
  8909. dirPlacesQueryPacket.QueryData.QueryID,
  8910. Utils.BytesToString(
  8911. dirPlacesQueryPacket.QueryData.QueryText),
  8912. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8913. (int)dirPlacesQueryPacket.QueryData.Category,
  8914. Utils.BytesToString(
  8915. dirPlacesQueryPacket.QueryData.SimName),
  8916. dirPlacesQueryPacket.QueryData.QueryStart);
  8917. }
  8918. return true;
  8919. }
  8920. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8921. {
  8922. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8923. #region Packet Session and User Check
  8924. if (m_checkPackets)
  8925. {
  8926. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8927. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8928. return true;
  8929. }
  8930. #endregion
  8931. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8932. if (handlerDirFindQuery != null)
  8933. {
  8934. handlerDirFindQuery(this,
  8935. dirFindQueryPacket.QueryData.QueryID,
  8936. Utils.BytesToString(
  8937. dirFindQueryPacket.QueryData.QueryText).Trim(),
  8938. dirFindQueryPacket.QueryData.QueryFlags,
  8939. dirFindQueryPacket.QueryData.QueryStart);
  8940. }
  8941. return true;
  8942. }
  8943. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8944. {
  8945. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8946. #region Packet Session and User Check
  8947. if (m_checkPackets)
  8948. {
  8949. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8950. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8951. return true;
  8952. }
  8953. #endregion
  8954. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8955. if (handlerDirLandQuery != null)
  8956. {
  8957. handlerDirLandQuery(this,
  8958. dirLandQueryPacket.QueryData.QueryID,
  8959. dirLandQueryPacket.QueryData.QueryFlags,
  8960. dirLandQueryPacket.QueryData.SearchType,
  8961. dirLandQueryPacket.QueryData.Price,
  8962. dirLandQueryPacket.QueryData.Area,
  8963. dirLandQueryPacket.QueryData.QueryStart);
  8964. }
  8965. return true;
  8966. }
  8967. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8968. {
  8969. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8970. #region Packet Session and User Check
  8971. if (m_checkPackets)
  8972. {
  8973. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8974. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8975. return true;
  8976. }
  8977. #endregion
  8978. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8979. if (handlerDirPopularQuery != null)
  8980. {
  8981. handlerDirPopularQuery(this,
  8982. dirPopularQueryPacket.QueryData.QueryID,
  8983. dirPopularQueryPacket.QueryData.QueryFlags);
  8984. }
  8985. return true;
  8986. }
  8987. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8988. {
  8989. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8990. #region Packet Session and User Check
  8991. if (m_checkPackets)
  8992. {
  8993. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8994. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8995. return true;
  8996. }
  8997. #endregion
  8998. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8999. if (handlerDirClassifiedQuery != null)
  9000. {
  9001. handlerDirClassifiedQuery(this,
  9002. dirClassifiedQueryPacket.QueryData.QueryID,
  9003. Utils.BytesToString(
  9004. dirClassifiedQueryPacket.QueryData.QueryText),
  9005. dirClassifiedQueryPacket.QueryData.QueryFlags,
  9006. dirClassifiedQueryPacket.QueryData.Category,
  9007. dirClassifiedQueryPacket.QueryData.QueryStart);
  9008. }
  9009. return true;
  9010. }
  9011. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  9012. {
  9013. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  9014. #region Packet Session and User Check
  9015. if (m_checkPackets)
  9016. {
  9017. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9018. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9019. return true;
  9020. }
  9021. #endregion
  9022. if (OnEventInfoRequest != null)
  9023. {
  9024. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9025. }
  9026. return true;
  9027. }
  9028. #endregion
  9029. #region Calling Card
  9030. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9031. {
  9032. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9033. #region Packet Session and User Check
  9034. if (m_checkPackets)
  9035. {
  9036. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9037. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9038. return true;
  9039. }
  9040. #endregion
  9041. if (OnOfferCallingCard != null)
  9042. {
  9043. OnOfferCallingCard(this,
  9044. offerCallingCardPacket.AgentBlock.DestID,
  9045. offerCallingCardPacket.AgentBlock.TransactionID);
  9046. }
  9047. return true;
  9048. }
  9049. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9050. {
  9051. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9052. #region Packet Session and User Check
  9053. if (m_checkPackets)
  9054. {
  9055. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9056. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9057. return true;
  9058. }
  9059. #endregion
  9060. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9061. // contain exactly one entry
  9062. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9063. {
  9064. OnAcceptCallingCard(this,
  9065. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9066. acceptCallingCardPacket.FolderData[0].FolderID);
  9067. }
  9068. return true;
  9069. }
  9070. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9071. {
  9072. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9073. #region Packet Session and User Check
  9074. if (m_checkPackets)
  9075. {
  9076. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9077. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9078. return true;
  9079. }
  9080. #endregion
  9081. if (OnDeclineCallingCard != null)
  9082. {
  9083. OnDeclineCallingCard(this,
  9084. declineCallingCardPacket.TransactionBlock.TransactionID);
  9085. }
  9086. return true;
  9087. }
  9088. #endregion Calling Card
  9089. #region Groups
  9090. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9091. {
  9092. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9093. #region Packet Session and User Check
  9094. if (m_checkPackets)
  9095. {
  9096. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9097. activateGroupPacket.AgentData.AgentID != AgentId)
  9098. return true;
  9099. }
  9100. #endregion
  9101. if (m_GroupsModule != null)
  9102. {
  9103. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9104. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9105. }
  9106. return true;
  9107. }
  9108. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9109. {
  9110. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9111. (GroupVoteHistoryRequestPacket)Packet;
  9112. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9113. if (handlerGroupVoteHistoryRequest != null)
  9114. {
  9115. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9116. return true;
  9117. }
  9118. return false;
  9119. }
  9120. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9121. {
  9122. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9123. (GroupActiveProposalsRequestPacket)Packet;
  9124. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9125. if (handlerGroupActiveProposalsRequest != null)
  9126. {
  9127. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9128. return true;
  9129. }
  9130. return false;
  9131. }
  9132. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9133. {
  9134. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9135. (GroupAccountDetailsRequestPacket)Packet;
  9136. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9137. if (handlerGroupAccountDetailsRequest != null)
  9138. {
  9139. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9140. return true;
  9141. }
  9142. return false;
  9143. }
  9144. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9145. {
  9146. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9147. (GroupAccountSummaryRequestPacket)Packet;
  9148. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9149. if (handlerGroupAccountSummaryRequest != null)
  9150. {
  9151. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9152. return true;
  9153. }
  9154. return false;
  9155. }
  9156. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9157. {
  9158. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9159. (GroupAccountTransactionsRequestPacket)Packet;
  9160. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9161. if (handlerGroupAccountTransactionsRequest != null)
  9162. {
  9163. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9164. return true;
  9165. }
  9166. return false;
  9167. }
  9168. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9169. {
  9170. GroupTitlesRequestPacket groupTitlesRequest =
  9171. (GroupTitlesRequestPacket)Pack;
  9172. #region Packet Session and User Check
  9173. if (m_checkPackets)
  9174. {
  9175. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9176. groupTitlesRequest.AgentData.AgentID != AgentId)
  9177. return true;
  9178. }
  9179. #endregion
  9180. if (m_GroupsModule != null)
  9181. {
  9182. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9183. groupTitlesReply.AgentData =
  9184. new GroupTitlesReplyPacket.AgentDataBlock();
  9185. groupTitlesReply.AgentData.AgentID = AgentId;
  9186. groupTitlesReply.AgentData.GroupID =
  9187. groupTitlesRequest.AgentData.GroupID;
  9188. groupTitlesReply.AgentData.RequestID =
  9189. groupTitlesRequest.AgentData.RequestID;
  9190. List<GroupTitlesData> titles =
  9191. m_GroupsModule.GroupTitlesRequest(this,
  9192. groupTitlesRequest.AgentData.GroupID);
  9193. groupTitlesReply.GroupData =
  9194. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9195. int i = 0;
  9196. foreach (GroupTitlesData d in titles)
  9197. {
  9198. groupTitlesReply.GroupData[i] =
  9199. new GroupTitlesReplyPacket.GroupDataBlock();
  9200. groupTitlesReply.GroupData[i].Title =
  9201. Util.StringToBytes256(d.Name);
  9202. groupTitlesReply.GroupData[i].RoleID =
  9203. d.UUID;
  9204. groupTitlesReply.GroupData[i].Selected =
  9205. d.Selected;
  9206. i++;
  9207. }
  9208. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9209. }
  9210. return true;
  9211. }
  9212. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9213. {
  9214. GroupProfileRequestPacket groupProfileRequest =
  9215. (GroupProfileRequestPacket)Pack;
  9216. #region Packet Session and User Check
  9217. if (m_checkPackets)
  9218. {
  9219. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9220. groupProfileRequest.AgentData.AgentID != AgentId)
  9221. return true;
  9222. }
  9223. #endregion
  9224. if (m_GroupsModule != null)
  9225. {
  9226. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9227. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9228. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9229. groupProfileReply.AgentData.AgentID = AgentId;
  9230. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9231. groupProfileRequest.GroupData.GroupID);
  9232. groupProfileReply.GroupData.GroupID = d.GroupID;
  9233. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9234. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9235. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9236. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9237. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9238. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9239. groupProfileReply.GroupData.FounderID = d.FounderID;
  9240. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9241. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9242. groupProfileReply.GroupData.Money = d.Money;
  9243. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9244. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9245. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9246. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9247. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9248. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9249. }
  9250. return true;
  9251. }
  9252. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9253. {
  9254. GroupMembersRequestPacket groupMembersRequestPacket =
  9255. (GroupMembersRequestPacket)Pack;
  9256. #region Packet Session and User Check
  9257. if (m_checkPackets)
  9258. {
  9259. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9260. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9261. return true;
  9262. }
  9263. #endregion
  9264. if (m_GroupsModule != null)
  9265. {
  9266. List<GroupMembersData> members =
  9267. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9268. int memberCount = members.Count;
  9269. while (true)
  9270. {
  9271. int blockCount = members.Count;
  9272. if (blockCount > 40)
  9273. blockCount = 40;
  9274. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9275. groupMembersReply.AgentData =
  9276. new GroupMembersReplyPacket.AgentDataBlock();
  9277. groupMembersReply.GroupData =
  9278. new GroupMembersReplyPacket.GroupDataBlock();
  9279. groupMembersReply.MemberData =
  9280. new GroupMembersReplyPacket.MemberDataBlock[
  9281. blockCount];
  9282. groupMembersReply.AgentData.AgentID = AgentId;
  9283. groupMembersReply.GroupData.GroupID =
  9284. groupMembersRequestPacket.GroupData.GroupID;
  9285. groupMembersReply.GroupData.RequestID =
  9286. groupMembersRequestPacket.GroupData.RequestID;
  9287. groupMembersReply.GroupData.MemberCount = memberCount;
  9288. for (int i = 0; i < blockCount; i++)
  9289. {
  9290. GroupMembersData m = members[0];
  9291. members.RemoveAt(0);
  9292. groupMembersReply.MemberData[i] =
  9293. new GroupMembersReplyPacket.MemberDataBlock();
  9294. groupMembersReply.MemberData[i].AgentID =
  9295. m.AgentID;
  9296. groupMembersReply.MemberData[i].Contribution =
  9297. m.Contribution;
  9298. groupMembersReply.MemberData[i].OnlineStatus =
  9299. Util.StringToBytes256(m.OnlineStatus);
  9300. groupMembersReply.MemberData[i].AgentPowers =
  9301. m.AgentPowers;
  9302. groupMembersReply.MemberData[i].Title =
  9303. Util.StringToBytes256(m.Title);
  9304. groupMembersReply.MemberData[i].IsOwner =
  9305. m.IsOwner;
  9306. }
  9307. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9308. if (members.Count == 0)
  9309. return true;
  9310. }
  9311. }
  9312. return true;
  9313. }
  9314. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9315. {
  9316. GroupRoleDataRequestPacket groupRolesRequest =
  9317. (GroupRoleDataRequestPacket)Pack;
  9318. #region Packet Session and User Check
  9319. if (m_checkPackets)
  9320. {
  9321. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9322. groupRolesRequest.AgentData.AgentID != AgentId)
  9323. return true;
  9324. }
  9325. #endregion
  9326. if (m_GroupsModule != null)
  9327. {
  9328. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9329. groupRolesReply.AgentData =
  9330. new GroupRoleDataReplyPacket.AgentDataBlock();
  9331. groupRolesReply.AgentData.AgentID = AgentId;
  9332. groupRolesReply.GroupData =
  9333. new GroupRoleDataReplyPacket.GroupDataBlock();
  9334. groupRolesReply.GroupData.GroupID =
  9335. groupRolesRequest.GroupData.GroupID;
  9336. groupRolesReply.GroupData.RequestID =
  9337. groupRolesRequest.GroupData.RequestID;
  9338. List<GroupRolesData> titles =
  9339. m_GroupsModule.GroupRoleDataRequest(this,
  9340. groupRolesRequest.GroupData.GroupID);
  9341. groupRolesReply.GroupData.RoleCount =
  9342. titles.Count;
  9343. groupRolesReply.RoleData =
  9344. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9345. int i = 0;
  9346. foreach (GroupRolesData d in titles)
  9347. {
  9348. groupRolesReply.RoleData[i] =
  9349. new GroupRoleDataReplyPacket.RoleDataBlock();
  9350. groupRolesReply.RoleData[i].RoleID =
  9351. d.RoleID;
  9352. groupRolesReply.RoleData[i].Name =
  9353. Util.StringToBytes256(d.Name);
  9354. groupRolesReply.RoleData[i].Title =
  9355. Util.StringToBytes256(d.Title);
  9356. groupRolesReply.RoleData[i].Description =
  9357. Util.StringToBytes1024(d.Description);
  9358. groupRolesReply.RoleData[i].Powers =
  9359. d.Powers;
  9360. groupRolesReply.RoleData[i].Members =
  9361. (uint)d.Members;
  9362. i++;
  9363. }
  9364. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9365. }
  9366. return true;
  9367. }
  9368. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9369. {
  9370. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9371. (GroupRoleMembersRequestPacket)Pack;
  9372. #region Packet Session and User Check
  9373. if (m_checkPackets)
  9374. {
  9375. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9376. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9377. return true;
  9378. }
  9379. #endregion
  9380. if (m_GroupsModule != null)
  9381. {
  9382. List<GroupRoleMembersData> mappings =
  9383. m_GroupsModule.GroupRoleMembersRequest(this,
  9384. groupRoleMembersRequest.GroupData.GroupID);
  9385. int mappingsCount = mappings.Count;
  9386. while (mappings.Count > 0)
  9387. {
  9388. int pairs = mappings.Count;
  9389. if (pairs > 32)
  9390. pairs = 32;
  9391. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9392. groupRoleMembersReply.AgentData =
  9393. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9394. groupRoleMembersReply.AgentData.AgentID =
  9395. AgentId;
  9396. groupRoleMembersReply.AgentData.GroupID =
  9397. groupRoleMembersRequest.GroupData.GroupID;
  9398. groupRoleMembersReply.AgentData.RequestID =
  9399. groupRoleMembersRequest.GroupData.RequestID;
  9400. groupRoleMembersReply.AgentData.TotalPairs =
  9401. (uint)mappingsCount;
  9402. groupRoleMembersReply.MemberData =
  9403. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9404. for (int i = 0; i < pairs; i++)
  9405. {
  9406. GroupRoleMembersData d = mappings[0];
  9407. mappings.RemoveAt(0);
  9408. groupRoleMembersReply.MemberData[i] =
  9409. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9410. groupRoleMembersReply.MemberData[i].RoleID =
  9411. d.RoleID;
  9412. groupRoleMembersReply.MemberData[i].MemberID =
  9413. d.MemberID;
  9414. }
  9415. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9416. }
  9417. }
  9418. return true;
  9419. }
  9420. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9421. {
  9422. CreateGroupRequestPacket createGroupRequest =
  9423. (CreateGroupRequestPacket)Pack;
  9424. #region Packet Session and User Check
  9425. if (m_checkPackets)
  9426. {
  9427. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9428. createGroupRequest.AgentData.AgentID != AgentId)
  9429. return true;
  9430. }
  9431. #endregion
  9432. if (m_GroupsModule != null)
  9433. {
  9434. m_GroupsModule.CreateGroup(this,
  9435. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9436. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9437. createGroupRequest.GroupData.ShowInList,
  9438. createGroupRequest.GroupData.InsigniaID,
  9439. createGroupRequest.GroupData.MembershipFee,
  9440. createGroupRequest.GroupData.OpenEnrollment,
  9441. createGroupRequest.GroupData.AllowPublish,
  9442. createGroupRequest.GroupData.MaturePublish);
  9443. }
  9444. return true;
  9445. }
  9446. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9447. {
  9448. UpdateGroupInfoPacket updateGroupInfo =
  9449. (UpdateGroupInfoPacket)Pack;
  9450. #region Packet Session and User Check
  9451. if (m_checkPackets)
  9452. {
  9453. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9454. updateGroupInfo.AgentData.AgentID != AgentId)
  9455. return true;
  9456. }
  9457. #endregion
  9458. if (m_GroupsModule != null)
  9459. {
  9460. m_GroupsModule.UpdateGroupInfo(this,
  9461. updateGroupInfo.GroupData.GroupID,
  9462. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9463. updateGroupInfo.GroupData.ShowInList,
  9464. updateGroupInfo.GroupData.InsigniaID,
  9465. updateGroupInfo.GroupData.MembershipFee,
  9466. updateGroupInfo.GroupData.OpenEnrollment,
  9467. updateGroupInfo.GroupData.AllowPublish,
  9468. updateGroupInfo.GroupData.MaturePublish);
  9469. }
  9470. return true;
  9471. }
  9472. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9473. {
  9474. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9475. (SetGroupAcceptNoticesPacket)Pack;
  9476. #region Packet Session and User Check
  9477. if (m_checkPackets)
  9478. {
  9479. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9480. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9481. return true;
  9482. }
  9483. #endregion
  9484. if (m_GroupsModule != null)
  9485. {
  9486. m_GroupsModule.SetGroupAcceptNotices(this,
  9487. setGroupAcceptNotices.Data.GroupID,
  9488. setGroupAcceptNotices.Data.AcceptNotices,
  9489. setGroupAcceptNotices.NewData.ListInProfile);
  9490. }
  9491. return true;
  9492. }
  9493. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9494. {
  9495. GroupTitleUpdatePacket groupTitleUpdate =
  9496. (GroupTitleUpdatePacket)Pack;
  9497. #region Packet Session and User Check
  9498. if (m_checkPackets)
  9499. {
  9500. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9501. groupTitleUpdate.AgentData.AgentID != AgentId)
  9502. return true;
  9503. }
  9504. #endregion
  9505. if (m_GroupsModule != null)
  9506. {
  9507. m_GroupsModule.GroupTitleUpdate(this,
  9508. groupTitleUpdate.AgentData.GroupID,
  9509. groupTitleUpdate.AgentData.TitleRoleID);
  9510. }
  9511. return true;
  9512. }
  9513. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9514. {
  9515. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9516. if (m_GroupsModule != null)
  9517. {
  9518. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9519. if (handlerParcelDeedToGroup != null)
  9520. {
  9521. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9522. }
  9523. }
  9524. return true;
  9525. }
  9526. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9527. {
  9528. GroupNoticesListRequestPacket groupNoticesListRequest =
  9529. (GroupNoticesListRequestPacket)Pack;
  9530. #region Packet Session and User Check
  9531. if (m_checkPackets)
  9532. {
  9533. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9534. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9535. return true;
  9536. }
  9537. #endregion
  9538. if (m_GroupsModule != null)
  9539. {
  9540. GroupNoticeData[] gn =
  9541. m_GroupsModule.GroupNoticesListRequest(this,
  9542. groupNoticesListRequest.Data.GroupID);
  9543. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9544. groupNoticesListReply.AgentData =
  9545. new GroupNoticesListReplyPacket.AgentDataBlock();
  9546. groupNoticesListReply.AgentData.AgentID = AgentId;
  9547. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9548. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9549. int i = 0;
  9550. foreach (GroupNoticeData g in gn)
  9551. {
  9552. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9553. groupNoticesListReply.Data[i].NoticeID =
  9554. g.NoticeID;
  9555. groupNoticesListReply.Data[i].Timestamp =
  9556. g.Timestamp;
  9557. groupNoticesListReply.Data[i].FromName =
  9558. Util.StringToBytes256(g.FromName);
  9559. groupNoticesListReply.Data[i].Subject =
  9560. Util.StringToBytes256(g.Subject);
  9561. groupNoticesListReply.Data[i].HasAttachment =
  9562. g.HasAttachment;
  9563. groupNoticesListReply.Data[i].AssetType =
  9564. g.AssetType;
  9565. i++;
  9566. }
  9567. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9568. }
  9569. return true;
  9570. }
  9571. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9572. {
  9573. GroupNoticeRequestPacket groupNoticeRequest =
  9574. (GroupNoticeRequestPacket)Pack;
  9575. #region Packet Session and User Check
  9576. if (m_checkPackets)
  9577. {
  9578. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9579. groupNoticeRequest.AgentData.AgentID != AgentId)
  9580. return true;
  9581. }
  9582. #endregion
  9583. if (m_GroupsModule != null)
  9584. {
  9585. m_GroupsModule.GroupNoticeRequest(this,
  9586. groupNoticeRequest.Data.GroupNoticeID);
  9587. }
  9588. return true;
  9589. }
  9590. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9591. {
  9592. GroupRoleUpdatePacket groupRoleUpdate =
  9593. (GroupRoleUpdatePacket)Pack;
  9594. #region Packet Session and User Check
  9595. if (m_checkPackets)
  9596. {
  9597. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9598. groupRoleUpdate.AgentData.AgentID != AgentId)
  9599. return true;
  9600. }
  9601. #endregion
  9602. if (m_GroupsModule != null)
  9603. {
  9604. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9605. groupRoleUpdate.RoleData)
  9606. {
  9607. m_GroupsModule.GroupRoleUpdate(this,
  9608. groupRoleUpdate.AgentData.GroupID,
  9609. d.RoleID,
  9610. Utils.BytesToString(d.Name),
  9611. Utils.BytesToString(d.Description),
  9612. Utils.BytesToString(d.Title),
  9613. d.Powers,
  9614. d.UpdateType);
  9615. }
  9616. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9617. }
  9618. return true;
  9619. }
  9620. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9621. {
  9622. GroupRoleChangesPacket groupRoleChanges =
  9623. (GroupRoleChangesPacket)Pack;
  9624. #region Packet Session and User Check
  9625. if (m_checkPackets)
  9626. {
  9627. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9628. groupRoleChanges.AgentData.AgentID != AgentId)
  9629. return true;
  9630. }
  9631. #endregion
  9632. if (m_GroupsModule != null)
  9633. {
  9634. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9635. groupRoleChanges.RoleChange)
  9636. {
  9637. m_GroupsModule.GroupRoleChanges(this,
  9638. groupRoleChanges.AgentData.GroupID,
  9639. d.RoleID,
  9640. d.MemberID,
  9641. d.Change);
  9642. }
  9643. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9644. }
  9645. return true;
  9646. }
  9647. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9648. {
  9649. JoinGroupRequestPacket joinGroupRequest =
  9650. (JoinGroupRequestPacket)Pack;
  9651. #region Packet Session and User Check
  9652. if (m_checkPackets)
  9653. {
  9654. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9655. joinGroupRequest.AgentData.AgentID != AgentId)
  9656. return true;
  9657. }
  9658. #endregion
  9659. if (m_GroupsModule != null)
  9660. {
  9661. m_GroupsModule.JoinGroupRequest(this,
  9662. joinGroupRequest.GroupData.GroupID);
  9663. }
  9664. return true;
  9665. }
  9666. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9667. {
  9668. LeaveGroupRequestPacket leaveGroupRequest =
  9669. (LeaveGroupRequestPacket)Pack;
  9670. #region Packet Session and User Check
  9671. if (m_checkPackets)
  9672. {
  9673. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9674. leaveGroupRequest.AgentData.AgentID != AgentId)
  9675. return true;
  9676. }
  9677. #endregion
  9678. if (m_GroupsModule != null)
  9679. {
  9680. m_GroupsModule.LeaveGroupRequest(this,
  9681. leaveGroupRequest.GroupData.GroupID);
  9682. }
  9683. return true;
  9684. }
  9685. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9686. {
  9687. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9688. (EjectGroupMemberRequestPacket)Pack;
  9689. #region Packet Session and User Check
  9690. if (m_checkPackets)
  9691. {
  9692. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9693. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9694. return true;
  9695. }
  9696. #endregion
  9697. if (m_GroupsModule != null)
  9698. {
  9699. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9700. in ejectGroupMemberRequest.EjectData)
  9701. {
  9702. m_GroupsModule.EjectGroupMemberRequest(this,
  9703. ejectGroupMemberRequest.GroupData.GroupID,
  9704. e.EjecteeID);
  9705. }
  9706. }
  9707. return true;
  9708. }
  9709. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9710. {
  9711. InviteGroupRequestPacket inviteGroupRequest =
  9712. (InviteGroupRequestPacket)Pack;
  9713. #region Packet Session and User Check
  9714. if (m_checkPackets)
  9715. {
  9716. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9717. inviteGroupRequest.AgentData.AgentID != AgentId)
  9718. return true;
  9719. }
  9720. #endregion
  9721. if (m_GroupsModule != null)
  9722. {
  9723. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9724. inviteGroupRequest.InviteData)
  9725. {
  9726. m_GroupsModule.InviteGroupRequest(this,
  9727. inviteGroupRequest.GroupData.GroupID,
  9728. b.InviteeID,
  9729. b.RoleID);
  9730. }
  9731. }
  9732. return true;
  9733. }
  9734. #endregion Groups
  9735. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9736. {
  9737. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9738. #region Packet Session and User Check
  9739. if (m_checkPackets)
  9740. {
  9741. if (startLureRequest.AgentData.SessionID != SessionId ||
  9742. startLureRequest.AgentData.AgentID != AgentId)
  9743. return true;
  9744. }
  9745. #endregion
  9746. StartLure handlerStartLure = OnStartLure;
  9747. if (handlerStartLure != null)
  9748. handlerStartLure(startLureRequest.Info.LureType,
  9749. Utils.BytesToString(
  9750. startLureRequest.Info.Message),
  9751. startLureRequest.TargetData[0].TargetID,
  9752. this);
  9753. return true;
  9754. }
  9755. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9756. {
  9757. TeleportLureRequestPacket teleportLureRequest =
  9758. (TeleportLureRequestPacket)Pack;
  9759. #region Packet Session and User Check
  9760. if (m_checkPackets)
  9761. {
  9762. if (teleportLureRequest.Info.SessionID != SessionId ||
  9763. teleportLureRequest.Info.AgentID != AgentId)
  9764. return true;
  9765. }
  9766. #endregion
  9767. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9768. if (handlerTeleportLureRequest != null)
  9769. handlerTeleportLureRequest(
  9770. teleportLureRequest.Info.LureID,
  9771. teleportLureRequest.Info.TeleportFlags,
  9772. this);
  9773. return true;
  9774. }
  9775. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9776. {
  9777. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9778. (ClassifiedInfoRequestPacket)Pack;
  9779. #region Packet Session and User Check
  9780. if (m_checkPackets)
  9781. {
  9782. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9783. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9784. return true;
  9785. }
  9786. #endregion
  9787. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9788. if (handlerClassifiedInfoRequest != null)
  9789. handlerClassifiedInfoRequest(
  9790. classifiedInfoRequest.Data.ClassifiedID,
  9791. this);
  9792. return true;
  9793. }
  9794. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9795. {
  9796. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9797. (ClassifiedInfoUpdatePacket)Pack;
  9798. #region Packet Session and User Check
  9799. if (m_checkPackets)
  9800. {
  9801. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9802. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9803. return true;
  9804. }
  9805. #endregion
  9806. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9807. if (handlerClassifiedInfoUpdate != null)
  9808. handlerClassifiedInfoUpdate(
  9809. classifiedInfoUpdate.Data.ClassifiedID,
  9810. classifiedInfoUpdate.Data.Category,
  9811. Utils.BytesToString(
  9812. classifiedInfoUpdate.Data.Name),
  9813. Utils.BytesToString(
  9814. classifiedInfoUpdate.Data.Desc),
  9815. classifiedInfoUpdate.Data.ParcelID,
  9816. classifiedInfoUpdate.Data.ParentEstate,
  9817. classifiedInfoUpdate.Data.SnapshotID,
  9818. new Vector3(
  9819. classifiedInfoUpdate.Data.PosGlobal),
  9820. classifiedInfoUpdate.Data.ClassifiedFlags,
  9821. classifiedInfoUpdate.Data.PriceForListing,
  9822. this);
  9823. return true;
  9824. }
  9825. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9826. {
  9827. ClassifiedDeletePacket classifiedDelete =
  9828. (ClassifiedDeletePacket)Pack;
  9829. #region Packet Session and User Check
  9830. if (m_checkPackets)
  9831. {
  9832. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9833. classifiedDelete.AgentData.AgentID != AgentId)
  9834. return true;
  9835. }
  9836. #endregion
  9837. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9838. if (handlerClassifiedDelete != null)
  9839. handlerClassifiedDelete(
  9840. classifiedDelete.Data.ClassifiedID,
  9841. this);
  9842. return true;
  9843. }
  9844. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9845. {
  9846. ClassifiedGodDeletePacket classifiedGodDelete =
  9847. (ClassifiedGodDeletePacket)Pack;
  9848. #region Packet Session and User Check
  9849. if (m_checkPackets)
  9850. {
  9851. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9852. classifiedGodDelete.AgentData.AgentID != AgentId)
  9853. return true;
  9854. }
  9855. #endregion
  9856. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9857. if (handlerClassifiedGodDelete != null)
  9858. handlerClassifiedGodDelete(
  9859. classifiedGodDelete.Data.ClassifiedID,
  9860. this);
  9861. return true;
  9862. }
  9863. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9864. {
  9865. EventGodDeletePacket eventGodDelete =
  9866. (EventGodDeletePacket)Pack;
  9867. #region Packet Session and User Check
  9868. if (m_checkPackets)
  9869. {
  9870. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9871. eventGodDelete.AgentData.AgentID != AgentId)
  9872. return true;
  9873. }
  9874. #endregion
  9875. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9876. if (handlerEventGodDelete != null)
  9877. handlerEventGodDelete(
  9878. eventGodDelete.EventData.EventID,
  9879. eventGodDelete.QueryData.QueryID,
  9880. Utils.BytesToString(
  9881. eventGodDelete.QueryData.QueryText),
  9882. eventGodDelete.QueryData.QueryFlags,
  9883. eventGodDelete.QueryData.QueryStart,
  9884. this);
  9885. return true;
  9886. }
  9887. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9888. {
  9889. EventNotificationAddRequestPacket eventNotificationAdd =
  9890. (EventNotificationAddRequestPacket)Pack;
  9891. #region Packet Session and User Check
  9892. if (m_checkPackets)
  9893. {
  9894. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9895. eventNotificationAdd.AgentData.AgentID != AgentId)
  9896. return true;
  9897. }
  9898. #endregion
  9899. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9900. if (handlerEventNotificationAddRequest != null)
  9901. handlerEventNotificationAddRequest(
  9902. eventNotificationAdd.EventData.EventID, this);
  9903. return true;
  9904. }
  9905. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9906. {
  9907. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9908. (EventNotificationRemoveRequestPacket)Pack;
  9909. #region Packet Session and User Check
  9910. if (m_checkPackets)
  9911. {
  9912. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9913. eventNotificationRemove.AgentData.AgentID != AgentId)
  9914. return true;
  9915. }
  9916. #endregion
  9917. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9918. if (handlerEventNotificationRemoveRequest != null)
  9919. handlerEventNotificationRemoveRequest(
  9920. eventNotificationRemove.EventData.EventID, this);
  9921. return true;
  9922. }
  9923. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9924. {
  9925. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9926. #region Packet Session and User Check
  9927. if (m_checkPackets)
  9928. {
  9929. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9930. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9931. return true;
  9932. }
  9933. #endregion
  9934. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9935. if (handlerRetrieveInstantMessages != null)
  9936. handlerRetrieveInstantMessages(this);
  9937. return true;
  9938. }
  9939. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9940. {
  9941. PickDeletePacket pickDelete =
  9942. (PickDeletePacket)Pack;
  9943. #region Packet Session and User Check
  9944. if (m_checkPackets)
  9945. {
  9946. if (pickDelete.AgentData.SessionID != SessionId ||
  9947. pickDelete.AgentData.AgentID != AgentId)
  9948. return true;
  9949. }
  9950. #endregion
  9951. PickDelete handlerPickDelete = OnPickDelete;
  9952. if (handlerPickDelete != null)
  9953. handlerPickDelete(this, pickDelete.Data.PickID);
  9954. return true;
  9955. }
  9956. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9957. {
  9958. PickGodDeletePacket pickGodDelete =
  9959. (PickGodDeletePacket)Pack;
  9960. #region Packet Session and User Check
  9961. if (m_checkPackets)
  9962. {
  9963. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9964. pickGodDelete.AgentData.AgentID != AgentId)
  9965. return true;
  9966. }
  9967. #endregion
  9968. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9969. if (handlerPickGodDelete != null)
  9970. handlerPickGodDelete(this,
  9971. pickGodDelete.AgentData.AgentID,
  9972. pickGodDelete.Data.PickID,
  9973. pickGodDelete.Data.QueryID);
  9974. return true;
  9975. }
  9976. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9977. {
  9978. PickInfoUpdatePacket pickInfoUpdate =
  9979. (PickInfoUpdatePacket)Pack;
  9980. #region Packet Session and User Check
  9981. if (m_checkPackets)
  9982. {
  9983. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9984. pickInfoUpdate.AgentData.AgentID != AgentId)
  9985. return true;
  9986. }
  9987. #endregion
  9988. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9989. if (handlerPickInfoUpdate != null)
  9990. handlerPickInfoUpdate(this,
  9991. pickInfoUpdate.Data.PickID,
  9992. pickInfoUpdate.Data.CreatorID,
  9993. pickInfoUpdate.Data.TopPick,
  9994. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9995. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9996. pickInfoUpdate.Data.SnapshotID,
  9997. pickInfoUpdate.Data.SortOrder,
  9998. pickInfoUpdate.Data.Enabled);
  9999. return true;
  10000. }
  10001. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  10002. {
  10003. AvatarNotesUpdatePacket avatarNotesUpdate =
  10004. (AvatarNotesUpdatePacket)Pack;
  10005. #region Packet Session and User Check
  10006. if (m_checkPackets)
  10007. {
  10008. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  10009. avatarNotesUpdate.AgentData.AgentID != AgentId)
  10010. return true;
  10011. }
  10012. #endregion
  10013. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  10014. if (handlerAvatarNotesUpdate != null)
  10015. handlerAvatarNotesUpdate(this,
  10016. avatarNotesUpdate.Data.TargetID,
  10017. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10018. return true;
  10019. }
  10020. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10021. {
  10022. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10023. (AvatarInterestsUpdatePacket)Pack;
  10024. #region Packet Session and User Check
  10025. if (m_checkPackets)
  10026. {
  10027. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10028. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10029. return true;
  10030. }
  10031. #endregion
  10032. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10033. if (handlerAvatarInterestUpdate != null)
  10034. handlerAvatarInterestUpdate(this,
  10035. avatarInterestUpdate.PropertiesData.WantToMask,
  10036. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10037. avatarInterestUpdate.PropertiesData.SkillsMask,
  10038. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10039. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10040. return true;
  10041. }
  10042. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10043. {
  10044. GrantUserRightsPacket GrantUserRights =
  10045. (GrantUserRightsPacket)Pack;
  10046. #region Packet Session and User Check
  10047. if (m_checkPackets)
  10048. {
  10049. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10050. GrantUserRights.AgentData.AgentID != AgentId)
  10051. return true;
  10052. }
  10053. #endregion
  10054. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10055. if (GrantUserRightsHandler != null)
  10056. GrantUserRightsHandler(this,
  10057. GrantUserRights.Rights[0].AgentRelated,
  10058. GrantUserRights.Rights[0].RelatedRights);
  10059. return true;
  10060. }
  10061. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10062. {
  10063. PlacesQueryPacket placesQueryPacket =
  10064. (PlacesQueryPacket)Pack;
  10065. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10066. if (handlerPlacesQuery != null)
  10067. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10068. placesQueryPacket.TransactionData.TransactionID,
  10069. Utils.BytesToString(
  10070. placesQueryPacket.QueryData.QueryText),
  10071. placesQueryPacket.QueryData.QueryFlags,
  10072. (byte)placesQueryPacket.QueryData.Category,
  10073. Utils.BytesToString(
  10074. placesQueryPacket.QueryData.SimName),
  10075. this);
  10076. return true;
  10077. }
  10078. #endregion Packet Handlers
  10079. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10080. {
  10081. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10082. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10083. // TODO: don't create new blocks if recycling an old packet
  10084. scriptQuestion.Data.TaskID = taskID;
  10085. scriptQuestion.Data.ItemID = itemID;
  10086. scriptQuestion.Data.Questions = question;
  10087. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10088. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10089. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10090. }
  10091. /// <summary>
  10092. /// Handler called when we receive a logout packet.
  10093. /// </summary>
  10094. /// <param name="client"></param>
  10095. /// <param name="packet"></param>
  10096. /// <returns></returns>
  10097. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10098. {
  10099. if (packet.Type == PacketType.LogoutRequest)
  10100. {
  10101. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10102. }
  10103. return Logout(client);
  10104. }
  10105. /// <summary>
  10106. ///
  10107. /// </summary>
  10108. /// <param name="client"></param>
  10109. /// <returns></returns>
  10110. protected virtual bool Logout(IClientAPI client)
  10111. {
  10112. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10113. Action<IClientAPI> handlerLogout = OnLogout;
  10114. if (handlerLogout != null)
  10115. {
  10116. handlerLogout(client);
  10117. }
  10118. return true;
  10119. }
  10120. /// <summary>
  10121. /// </summary>
  10122. /// <remarks>
  10123. /// At the moment, we always reply that there is no cached texture.
  10124. /// </remarks>
  10125. /// <param name="simclient"></param>
  10126. /// <param name="packet"></param>
  10127. /// <returns></returns>
  10128. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10129. {
  10130. //m_log.Debug("texture cached: " + packet.ToString());
  10131. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10132. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10133. if (cachedtex.AgentData.SessionID != SessionId)
  10134. return false;
  10135. // TODO: don't create new blocks if recycling an old packet
  10136. cachedresp.AgentData.AgentID = AgentId;
  10137. cachedresp.AgentData.SessionID = m_sessionId;
  10138. cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
  10139. m_cachedTextureSerial++;
  10140. cachedresp.WearableData =
  10141. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  10142. //IAvatarFactoryModule fac = m_scene.RequestModuleInterface<IAvatarFactoryModule>();
  10143. // var item = fac.GetBakedTextureFaces(AgentId);
  10144. //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
  10145. IAssetService cache = m_scene.AssetService;
  10146. IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
  10147. //bakedTextureModule = null;
  10148. int maxWearablesLoop = cachedtex.WearableData.Length;
  10149. if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
  10150. maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
  10151. if (bakedTextureModule != null && cache != null)
  10152. {
  10153. // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
  10154. WearableCacheItem[] cacheItems = null;
  10155. ScenePresence p = m_scene.GetScenePresence(AgentId);
  10156. if (p.Appearance != null)
  10157. if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
  10158. {
  10159. try
  10160. {
  10161. cacheItems = bakedTextureModule.Get(AgentId);
  10162. p.Appearance.WearableCacheItems = cacheItems;
  10163. p.Appearance.WearableCacheItemsDirty = false;
  10164. }
  10165. /*
  10166. * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception!
  10167. *
  10168. catch (System.Net.Sockets.SocketException)
  10169. {
  10170. cacheItems = null;
  10171. }
  10172. catch (WebException)
  10173. {
  10174. cacheItems = null;
  10175. }
  10176. catch (InvalidOperationException)
  10177. {
  10178. cacheItems = null;
  10179. } */
  10180. catch (Exception)
  10181. {
  10182. cacheItems = null;
  10183. }
  10184. }
  10185. else if (p.Appearance.WearableCacheItems != null)
  10186. {
  10187. cacheItems = p.Appearance.WearableCacheItems;
  10188. }
  10189. if (cache != null && cacheItems != null)
  10190. {
  10191. foreach (WearableCacheItem item in cacheItems)
  10192. {
  10193. if (cache.GetCached(item.TextureID.ToString()) == null)
  10194. {
  10195. item.TextureAsset.Temporary = true;
  10196. cache.Store(item.TextureAsset);
  10197. }
  10198. }
  10199. }
  10200. if (cacheItems != null)
  10201. {
  10202. for (int i = 0; i < maxWearablesLoop; i++)
  10203. {
  10204. WearableCacheItem item =
  10205. WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
  10206. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10207. cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex;
  10208. cachedresp.WearableData[i].HostName = new byte[0];
  10209. if (item != null && cachedtex.WearableData[i].ID == item.CacheId)
  10210. {
  10211. cachedresp.WearableData[i].TextureID = item.TextureID;
  10212. }
  10213. else
  10214. {
  10215. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10216. }
  10217. }
  10218. }
  10219. else
  10220. {
  10221. for (int i = 0; i < maxWearablesLoop; i++)
  10222. {
  10223. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10224. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10225. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10226. //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
  10227. cachedresp.WearableData[i].HostName = new byte[0];
  10228. }
  10229. }
  10230. }
  10231. else
  10232. {
  10233. if (cache == null)
  10234. {
  10235. for (int i = 0; i < maxWearablesLoop; i++)
  10236. {
  10237. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10238. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10239. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10240. //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
  10241. cachedresp.WearableData[i].HostName = new byte[0];
  10242. }
  10243. }
  10244. else
  10245. {
  10246. for (int i = 0; i < maxWearablesLoop; i++)
  10247. {
  10248. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10249. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  10250. if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
  10251. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10252. //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
  10253. else
  10254. cachedresp.WearableData[i].TextureID = UUID.Zero;
  10255. // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
  10256. cachedresp.WearableData[i].HostName = new byte[0];
  10257. }
  10258. }
  10259. }
  10260. cachedresp.Header.Zerocoded = true;
  10261. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10262. return true;
  10263. }
  10264. /// <summary>
  10265. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10266. /// its appearance texture cached.
  10267. /// </summary>
  10268. /// <param name="avatar"></param>
  10269. /// <param name="serial"></param>
  10270. /// <param name="cachedTextures"></param>
  10271. /// <returns></returns>
  10272. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10273. {
  10274. ScenePresence presence = avatar as ScenePresence;
  10275. if (presence == null)
  10276. return;
  10277. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10278. // TODO: don't create new blocks if recycling an old packet
  10279. cachedresp.AgentData.AgentID = m_agentId;
  10280. cachedresp.AgentData.SessionID = m_sessionId;
  10281. cachedresp.AgentData.SerialNum = serial;
  10282. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10283. for (int i = 0; i < cachedTextures.Count; i++)
  10284. {
  10285. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10286. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10287. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10288. cachedresp.WearableData[i].HostName = new byte[0];
  10289. }
  10290. cachedresp.Header.Zerocoded = true;
  10291. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10292. }
  10293. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10294. {
  10295. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10296. if (multipleupdate.AgentData.SessionID != SessionId)
  10297. return false;
  10298. // m_log.DebugFormat(
  10299. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10300. Scene tScene = (Scene)m_scene;
  10301. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10302. {
  10303. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10304. // Can't act on Null Data
  10305. if (block.Data != null)
  10306. {
  10307. uint localId = block.ObjectLocalID;
  10308. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10309. if (part == null)
  10310. {
  10311. // It's a ghost! tell the client to delete it from view.
  10312. simClient.SendKillObject(new List<uint> { localId });
  10313. }
  10314. else
  10315. {
  10316. // m_log.DebugFormat(
  10317. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10318. // i, block.Type, part.Name, part.LocalId);
  10319. // // Do this once since fetch parts creates a new array.
  10320. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10321. // for (int j = 0; j < parts.Length; j++)
  10322. // {
  10323. // part.StoreUndoState();
  10324. // parts[j].IgnoreUndoUpdate = true;
  10325. // }
  10326. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10327. switch (block.Type)
  10328. {
  10329. case 1:
  10330. Vector3 pos1 = new Vector3(block.Data, 0);
  10331. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10332. if (handlerUpdatePrimSinglePosition != null)
  10333. {
  10334. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10335. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10336. }
  10337. break;
  10338. case 2:
  10339. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10340. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10341. if (handlerUpdatePrimSingleRotation != null)
  10342. {
  10343. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10344. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10345. }
  10346. break;
  10347. case 3:
  10348. Vector3 rotPos = new Vector3(block.Data, 0);
  10349. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10350. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10351. if (handlerUpdatePrimSingleRotationPosition != null)
  10352. {
  10353. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10354. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10355. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10356. }
  10357. break;
  10358. case 4:
  10359. case 20:
  10360. Vector3 scale4 = new Vector3(block.Data, 0);
  10361. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10362. if (handlerUpdatePrimScale != null)
  10363. {
  10364. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10365. handlerUpdatePrimScale(localId, scale4, this);
  10366. }
  10367. break;
  10368. case 5:
  10369. Vector3 scale1 = new Vector3(block.Data, 12);
  10370. Vector3 pos11 = new Vector3(block.Data, 0);
  10371. handlerUpdatePrimScale = OnUpdatePrimScale;
  10372. if (handlerUpdatePrimScale != null)
  10373. {
  10374. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10375. handlerUpdatePrimScale(localId, scale1, this);
  10376. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10377. if (handlerUpdatePrimSinglePosition != null)
  10378. {
  10379. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10380. }
  10381. }
  10382. break;
  10383. case 9:
  10384. Vector3 pos2 = new Vector3(block.Data, 0);
  10385. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10386. if (handlerUpdateVector != null)
  10387. {
  10388. handlerUpdateVector(localId, pos2, this);
  10389. }
  10390. break;
  10391. case 10:
  10392. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10393. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10394. if (handlerUpdatePrimRotation != null)
  10395. {
  10396. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10397. handlerUpdatePrimRotation(localId, rot3, this);
  10398. }
  10399. break;
  10400. case 11:
  10401. Vector3 pos3 = new Vector3(block.Data, 0);
  10402. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10403. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10404. if (handlerUpdatePrimGroupRotation != null)
  10405. {
  10406. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10407. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10408. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10409. }
  10410. break;
  10411. case 12:
  10412. case 28:
  10413. Vector3 scale7 = new Vector3(block.Data, 0);
  10414. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10415. if (handlerUpdatePrimGroupScale != null)
  10416. {
  10417. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10418. handlerUpdatePrimGroupScale(localId, scale7, this);
  10419. }
  10420. break;
  10421. case 13:
  10422. Vector3 scale2 = new Vector3(block.Data, 12);
  10423. Vector3 pos4 = new Vector3(block.Data, 0);
  10424. handlerUpdatePrimScale = OnUpdatePrimScale;
  10425. if (handlerUpdatePrimScale != null)
  10426. {
  10427. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10428. handlerUpdatePrimScale(localId, scale2, this);
  10429. // Change the position based on scale (for bug number 246)
  10430. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10431. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10432. if (handlerUpdatePrimSinglePosition != null)
  10433. {
  10434. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10435. }
  10436. }
  10437. break;
  10438. case 29:
  10439. Vector3 scale5 = new Vector3(block.Data, 12);
  10440. Vector3 pos5 = new Vector3(block.Data, 0);
  10441. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10442. if (handlerUpdatePrimGroupScale != null)
  10443. {
  10444. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10445. part.StoreUndoState(true);
  10446. part.IgnoreUndoUpdate = true;
  10447. handlerUpdatePrimGroupScale(localId, scale5, this);
  10448. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10449. if (handlerUpdateVector != null)
  10450. {
  10451. handlerUpdateVector(localId, pos5, this);
  10452. }
  10453. part.IgnoreUndoUpdate = false;
  10454. }
  10455. break;
  10456. case 21:
  10457. Vector3 scale6 = new Vector3(block.Data, 12);
  10458. Vector3 pos6 = new Vector3(block.Data, 0);
  10459. handlerUpdatePrimScale = OnUpdatePrimScale;
  10460. if (handlerUpdatePrimScale != null)
  10461. {
  10462. part.StoreUndoState(false);
  10463. part.IgnoreUndoUpdate = true;
  10464. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10465. handlerUpdatePrimScale(localId, scale6, this);
  10466. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10467. if (handlerUpdatePrimSinglePosition != null)
  10468. {
  10469. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10470. }
  10471. part.IgnoreUndoUpdate = false;
  10472. }
  10473. break;
  10474. default:
  10475. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10476. break;
  10477. }
  10478. // for (int j = 0; j < parts.Length; j++)
  10479. // parts[j].IgnoreUndoUpdate = false;
  10480. }
  10481. }
  10482. }
  10483. return true;
  10484. }
  10485. public void RequestMapLayer()
  10486. {
  10487. //should be getting the map layer from the grid server
  10488. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10489. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10490. // TODO: don't create new blocks if recycling an old packet
  10491. mapReply.AgentData.AgentID = AgentId;
  10492. mapReply.AgentData.Flags = 0;
  10493. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10494. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10495. mapReply.LayerData[0].Bottom = 0;
  10496. mapReply.LayerData[0].Left = 0;
  10497. mapReply.LayerData[0].Top = 30000;
  10498. mapReply.LayerData[0].Right = 30000;
  10499. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10500. mapReply.Header.Zerocoded = true;
  10501. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10502. }
  10503. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10504. {
  10505. /*
  10506. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10507. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10508. mbReply.AgentData.AgentId = AgentId;
  10509. int len;
  10510. if (simMapProfiles == null)
  10511. len = 0;
  10512. else
  10513. len = simMapProfiles.Count;
  10514. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10515. int iii;
  10516. for (iii = 0; iii < len; iii++)
  10517. {
  10518. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10519. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10520. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10521. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10522. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10523. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10524. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10525. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10526. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10527. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10528. }
  10529. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10530. */
  10531. }
  10532. /// <summary>
  10533. /// Sets the throttles from values supplied by the client
  10534. /// </summary>
  10535. /// <param name="throttles"></param>
  10536. public void SetChildAgentThrottle(byte[] throttles)
  10537. {
  10538. m_udpClient.SetThrottles(throttles);
  10539. }
  10540. /// <summary>
  10541. /// Get the current throttles for this client as a packed byte array
  10542. /// </summary>
  10543. /// <param name="multiplier">Unused</param>
  10544. /// <returns></returns>
  10545. public byte[] GetThrottlesPacked(float multiplier)
  10546. {
  10547. return m_udpClient.GetThrottlesPacked(multiplier);
  10548. }
  10549. /// <summary>
  10550. /// Cruft?
  10551. /// </summary>
  10552. public virtual void InPacket(object NewPack)
  10553. {
  10554. throw new NotImplementedException();
  10555. }
  10556. /// <summary>
  10557. /// This is the starting point for sending a simulator packet out to the client
  10558. /// </summary>
  10559. /// <param name="packet">Packet to send</param>
  10560. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10561. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10562. {
  10563. #region BinaryStats
  10564. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10565. #endregion BinaryStats
  10566. OutPacket(packet, throttlePacketType, true);
  10567. }
  10568. /// <summary>
  10569. /// This is the starting point for sending a simulator packet out to the client
  10570. /// </summary>
  10571. /// <param name="packet">Packet to send</param>
  10572. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10573. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10574. /// packets (the default), or false to disable splitting if the calling code
  10575. /// handles splitting manually</param>
  10576. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10577. {
  10578. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10579. }
  10580. /// <summary>
  10581. /// This is the starting point for sending a simulator packet out to the client
  10582. /// </summary>
  10583. /// <param name="packet">Packet to send</param>
  10584. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10585. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10586. /// packets (the default), or false to disable splitting if the calling code
  10587. /// handles splitting manually</param>
  10588. /// <param name="method">The method to be called in the event this packet is reliable
  10589. /// and unacknowledged. The server will provide normal resend capability if you do not
  10590. /// provide your own method.</param>
  10591. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10592. {
  10593. if (DebugPacketLevel > 0)
  10594. {
  10595. bool logPacket = true;
  10596. if (DebugPacketLevel <= 255
  10597. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10598. logPacket = false;
  10599. if (DebugPacketLevel <= 200
  10600. && (packet.Type == PacketType.ImagePacket
  10601. || packet.Type == PacketType.ImageData
  10602. || packet.Type == PacketType.LayerData
  10603. || packet.Type == PacketType.CoarseLocationUpdate))
  10604. logPacket = false;
  10605. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10606. logPacket = false;
  10607. if (DebugPacketLevel <= 50
  10608. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10609. logPacket = false;
  10610. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10611. logPacket = false;
  10612. if (logPacket)
  10613. m_log.DebugFormat(
  10614. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10615. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10616. }
  10617. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10618. }
  10619. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10620. {
  10621. float locx = 0;
  10622. float locy = 0;
  10623. float locz = 0;
  10624. uint regionX = 0;
  10625. uint regionY = 0;
  10626. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10627. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10628. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10629. locz = Convert.ToSingle(args[2]);
  10630. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10631. if (handlerAutoPilotGo != null)
  10632. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10633. }
  10634. /// <summary>
  10635. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10636. /// </summary>
  10637. /// <param name="Pack">OpenMetaverse.packet</param>
  10638. public void ProcessInPacket(Packet packet)
  10639. {
  10640. if (DebugPacketLevel > 0)
  10641. {
  10642. bool logPacket = true;
  10643. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10644. logPacket = false;
  10645. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10646. logPacket = false;
  10647. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10648. logPacket = false;
  10649. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10650. logPacket = false;
  10651. if (logPacket)
  10652. m_log.DebugFormat(
  10653. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10654. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10655. }
  10656. if (!ProcessPacketMethod(packet))
  10657. m_log.WarnFormat(
  10658. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10659. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10660. }
  10661. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10662. {
  10663. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10664. shape.PCode = addPacket.ObjectData.PCode;
  10665. shape.State = addPacket.ObjectData.State;
  10666. shape.LastAttachPoint = addPacket.ObjectData.State;
  10667. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10668. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10669. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10670. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10671. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10672. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10673. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10674. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10675. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10676. shape.Scale = addPacket.ObjectData.Scale;
  10677. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10678. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10679. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10680. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10681. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10682. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10683. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10684. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10685. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10686. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10687. shape.TextureEntry = ntex.GetBytes();
  10688. //shape.Textures = ntex;
  10689. return shape;
  10690. }
  10691. public ClientInfo GetClientInfo()
  10692. {
  10693. ClientInfo info = m_udpClient.GetClientInfo();
  10694. info.proxyEP = null;
  10695. if (info.agentcircuit == null)
  10696. info.agentcircuit = RequestClientInfo();
  10697. return info;
  10698. }
  10699. public void SetClientInfo(ClientInfo info)
  10700. {
  10701. m_udpClient.SetClientInfo(info);
  10702. }
  10703. #region Media Parcel Members
  10704. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10705. {
  10706. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10707. commandMessagePacket.CommandBlock.Flags = flags;
  10708. commandMessagePacket.CommandBlock.Command = (uint)command;
  10709. commandMessagePacket.CommandBlock.Time = time;
  10710. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10711. }
  10712. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10713. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10714. byte mediaLoop)
  10715. {
  10716. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10717. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10718. updatePacket.DataBlock.MediaID = mediaTextureID;
  10719. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10720. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10721. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10722. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10723. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10724. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10725. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10726. }
  10727. #endregion
  10728. #region Camera
  10729. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10730. {
  10731. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10732. packet.ObjectData.ObjectID = objectID;
  10733. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10734. uint idx = 0;
  10735. foreach (KeyValuePair<int, float> pair in parameters)
  10736. {
  10737. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10738. block.Type = pair.Key;
  10739. block.Value = pair.Value;
  10740. camPropBlock[idx++] = block;
  10741. }
  10742. packet.CameraProperty = camPropBlock;
  10743. OutPacket(packet, ThrottleOutPacketType.Task);
  10744. }
  10745. public void SendClearFollowCamProperties(UUID objectID)
  10746. {
  10747. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10748. packet.ObjectData.ObjectID = objectID;
  10749. OutPacket(packet, ThrottleOutPacketType.Task);
  10750. }
  10751. #endregion
  10752. public void SetClientOption(string option, string value)
  10753. {
  10754. switch (option)
  10755. {
  10756. default:
  10757. break;
  10758. }
  10759. }
  10760. public string GetClientOption(string option)
  10761. {
  10762. switch (option)
  10763. {
  10764. default:
  10765. break;
  10766. }
  10767. return string.Empty;
  10768. }
  10769. #region IClientCore
  10770. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10771. /// <summary>
  10772. /// Register an interface on this client, should only be called in the constructor.
  10773. /// </summary>
  10774. /// <typeparam name="T"></typeparam>
  10775. /// <param name="iface"></param>
  10776. protected void RegisterInterface<T>(T iface)
  10777. {
  10778. lock (m_clientInterfaces)
  10779. {
  10780. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10781. {
  10782. m_clientInterfaces.Add(typeof(T), iface);
  10783. }
  10784. }
  10785. }
  10786. public bool TryGet<T>(out T iface)
  10787. {
  10788. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10789. {
  10790. iface = (T)m_clientInterfaces[typeof(T)];
  10791. return true;
  10792. }
  10793. iface = default(T);
  10794. return false;
  10795. }
  10796. public T Get<T>()
  10797. {
  10798. return (T)m_clientInterfaces[typeof(T)];
  10799. }
  10800. public void Disconnect(string reason)
  10801. {
  10802. Kick(reason);
  10803. Thread.Sleep(1000);
  10804. Disconnect();
  10805. }
  10806. public void Disconnect()
  10807. {
  10808. Close();
  10809. }
  10810. #endregion
  10811. public void RefreshGroupMembership()
  10812. {
  10813. if (m_GroupsModule != null)
  10814. {
  10815. GroupMembershipData[] GroupMembership =
  10816. m_GroupsModule.GetMembershipData(AgentId);
  10817. m_groupPowers.Clear();
  10818. if (GroupMembership != null)
  10819. {
  10820. for (int i = 0; i < GroupMembership.Length; i++)
  10821. {
  10822. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10823. }
  10824. }
  10825. }
  10826. }
  10827. public string Report()
  10828. {
  10829. return m_udpClient.GetStats();
  10830. }
  10831. public string XReport(string uptime, string version)
  10832. {
  10833. return String.Empty;
  10834. }
  10835. public OSDMap OReport(string uptime, string version)
  10836. {
  10837. return new OSDMap();
  10838. }
  10839. /// <summary>
  10840. /// Make an asset request to the asset service in response to a client request.
  10841. /// </summary>
  10842. /// <param name="transferRequest"></param>
  10843. /// <param name="taskID"></param>
  10844. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10845. {
  10846. UUID requestID = UUID.Zero;
  10847. int sourceType = transferRequest.TransferInfo.SourceType;
  10848. if (sourceType == (int)SourceType.Asset)
  10849. {
  10850. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10851. }
  10852. else if (sourceType == (int)SourceType.SimInventoryItem)
  10853. {
  10854. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10855. }
  10856. else if (sourceType == (int)SourceType.SimEstate)
  10857. {
  10858. requestID = taskID;
  10859. }
  10860. // m_log.DebugFormat(
  10861. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10862. // requestID, taskID, (SourceType)sourceType, Name);
  10863. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10864. }
  10865. /// <summary>
  10866. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10867. /// </summary>
  10868. /// <param name="id"></param>
  10869. /// <param name="sender"></param>
  10870. /// <param name="asset"></param>
  10871. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10872. {
  10873. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10874. UUID requestID = UUID.Zero;
  10875. byte source = (byte)SourceType.Asset;
  10876. AssetRequestToClient req = new AssetRequestToClient();
  10877. if (asset == null)
  10878. {
  10879. req.AssetInf = null;
  10880. req.AssetRequestSource = source;
  10881. req.IsTextureRequest = false;
  10882. req.NumPackets = 0;
  10883. req.Params = transferRequest.TransferInfo.Params;
  10884. req.RequestAssetID = requestID;
  10885. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10886. SendAssetNotFound(req);
  10887. return;
  10888. }
  10889. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10890. {
  10891. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10892. }
  10893. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10894. {
  10895. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10896. source = (byte)SourceType.SimInventoryItem;
  10897. //m_log.Debug("asset request " + requestID);
  10898. }
  10899. // Scripts cannot be retrieved by direct request
  10900. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10901. return;
  10902. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10903. req.AssetInf = asset;
  10904. req.AssetRequestSource = source;
  10905. req.IsTextureRequest = false;
  10906. req.NumPackets = CalculateNumPackets(asset.Data);
  10907. req.Params = transferRequest.TransferInfo.Params;
  10908. req.RequestAssetID = requestID;
  10909. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10910. SendAsset(req);
  10911. }
  10912. /// <summary>
  10913. /// Calculate the number of packets required to send the asset to the client.
  10914. /// </summary>
  10915. /// <param name="data"></param>
  10916. /// <returns></returns>
  10917. private static int CalculateNumPackets(byte[] data)
  10918. {
  10919. const uint m_maxPacketSize = 600;
  10920. int numPackets = 1;
  10921. if (data == null)
  10922. return 0;
  10923. if (data.LongLength > m_maxPacketSize)
  10924. {
  10925. // over max number of bytes so split up file
  10926. long restData = data.LongLength - m_maxPacketSize;
  10927. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10928. numPackets += restPackets;
  10929. }
  10930. return numPackets;
  10931. }
  10932. public void SendRebakeAvatarTextures(UUID textureID)
  10933. {
  10934. RebakeAvatarTexturesPacket pack =
  10935. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10936. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10937. pack.TextureData.TextureID = textureID;
  10938. OutPacket(pack, ThrottleOutPacketType.Task);
  10939. }
  10940. public struct PacketProcessor
  10941. {
  10942. public PacketMethod method;
  10943. public bool Async;
  10944. }
  10945. public class AsyncPacketProcess
  10946. {
  10947. public bool result = false;
  10948. public readonly LLClientView ClientView = null;
  10949. public readonly Packet Pack = null;
  10950. public readonly PacketMethod Method = null;
  10951. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10952. {
  10953. ClientView = pClientview;
  10954. Method = pMethod;
  10955. Pack = pPack;
  10956. }
  10957. }
  10958. public static OSD BuildEvent(string eventName, OSD eventBody)
  10959. {
  10960. OSDMap osdEvent = new OSDMap(2);
  10961. osdEvent.Add("message", new OSDString(eventName));
  10962. osdEvent.Add("body", eventBody);
  10963. return osdEvent;
  10964. }
  10965. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10966. {
  10967. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10968. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10969. packet.AgentData.AgentID = AgentId;
  10970. packet.AgentData.AvatarID = avatarID;
  10971. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10972. packet.PropertiesData.WantToMask = wantMask;
  10973. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10974. packet.PropertiesData.SkillsMask = skillsMask;
  10975. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10976. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10977. OutPacket(packet, ThrottleOutPacketType.Task);
  10978. }
  10979. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10980. {
  10981. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10982. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10983. packet.AgentData.AgentID = agentID;
  10984. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10985. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10986. packet.Rights[0].AgentRelated = friendID;
  10987. packet.Rights[0].RelatedRights = rights;
  10988. OutPacket(packet, ThrottleOutPacketType.Task);
  10989. }
  10990. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10991. {
  10992. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10993. dialog.Data.ObjectID = objectId;
  10994. dialog.Data.ChatChannel = chatChannel;
  10995. dialog.Data.ImageID = UUID.Zero;
  10996. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10997. // this is the username of the *owner*
  10998. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10999. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  11000. dialog.Data.Message = Util.StringToBytes256(message);
  11001. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  11002. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  11003. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  11004. dialog.Buttons = buttons;
  11005. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  11006. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  11007. dialog.OwnerData[0].OwnerID = ownerID;
  11008. OutPacket(dialog, ThrottleOutPacketType.Task);
  11009. }
  11010. public void SendAgentTerseUpdate(ISceneEntity p)
  11011. {
  11012. if (p is ScenePresence)
  11013. {
  11014. // m_log.DebugFormat(
  11015. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  11016. // p.Name, Name, Scene.Name);
  11017. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  11018. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  11019. // velocity, collision plane and avatar height
  11020. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  11021. // when the avatar stands up
  11022. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  11023. CreateImprovedTerseBlock(p, false);
  11024. const float TIME_DILATION = 1.0f;
  11025. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  11026. ImprovedTerseObjectUpdatePacket packet
  11027. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  11028. PacketType.ImprovedTerseObjectUpdate);
  11029. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  11030. packet.RegionData.TimeDilation = timeDilation;
  11031. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  11032. packet.ObjectData[0] = block;
  11033. OutPacket(packet, ThrottleOutPacketType.Task, true);
  11034. }
  11035. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  11036. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  11037. }
  11038. public void SendPlacesReply(UUID queryID, UUID transactionID,
  11039. PlacesReplyData[] data)
  11040. {
  11041. PlacesReplyPacket reply = null;
  11042. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  11043. new PlacesReplyPacket.QueryDataBlock[0];
  11044. for (int i = 0 ; i < data.Length ; i++)
  11045. {
  11046. PlacesReplyPacket.QueryDataBlock block =
  11047. new PlacesReplyPacket.QueryDataBlock();
  11048. block.OwnerID = data[i].OwnerID;
  11049. block.Name = Util.StringToBytes256(data[i].Name);
  11050. block.Desc = Util.StringToBytes1024(data[i].Desc);
  11051. block.ActualArea = data[i].ActualArea;
  11052. block.BillableArea = data[i].BillableArea;
  11053. block.Flags = data[i].Flags;
  11054. block.GlobalX = data[i].GlobalX;
  11055. block.GlobalY = data[i].GlobalY;
  11056. block.GlobalZ = data[i].GlobalZ;
  11057. block.SimName = Util.StringToBytes256(data[i].SimName);
  11058. block.SnapshotID = data[i].SnapshotID;
  11059. block.Dwell = data[i].Dwell;
  11060. block.Price = data[i].Price;
  11061. if (reply != null && reply.Length + block.Length > 1400)
  11062. {
  11063. OutPacket(reply, ThrottleOutPacketType.Task);
  11064. reply = null;
  11065. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  11066. }
  11067. if (reply == null)
  11068. {
  11069. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  11070. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  11071. reply.AgentData.AgentID = AgentId;
  11072. reply.AgentData.QueryID = queryID;
  11073. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  11074. reply.TransactionData.TransactionID = transactionID;
  11075. reply.QueryData = dataBlocks;
  11076. }
  11077. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  11078. dataBlocks[dataBlocks.Length - 1] = block;
  11079. reply.QueryData = dataBlocks;
  11080. }
  11081. if (reply != null)
  11082. OutPacket(reply, ThrottleOutPacketType.Task);
  11083. }
  11084. public void SendRemoveInventoryItems(UUID[] items)
  11085. {
  11086. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11087. if (eq == null)
  11088. {
  11089. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11090. return;
  11091. }
  11092. OSDMap llsd = new OSDMap(3);
  11093. OSDMap AgentDataMap = new OSDMap(1);
  11094. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11095. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11096. OSDArray AgentData = new OSDArray(1);
  11097. AgentData.Add(AgentDataMap);
  11098. llsd.Add("AgentData", AgentData);
  11099. OSDArray ItemData = new OSDArray();
  11100. foreach (UUID item in items)
  11101. {
  11102. OSDMap ItemDataMap = new OSDMap(2);
  11103. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  11104. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11105. ItemData.Add(ItemDataMap);
  11106. }
  11107. llsd.Add("InventoryData", ItemData);
  11108. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  11109. llsd), AgentId);
  11110. }
  11111. public void SendRemoveInventoryFolders(UUID[] folders)
  11112. {
  11113. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11114. if (eq == null)
  11115. {
  11116. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11117. return;
  11118. }
  11119. OSDMap llsd = new OSDMap(3);
  11120. OSDMap AgentDataMap = new OSDMap(1);
  11121. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11122. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11123. OSDArray AgentData = new OSDArray(1);
  11124. AgentData.Add(AgentDataMap);
  11125. llsd.Add("AgentData", AgentData);
  11126. OSDArray FolderData = new OSDArray();
  11127. foreach (UUID folder in folders)
  11128. {
  11129. OSDMap FolderDataMap = new OSDMap(2);
  11130. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11131. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11132. FolderData.Add(FolderDataMap);
  11133. }
  11134. llsd.Add("FolderData", FolderData);
  11135. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11136. llsd), AgentId);
  11137. }
  11138. private byte[] EncodeU32(uint val)
  11139. {
  11140. byte[] ret = BitConverter.GetBytes(val);
  11141. if (BitConverter.IsLittleEndian)
  11142. Array.Reverse(ret);
  11143. return ret;
  11144. }
  11145. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11146. {
  11147. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11148. if (eq == null)
  11149. {
  11150. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11151. return;
  11152. }
  11153. OSDMap llsd = new OSDMap(3);
  11154. OSDMap AgentDataMap = new OSDMap(1);
  11155. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11156. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11157. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11158. OSDArray AgentData = new OSDArray(1);
  11159. AgentData.Add(AgentDataMap);
  11160. llsd.Add("AgentData", AgentData);
  11161. OSDArray FolderData = new OSDArray();
  11162. foreach (InventoryFolderBase folder in folders)
  11163. {
  11164. OSDMap FolderDataMap = new OSDMap(5);
  11165. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11166. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11167. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11168. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11169. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11170. FolderData.Add(FolderDataMap);
  11171. }
  11172. llsd.Add("FolderData", FolderData);
  11173. OSDArray ItemData = new OSDArray();
  11174. foreach (InventoryItemBase item in items)
  11175. {
  11176. OSDMap ItemDataMap = new OSDMap();
  11177. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11178. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11179. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11180. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11181. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11182. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11183. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11184. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11185. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11186. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11187. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11188. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11189. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11190. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11191. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11192. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11193. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11194. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11195. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11196. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11197. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11198. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11199. (sbyte)item.AssetType, item.AssetID,
  11200. item.GroupID, 100,
  11201. item.Owner, item.CreatorIdAsUuid,
  11202. item.ID, item.Folder,
  11203. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11204. (uint)PermissionMask.All)
  11205. )));
  11206. ItemDataMap.Add("CallbackID", 0);
  11207. ItemData.Add(ItemDataMap);
  11208. }
  11209. llsd.Add("ItemData", ItemData);
  11210. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11211. llsd), AgentId);
  11212. }
  11213. }
  11214. }