LLClientView.cs 534 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206
  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.Statistics;
  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 Nini.Config;
  50. using System.IO;
  51. namespace OpenSim.Region.ClientStack.LindenUDP
  52. {
  53. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  54. /// <summary>
  55. /// Handles new client connections
  56. /// Constructor takes a single Packet and authenticates everything
  57. /// </summary>
  58. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector
  59. {
  60. /// <value>
  61. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  62. /// </value>
  63. public int DebugPacketLevel { get; set; }
  64. #region Events
  65. public event GenericMessage OnGenericMessage;
  66. public event BinaryGenericMessage OnBinaryGenericMessage;
  67. public event Action<IClientAPI> OnLogout;
  68. public event ObjectPermissions OnObjectPermissions;
  69. public event Action<IClientAPI> OnConnectionClosed;
  70. public event ViewerEffectEventHandler OnViewerEffect;
  71. public event ImprovedInstantMessage OnInstantMessage;
  72. public event ChatMessage OnChatFromClient;
  73. public event TextureRequest OnRequestTexture;
  74. public event RezObject OnRezObject;
  75. public event DeRezObject OnDeRezObject;
  76. public event ModifyTerrain OnModifyTerrain;
  77. public event Action<IClientAPI> OnRegionHandShakeReply;
  78. public event GenericCall1 OnRequestWearables;
  79. public event SetAppearance OnSetAppearance;
  80. public event AvatarNowWearing OnAvatarNowWearing;
  81. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  82. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  83. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  84. public event ObjectAttach OnObjectAttach;
  85. public event ObjectDeselect OnObjectDetach;
  86. public event ObjectDrop OnObjectDrop;
  87. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  88. public event UpdateAgent OnPreAgentUpdate;
  89. public event UpdateAgent OnAgentUpdate;
  90. public event AgentRequestSit OnAgentRequestSit;
  91. public event AgentSit OnAgentSit;
  92. public event AvatarPickerRequest OnAvatarPickerRequest;
  93. public event StartAnim OnStartAnim;
  94. public event StopAnim OnStopAnim;
  95. public event Action<IClientAPI> OnRequestAvatarsData;
  96. public event LinkObjects OnLinkObjects;
  97. public event DelinkObjects OnDelinkObjects;
  98. public event GrabObject OnGrabObject;
  99. public event DeGrabObject OnDeGrabObject;
  100. public event SpinStart OnSpinStart;
  101. public event SpinStop OnSpinStop;
  102. public event ObjectDuplicate OnObjectDuplicate;
  103. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  104. public event MoveObject OnGrabUpdate;
  105. public event SpinObject OnSpinUpdate;
  106. public event AddNewPrim OnAddPrim;
  107. public event RequestGodlikePowers OnRequestGodlikePowers;
  108. public event GodKickUser OnGodKickUser;
  109. public event ObjectExtraParams OnUpdateExtraParams;
  110. public event UpdateShape OnUpdatePrimShape;
  111. public event ObjectRequest OnObjectRequest;
  112. public event ObjectSelect OnObjectSelect;
  113. public event ObjectDeselect OnObjectDeselect;
  114. public event GenericCall7 OnObjectDescription;
  115. public event GenericCall7 OnObjectName;
  116. public event GenericCall7 OnObjectClickAction;
  117. public event GenericCall7 OnObjectMaterial;
  118. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  119. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  120. public event UpdatePrimFlags OnUpdatePrimFlags;
  121. public event UpdatePrimTexture OnUpdatePrimTexture;
  122. public event UpdateVector OnUpdatePrimGroupPosition;
  123. public event UpdateVector OnUpdatePrimSinglePosition;
  124. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  125. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  126. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  127. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  128. public event UpdateVector OnUpdatePrimScale;
  129. public event UpdateVector OnUpdatePrimGroupScale;
  130. public event StatusChange OnChildAgentStatus;
  131. public event GenericCall2 OnStopMovement;
  132. public event Action<UUID> OnRemoveAvatar;
  133. public event RequestMapBlocks OnRequestMapBlocks;
  134. public event RequestMapName OnMapNameRequest;
  135. public event TeleportLocationRequest OnTeleportLocationRequest;
  136. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  137. public event DisconnectUser OnDisconnectUser;
  138. public event RequestAvatarProperties OnRequestAvatarProperties;
  139. public event SetAlwaysRun OnSetAlwaysRun;
  140. public event FetchInventory OnAgentDataUpdateRequest;
  141. public event TeleportLocationRequest OnSetStartLocationRequest;
  142. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  143. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  144. public event LinkInventoryItem OnLinkInventoryItem;
  145. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  146. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  147. public event MoveInventoryFolder OnMoveInventoryFolder;
  148. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  149. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  150. public event FetchInventory OnFetchInventory;
  151. public event RequestTaskInventory OnRequestTaskInventory;
  152. public event UpdateInventoryItem OnUpdateInventoryItem;
  153. public event CopyInventoryItem OnCopyInventoryItem;
  154. public event MoveInventoryItem OnMoveInventoryItem;
  155. public event RemoveInventoryItem OnRemoveInventoryItem;
  156. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  157. public event UDPAssetUploadRequest OnAssetUploadRequest;
  158. public event XferReceive OnXferReceive;
  159. public event RequestXfer OnRequestXfer;
  160. public event ConfirmXfer OnConfirmXfer;
  161. public event AbortXfer OnAbortXfer;
  162. public event RequestTerrain OnRequestTerrain;
  163. public event RezScript OnRezScript;
  164. public event UpdateTaskInventory OnUpdateTaskInventory;
  165. public event MoveTaskInventory OnMoveTaskItem;
  166. public event RemoveTaskInventory OnRemoveTaskItem;
  167. public event RequestAsset OnRequestAsset;
  168. public event UUIDNameRequest OnNameFromUUIDRequest;
  169. public event ParcelAccessListRequest OnParcelAccessListRequest;
  170. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  171. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  172. public event ParcelDivideRequest OnParcelDivideRequest;
  173. public event ParcelJoinRequest OnParcelJoinRequest;
  174. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  175. public event ParcelSelectObjects OnParcelSelectObjects;
  176. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  177. public event ParcelAbandonRequest OnParcelAbandonRequest;
  178. public event ParcelGodForceOwner OnParcelGodForceOwner;
  179. public event ParcelReclaim OnParcelReclaim;
  180. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  181. public event ParcelDeedToGroup OnParcelDeedToGroup;
  182. public event RegionInfoRequest OnRegionInfoRequest;
  183. public event EstateCovenantRequest OnEstateCovenantRequest;
  184. public event FriendActionDelegate OnApproveFriendRequest;
  185. public event FriendActionDelegate OnDenyFriendRequest;
  186. public event FriendshipTermination OnTerminateFriendship;
  187. public event GrantUserFriendRights OnGrantUserRights;
  188. public event MoneyTransferRequest OnMoneyTransferRequest;
  189. public event EconomyDataRequest OnEconomyDataRequest;
  190. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  191. public event ParcelBuy OnParcelBuy;
  192. public event UUIDNameRequest OnTeleportHomeRequest;
  193. public event UUIDNameRequest OnUUIDGroupNameRequest;
  194. public event ScriptAnswer OnScriptAnswer;
  195. public event RequestPayPrice OnRequestPayPrice;
  196. public event ObjectSaleInfo OnObjectSaleInfo;
  197. public event ObjectBuy OnObjectBuy;
  198. public event BuyObjectInventory OnBuyObjectInventory;
  199. public event AgentSit OnUndo;
  200. public event AgentSit OnRedo;
  201. public event LandUndo OnLandUndo;
  202. public event ForceReleaseControls OnForceReleaseControls;
  203. public event GodLandStatRequest OnLandStatRequest;
  204. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  205. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  206. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  207. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  208. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  209. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  210. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  211. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  212. public event BakeTerrain OnBakeTerrain;
  213. public event RequestTerrain OnUploadTerrain;
  214. public event EstateChangeInfo OnEstateChangeInfo;
  215. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  216. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  217. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  218. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  219. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  220. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  221. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  222. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  223. public event RegionHandleRequest OnRegionHandleRequest;
  224. public event ParcelInfoRequest OnParcelInfoRequest;
  225. public event ScriptReset OnScriptReset;
  226. public event GetScriptRunning OnGetScriptRunning;
  227. public event SetScriptRunning OnSetScriptRunning;
  228. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  229. public event TerrainUnacked OnUnackedTerrain;
  230. public event ActivateGesture OnActivateGesture;
  231. public event DeactivateGesture OnDeactivateGesture;
  232. public event ObjectOwner OnObjectOwner;
  233. public event DirPlacesQuery OnDirPlacesQuery;
  234. public event DirFindQuery OnDirFindQuery;
  235. public event DirLandQuery OnDirLandQuery;
  236. public event DirPopularQuery OnDirPopularQuery;
  237. public event DirClassifiedQuery OnDirClassifiedQuery;
  238. public event EventInfoRequest OnEventInfoRequest;
  239. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  240. public event MapItemRequest OnMapItemRequest;
  241. public event OfferCallingCard OnOfferCallingCard;
  242. public event AcceptCallingCard OnAcceptCallingCard;
  243. public event DeclineCallingCard OnDeclineCallingCard;
  244. public event SoundTrigger OnSoundTrigger;
  245. public event StartLure OnStartLure;
  246. public event TeleportLureRequest OnTeleportLureRequest;
  247. public event NetworkStats OnNetworkStatsUpdate;
  248. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  249. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  250. public event ClassifiedDelete OnClassifiedDelete;
  251. public event ClassifiedDelete OnClassifiedGodDelete;
  252. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  253. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  254. public event EventGodDelete OnEventGodDelete;
  255. public event ParcelDwellRequest OnParcelDwellRequest;
  256. public event UserInfoRequest OnUserInfoRequest;
  257. public event UpdateUserInfo OnUpdateUserInfo;
  258. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  259. public event PickDelete OnPickDelete;
  260. public event PickGodDelete OnPickGodDelete;
  261. public event PickInfoUpdate OnPickInfoUpdate;
  262. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  263. public event MuteListRequest OnMuteListRequest;
  264. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  265. public event PlacesQuery OnPlacesQuery;
  266. public event AgentFOV OnAgentFOV;
  267. public event FindAgentUpdate OnFindAgent;
  268. public event TrackAgentUpdate OnTrackAgent;
  269. public event NewUserReport OnUserReport;
  270. public event SaveStateHandler OnSaveState;
  271. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  272. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  273. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  274. public event FreezeUserUpdate OnParcelFreezeUser;
  275. public event EjectUserUpdate OnParcelEjectUser;
  276. public event ParcelBuyPass OnParcelBuyPass;
  277. public event ParcelGodMark OnParcelGodMark;
  278. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  279. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  280. public event SimWideDeletesDelegate OnSimWideDeletes;
  281. public event SendPostcard OnSendPostcard;
  282. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  283. public event MuteListEntryRemove OnRemoveMuteListEntry;
  284. public event GodlikeMessage onGodlikeMessage;
  285. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  286. #endregion Events
  287. #region Class Members
  288. // LLClientView Only
  289. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  290. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  291. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  292. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  293. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  294. /// <summary>
  295. /// Handles UDP texture download.
  296. /// </summary>
  297. public LLImageManager ImageManager { get; private set; }
  298. private readonly LLUDPServer m_udpServer;
  299. private readonly LLUDPClient m_udpClient;
  300. private readonly UUID m_sessionId;
  301. private readonly UUID m_secureSessionId;
  302. protected readonly UUID m_agentId;
  303. private readonly uint m_circuitCode;
  304. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  305. private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
  306. private readonly IGroupsModule m_GroupsModule;
  307. private int m_cachedTextureSerial;
  308. private PriorityQueue m_entityUpdates;
  309. private PriorityQueue m_entityProps;
  310. private Prioritizer m_prioritizer;
  311. private bool m_disableFacelights = false;
  312. /// <value>
  313. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  314. /// continually recreate it.
  315. /// </value>
  316. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  317. /// <value>
  318. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  319. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  320. /// ownerless phantom.
  321. ///
  322. /// All manipulation of this set has to occur under a lock
  323. ///
  324. /// </value>
  325. protected HashSet<uint> m_killRecord;
  326. // protected HashSet<uint> m_attachmentsSent;
  327. private int m_moneyBalance;
  328. private int m_animationSequenceNumber = 1;
  329. private bool m_SendLogoutPacketWhenClosing = true;
  330. private AgentUpdateArgs lastarg;
  331. private bool m_IsActive = true;
  332. private bool m_IsLoggingOut = false;
  333. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  334. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  335. protected Scene m_scene;
  336. protected string m_firstName;
  337. protected string m_lastName;
  338. protected Thread m_clientThread;
  339. protected Vector3 m_startpos;
  340. protected EndPoint m_userEndPoint;
  341. protected UUID m_activeGroupID;
  342. protected string m_activeGroupName = String.Empty;
  343. protected ulong m_activeGroupPowers;
  344. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  345. protected int m_terrainCheckerCount;
  346. protected uint m_agentFOVCounter;
  347. protected IAssetService m_assetService;
  348. private const bool m_checkPackets = true;
  349. #endregion Class Members
  350. #region Properties
  351. public LLUDPClient UDPClient { get { return m_udpClient; } }
  352. public LLUDPServer UDPServer { get { return m_udpServer; } }
  353. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  354. public UUID SecureSessionId { get { return m_secureSessionId; } }
  355. public IScene Scene { get { return m_scene; } }
  356. public UUID SessionId { get { return m_sessionId; } }
  357. public Vector3 StartPos
  358. {
  359. get { return m_startpos; }
  360. set { m_startpos = value; }
  361. }
  362. public UUID AgentId { get { return m_agentId; } }
  363. public ISceneAgent SceneAgent { get; private set; }
  364. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  365. public string ActiveGroupName { get { return m_activeGroupName; } }
  366. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  367. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  368. /// <summary>
  369. /// Entity update queues
  370. /// </summary>
  371. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  372. /// <summary>
  373. /// First name of the agent/avatar represented by the client
  374. /// </summary>
  375. public string FirstName { get { return m_firstName; } }
  376. /// <summary>
  377. /// Last name of the agent/avatar represented by the client
  378. /// </summary>
  379. public string LastName { get { return m_lastName; } }
  380. /// <summary>
  381. /// Full name of the client (first name and last name)
  382. /// </summary>
  383. public string Name { get { return FirstName + " " + LastName; } }
  384. public uint CircuitCode { get { return m_circuitCode; } }
  385. public int MoneyBalance { get { return m_moneyBalance; } }
  386. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  387. public bool IsActive
  388. {
  389. get { return m_IsActive; }
  390. set { m_IsActive = value; }
  391. }
  392. public bool IsLoggingOut
  393. {
  394. get { return m_IsLoggingOut; }
  395. set { m_IsLoggingOut = value; }
  396. }
  397. public bool DisableFacelights
  398. {
  399. get { return m_disableFacelights; }
  400. set { m_disableFacelights = value; }
  401. }
  402. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  403. #endregion Properties
  404. // ~LLClientView()
  405. // {
  406. // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode);
  407. // }
  408. /// <summary>
  409. /// Constructor
  410. /// </summary>
  411. public LLClientView(EndPoint remoteEP, Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  412. UUID agentId, UUID sessionId, uint circuitCode)
  413. {
  414. RegisterInterface<IClientIM>(this);
  415. RegisterInterface<IClientChat>(this);
  416. RegisterInterface<IClientIPEndpoint>(this);
  417. InitDefaultAnimations();
  418. m_scene = scene;
  419. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  420. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  421. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  422. m_killRecord = new HashSet<uint>();
  423. // m_attachmentsSent = new HashSet<uint>();
  424. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  425. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  426. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  427. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  428. m_agentId = agentId;
  429. m_sessionId = sessionId;
  430. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  431. m_circuitCode = circuitCode;
  432. m_userEndPoint = remoteEP;
  433. m_firstName = sessionInfo.LoginInfo.First;
  434. m_lastName = sessionInfo.LoginInfo.Last;
  435. m_startpos = sessionInfo.LoginInfo.StartPos;
  436. m_moneyBalance = 1000;
  437. m_udpServer = udpServer;
  438. m_udpClient = udpClient;
  439. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  440. m_udpClient.OnPacketStats += PopulateStats;
  441. m_prioritizer = new Prioritizer(m_scene);
  442. RegisterLocalPacketHandlers();
  443. }
  444. #region Client Methods
  445. /// <summary>
  446. /// Shut down the client view
  447. /// </summary>
  448. public void Close()
  449. {
  450. m_log.DebugFormat(
  451. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  452. Name, m_scene.RegionInfo.RegionName);
  453. // Send the STOP packet
  454. DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
  455. OutPacket(disable, ThrottleOutPacketType.Unknown);
  456. IsActive = false;
  457. // Shutdown the image manager
  458. ImageManager.Close();
  459. // Fire the callback for this connection closing
  460. if (OnConnectionClosed != null)
  461. OnConnectionClosed(this);
  462. // Flush all of the packets out of the UDP server for this client
  463. if (m_udpServer != null)
  464. m_udpServer.Flush(m_udpClient);
  465. // Remove ourselves from the scene
  466. m_scene.RemoveClient(AgentId, true);
  467. SceneAgent = null;
  468. // We can't reach into other scenes and close the connection
  469. // We need to do this over grid communications
  470. //m_scene.CloseAllAgents(CircuitCode);
  471. // Disable UDP handling for this client
  472. m_udpClient.Shutdown();
  473. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  474. //GC.Collect();
  475. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  476. }
  477. public void Kick(string message)
  478. {
  479. if (!SceneAgent.IsChildAgent)
  480. {
  481. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  482. kupack.UserInfo.AgentID = AgentId;
  483. kupack.UserInfo.SessionID = SessionId;
  484. kupack.TargetBlock.TargetIP = 0;
  485. kupack.TargetBlock.TargetPort = 0;
  486. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  487. OutPacket(kupack, ThrottleOutPacketType.Task);
  488. // You must sleep here or users get no message!
  489. Thread.Sleep(500);
  490. }
  491. }
  492. public void Stop()
  493. {
  494. }
  495. #endregion Client Methods
  496. #region Packet Handling
  497. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  498. {
  499. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  500. if (handlerNetworkStatsUpdate != null)
  501. {
  502. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  503. }
  504. }
  505. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  506. {
  507. bool result = false;
  508. lock (PacketHandlers)
  509. {
  510. if (!PacketHandlers.ContainsKey(packetType))
  511. {
  512. PacketHandlers.Add(packetType, handler);
  513. result = true;
  514. }
  515. }
  516. return result;
  517. }
  518. /// <summary>
  519. /// Add a handler for the given packet type.
  520. /// </summary>
  521. /// <remarks>
  522. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  523. /// are received then please use the synchronous version of this method.
  524. /// </remarks>
  525. /// <param name="packetType"></param>
  526. /// <param name="handler"></param>
  527. /// <returns>true if the handler was added. This is currently always the case.</returns>
  528. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  529. {
  530. return AddLocalPacketHandler(packetType, handler, true);
  531. }
  532. /// <summary>
  533. /// Add a handler for the given packet type.
  534. /// </summary>
  535. /// <param name="packetType"></param>
  536. /// <param name="handler"></param>
  537. /// <param name="doAsync">
  538. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  539. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  540. /// synchronously.
  541. /// </param>
  542. /// <returns>true if the handler was added. This is currently always the case.</returns>
  543. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  544. {
  545. bool result = false;
  546. lock (m_packetHandlers)
  547. {
  548. if (!m_packetHandlers.ContainsKey(packetType))
  549. {
  550. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  551. result = true;
  552. }
  553. }
  554. return result;
  555. }
  556. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  557. {
  558. MethodName = MethodName.ToLower().Trim();
  559. bool result = false;
  560. lock (m_genericPacketHandlers)
  561. {
  562. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  563. {
  564. m_genericPacketHandlers.Add(MethodName, handler);
  565. result = true;
  566. }
  567. }
  568. return result;
  569. }
  570. /// <summary>
  571. /// Try to process a packet using registered packet handlers
  572. /// </summary>
  573. /// <param name="packet"></param>
  574. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  575. protected virtual bool ProcessPacketMethod(Packet packet)
  576. {
  577. bool result = false;
  578. PacketProcessor pprocessor;
  579. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  580. {
  581. //there is a local handler for this packet type
  582. if (pprocessor.Async)
  583. {
  584. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  585. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  586. result = true;
  587. }
  588. else
  589. {
  590. result = pprocessor.method(this, packet);
  591. }
  592. }
  593. else
  594. {
  595. //there is not a local handler so see if there is a Global handler
  596. PacketMethod method = null;
  597. bool found;
  598. lock (PacketHandlers)
  599. {
  600. found = PacketHandlers.TryGetValue(packet.Type, out method);
  601. }
  602. if (found)
  603. {
  604. result = method(this, packet);
  605. }
  606. }
  607. return result;
  608. }
  609. public void ProcessSpecificPacketAsync(object state)
  610. {
  611. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  612. try
  613. {
  614. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  615. }
  616. catch (Exception e)
  617. {
  618. // Make sure that we see any exception caused by the asynchronous operation.
  619. m_log.ErrorFormat(
  620. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  621. packetObject.Pack, Name, e.Message, e.StackTrace);
  622. }
  623. }
  624. #endregion Packet Handling
  625. # region Setup
  626. public virtual void Start()
  627. {
  628. SceneAgent = m_scene.AddNewClient(this, PresenceType.User);
  629. RefreshGroupMembership();
  630. }
  631. # endregion
  632. public void ActivateGesture(UUID assetId, UUID gestureId)
  633. {
  634. }
  635. public void DeactivateGesture(UUID assetId, UUID gestureId)
  636. {
  637. }
  638. // Sound
  639. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  640. {
  641. }
  642. #region Scene/Avatar to Client
  643. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  644. {
  645. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  646. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  647. handshake.RegionInfo.BillableFactor = args.billableFactor;
  648. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  649. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  650. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  651. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  652. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  653. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  654. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  655. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  656. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  657. handshake.RegionInfo.SimAccess = args.simAccess;
  658. handshake.RegionInfo.WaterHeight = args.waterHeight;
  659. handshake.RegionInfo.RegionFlags = args.regionFlags;
  660. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  661. handshake.RegionInfo.SimOwner = args.SimOwner;
  662. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  663. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  664. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  665. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  666. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  667. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  668. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  669. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  670. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  671. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  672. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  673. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  674. handshake.RegionInfo3.CPUClassID = 9;
  675. handshake.RegionInfo3.CPURatio = 1;
  676. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  677. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  678. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  679. OutPacket(handshake, ThrottleOutPacketType.Task);
  680. }
  681. /// <summary>
  682. ///
  683. /// </summary>
  684. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  685. {
  686. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  687. mov.SimData.ChannelVersion = m_channelVersion;
  688. mov.AgentData.SessionID = m_sessionId;
  689. mov.AgentData.AgentID = AgentId;
  690. mov.Data.RegionHandle = regInfo.RegionHandle;
  691. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  692. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  693. {
  694. mov.Data.Position = m_startpos;
  695. }
  696. else
  697. {
  698. mov.Data.Position = pos;
  699. }
  700. mov.Data.LookAt = look;
  701. // Hack to get this out immediately and skip the throttles
  702. OutPacket(mov, ThrottleOutPacketType.Unknown);
  703. }
  704. public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName,
  705. UUID fromAgentID, byte source, byte audible)
  706. {
  707. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  708. reply.ChatData.Audible = audible;
  709. reply.ChatData.Message = Util.StringToBytes1024(message);
  710. reply.ChatData.ChatType = type;
  711. reply.ChatData.SourceType = source;
  712. reply.ChatData.Position = fromPos;
  713. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  714. reply.ChatData.OwnerID = fromAgentID;
  715. reply.ChatData.SourceID = fromAgentID;
  716. OutPacket(reply, ThrottleOutPacketType.Task);
  717. }
  718. /// <summary>
  719. /// Send an instant message to this client
  720. /// </summary>
  721. //
  722. // Don't remove transaction ID! Groups and item gives need to set it!
  723. public void SendInstantMessage(GridInstantMessage im)
  724. {
  725. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  726. {
  727. ImprovedInstantMessagePacket msg
  728. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  729. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  730. msg.AgentData.SessionID = UUID.Zero;
  731. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  732. msg.MessageBlock.Dialog = im.dialog;
  733. msg.MessageBlock.FromGroup = im.fromGroup;
  734. if (im.imSessionID == UUID.Zero.Guid)
  735. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  736. else
  737. msg.MessageBlock.ID = new UUID(im.imSessionID);
  738. msg.MessageBlock.Offline = im.offline;
  739. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  740. msg.MessageBlock.Position = im.Position;
  741. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  742. msg.MessageBlock.Timestamp = im.timestamp;
  743. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  744. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  745. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  746. if (im.message.StartsWith("[grouptest]"))
  747. { // this block is test code for implementing group IM - delete when group IM is finished
  748. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  749. if (eq != null)
  750. {
  751. im.dialog = 17;
  752. //eq.ChatterboxInvitation(
  753. // new UUID("00000000-68f9-1111-024e-222222111123"),
  754. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  755. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  756. eq.ChatterboxInvitation(
  757. new UUID("00000000-68f9-1111-024e-222222111123"),
  758. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  759. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  760. eq.ChatterBoxSessionAgentListUpdates(
  761. new UUID("00000000-68f9-1111-024e-222222111123"),
  762. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  763. }
  764. Console.WriteLine("SendInstantMessage: " + msg);
  765. }
  766. else
  767. OutPacket(msg, ThrottleOutPacketType.Task);
  768. }
  769. }
  770. public void SendGenericMessage(string method, List<string> message)
  771. {
  772. GenericMessagePacket gmp = new GenericMessagePacket();
  773. gmp.MethodData.Method = Util.StringToBytes256(method);
  774. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  775. int i = 0;
  776. foreach (string val in message)
  777. {
  778. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  779. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  780. }
  781. OutPacket(gmp, ThrottleOutPacketType.Task);
  782. }
  783. public void SendGenericMessage(string method, List<byte[]> message)
  784. {
  785. GenericMessagePacket gmp = new GenericMessagePacket();
  786. gmp.MethodData.Method = Util.StringToBytes256(method);
  787. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  788. int i = 0;
  789. foreach (byte[] val in message)
  790. {
  791. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  792. gmp.ParamList[i++].Parameter = val;
  793. }
  794. OutPacket(gmp, ThrottleOutPacketType.Task);
  795. }
  796. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  797. {
  798. int i = 0;
  799. foreach (GroupActiveProposals Proposal in Proposals)
  800. {
  801. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  802. GAPIRP.AgentData.AgentID = AgentId;
  803. GAPIRP.AgentData.GroupID = groupID;
  804. GAPIRP.TransactionData.TransactionID = transactionID;
  805. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  806. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  807. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  808. ProposalData.VoteCast = Utils.StringToBytes("false");
  809. ProposalData.VoteID = new UUID(Proposal.VoteID);
  810. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  811. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  812. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  813. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  814. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  815. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  816. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  817. ProposalData.AlreadyVoted = false;
  818. GAPIRP.ProposalData[i] = ProposalData;
  819. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  820. i++;
  821. }
  822. if (Proposals.Length == 0)
  823. {
  824. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  825. GAPIRP.AgentData.AgentID = AgentId;
  826. GAPIRP.AgentData.GroupID = groupID;
  827. GAPIRP.TransactionData.TransactionID = transactionID;
  828. GAPIRP.TransactionData.TotalNumItems = 1;
  829. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  830. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  831. ProposalData.VoteCast = Utils.StringToBytes("false");
  832. ProposalData.VoteID = UUID.Zero;
  833. ProposalData.VoteInitiator = UUID.Zero;
  834. ProposalData.Majority = 0;
  835. ProposalData.Quorum = 0;
  836. ProposalData.TerseDateID = Utils.StringToBytes("");
  837. ProposalData.StartDateTime = Utils.StringToBytes("");
  838. ProposalData.EndDateTime = Utils.StringToBytes("");
  839. ProposalData.ProposalText = Utils.StringToBytes("");
  840. ProposalData.AlreadyVoted = false;
  841. GAPIRP.ProposalData[0] = ProposalData;
  842. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  843. }
  844. }
  845. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  846. {
  847. int i = 0;
  848. foreach (GroupVoteHistory Vote in Votes)
  849. {
  850. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  851. GVHIRP.AgentData.AgentID = AgentId;
  852. GVHIRP.AgentData.GroupID = groupID;
  853. GVHIRP.TransactionData.TransactionID = transactionID;
  854. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  855. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  856. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  857. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  858. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  859. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  860. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  861. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  862. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  863. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  864. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  865. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  866. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  867. VoteItem.CandidateID = UUID.Zero;
  868. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  869. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  870. GVHIRP.VoteItem[i] = VoteItem;
  871. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  872. i++;
  873. }
  874. if (Votes.Length == 0)
  875. {
  876. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  877. GVHIRP.AgentData.AgentID = AgentId;
  878. GVHIRP.AgentData.GroupID = groupID;
  879. GVHIRP.TransactionData.TransactionID = transactionID;
  880. GVHIRP.TransactionData.TotalNumItems = 0;
  881. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  882. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  883. GVHIRP.HistoryItemData.Majority = 0;
  884. GVHIRP.HistoryItemData.Quorum = 0;
  885. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  886. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  887. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  888. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  889. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  890. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  891. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  892. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  893. VoteItem.CandidateID = UUID.Zero;
  894. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  895. VoteItem.VoteCast = Utils.StringToBytes("No");
  896. GVHIRP.VoteItem[0] = VoteItem;
  897. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  898. }
  899. }
  900. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  901. {
  902. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  903. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  904. GADRP.AgentData.AgentID = sender.AgentId;
  905. GADRP.AgentData.GroupID = groupID;
  906. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  907. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  908. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  909. GADRP.MoneyData.CurrentInterval = 0;
  910. GADRP.MoneyData.IntervalDays = 7;
  911. GADRP.MoneyData.RequestID = transactionID;
  912. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  913. History.Amount = amt;
  914. History.Description = Utils.StringToBytes("");
  915. GADRP.HistoryData[0] = History;
  916. OutPacket(GADRP, ThrottleOutPacketType.Task);
  917. }
  918. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  919. {
  920. GroupAccountSummaryReplyPacket GASRP =
  921. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  922. PacketType.GroupAccountSummaryReply);
  923. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  924. GASRP.AgentData.AgentID = sender.AgentId;
  925. GASRP.AgentData.GroupID = groupID;
  926. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  927. GASRP.MoneyData.Balance = (int)moneyAmt;
  928. GASRP.MoneyData.TotalCredits = totalTier;
  929. GASRP.MoneyData.TotalDebits = usedTier;
  930. GASRP.MoneyData.StartDate = new byte[1];
  931. GASRP.MoneyData.CurrentInterval = 1;
  932. GASRP.MoneyData.GroupTaxCurrent = 0;
  933. GASRP.MoneyData.GroupTaxEstimate = 0;
  934. GASRP.MoneyData.IntervalDays = 0;
  935. GASRP.MoneyData.LandTaxCurrent = 0;
  936. GASRP.MoneyData.LandTaxEstimate = 0;
  937. GASRP.MoneyData.LastTaxDate = new byte[1];
  938. GASRP.MoneyData.LightTaxCurrent = 0;
  939. GASRP.MoneyData.TaxDate = new byte[1];
  940. GASRP.MoneyData.RequestID = sender.AgentId;
  941. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  942. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  943. GASRP.MoneyData.ObjectTaxEstimate = 0;
  944. GASRP.MoneyData.NonExemptMembers = 0;
  945. GASRP.MoneyData.ObjectTaxCurrent = 0;
  946. GASRP.MoneyData.LightTaxEstimate = 0;
  947. OutPacket(GASRP, ThrottleOutPacketType.Task);
  948. }
  949. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  950. {
  951. GroupAccountTransactionsReplyPacket GATRP =
  952. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  953. PacketType.GroupAccountTransactionsReply);
  954. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  955. GATRP.AgentData.AgentID = sender.AgentId;
  956. GATRP.AgentData.GroupID = groupID;
  957. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  958. GATRP.MoneyData.CurrentInterval = 0;
  959. GATRP.MoneyData.IntervalDays = 7;
  960. GATRP.MoneyData.RequestID = transactionID;
  961. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  962. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  963. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  964. History.Amount = 0;
  965. History.Item = Utils.StringToBytes("");
  966. History.Time = Utils.StringToBytes("");
  967. History.Type = 0;
  968. History.User = Utils.StringToBytes("");
  969. GATRP.HistoryData[0] = History;
  970. OutPacket(GATRP, ThrottleOutPacketType.Task);
  971. }
  972. /// <summary>
  973. /// Send the region heightmap to the client
  974. /// </summary>
  975. /// <param name="map">heightmap</param>
  976. public virtual void SendLayerData(float[] map)
  977. {
  978. Util.FireAndForget(DoSendLayerData, map);
  979. }
  980. /// <summary>
  981. /// Send terrain layer information to the client.
  982. /// </summary>
  983. /// <param name="o"></param>
  984. private void DoSendLayerData(object o)
  985. {
  986. float[] map = LLHeightFieldMoronize((float[])o);
  987. try
  988. {
  989. //for (int y = 0; y < 16; y++)
  990. //{
  991. // for (int x = 0; x < 16; x++)
  992. // {
  993. // SendLayerData(x, y, map);
  994. // }
  995. //}
  996. // Send LayerData in a spiral pattern. Fun!
  997. SendLayerTopRight(map, 0, 0, 15, 15);
  998. }
  999. catch (Exception e)
  1000. {
  1001. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1002. }
  1003. }
  1004. private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
  1005. {
  1006. // Row
  1007. for (int i = x1; i <= x2; i++)
  1008. SendLayerData(i, y1, map);
  1009. // Column
  1010. for (int j = y1 + 1; j <= y2; j++)
  1011. SendLayerData(x2, j, map);
  1012. if (x2 - x1 > 0)
  1013. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1014. }
  1015. void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
  1016. {
  1017. // Row in reverse
  1018. for (int i = x2; i >= x1; i--)
  1019. SendLayerData(i, y2, map);
  1020. // Column in reverse
  1021. for (int j = y2 - 1; j >= y1; j--)
  1022. SendLayerData(x1, j, map);
  1023. if (x2 - x1 > 0)
  1024. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1025. }
  1026. /// <summary>
  1027. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1028. /// </summary>
  1029. /// <param name="map">heightmap</param>
  1030. /// <param name="px">X coordinate for patches 0..12</param>
  1031. /// <param name="py">Y coordinate for patches 0..15</param>
  1032. // private void SendLayerPacket(float[] map, int y, int x)
  1033. // {
  1034. // int[] patches = new int[4];
  1035. // patches[0] = x + 0 + y * 16;
  1036. // patches[1] = x + 1 + y * 16;
  1037. // patches[2] = x + 2 + y * 16;
  1038. // patches[3] = x + 3 + y * 16;
  1039. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1040. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1041. // }
  1042. /// <summary>
  1043. /// Sends a specified patch to a client
  1044. /// </summary>
  1045. /// <param name="px">Patch coordinate (x) 0..15</param>
  1046. /// <param name="py">Patch coordinate (y) 0..15</param>
  1047. /// <param name="map">heightmap</param>
  1048. public void SendLayerData(int px, int py, float[] map)
  1049. {
  1050. try
  1051. {
  1052. int[] patches = new int[] { py * 16 + px };
  1053. float[] heightmap = (map.Length == 65536) ?
  1054. map :
  1055. LLHeightFieldMoronize(map);
  1056. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1057. layerpack.Header.Reliable = true;
  1058. OutPacket(layerpack, ThrottleOutPacketType.Land);
  1059. }
  1060. catch (Exception e)
  1061. {
  1062. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1063. }
  1064. }
  1065. /// <summary>
  1066. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1067. /// </summary>
  1068. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1069. /// <returns>float array in the base 256</returns>
  1070. internal float[] LLHeightFieldMoronize(float[] map)
  1071. {
  1072. if (map.Length == 65536)
  1073. return map;
  1074. else
  1075. {
  1076. float[] returnmap = new float[65536];
  1077. if (map.Length < 65535)
  1078. {
  1079. // rebase the vector stride to 256
  1080. for (int i = 0; i < Constants.RegionSize; i++)
  1081. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1082. }
  1083. else
  1084. {
  1085. for (int i = 0; i < 256; i++)
  1086. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1087. }
  1088. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1089. return returnmap;
  1090. }
  1091. }
  1092. /// <summary>
  1093. /// Send the wind matrix to the client
  1094. /// </summary>
  1095. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1096. public virtual void SendWindData(Vector2[] windSpeeds)
  1097. {
  1098. Util.FireAndForget(DoSendWindData, windSpeeds);
  1099. }
  1100. /// <summary>
  1101. /// Send the cloud matrix to the client
  1102. /// </summary>
  1103. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1104. public virtual void SendCloudData(float[] cloudDensity)
  1105. {
  1106. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1107. }
  1108. /// <summary>
  1109. /// Send wind layer information to the client.
  1110. /// </summary>
  1111. /// <param name="o"></param>
  1112. private void DoSendWindData(object o)
  1113. {
  1114. Vector2[] windSpeeds = (Vector2[])o;
  1115. TerrainPatch[] patches = new TerrainPatch[2];
  1116. patches[0] = new TerrainPatch();
  1117. patches[0].Data = new float[16 * 16];
  1118. patches[1] = new TerrainPatch();
  1119. patches[1].Data = new float[16 * 16];
  1120. for (int y = 0; y < 16; y++)
  1121. {
  1122. for (int x = 0; x < 16; x++)
  1123. {
  1124. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1125. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1126. }
  1127. }
  1128. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1129. layerpack.Header.Zerocoded = true;
  1130. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1131. }
  1132. /// <summary>
  1133. /// Send cloud layer information to the client.
  1134. /// </summary>
  1135. /// <param name="o"></param>
  1136. private void DoSendCloudData(object o)
  1137. {
  1138. float[] cloudCover = (float[])o;
  1139. TerrainPatch[] patches = new TerrainPatch[1];
  1140. patches[0] = new TerrainPatch();
  1141. patches[0].Data = new float[16 * 16];
  1142. for (int y = 0; y < 16; y++)
  1143. {
  1144. for (int x = 0; x < 16; x++)
  1145. {
  1146. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1147. }
  1148. }
  1149. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1150. layerpack.Header.Zerocoded = true;
  1151. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1152. }
  1153. /// <summary>
  1154. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1155. /// </summary>
  1156. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1157. {
  1158. IPAddress neighbourIP = neighbourEndPoint.Address;
  1159. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1160. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1161. // TODO: don't create new blocks if recycling an old packet
  1162. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1163. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1164. byte[] byteIP = neighbourIP.GetAddressBytes();
  1165. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1166. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1167. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1168. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1169. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1170. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1171. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1172. }
  1173. public AgentCircuitData RequestClientInfo()
  1174. {
  1175. AgentCircuitData agentData = new AgentCircuitData();
  1176. agentData.AgentID = AgentId;
  1177. agentData.SessionID = m_sessionId;
  1178. agentData.SecureSessionID = SecureSessionId;
  1179. agentData.circuitcode = m_circuitCode;
  1180. agentData.child = false;
  1181. agentData.firstname = m_firstName;
  1182. agentData.lastname = m_lastName;
  1183. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1184. if (capsModule == null) // can happen when shutting down.
  1185. return agentData;
  1186. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1187. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1188. return agentData;
  1189. }
  1190. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1191. string capsURL)
  1192. {
  1193. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1194. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1195. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1196. // TODO: don't create new blocks if recycling an old packet
  1197. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1198. newSimPack.AgentData.AgentID = AgentId;
  1199. newSimPack.AgentData.SessionID = m_sessionId;
  1200. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1201. newSimPack.Info.Position = pos;
  1202. newSimPack.Info.LookAt = look;
  1203. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1204. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1205. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1206. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1207. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1208. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1209. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1210. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1211. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1212. // Hack to get this out immediately and skip throttles
  1213. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1214. }
  1215. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1216. {
  1217. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1218. // TODO: don't create new blocks if recycling an old packet
  1219. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1220. mapReply.AgentData.AgentID = AgentId;
  1221. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1222. mapReply.AgentData.Flags = flag;
  1223. for (int i = 0; i < mapBlocks2.Length; i++)
  1224. {
  1225. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1226. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1227. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1228. mapReply.Data[i].X = mapBlocks2[i].X;
  1229. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1230. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1231. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1232. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1233. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1234. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1235. }
  1236. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1237. }
  1238. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1239. {
  1240. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1241. int maxsend = 10;
  1242. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1243. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1244. for (int i = 0; i < mapBlocks2.Length; i++)
  1245. {
  1246. sendingBlocks.Add(mapBlocks2[i]);
  1247. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1248. {
  1249. SendMapBlockSplit(sendingBlocks, flag);
  1250. sendingBlocks = new List<MapBlockData>();
  1251. }
  1252. }
  1253. }
  1254. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1255. {
  1256. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1257. tpLocal.Info.AgentID = AgentId;
  1258. tpLocal.Info.TeleportFlags = flags;
  1259. tpLocal.Info.LocationID = 2;
  1260. tpLocal.Info.LookAt = lookAt;
  1261. tpLocal.Info.Position = position;
  1262. // Hack to get this out immediately and skip throttles
  1263. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1264. }
  1265. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1266. uint flags, string capsURL)
  1267. {
  1268. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1269. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1270. teleport.Info.AgentID = AgentId;
  1271. teleport.Info.RegionHandle = regionHandle;
  1272. teleport.Info.SimAccess = simAccess;
  1273. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1274. IPAddress oIP = newRegionEndPoint.Address;
  1275. byte[] byteIP = oIP.GetAddressBytes();
  1276. uint ip = (uint)byteIP[3] << 24;
  1277. ip += (uint)byteIP[2] << 16;
  1278. ip += (uint)byteIP[1] << 8;
  1279. ip += (uint)byteIP[0];
  1280. teleport.Info.SimIP = ip;
  1281. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1282. teleport.Info.LocationID = 4;
  1283. teleport.Info.TeleportFlags = 1 << 4;
  1284. // Hack to get this out immediately and skip throttles.
  1285. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1286. }
  1287. /// <summary>
  1288. /// Inform the client that a teleport attempt has failed
  1289. /// </summary>
  1290. public void SendTeleportFailed(string reason)
  1291. {
  1292. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1293. tpFailed.Info.AgentID = AgentId;
  1294. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1295. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1296. // Hack to get this out immediately and skip throttles
  1297. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1298. }
  1299. /// <summary>
  1300. ///
  1301. /// </summary>
  1302. public void SendTeleportStart(uint flags)
  1303. {
  1304. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1305. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1306. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1307. // Hack to get this out immediately and skip throttles
  1308. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1309. }
  1310. public void SendTeleportProgress(uint flags, string message)
  1311. {
  1312. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1313. tpProgress.AgentData.AgentID = this.AgentId;
  1314. tpProgress.Info.TeleportFlags = flags;
  1315. tpProgress.Info.Message = Util.StringToBytes256(message);
  1316. // Hack to get this out immediately and skip throttles
  1317. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1318. }
  1319. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
  1320. {
  1321. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1322. money.MoneyData.AgentID = AgentId;
  1323. money.MoneyData.TransactionID = transaction;
  1324. money.MoneyData.TransactionSuccess = success;
  1325. money.MoneyData.Description = description;
  1326. money.MoneyData.MoneyBalance = balance;
  1327. money.TransactionInfo.ItemDescription = Util.StringToBytes256("NONE");
  1328. OutPacket(money, ThrottleOutPacketType.Task);
  1329. }
  1330. public void SendPayPrice(UUID objectID, int[] payPrice)
  1331. {
  1332. if (payPrice[0] == 0 &&
  1333. payPrice[1] == 0 &&
  1334. payPrice[2] == 0 &&
  1335. payPrice[3] == 0 &&
  1336. payPrice[4] == 0)
  1337. return;
  1338. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1339. payPriceReply.ObjectData.ObjectID = objectID;
  1340. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1341. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1342. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1343. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1344. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1345. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1346. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1347. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1348. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1349. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1350. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1351. }
  1352. public void SendStartPingCheck(byte seq)
  1353. {
  1354. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1355. pc.Header.Reliable = false;
  1356. pc.PingID.PingID = seq;
  1357. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1358. pc.PingID.OldestUnacked = 0;
  1359. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1360. }
  1361. public void SendKillObject(ulong regionHandle, uint localID)
  1362. {
  1363. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1364. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1365. // TODO: don't create new blocks if recycling an old packet
  1366. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
  1367. kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
  1368. kill.ObjectData[0].ID = localID;
  1369. kill.Header.Reliable = true;
  1370. kill.Header.Zerocoded = true;
  1371. if (m_scene.GetScenePresence(localID) == null)
  1372. {
  1373. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1374. // condition where a kill can be processed before an out-of-date update for the same object.
  1375. lock (m_killRecord)
  1376. {
  1377. m_killRecord.Add(localID);
  1378. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1379. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1380. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1381. // scene objects in a viewer until that viewer is relogged in.
  1382. OutPacket(kill, ThrottleOutPacketType.Task);
  1383. }
  1384. }
  1385. else
  1386. {
  1387. // OutPacket(kill, ThrottleOutPacketType.State);
  1388. OutPacket(kill, ThrottleOutPacketType.Task);
  1389. }
  1390. }
  1391. /// <summary>
  1392. /// Send information about the items contained in a folder to the client.
  1393. ///
  1394. /// XXX This method needs some refactoring loving
  1395. /// </summary>
  1396. /// <param name="ownerID">The owner of the folder</param>
  1397. /// <param name="folderID">The id of the folder</param>
  1398. /// <param name="items">The items contained in the folder identified by folderID</param>
  1399. /// <param name="folders"></param>
  1400. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1401. /// <param name="fetchItems">Do we need to send item information?</param>
  1402. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1403. List<InventoryFolderBase> folders, int version,
  1404. bool fetchFolders, bool fetchItems)
  1405. {
  1406. // An inventory descendents packet consists of a single agent section and an inventory details
  1407. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1408. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1409. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1410. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1411. //
  1412. // http://opensimulator.org/mantis/view.php?id=226
  1413. //
  1414. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1415. // 6 to 7 items at a time, so let's stick with 6
  1416. int MAX_ITEMS_PER_PACKET = 5;
  1417. int MAX_FOLDERS_PER_PACKET = 6;
  1418. int totalItems = fetchItems ? items.Count : 0;
  1419. int totalFolders = fetchFolders ? folders.Count : 0;
  1420. int itemsSent = 0;
  1421. int foldersSent = 0;
  1422. int foldersToSend = 0;
  1423. int itemsToSend = 0;
  1424. InventoryDescendentsPacket currentPacket = null;
  1425. // Handle empty folders
  1426. //
  1427. if (totalItems == 0 && totalFolders == 0)
  1428. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1429. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1430. //
  1431. while (itemsSent < totalItems || foldersSent < totalFolders)
  1432. {
  1433. if (currentPacket == null) // Start a new packet
  1434. {
  1435. foldersToSend = totalFolders - foldersSent;
  1436. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1437. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1438. if (foldersToSend == 0)
  1439. {
  1440. itemsToSend = totalItems - itemsSent;
  1441. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1442. itemsToSend = MAX_ITEMS_PER_PACKET;
  1443. }
  1444. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1445. }
  1446. if (foldersToSend-- > 0)
  1447. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1448. else if (itemsToSend-- > 0)
  1449. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1450. else
  1451. {
  1452. // m_log.DebugFormat(
  1453. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1454. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1455. currentPacket = null;
  1456. }
  1457. }
  1458. if (currentPacket != null)
  1459. {
  1460. // m_log.DebugFormat(
  1461. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1462. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1463. }
  1464. }
  1465. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1466. {
  1467. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1468. newBlock.FolderID = folder.ID;
  1469. newBlock.Name = Util.StringToBytes256(folder.Name);
  1470. newBlock.ParentID = folder.ParentID;
  1471. newBlock.Type = (sbyte)folder.Type;
  1472. return newBlock;
  1473. }
  1474. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1475. {
  1476. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1477. newBlock.ItemID = item.ID;
  1478. newBlock.AssetID = item.AssetID;
  1479. newBlock.CreatorID = item.CreatorIdAsUuid;
  1480. newBlock.BaseMask = item.BasePermissions;
  1481. newBlock.Description = Util.StringToBytes256(item.Description);
  1482. newBlock.EveryoneMask = item.EveryOnePermissions;
  1483. newBlock.OwnerMask = item.CurrentPermissions;
  1484. newBlock.FolderID = item.Folder;
  1485. newBlock.InvType = (sbyte)item.InvType;
  1486. newBlock.Name = Util.StringToBytes256(item.Name);
  1487. newBlock.NextOwnerMask = item.NextPermissions;
  1488. newBlock.OwnerID = item.Owner;
  1489. newBlock.Type = (sbyte)item.AssetType;
  1490. newBlock.GroupID = item.GroupID;
  1491. newBlock.GroupOwned = item.GroupOwned;
  1492. newBlock.GroupMask = item.GroupPermissions;
  1493. newBlock.CreationDate = item.CreationDate;
  1494. newBlock.SalePrice = item.SalePrice;
  1495. newBlock.SaleType = item.SaleType;
  1496. newBlock.Flags = item.Flags;
  1497. newBlock.CRC =
  1498. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1499. newBlock.InvType, newBlock.Type,
  1500. newBlock.AssetID, newBlock.GroupID,
  1501. newBlock.SalePrice,
  1502. newBlock.OwnerID, newBlock.CreatorID,
  1503. newBlock.ItemID, newBlock.FolderID,
  1504. newBlock.EveryoneMask,
  1505. newBlock.Flags, newBlock.OwnerMask,
  1506. newBlock.GroupMask, newBlock.NextOwnerMask);
  1507. return newBlock;
  1508. }
  1509. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1510. {
  1511. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1512. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1513. packet.FolderData[0].FolderID = UUID.Zero;
  1514. packet.FolderData[0].ParentID = UUID.Zero;
  1515. packet.FolderData[0].Type = -1;
  1516. packet.FolderData[0].Name = new byte[0];
  1517. }
  1518. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1519. {
  1520. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1521. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1522. packet.ItemData[0].ItemID = UUID.Zero;
  1523. packet.ItemData[0].AssetID = UUID.Zero;
  1524. packet.ItemData[0].CreatorID = UUID.Zero;
  1525. packet.ItemData[0].BaseMask = 0;
  1526. packet.ItemData[0].Description = new byte[0];
  1527. packet.ItemData[0].EveryoneMask = 0;
  1528. packet.ItemData[0].OwnerMask = 0;
  1529. packet.ItemData[0].FolderID = UUID.Zero;
  1530. packet.ItemData[0].InvType = (sbyte)0;
  1531. packet.ItemData[0].Name = new byte[0];
  1532. packet.ItemData[0].NextOwnerMask = 0;
  1533. packet.ItemData[0].OwnerID = UUID.Zero;
  1534. packet.ItemData[0].Type = -1;
  1535. packet.ItemData[0].GroupID = UUID.Zero;
  1536. packet.ItemData[0].GroupOwned = false;
  1537. packet.ItemData[0].GroupMask = 0;
  1538. packet.ItemData[0].CreationDate = 0;
  1539. packet.ItemData[0].SalePrice = 0;
  1540. packet.ItemData[0].SaleType = 0;
  1541. packet.ItemData[0].Flags = 0;
  1542. // No need to add CRC
  1543. }
  1544. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1545. {
  1546. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1547. descend.Header.Zerocoded = true;
  1548. descend.AgentData.AgentID = AgentId;
  1549. descend.AgentData.OwnerID = ownerID;
  1550. descend.AgentData.FolderID = folderID;
  1551. descend.AgentData.Version = version;
  1552. descend.AgentData.Descendents = descendents;
  1553. if (folders > 0)
  1554. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1555. else
  1556. AddNullFolderBlockToDecendentsPacket(ref descend);
  1557. if (items > 0)
  1558. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1559. else
  1560. AddNullItemBlockToDescendentsPacket(ref descend);
  1561. return descend;
  1562. }
  1563. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1564. {
  1565. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1566. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1567. // TODO: don't create new blocks if recycling an old packet
  1568. inventoryReply.AgentData.AgentID = AgentId;
  1569. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1570. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1571. inventoryReply.InventoryData[0].ItemID = item.ID;
  1572. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1573. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1574. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1575. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1576. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1577. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1578. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1579. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1580. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1581. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1582. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1583. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1584. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1585. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1586. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1587. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1588. inventoryReply.InventoryData[0].Flags = item.Flags;
  1589. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1590. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1591. inventoryReply.InventoryData[0].CRC =
  1592. Helpers.InventoryCRC(
  1593. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1594. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1595. inventoryReply.InventoryData[0].GroupID, 100,
  1596. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1597. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1598. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1599. FULL_MASK_PERMISSIONS);
  1600. inventoryReply.Header.Zerocoded = true;
  1601. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1602. }
  1603. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1604. {
  1605. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1606. UUID transactionId = UUID.Random();
  1607. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1608. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1609. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1610. if (folderDataBlocks.Count > 0)
  1611. {
  1612. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1613. // Send these now
  1614. BulkUpdateInventoryPacket bulkUpdate
  1615. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1616. bulkUpdate.Header.Zerocoded = true;
  1617. bulkUpdate.AgentData.AgentID = AgentId;
  1618. bulkUpdate.AgentData.TransactionID = transactionId;
  1619. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1620. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1621. bulkUpdate.ItemData = foo.ToArray();
  1622. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1623. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1624. }
  1625. }
  1626. /// <summary>
  1627. /// Recursively construct bulk update packets to send folders and items
  1628. /// </summary>
  1629. /// <param name="folder"></param>
  1630. /// <param name="folderDataBlocks"></param>
  1631. /// <param name="transactionId"></param>
  1632. private void SendBulkUpdateInventoryFolderRecursive(
  1633. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1634. UUID transactionId)
  1635. {
  1636. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1637. const int MAX_ITEMS_PER_PACKET = 5;
  1638. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1639. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1640. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1641. // being used on the Linden grid at 20081203).
  1642. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1643. List<InventoryItemBase> items = contents.Items;
  1644. while (items.Count > 0)
  1645. {
  1646. BulkUpdateInventoryPacket bulkUpdate
  1647. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1648. bulkUpdate.Header.Zerocoded = true;
  1649. bulkUpdate.AgentData.AgentID = AgentId;
  1650. bulkUpdate.AgentData.TransactionID = transactionId;
  1651. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1652. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1653. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1654. for (int i = 0; i < itemsToSend; i++)
  1655. {
  1656. // Remove from the end of the list so that we don't incur a performance penalty
  1657. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1658. items.RemoveAt(items.Count - 1);
  1659. }
  1660. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1661. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1662. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1663. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1664. // items belong.
  1665. if (items.Count > 0)
  1666. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1667. }
  1668. List<InventoryFolderBase> subFolders = contents.Folders;
  1669. foreach (InventoryFolderBase subFolder in subFolders)
  1670. {
  1671. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1672. }
  1673. }
  1674. /// <summary>
  1675. /// Generate a bulk update inventory data block for the given folder
  1676. /// </summary>
  1677. /// <param name="folder"></param>
  1678. /// <returns></returns>
  1679. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1680. {
  1681. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1682. folderBlock.FolderID = folder.ID;
  1683. folderBlock.ParentID = folder.ParentID;
  1684. folderBlock.Type = -1;
  1685. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1686. return folderBlock;
  1687. }
  1688. /// <summary>
  1689. /// Generate a bulk update inventory data block for the given item
  1690. /// </summary>
  1691. /// <param name="item"></param>
  1692. /// <returns></returns>
  1693. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1694. {
  1695. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1696. itemBlock.ItemID = item.ID;
  1697. itemBlock.AssetID = item.AssetID;
  1698. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1699. itemBlock.BaseMask = item.BasePermissions;
  1700. itemBlock.Description = Util.StringToBytes256(item.Description);
  1701. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1702. itemBlock.FolderID = item.Folder;
  1703. itemBlock.InvType = (sbyte)item.InvType;
  1704. itemBlock.Name = Util.StringToBytes256(item.Name);
  1705. itemBlock.NextOwnerMask = item.NextPermissions;
  1706. itemBlock.OwnerID = item.Owner;
  1707. itemBlock.OwnerMask = item.CurrentPermissions;
  1708. itemBlock.Type = (sbyte)item.AssetType;
  1709. itemBlock.GroupID = item.GroupID;
  1710. itemBlock.GroupOwned = item.GroupOwned;
  1711. itemBlock.GroupMask = item.GroupPermissions;
  1712. itemBlock.Flags = item.Flags;
  1713. itemBlock.SalePrice = item.SalePrice;
  1714. itemBlock.SaleType = item.SaleType;
  1715. itemBlock.CreationDate = item.CreationDate;
  1716. itemBlock.CRC =
  1717. Helpers.InventoryCRC(
  1718. 1000, 0, itemBlock.InvType,
  1719. itemBlock.Type, itemBlock.AssetID,
  1720. itemBlock.GroupID, 100,
  1721. itemBlock.OwnerID, itemBlock.CreatorID,
  1722. itemBlock.ItemID, itemBlock.FolderID,
  1723. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1724. (uint)PermissionMask.All);
  1725. return itemBlock;
  1726. }
  1727. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1728. {
  1729. if (node is InventoryItemBase)
  1730. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1731. else if (node is InventoryFolderBase)
  1732. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1733. else if (node != null)
  1734. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1735. else
  1736. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1737. }
  1738. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1739. {
  1740. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1741. BulkUpdateInventoryPacket bulkUpdate
  1742. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1743. bulkUpdate.AgentData.AgentID = AgentId;
  1744. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1745. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1746. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1747. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1748. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1749. bulkUpdate.FolderData[0].Type = -1;
  1750. bulkUpdate.FolderData[0].Name = new byte[0];
  1751. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1752. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1753. bulkUpdate.ItemData[0].ItemID = item.ID;
  1754. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1755. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1756. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1757. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1758. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1759. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1760. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1761. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1762. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1763. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1764. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1765. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1766. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1767. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1768. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1769. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1770. bulkUpdate.ItemData[0].Flags = item.Flags;
  1771. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1772. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1773. bulkUpdate.ItemData[0].CRC =
  1774. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1775. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1776. bulkUpdate.ItemData[0].GroupID, 100,
  1777. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1778. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1779. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1780. FULL_MASK_PERMISSIONS);
  1781. bulkUpdate.Header.Zerocoded = true;
  1782. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1783. }
  1784. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1785. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1786. {
  1787. const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
  1788. UpdateCreateInventoryItemPacket InventoryReply
  1789. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1790. PacketType.UpdateCreateInventoryItem);
  1791. // TODO: don't create new blocks if recycling an old packet
  1792. InventoryReply.AgentData.AgentID = AgentId;
  1793. InventoryReply.AgentData.SimApproved = true;
  1794. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1795. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1796. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1797. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1798. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1799. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1800. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1801. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1802. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1803. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1804. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1805. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1806. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1807. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1808. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1809. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1810. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1811. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1812. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1813. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1814. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1815. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1816. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1817. InventoryReply.InventoryData[0].CRC =
  1818. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1819. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1820. InventoryReply.InventoryData[0].GroupID, 100,
  1821. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1822. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1823. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1824. FULL_MASK_PERMISSIONS);
  1825. InventoryReply.Header.Zerocoded = true;
  1826. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1827. }
  1828. public void SendRemoveInventoryItem(UUID itemID)
  1829. {
  1830. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1831. // TODO: don't create new blocks if recycling an old packet
  1832. remove.AgentData.AgentID = AgentId;
  1833. remove.AgentData.SessionID = m_sessionId;
  1834. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1835. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1836. remove.InventoryData[0].ItemID = itemID;
  1837. remove.Header.Zerocoded = true;
  1838. OutPacket(remove, ThrottleOutPacketType.Asset);
  1839. }
  1840. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1841. {
  1842. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1843. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1844. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1845. ddata.Controls = (uint)controls;
  1846. ddata.PassToAgent = passToAgent;
  1847. ddata.TakeControls = TakeControls;
  1848. data[0] = ddata;
  1849. scriptcontrol.Data = data;
  1850. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1851. }
  1852. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1853. {
  1854. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1855. replytask.InventoryData.TaskID = taskID;
  1856. replytask.InventoryData.Serial = serial;
  1857. replytask.InventoryData.Filename = fileName;
  1858. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1859. }
  1860. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1861. {
  1862. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1863. sendXfer.XferID.ID = xferID;
  1864. sendXfer.XferID.Packet = packet;
  1865. sendXfer.DataPacket.Data = data;
  1866. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1867. }
  1868. public void SendAbortXferPacket(ulong xferID)
  1869. {
  1870. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1871. xferItem.XferID.ID = xferID;
  1872. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1873. }
  1874. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1875. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1876. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1877. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1878. {
  1879. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1880. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1881. economyData.Info.ObjectCapacity = ObjectCapacity;
  1882. economyData.Info.ObjectCount = ObjectCount;
  1883. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1884. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1885. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1886. economyData.Info.PriceObjectRent = PriceObjectRent;
  1887. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1888. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1889. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1890. economyData.Info.PriceParcelRent = PriceParcelRent;
  1891. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1892. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1893. economyData.Info.PriceRentLight = PriceRentLight;
  1894. economyData.Info.PriceUpload = PriceUpload;
  1895. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1896. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1897. economyData.Header.Reliable = true;
  1898. OutPacket(economyData, ThrottleOutPacketType.Task);
  1899. }
  1900. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1901. {
  1902. //construct the AvatarPickerReply packet.
  1903. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1904. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1905. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1906. //int i = 0;
  1907. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  1908. foreach (AvatarPickerReplyDataArgs arg in Data)
  1909. {
  1910. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  1911. db.AvatarID = arg.AvatarID;
  1912. db.FirstName = arg.FirstName;
  1913. db.LastName = arg.LastName;
  1914. data_block.Add(db);
  1915. }
  1916. replyPacket.Data = data_block.ToArray();
  1917. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  1918. }
  1919. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  1920. {
  1921. m_activeGroupID = activegroupid;
  1922. m_activeGroupName = groupname;
  1923. m_activeGroupPowers = grouppowers;
  1924. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  1925. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  1926. sendAgentDataUpdate.AgentData.AgentID = agentid;
  1927. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  1928. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  1929. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  1930. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  1931. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  1932. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  1933. }
  1934. /// <summary>
  1935. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  1936. /// blue information box in the bottom right hand corner.
  1937. /// </summary>
  1938. /// <param name="message"></param>
  1939. public void SendAlertMessage(string message)
  1940. {
  1941. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  1942. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  1943. alertPack.AlertData.Message = Util.StringToBytes256(message);
  1944. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  1945. OutPacket(alertPack, ThrottleOutPacketType.Task);
  1946. }
  1947. /// <summary>
  1948. /// Send an agent alert message to the client.
  1949. /// </summary>
  1950. /// <param name="message"></param>
  1951. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  1952. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  1953. /// the AlertMessage packet).</param>
  1954. public void SendAgentAlertMessage(string message, bool modal)
  1955. {
  1956. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  1957. }
  1958. /// <summary>
  1959. /// Construct an agent alert packet
  1960. /// </summary>
  1961. /// <param name="message"></param>
  1962. /// <param name="modal"></param>
  1963. /// <returns></returns>
  1964. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  1965. {
  1966. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  1967. alertPack.AgentData.AgentID = AgentId;
  1968. alertPack.AlertData.Message = Util.StringToBytes256(message);
  1969. alertPack.AlertData.Modal = modal;
  1970. return alertPack;
  1971. }
  1972. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  1973. string url)
  1974. {
  1975. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  1976. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  1977. loadURL.Data.ObjectID = objectID;
  1978. loadURL.Data.OwnerID = ownerID;
  1979. loadURL.Data.OwnerIsGroup = groupOwned;
  1980. loadURL.Data.Message = Util.StringToBytes256(message);
  1981. loadURL.Data.URL = Util.StringToBytes256(url);
  1982. OutPacket(loadURL, ThrottleOutPacketType.Task);
  1983. }
  1984. public void SendDialog(
  1985. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  1986. UUID textureID, int ch, string[] buttonlabels)
  1987. {
  1988. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  1989. dialog.Data.ObjectID = objectID;
  1990. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  1991. // this is the username of the *owner*
  1992. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  1993. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  1994. dialog.Data.Message = Util.StringToBytes1024(msg);
  1995. dialog.Data.ImageID = textureID;
  1996. dialog.Data.ChatChannel = ch;
  1997. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  1998. for (int i = 0; i < buttonlabels.Length; i++)
  1999. {
  2000. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2001. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2002. }
  2003. dialog.Buttons = buttons;
  2004. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2005. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2006. dialog.OwnerData[0].OwnerID = ownerID;
  2007. OutPacket(dialog, ThrottleOutPacketType.Task);
  2008. }
  2009. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2010. {
  2011. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2012. // TODO: don't create new blocks if recycling an old packet
  2013. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2014. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2015. preSound.DataBlock[0].ObjectID = objectID;
  2016. preSound.DataBlock[0].OwnerID = ownerID;
  2017. preSound.DataBlock[0].SoundID = soundID;
  2018. preSound.Header.Zerocoded = true;
  2019. OutPacket(preSound, ThrottleOutPacketType.Task);
  2020. }
  2021. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2022. {
  2023. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2024. sound.DataBlock.SoundID = soundID;
  2025. sound.DataBlock.ObjectID = objectID;
  2026. sound.DataBlock.OwnerID = ownerID;
  2027. sound.DataBlock.Gain = gain;
  2028. sound.DataBlock.Flags = flags;
  2029. OutPacket(sound, ThrottleOutPacketType.Task);
  2030. }
  2031. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2032. {
  2033. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2034. sound.SoundData.SoundID = soundID;
  2035. sound.SoundData.OwnerID = ownerID;
  2036. sound.SoundData.ObjectID = objectID;
  2037. sound.SoundData.ParentID = parentID;
  2038. sound.SoundData.Handle = handle;
  2039. sound.SoundData.Position = position;
  2040. sound.SoundData.Gain = gain;
  2041. OutPacket(sound, ThrottleOutPacketType.Task);
  2042. }
  2043. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2044. {
  2045. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2046. sound.DataBlock.ObjectID = objectID;
  2047. sound.DataBlock.Gain = gain;
  2048. OutPacket(sound, ThrottleOutPacketType.Task);
  2049. }
  2050. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2051. {
  2052. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2053. // So adjust for that
  2054. // Contributed by: Godfrey
  2055. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2056. {
  2057. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2058. }
  2059. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2060. viewertime.TimeInfo.SunDirection = Position;
  2061. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2062. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2063. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2064. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2065. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2066. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2067. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2068. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2069. viewertime.Header.Reliable = false;
  2070. viewertime.Header.Zerocoded = true;
  2071. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2072. }
  2073. // Currently Deprecated
  2074. public void SendViewerTime(int phase)
  2075. {
  2076. /*
  2077. Console.WriteLine("SunPhase: {0}", phase);
  2078. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2079. //viewertime.TimeInfo.SecPerDay = 86400;
  2080. //viewertime.TimeInfo.SecPerYear = 31536000;
  2081. viewertime.TimeInfo.SecPerDay = 1000;
  2082. viewertime.TimeInfo.SecPerYear = 365000;
  2083. viewertime.TimeInfo.SunPhase = 1;
  2084. int sunPhase = (phase + 2) / 2;
  2085. if ((sunPhase < 6) || (sunPhase > 36))
  2086. {
  2087. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2088. Console.WriteLine("sending night");
  2089. }
  2090. else
  2091. {
  2092. if (sunPhase < 12)
  2093. {
  2094. sunPhase = 12;
  2095. }
  2096. sunPhase = sunPhase - 12;
  2097. float yValue = 0.1f * (sunPhase);
  2098. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2099. if (yValue > 1.2f)
  2100. {
  2101. yValue = yValue - 1.2f;
  2102. }
  2103. yValue = Util.Clip(yValue, 0, 1);
  2104. if (sunPhase < 14)
  2105. {
  2106. yValue = 1 - yValue;
  2107. }
  2108. if (sunPhase < 12)
  2109. {
  2110. yValue *= -1;
  2111. }
  2112. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2113. Console.WriteLine("sending sun update " + yValue);
  2114. }
  2115. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2116. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2117. viewertime.Header.Reliable = false;
  2118. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2119. */
  2120. }
  2121. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2122. {
  2123. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2124. packet.Header.Reliable = false;
  2125. packet.Header.Zerocoded = true;
  2126. packet.AgentData.AgentID = AgentId;
  2127. packet.AgentData.SessionID = SessionId;
  2128. packet.Effect = effectBlocks;
  2129. // OutPacket(packet, ThrottleOutPacketType.State);
  2130. OutPacket(packet, ThrottleOutPacketType.Task);
  2131. }
  2132. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2133. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2134. UUID partnerID)
  2135. {
  2136. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2137. avatarReply.AgentData.AgentID = AgentId;
  2138. avatarReply.AgentData.AvatarID = avatarID;
  2139. if (aboutText != null)
  2140. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2141. else
  2142. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2143. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2144. avatarReply.PropertiesData.CharterMember = charterMember;
  2145. if (flAbout != null)
  2146. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2147. else
  2148. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2149. avatarReply.PropertiesData.Flags = flags;
  2150. avatarReply.PropertiesData.FLImageID = flImageID;
  2151. avatarReply.PropertiesData.ImageID = imageID;
  2152. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2153. avatarReply.PropertiesData.PartnerID = partnerID;
  2154. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2155. }
  2156. /// <summary>
  2157. /// Send the client an Estate message blue box pop-down with a single OK button
  2158. /// </summary>
  2159. /// <param name="FromAvatarID"></param>
  2160. /// <param name="fromSessionID"></param>
  2161. /// <param name="FromAvatarName"></param>
  2162. /// <param name="Message"></param>
  2163. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2164. {
  2165. if (!SceneAgent.IsChildAgent)
  2166. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2167. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2168. }
  2169. public void SendLogoutPacket()
  2170. {
  2171. // I know this is a bit of a hack, however there are times when you don't
  2172. // want to send this, but still need to do the rest of the shutdown process
  2173. // this method gets called from the packet server.. which makes it practically
  2174. // impossible to do any other way.
  2175. if (m_SendLogoutPacketWhenClosing)
  2176. {
  2177. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2178. // TODO: don't create new blocks if recycling an old packet
  2179. logReply.AgentData.AgentID = AgentId;
  2180. logReply.AgentData.SessionID = SessionId;
  2181. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2182. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2183. logReply.InventoryData[0].ItemID = UUID.Zero;
  2184. OutPacket(logReply, ThrottleOutPacketType.Task);
  2185. }
  2186. }
  2187. public void SendHealth(float health)
  2188. {
  2189. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2190. healthpacket.HealthData.Health = health;
  2191. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2192. }
  2193. public void SendAgentOnline(UUID[] agentIDs)
  2194. {
  2195. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2196. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2197. for (int i = 0; i < agentIDs.Length; i++)
  2198. {
  2199. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2200. onpbl.AgentID = agentIDs[i];
  2201. onpb[i] = onpbl;
  2202. }
  2203. onp.AgentBlock = onpb;
  2204. onp.Header.Reliable = true;
  2205. OutPacket(onp, ThrottleOutPacketType.Task);
  2206. }
  2207. public void SendAgentOffline(UUID[] agentIDs)
  2208. {
  2209. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2210. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2211. for (int i = 0; i < agentIDs.Length; i++)
  2212. {
  2213. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2214. onpbl.AgentID = agentIDs[i];
  2215. offpb[i] = onpbl;
  2216. }
  2217. offp.AgentBlock = offpb;
  2218. offp.Header.Reliable = true;
  2219. OutPacket(offp, ThrottleOutPacketType.Task);
  2220. }
  2221. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2222. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2223. {
  2224. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2225. avatarSitResponse.SitObject.ID = TargetID;
  2226. if (CameraAtOffset != Vector3.Zero)
  2227. {
  2228. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2229. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2230. }
  2231. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2232. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2233. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2234. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2235. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2236. }
  2237. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2238. {
  2239. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2240. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2241. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2242. adb.AgentID = AgentId;
  2243. adb.SessionID = SessionId; // More security
  2244. gdb.GodLevel = (byte)AdminLevel;
  2245. gdb.Token = Token;
  2246. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2247. respondPacket.GrantData = gdb;
  2248. respondPacket.AgentData = adb;
  2249. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2250. }
  2251. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2252. {
  2253. m_groupPowers.Clear();
  2254. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2255. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2256. for (int i = 0; i < GroupMembership.Length; i++)
  2257. {
  2258. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2259. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2260. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2261. Group.Contribution = GroupMembership[i].Contribution;
  2262. Group.GroupID = GroupMembership[i].GroupID;
  2263. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2264. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2265. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2266. Groups[i] = Group;
  2267. }
  2268. Groupupdate.GroupData = Groups;
  2269. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2270. Groupupdate.AgentData.AgentID = AgentId;
  2271. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2272. try
  2273. {
  2274. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2275. if (eq != null)
  2276. {
  2277. eq.GroupMembership(Groupupdate, this.AgentId);
  2278. }
  2279. }
  2280. catch (Exception ex)
  2281. {
  2282. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2283. m_log.Warn("sending group membership data via UDP");
  2284. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2285. }
  2286. }
  2287. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2288. {
  2289. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2290. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2291. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2292. uidnamebloc.ID = groupLLUID;
  2293. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2294. uidnameblock[0] = uidnamebloc;
  2295. pack.UUIDNameBlock = uidnameblock;
  2296. OutPacket(pack, ThrottleOutPacketType.Task);
  2297. }
  2298. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2299. {
  2300. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2301. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2302. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2303. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2304. // lsrepdb.
  2305. lsrp.RequestData.ReportType = reportType;
  2306. lsrp.RequestData.RequestFlags = requestFlags;
  2307. lsrp.RequestData.TotalObjectCount = resultCount;
  2308. for (int i = 0; i < lsrpia.Length; i++)
  2309. {
  2310. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2311. lsrepdb.LocationX = lsrpia[i].LocationX;
  2312. lsrepdb.LocationY = lsrpia[i].LocationY;
  2313. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2314. lsrepdb.Score = lsrpia[i].Score;
  2315. lsrepdb.TaskID = lsrpia[i].TaskID;
  2316. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2317. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2318. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2319. lsrepdba[i] = lsrepdb;
  2320. }
  2321. lsrp.ReportData = lsrepdba;
  2322. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2323. }
  2324. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2325. {
  2326. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2327. scriptRunningReply.Script.ObjectID = objectID;
  2328. scriptRunningReply.Script.ItemID = itemID;
  2329. scriptRunningReply.Script.Running = running;
  2330. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2331. }
  2332. public void SendAsset(AssetRequestToClient req)
  2333. {
  2334. if (req.AssetInf.Data == null)
  2335. {
  2336. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2337. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2338. return;
  2339. }
  2340. //m_log.Debug("sending asset " + req.RequestAssetID);
  2341. TransferInfoPacket Transfer = new TransferInfoPacket();
  2342. Transfer.TransferInfo.ChannelType = 2;
  2343. Transfer.TransferInfo.Status = 0;
  2344. Transfer.TransferInfo.TargetType = 0;
  2345. if (req.AssetRequestSource == 2)
  2346. {
  2347. Transfer.TransferInfo.Params = new byte[20];
  2348. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2349. int assType = req.AssetInf.Type;
  2350. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2351. }
  2352. else if (req.AssetRequestSource == 3)
  2353. {
  2354. Transfer.TransferInfo.Params = req.Params;
  2355. // Transfer.TransferInfo.Params = new byte[100];
  2356. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2357. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2358. }
  2359. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2360. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2361. Transfer.Header.Zerocoded = true;
  2362. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2363. if (req.NumPackets == 1)
  2364. {
  2365. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2366. TransferPacket.TransferData.Packet = 0;
  2367. TransferPacket.TransferData.ChannelType = 2;
  2368. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2369. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2370. TransferPacket.TransferData.Status = 1;
  2371. TransferPacket.Header.Zerocoded = true;
  2372. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2373. }
  2374. else
  2375. {
  2376. int processedLength = 0;
  2377. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2378. int packetNumber = 0;
  2379. while (processedLength < req.AssetInf.Data.Length)
  2380. {
  2381. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2382. TransferPacket.TransferData.Packet = packetNumber;
  2383. TransferPacket.TransferData.ChannelType = 2;
  2384. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2385. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2386. byte[] chunk = new byte[chunkSize];
  2387. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2388. TransferPacket.TransferData.Data = chunk;
  2389. // 0 indicates more packets to come, 1 indicates last packet
  2390. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2391. {
  2392. TransferPacket.TransferData.Status = 0;
  2393. }
  2394. else
  2395. {
  2396. TransferPacket.TransferData.Status = 1;
  2397. }
  2398. TransferPacket.Header.Zerocoded = true;
  2399. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2400. processedLength += chunkSize;
  2401. packetNumber++;
  2402. }
  2403. }
  2404. }
  2405. public void SendTexture(AssetBase TextureAsset)
  2406. {
  2407. }
  2408. public void SendRegionHandle(UUID regionID, ulong handle)
  2409. {
  2410. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2411. reply.ReplyBlock.RegionID = regionID;
  2412. reply.ReplyBlock.RegionHandle = handle;
  2413. OutPacket(reply, ThrottleOutPacketType.Land);
  2414. }
  2415. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2416. {
  2417. float dwell = 0.0f;
  2418. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2419. if (dwellModule != null)
  2420. dwell = dwellModule.GetDwell(land.GlobalID);
  2421. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2422. reply.AgentData.AgentID = m_agentId;
  2423. reply.Data.ParcelID = parcelID;
  2424. reply.Data.OwnerID = land.OwnerID;
  2425. reply.Data.Name = Utils.StringToBytes(land.Name);
  2426. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2427. reply.Data.ActualArea = land.Area;
  2428. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2429. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2430. reply.Data.Flags = (byte)(
  2431. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2432. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2433. Vector3 pos = land.UserLocation;
  2434. if (pos.Equals(Vector3.Zero))
  2435. {
  2436. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2437. }
  2438. reply.Data.GlobalX = info.RegionLocX + x;
  2439. reply.Data.GlobalY = info.RegionLocY + y;
  2440. reply.Data.GlobalZ = pos.Z;
  2441. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2442. reply.Data.SnapshotID = land.SnapshotID;
  2443. reply.Data.Dwell = dwell;
  2444. reply.Data.SalePrice = land.SalePrice;
  2445. reply.Data.AuctionID = (int)land.AuctionID;
  2446. OutPacket(reply, ThrottleOutPacketType.Land);
  2447. }
  2448. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2449. {
  2450. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2451. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2452. packet.Data.SimName = Utils.StringToBytes(simName);
  2453. packet.Data.SimPosition = pos;
  2454. packet.Data.LookAt = lookAt;
  2455. OutPacket(packet, ThrottleOutPacketType.Task);
  2456. }
  2457. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2458. {
  2459. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2460. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2461. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2462. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2463. packet.AgentData.AgentID = AgentId;
  2464. packet.QueryData[0].QueryID = queryID;
  2465. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2466. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2467. DirPlacesReplyPacket.StatusDataBlock[] status =
  2468. new DirPlacesReplyPacket.StatusDataBlock[0];
  2469. packet.QueryReplies = replies;
  2470. packet.StatusData = status;
  2471. foreach (DirPlacesReplyData d in data)
  2472. {
  2473. int idx = replies.Length;
  2474. Array.Resize(ref replies, idx + 1);
  2475. Array.Resize(ref status, idx + 1);
  2476. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2477. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2478. replies[idx].ParcelID = d.parcelID;
  2479. replies[idx].Name = Utils.StringToBytes(d.name);
  2480. replies[idx].ForSale = d.forSale;
  2481. replies[idx].Auction = d.auction;
  2482. replies[idx].Dwell = d.dwell;
  2483. status[idx].Status = d.Status;
  2484. packet.QueryReplies = replies;
  2485. packet.StatusData = status;
  2486. if (packet.Length >= 1000)
  2487. {
  2488. OutPacket(packet, ThrottleOutPacketType.Task);
  2489. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2490. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2491. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2492. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2493. packet.AgentData.AgentID = AgentId;
  2494. packet.QueryData[0].QueryID = queryID;
  2495. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2496. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2497. }
  2498. }
  2499. if (replies.Length > 0 || data.Length == 0)
  2500. OutPacket(packet, ThrottleOutPacketType.Task);
  2501. }
  2502. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2503. {
  2504. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2505. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2506. packet.AgentData.AgentID = AgentId;
  2507. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2508. packet.QueryData.QueryID = queryID;
  2509. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2510. data.Length];
  2511. int i = 0;
  2512. foreach (DirPeopleReplyData d in data)
  2513. {
  2514. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2515. packet.QueryReplies[i].AgentID = d.agentID;
  2516. packet.QueryReplies[i].FirstName =
  2517. Utils.StringToBytes(d.firstName);
  2518. packet.QueryReplies[i].LastName =
  2519. Utils.StringToBytes(d.lastName);
  2520. packet.QueryReplies[i].Group =
  2521. Utils.StringToBytes(d.group);
  2522. packet.QueryReplies[i].Online = d.online;
  2523. packet.QueryReplies[i].Reputation = d.reputation;
  2524. i++;
  2525. }
  2526. OutPacket(packet, ThrottleOutPacketType.Task);
  2527. }
  2528. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2529. {
  2530. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2531. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2532. packet.AgentData.AgentID = AgentId;
  2533. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2534. packet.QueryData.QueryID = queryID;
  2535. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2536. data.Length];
  2537. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2538. data.Length];
  2539. int i = 0;
  2540. foreach (DirEventsReplyData d in data)
  2541. {
  2542. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2543. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2544. packet.QueryReplies[i].OwnerID = d.ownerID;
  2545. packet.QueryReplies[i].Name =
  2546. Utils.StringToBytes(d.name);
  2547. packet.QueryReplies[i].EventID = d.eventID;
  2548. packet.QueryReplies[i].Date =
  2549. Utils.StringToBytes(d.date);
  2550. packet.QueryReplies[i].UnixTime = d.unixTime;
  2551. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2552. packet.StatusData[i].Status = d.Status;
  2553. i++;
  2554. }
  2555. OutPacket(packet, ThrottleOutPacketType.Task);
  2556. }
  2557. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2558. {
  2559. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2560. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2561. packet.AgentData.AgentID = AgentId;
  2562. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2563. packet.QueryData.QueryID = queryID;
  2564. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2565. data.Length];
  2566. int i = 0;
  2567. foreach (DirGroupsReplyData d in data)
  2568. {
  2569. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2570. packet.QueryReplies[i].GroupID = d.groupID;
  2571. packet.QueryReplies[i].GroupName =
  2572. Utils.StringToBytes(d.groupName);
  2573. packet.QueryReplies[i].Members = d.members;
  2574. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2575. i++;
  2576. }
  2577. OutPacket(packet, ThrottleOutPacketType.Task);
  2578. }
  2579. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2580. {
  2581. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2582. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2583. packet.AgentData.AgentID = AgentId;
  2584. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2585. packet.QueryData.QueryID = queryID;
  2586. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2587. data.Length];
  2588. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2589. data.Length];
  2590. int i = 0;
  2591. foreach (DirClassifiedReplyData d in data)
  2592. {
  2593. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2594. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2595. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2596. packet.QueryReplies[i].Name =
  2597. Utils.StringToBytes(d.name);
  2598. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2599. packet.QueryReplies[i].CreationDate = d.creationDate;
  2600. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2601. packet.QueryReplies[i].PriceForListing = d.price;
  2602. packet.StatusData[i].Status = d.Status;
  2603. i++;
  2604. }
  2605. OutPacket(packet, ThrottleOutPacketType.Task);
  2606. }
  2607. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2608. {
  2609. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2610. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2611. packet.AgentData.AgentID = AgentId;
  2612. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2613. packet.QueryData.QueryID = queryID;
  2614. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2615. data.Length];
  2616. int i = 0;
  2617. foreach (DirLandReplyData d in data)
  2618. {
  2619. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2620. packet.QueryReplies[i].ParcelID = d.parcelID;
  2621. packet.QueryReplies[i].Name =
  2622. Utils.StringToBytes(d.name);
  2623. packet.QueryReplies[i].Auction = d.auction;
  2624. packet.QueryReplies[i].ForSale = d.forSale;
  2625. packet.QueryReplies[i].SalePrice = d.salePrice;
  2626. packet.QueryReplies[i].ActualArea = d.actualArea;
  2627. i++;
  2628. }
  2629. OutPacket(packet, ThrottleOutPacketType.Task);
  2630. }
  2631. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2632. {
  2633. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2634. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2635. packet.AgentData.AgentID = AgentId;
  2636. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2637. packet.QueryData.QueryID = queryID;
  2638. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2639. data.Length];
  2640. int i = 0;
  2641. foreach (DirPopularReplyData d in data)
  2642. {
  2643. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2644. packet.QueryReplies[i].ParcelID = d.parcelID;
  2645. packet.QueryReplies[i].Name =
  2646. Utils.StringToBytes(d.name);
  2647. packet.QueryReplies[i].Dwell = d.dwell;
  2648. i++;
  2649. }
  2650. OutPacket(packet, ThrottleOutPacketType.Task);
  2651. }
  2652. public void SendEventInfoReply(EventData data)
  2653. {
  2654. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2655. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2656. packet.AgentData.AgentID = AgentId;
  2657. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2658. packet.EventData.EventID = data.eventID;
  2659. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2660. packet.EventData.Name = Utils.StringToBytes(data.name);
  2661. packet.EventData.Category = Utils.StringToBytes(data.category);
  2662. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2663. packet.EventData.Date = Utils.StringToBytes(data.date);
  2664. packet.EventData.DateUTC = data.dateUTC;
  2665. packet.EventData.Duration = data.duration;
  2666. packet.EventData.Cover = data.cover;
  2667. packet.EventData.Amount = data.amount;
  2668. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2669. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2670. packet.EventData.EventFlags = data.eventFlags;
  2671. OutPacket(packet, ThrottleOutPacketType.Task);
  2672. }
  2673. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2674. {
  2675. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2676. mirplk.AgentData.AgentID = AgentId;
  2677. mirplk.RequestData.ItemType = mapitemtype;
  2678. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2679. for (int i = 0; i < replies.Length; i++)
  2680. {
  2681. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2682. mrdata.X = replies[i].x;
  2683. mrdata.Y = replies[i].y;
  2684. mrdata.ID = replies[i].id;
  2685. mrdata.Extra = replies[i].Extra;
  2686. mrdata.Extra2 = replies[i].Extra2;
  2687. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2688. mirplk.Data[i] = mrdata;
  2689. }
  2690. //m_log.Debug(mirplk.ToString());
  2691. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2692. }
  2693. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2694. {
  2695. // a bit special, as this uses AgentID to store the source instead
  2696. // of the destination. The destination (the receiver) goes into destID
  2697. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2698. p.AgentData.AgentID = srcID;
  2699. p.AgentData.SessionID = UUID.Zero;
  2700. p.AgentBlock.DestID = AgentId;
  2701. p.AgentBlock.TransactionID = transactionID;
  2702. OutPacket(p, ThrottleOutPacketType.Task);
  2703. }
  2704. public void SendAcceptCallingCard(UUID transactionID)
  2705. {
  2706. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2707. p.AgentData.AgentID = AgentId;
  2708. p.AgentData.SessionID = UUID.Zero;
  2709. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2710. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2711. p.FolderData[0].FolderID = UUID.Zero;
  2712. OutPacket(p, ThrottleOutPacketType.Task);
  2713. }
  2714. public void SendDeclineCallingCard(UUID transactionID)
  2715. {
  2716. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2717. p.AgentData.AgentID = AgentId;
  2718. p.AgentData.SessionID = UUID.Zero;
  2719. p.TransactionBlock.TransactionID = transactionID;
  2720. OutPacket(p, ThrottleOutPacketType.Task);
  2721. }
  2722. public void SendTerminateFriend(UUID exFriendID)
  2723. {
  2724. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2725. p.AgentData.AgentID = AgentId;
  2726. p.AgentData.SessionID = SessionId;
  2727. p.ExBlock.OtherID = exFriendID;
  2728. OutPacket(p, ThrottleOutPacketType.Task);
  2729. }
  2730. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2731. {
  2732. OSDMap llsd = new OSDMap(3);
  2733. OSDArray AgentData = new OSDArray(1);
  2734. OSDMap AgentDataMap = new OSDMap(1);
  2735. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2736. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2737. AgentData.Add(AgentDataMap);
  2738. llsd.Add("AgentData", AgentData);
  2739. OSDArray GroupData = new OSDArray(data.Length);
  2740. OSDArray NewGroupData = new OSDArray(data.Length);
  2741. foreach (GroupMembershipData m in data)
  2742. {
  2743. OSDMap GroupDataMap = new OSDMap(6);
  2744. OSDMap NewGroupDataMap = new OSDMap(1);
  2745. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2746. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2747. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2748. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2749. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2750. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2751. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2752. GroupData.Add(GroupDataMap);
  2753. NewGroupData.Add(NewGroupDataMap);
  2754. }
  2755. llsd.Add("GroupData", GroupData);
  2756. llsd.Add("NewGroupData", NewGroupData);
  2757. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2758. if (eq != null)
  2759. {
  2760. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2761. }
  2762. }
  2763. public void SendJoinGroupReply(UUID groupID, bool success)
  2764. {
  2765. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2766. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2767. p.AgentData.AgentID = AgentId;
  2768. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2769. p.GroupData.GroupID = groupID;
  2770. p.GroupData.Success = success;
  2771. OutPacket(p, ThrottleOutPacketType.Task);
  2772. }
  2773. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2774. {
  2775. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2776. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2777. p.AgentData.AgentID = agentID;
  2778. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2779. p.GroupData.GroupID = groupID;
  2780. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2781. p.EjectData.Success = success;
  2782. OutPacket(p, ThrottleOutPacketType.Task);
  2783. }
  2784. public void SendLeaveGroupReply(UUID groupID, bool success)
  2785. {
  2786. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2787. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2788. p.AgentData.AgentID = AgentId;
  2789. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2790. p.GroupData.GroupID = groupID;
  2791. p.GroupData.Success = success;
  2792. OutPacket(p, ThrottleOutPacketType.Task);
  2793. }
  2794. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2795. {
  2796. if (classifiedID.Length != name.Length)
  2797. return;
  2798. AvatarClassifiedReplyPacket ac =
  2799. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2800. PacketType.AvatarClassifiedReply);
  2801. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2802. ac.AgentData.AgentID = AgentId;
  2803. ac.AgentData.TargetID = targetID;
  2804. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2805. int i;
  2806. for (i = 0; i < classifiedID.Length; i++)
  2807. {
  2808. ac.Data[i].ClassifiedID = classifiedID[i];
  2809. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2810. }
  2811. OutPacket(ac, ThrottleOutPacketType.Task);
  2812. }
  2813. 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)
  2814. {
  2815. ClassifiedInfoReplyPacket cr =
  2816. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2817. PacketType.ClassifiedInfoReply);
  2818. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2819. cr.AgentData.AgentID = AgentId;
  2820. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2821. cr.Data.ClassifiedID = classifiedID;
  2822. cr.Data.CreatorID = creatorID;
  2823. cr.Data.CreationDate = creationDate;
  2824. cr.Data.ExpirationDate = expirationDate;
  2825. cr.Data.Category = category;
  2826. cr.Data.Name = Utils.StringToBytes(name);
  2827. cr.Data.Desc = Utils.StringToBytes(description);
  2828. cr.Data.ParcelID = parcelID;
  2829. cr.Data.ParentEstate = parentEstate;
  2830. cr.Data.SnapshotID = snapshotID;
  2831. cr.Data.SimName = Utils.StringToBytes(simName);
  2832. cr.Data.PosGlobal = new Vector3d(globalPos);
  2833. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2834. cr.Data.ClassifiedFlags = classifiedFlags;
  2835. cr.Data.PriceForListing = price;
  2836. OutPacket(cr, ThrottleOutPacketType.Task);
  2837. }
  2838. public void SendAgentDropGroup(UUID groupID)
  2839. {
  2840. AgentDropGroupPacket dg =
  2841. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2842. PacketType.AgentDropGroup);
  2843. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2844. dg.AgentData.AgentID = AgentId;
  2845. dg.AgentData.GroupID = groupID;
  2846. OutPacket(dg, ThrottleOutPacketType.Task);
  2847. }
  2848. public void SendAvatarNotesReply(UUID targetID, string text)
  2849. {
  2850. AvatarNotesReplyPacket an =
  2851. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2852. PacketType.AvatarNotesReply);
  2853. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2854. an.AgentData.AgentID = AgentId;
  2855. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2856. an.Data.TargetID = targetID;
  2857. an.Data.Notes = Utils.StringToBytes(text);
  2858. OutPacket(an, ThrottleOutPacketType.Task);
  2859. }
  2860. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2861. {
  2862. AvatarPicksReplyPacket ap =
  2863. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2864. PacketType.AvatarPicksReply);
  2865. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2866. ap.AgentData.AgentID = AgentId;
  2867. ap.AgentData.TargetID = targetID;
  2868. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  2869. int i = 0;
  2870. foreach (KeyValuePair<UUID, string> pick in picks)
  2871. {
  2872. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  2873. ap.Data[i].PickID = pick.Key;
  2874. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  2875. i++;
  2876. }
  2877. OutPacket(ap, ThrottleOutPacketType.Task);
  2878. }
  2879. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  2880. {
  2881. AvatarClassifiedReplyPacket ac =
  2882. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2883. PacketType.AvatarClassifiedReply);
  2884. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2885. ac.AgentData.AgentID = AgentId;
  2886. ac.AgentData.TargetID = targetID;
  2887. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  2888. int i = 0;
  2889. foreach (KeyValuePair<UUID, string> classified in classifieds)
  2890. {
  2891. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  2892. ac.Data[i].ClassifiedID = classified.Key;
  2893. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  2894. i++;
  2895. }
  2896. OutPacket(ac, ThrottleOutPacketType.Task);
  2897. }
  2898. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  2899. {
  2900. ParcelDwellReplyPacket pd =
  2901. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  2902. PacketType.ParcelDwellReply);
  2903. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  2904. pd.AgentData.AgentID = AgentId;
  2905. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  2906. pd.Data.LocalID = localID;
  2907. pd.Data.ParcelID = parcelID;
  2908. pd.Data.Dwell = dwell;
  2909. OutPacket(pd, ThrottleOutPacketType.Land);
  2910. }
  2911. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  2912. {
  2913. UserInfoReplyPacket ur =
  2914. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  2915. PacketType.UserInfoReply);
  2916. string Visible = "hidden";
  2917. if (visible)
  2918. Visible = "default";
  2919. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  2920. ur.AgentData.AgentID = AgentId;
  2921. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  2922. ur.UserData.IMViaEMail = imViaEmail;
  2923. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  2924. ur.UserData.EMail = Utils.StringToBytes(email);
  2925. OutPacket(ur, ThrottleOutPacketType.Task);
  2926. }
  2927. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  2928. {
  2929. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  2930. createGroupReply.AgentData =
  2931. new CreateGroupReplyPacket.AgentDataBlock();
  2932. createGroupReply.ReplyData =
  2933. new CreateGroupReplyPacket.ReplyDataBlock();
  2934. createGroupReply.AgentData.AgentID = AgentId;
  2935. createGroupReply.ReplyData.GroupID = groupID;
  2936. createGroupReply.ReplyData.Success = success;
  2937. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  2938. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  2939. }
  2940. public void SendUseCachedMuteList()
  2941. {
  2942. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  2943. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  2944. useCachedMuteList.AgentData.AgentID = AgentId;
  2945. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  2946. }
  2947. public void SendMuteListUpdate(string filename)
  2948. {
  2949. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  2950. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  2951. muteListUpdate.MuteData.AgentID = AgentId;
  2952. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  2953. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  2954. }
  2955. 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)
  2956. {
  2957. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  2958. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  2959. pickInfoReply.AgentData.AgentID = AgentId;
  2960. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  2961. pickInfoReply.Data.PickID = pickID;
  2962. pickInfoReply.Data.CreatorID = creatorID;
  2963. pickInfoReply.Data.TopPick = topPick;
  2964. pickInfoReply.Data.ParcelID = parcelID;
  2965. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  2966. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  2967. pickInfoReply.Data.SnapshotID = snapshotID;
  2968. pickInfoReply.Data.User = Utils.StringToBytes(user);
  2969. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  2970. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  2971. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  2972. pickInfoReply.Data.SortOrder = sortOrder;
  2973. pickInfoReply.Data.Enabled = enabled;
  2974. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  2975. }
  2976. #endregion Scene/Avatar to Client
  2977. // Gesture
  2978. #region Appearance/ Wearables Methods
  2979. public void SendWearables(AvatarWearable[] wearables, int serial)
  2980. {
  2981. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  2982. aw.AgentData.AgentID = AgentId;
  2983. aw.AgentData.SerialNum = (uint)serial;
  2984. aw.AgentData.SessionID = m_sessionId;
  2985. int count = 0;
  2986. for (int i = 0; i < wearables.Length; i++)
  2987. count += wearables[i].Count;
  2988. // TODO: don't create new blocks if recycling an old packet
  2989. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  2990. AgentWearablesUpdatePacket.WearableDataBlock awb;
  2991. int idx = 0;
  2992. for (int i = 0; i < wearables.Length; i++)
  2993. {
  2994. for (int j = 0; j < wearables[i].Count; j++)
  2995. {
  2996. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  2997. awb.WearableType = (byte)i;
  2998. awb.AssetID = wearables[i][j].AssetID;
  2999. awb.ItemID = wearables[i][j].ItemID;
  3000. aw.WearableData[idx] = awb;
  3001. idx++;
  3002. // m_log.DebugFormat(
  3003. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3004. // awb.ItemID, awb.AssetID, i, Name);
  3005. }
  3006. }
  3007. OutPacket(aw, ThrottleOutPacketType.Task);
  3008. }
  3009. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3010. {
  3011. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3012. // TODO: don't create new blocks if recycling an old packet
  3013. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  3014. avp.ObjectData.TextureEntry = textureEntry;
  3015. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3016. for (int i = 0; i < visualParams.Length; i++)
  3017. {
  3018. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3019. avblock.ParamValue = visualParams[i];
  3020. avp.VisualParam[i] = avblock;
  3021. }
  3022. avp.Sender.IsTrial = false;
  3023. avp.Sender.ID = agentID;
  3024. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3025. OutPacket(avp, ThrottleOutPacketType.Task);
  3026. }
  3027. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3028. {
  3029. //m_log.DebugFormat("[CLIENT]: Sending animations to {0}", Name);
  3030. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3031. // TODO: don't create new blocks if recycling an old packet
  3032. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3033. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3034. ani.Sender.ID = sourceAgentId;
  3035. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3036. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3037. for (int i = 0; i < animations.Length; ++i)
  3038. {
  3039. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3040. ani.AnimationList[i].AnimID = animations[i];
  3041. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3042. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3043. if (objectIDs[i].Equals(sourceAgentId))
  3044. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3045. else
  3046. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3047. }
  3048. ani.Header.Reliable = false;
  3049. OutPacket(ani, ThrottleOutPacketType.Task);
  3050. }
  3051. #endregion
  3052. #region Avatar Packet/Data Sending Methods
  3053. /// <summary>
  3054. /// Send an ObjectUpdate packet with information about an avatar
  3055. /// </summary>
  3056. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3057. {
  3058. ScenePresence presence = avatar as ScenePresence;
  3059. if (presence == null)
  3060. return;
  3061. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3062. objupdate.Header.Zerocoded = true;
  3063. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3064. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3065. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3066. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3067. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3068. // We need to record the avatar local id since the root prim of an attachment points to this.
  3069. // m_attachmentsSent.Add(avatar.LocalId);
  3070. }
  3071. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3072. {
  3073. if (!IsActive) return; // We don't need to update inactive clients.
  3074. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3075. loc.Header.Reliable = false;
  3076. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3077. // a CoarseLocationUpdate packet is received. Oh well.
  3078. int total = Math.Min(CoarseLocations.Count, 60);
  3079. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3080. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3081. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3082. int selfindex = -1;
  3083. for (int i = 0; i < total; i++)
  3084. {
  3085. CoarseLocationUpdatePacket.LocationBlock lb =
  3086. new CoarseLocationUpdatePacket.LocationBlock();
  3087. lb.X = (byte)CoarseLocations[i].X;
  3088. lb.Y = (byte)CoarseLocations[i].Y;
  3089. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3090. loc.Location[i] = lb;
  3091. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3092. loc.AgentData[i].AgentID = users[i];
  3093. if (users[i] == AgentId)
  3094. selfindex = i;
  3095. }
  3096. ib.You = (short)selfindex;
  3097. ib.Prey = -1;
  3098. loc.Index = ib;
  3099. OutPacket(loc, ThrottleOutPacketType.Task);
  3100. }
  3101. #endregion Avatar Packet/Data Sending Methods
  3102. #region Primitive Packet/Data Sending Methods
  3103. /// <summary>
  3104. /// Generate one of the object update packets based on PrimUpdateFlags
  3105. /// and broadcast the packet to clients
  3106. /// </summary>
  3107. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3108. {
  3109. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3110. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3111. lock (m_entityUpdates.SyncRoot)
  3112. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3113. }
  3114. /// <summary>
  3115. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3116. /// We will update the priority and put it in the correct queue, merging update flags
  3117. /// with any other updates that may be queued for the same entity.
  3118. /// The original update time is used for the merged update.
  3119. /// </summary>
  3120. private void ResendPrimUpdate(EntityUpdate update)
  3121. {
  3122. // If the update exists in priority queue, it will be updated.
  3123. // If it does not exist then it will be added with the current (rather than its original) priority
  3124. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3125. lock (m_entityUpdates.SyncRoot)
  3126. m_entityUpdates.Enqueue(priority, update);
  3127. }
  3128. /// <summary>
  3129. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3130. /// We will update the priority and put it in the correct queue, merging update flags
  3131. /// with any other updates that may be queued for the same entity.
  3132. /// The original update time is used for the merged update.
  3133. /// </summary>
  3134. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3135. {
  3136. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3137. // Remove the update packet from the list of packets waiting for acknowledgement
  3138. // because we are requeuing the list of updates. They will be resent in new packets
  3139. // with the most recent state and priority.
  3140. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3141. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3142. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3143. foreach (EntityUpdate update in updates)
  3144. ResendPrimUpdate(update);
  3145. }
  3146. private void ProcessEntityUpdates(int maxUpdates)
  3147. {
  3148. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3149. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3150. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3151. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3152. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3153. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3154. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3155. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3156. // Check to see if this is a flush
  3157. if (maxUpdates <= 0)
  3158. {
  3159. maxUpdates = Int32.MaxValue;
  3160. }
  3161. int updatesThisCall = 0;
  3162. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3163. // condition where a kill can be processed before an out-of-date update for the same object.
  3164. lock (m_killRecord)
  3165. {
  3166. float avgTimeDilation = 1.0f;
  3167. IEntityUpdate iupdate;
  3168. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3169. while (updatesThisCall < maxUpdates)
  3170. {
  3171. lock (m_entityUpdates.SyncRoot)
  3172. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3173. break;
  3174. EntityUpdate update = (EntityUpdate)iupdate;
  3175. avgTimeDilation += update.TimeDilation;
  3176. avgTimeDilation *= 0.5f;
  3177. if (update.Entity is SceneObjectPart)
  3178. {
  3179. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3180. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3181. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3182. // safety measure.
  3183. //
  3184. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3185. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3186. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3187. //
  3188. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3189. // after the root prim has been deleted.
  3190. if (m_killRecord.Contains(part.LocalId))
  3191. {
  3192. // m_log.WarnFormat(
  3193. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3194. // part.LocalId, Name);
  3195. continue;
  3196. }
  3197. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3198. {
  3199. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3200. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3201. {
  3202. part.Shape.LightEntry = false;
  3203. }
  3204. }
  3205. }
  3206. ++updatesThisCall;
  3207. #region UpdateFlags to packet type conversion
  3208. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3209. bool canUseCompressed = true;
  3210. bool canUseImproved = true;
  3211. // Compressed object updates only make sense for LL primitives
  3212. if (!(update.Entity is SceneObjectPart))
  3213. {
  3214. canUseCompressed = false;
  3215. }
  3216. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3217. {
  3218. canUseCompressed = false;
  3219. canUseImproved = false;
  3220. }
  3221. else
  3222. {
  3223. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3224. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3225. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3226. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3227. {
  3228. canUseCompressed = false;
  3229. }
  3230. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3231. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3232. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3233. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3234. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3235. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3236. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3237. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3238. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3239. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3240. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3241. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3242. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3243. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3244. {
  3245. canUseImproved = false;
  3246. }
  3247. }
  3248. #endregion UpdateFlags to packet type conversion
  3249. #region Block Construction
  3250. // TODO: Remove this once we can build compressed updates
  3251. canUseCompressed = false;
  3252. if (!canUseImproved && !canUseCompressed)
  3253. {
  3254. if (update.Entity is ScenePresence)
  3255. {
  3256. objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity));
  3257. objectUpdates.Value.Add(update);
  3258. }
  3259. else
  3260. {
  3261. objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
  3262. objectUpdates.Value.Add(update);
  3263. }
  3264. }
  3265. else if (!canUseImproved)
  3266. {
  3267. compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags));
  3268. compressedUpdates.Value.Add(update);
  3269. }
  3270. else
  3271. {
  3272. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3273. {
  3274. // Self updates go into a special list
  3275. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3276. terseAgentUpdates.Value.Add(update);
  3277. }
  3278. else
  3279. {
  3280. // Everything else goes here
  3281. terseUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3282. terseUpdates.Value.Add(update);
  3283. }
  3284. }
  3285. #endregion Block Construction
  3286. }
  3287. #region Packet Sending
  3288. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3289. if (terseAgentUpdateBlocks.IsValueCreated)
  3290. {
  3291. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3292. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  3293. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3294. packet.RegionData.TimeDilation = timeDilation;
  3295. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3296. for (int i = 0; i < blocks.Count; i++)
  3297. packet.ObjectData[i] = blocks[i];
  3298. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3299. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3300. }
  3301. if (objectUpdateBlocks.IsValueCreated)
  3302. {
  3303. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3304. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3305. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3306. packet.RegionData.TimeDilation = timeDilation;
  3307. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3308. for (int i = 0; i < blocks.Count; i++)
  3309. packet.ObjectData[i] = blocks[i];
  3310. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3311. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3312. }
  3313. if (compressedUpdateBlocks.IsValueCreated)
  3314. {
  3315. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3316. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3317. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3318. packet.RegionData.TimeDilation = timeDilation;
  3319. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3320. for (int i = 0; i < blocks.Count; i++)
  3321. packet.ObjectData[i] = blocks[i];
  3322. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3323. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3324. }
  3325. if (terseUpdateBlocks.IsValueCreated)
  3326. {
  3327. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3328. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  3329. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3330. packet.RegionData.TimeDilation = timeDilation;
  3331. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3332. for (int i = 0; i < blocks.Count; i++)
  3333. packet.ObjectData[i] = blocks[i];
  3334. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3335. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3336. }
  3337. }
  3338. #endregion Packet Sending
  3339. }
  3340. public void ReprioritizeUpdates()
  3341. {
  3342. lock (m_entityUpdates.SyncRoot)
  3343. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3344. }
  3345. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3346. {
  3347. if (entity != null)
  3348. {
  3349. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3350. return true;
  3351. }
  3352. return false;
  3353. }
  3354. public void FlushPrimUpdates()
  3355. {
  3356. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3357. while (m_entityUpdates.Count > 0)
  3358. ProcessEntityUpdates(-1);
  3359. }
  3360. #endregion Primitive Packet/Data Sending Methods
  3361. // These are used to implement an adaptive backoff in the number
  3362. // of updates converted to packets. Since we don't want packets
  3363. // to sit in the queue with old data, only convert enough updates
  3364. // to packets that can be sent in 200ms.
  3365. private Int32 m_LastQueueFill = 0;
  3366. private Int32 m_maxUpdates = 0;
  3367. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3368. {
  3369. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3370. {
  3371. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3372. {
  3373. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3374. }
  3375. else
  3376. {
  3377. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3378. m_maxUpdates += 5;
  3379. else
  3380. m_maxUpdates = m_maxUpdates >> 1;
  3381. }
  3382. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3383. m_LastQueueFill = Util.EnvironmentTickCount();
  3384. if (m_entityUpdates.Count > 0)
  3385. ProcessEntityUpdates(m_maxUpdates);
  3386. if (m_entityProps.Count > 0)
  3387. ProcessEntityPropertyRequests(m_maxUpdates);
  3388. }
  3389. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3390. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3391. }
  3392. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3393. {
  3394. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3395. newPack.AssetBlock.Type = AssetType;
  3396. newPack.AssetBlock.Success = Success;
  3397. newPack.AssetBlock.UUID = AssetFullID;
  3398. newPack.Header.Zerocoded = true;
  3399. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3400. }
  3401. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3402. {
  3403. RequestXferPacket newPack = new RequestXferPacket();
  3404. newPack.XferID.ID = XferID;
  3405. newPack.XferID.VFileType = AssetType;
  3406. newPack.XferID.VFileID = vFileID;
  3407. newPack.XferID.FilePath = FilePath;
  3408. newPack.XferID.Filename = FileName;
  3409. newPack.Header.Zerocoded = true;
  3410. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3411. }
  3412. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3413. {
  3414. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3415. newPack.XferID.ID = xferID;
  3416. newPack.XferID.Packet = PacketID;
  3417. newPack.Header.Zerocoded = true;
  3418. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3419. }
  3420. public void SendInitiateDownload(string simFileName, string clientFileName)
  3421. {
  3422. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3423. newPack.AgentData.AgentID = AgentId;
  3424. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3425. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3426. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3427. }
  3428. public void SendImageFirstPart(
  3429. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3430. {
  3431. ImageDataPacket im = new ImageDataPacket();
  3432. im.Header.Reliable = false;
  3433. im.ImageID.Packets = numParts;
  3434. im.ImageID.ID = ImageUUID;
  3435. if (ImageSize > 0)
  3436. im.ImageID.Size = ImageSize;
  3437. im.ImageData.Data = ImageData;
  3438. im.ImageID.Codec = imageCodec;
  3439. im.Header.Zerocoded = true;
  3440. OutPacket(im, ThrottleOutPacketType.Texture);
  3441. }
  3442. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3443. {
  3444. ImagePacketPacket im = new ImagePacketPacket();
  3445. im.Header.Reliable = false;
  3446. im.ImageID.Packet = partNumber;
  3447. im.ImageID.ID = imageUuid;
  3448. im.ImageData.Data = imageData;
  3449. OutPacket(im, ThrottleOutPacketType.Texture);
  3450. }
  3451. public void SendImageNotFound(UUID imageid)
  3452. {
  3453. ImageNotInDatabasePacket notFoundPacket
  3454. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3455. notFoundPacket.ImageID.ID = imageid;
  3456. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3457. }
  3458. public void SendShutdownConnectionNotice()
  3459. {
  3460. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3461. }
  3462. public void SendSimStats(SimStats stats)
  3463. {
  3464. SimStatsPacket pack = new SimStatsPacket();
  3465. pack.Region = new SimStatsPacket.RegionBlock();
  3466. pack.Region.RegionX = stats.RegionX;
  3467. pack.Region.RegionY = stats.RegionY;
  3468. pack.Region.RegionFlags = stats.RegionFlags;
  3469. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3470. //pack.Region = //stats.RegionBlock;
  3471. pack.Stat = stats.StatsBlock;
  3472. pack.Header.Reliable = false;
  3473. OutPacket(pack, ThrottleOutPacketType.Task);
  3474. }
  3475. private class ObjectPropertyUpdate : IEntityUpdate
  3476. {
  3477. internal bool SendFamilyProps;
  3478. internal bool SendObjectProps;
  3479. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3480. : base(entity,flags)
  3481. {
  3482. SendFamilyProps = sendfam;
  3483. SendObjectProps = sendobj;
  3484. }
  3485. public void Update(ObjectPropertyUpdate update)
  3486. {
  3487. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3488. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3489. // other properties may need to be updated by base class
  3490. base.Update(update);
  3491. }
  3492. }
  3493. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3494. {
  3495. uint priority = 0; // time based ordering only
  3496. lock (m_entityProps.SyncRoot)
  3497. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3498. }
  3499. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3500. {
  3501. uint priority = 0;
  3502. lock (m_entityProps.SyncRoot)
  3503. m_entityProps.Enqueue(priority, update);
  3504. }
  3505. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3506. {
  3507. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3508. // Remove the update packet from the list of packets waiting for acknowledgement
  3509. // because we are requeuing the list of updates. They will be resent in new packets
  3510. // with the most recent state.
  3511. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3512. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3513. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3514. foreach (ObjectPropertyUpdate update in updates)
  3515. ResendPropertyUpdate(update);
  3516. }
  3517. public void SendObjectPropertiesReply(ISceneEntity entity)
  3518. {
  3519. uint priority = 0; // time based ordering only
  3520. lock (m_entityProps.SyncRoot)
  3521. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3522. }
  3523. private void ProcessEntityPropertyRequests(int maxUpdates)
  3524. {
  3525. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3526. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3527. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3528. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3529. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3530. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3531. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3532. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3533. IEntityUpdate iupdate;
  3534. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3535. int updatesThisCall = 0;
  3536. while (updatesThisCall < m_maxUpdates)
  3537. {
  3538. lock (m_entityProps.SyncRoot)
  3539. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3540. break;
  3541. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3542. if (update.SendFamilyProps)
  3543. {
  3544. if (update.Entity is SceneObjectPart)
  3545. {
  3546. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3547. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3548. objectFamilyBlocks.Value.Add(objPropDB);
  3549. familyUpdates.Value.Add(update);
  3550. }
  3551. }
  3552. if (update.SendObjectProps)
  3553. {
  3554. if (update.Entity is SceneObjectPart)
  3555. {
  3556. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3557. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3558. objectPropertiesBlocks.Value.Add(objPropDB);
  3559. propertyUpdates.Value.Add(update);
  3560. }
  3561. }
  3562. updatesThisCall++;
  3563. }
  3564. // Int32 ppcnt = 0;
  3565. // Int32 pbcnt = 0;
  3566. if (objectPropertiesBlocks.IsValueCreated)
  3567. {
  3568. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3569. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3570. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3571. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3572. for (int i = 0; i < blocks.Count; i++)
  3573. packet.ObjectData[i] = blocks[i];
  3574. packet.Header.Zerocoded = true;
  3575. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3576. // of the object rather than the properties when the packet was created
  3577. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3578. delegate(OutgoingPacket oPacket)
  3579. {
  3580. ResendPropertyUpdates(updates, oPacket);
  3581. });
  3582. // pbcnt += blocks.Count;
  3583. // ppcnt++;
  3584. }
  3585. // Int32 fpcnt = 0;
  3586. // Int32 fbcnt = 0;
  3587. if (objectFamilyBlocks.IsValueCreated)
  3588. {
  3589. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3590. // one packet per object block... uggh...
  3591. for (int i = 0; i < blocks.Count; i++)
  3592. {
  3593. ObjectPropertiesFamilyPacket packet =
  3594. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3595. packet.ObjectData = blocks[i];
  3596. packet.Header.Zerocoded = true;
  3597. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3598. // of the object rather than the properties when the packet was created
  3599. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3600. updates.Add(familyUpdates.Value[i]);
  3601. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3602. delegate(OutgoingPacket oPacket)
  3603. {
  3604. ResendPropertyUpdates(updates, oPacket);
  3605. });
  3606. // fpcnt++;
  3607. // fbcnt++;
  3608. }
  3609. }
  3610. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3611. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3612. }
  3613. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3614. {
  3615. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3616. block.RequestFlags = requestFlags;
  3617. block.ObjectID = sop.UUID;
  3618. if (sop.OwnerID == sop.GroupID)
  3619. block.OwnerID = UUID.Zero;
  3620. else
  3621. block.OwnerID = sop.OwnerID;
  3622. block.GroupID = sop.GroupID;
  3623. block.BaseMask = sop.BaseMask;
  3624. block.OwnerMask = sop.OwnerMask;
  3625. block.GroupMask = sop.GroupMask;
  3626. block.EveryoneMask = sop.EveryoneMask;
  3627. block.NextOwnerMask = sop.NextOwnerMask;
  3628. // TODO: More properties are needed in SceneObjectPart!
  3629. block.OwnershipCost = sop.OwnershipCost;
  3630. block.SaleType = sop.ObjectSaleType;
  3631. block.SalePrice = sop.SalePrice;
  3632. block.Category = sop.Category;
  3633. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3634. block.Name = Util.StringToBytes256(sop.Name);
  3635. block.Description = Util.StringToBytes256(sop.Description);
  3636. return block;
  3637. }
  3638. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3639. {
  3640. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3641. // TODO: don't create new blocks if recycling an old packet
  3642. ObjectPropertiesPacket.ObjectDataBlock block =
  3643. new ObjectPropertiesPacket.ObjectDataBlock();
  3644. block.ObjectID = sop.UUID;
  3645. block.Name = Util.StringToBytes256(sop.Name);
  3646. block.Description = Util.StringToBytes256(sop.Description);
  3647. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3648. block.CreatorID = sop.CreatorID;
  3649. block.GroupID = sop.GroupID;
  3650. block.LastOwnerID = sop.LastOwnerID;
  3651. if (sop.OwnerID == sop.GroupID)
  3652. block.OwnerID = UUID.Zero;
  3653. else
  3654. block.OwnerID = sop.OwnerID;
  3655. block.ItemID = sop.FromUserInventoryItemID;
  3656. block.FolderID = UUID.Zero; // sop.FromFolderID ??
  3657. block.FromTaskID = UUID.Zero; // ???
  3658. block.InventorySerial = (short)sop.InventorySerial;
  3659. SceneObjectPart root = sop.ParentGroup.RootPart;
  3660. block.TouchName = Util.StringToBytes256(root.TouchName);
  3661. block.TextureID = new byte[0]; // TextureID ???
  3662. block.SitName = Util.StringToBytes256(root.SitName);
  3663. block.OwnerMask = root.OwnerMask;
  3664. block.NextOwnerMask = root.NextOwnerMask;
  3665. block.GroupMask = root.GroupMask;
  3666. block.EveryoneMask = root.EveryoneMask;
  3667. block.BaseMask = root.BaseMask;
  3668. block.SaleType = root.ObjectSaleType;
  3669. block.SalePrice = root.SalePrice;
  3670. return block;
  3671. }
  3672. #region Estate Data Sending Methods
  3673. private static bool convertParamStringToBool(byte[] field)
  3674. {
  3675. string s = Utils.BytesToString(field);
  3676. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3677. {
  3678. return true;
  3679. }
  3680. return false;
  3681. }
  3682. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3683. {
  3684. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3685. packet.AgentData.TransactionID = UUID.Random();
  3686. packet.AgentData.AgentID = AgentId;
  3687. packet.AgentData.SessionID = SessionId;
  3688. packet.MethodData.Invoice = invoice;
  3689. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3690. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3691. for (int i = 0; i < (6 + Data.Length); i++)
  3692. {
  3693. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3694. }
  3695. int j = 0;
  3696. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3697. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3698. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3699. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3700. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3701. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3702. j = 2; // Agents
  3703. if ((code & 2) != 0)
  3704. j = 3; // Groups
  3705. if ((code & 8) != 0)
  3706. j = 5; // Managers
  3707. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3708. j = 6;
  3709. for (int i = 0; i < Data.Length; i++)
  3710. {
  3711. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3712. }
  3713. packet.ParamList = returnblock;
  3714. packet.Header.Reliable = true;
  3715. OutPacket(packet, ThrottleOutPacketType.Task);
  3716. }
  3717. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3718. {
  3719. List<UUID> BannedUsers = new List<UUID>();
  3720. for (int i = 0; i < bl.Length; i++)
  3721. {
  3722. if (bl[i] == null)
  3723. continue;
  3724. if (bl[i].BannedUserID == UUID.Zero)
  3725. continue;
  3726. BannedUsers.Add(bl[i].BannedUserID);
  3727. }
  3728. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3729. packet.AgentData.TransactionID = UUID.Random();
  3730. packet.AgentData.AgentID = AgentId;
  3731. packet.AgentData.SessionID = SessionId;
  3732. packet.MethodData.Invoice = invoice;
  3733. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3734. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  3735. for (int i = 0; i < (6 + BannedUsers.Count); i++)
  3736. {
  3737. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3738. }
  3739. int j = 0;
  3740. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3741. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  3742. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3743. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3744. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  3745. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3746. foreach (UUID banned in BannedUsers)
  3747. {
  3748. returnblock[j].Parameter = banned.GetBytes(); j++;
  3749. }
  3750. packet.ParamList = returnblock;
  3751. packet.Header.Reliable = false;
  3752. OutPacket(packet, ThrottleOutPacketType.Task);
  3753. }
  3754. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  3755. {
  3756. RegionInfoPacket rinfopack = new RegionInfoPacket();
  3757. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  3758. rinfopack.AgentData.AgentID = AgentId;
  3759. rinfopack.AgentData.SessionID = SessionId;
  3760. rinfoblk.BillableFactor = args.billableFactor;
  3761. rinfoblk.EstateID = args.estateID;
  3762. rinfoblk.MaxAgents = args.maxAgents;
  3763. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  3764. rinfoblk.ParentEstateID = args.parentEstateID;
  3765. rinfoblk.PricePerMeter = args.pricePerMeter;
  3766. rinfoblk.RedirectGridX = args.redirectGridX;
  3767. rinfoblk.RedirectGridY = args.redirectGridY;
  3768. rinfoblk.RegionFlags = args.regionFlags;
  3769. rinfoblk.SimAccess = args.simAccess;
  3770. rinfoblk.SunHour = args.sunHour;
  3771. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  3772. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  3773. rinfoblk.UseEstateSun = args.useEstateSun;
  3774. rinfoblk.WaterHeight = args.waterHeight;
  3775. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  3776. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  3777. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  3778. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  3779. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  3780. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  3781. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  3782. rinfopack.HasVariableBlocks = true;
  3783. rinfopack.RegionInfo = rinfoblk;
  3784. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  3785. rinfopack.AgentData.AgentID = AgentId;
  3786. rinfopack.AgentData.SessionID = SessionId;
  3787. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  3788. }
  3789. public void SendEstateCovenantInformation(UUID covenant)
  3790. {
  3791. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  3792. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  3793. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  3794. edata.CovenantID = covenant;
  3795. edata.CovenantTimestamp = 0;
  3796. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  3797. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  3798. einfopack.Data = edata;
  3799. OutPacket(einfopack, ThrottleOutPacketType.Task);
  3800. }
  3801. public void SendDetailedEstateData(
  3802. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  3803. UUID covenant, string abuseEmail, UUID estateOwner)
  3804. {
  3805. // m_log.DebugFormat(
  3806. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  3807. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3808. packet.MethodData.Invoice = invoice;
  3809. packet.AgentData.TransactionID = UUID.Random();
  3810. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  3811. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  3812. for (int i = 0; i < 10; i++)
  3813. {
  3814. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3815. }
  3816. //Sending Estate Settings
  3817. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  3818. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  3819. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  3820. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  3821. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  3822. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  3823. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  3824. returnblock[7].Parameter = Utils.StringToBytes("1160895077"); // what is this?
  3825. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  3826. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  3827. packet.ParamList = returnblock;
  3828. packet.Header.Reliable = false;
  3829. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  3830. OutPacket(packet, ThrottleOutPacketType.Task);
  3831. }
  3832. #endregion
  3833. #region Land Data Sending Methods
  3834. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  3835. {
  3836. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  3837. packet.ParcelData.Data = data;
  3838. packet.ParcelData.SequenceID = sequence_id;
  3839. packet.Header.Zerocoded = true;
  3840. OutPacket(packet, ThrottleOutPacketType.Task);
  3841. }
  3842. public void SendLandProperties(
  3843. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  3844. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  3845. {
  3846. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  3847. LandData landData = lo.LandData;
  3848. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  3849. updateMessage.AABBMax = landData.AABBMax;
  3850. updateMessage.AABBMin = landData.AABBMin;
  3851. updateMessage.Area = landData.Area;
  3852. updateMessage.AuctionID = landData.AuctionID;
  3853. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  3854. updateMessage.Bitmap = landData.Bitmap;
  3855. updateMessage.Desc = landData.Description;
  3856. updateMessage.Category = landData.Category;
  3857. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  3858. updateMessage.ClaimPrice = landData.ClaimPrice;
  3859. updateMessage.GroupID = landData.GroupID;
  3860. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  3861. updateMessage.LandingType = (LandingType) landData.LandingType;
  3862. updateMessage.LocalID = landData.LocalID;
  3863. if (landData.Area > 0)
  3864. {
  3865. updateMessage.MaxPrims = parcelObjectCapacity;
  3866. }
  3867. else
  3868. {
  3869. updateMessage.MaxPrims = 0;
  3870. }
  3871. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  3872. updateMessage.MediaID = landData.MediaID;
  3873. updateMessage.MediaURL = landData.MediaURL;
  3874. updateMessage.MusicURL = landData.MusicURL;
  3875. updateMessage.Name = landData.Name;
  3876. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  3877. updateMessage.OtherCount = 0; //TODO: Unimplemented
  3878. updateMessage.OwnerID = landData.OwnerID;
  3879. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  3880. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  3881. updateMessage.PassHours = landData.PassHours;
  3882. updateMessage.PassPrice = landData.PassPrice;
  3883. updateMessage.PublicCount = 0; //TODO: Unimplemented
  3884. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  3885. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  3886. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  3887. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  3888. updateMessage.RentPrice = 0;
  3889. updateMessage.RequestResult = (ParcelResult) request_result;
  3890. updateMessage.SalePrice = landData.SalePrice;
  3891. updateMessage.SelfCount = 0; //TODO: Unimplemented
  3892. updateMessage.SequenceID = sequence_id;
  3893. if (landData.SimwideArea > 0)
  3894. {
  3895. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  3896. updateMessage.SimWideMaxPrims = simulatorCapacity;
  3897. }
  3898. else
  3899. {
  3900. updateMessage.SimWideMaxPrims = 0;
  3901. }
  3902. updateMessage.SnapSelection = snap_selection;
  3903. updateMessage.SnapshotID = landData.SnapshotID;
  3904. updateMessage.Status = (ParcelStatus) landData.Status;
  3905. updateMessage.UserLocation = landData.UserLocation;
  3906. updateMessage.UserLookAt = landData.UserLookAt;
  3907. updateMessage.MediaType = landData.MediaType;
  3908. updateMessage.MediaDesc = landData.MediaDescription;
  3909. updateMessage.MediaWidth = landData.MediaWidth;
  3910. updateMessage.MediaHeight = landData.MediaHeight;
  3911. updateMessage.MediaLoop = landData.MediaLoop;
  3912. updateMessage.ObscureMusic = landData.ObscureMusic;
  3913. updateMessage.ObscureMedia = landData.ObscureMedia;
  3914. IPrimCounts pc = lo.PrimCounts;
  3915. updateMessage.OwnerPrims = pc.Owner;
  3916. updateMessage.GroupPrims = pc.Group;
  3917. updateMessage.OtherPrims = pc.Others;
  3918. updateMessage.SelectedPrims = pc.Selected;
  3919. updateMessage.TotalPrims = pc.Total;
  3920. updateMessage.SimWideTotalPrims = pc.Simulator;
  3921. try
  3922. {
  3923. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  3924. if (eq != null)
  3925. {
  3926. eq.ParcelProperties(updateMessage, this.AgentId);
  3927. }
  3928. else
  3929. {
  3930. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  3931. }
  3932. }
  3933. catch (Exception ex)
  3934. {
  3935. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  3936. }
  3937. }
  3938. public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
  3939. {
  3940. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  3941. replyPacket.Data.AgentID = AgentId;
  3942. replyPacket.Data.Flags = accessFlag;
  3943. replyPacket.Data.LocalID = localLandID;
  3944. replyPacket.Data.SequenceID = 0;
  3945. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  3946. foreach (UUID avatar in avatars)
  3947. {
  3948. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  3949. block.Flags = accessFlag;
  3950. block.ID = avatar;
  3951. block.Time = 0;
  3952. list.Add(block);
  3953. }
  3954. replyPacket.List = list.ToArray();
  3955. replyPacket.Header.Zerocoded = true;
  3956. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  3957. }
  3958. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  3959. {
  3960. m_log.WarnFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  3961. bool firstCall = true;
  3962. const int MAX_OBJECTS_PER_PACKET = 251;
  3963. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  3964. ForceObjectSelectPacket.DataBlock[] data;
  3965. while (ObjectIDs.Count > 0)
  3966. {
  3967. if (firstCall)
  3968. {
  3969. pack._Header.ResetList = true;
  3970. firstCall = false;
  3971. }
  3972. else
  3973. {
  3974. pack._Header.ResetList = false;
  3975. }
  3976. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  3977. {
  3978. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  3979. }
  3980. else
  3981. {
  3982. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  3983. }
  3984. int i;
  3985. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  3986. {
  3987. data[i] = new ForceObjectSelectPacket.DataBlock();
  3988. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  3989. ObjectIDs.RemoveAt(0);
  3990. }
  3991. pack.Data = data;
  3992. pack.Header.Zerocoded = true;
  3993. OutPacket(pack, ThrottleOutPacketType.Task);
  3994. }
  3995. }
  3996. public void SendCameraConstraint(Vector4 ConstraintPlane)
  3997. {
  3998. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  3999. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4000. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4001. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4002. OutPacket(cpack, ThrottleOutPacketType.Task);
  4003. }
  4004. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4005. {
  4006. int notifyCount = ownersAndCount.Count;
  4007. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4008. if (notifyCount > 0)
  4009. {
  4010. if (notifyCount > 32)
  4011. {
  4012. m_log.InfoFormat(
  4013. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4014. + " - a developer might want to investigate whether this is a hard limit", 32);
  4015. notifyCount = 32;
  4016. }
  4017. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4018. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4019. int num = 0;
  4020. foreach (UUID owner in ownersAndCount.Keys)
  4021. {
  4022. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4023. dataBlock[num].Count = ownersAndCount[owner];
  4024. if (land.GroupID == owner || groups.Contains(owner))
  4025. dataBlock[num].IsGroupOwned = true;
  4026. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4027. dataBlock[num].OwnerID = owner;
  4028. num++;
  4029. if (num >= notifyCount)
  4030. {
  4031. break;
  4032. }
  4033. }
  4034. pack.Data = dataBlock;
  4035. }
  4036. else
  4037. {
  4038. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4039. }
  4040. pack.Header.Zerocoded = true;
  4041. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4042. }
  4043. #endregion
  4044. #region Helper Methods
  4045. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4046. {
  4047. #region ScenePresence/SOP Handling
  4048. bool avatar = (entity is ScenePresence);
  4049. uint localID = entity.LocalId;
  4050. uint attachPoint;
  4051. Vector4 collisionPlane;
  4052. Vector3 position, velocity, acceleration, angularVelocity;
  4053. Quaternion rotation;
  4054. byte[] textureEntry;
  4055. if (entity is ScenePresence)
  4056. {
  4057. ScenePresence presence = (ScenePresence)entity;
  4058. attachPoint = 0;
  4059. collisionPlane = presence.CollisionPlane;
  4060. position = presence.OffsetPosition;
  4061. velocity = presence.Velocity;
  4062. acceleration = Vector3.Zero;
  4063. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4064. // in that direction, even though we don't model this on the server. Implementing this in the future
  4065. // may improve movement smoothness.
  4066. // acceleration = new Vector3(1, 0, 0);
  4067. angularVelocity = Vector3.Zero;
  4068. rotation = presence.Rotation;
  4069. if (sendTexture)
  4070. textureEntry = presence.Appearance.Texture.GetBytes();
  4071. else
  4072. textureEntry = null;
  4073. }
  4074. else
  4075. {
  4076. SceneObjectPart part = (SceneObjectPart)entity;
  4077. attachPoint = part.ParentGroup.AttachmentPoint;
  4078. // m_log.DebugFormat(
  4079. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4080. // attachPoint, part.Name, part.LocalId, Name);
  4081. collisionPlane = Vector4.Zero;
  4082. position = part.RelativePosition;
  4083. velocity = part.Velocity;
  4084. acceleration = part.Acceleration;
  4085. angularVelocity = part.AngularVelocity;
  4086. rotation = part.RotationOffset;
  4087. if (sendTexture)
  4088. textureEntry = part.Shape.TextureEntry;
  4089. else
  4090. textureEntry = null;
  4091. }
  4092. #endregion ScenePresence/SOP Handling
  4093. int pos = 0;
  4094. byte[] data = new byte[(avatar ? 60 : 44)];
  4095. // LocalID
  4096. Utils.UIntToBytes(localID, data, pos);
  4097. pos += 4;
  4098. // Avatar/CollisionPlane
  4099. data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ;
  4100. if (avatar)
  4101. {
  4102. data[pos++] = 1;
  4103. if (collisionPlane == Vector4.Zero)
  4104. collisionPlane = Vector4.UnitW;
  4105. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4106. collisionPlane.ToBytes(data, pos);
  4107. pos += 16;
  4108. }
  4109. else
  4110. {
  4111. ++pos;
  4112. }
  4113. // Position
  4114. position.ToBytes(data, pos);
  4115. pos += 12;
  4116. // Velocity
  4117. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4118. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4119. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4120. // Acceleration
  4121. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4122. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4123. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4124. // Rotation
  4125. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4126. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4127. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4128. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4129. // Angular Velocity
  4130. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4131. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4132. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4133. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
  4134. block.Data = data;
  4135. if (textureEntry != null && textureEntry.Length > 0)
  4136. {
  4137. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4138. // Texture Length
  4139. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4140. // Texture
  4141. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4142. block.TextureEntry = teBytesFinal;
  4143. }
  4144. else
  4145. {
  4146. block.TextureEntry = Utils.EmptyBytes;
  4147. }
  4148. return block;
  4149. }
  4150. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4151. {
  4152. byte[] objectData = new byte[76];
  4153. data.CollisionPlane.ToBytes(objectData, 0);
  4154. data.OffsetPosition.ToBytes(objectData, 16);
  4155. // data.Velocity.ToBytes(objectData, 28);
  4156. // data.Acceleration.ToBytes(objectData, 40);
  4157. data.Rotation.ToBytes(objectData, 52);
  4158. //data.AngularVelocity.ToBytes(objectData, 64);
  4159. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4160. update.Data = Utils.EmptyBytes;
  4161. update.ExtraParams = new byte[1];
  4162. update.FullID = data.UUID;
  4163. update.ID = data.LocalId;
  4164. update.Material = (byte)Material.Flesh;
  4165. update.MediaURL = Utils.EmptyBytes;
  4166. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4167. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4168. update.ObjectData = objectData;
  4169. update.ParentID = data.ParentID;
  4170. update.PathCurve = 16;
  4171. update.PathScaleX = 100;
  4172. update.PathScaleY = 100;
  4173. update.PCode = (byte)PCode.Avatar;
  4174. update.ProfileCurve = 1;
  4175. update.PSBlock = Utils.EmptyBytes;
  4176. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4177. update.Text = Utils.EmptyBytes;
  4178. update.TextColor = new byte[4];
  4179. // Don't send texture anim for avatars - this has no meaning for them.
  4180. update.TextureAnim = Utils.EmptyBytes;
  4181. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4182. update.TextureEntry = Utils.EmptyBytes;
  4183. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4184. update.UpdateFlags = (uint)(
  4185. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4186. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4187. PrimFlags.ObjectOwnerModify);
  4188. return update;
  4189. }
  4190. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4191. {
  4192. byte[] objectData = new byte[60];
  4193. data.RelativePosition.ToBytes(objectData, 0);
  4194. data.Velocity.ToBytes(objectData, 12);
  4195. data.Acceleration.ToBytes(objectData, 24);
  4196. try
  4197. {
  4198. data.RotationOffset.ToBytes(objectData, 36);
  4199. }
  4200. catch (Exception e)
  4201. {
  4202. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4203. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4204. }
  4205. data.AngularVelocity.ToBytes(objectData, 48);
  4206. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4207. update.ClickAction = (byte)data.ClickAction;
  4208. update.CRC = 0;
  4209. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4210. update.FullID = data.UUID;
  4211. update.ID = data.LocalId;
  4212. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4213. //update.JointPivot = Vector3.Zero;
  4214. //update.JointType = 0;
  4215. update.Material = data.Material;
  4216. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4217. if (data.ParentGroup.IsAttachment)
  4218. {
  4219. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.FromItemID);
  4220. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4221. }
  4222. else
  4223. {
  4224. update.NameValue = Utils.EmptyBytes;
  4225. // The root part state is the canonical state for all parts of the object. The other part states in the
  4226. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4227. update.State = data.ParentGroup.RootPart.Shape.State;
  4228. }
  4229. // m_log.DebugFormat(
  4230. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4231. // update.State, data.Name, data.LocalId, Name);
  4232. update.ObjectData = objectData;
  4233. update.ParentID = data.ParentID;
  4234. update.PathBegin = data.Shape.PathBegin;
  4235. update.PathCurve = data.Shape.PathCurve;
  4236. update.PathEnd = data.Shape.PathEnd;
  4237. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4238. update.PathRevolutions = data.Shape.PathRevolutions;
  4239. update.PathScaleX = data.Shape.PathScaleX;
  4240. update.PathScaleY = data.Shape.PathScaleY;
  4241. update.PathShearX = data.Shape.PathShearX;
  4242. update.PathShearY = data.Shape.PathShearY;
  4243. update.PathSkew = data.Shape.PathSkew;
  4244. update.PathTaperX = data.Shape.PathTaperX;
  4245. update.PathTaperY = data.Shape.PathTaperY;
  4246. update.PathTwist = data.Shape.PathTwist;
  4247. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4248. update.PCode = data.Shape.PCode;
  4249. update.ProfileBegin = data.Shape.ProfileBegin;
  4250. update.ProfileCurve = data.Shape.ProfileCurve;
  4251. update.ProfileEnd = data.Shape.ProfileEnd;
  4252. update.ProfileHollow = data.Shape.ProfileHollow;
  4253. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4254. update.TextColor = data.GetTextColor().GetBytes(false);
  4255. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4256. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4257. update.Scale = data.Shape.Scale;
  4258. update.Text = Util.StringToBytes256(data.Text);
  4259. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4260. #region PrimFlags
  4261. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4262. // Don't send the CreateSelected flag to everyone
  4263. flags &= ~PrimFlags.CreateSelected;
  4264. if (recipientID == data.OwnerID)
  4265. {
  4266. if (data.CreateSelected)
  4267. {
  4268. // Only send this flag once, then unset it
  4269. flags |= PrimFlags.CreateSelected;
  4270. data.CreateSelected = false;
  4271. }
  4272. }
  4273. // m_log.DebugFormat(
  4274. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4275. // data.Name, update.FullID, flags, update.ID);
  4276. update.UpdateFlags = (uint)flags;
  4277. #endregion PrimFlags
  4278. if (data.Sound != UUID.Zero)
  4279. {
  4280. update.Sound = data.Sound;
  4281. update.OwnerID = data.OwnerID;
  4282. update.Gain = (float)data.SoundGain;
  4283. update.Radius = (float)data.SoundRadius;
  4284. update.Flags = data.SoundFlags;
  4285. }
  4286. switch ((PCode)data.Shape.PCode)
  4287. {
  4288. case PCode.Grass:
  4289. case PCode.Tree:
  4290. case PCode.NewTree:
  4291. update.Data = new byte[] { data.Shape.State };
  4292. break;
  4293. default:
  4294. update.Data = Utils.EmptyBytes;
  4295. break;
  4296. }
  4297. return update;
  4298. }
  4299. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4300. {
  4301. // TODO: Implement this
  4302. return null;
  4303. }
  4304. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4305. {
  4306. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4307. // TODO: don't create new blocks if recycling an old packet
  4308. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4309. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4310. packet.UUIDNameBlock[0].ID = profileId;
  4311. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4312. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4313. OutPacket(packet, ThrottleOutPacketType.Task);
  4314. }
  4315. public ulong GetGroupPowers(UUID groupID)
  4316. {
  4317. if (groupID == m_activeGroupID)
  4318. return m_activeGroupPowers;
  4319. if (m_groupPowers.ContainsKey(groupID))
  4320. return m_groupPowers[groupID];
  4321. return 0;
  4322. }
  4323. #endregion
  4324. /// <summary>
  4325. /// This is a different way of processing packets then ProcessInPacket
  4326. /// </summary>
  4327. protected virtual void RegisterLocalPacketHandlers()
  4328. {
  4329. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4330. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4331. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4332. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4333. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4334. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4335. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4336. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false);
  4337. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false);
  4338. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4339. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4340. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4341. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4342. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4343. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage, false);
  4344. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4345. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4346. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFrendship);
  4347. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4348. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4349. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4350. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply);
  4351. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4352. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4353. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4354. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4355. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4356. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4357. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4358. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4359. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4360. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4361. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4362. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4363. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4364. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4365. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4366. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4367. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4368. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4369. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4370. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4371. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4372. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4373. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4374. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4375. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4376. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4377. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4378. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4379. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4380. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4381. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4382. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4383. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4384. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4385. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4386. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4387. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4388. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4389. // some clients will send out a separate ObjectImage packet for each face
  4390. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4391. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4392. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4393. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4394. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4395. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4396. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4397. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4398. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4399. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4400. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4401. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4402. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4403. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4404. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4405. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4406. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4407. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4408. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4409. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage);
  4410. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest);
  4411. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4412. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4413. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4414. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4415. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4416. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4417. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4418. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4419. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4420. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4421. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4422. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4423. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4424. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4425. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4426. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4427. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4428. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4429. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4430. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4431. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4432. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4433. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4434. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4435. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest, false);
  4436. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest, false);
  4437. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest, false);
  4438. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4439. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4440. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4441. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest);
  4442. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4443. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4444. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4445. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4446. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4447. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4448. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4449. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4450. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4451. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4452. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4453. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4454. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4455. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4456. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4457. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4458. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4459. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4460. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4461. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4462. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4463. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4464. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4465. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4466. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4467. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4468. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4469. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4470. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4471. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4472. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4473. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4474. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4475. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4476. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4477. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4478. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4479. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4480. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4481. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4482. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4483. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4484. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4485. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4486. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4487. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4488. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4489. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4490. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4491. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4492. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4493. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4494. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4495. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4496. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4497. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4498. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4499. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4500. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4501. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4502. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4503. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4504. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4505. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4506. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4507. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4508. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4509. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4510. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4511. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4512. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4513. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4514. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4515. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4516. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4517. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4518. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4519. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4520. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4521. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4522. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4523. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4524. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4525. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4526. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4527. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4528. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4529. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4530. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4531. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4532. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4533. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4534. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4535. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4536. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4537. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4538. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4539. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4540. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4541. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4542. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4543. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4544. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4545. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4546. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4547. }
  4548. #region Packet Handlers
  4549. #region Scene/Avatar
  4550. private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
  4551. {
  4552. if (OnAgentUpdate != null)
  4553. {
  4554. bool update = false;
  4555. AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
  4556. #region Packet Session and User Check
  4557. if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
  4558. return false;
  4559. #endregion
  4560. AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
  4561. // We can only check when we have something to check
  4562. // against.
  4563. if (lastarg != null)
  4564. {
  4565. update =
  4566. (
  4567. (x.BodyRotation != lastarg.BodyRotation) ||
  4568. (x.CameraAtAxis != lastarg.CameraAtAxis) ||
  4569. (x.CameraCenter != lastarg.CameraCenter) ||
  4570. (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
  4571. (x.CameraUpAxis != lastarg.CameraUpAxis) ||
  4572. (x.ControlFlags != lastarg.ControlFlags) ||
  4573. (x.Far != lastarg.Far) ||
  4574. (x.Flags != lastarg.Flags) ||
  4575. (x.State != lastarg.State) ||
  4576. (x.HeadRotation != lastarg.HeadRotation) ||
  4577. (x.SessionID != lastarg.SessionID) ||
  4578. (x.AgentID != lastarg.AgentID)
  4579. );
  4580. }
  4581. else
  4582. {
  4583. update = true;
  4584. }
  4585. // These should be ordered from most-likely to
  4586. // least likely to change. I've made an initial
  4587. // guess at that.
  4588. if (update)
  4589. {
  4590. // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name);
  4591. AgentUpdateArgs arg = new AgentUpdateArgs();
  4592. arg.AgentID = x.AgentID;
  4593. arg.BodyRotation = x.BodyRotation;
  4594. arg.CameraAtAxis = x.CameraAtAxis;
  4595. arg.CameraCenter = x.CameraCenter;
  4596. arg.CameraLeftAxis = x.CameraLeftAxis;
  4597. arg.CameraUpAxis = x.CameraUpAxis;
  4598. arg.ControlFlags = x.ControlFlags;
  4599. arg.Far = x.Far;
  4600. arg.Flags = x.Flags;
  4601. arg.HeadRotation = x.HeadRotation;
  4602. arg.SessionID = x.SessionID;
  4603. arg.State = x.State;
  4604. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4605. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4606. lastarg = arg; // save this set of arguments for nexttime
  4607. if (handlerPreAgentUpdate != null)
  4608. OnPreAgentUpdate(this, arg);
  4609. if (handlerAgentUpdate != null)
  4610. OnAgentUpdate(this, arg);
  4611. handlerAgentUpdate = null;
  4612. handlerPreAgentUpdate = null;
  4613. }
  4614. }
  4615. return true;
  4616. }
  4617. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4618. {
  4619. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4620. // validate the agent owns the agentID and sessionID
  4621. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4622. money.AgentData.SessionID == sender.SessionId)
  4623. {
  4624. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  4625. if (handlerMoneyTransferRequest != null)
  4626. {
  4627. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  4628. money.MoneyData.Amount, money.MoneyData.TransactionType,
  4629. Util.FieldToString(money.MoneyData.Description));
  4630. }
  4631. return true;
  4632. }
  4633. return false;
  4634. }
  4635. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  4636. {
  4637. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  4638. (ParcelGodMarkAsContentPacket)Packet;
  4639. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  4640. if (ParcelGodMarkAsContentHandler != null)
  4641. {
  4642. ParcelGodMarkAsContentHandler(this,
  4643. ParcelGodMarkAsContent.AgentData.AgentID,
  4644. ParcelGodMarkAsContent.ParcelData.LocalID);
  4645. return true;
  4646. }
  4647. return false;
  4648. }
  4649. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  4650. {
  4651. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  4652. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  4653. if (FreezeUserHandler != null)
  4654. {
  4655. FreezeUserHandler(this,
  4656. FreezeUser.AgentData.AgentID,
  4657. FreezeUser.Data.Flags,
  4658. FreezeUser.Data.TargetID);
  4659. return true;
  4660. }
  4661. return false;
  4662. }
  4663. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  4664. {
  4665. EjectUserPacket EjectUser =
  4666. (EjectUserPacket)Packet;
  4667. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  4668. if (EjectUserHandler != null)
  4669. {
  4670. EjectUserHandler(this,
  4671. EjectUser.AgentData.AgentID,
  4672. EjectUser.Data.Flags,
  4673. EjectUser.Data.TargetID);
  4674. return true;
  4675. }
  4676. return false;
  4677. }
  4678. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  4679. {
  4680. ParcelBuyPassPacket ParcelBuyPass =
  4681. (ParcelBuyPassPacket)Packet;
  4682. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  4683. if (ParcelBuyPassHandler != null)
  4684. {
  4685. ParcelBuyPassHandler(this,
  4686. ParcelBuyPass.AgentData.AgentID,
  4687. ParcelBuyPass.ParcelData.LocalID);
  4688. return true;
  4689. }
  4690. return false;
  4691. }
  4692. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  4693. {
  4694. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  4695. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  4696. {
  4697. ParcelBuy handlerParcelBuy = OnParcelBuy;
  4698. if (handlerParcelBuy != null)
  4699. {
  4700. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  4701. parcel.Data.IsGroupOwned,
  4702. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  4703. parcel.ParcelData.Price,
  4704. false);
  4705. }
  4706. return true;
  4707. }
  4708. return false;
  4709. }
  4710. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  4711. {
  4712. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  4713. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  4714. {
  4715. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  4716. if (handlerUUIDGroupNameRequest != null)
  4717. {
  4718. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  4719. }
  4720. }
  4721. return true;
  4722. }
  4723. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  4724. {
  4725. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  4726. if (m_genericPacketHandlers.Count == 0) return false;
  4727. if (gmpack.AgentData.SessionID != SessionId) return false;
  4728. GenericMessage handlerGenericMessage = null;
  4729. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  4730. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  4731. {
  4732. List<string> msg = new List<string>();
  4733. List<byte[]> msgBytes = new List<byte[]>();
  4734. if (handlerGenericMessage != null)
  4735. {
  4736. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  4737. {
  4738. msg.Add(Util.FieldToString(block.Parameter));
  4739. msgBytes.Add(block.Parameter);
  4740. }
  4741. try
  4742. {
  4743. if (OnBinaryGenericMessage != null)
  4744. {
  4745. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  4746. }
  4747. handlerGenericMessage(sender, method, msg);
  4748. return true;
  4749. }
  4750. catch (Exception e)
  4751. {
  4752. m_log.ErrorFormat(
  4753. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  4754. }
  4755. }
  4756. }
  4757. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  4758. return false;
  4759. }
  4760. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  4761. {
  4762. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  4763. if (ogpack.AgentData.SessionID != SessionId) return false;
  4764. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  4765. if (handlerObjectGroupRequest != null)
  4766. {
  4767. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  4768. {
  4769. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  4770. }
  4771. }
  4772. return true;
  4773. }
  4774. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  4775. {
  4776. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  4777. if (viewer.AgentData.SessionID != SessionId) return false;
  4778. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  4779. if (handlerViewerEffect != null)
  4780. {
  4781. int length = viewer.Effect.Length;
  4782. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  4783. for (int i = 0; i < length; i++)
  4784. {
  4785. //copy the effects block arguments into the event handler arg.
  4786. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  4787. argument.AgentID = viewer.Effect[i].AgentID;
  4788. argument.Color = viewer.Effect[i].Color;
  4789. argument.Duration = viewer.Effect[i].Duration;
  4790. argument.ID = viewer.Effect[i].ID;
  4791. argument.Type = viewer.Effect[i].Type;
  4792. argument.TypeData = viewer.Effect[i].TypeData;
  4793. args.Add(argument);
  4794. }
  4795. handlerViewerEffect(sender, args);
  4796. }
  4797. return true;
  4798. }
  4799. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  4800. {
  4801. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  4802. #region Packet Session and User Check
  4803. if (m_checkPackets)
  4804. {
  4805. if (avatarProperties.AgentData.SessionID != SessionId ||
  4806. avatarProperties.AgentData.AgentID != AgentId)
  4807. return true;
  4808. }
  4809. #endregion
  4810. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  4811. if (handlerRequestAvatarProperties != null)
  4812. {
  4813. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  4814. }
  4815. return true;
  4816. }
  4817. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  4818. {
  4819. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  4820. #region Packet Session and User Check
  4821. if (m_checkPackets)
  4822. {
  4823. if (inchatpack.AgentData.SessionID != SessionId ||
  4824. inchatpack.AgentData.AgentID != AgentId)
  4825. return true;
  4826. }
  4827. #endregion
  4828. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  4829. byte[] message = inchatpack.ChatData.Message;
  4830. byte type = inchatpack.ChatData.Type;
  4831. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  4832. // UUID fromAgentID = AgentId;
  4833. int channel = inchatpack.ChatData.Channel;
  4834. if (OnChatFromClient != null)
  4835. {
  4836. OSChatMessage args = new OSChatMessage();
  4837. args.Channel = channel;
  4838. args.From = fromName;
  4839. args.Message = Utils.BytesToString(message);
  4840. args.Type = (ChatTypeEnum)type;
  4841. args.Position = fromPos;
  4842. args.Scene = Scene;
  4843. args.Sender = this;
  4844. args.SenderUUID = this.AgentId;
  4845. ChatMessage handlerChatFromClient = OnChatFromClient;
  4846. if (handlerChatFromClient != null)
  4847. handlerChatFromClient(this, args);
  4848. }
  4849. return true;
  4850. }
  4851. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  4852. {
  4853. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  4854. #region Packet Session and User Check
  4855. if (m_checkPackets)
  4856. {
  4857. if (avatarProps.AgentData.SessionID != SessionId ||
  4858. avatarProps.AgentData.AgentID != AgentId)
  4859. return true;
  4860. }
  4861. #endregion
  4862. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  4863. if (handlerUpdateAvatarProperties != null)
  4864. {
  4865. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  4866. UserProfileData UserProfile = new UserProfileData();
  4867. UserProfile.ID = AgentId;
  4868. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  4869. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  4870. UserProfile.FirstLifeImage = Properties.FLImageID;
  4871. UserProfile.Image = Properties.ImageID;
  4872. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  4873. UserProfile.UserFlags &= ~3;
  4874. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  4875. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  4876. handlerUpdateAvatarProperties(this, UserProfile);
  4877. }
  4878. return true;
  4879. }
  4880. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  4881. {
  4882. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  4883. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  4884. #region Packet Session and User Check
  4885. if (m_checkPackets)
  4886. {
  4887. if (rdialog.AgentData.SessionID != SessionId ||
  4888. rdialog.AgentData.AgentID != AgentId)
  4889. return true;
  4890. }
  4891. #endregion
  4892. int ch = rdialog.Data.ChatChannel;
  4893. byte[] msg = rdialog.Data.ButtonLabel;
  4894. if (OnChatFromClient != null)
  4895. {
  4896. OSChatMessage args = new OSChatMessage();
  4897. args.Channel = ch;
  4898. args.From = String.Empty;
  4899. args.Message = Utils.BytesToString(msg);
  4900. args.Type = ChatTypeEnum.Shout;
  4901. args.Position = new Vector3();
  4902. args.Scene = Scene;
  4903. args.Sender = this;
  4904. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  4905. if (handlerChatFromClient2 != null)
  4906. handlerChatFromClient2(this, args);
  4907. }
  4908. return true;
  4909. }
  4910. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  4911. {
  4912. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  4913. #region Packet Session and User Check
  4914. if (m_checkPackets)
  4915. {
  4916. if (msgpack.AgentData.SessionID != SessionId ||
  4917. msgpack.AgentData.AgentID != AgentId)
  4918. return true;
  4919. }
  4920. #endregion
  4921. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  4922. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  4923. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  4924. if (handlerInstantMessage != null)
  4925. {
  4926. GridInstantMessage im = new GridInstantMessage(Scene,
  4927. msgpack.AgentData.AgentID,
  4928. IMfromName,
  4929. msgpack.MessageBlock.ToAgentID,
  4930. msgpack.MessageBlock.Dialog,
  4931. msgpack.MessageBlock.FromGroup,
  4932. IMmessage,
  4933. msgpack.MessageBlock.ID,
  4934. msgpack.MessageBlock.Offline != 0 ? true : false,
  4935. msgpack.MessageBlock.Position,
  4936. msgpack.MessageBlock.BinaryBucket);
  4937. handlerInstantMessage(this, im);
  4938. }
  4939. return true;
  4940. }
  4941. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  4942. {
  4943. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  4944. #region Packet Session and User Check
  4945. if (m_checkPackets)
  4946. {
  4947. if (afriendpack.AgentData.SessionID != SessionId ||
  4948. afriendpack.AgentData.AgentID != AgentId)
  4949. return true;
  4950. }
  4951. #endregion
  4952. // My guess is this is the folder to stick the calling card into
  4953. List<UUID> callingCardFolders = new List<UUID>();
  4954. UUID agentID = afriendpack.AgentData.AgentID;
  4955. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  4956. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  4957. {
  4958. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  4959. }
  4960. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  4961. if (handlerApproveFriendRequest != null)
  4962. {
  4963. handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders);
  4964. }
  4965. return true;
  4966. }
  4967. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  4968. {
  4969. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  4970. #region Packet Session and User Check
  4971. if (m_checkPackets)
  4972. {
  4973. if (dfriendpack.AgentData.SessionID != SessionId ||
  4974. dfriendpack.AgentData.AgentID != AgentId)
  4975. return true;
  4976. }
  4977. #endregion
  4978. if (OnDenyFriendRequest != null)
  4979. {
  4980. OnDenyFriendRequest(this,
  4981. dfriendpack.AgentData.AgentID,
  4982. dfriendpack.TransactionBlock.TransactionID,
  4983. null);
  4984. }
  4985. return true;
  4986. }
  4987. private bool HandlerTerminateFrendship(IClientAPI sender, Packet Pack)
  4988. {
  4989. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  4990. #region Packet Session and User Check
  4991. if (m_checkPackets)
  4992. {
  4993. if (tfriendpack.AgentData.SessionID != SessionId ||
  4994. tfriendpack.AgentData.AgentID != AgentId)
  4995. return true;
  4996. }
  4997. #endregion
  4998. UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
  4999. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5000. FriendshipTermination handlerTerminateFriendship = OnTerminateFriendship;
  5001. if (handlerTerminateFriendship != null)
  5002. {
  5003. handlerTerminateFriendship(this, listOwnerAgentID, exFriendID);
  5004. }
  5005. return true;
  5006. }
  5007. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5008. {
  5009. FindAgentPacket FindAgent =
  5010. (FindAgentPacket)Packet;
  5011. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5012. if (FindAgentHandler != null)
  5013. {
  5014. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5015. return true;
  5016. }
  5017. return false;
  5018. }
  5019. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5020. {
  5021. TrackAgentPacket TrackAgent =
  5022. (TrackAgentPacket)Packet;
  5023. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5024. if (TrackAgentHandler != null)
  5025. {
  5026. TrackAgentHandler(this,
  5027. TrackAgent.AgentData.AgentID,
  5028. TrackAgent.TargetData.PreyID);
  5029. return true;
  5030. }
  5031. return false;
  5032. }
  5033. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5034. {
  5035. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5036. #region Packet Session and User Check
  5037. if (m_checkPackets)
  5038. {
  5039. if (rezPacket.AgentData.SessionID != SessionId ||
  5040. rezPacket.AgentData.AgentID != AgentId)
  5041. return true;
  5042. }
  5043. #endregion
  5044. RezObject handlerRezObject = OnRezObject;
  5045. if (handlerRezObject != null)
  5046. {
  5047. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5048. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5049. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5050. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5051. rezPacket.RezData.FromTaskID);
  5052. }
  5053. return true;
  5054. }
  5055. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5056. {
  5057. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5058. #region Packet Session and User Check
  5059. if (m_checkPackets)
  5060. {
  5061. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5062. DeRezPacket.AgentData.AgentID != AgentId)
  5063. return true;
  5064. }
  5065. #endregion
  5066. DeRezObject handlerDeRezObject = OnDeRezObject;
  5067. if (handlerDeRezObject != null)
  5068. {
  5069. List<uint> deRezIDs = new List<uint>();
  5070. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5071. DeRezPacket.ObjectData)
  5072. {
  5073. deRezIDs.Add(data.ObjectLocalID);
  5074. }
  5075. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5076. // values given by a Second Life client
  5077. handlerDeRezObject(this, deRezIDs,
  5078. DeRezPacket.AgentBlock.GroupID,
  5079. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5080. DeRezPacket.AgentBlock.DestinationID);
  5081. }
  5082. return true;
  5083. }
  5084. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5085. {
  5086. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5087. #region Packet Session and User Check
  5088. if (m_checkPackets)
  5089. {
  5090. if (modify.AgentData.SessionID != SessionId ||
  5091. modify.AgentData.AgentID != AgentId)
  5092. return true;
  5093. }
  5094. #endregion
  5095. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5096. if (modify.ParcelData.Length > 0)
  5097. {
  5098. if (OnModifyTerrain != null)
  5099. {
  5100. for (int i = 0; i < modify.ParcelData.Length; i++)
  5101. {
  5102. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5103. if (handlerModifyTerrain != null)
  5104. {
  5105. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5106. modify.ModifyBlock.BrushSize,
  5107. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5108. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5109. modify.ParcelData[i].East, AgentId);
  5110. }
  5111. }
  5112. }
  5113. }
  5114. return true;
  5115. }
  5116. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5117. {
  5118. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5119. if (handlerRegionHandShakeReply != null)
  5120. {
  5121. handlerRegionHandShakeReply(this);
  5122. }
  5123. return true;
  5124. }
  5125. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5126. {
  5127. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5128. if (handlerRequestWearables != null)
  5129. {
  5130. handlerRequestWearables(sender);
  5131. }
  5132. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5133. if (handlerRequestAvatarsData != null)
  5134. {
  5135. handlerRequestAvatarsData(this);
  5136. }
  5137. return true;
  5138. }
  5139. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5140. {
  5141. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5142. #region Packet Session and User Check
  5143. if (m_checkPackets)
  5144. {
  5145. if (appear.AgentData.SessionID != SessionId ||
  5146. appear.AgentData.AgentID != AgentId)
  5147. return true;
  5148. }
  5149. #endregion
  5150. SetAppearance handlerSetAppearance = OnSetAppearance;
  5151. if (handlerSetAppearance != null)
  5152. {
  5153. // Temporarily protect ourselves from the mantis #951 failure.
  5154. // However, we could do this for several other handlers where a failure isn't terminal
  5155. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5156. try
  5157. {
  5158. byte[] visualparams = new byte[appear.VisualParam.Length];
  5159. for (int i = 0; i < appear.VisualParam.Length; i++)
  5160. visualparams[i] = appear.VisualParam[i].ParamValue;
  5161. Primitive.TextureEntry te = null;
  5162. if (appear.ObjectData.TextureEntry.Length > 1)
  5163. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5164. handlerSetAppearance(sender, te, visualparams);
  5165. }
  5166. catch (Exception e)
  5167. {
  5168. m_log.ErrorFormat(
  5169. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5170. e);
  5171. }
  5172. }
  5173. return true;
  5174. }
  5175. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5176. {
  5177. if (OnAvatarNowWearing != null)
  5178. {
  5179. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5180. #region Packet Session and User Check
  5181. if (m_checkPackets)
  5182. {
  5183. if (nowWearing.AgentData.SessionID != SessionId ||
  5184. nowWearing.AgentData.AgentID != AgentId)
  5185. return true;
  5186. }
  5187. #endregion
  5188. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5189. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5190. {
  5191. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5192. AvatarWearingArgs.Wearable wearable =
  5193. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5194. nowWearing.WearableData[i].WearableType);
  5195. wearingArgs.NowWearing.Add(wearable);
  5196. }
  5197. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5198. if (handlerAvatarNowWearing != null)
  5199. {
  5200. handlerAvatarNowWearing(this, wearingArgs);
  5201. }
  5202. }
  5203. return true;
  5204. }
  5205. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5206. {
  5207. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5208. if (handlerRezSingleAttachment != null)
  5209. {
  5210. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5211. #region Packet Session and User Check
  5212. if (m_checkPackets)
  5213. {
  5214. if (rez.AgentData.SessionID != SessionId ||
  5215. rez.AgentData.AgentID != AgentId)
  5216. return true;
  5217. }
  5218. #endregion
  5219. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5220. rez.ObjectData.AttachmentPt);
  5221. }
  5222. return true;
  5223. }
  5224. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5225. {
  5226. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5227. if (handlerRezMultipleAttachments != null)
  5228. {
  5229. RezMultipleAttachmentsFromInvPacket rez = (RezMultipleAttachmentsFromInvPacket)Pack;
  5230. handlerRezMultipleAttachments(this, rez.HeaderData,
  5231. rez.ObjectData);
  5232. }
  5233. return true;
  5234. }
  5235. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5236. {
  5237. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5238. if (handlerDetachAttachmentIntoInv != null)
  5239. {
  5240. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5241. #region Packet Session and User Check
  5242. // UNSUPPORTED ON THIS PACKET
  5243. #endregion
  5244. UUID itemID = detachtoInv.ObjectData.ItemID;
  5245. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5246. handlerDetachAttachmentIntoInv(itemID, this);
  5247. }
  5248. return true;
  5249. }
  5250. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5251. {
  5252. if (OnObjectAttach != null)
  5253. {
  5254. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5255. #region Packet Session and User Check
  5256. if (m_checkPackets)
  5257. {
  5258. if (att.AgentData.SessionID != SessionId ||
  5259. att.AgentData.AgentID != AgentId)
  5260. return true;
  5261. }
  5262. #endregion
  5263. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5264. if (handlerObjectAttach != null)
  5265. {
  5266. if (att.ObjectData.Length > 0)
  5267. {
  5268. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5269. }
  5270. }
  5271. }
  5272. return true;
  5273. }
  5274. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5275. {
  5276. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5277. #region Packet Session and User Check
  5278. if (m_checkPackets)
  5279. {
  5280. if (dett.AgentData.SessionID != SessionId ||
  5281. dett.AgentData.AgentID != AgentId)
  5282. return true;
  5283. }
  5284. #endregion
  5285. for (int j = 0; j < dett.ObjectData.Length; j++)
  5286. {
  5287. uint obj = dett.ObjectData[j].ObjectLocalID;
  5288. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5289. if (handlerObjectDetach != null)
  5290. {
  5291. handlerObjectDetach(obj, this);
  5292. }
  5293. }
  5294. return true;
  5295. }
  5296. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5297. {
  5298. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5299. #region Packet Session and User Check
  5300. if (m_checkPackets)
  5301. {
  5302. if (dropp.AgentData.SessionID != SessionId ||
  5303. dropp.AgentData.AgentID != AgentId)
  5304. return true;
  5305. }
  5306. #endregion
  5307. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5308. {
  5309. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5310. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5311. if (handlerObjectDrop != null)
  5312. {
  5313. handlerObjectDrop(obj, this);
  5314. }
  5315. }
  5316. return true;
  5317. }
  5318. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5319. {
  5320. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5321. #region Packet Session and User Check
  5322. if (m_checkPackets)
  5323. {
  5324. if (run.AgentData.SessionID != SessionId ||
  5325. run.AgentData.AgentID != AgentId)
  5326. return true;
  5327. }
  5328. #endregion
  5329. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5330. if (handlerSetAlwaysRun != null)
  5331. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5332. return true;
  5333. }
  5334. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5335. {
  5336. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5337. if (handlerCompleteMovementToRegion != null)
  5338. {
  5339. handlerCompleteMovementToRegion(sender, true);
  5340. }
  5341. handlerCompleteMovementToRegion = null;
  5342. return true;
  5343. }
  5344. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5345. {
  5346. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5347. #region Packet Session and User Check
  5348. if (m_checkPackets)
  5349. {
  5350. if (AgentAni.AgentData.SessionID != SessionId ||
  5351. AgentAni.AgentData.AgentID != AgentId)
  5352. return true;
  5353. }
  5354. #endregion
  5355. StartAnim handlerStartAnim = null;
  5356. StopAnim handlerStopAnim = null;
  5357. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5358. {
  5359. if (AgentAni.AnimationList[i].StartAnim)
  5360. {
  5361. handlerStartAnim = OnStartAnim;
  5362. if (handlerStartAnim != null)
  5363. {
  5364. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5365. }
  5366. }
  5367. else
  5368. {
  5369. handlerStopAnim = OnStopAnim;
  5370. if (handlerStopAnim != null)
  5371. {
  5372. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5373. }
  5374. }
  5375. }
  5376. return true;
  5377. }
  5378. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5379. {
  5380. if (OnAgentRequestSit != null)
  5381. {
  5382. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5383. #region Packet Session and User Check
  5384. if (m_checkPackets)
  5385. {
  5386. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5387. agentRequestSit.AgentData.AgentID != AgentId)
  5388. return true;
  5389. }
  5390. #endregion
  5391. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5392. if (handlerAgentRequestSit != null)
  5393. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5394. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5395. }
  5396. return true;
  5397. }
  5398. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5399. {
  5400. if (OnAgentSit != null)
  5401. {
  5402. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5403. #region Packet Session and User Check
  5404. if (m_checkPackets)
  5405. {
  5406. if (agentSit.AgentData.SessionID != SessionId ||
  5407. agentSit.AgentData.AgentID != AgentId)
  5408. return true;
  5409. }
  5410. #endregion
  5411. AgentSit handlerAgentSit = OnAgentSit;
  5412. if (handlerAgentSit != null)
  5413. {
  5414. OnAgentSit(this, agentSit.AgentData.AgentID);
  5415. }
  5416. }
  5417. return true;
  5418. }
  5419. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5420. {
  5421. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5422. #region Packet Session and User Check
  5423. if (m_checkPackets)
  5424. {
  5425. // UNSUPPORTED ON THIS PACKET
  5426. }
  5427. #endregion
  5428. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5429. if (handlerSoundTrigger != null)
  5430. {
  5431. // UUIDS are sent as zeroes by the client, substitute agent's id
  5432. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5433. AgentId, AgentId,
  5434. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5435. soundTriggerPacket.SoundData.Handle, 0);
  5436. }
  5437. return true;
  5438. }
  5439. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5440. {
  5441. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5442. #region Packet Session and User Check
  5443. if (m_checkPackets)
  5444. {
  5445. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5446. avRequestQuery.AgentData.AgentID != AgentId)
  5447. return true;
  5448. }
  5449. #endregion
  5450. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5451. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5452. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5453. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5454. if (handlerAvatarPickerRequest != null)
  5455. {
  5456. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5457. Utils.BytesToString(querydata.Name));
  5458. }
  5459. return true;
  5460. }
  5461. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5462. {
  5463. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5464. #region Packet Session and User Check
  5465. if (m_checkPackets)
  5466. {
  5467. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5468. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5469. return true;
  5470. }
  5471. #endregion
  5472. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5473. if (handlerAgentDataUpdateRequest != null)
  5474. {
  5475. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5476. }
  5477. return true;
  5478. }
  5479. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5480. {
  5481. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5482. if (handlerUserInfoRequest != null)
  5483. {
  5484. handlerUserInfoRequest(this);
  5485. }
  5486. else
  5487. {
  5488. SendUserInfoReply(false, true, "");
  5489. }
  5490. return true;
  5491. }
  5492. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5493. {
  5494. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5495. #region Packet Session and User Check
  5496. if (m_checkPackets)
  5497. {
  5498. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5499. updateUserInfo.AgentData.AgentID != AgentId)
  5500. return true;
  5501. }
  5502. #endregion
  5503. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5504. if (handlerUpdateUserInfo != null)
  5505. {
  5506. bool visible = true;
  5507. string DirectoryVisibility =
  5508. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5509. if (DirectoryVisibility == "hidden")
  5510. visible = false;
  5511. handlerUpdateUserInfo(
  5512. updateUserInfo.UserData.IMViaEMail,
  5513. visible, this);
  5514. }
  5515. return true;
  5516. }
  5517. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5518. {
  5519. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5520. #region Packet Session and User Check
  5521. if (m_checkPackets)
  5522. {
  5523. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5524. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5525. return true;
  5526. }
  5527. #endregion
  5528. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5529. {
  5530. // Linden Client limitation..
  5531. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5532. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5533. {
  5534. ScenePresence avatar = null;
  5535. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5536. {
  5537. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5538. {
  5539. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5540. }
  5541. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5542. {
  5543. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5544. }
  5545. }
  5546. }
  5547. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5548. if (handlerSetStartLocationRequest != null)
  5549. {
  5550. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5551. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5552. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5553. }
  5554. }
  5555. return true;
  5556. }
  5557. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5558. {
  5559. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5560. #region Packet Session and User Check
  5561. if (m_checkPackets)
  5562. {
  5563. if (atpack.AgentData.SessionID != SessionId ||
  5564. atpack.AgentData.AgentID != AgentId)
  5565. return true;
  5566. }
  5567. #endregion
  5568. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5569. return true;
  5570. }
  5571. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5572. {
  5573. m_udpClient.IsPaused = true;
  5574. return true;
  5575. }
  5576. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5577. {
  5578. m_udpClient.IsPaused = false;
  5579. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5580. return true;
  5581. }
  5582. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5583. {
  5584. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5585. if (handlerForceReleaseControls != null)
  5586. {
  5587. handlerForceReleaseControls(this, AgentId);
  5588. }
  5589. return true;
  5590. }
  5591. #endregion Scene/Avatar
  5592. #region Objects/m_sceneObjects
  5593. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5594. {
  5595. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  5596. #region Packet Session and User Check
  5597. if (m_checkPackets)
  5598. {
  5599. if (link.AgentData.SessionID != SessionId ||
  5600. link.AgentData.AgentID != AgentId)
  5601. return true;
  5602. }
  5603. #endregion
  5604. uint parentprimid = 0;
  5605. List<uint> childrenprims = new List<uint>();
  5606. if (link.ObjectData.Length > 1)
  5607. {
  5608. parentprimid = link.ObjectData[0].ObjectLocalID;
  5609. for (int i = 1; i < link.ObjectData.Length; i++)
  5610. {
  5611. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  5612. }
  5613. }
  5614. LinkObjects handlerLinkObjects = OnLinkObjects;
  5615. if (handlerLinkObjects != null)
  5616. {
  5617. handlerLinkObjects(this, parentprimid, childrenprims);
  5618. }
  5619. return true;
  5620. }
  5621. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  5622. {
  5623. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  5624. #region Packet Session and User Check
  5625. if (m_checkPackets)
  5626. {
  5627. if (delink.AgentData.SessionID != SessionId ||
  5628. delink.AgentData.AgentID != AgentId)
  5629. return true;
  5630. }
  5631. #endregion
  5632. // It appears the prim at index 0 is not always the root prim (for
  5633. // instance, when one prim of a link set has been edited independently
  5634. // of the others). Therefore, we'll pass all the ids onto the delink
  5635. // method for it to decide which is the root.
  5636. List<uint> prims = new List<uint>();
  5637. for (int i = 0; i < delink.ObjectData.Length; i++)
  5638. {
  5639. prims.Add(delink.ObjectData[i].ObjectLocalID);
  5640. }
  5641. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  5642. if (handlerDelinkObjects != null)
  5643. {
  5644. handlerDelinkObjects(prims, this);
  5645. }
  5646. return true;
  5647. }
  5648. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  5649. {
  5650. if (OnAddPrim != null)
  5651. {
  5652. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  5653. #region Packet Session and User Check
  5654. if (m_checkPackets)
  5655. {
  5656. if (addPacket.AgentData.SessionID != SessionId ||
  5657. addPacket.AgentData.AgentID != AgentId)
  5658. return true;
  5659. }
  5660. #endregion
  5661. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  5662. // m_log.Info("[REZData]: " + addPacket.ToString());
  5663. //BypassRaycast: 1
  5664. //RayStart: <69.79469, 158.2652, 98.40343>
  5665. //RayEnd: <61.97724, 141.995, 92.58341>
  5666. //RayTargetID: 00000000-0000-0000-0000-000000000000
  5667. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  5668. //object from rezing initially
  5669. AddNewPrim handlerAddPrim = OnAddPrim;
  5670. if (handlerAddPrim != null)
  5671. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  5672. }
  5673. return true;
  5674. }
  5675. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  5676. {
  5677. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  5678. #region Packet Session and User Check
  5679. if (m_checkPackets)
  5680. {
  5681. if (shapePacket.AgentData.SessionID != SessionId ||
  5682. shapePacket.AgentData.AgentID != AgentId)
  5683. return true;
  5684. }
  5685. #endregion
  5686. UpdateShape handlerUpdatePrimShape = null;
  5687. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  5688. {
  5689. handlerUpdatePrimShape = OnUpdatePrimShape;
  5690. if (handlerUpdatePrimShape != null)
  5691. {
  5692. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  5693. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  5694. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  5695. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  5696. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  5697. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  5698. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  5699. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  5700. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  5701. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  5702. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  5703. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  5704. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  5705. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  5706. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  5707. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  5708. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  5709. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  5710. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  5711. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  5712. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  5713. shapeData);
  5714. }
  5715. }
  5716. return true;
  5717. }
  5718. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  5719. {
  5720. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  5721. #region Packet Session and User Check
  5722. if (m_checkPackets)
  5723. {
  5724. if (extraPar.AgentData.SessionID != SessionId ||
  5725. extraPar.AgentData.AgentID != AgentId)
  5726. return true;
  5727. }
  5728. #endregion
  5729. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  5730. if (handlerUpdateExtraParams != null)
  5731. {
  5732. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  5733. {
  5734. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  5735. extraPar.ObjectData[i].ParamType,
  5736. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  5737. }
  5738. }
  5739. return true;
  5740. }
  5741. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  5742. {
  5743. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  5744. #region Packet Session and User Check
  5745. if (m_checkPackets)
  5746. {
  5747. if (dupe.AgentData.SessionID != SessionId ||
  5748. dupe.AgentData.AgentID != AgentId)
  5749. return true;
  5750. }
  5751. #endregion
  5752. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  5753. ObjectDuplicate handlerObjectDuplicate = null;
  5754. for (int i = 0; i < dupe.ObjectData.Length; i++)
  5755. {
  5756. handlerObjectDuplicate = OnObjectDuplicate;
  5757. if (handlerObjectDuplicate != null)
  5758. {
  5759. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  5760. dupe.SharedData.DuplicateFlags, AgentId,
  5761. m_activeGroupID);
  5762. }
  5763. }
  5764. return true;
  5765. }
  5766. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  5767. {
  5768. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  5769. #region Packet Session and User Check
  5770. if (m_checkPackets)
  5771. {
  5772. if (incomingRequest.AgentData.SessionID != SessionId ||
  5773. incomingRequest.AgentData.AgentID != AgentId)
  5774. return true;
  5775. }
  5776. #endregion
  5777. ObjectRequest handlerObjectRequest = null;
  5778. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  5779. {
  5780. handlerObjectRequest = OnObjectRequest;
  5781. if (handlerObjectRequest != null)
  5782. {
  5783. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  5784. }
  5785. }
  5786. return true;
  5787. }
  5788. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  5789. {
  5790. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  5791. #region Packet Session and User Check
  5792. if (m_checkPackets)
  5793. {
  5794. if (incomingselect.AgentData.SessionID != SessionId ||
  5795. incomingselect.AgentData.AgentID != AgentId)
  5796. return true;
  5797. }
  5798. #endregion
  5799. ObjectSelect handlerObjectSelect = null;
  5800. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  5801. {
  5802. handlerObjectSelect = OnObjectSelect;
  5803. if (handlerObjectSelect != null)
  5804. {
  5805. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  5806. }
  5807. }
  5808. return true;
  5809. }
  5810. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  5811. {
  5812. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  5813. #region Packet Session and User Check
  5814. if (m_checkPackets)
  5815. {
  5816. if (incomingdeselect.AgentData.SessionID != SessionId ||
  5817. incomingdeselect.AgentData.AgentID != AgentId)
  5818. return true;
  5819. }
  5820. #endregion
  5821. ObjectDeselect handlerObjectDeselect = null;
  5822. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  5823. {
  5824. handlerObjectDeselect = OnObjectDeselect;
  5825. if (handlerObjectDeselect != null)
  5826. {
  5827. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  5828. }
  5829. }
  5830. return true;
  5831. }
  5832. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  5833. {
  5834. // DEPRECATED: but till libsecondlife removes it, people will use it
  5835. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  5836. #region Packet Session and User Check
  5837. if (m_checkPackets)
  5838. {
  5839. if (position.AgentData.SessionID != SessionId ||
  5840. position.AgentData.AgentID != AgentId)
  5841. return true;
  5842. }
  5843. #endregion
  5844. for (int i = 0; i < position.ObjectData.Length; i++)
  5845. {
  5846. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  5847. if (handlerUpdateVector != null)
  5848. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  5849. }
  5850. return true;
  5851. }
  5852. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  5853. {
  5854. // DEPRECATED: but till libsecondlife removes it, people will use it
  5855. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  5856. #region Packet Session and User Check
  5857. if (m_checkPackets)
  5858. {
  5859. if (scale.AgentData.SessionID != SessionId ||
  5860. scale.AgentData.AgentID != AgentId)
  5861. return true;
  5862. }
  5863. #endregion
  5864. for (int i = 0; i < scale.ObjectData.Length; i++)
  5865. {
  5866. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  5867. if (handlerUpdatePrimGroupScale != null)
  5868. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  5869. }
  5870. return true;
  5871. }
  5872. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  5873. {
  5874. // DEPRECATED: but till libsecondlife removes it, people will use it
  5875. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  5876. #region Packet Session and User Check
  5877. if (m_checkPackets)
  5878. {
  5879. if (rotation.AgentData.SessionID != SessionId ||
  5880. rotation.AgentData.AgentID != AgentId)
  5881. return true;
  5882. }
  5883. #endregion
  5884. for (int i = 0; i < rotation.ObjectData.Length; i++)
  5885. {
  5886. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  5887. if (handlerUpdatePrimRotation != null)
  5888. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  5889. }
  5890. return true;
  5891. }
  5892. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  5893. {
  5894. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  5895. #region Packet Session and User Check
  5896. if (m_checkPackets)
  5897. {
  5898. if (flags.AgentData.SessionID != SessionId ||
  5899. flags.AgentData.AgentID != AgentId)
  5900. return true;
  5901. }
  5902. #endregion
  5903. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  5904. if (handlerUpdatePrimFlags != null)
  5905. {
  5906. byte[] data = Pack.ToBytes();
  5907. // 46,47,48 are special positions within the packet
  5908. // This may change so perhaps we need a better way
  5909. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  5910. bool UsePhysics = (data[46] != 0) ? true : false;
  5911. bool IsTemporary = (data[47] != 0) ? true : false;
  5912. bool IsPhantom = (data[48] != 0) ? true : false;
  5913. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  5914. }
  5915. return true;
  5916. }
  5917. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  5918. {
  5919. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  5920. UpdatePrimTexture handlerUpdatePrimTexture = null;
  5921. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  5922. {
  5923. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  5924. if (handlerUpdatePrimTexture != null)
  5925. {
  5926. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  5927. imagePack.ObjectData[i].TextureEntry, this);
  5928. }
  5929. }
  5930. return true;
  5931. }
  5932. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  5933. {
  5934. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  5935. #region Packet Session and User Check
  5936. if (m_checkPackets)
  5937. {
  5938. if (grab.AgentData.SessionID != SessionId ||
  5939. grab.AgentData.AgentID != AgentId)
  5940. return true;
  5941. }
  5942. #endregion
  5943. GrabObject handlerGrabObject = OnGrabObject;
  5944. if (handlerGrabObject != null)
  5945. {
  5946. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  5947. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  5948. {
  5949. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  5950. {
  5951. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  5952. arg.Binormal = surfaceInfo.Binormal;
  5953. arg.FaceIndex = surfaceInfo.FaceIndex;
  5954. arg.Normal = surfaceInfo.Normal;
  5955. arg.Position = surfaceInfo.Position;
  5956. arg.STCoord = surfaceInfo.STCoord;
  5957. arg.UVCoord = surfaceInfo.UVCoord;
  5958. touchArgs.Add(arg);
  5959. }
  5960. }
  5961. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  5962. }
  5963. return true;
  5964. }
  5965. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  5966. {
  5967. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  5968. #region Packet Session and User Check
  5969. if (m_checkPackets)
  5970. {
  5971. if (grabUpdate.AgentData.SessionID != SessionId ||
  5972. grabUpdate.AgentData.AgentID != AgentId)
  5973. return true;
  5974. }
  5975. #endregion
  5976. MoveObject handlerGrabUpdate = OnGrabUpdate;
  5977. if (handlerGrabUpdate != null)
  5978. {
  5979. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  5980. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  5981. {
  5982. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  5983. {
  5984. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  5985. arg.Binormal = surfaceInfo.Binormal;
  5986. arg.FaceIndex = surfaceInfo.FaceIndex;
  5987. arg.Normal = surfaceInfo.Normal;
  5988. arg.Position = surfaceInfo.Position;
  5989. arg.STCoord = surfaceInfo.STCoord;
  5990. arg.UVCoord = surfaceInfo.UVCoord;
  5991. touchArgs.Add(arg);
  5992. }
  5993. }
  5994. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  5995. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  5996. }
  5997. return true;
  5998. }
  5999. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6000. {
  6001. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6002. #region Packet Session and User Check
  6003. if (m_checkPackets)
  6004. {
  6005. if (deGrab.AgentData.SessionID != SessionId ||
  6006. deGrab.AgentData.AgentID != AgentId)
  6007. return true;
  6008. }
  6009. #endregion
  6010. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6011. if (handlerDeGrabObject != null)
  6012. {
  6013. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6014. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6015. {
  6016. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6017. {
  6018. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6019. arg.Binormal = surfaceInfo.Binormal;
  6020. arg.FaceIndex = surfaceInfo.FaceIndex;
  6021. arg.Normal = surfaceInfo.Normal;
  6022. arg.Position = surfaceInfo.Position;
  6023. arg.STCoord = surfaceInfo.STCoord;
  6024. arg.UVCoord = surfaceInfo.UVCoord;
  6025. touchArgs.Add(arg);
  6026. }
  6027. }
  6028. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6029. }
  6030. return true;
  6031. }
  6032. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6033. {
  6034. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6035. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6036. #region Packet Session and User Check
  6037. if (m_checkPackets)
  6038. {
  6039. if (spinStart.AgentData.SessionID != SessionId ||
  6040. spinStart.AgentData.AgentID != AgentId)
  6041. return true;
  6042. }
  6043. #endregion
  6044. SpinStart handlerSpinStart = OnSpinStart;
  6045. if (handlerSpinStart != null)
  6046. {
  6047. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6048. }
  6049. return true;
  6050. }
  6051. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6052. {
  6053. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6054. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6055. #region Packet Session and User Check
  6056. if (m_checkPackets)
  6057. {
  6058. if (spinUpdate.AgentData.SessionID != SessionId ||
  6059. spinUpdate.AgentData.AgentID != AgentId)
  6060. return true;
  6061. }
  6062. #endregion
  6063. Vector3 axis;
  6064. float angle;
  6065. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6066. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6067. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6068. if (handlerSpinUpdate != null)
  6069. {
  6070. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6071. }
  6072. return true;
  6073. }
  6074. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6075. {
  6076. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6077. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6078. #region Packet Session and User Check
  6079. if (m_checkPackets)
  6080. {
  6081. if (spinStop.AgentData.SessionID != SessionId ||
  6082. spinStop.AgentData.AgentID != AgentId)
  6083. return true;
  6084. }
  6085. #endregion
  6086. SpinStop handlerSpinStop = OnSpinStop;
  6087. if (handlerSpinStop != null)
  6088. {
  6089. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6090. }
  6091. return true;
  6092. }
  6093. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6094. {
  6095. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6096. #region Packet Session and User Check
  6097. if (m_checkPackets)
  6098. {
  6099. if (objDes.AgentData.SessionID != SessionId ||
  6100. objDes.AgentData.AgentID != AgentId)
  6101. return true;
  6102. }
  6103. #endregion
  6104. GenericCall7 handlerObjectDescription = null;
  6105. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6106. {
  6107. handlerObjectDescription = OnObjectDescription;
  6108. if (handlerObjectDescription != null)
  6109. {
  6110. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6111. Util.FieldToString(objDes.ObjectData[i].Description));
  6112. }
  6113. }
  6114. return true;
  6115. }
  6116. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6117. {
  6118. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6119. #region Packet Session and User Check
  6120. if (m_checkPackets)
  6121. {
  6122. if (objName.AgentData.SessionID != SessionId ||
  6123. objName.AgentData.AgentID != AgentId)
  6124. return true;
  6125. }
  6126. #endregion
  6127. GenericCall7 handlerObjectName = null;
  6128. for (int i = 0; i < objName.ObjectData.Length; i++)
  6129. {
  6130. handlerObjectName = OnObjectName;
  6131. if (handlerObjectName != null)
  6132. {
  6133. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6134. Util.FieldToString(objName.ObjectData[i].Name));
  6135. }
  6136. }
  6137. return true;
  6138. }
  6139. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6140. {
  6141. if (OnObjectPermissions != null)
  6142. {
  6143. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6144. #region Packet Session and User Check
  6145. if (m_checkPackets)
  6146. {
  6147. if (newobjPerms.AgentData.SessionID != SessionId ||
  6148. newobjPerms.AgentData.AgentID != AgentId)
  6149. return true;
  6150. }
  6151. #endregion
  6152. UUID AgentID = newobjPerms.AgentData.AgentID;
  6153. UUID SessionID = newobjPerms.AgentData.SessionID;
  6154. ObjectPermissions handlerObjectPermissions = null;
  6155. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6156. {
  6157. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6158. byte field = permChanges.Field;
  6159. uint localID = permChanges.ObjectLocalID;
  6160. uint mask = permChanges.Mask;
  6161. byte set = permChanges.Set;
  6162. handlerObjectPermissions = OnObjectPermissions;
  6163. if (handlerObjectPermissions != null)
  6164. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6165. }
  6166. }
  6167. // Here's our data,
  6168. // PermField contains the field the info goes into
  6169. // PermField determines which mask we're changing
  6170. //
  6171. // chmask is the mask of the change
  6172. // setTF is whether we're adding it or taking it away
  6173. //
  6174. // objLocalID is the localID of the object.
  6175. // Unfortunately, we have to pass the event the packet because objData is an array
  6176. // That means multiple object perms may be updated in a single packet.
  6177. return true;
  6178. }
  6179. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6180. {
  6181. UndoPacket undoitem = (UndoPacket)Pack;
  6182. #region Packet Session and User Check
  6183. if (m_checkPackets)
  6184. {
  6185. if (undoitem.AgentData.SessionID != SessionId ||
  6186. undoitem.AgentData.AgentID != AgentId)
  6187. return true;
  6188. }
  6189. #endregion
  6190. if (undoitem.ObjectData.Length > 0)
  6191. {
  6192. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6193. {
  6194. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6195. AgentSit handlerOnUndo = OnUndo;
  6196. if (handlerOnUndo != null)
  6197. {
  6198. handlerOnUndo(this, objiD);
  6199. }
  6200. }
  6201. }
  6202. return true;
  6203. }
  6204. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6205. {
  6206. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6207. #region Packet Session and User Check
  6208. if (m_checkPackets)
  6209. {
  6210. if (undolanditem.AgentData.SessionID != SessionId ||
  6211. undolanditem.AgentData.AgentID != AgentId)
  6212. return true;
  6213. }
  6214. #endregion
  6215. LandUndo handlerOnUndo = OnLandUndo;
  6216. if (handlerOnUndo != null)
  6217. {
  6218. handlerOnUndo(this);
  6219. }
  6220. return true;
  6221. }
  6222. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6223. {
  6224. RedoPacket redoitem = (RedoPacket)Pack;
  6225. #region Packet Session and User Check
  6226. if (m_checkPackets)
  6227. {
  6228. if (redoitem.AgentData.SessionID != SessionId ||
  6229. redoitem.AgentData.AgentID != AgentId)
  6230. return true;
  6231. }
  6232. #endregion
  6233. if (redoitem.ObjectData.Length > 0)
  6234. {
  6235. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6236. {
  6237. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6238. AgentSit handlerOnRedo = OnRedo;
  6239. if (handlerOnRedo != null)
  6240. {
  6241. handlerOnRedo(this, objiD);
  6242. }
  6243. }
  6244. }
  6245. return true;
  6246. }
  6247. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6248. {
  6249. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6250. #region Packet Session and User Check
  6251. if (m_checkPackets)
  6252. {
  6253. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6254. dupeOnRay.AgentData.AgentID != AgentId)
  6255. return true;
  6256. }
  6257. #endregion
  6258. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6259. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6260. {
  6261. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6262. if (handlerObjectDuplicateOnRay != null)
  6263. {
  6264. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6265. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6266. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6267. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6268. }
  6269. }
  6270. return true;
  6271. }
  6272. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6273. {
  6274. //This powers the little tooltip that appears when you move your mouse over an object
  6275. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6276. #region Packet Session and User Check
  6277. if (m_checkPackets)
  6278. {
  6279. if (packToolTip.AgentData.SessionID != SessionId ||
  6280. packToolTip.AgentData.AgentID != AgentId)
  6281. return true;
  6282. }
  6283. #endregion
  6284. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6285. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6286. if (handlerRequestObjectPropertiesFamily != null)
  6287. {
  6288. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6289. packObjBlock.ObjectID);
  6290. }
  6291. return true;
  6292. }
  6293. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6294. {
  6295. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6296. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6297. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6298. #region Packet Session and User Check
  6299. if (m_checkPackets)
  6300. {
  6301. if (packInSearch.AgentData.SessionID != SessionId ||
  6302. packInSearch.AgentData.AgentID != AgentId)
  6303. return true;
  6304. }
  6305. #endregion
  6306. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6307. {
  6308. bool inSearch = objData.IncludeInSearch;
  6309. uint localID = objData.ObjectLocalID;
  6310. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6311. if (handlerObjectIncludeInSearch != null)
  6312. {
  6313. handlerObjectIncludeInSearch(this, inSearch, localID);
  6314. }
  6315. }
  6316. return true;
  6317. }
  6318. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6319. {
  6320. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6321. #region Packet Session and User Check
  6322. if (m_checkPackets)
  6323. {
  6324. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6325. scriptAnswer.AgentData.AgentID != AgentId)
  6326. return true;
  6327. }
  6328. #endregion
  6329. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6330. if (handlerScriptAnswer != null)
  6331. {
  6332. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6333. }
  6334. return true;
  6335. }
  6336. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6337. {
  6338. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6339. #region Packet Session and User Check
  6340. if (m_checkPackets)
  6341. {
  6342. if (ocpacket.AgentData.SessionID != SessionId ||
  6343. ocpacket.AgentData.AgentID != AgentId)
  6344. return true;
  6345. }
  6346. #endregion
  6347. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6348. if (handlerObjectClickAction != null)
  6349. {
  6350. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6351. {
  6352. byte action = odata.ClickAction;
  6353. uint localID = odata.ObjectLocalID;
  6354. handlerObjectClickAction(this, localID, action.ToString());
  6355. }
  6356. }
  6357. return true;
  6358. }
  6359. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6360. {
  6361. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6362. #region Packet Session and User Check
  6363. if (m_checkPackets)
  6364. {
  6365. if (ompacket.AgentData.SessionID != SessionId ||
  6366. ompacket.AgentData.AgentID != AgentId)
  6367. return true;
  6368. }
  6369. #endregion
  6370. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6371. if (handlerObjectMaterial != null)
  6372. {
  6373. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6374. {
  6375. byte material = odata.Material;
  6376. uint localID = odata.ObjectLocalID;
  6377. handlerObjectMaterial(this, localID, material.ToString());
  6378. }
  6379. }
  6380. return true;
  6381. }
  6382. #endregion Objects/m_sceneObjects
  6383. #region Inventory/Asset/Other related packets
  6384. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6385. {
  6386. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6387. //m_log.Debug("image request: " + Pack.ToString());
  6388. #region Packet Session and User Check
  6389. if (m_checkPackets)
  6390. {
  6391. if (imageRequest.AgentData.SessionID != SessionId ||
  6392. imageRequest.AgentData.AgentID != AgentId)
  6393. return true;
  6394. }
  6395. #endregion
  6396. //handlerTextureRequest = null;
  6397. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6398. {
  6399. TextureRequestArgs args = new TextureRequestArgs();
  6400. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6401. args.RequestedAssetID = block.Image;
  6402. args.DiscardLevel = block.DiscardLevel;
  6403. args.PacketNumber = block.Packet;
  6404. args.Priority = block.DownloadPriority;
  6405. args.requestSequence = imageRequest.Header.Sequence;
  6406. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6407. // priority of avatar textures to get avatars rezzing in faster than the
  6408. // surrounding scene
  6409. if ((ImageType)block.Type == ImageType.Baked)
  6410. args.Priority *= 2.0f;
  6411. ImageManager.EnqueueReq(args);
  6412. }
  6413. return true;
  6414. }
  6415. /// <summary>
  6416. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6417. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6418. /// </summary>
  6419. /// <param name="sender"></param>
  6420. /// <param name="Pack"></param>
  6421. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6422. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6423. {
  6424. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6425. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6426. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6427. // Validate inventory transfers
  6428. // Has to be done here, because AssetCache can't do it
  6429. //
  6430. UUID taskID = UUID.Zero;
  6431. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6432. {
  6433. taskID = new UUID(transfer.TransferInfo.Params, 48);
  6434. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6435. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6436. // m_log.DebugFormat(
  6437. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6438. // requestID, itemID, taskID, Name);
  6439. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6440. {
  6441. if (taskID != UUID.Zero) // Prim
  6442. {
  6443. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6444. if (part == null)
  6445. {
  6446. m_log.WarnFormat(
  6447. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6448. Name, requestID, itemID, taskID);
  6449. return true;
  6450. }
  6451. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6452. if (tii == null)
  6453. {
  6454. m_log.WarnFormat(
  6455. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6456. Name, requestID, itemID, taskID);
  6457. return true;
  6458. }
  6459. if (tii.Type == (int)AssetType.LSLText)
  6460. {
  6461. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6462. return true;
  6463. }
  6464. else if (tii.Type == (int)AssetType.Notecard)
  6465. {
  6466. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6467. return true;
  6468. }
  6469. else
  6470. {
  6471. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6472. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6473. if (part.OwnerID != AgentId)
  6474. {
  6475. m_log.WarnFormat(
  6476. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6477. Name, requestID, itemID, taskID, part.OwnerID);
  6478. return true;
  6479. }
  6480. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6481. {
  6482. m_log.WarnFormat(
  6483. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6484. Name, requestID, itemID, taskID);
  6485. return true;
  6486. }
  6487. if (tii.OwnerID != AgentId)
  6488. {
  6489. m_log.WarnFormat(
  6490. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6491. Name, requestID, itemID, taskID, tii.OwnerID);
  6492. return true;
  6493. }
  6494. if ((
  6495. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6496. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6497. {
  6498. m_log.WarnFormat(
  6499. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6500. Name, requestID, itemID, taskID);
  6501. return true;
  6502. }
  6503. if (tii.AssetID != requestID)
  6504. {
  6505. m_log.WarnFormat(
  6506. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6507. Name, requestID, itemID, taskID, tii.AssetID);
  6508. return true;
  6509. }
  6510. }
  6511. }
  6512. else // Agent
  6513. {
  6514. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6515. if (invAccess != null)
  6516. {
  6517. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6518. return false;
  6519. }
  6520. else
  6521. {
  6522. return false;
  6523. }
  6524. }
  6525. }
  6526. }
  6527. MakeAssetRequest(transfer, taskID);
  6528. return true;
  6529. }
  6530. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6531. {
  6532. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6533. // m_log.Debug("upload request " + request.ToString());
  6534. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6535. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6536. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6537. if (handlerAssetUploadRequest != null)
  6538. {
  6539. handlerAssetUploadRequest(this, temp,
  6540. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6541. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6542. request.AssetBlock.Tempfile);
  6543. }
  6544. return true;
  6545. }
  6546. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6547. {
  6548. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6549. RequestXfer handlerRequestXfer = OnRequestXfer;
  6550. if (handlerRequestXfer != null)
  6551. {
  6552. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6553. }
  6554. return true;
  6555. }
  6556. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  6557. {
  6558. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  6559. XferReceive handlerXferReceive = OnXferReceive;
  6560. if (handlerXferReceive != null)
  6561. {
  6562. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  6563. }
  6564. return true;
  6565. }
  6566. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  6567. {
  6568. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  6569. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  6570. if (handlerConfirmXfer != null)
  6571. {
  6572. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  6573. }
  6574. return true;
  6575. }
  6576. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  6577. {
  6578. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  6579. AbortXfer handlerAbortXfer = OnAbortXfer;
  6580. if (handlerAbortXfer != null)
  6581. {
  6582. handlerAbortXfer(this, abortXfer.XferID.ID);
  6583. }
  6584. return true;
  6585. }
  6586. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  6587. {
  6588. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  6589. #region Packet Session and User Check
  6590. if (m_checkPackets)
  6591. {
  6592. if (invFolder.AgentData.SessionID != SessionId ||
  6593. invFolder.AgentData.AgentID != AgentId)
  6594. return true;
  6595. }
  6596. #endregion
  6597. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  6598. if (handlerCreateInventoryFolder != null)
  6599. {
  6600. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  6601. (ushort)invFolder.FolderData.Type,
  6602. Util.FieldToString(invFolder.FolderData.Name),
  6603. invFolder.FolderData.ParentID);
  6604. }
  6605. return true;
  6606. }
  6607. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  6608. {
  6609. if (OnUpdateInventoryFolder != null)
  6610. {
  6611. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  6612. #region Packet Session and User Check
  6613. if (m_checkPackets)
  6614. {
  6615. if (invFolderx.AgentData.SessionID != SessionId ||
  6616. invFolderx.AgentData.AgentID != AgentId)
  6617. return true;
  6618. }
  6619. #endregion
  6620. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  6621. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  6622. {
  6623. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  6624. if (handlerUpdateInventoryFolder != null)
  6625. {
  6626. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  6627. (ushort)invFolderx.FolderData[i].Type,
  6628. Util.FieldToString(invFolderx.FolderData[i].Name),
  6629. invFolderx.FolderData[i].ParentID);
  6630. }
  6631. }
  6632. }
  6633. return true;
  6634. }
  6635. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  6636. {
  6637. if (OnMoveInventoryFolder != null)
  6638. {
  6639. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  6640. #region Packet Session and User Check
  6641. if (m_checkPackets)
  6642. {
  6643. if (invFoldery.AgentData.SessionID != SessionId ||
  6644. invFoldery.AgentData.AgentID != AgentId)
  6645. return true;
  6646. }
  6647. #endregion
  6648. MoveInventoryFolder handlerMoveInventoryFolder = null;
  6649. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  6650. {
  6651. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  6652. if (handlerMoveInventoryFolder != null)
  6653. {
  6654. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  6655. invFoldery.InventoryData[i].ParentID);
  6656. }
  6657. }
  6658. }
  6659. return true;
  6660. }
  6661. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  6662. {
  6663. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  6664. #region Packet Session and User Check
  6665. if (m_checkPackets)
  6666. {
  6667. if (createItem.AgentData.SessionID != SessionId ||
  6668. createItem.AgentData.AgentID != AgentId)
  6669. return true;
  6670. }
  6671. #endregion
  6672. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  6673. if (handlerCreateNewInventoryItem != null)
  6674. {
  6675. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  6676. createItem.InventoryBlock.FolderID,
  6677. createItem.InventoryBlock.CallbackID,
  6678. Util.FieldToString(createItem.InventoryBlock.Description),
  6679. Util.FieldToString(createItem.InventoryBlock.Name),
  6680. createItem.InventoryBlock.InvType,
  6681. createItem.InventoryBlock.Type,
  6682. createItem.InventoryBlock.WearableType,
  6683. createItem.InventoryBlock.NextOwnerMask,
  6684. Util.UnixTimeSinceEpoch());
  6685. }
  6686. return true;
  6687. }
  6688. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  6689. {
  6690. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  6691. #region Packet Session and User Check
  6692. if (m_checkPackets)
  6693. {
  6694. if (createLink.AgentData.SessionID != SessionId ||
  6695. createLink.AgentData.AgentID != AgentId)
  6696. return true;
  6697. }
  6698. #endregion
  6699. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  6700. if (linkInventoryItem != null)
  6701. {
  6702. linkInventoryItem(
  6703. this,
  6704. createLink.InventoryBlock.TransactionID,
  6705. createLink.InventoryBlock.FolderID,
  6706. createLink.InventoryBlock.CallbackID,
  6707. Util.FieldToString(createLink.InventoryBlock.Description),
  6708. Util.FieldToString(createLink.InventoryBlock.Name),
  6709. createLink.InventoryBlock.InvType,
  6710. createLink.InventoryBlock.Type,
  6711. createLink.InventoryBlock.OldItemID);
  6712. }
  6713. return true;
  6714. }
  6715. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  6716. {
  6717. if (OnFetchInventory != null)
  6718. {
  6719. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  6720. #region Packet Session and User Check
  6721. if (m_checkPackets)
  6722. {
  6723. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  6724. FetchInventoryx.AgentData.AgentID != AgentId)
  6725. return true;
  6726. }
  6727. #endregion
  6728. FetchInventory handlerFetchInventory = null;
  6729. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  6730. {
  6731. handlerFetchInventory = OnFetchInventory;
  6732. if (handlerFetchInventory != null)
  6733. {
  6734. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  6735. FetchInventoryx.InventoryData[i].OwnerID);
  6736. }
  6737. }
  6738. }
  6739. return true;
  6740. }
  6741. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  6742. {
  6743. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  6744. #region Packet Session and User Check
  6745. if (m_checkPackets)
  6746. {
  6747. if (Fetch.AgentData.SessionID != SessionId ||
  6748. Fetch.AgentData.AgentID != AgentId)
  6749. return true;
  6750. }
  6751. #endregion
  6752. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  6753. if (handlerFetchInventoryDescendents != null)
  6754. {
  6755. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  6756. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  6757. Fetch.InventoryData.SortOrder);
  6758. }
  6759. return true;
  6760. }
  6761. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  6762. {
  6763. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  6764. #region Packet Session and User Check
  6765. if (m_checkPackets)
  6766. {
  6767. if (Purge.AgentData.SessionID != SessionId ||
  6768. Purge.AgentData.AgentID != AgentId)
  6769. return true;
  6770. }
  6771. #endregion
  6772. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  6773. if (handlerPurgeInventoryDescendents != null)
  6774. {
  6775. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  6776. }
  6777. return true;
  6778. }
  6779. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  6780. {
  6781. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  6782. #region Packet Session and User Check
  6783. if (m_checkPackets)
  6784. {
  6785. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  6786. inventoryItemUpdate.AgentData.AgentID != AgentId)
  6787. return true;
  6788. }
  6789. #endregion
  6790. if (OnUpdateInventoryItem != null)
  6791. {
  6792. UpdateInventoryItem handlerUpdateInventoryItem = null;
  6793. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  6794. {
  6795. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  6796. if (handlerUpdateInventoryItem != null)
  6797. {
  6798. InventoryItemBase itemUpd = new InventoryItemBase();
  6799. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  6800. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  6801. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  6802. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  6803. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  6804. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  6805. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  6806. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  6807. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  6808. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  6809. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  6810. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  6811. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  6812. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  6813. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  6814. inventoryItemUpdate.InventoryData[i].ItemID,
  6815. itemUpd);
  6816. }
  6817. }
  6818. }
  6819. return true;
  6820. }
  6821. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  6822. {
  6823. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  6824. #region Packet Session and User Check
  6825. if (m_checkPackets)
  6826. {
  6827. if (copyitem.AgentData.SessionID != SessionId ||
  6828. copyitem.AgentData.AgentID != AgentId)
  6829. return true;
  6830. }
  6831. #endregion
  6832. CopyInventoryItem handlerCopyInventoryItem = null;
  6833. if (OnCopyInventoryItem != null)
  6834. {
  6835. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  6836. {
  6837. handlerCopyInventoryItem = OnCopyInventoryItem;
  6838. if (handlerCopyInventoryItem != null)
  6839. {
  6840. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  6841. datablock.OldItemID, datablock.NewFolderID,
  6842. Util.FieldToString(datablock.NewName));
  6843. }
  6844. }
  6845. }
  6846. return true;
  6847. }
  6848. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  6849. {
  6850. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  6851. #region Packet Session and User Check
  6852. if (m_checkPackets)
  6853. {
  6854. if (moveitem.AgentData.SessionID != SessionId ||
  6855. moveitem.AgentData.AgentID != AgentId)
  6856. return true;
  6857. }
  6858. #endregion
  6859. if (OnMoveInventoryItem != null)
  6860. {
  6861. MoveInventoryItem handlerMoveInventoryItem = null;
  6862. InventoryItemBase itm = null;
  6863. List<InventoryItemBase> items = new List<InventoryItemBase>();
  6864. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  6865. {
  6866. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  6867. itm.Folder = datablock.FolderID;
  6868. itm.Name = Util.FieldToString(datablock.NewName);
  6869. // weird, comes out as empty string
  6870. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  6871. items.Add(itm);
  6872. }
  6873. handlerMoveInventoryItem = OnMoveInventoryItem;
  6874. if (handlerMoveInventoryItem != null)
  6875. {
  6876. handlerMoveInventoryItem(this, items);
  6877. }
  6878. }
  6879. return true;
  6880. }
  6881. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  6882. {
  6883. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  6884. #region Packet Session and User Check
  6885. if (m_checkPackets)
  6886. {
  6887. if (removeItem.AgentData.SessionID != SessionId ||
  6888. removeItem.AgentData.AgentID != AgentId)
  6889. return true;
  6890. }
  6891. #endregion
  6892. if (OnRemoveInventoryItem != null)
  6893. {
  6894. RemoveInventoryItem handlerRemoveInventoryItem = null;
  6895. List<UUID> uuids = new List<UUID>();
  6896. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  6897. {
  6898. uuids.Add(datablock.ItemID);
  6899. }
  6900. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  6901. if (handlerRemoveInventoryItem != null)
  6902. {
  6903. handlerRemoveInventoryItem(this, uuids);
  6904. }
  6905. }
  6906. return true;
  6907. }
  6908. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  6909. {
  6910. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  6911. #region Packet Session and User Check
  6912. if (m_checkPackets)
  6913. {
  6914. if (removeFolder.AgentData.SessionID != SessionId ||
  6915. removeFolder.AgentData.AgentID != AgentId)
  6916. return true;
  6917. }
  6918. #endregion
  6919. if (OnRemoveInventoryFolder != null)
  6920. {
  6921. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  6922. List<UUID> uuids = new List<UUID>();
  6923. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  6924. {
  6925. uuids.Add(datablock.FolderID);
  6926. }
  6927. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  6928. if (handlerRemoveInventoryFolder != null)
  6929. {
  6930. handlerRemoveInventoryFolder(this, uuids);
  6931. }
  6932. }
  6933. return true;
  6934. }
  6935. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  6936. {
  6937. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  6938. #region Packet Session and User Check
  6939. if (m_checkPackets)
  6940. {
  6941. if (removeObject.AgentData.SessionID != SessionId ||
  6942. removeObject.AgentData.AgentID != AgentId)
  6943. return true;
  6944. }
  6945. #endregion
  6946. if (OnRemoveInventoryFolder != null)
  6947. {
  6948. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  6949. List<UUID> uuids = new List<UUID>();
  6950. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  6951. {
  6952. uuids.Add(datablock.FolderID);
  6953. }
  6954. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  6955. if (handlerRemoveInventoryFolder != null)
  6956. {
  6957. handlerRemoveInventoryFolder(this, uuids);
  6958. }
  6959. }
  6960. if (OnRemoveInventoryItem != null)
  6961. {
  6962. RemoveInventoryItem handlerRemoveInventoryItem = null;
  6963. List<UUID> uuids = new List<UUID>();
  6964. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  6965. {
  6966. uuids.Add(datablock.ItemID);
  6967. }
  6968. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  6969. if (handlerRemoveInventoryItem != null)
  6970. {
  6971. handlerRemoveInventoryItem(this, uuids);
  6972. }
  6973. }
  6974. return true;
  6975. }
  6976. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  6977. {
  6978. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  6979. #region Packet Session and User Check
  6980. if (m_checkPackets)
  6981. {
  6982. if (requesttask.AgentData.SessionID != SessionId ||
  6983. requesttask.AgentData.AgentID != AgentId)
  6984. return true;
  6985. }
  6986. #endregion
  6987. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  6988. if (handlerRequestTaskInventory != null)
  6989. {
  6990. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  6991. }
  6992. return true;
  6993. }
  6994. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  6995. {
  6996. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  6997. #region Packet Session and User Check
  6998. if (m_checkPackets)
  6999. {
  7000. if (updatetask.AgentData.SessionID != SessionId ||
  7001. updatetask.AgentData.AgentID != AgentId)
  7002. return true;
  7003. }
  7004. #endregion
  7005. if (OnUpdateTaskInventory != null)
  7006. {
  7007. if (updatetask.UpdateData.Key == 0)
  7008. {
  7009. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7010. if (handlerUpdateTaskInventory != null)
  7011. {
  7012. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7013. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7014. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7015. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7016. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7017. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7018. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7019. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7020. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7021. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7022. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7023. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7024. // different
  7025. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7026. newTaskItem.Type = updatetask.InventoryData.Type;
  7027. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7028. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7029. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7030. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7031. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7032. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7033. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7034. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7035. newTaskItem, updatetask.UpdateData.LocalID);
  7036. }
  7037. }
  7038. }
  7039. return true;
  7040. }
  7041. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7042. {
  7043. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7044. #region Packet Session and User Check
  7045. if (m_checkPackets)
  7046. {
  7047. if (removeTask.AgentData.SessionID != SessionId ||
  7048. removeTask.AgentData.AgentID != AgentId)
  7049. return true;
  7050. }
  7051. #endregion
  7052. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7053. if (handlerRemoveTaskItem != null)
  7054. {
  7055. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7056. }
  7057. return true;
  7058. }
  7059. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7060. {
  7061. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7062. #region Packet Session and User Check
  7063. if (m_checkPackets)
  7064. {
  7065. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7066. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7067. return true;
  7068. }
  7069. #endregion
  7070. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7071. if (handlerMoveTaskItem != null)
  7072. {
  7073. handlerMoveTaskItem(
  7074. this, moveTaskInventoryPacket.AgentData.FolderID,
  7075. moveTaskInventoryPacket.InventoryData.LocalID,
  7076. moveTaskInventoryPacket.InventoryData.ItemID);
  7077. }
  7078. return true;
  7079. }
  7080. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7081. {
  7082. //m_log.Debug(Pack.ToString());
  7083. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7084. #region Packet Session and User Check
  7085. if (m_checkPackets)
  7086. {
  7087. if (rezScriptx.AgentData.SessionID != SessionId ||
  7088. rezScriptx.AgentData.AgentID != AgentId)
  7089. return true;
  7090. }
  7091. #endregion
  7092. RezScript handlerRezScript = OnRezScript;
  7093. InventoryItemBase item = new InventoryItemBase();
  7094. item.ID = rezScriptx.InventoryBlock.ItemID;
  7095. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7096. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7097. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7098. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7099. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7100. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7101. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7102. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7103. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7104. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7105. item.AssetType = rezScriptx.InventoryBlock.Type;
  7106. item.InvType = rezScriptx.InventoryBlock.InvType;
  7107. item.Flags = rezScriptx.InventoryBlock.Flags;
  7108. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7109. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7110. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7111. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7112. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7113. if (handlerRezScript != null)
  7114. {
  7115. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7116. }
  7117. return true;
  7118. }
  7119. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7120. {
  7121. RequestMapLayer();
  7122. return true;
  7123. }
  7124. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7125. {
  7126. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7127. #region Packet Session and User Check
  7128. if (m_checkPackets)
  7129. {
  7130. if (MapRequest.AgentData.SessionID != SessionId ||
  7131. MapRequest.AgentData.AgentID != AgentId)
  7132. return true;
  7133. }
  7134. #endregion
  7135. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7136. if (handlerRequestMapBlocks != null)
  7137. {
  7138. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7139. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7140. }
  7141. return true;
  7142. }
  7143. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7144. {
  7145. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7146. #region Packet Session and User Check
  7147. if (m_checkPackets)
  7148. {
  7149. if (map.AgentData.SessionID != SessionId ||
  7150. map.AgentData.AgentID != AgentId)
  7151. return true;
  7152. }
  7153. #endregion
  7154. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7155. map.NameData.Name.Length - 1);
  7156. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7157. if (handlerMapNameRequest != null)
  7158. {
  7159. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7160. }
  7161. return true;
  7162. }
  7163. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7164. {
  7165. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7166. #region Packet Session and User Check
  7167. if (m_checkPackets)
  7168. {
  7169. if (tpReq.Info.SessionID != SessionId ||
  7170. tpReq.Info.AgentID != AgentId)
  7171. return true;
  7172. }
  7173. #endregion
  7174. UUID lmid = tpReq.Info.LandmarkID;
  7175. AssetLandmark lm;
  7176. if (lmid != UUID.Zero)
  7177. {
  7178. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7179. AssetBase lma = m_assetService.Get(lmid.ToString());
  7180. if (lma == null)
  7181. {
  7182. // Failed to find landmark
  7183. // Let's try to search in the user's home asset server
  7184. lma = FindAssetInUserAssetServer(lmid.ToString());
  7185. if (lma == null)
  7186. {
  7187. // Really doesn't exist
  7188. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7189. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7190. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7191. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7192. }
  7193. }
  7194. try
  7195. {
  7196. lm = new AssetLandmark(lma);
  7197. }
  7198. catch (NullReferenceException)
  7199. {
  7200. // asset not found generates null ref inside the assetlandmark constructor.
  7201. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7202. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7203. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7204. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7205. return true;
  7206. }
  7207. }
  7208. else
  7209. {
  7210. // Teleport home request
  7211. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7212. if (handlerTeleportHomeRequest != null)
  7213. {
  7214. handlerTeleportHomeRequest(AgentId, this);
  7215. }
  7216. return true;
  7217. }
  7218. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7219. if (handlerTeleportLandmarkRequest != null)
  7220. {
  7221. handlerTeleportLandmarkRequest(this, lm);
  7222. }
  7223. else
  7224. {
  7225. //no event handler so cancel request
  7226. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7227. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7228. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7229. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7230. }
  7231. return true;
  7232. }
  7233. private AssetBase FindAssetInUserAssetServer(string id)
  7234. {
  7235. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7236. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7237. {
  7238. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7239. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7240. }
  7241. return null;
  7242. }
  7243. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7244. {
  7245. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7246. // m_log.Debug(tpLocReq.ToString());
  7247. #region Packet Session and User Check
  7248. if (m_checkPackets)
  7249. {
  7250. if (tpLocReq.AgentData.SessionID != SessionId ||
  7251. tpLocReq.AgentData.AgentID != AgentId)
  7252. return true;
  7253. }
  7254. #endregion
  7255. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7256. if (handlerTeleportLocationRequest != null)
  7257. {
  7258. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7259. tpLocReq.Info.LookAt, 16);
  7260. }
  7261. else
  7262. {
  7263. //no event handler so cancel request
  7264. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7265. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7266. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7267. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7268. }
  7269. return true;
  7270. }
  7271. #endregion Inventory/Asset/Other related packets
  7272. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7273. {
  7274. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7275. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7276. {
  7277. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7278. if (handlerNameRequest != null)
  7279. {
  7280. handlerNameRequest(UUIDBlock.ID, this);
  7281. }
  7282. }
  7283. return true;
  7284. }
  7285. #region Parcel related packets
  7286. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7287. {
  7288. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7289. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7290. if (handlerRegionHandleRequest != null)
  7291. {
  7292. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7293. }
  7294. return true;
  7295. }
  7296. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7297. {
  7298. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7299. #region Packet Session and User Check
  7300. if (m_checkPackets)
  7301. {
  7302. if (pirPack.AgentData.SessionID != SessionId ||
  7303. pirPack.AgentData.AgentID != AgentId)
  7304. return true;
  7305. }
  7306. #endregion
  7307. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7308. if (handlerParcelInfoRequest != null)
  7309. {
  7310. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7311. }
  7312. return true;
  7313. }
  7314. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7315. {
  7316. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7317. #region Packet Session and User Check
  7318. if (m_checkPackets)
  7319. {
  7320. if (requestPacket.AgentData.SessionID != SessionId ||
  7321. requestPacket.AgentData.AgentID != AgentId)
  7322. return true;
  7323. }
  7324. #endregion
  7325. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7326. if (handlerParcelAccessListRequest != null)
  7327. {
  7328. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7329. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7330. requestPacket.Data.LocalID, this);
  7331. }
  7332. return true;
  7333. }
  7334. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7335. {
  7336. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7337. #region Packet Session and User Check
  7338. if (m_checkPackets)
  7339. {
  7340. if (updatePacket.AgentData.SessionID != SessionId ||
  7341. updatePacket.AgentData.AgentID != AgentId)
  7342. return true;
  7343. }
  7344. #endregion
  7345. List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>();
  7346. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7347. {
  7348. ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
  7349. entry.AgentID = block.ID;
  7350. entry.Flags = (AccessList)block.Flags;
  7351. entry.Time = Util.ToDateTime(block.Time);
  7352. entries.Add(entry);
  7353. }
  7354. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7355. if (handlerParcelAccessListUpdateRequest != null)
  7356. {
  7357. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7358. updatePacket.Data.Flags,
  7359. updatePacket.Data.LocalID,
  7360. updatePacket.Data.TransactionID,
  7361. updatePacket.Data.SequenceID,
  7362. updatePacket.Data.Sections,
  7363. entries, this);
  7364. }
  7365. return true;
  7366. }
  7367. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7368. {
  7369. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7370. #region Packet Session and User Check
  7371. if (m_checkPackets)
  7372. {
  7373. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7374. propertiesRequest.AgentData.AgentID != AgentId)
  7375. return true;
  7376. }
  7377. #endregion
  7378. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7379. if (handlerParcelPropertiesRequest != null)
  7380. {
  7381. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7382. (int)Math.Round(propertiesRequest.ParcelData.South),
  7383. (int)Math.Round(propertiesRequest.ParcelData.East),
  7384. (int)Math.Round(propertiesRequest.ParcelData.North),
  7385. propertiesRequest.ParcelData.SequenceID,
  7386. propertiesRequest.ParcelData.SnapSelection, this);
  7387. }
  7388. return true;
  7389. }
  7390. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7391. {
  7392. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7393. #region Packet Session and User Check
  7394. if (m_checkPackets)
  7395. {
  7396. if (landDivide.AgentData.SessionID != SessionId ||
  7397. landDivide.AgentData.AgentID != AgentId)
  7398. return true;
  7399. }
  7400. #endregion
  7401. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7402. if (handlerParcelDivideRequest != null)
  7403. {
  7404. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7405. (int)Math.Round(landDivide.ParcelData.South),
  7406. (int)Math.Round(landDivide.ParcelData.East),
  7407. (int)Math.Round(landDivide.ParcelData.North), this);
  7408. }
  7409. return true;
  7410. }
  7411. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7412. {
  7413. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7414. #region Packet Session and User Check
  7415. if (m_checkPackets)
  7416. {
  7417. if (landJoin.AgentData.SessionID != SessionId ||
  7418. landJoin.AgentData.AgentID != AgentId)
  7419. return true;
  7420. }
  7421. #endregion
  7422. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7423. if (handlerParcelJoinRequest != null)
  7424. {
  7425. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7426. (int)Math.Round(landJoin.ParcelData.South),
  7427. (int)Math.Round(landJoin.ParcelData.East),
  7428. (int)Math.Round(landJoin.ParcelData.North), this);
  7429. }
  7430. return true;
  7431. }
  7432. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7433. {
  7434. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7435. #region Packet Session and User Check
  7436. if (m_checkPackets)
  7437. {
  7438. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7439. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7440. return true;
  7441. }
  7442. #endregion
  7443. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7444. if (handlerParcelPropertiesUpdateRequest != null)
  7445. {
  7446. LandUpdateArgs args = new LandUpdateArgs();
  7447. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7448. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7449. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7450. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7451. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7452. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7453. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7454. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7455. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7456. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7457. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7458. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7459. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7460. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7461. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7462. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7463. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7464. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7465. }
  7466. return true;
  7467. }
  7468. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7469. {
  7470. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7471. #region Packet Session and User Check
  7472. if (m_checkPackets)
  7473. {
  7474. if (selectPacket.AgentData.SessionID != SessionId ||
  7475. selectPacket.AgentData.AgentID != AgentId)
  7476. return true;
  7477. }
  7478. #endregion
  7479. List<UUID> returnIDs = new List<UUID>();
  7480. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7481. selectPacket.ReturnIDs)
  7482. {
  7483. returnIDs.Add(rb.ReturnID);
  7484. }
  7485. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7486. if (handlerParcelSelectObjects != null)
  7487. {
  7488. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7489. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7490. }
  7491. return true;
  7492. }
  7493. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7494. {
  7495. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7496. #region Packet Session and User Check
  7497. if (m_checkPackets)
  7498. {
  7499. if (reqPacket.AgentData.SessionID != SessionId ||
  7500. reqPacket.AgentData.AgentID != AgentId)
  7501. return true;
  7502. }
  7503. #endregion
  7504. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7505. if (handlerParcelObjectOwnerRequest != null)
  7506. {
  7507. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7508. }
  7509. return true;
  7510. }
  7511. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7512. {
  7513. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7514. #region Packet Session and User Check
  7515. if (m_checkPackets)
  7516. {
  7517. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7518. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7519. return true;
  7520. }
  7521. #endregion
  7522. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7523. if (handlerParcelGodForceOwner != null)
  7524. {
  7525. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7526. }
  7527. return true;
  7528. }
  7529. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7530. {
  7531. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7532. #region Packet Session and User Check
  7533. if (m_checkPackets)
  7534. {
  7535. if (releasePacket.AgentData.SessionID != SessionId ||
  7536. releasePacket.AgentData.AgentID != AgentId)
  7537. return true;
  7538. }
  7539. #endregion
  7540. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7541. if (handlerParcelAbandonRequest != null)
  7542. {
  7543. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7544. }
  7545. return true;
  7546. }
  7547. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  7548. {
  7549. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  7550. #region Packet Session and User Check
  7551. if (m_checkPackets)
  7552. {
  7553. if (reclaimPacket.AgentData.SessionID != SessionId ||
  7554. reclaimPacket.AgentData.AgentID != AgentId)
  7555. return true;
  7556. }
  7557. #endregion
  7558. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  7559. if (handlerParcelReclaim != null)
  7560. {
  7561. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  7562. }
  7563. return true;
  7564. }
  7565. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  7566. {
  7567. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  7568. #region Packet Session and User Check
  7569. if (m_checkPackets)
  7570. {
  7571. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  7572. parcelReturnObjects.AgentData.AgentID != AgentId)
  7573. return true;
  7574. }
  7575. #endregion
  7576. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  7577. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  7578. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  7579. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  7580. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  7581. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  7582. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  7583. if (handlerParcelReturnObjectsRequest != null)
  7584. {
  7585. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  7586. }
  7587. return true;
  7588. }
  7589. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  7590. {
  7591. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  7592. #region Packet Session and User Check
  7593. if (m_checkPackets)
  7594. {
  7595. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  7596. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  7597. return true;
  7598. }
  7599. #endregion
  7600. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  7601. if (handlerParcelSetOtherCleanTime != null)
  7602. {
  7603. handlerParcelSetOtherCleanTime(this,
  7604. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  7605. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  7606. }
  7607. return true;
  7608. }
  7609. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  7610. {
  7611. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  7612. #region Packet Session and User Check
  7613. if (m_checkPackets)
  7614. {
  7615. if (lsrp.AgentData.SessionID != SessionId ||
  7616. lsrp.AgentData.AgentID != AgentId)
  7617. return true;
  7618. }
  7619. #endregion
  7620. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  7621. if (handlerLandStatRequest != null)
  7622. {
  7623. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  7624. }
  7625. return true;
  7626. }
  7627. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  7628. {
  7629. ParcelDwellRequestPacket dwellrq =
  7630. (ParcelDwellRequestPacket)Pack;
  7631. #region Packet Session and User Check
  7632. if (m_checkPackets)
  7633. {
  7634. if (dwellrq.AgentData.SessionID != SessionId ||
  7635. dwellrq.AgentData.AgentID != AgentId)
  7636. return true;
  7637. }
  7638. #endregion
  7639. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  7640. if (handlerParcelDwellRequest != null)
  7641. {
  7642. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  7643. }
  7644. return true;
  7645. }
  7646. #endregion Parcel related packets
  7647. #region Estate Packets
  7648. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  7649. {
  7650. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  7651. //m_log.Debug(messagePacket.ToString());
  7652. GodLandStatRequest handlerLandStatRequest;
  7653. #region Packet Session and User Check
  7654. if (m_checkPackets)
  7655. {
  7656. if (messagePacket.AgentData.SessionID != SessionId ||
  7657. messagePacket.AgentData.AgentID != AgentId)
  7658. return true;
  7659. }
  7660. #endregion
  7661. switch (Utils.BytesToString(messagePacket.MethodData.Method))
  7662. {
  7663. case "getinfo":
  7664. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7665. {
  7666. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  7667. }
  7668. return true;
  7669. case "setregioninfo":
  7670. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7671. {
  7672. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  7673. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  7674. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  7675. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  7676. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  7677. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  7678. }
  7679. return true;
  7680. // case "texturebase":
  7681. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7682. // {
  7683. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7684. // {
  7685. // string s = Utils.BytesToString(block.Parameter);
  7686. // string[] splitField = s.Split(' ');
  7687. // if (splitField.Length == 2)
  7688. // {
  7689. // UUID tempUUID = new UUID(splitField[1]);
  7690. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  7691. // }
  7692. // }
  7693. // }
  7694. // break;
  7695. case "texturedetail":
  7696. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7697. {
  7698. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7699. {
  7700. string s = Utils.BytesToString(block.Parameter);
  7701. string[] splitField = s.Split(' ');
  7702. if (splitField.Length == 2)
  7703. {
  7704. Int16 corner = Convert.ToInt16(splitField[0]);
  7705. UUID textureUUID = new UUID(splitField[1]);
  7706. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  7707. }
  7708. }
  7709. }
  7710. return true;
  7711. case "textureheights":
  7712. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7713. {
  7714. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7715. {
  7716. string s = Utils.BytesToString(block.Parameter);
  7717. string[] splitField = s.Split(' ');
  7718. if (splitField.Length == 3)
  7719. {
  7720. Int16 corner = Convert.ToInt16(splitField[0]);
  7721. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  7722. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  7723. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  7724. }
  7725. }
  7726. }
  7727. return true;
  7728. case "texturecommit":
  7729. OnCommitEstateTerrainTextureRequest(this);
  7730. return true;
  7731. case "setregionterrain":
  7732. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7733. {
  7734. if (messagePacket.ParamList.Length != 9)
  7735. {
  7736. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  7737. }
  7738. else
  7739. {
  7740. try
  7741. {
  7742. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7743. if (!tmp.Contains(".")) tmp += ".00";
  7744. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7745. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7746. if (!tmp.Contains(".")) tmp += ".00";
  7747. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7748. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  7749. if (!tmp.Contains(".")) tmp += ".00";
  7750. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  7751. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  7752. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  7753. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  7754. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  7755. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  7756. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  7757. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  7758. }
  7759. catch (Exception ex)
  7760. {
  7761. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  7762. }
  7763. }
  7764. }
  7765. return true;
  7766. case "restart":
  7767. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7768. {
  7769. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  7770. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7771. {
  7772. float timeSeconds;
  7773. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  7774. timeSeconds = (int)timeSeconds;
  7775. OnEstateRestartSimRequest(this, (int)timeSeconds);
  7776. }
  7777. }
  7778. return true;
  7779. case "estatechangecovenantid":
  7780. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7781. {
  7782. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  7783. {
  7784. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  7785. OnEstateChangeCovenantRequest(this, newCovenantID);
  7786. }
  7787. }
  7788. return true;
  7789. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  7790. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7791. {
  7792. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7793. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  7794. }
  7795. return true;
  7796. case "simulatormessage":
  7797. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7798. {
  7799. UUID invoice = messagePacket.MethodData.Invoice;
  7800. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7801. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7802. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7803. UUID sessionID = messagePacket.AgentData.SessionID;
  7804. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7805. }
  7806. return true;
  7807. case "instantmessage":
  7808. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7809. {
  7810. if (messagePacket.ParamList.Length < 2)
  7811. return true;
  7812. UUID invoice = messagePacket.MethodData.Invoice;
  7813. UUID sessionID = messagePacket.AgentData.SessionID;
  7814. UUID SenderID;
  7815. string SenderName;
  7816. string Message;
  7817. if (messagePacket.ParamList.Length < 5)
  7818. {
  7819. SenderID = AgentId;
  7820. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  7821. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  7822. }
  7823. else
  7824. {
  7825. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7826. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  7827. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  7828. }
  7829. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  7830. }
  7831. return true;
  7832. case "setregiondebug":
  7833. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7834. {
  7835. UUID invoice = messagePacket.MethodData.Invoice;
  7836. UUID SenderID = messagePacket.AgentData.AgentID;
  7837. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  7838. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  7839. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  7840. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  7841. }
  7842. return true;
  7843. case "teleporthomeuser":
  7844. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7845. {
  7846. UUID invoice = messagePacket.MethodData.Invoice;
  7847. UUID SenderID = messagePacket.AgentData.AgentID;
  7848. UUID Prey;
  7849. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  7850. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  7851. }
  7852. return true;
  7853. case "teleporthomeallusers":
  7854. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7855. {
  7856. UUID invoice = messagePacket.MethodData.Invoice;
  7857. UUID SenderID = messagePacket.AgentData.AgentID;
  7858. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  7859. }
  7860. return true;
  7861. case "colliders":
  7862. handlerLandStatRequest = OnLandStatRequest;
  7863. if (handlerLandStatRequest != null)
  7864. {
  7865. handlerLandStatRequest(0, 1, 0, "", this);
  7866. }
  7867. return true;
  7868. case "scripts":
  7869. handlerLandStatRequest = OnLandStatRequest;
  7870. if (handlerLandStatRequest != null)
  7871. {
  7872. handlerLandStatRequest(0, 0, 0, "", this);
  7873. }
  7874. return true;
  7875. case "terrain":
  7876. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7877. {
  7878. if (messagePacket.ParamList.Length > 0)
  7879. {
  7880. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  7881. {
  7882. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  7883. if (handlerBakeTerrain != null)
  7884. {
  7885. handlerBakeTerrain(this);
  7886. }
  7887. }
  7888. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  7889. {
  7890. if (messagePacket.ParamList.Length > 1)
  7891. {
  7892. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  7893. if (handlerRequestTerrain != null)
  7894. {
  7895. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7896. }
  7897. }
  7898. }
  7899. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  7900. {
  7901. if (messagePacket.ParamList.Length > 1)
  7902. {
  7903. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  7904. if (handlerUploadTerrain != null)
  7905. {
  7906. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7907. }
  7908. }
  7909. }
  7910. }
  7911. }
  7912. return true;
  7913. case "estatechangeinfo":
  7914. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  7915. {
  7916. UUID invoice = messagePacket.MethodData.Invoice;
  7917. UUID SenderID = messagePacket.AgentData.AgentID;
  7918. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  7919. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  7920. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  7921. if (handlerEstateChangeInfo != null)
  7922. {
  7923. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  7924. }
  7925. }
  7926. return true;
  7927. default:
  7928. m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket);
  7929. return true;
  7930. }
  7931. //int parcelID, uint reportType, uint requestflags, string filter
  7932. //lsrp.RequestData.ParcelLocalID;
  7933. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  7934. //lsrp.RequestData.RequestFlags;
  7935. //lsrp.RequestData.Filter;
  7936. // return true;
  7937. }
  7938. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  7939. {
  7940. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  7941. #region Packet Session and User Check
  7942. if (m_checkPackets)
  7943. {
  7944. if (mPacket.SessionID != SessionId ||
  7945. mPacket.AgentID != AgentId)
  7946. return true;
  7947. }
  7948. #endregion
  7949. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  7950. if (handlerRegionInfoRequest != null)
  7951. {
  7952. handlerRegionInfoRequest(this);
  7953. }
  7954. return true;
  7955. }
  7956. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  7957. {
  7958. //EstateCovenantRequestPacket.AgentDataBlock epack =
  7959. // ((EstateCovenantRequestPacket)Pack).AgentData;
  7960. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  7961. if (handlerEstateCovenantRequest != null)
  7962. {
  7963. handlerEstateCovenantRequest(this);
  7964. }
  7965. return true;
  7966. }
  7967. #endregion Estate Packets
  7968. #region GodPackets
  7969. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  7970. {
  7971. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  7972. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  7973. UUID token = rblock.Token;
  7974. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  7975. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  7976. if (handlerReqGodlikePowers != null)
  7977. {
  7978. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  7979. }
  7980. return true;
  7981. }
  7982. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  7983. {
  7984. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  7985. (GodUpdateRegionInfoPacket)Packet;
  7986. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  7987. if (handlerGodUpdateRegionInfo != null)
  7988. {
  7989. handlerGodUpdateRegionInfo(this,
  7990. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  7991. GodUpdateRegionInfo.RegionInfo.EstateID,
  7992. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  7993. GodUpdateRegionInfo.RegionInfo.SimName,
  7994. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  7995. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  7996. return true;
  7997. }
  7998. return false;
  7999. }
  8000. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8001. {
  8002. SimWideDeletesPacket SimWideDeletesRequest =
  8003. (SimWideDeletesPacket)Packet;
  8004. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8005. if (handlerSimWideDeletesRequest != null)
  8006. {
  8007. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8008. return true;
  8009. }
  8010. return false;
  8011. }
  8012. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8013. {
  8014. GodlikeMessagePacket GodlikeMessage =
  8015. (GodlikeMessagePacket)Packet;
  8016. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8017. if (handlerGodlikeMessage != null)
  8018. {
  8019. handlerGodlikeMessage(this,
  8020. GodlikeMessage.MethodData.Invoice,
  8021. GodlikeMessage.MethodData.Method,
  8022. GodlikeMessage.ParamList[0].Parameter);
  8023. return true;
  8024. }
  8025. return false;
  8026. }
  8027. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8028. {
  8029. StateSavePacket SaveStateMessage =
  8030. (StateSavePacket)Packet;
  8031. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8032. if (handlerSaveStatePacket != null)
  8033. {
  8034. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8035. return true;
  8036. }
  8037. return false;
  8038. }
  8039. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8040. {
  8041. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8042. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8043. {
  8044. GodKickUser handlerGodKickUser = OnGodKickUser;
  8045. if (handlerGodKickUser != null)
  8046. {
  8047. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8048. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8049. }
  8050. }
  8051. else
  8052. {
  8053. SendAgentAlertMessage("Kick request denied", false);
  8054. }
  8055. //KickUserPacket kupack = new KickUserPacket();
  8056. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8057. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8058. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8059. //kupack.TargetBlock.TargetIP = (uint)0;
  8060. //kupack.TargetBlock.TargetPort = (ushort)0;
  8061. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8062. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8063. return true;
  8064. }
  8065. #endregion GodPackets
  8066. #region Economy/Transaction Packets
  8067. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8068. {
  8069. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8070. #region Packet Session and User Check
  8071. if (m_checkPackets)
  8072. {
  8073. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8074. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8075. return true;
  8076. }
  8077. #endregion
  8078. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8079. if (handlerMoneyBalanceRequest != null)
  8080. {
  8081. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8082. }
  8083. return true;
  8084. }
  8085. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8086. {
  8087. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8088. if (handlerEconomoyDataRequest != null)
  8089. {
  8090. handlerEconomoyDataRequest(AgentId);
  8091. }
  8092. return true;
  8093. }
  8094. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8095. {
  8096. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8097. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8098. if (handlerRequestPayPrice != null)
  8099. {
  8100. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8101. }
  8102. return true;
  8103. }
  8104. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8105. {
  8106. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8107. #region Packet Session and User Check
  8108. if (m_checkPackets)
  8109. {
  8110. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8111. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8112. return true;
  8113. }
  8114. #endregion
  8115. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8116. if (handlerObjectSaleInfo != null)
  8117. {
  8118. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8119. in objectSaleInfoPacket.ObjectData)
  8120. {
  8121. handlerObjectSaleInfo(this,
  8122. objectSaleInfoPacket.AgentData.AgentID,
  8123. objectSaleInfoPacket.AgentData.SessionID,
  8124. d.LocalID,
  8125. d.SaleType,
  8126. d.SalePrice);
  8127. }
  8128. }
  8129. return true;
  8130. }
  8131. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8132. {
  8133. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8134. #region Packet Session and User Check
  8135. if (m_checkPackets)
  8136. {
  8137. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8138. objectBuyPacket.AgentData.AgentID != AgentId)
  8139. return true;
  8140. }
  8141. #endregion
  8142. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8143. if (handlerObjectBuy != null)
  8144. {
  8145. foreach (ObjectBuyPacket.ObjectDataBlock d
  8146. in objectBuyPacket.ObjectData)
  8147. {
  8148. handlerObjectBuy(this,
  8149. objectBuyPacket.AgentData.AgentID,
  8150. objectBuyPacket.AgentData.SessionID,
  8151. objectBuyPacket.AgentData.GroupID,
  8152. objectBuyPacket.AgentData.CategoryID,
  8153. d.ObjectLocalID,
  8154. d.SaleType,
  8155. d.SalePrice);
  8156. }
  8157. }
  8158. return true;
  8159. }
  8160. #endregion Economy/Transaction Packets
  8161. #region Script Packets
  8162. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8163. {
  8164. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8165. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8166. if (handlerGetScriptRunning != null)
  8167. {
  8168. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8169. }
  8170. return true;
  8171. }
  8172. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8173. {
  8174. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8175. #region Packet Session and User Check
  8176. if (m_checkPackets)
  8177. {
  8178. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8179. setScriptRunning.AgentData.AgentID != AgentId)
  8180. return true;
  8181. }
  8182. #endregion
  8183. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8184. if (handlerSetScriptRunning != null)
  8185. {
  8186. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8187. }
  8188. return true;
  8189. }
  8190. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8191. {
  8192. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8193. #region Packet Session and User Check
  8194. if (m_checkPackets)
  8195. {
  8196. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8197. scriptResetPacket.AgentData.AgentID != AgentId)
  8198. return true;
  8199. }
  8200. #endregion
  8201. ScriptReset handlerScriptReset = OnScriptReset;
  8202. if (handlerScriptReset != null)
  8203. {
  8204. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8205. }
  8206. return true;
  8207. }
  8208. #endregion Script Packets
  8209. #region Gesture Managment
  8210. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8211. {
  8212. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8213. #region Packet Session and User Check
  8214. if (m_checkPackets)
  8215. {
  8216. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8217. activateGesturePacket.AgentData.AgentID != AgentId)
  8218. return true;
  8219. }
  8220. #endregion
  8221. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8222. if (handlerActivateGesture != null)
  8223. {
  8224. handlerActivateGesture(this,
  8225. activateGesturePacket.Data[0].AssetID,
  8226. activateGesturePacket.Data[0].ItemID);
  8227. }
  8228. else m_log.Error("Null pointer for activateGesture");
  8229. return true;
  8230. }
  8231. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8232. {
  8233. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8234. #region Packet Session and User Check
  8235. if (m_checkPackets)
  8236. {
  8237. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8238. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8239. return true;
  8240. }
  8241. #endregion
  8242. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8243. if (handlerDeactivateGesture != null)
  8244. {
  8245. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8246. }
  8247. return true;
  8248. }
  8249. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8250. {
  8251. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8252. #region Packet Session and User Check
  8253. if (m_checkPackets)
  8254. {
  8255. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8256. objectOwnerPacket.AgentData.AgentID != AgentId)
  8257. return true;
  8258. }
  8259. #endregion
  8260. List<uint> localIDs = new List<uint>();
  8261. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8262. localIDs.Add(d.ObjectLocalID);
  8263. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8264. if (handlerObjectOwner != null)
  8265. {
  8266. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8267. }
  8268. return true;
  8269. }
  8270. #endregion Gesture Managment
  8271. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8272. {
  8273. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8274. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8275. {
  8276. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8277. AgentFOV handlerAgentFOV = OnAgentFOV;
  8278. if (handlerAgentFOV != null)
  8279. {
  8280. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8281. }
  8282. }
  8283. return true;
  8284. }
  8285. #region unimplemented handlers
  8286. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8287. {
  8288. // TODO: handle this packet
  8289. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8290. return true;
  8291. }
  8292. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8293. {
  8294. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8295. #region Packet Session and User Check
  8296. if (m_checkPackets)
  8297. {
  8298. if (mirpk.AgentData.SessionID != SessionId ||
  8299. mirpk.AgentData.AgentID != AgentId)
  8300. return true;
  8301. }
  8302. #endregion
  8303. //m_log.Debug(mirpk.ToString());
  8304. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8305. if (handlerMapItemRequest != null)
  8306. {
  8307. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8308. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8309. mirpk.RequestData.RegionHandle);
  8310. }
  8311. return true;
  8312. }
  8313. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8314. {
  8315. return true;
  8316. }
  8317. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8318. {
  8319. MuteListRequestPacket muteListRequest =
  8320. (MuteListRequestPacket)Pack;
  8321. #region Packet Session and User Check
  8322. if (m_checkPackets)
  8323. {
  8324. if (muteListRequest.AgentData.SessionID != SessionId ||
  8325. muteListRequest.AgentData.AgentID != AgentId)
  8326. return true;
  8327. }
  8328. #endregion
  8329. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8330. if (handlerMuteListRequest != null)
  8331. {
  8332. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8333. }
  8334. else
  8335. {
  8336. SendUseCachedMuteList();
  8337. }
  8338. return true;
  8339. }
  8340. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8341. {
  8342. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8343. (UpdateMuteListEntryPacket)Packet;
  8344. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8345. if (handlerUpdateMuteListEntry != null)
  8346. {
  8347. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8348. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8349. UpdateMuteListEntry.MuteData.MuteType,
  8350. UpdateMuteListEntry.AgentData.AgentID);
  8351. return true;
  8352. }
  8353. return false;
  8354. }
  8355. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8356. {
  8357. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8358. (RemoveMuteListEntryPacket)Packet;
  8359. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8360. if (handlerRemoveMuteListEntry != null)
  8361. {
  8362. handlerRemoveMuteListEntry(this,
  8363. RemoveMuteListEntry.MuteData.MuteID,
  8364. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8365. RemoveMuteListEntry.AgentData.AgentID);
  8366. return true;
  8367. }
  8368. return false;
  8369. }
  8370. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8371. {
  8372. UserReportPacket UserReport =
  8373. (UserReportPacket)Packet;
  8374. NewUserReport handlerUserReport = OnUserReport;
  8375. if (handlerUserReport != null)
  8376. {
  8377. handlerUserReport(this,
  8378. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8379. UserReport.ReportData.AbuserID,
  8380. UserReport.ReportData.Category,
  8381. UserReport.ReportData.CheckFlags,
  8382. Utils.BytesToString(UserReport.ReportData.Details),
  8383. UserReport.ReportData.ObjectID,
  8384. UserReport.ReportData.Position,
  8385. UserReport.ReportData.ReportType,
  8386. UserReport.ReportData.ScreenshotID,
  8387. Utils.BytesToString(UserReport.ReportData.Summary),
  8388. UserReport.AgentData.AgentID);
  8389. return true;
  8390. }
  8391. return false;
  8392. }
  8393. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8394. {
  8395. // SendPostcardPacket SendPostcard =
  8396. // (SendPostcardPacket)packet;
  8397. SendPostcard handlerSendPostcard = OnSendPostcard;
  8398. if (handlerSendPostcard != null)
  8399. {
  8400. handlerSendPostcard(this);
  8401. return true;
  8402. }
  8403. return false;
  8404. }
  8405. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8406. {
  8407. return true;
  8408. }
  8409. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8410. {
  8411. return true;
  8412. }
  8413. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8414. {
  8415. return true;
  8416. }
  8417. #endregion unimplemented handlers
  8418. #region Dir handlers
  8419. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8420. {
  8421. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8422. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8423. #region Packet Session and User Check
  8424. if (m_checkPackets)
  8425. {
  8426. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8427. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8428. return true;
  8429. }
  8430. #endregion
  8431. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8432. if (handlerDirPlacesQuery != null)
  8433. {
  8434. handlerDirPlacesQuery(this,
  8435. dirPlacesQueryPacket.QueryData.QueryID,
  8436. Utils.BytesToString(
  8437. dirPlacesQueryPacket.QueryData.QueryText),
  8438. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8439. (int)dirPlacesQueryPacket.QueryData.Category,
  8440. Utils.BytesToString(
  8441. dirPlacesQueryPacket.QueryData.SimName),
  8442. dirPlacesQueryPacket.QueryData.QueryStart);
  8443. }
  8444. return true;
  8445. }
  8446. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8447. {
  8448. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8449. #region Packet Session and User Check
  8450. if (m_checkPackets)
  8451. {
  8452. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8453. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8454. return true;
  8455. }
  8456. #endregion
  8457. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8458. if (handlerDirFindQuery != null)
  8459. {
  8460. handlerDirFindQuery(this,
  8461. dirFindQueryPacket.QueryData.QueryID,
  8462. Utils.BytesToString(
  8463. dirFindQueryPacket.QueryData.QueryText),
  8464. dirFindQueryPacket.QueryData.QueryFlags,
  8465. dirFindQueryPacket.QueryData.QueryStart);
  8466. }
  8467. return true;
  8468. }
  8469. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8470. {
  8471. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8472. #region Packet Session and User Check
  8473. if (m_checkPackets)
  8474. {
  8475. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8476. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8477. return true;
  8478. }
  8479. #endregion
  8480. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8481. if (handlerDirLandQuery != null)
  8482. {
  8483. handlerDirLandQuery(this,
  8484. dirLandQueryPacket.QueryData.QueryID,
  8485. dirLandQueryPacket.QueryData.QueryFlags,
  8486. dirLandQueryPacket.QueryData.SearchType,
  8487. dirLandQueryPacket.QueryData.Price,
  8488. dirLandQueryPacket.QueryData.Area,
  8489. dirLandQueryPacket.QueryData.QueryStart);
  8490. }
  8491. return true;
  8492. }
  8493. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8494. {
  8495. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8496. #region Packet Session and User Check
  8497. if (m_checkPackets)
  8498. {
  8499. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8500. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8501. return true;
  8502. }
  8503. #endregion
  8504. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8505. if (handlerDirPopularQuery != null)
  8506. {
  8507. handlerDirPopularQuery(this,
  8508. dirPopularQueryPacket.QueryData.QueryID,
  8509. dirPopularQueryPacket.QueryData.QueryFlags);
  8510. }
  8511. return true;
  8512. }
  8513. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  8514. {
  8515. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  8516. #region Packet Session and User Check
  8517. if (m_checkPackets)
  8518. {
  8519. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  8520. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  8521. return true;
  8522. }
  8523. #endregion
  8524. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  8525. if (handlerDirClassifiedQuery != null)
  8526. {
  8527. handlerDirClassifiedQuery(this,
  8528. dirClassifiedQueryPacket.QueryData.QueryID,
  8529. Utils.BytesToString(
  8530. dirClassifiedQueryPacket.QueryData.QueryText),
  8531. dirClassifiedQueryPacket.QueryData.QueryFlags,
  8532. dirClassifiedQueryPacket.QueryData.Category,
  8533. dirClassifiedQueryPacket.QueryData.QueryStart);
  8534. }
  8535. return true;
  8536. }
  8537. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  8538. {
  8539. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  8540. #region Packet Session and User Check
  8541. if (m_checkPackets)
  8542. {
  8543. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  8544. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  8545. return true;
  8546. }
  8547. #endregion
  8548. if (OnEventInfoRequest != null)
  8549. {
  8550. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  8551. }
  8552. return true;
  8553. }
  8554. #endregion
  8555. #region Calling Card
  8556. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  8557. {
  8558. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  8559. #region Packet Session and User Check
  8560. if (m_checkPackets)
  8561. {
  8562. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  8563. offerCallingCardPacket.AgentData.AgentID != AgentId)
  8564. return true;
  8565. }
  8566. #endregion
  8567. if (OnOfferCallingCard != null)
  8568. {
  8569. OnOfferCallingCard(this,
  8570. offerCallingCardPacket.AgentBlock.DestID,
  8571. offerCallingCardPacket.AgentBlock.TransactionID);
  8572. }
  8573. return true;
  8574. }
  8575. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  8576. {
  8577. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  8578. #region Packet Session and User Check
  8579. if (m_checkPackets)
  8580. {
  8581. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  8582. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  8583. return true;
  8584. }
  8585. #endregion
  8586. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  8587. // contain exactly one entry
  8588. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  8589. {
  8590. OnAcceptCallingCard(this,
  8591. acceptCallingCardPacket.TransactionBlock.TransactionID,
  8592. acceptCallingCardPacket.FolderData[0].FolderID);
  8593. }
  8594. return true;
  8595. }
  8596. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  8597. {
  8598. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  8599. #region Packet Session and User Check
  8600. if (m_checkPackets)
  8601. {
  8602. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  8603. declineCallingCardPacket.AgentData.AgentID != AgentId)
  8604. return true;
  8605. }
  8606. #endregion
  8607. if (OnDeclineCallingCard != null)
  8608. {
  8609. OnDeclineCallingCard(this,
  8610. declineCallingCardPacket.TransactionBlock.TransactionID);
  8611. }
  8612. return true;
  8613. }
  8614. #endregion Calling Card
  8615. #region Groups
  8616. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  8617. {
  8618. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  8619. #region Packet Session and User Check
  8620. if (m_checkPackets)
  8621. {
  8622. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  8623. activateGroupPacket.AgentData.AgentID != AgentId)
  8624. return true;
  8625. }
  8626. #endregion
  8627. if (m_GroupsModule != null)
  8628. {
  8629. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  8630. m_GroupsModule.SendAgentGroupDataUpdate(this);
  8631. }
  8632. return true;
  8633. }
  8634. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  8635. {
  8636. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  8637. (GroupVoteHistoryRequestPacket)Packet;
  8638. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  8639. if (handlerGroupVoteHistoryRequest != null)
  8640. {
  8641. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  8642. return true;
  8643. }
  8644. return false;
  8645. }
  8646. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  8647. {
  8648. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  8649. (GroupActiveProposalsRequestPacket)Packet;
  8650. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  8651. if (handlerGroupActiveProposalsRequest != null)
  8652. {
  8653. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  8654. return true;
  8655. }
  8656. return false;
  8657. }
  8658. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  8659. {
  8660. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  8661. (GroupAccountDetailsRequestPacket)Packet;
  8662. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  8663. if (handlerGroupAccountDetailsRequest != null)
  8664. {
  8665. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  8666. return true;
  8667. }
  8668. return false;
  8669. }
  8670. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  8671. {
  8672. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  8673. (GroupAccountSummaryRequestPacket)Packet;
  8674. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  8675. if (handlerGroupAccountSummaryRequest != null)
  8676. {
  8677. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  8678. return true;
  8679. }
  8680. return false;
  8681. }
  8682. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  8683. {
  8684. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  8685. (GroupAccountTransactionsRequestPacket)Packet;
  8686. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  8687. if (handlerGroupAccountTransactionsRequest != null)
  8688. {
  8689. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  8690. return true;
  8691. }
  8692. return false;
  8693. }
  8694. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  8695. {
  8696. GroupTitlesRequestPacket groupTitlesRequest =
  8697. (GroupTitlesRequestPacket)Pack;
  8698. #region Packet Session and User Check
  8699. if (m_checkPackets)
  8700. {
  8701. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  8702. groupTitlesRequest.AgentData.AgentID != AgentId)
  8703. return true;
  8704. }
  8705. #endregion
  8706. if (m_GroupsModule != null)
  8707. {
  8708. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  8709. groupTitlesReply.AgentData =
  8710. new GroupTitlesReplyPacket.AgentDataBlock();
  8711. groupTitlesReply.AgentData.AgentID = AgentId;
  8712. groupTitlesReply.AgentData.GroupID =
  8713. groupTitlesRequest.AgentData.GroupID;
  8714. groupTitlesReply.AgentData.RequestID =
  8715. groupTitlesRequest.AgentData.RequestID;
  8716. List<GroupTitlesData> titles =
  8717. m_GroupsModule.GroupTitlesRequest(this,
  8718. groupTitlesRequest.AgentData.GroupID);
  8719. groupTitlesReply.GroupData =
  8720. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  8721. int i = 0;
  8722. foreach (GroupTitlesData d in titles)
  8723. {
  8724. groupTitlesReply.GroupData[i] =
  8725. new GroupTitlesReplyPacket.GroupDataBlock();
  8726. groupTitlesReply.GroupData[i].Title =
  8727. Util.StringToBytes256(d.Name);
  8728. groupTitlesReply.GroupData[i].RoleID =
  8729. d.UUID;
  8730. groupTitlesReply.GroupData[i].Selected =
  8731. d.Selected;
  8732. i++;
  8733. }
  8734. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  8735. }
  8736. return true;
  8737. }
  8738. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  8739. {
  8740. GroupProfileRequestPacket groupProfileRequest =
  8741. (GroupProfileRequestPacket)Pack;
  8742. #region Packet Session and User Check
  8743. if (m_checkPackets)
  8744. {
  8745. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  8746. groupProfileRequest.AgentData.AgentID != AgentId)
  8747. return true;
  8748. }
  8749. #endregion
  8750. if (m_GroupsModule != null)
  8751. {
  8752. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  8753. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  8754. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  8755. groupProfileReply.AgentData.AgentID = AgentId;
  8756. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  8757. groupProfileRequest.GroupData.GroupID);
  8758. groupProfileReply.GroupData.GroupID = d.GroupID;
  8759. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  8760. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  8761. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  8762. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  8763. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  8764. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  8765. groupProfileReply.GroupData.FounderID = d.FounderID;
  8766. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  8767. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  8768. groupProfileReply.GroupData.Money = d.Money;
  8769. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  8770. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  8771. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  8772. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  8773. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  8774. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  8775. }
  8776. return true;
  8777. }
  8778. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  8779. {
  8780. GroupMembersRequestPacket groupMembersRequestPacket =
  8781. (GroupMembersRequestPacket)Pack;
  8782. #region Packet Session and User Check
  8783. if (m_checkPackets)
  8784. {
  8785. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  8786. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  8787. return true;
  8788. }
  8789. #endregion
  8790. if (m_GroupsModule != null)
  8791. {
  8792. List<GroupMembersData> members =
  8793. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  8794. int memberCount = members.Count;
  8795. while (true)
  8796. {
  8797. int blockCount = members.Count;
  8798. if (blockCount > 40)
  8799. blockCount = 40;
  8800. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  8801. groupMembersReply.AgentData =
  8802. new GroupMembersReplyPacket.AgentDataBlock();
  8803. groupMembersReply.GroupData =
  8804. new GroupMembersReplyPacket.GroupDataBlock();
  8805. groupMembersReply.MemberData =
  8806. new GroupMembersReplyPacket.MemberDataBlock[
  8807. blockCount];
  8808. groupMembersReply.AgentData.AgentID = AgentId;
  8809. groupMembersReply.GroupData.GroupID =
  8810. groupMembersRequestPacket.GroupData.GroupID;
  8811. groupMembersReply.GroupData.RequestID =
  8812. groupMembersRequestPacket.GroupData.RequestID;
  8813. groupMembersReply.GroupData.MemberCount = memberCount;
  8814. for (int i = 0; i < blockCount; i++)
  8815. {
  8816. GroupMembersData m = members[0];
  8817. members.RemoveAt(0);
  8818. groupMembersReply.MemberData[i] =
  8819. new GroupMembersReplyPacket.MemberDataBlock();
  8820. groupMembersReply.MemberData[i].AgentID =
  8821. m.AgentID;
  8822. groupMembersReply.MemberData[i].Contribution =
  8823. m.Contribution;
  8824. groupMembersReply.MemberData[i].OnlineStatus =
  8825. Util.StringToBytes256(m.OnlineStatus);
  8826. groupMembersReply.MemberData[i].AgentPowers =
  8827. m.AgentPowers;
  8828. groupMembersReply.MemberData[i].Title =
  8829. Util.StringToBytes256(m.Title);
  8830. groupMembersReply.MemberData[i].IsOwner =
  8831. m.IsOwner;
  8832. }
  8833. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  8834. if (members.Count == 0)
  8835. return true;
  8836. }
  8837. }
  8838. return true;
  8839. }
  8840. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  8841. {
  8842. GroupRoleDataRequestPacket groupRolesRequest =
  8843. (GroupRoleDataRequestPacket)Pack;
  8844. #region Packet Session and User Check
  8845. if (m_checkPackets)
  8846. {
  8847. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  8848. groupRolesRequest.AgentData.AgentID != AgentId)
  8849. return true;
  8850. }
  8851. #endregion
  8852. if (m_GroupsModule != null)
  8853. {
  8854. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  8855. groupRolesReply.AgentData =
  8856. new GroupRoleDataReplyPacket.AgentDataBlock();
  8857. groupRolesReply.AgentData.AgentID = AgentId;
  8858. groupRolesReply.GroupData =
  8859. new GroupRoleDataReplyPacket.GroupDataBlock();
  8860. groupRolesReply.GroupData.GroupID =
  8861. groupRolesRequest.GroupData.GroupID;
  8862. groupRolesReply.GroupData.RequestID =
  8863. groupRolesRequest.GroupData.RequestID;
  8864. List<GroupRolesData> titles =
  8865. m_GroupsModule.GroupRoleDataRequest(this,
  8866. groupRolesRequest.GroupData.GroupID);
  8867. groupRolesReply.GroupData.RoleCount =
  8868. titles.Count;
  8869. groupRolesReply.RoleData =
  8870. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  8871. int i = 0;
  8872. foreach (GroupRolesData d in titles)
  8873. {
  8874. groupRolesReply.RoleData[i] =
  8875. new GroupRoleDataReplyPacket.RoleDataBlock();
  8876. groupRolesReply.RoleData[i].RoleID =
  8877. d.RoleID;
  8878. groupRolesReply.RoleData[i].Name =
  8879. Util.StringToBytes256(d.Name);
  8880. groupRolesReply.RoleData[i].Title =
  8881. Util.StringToBytes256(d.Title);
  8882. groupRolesReply.RoleData[i].Description =
  8883. Util.StringToBytes1024(d.Description);
  8884. groupRolesReply.RoleData[i].Powers =
  8885. d.Powers;
  8886. groupRolesReply.RoleData[i].Members =
  8887. (uint)d.Members;
  8888. i++;
  8889. }
  8890. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  8891. }
  8892. return true;
  8893. }
  8894. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  8895. {
  8896. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  8897. (GroupRoleMembersRequestPacket)Pack;
  8898. #region Packet Session and User Check
  8899. if (m_checkPackets)
  8900. {
  8901. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  8902. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  8903. return true;
  8904. }
  8905. #endregion
  8906. if (m_GroupsModule != null)
  8907. {
  8908. List<GroupRoleMembersData> mappings =
  8909. m_GroupsModule.GroupRoleMembersRequest(this,
  8910. groupRoleMembersRequest.GroupData.GroupID);
  8911. int mappingsCount = mappings.Count;
  8912. while (mappings.Count > 0)
  8913. {
  8914. int pairs = mappings.Count;
  8915. if (pairs > 32)
  8916. pairs = 32;
  8917. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  8918. groupRoleMembersReply.AgentData =
  8919. new GroupRoleMembersReplyPacket.AgentDataBlock();
  8920. groupRoleMembersReply.AgentData.AgentID =
  8921. AgentId;
  8922. groupRoleMembersReply.AgentData.GroupID =
  8923. groupRoleMembersRequest.GroupData.GroupID;
  8924. groupRoleMembersReply.AgentData.RequestID =
  8925. groupRoleMembersRequest.GroupData.RequestID;
  8926. groupRoleMembersReply.AgentData.TotalPairs =
  8927. (uint)mappingsCount;
  8928. groupRoleMembersReply.MemberData =
  8929. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  8930. for (int i = 0; i < pairs; i++)
  8931. {
  8932. GroupRoleMembersData d = mappings[0];
  8933. mappings.RemoveAt(0);
  8934. groupRoleMembersReply.MemberData[i] =
  8935. new GroupRoleMembersReplyPacket.MemberDataBlock();
  8936. groupRoleMembersReply.MemberData[i].RoleID =
  8937. d.RoleID;
  8938. groupRoleMembersReply.MemberData[i].MemberID =
  8939. d.MemberID;
  8940. }
  8941. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  8942. }
  8943. }
  8944. return true;
  8945. }
  8946. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  8947. {
  8948. CreateGroupRequestPacket createGroupRequest =
  8949. (CreateGroupRequestPacket)Pack;
  8950. #region Packet Session and User Check
  8951. if (m_checkPackets)
  8952. {
  8953. if (createGroupRequest.AgentData.SessionID != SessionId ||
  8954. createGroupRequest.AgentData.AgentID != AgentId)
  8955. return true;
  8956. }
  8957. #endregion
  8958. if (m_GroupsModule != null)
  8959. {
  8960. m_GroupsModule.CreateGroup(this,
  8961. Utils.BytesToString(createGroupRequest.GroupData.Name),
  8962. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  8963. createGroupRequest.GroupData.ShowInList,
  8964. createGroupRequest.GroupData.InsigniaID,
  8965. createGroupRequest.GroupData.MembershipFee,
  8966. createGroupRequest.GroupData.OpenEnrollment,
  8967. createGroupRequest.GroupData.AllowPublish,
  8968. createGroupRequest.GroupData.MaturePublish);
  8969. }
  8970. return true;
  8971. }
  8972. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  8973. {
  8974. UpdateGroupInfoPacket updateGroupInfo =
  8975. (UpdateGroupInfoPacket)Pack;
  8976. #region Packet Session and User Check
  8977. if (m_checkPackets)
  8978. {
  8979. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  8980. updateGroupInfo.AgentData.AgentID != AgentId)
  8981. return true;
  8982. }
  8983. #endregion
  8984. if (m_GroupsModule != null)
  8985. {
  8986. m_GroupsModule.UpdateGroupInfo(this,
  8987. updateGroupInfo.GroupData.GroupID,
  8988. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  8989. updateGroupInfo.GroupData.ShowInList,
  8990. updateGroupInfo.GroupData.InsigniaID,
  8991. updateGroupInfo.GroupData.MembershipFee,
  8992. updateGroupInfo.GroupData.OpenEnrollment,
  8993. updateGroupInfo.GroupData.AllowPublish,
  8994. updateGroupInfo.GroupData.MaturePublish);
  8995. }
  8996. return true;
  8997. }
  8998. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  8999. {
  9000. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9001. (SetGroupAcceptNoticesPacket)Pack;
  9002. #region Packet Session and User Check
  9003. if (m_checkPackets)
  9004. {
  9005. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9006. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9007. return true;
  9008. }
  9009. #endregion
  9010. if (m_GroupsModule != null)
  9011. {
  9012. m_GroupsModule.SetGroupAcceptNotices(this,
  9013. setGroupAcceptNotices.Data.GroupID,
  9014. setGroupAcceptNotices.Data.AcceptNotices,
  9015. setGroupAcceptNotices.NewData.ListInProfile);
  9016. }
  9017. return true;
  9018. }
  9019. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9020. {
  9021. GroupTitleUpdatePacket groupTitleUpdate =
  9022. (GroupTitleUpdatePacket)Pack;
  9023. #region Packet Session and User Check
  9024. if (m_checkPackets)
  9025. {
  9026. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9027. groupTitleUpdate.AgentData.AgentID != AgentId)
  9028. return true;
  9029. }
  9030. #endregion
  9031. if (m_GroupsModule != null)
  9032. {
  9033. m_GroupsModule.GroupTitleUpdate(this,
  9034. groupTitleUpdate.AgentData.GroupID,
  9035. groupTitleUpdate.AgentData.TitleRoleID);
  9036. }
  9037. return true;
  9038. }
  9039. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9040. {
  9041. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9042. if (m_GroupsModule != null)
  9043. {
  9044. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9045. if (handlerParcelDeedToGroup != null)
  9046. {
  9047. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9048. }
  9049. }
  9050. return true;
  9051. }
  9052. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9053. {
  9054. GroupNoticesListRequestPacket groupNoticesListRequest =
  9055. (GroupNoticesListRequestPacket)Pack;
  9056. #region Packet Session and User Check
  9057. if (m_checkPackets)
  9058. {
  9059. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9060. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9061. return true;
  9062. }
  9063. #endregion
  9064. if (m_GroupsModule != null)
  9065. {
  9066. GroupNoticeData[] gn =
  9067. m_GroupsModule.GroupNoticesListRequest(this,
  9068. groupNoticesListRequest.Data.GroupID);
  9069. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9070. groupNoticesListReply.AgentData =
  9071. new GroupNoticesListReplyPacket.AgentDataBlock();
  9072. groupNoticesListReply.AgentData.AgentID = AgentId;
  9073. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9074. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9075. int i = 0;
  9076. foreach (GroupNoticeData g in gn)
  9077. {
  9078. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9079. groupNoticesListReply.Data[i].NoticeID =
  9080. g.NoticeID;
  9081. groupNoticesListReply.Data[i].Timestamp =
  9082. g.Timestamp;
  9083. groupNoticesListReply.Data[i].FromName =
  9084. Util.StringToBytes256(g.FromName);
  9085. groupNoticesListReply.Data[i].Subject =
  9086. Util.StringToBytes256(g.Subject);
  9087. groupNoticesListReply.Data[i].HasAttachment =
  9088. g.HasAttachment;
  9089. groupNoticesListReply.Data[i].AssetType =
  9090. g.AssetType;
  9091. i++;
  9092. }
  9093. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9094. }
  9095. return true;
  9096. }
  9097. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9098. {
  9099. GroupNoticeRequestPacket groupNoticeRequest =
  9100. (GroupNoticeRequestPacket)Pack;
  9101. #region Packet Session and User Check
  9102. if (m_checkPackets)
  9103. {
  9104. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9105. groupNoticeRequest.AgentData.AgentID != AgentId)
  9106. return true;
  9107. }
  9108. #endregion
  9109. if (m_GroupsModule != null)
  9110. {
  9111. m_GroupsModule.GroupNoticeRequest(this,
  9112. groupNoticeRequest.Data.GroupNoticeID);
  9113. }
  9114. return true;
  9115. }
  9116. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9117. {
  9118. GroupRoleUpdatePacket groupRoleUpdate =
  9119. (GroupRoleUpdatePacket)Pack;
  9120. #region Packet Session and User Check
  9121. if (m_checkPackets)
  9122. {
  9123. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9124. groupRoleUpdate.AgentData.AgentID != AgentId)
  9125. return true;
  9126. }
  9127. #endregion
  9128. if (m_GroupsModule != null)
  9129. {
  9130. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9131. groupRoleUpdate.RoleData)
  9132. {
  9133. m_GroupsModule.GroupRoleUpdate(this,
  9134. groupRoleUpdate.AgentData.GroupID,
  9135. d.RoleID,
  9136. Utils.BytesToString(d.Name),
  9137. Utils.BytesToString(d.Description),
  9138. Utils.BytesToString(d.Title),
  9139. d.Powers,
  9140. d.UpdateType);
  9141. }
  9142. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9143. }
  9144. return true;
  9145. }
  9146. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9147. {
  9148. GroupRoleChangesPacket groupRoleChanges =
  9149. (GroupRoleChangesPacket)Pack;
  9150. #region Packet Session and User Check
  9151. if (m_checkPackets)
  9152. {
  9153. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9154. groupRoleChanges.AgentData.AgentID != AgentId)
  9155. return true;
  9156. }
  9157. #endregion
  9158. if (m_GroupsModule != null)
  9159. {
  9160. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9161. groupRoleChanges.RoleChange)
  9162. {
  9163. m_GroupsModule.GroupRoleChanges(this,
  9164. groupRoleChanges.AgentData.GroupID,
  9165. d.RoleID,
  9166. d.MemberID,
  9167. d.Change);
  9168. }
  9169. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9170. }
  9171. return true;
  9172. }
  9173. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9174. {
  9175. JoinGroupRequestPacket joinGroupRequest =
  9176. (JoinGroupRequestPacket)Pack;
  9177. #region Packet Session and User Check
  9178. if (m_checkPackets)
  9179. {
  9180. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9181. joinGroupRequest.AgentData.AgentID != AgentId)
  9182. return true;
  9183. }
  9184. #endregion
  9185. if (m_GroupsModule != null)
  9186. {
  9187. m_GroupsModule.JoinGroupRequest(this,
  9188. joinGroupRequest.GroupData.GroupID);
  9189. }
  9190. return true;
  9191. }
  9192. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9193. {
  9194. LeaveGroupRequestPacket leaveGroupRequest =
  9195. (LeaveGroupRequestPacket)Pack;
  9196. #region Packet Session and User Check
  9197. if (m_checkPackets)
  9198. {
  9199. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9200. leaveGroupRequest.AgentData.AgentID != AgentId)
  9201. return true;
  9202. }
  9203. #endregion
  9204. if (m_GroupsModule != null)
  9205. {
  9206. m_GroupsModule.LeaveGroupRequest(this,
  9207. leaveGroupRequest.GroupData.GroupID);
  9208. }
  9209. return true;
  9210. }
  9211. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9212. {
  9213. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9214. (EjectGroupMemberRequestPacket)Pack;
  9215. #region Packet Session and User Check
  9216. if (m_checkPackets)
  9217. {
  9218. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9219. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9220. return true;
  9221. }
  9222. #endregion
  9223. if (m_GroupsModule != null)
  9224. {
  9225. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9226. in ejectGroupMemberRequest.EjectData)
  9227. {
  9228. m_GroupsModule.EjectGroupMemberRequest(this,
  9229. ejectGroupMemberRequest.GroupData.GroupID,
  9230. e.EjecteeID);
  9231. }
  9232. }
  9233. return true;
  9234. }
  9235. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9236. {
  9237. InviteGroupRequestPacket inviteGroupRequest =
  9238. (InviteGroupRequestPacket)Pack;
  9239. #region Packet Session and User Check
  9240. if (m_checkPackets)
  9241. {
  9242. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9243. inviteGroupRequest.AgentData.AgentID != AgentId)
  9244. return true;
  9245. }
  9246. #endregion
  9247. if (m_GroupsModule != null)
  9248. {
  9249. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9250. inviteGroupRequest.InviteData)
  9251. {
  9252. m_GroupsModule.InviteGroupRequest(this,
  9253. inviteGroupRequest.GroupData.GroupID,
  9254. b.InviteeID,
  9255. b.RoleID);
  9256. }
  9257. }
  9258. return true;
  9259. }
  9260. #endregion Groups
  9261. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9262. {
  9263. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9264. #region Packet Session and User Check
  9265. if (m_checkPackets)
  9266. {
  9267. if (startLureRequest.AgentData.SessionID != SessionId ||
  9268. startLureRequest.AgentData.AgentID != AgentId)
  9269. return true;
  9270. }
  9271. #endregion
  9272. StartLure handlerStartLure = OnStartLure;
  9273. if (handlerStartLure != null)
  9274. handlerStartLure(startLureRequest.Info.LureType,
  9275. Utils.BytesToString(
  9276. startLureRequest.Info.Message),
  9277. startLureRequest.TargetData[0].TargetID,
  9278. this);
  9279. return true;
  9280. }
  9281. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9282. {
  9283. TeleportLureRequestPacket teleportLureRequest =
  9284. (TeleportLureRequestPacket)Pack;
  9285. #region Packet Session and User Check
  9286. if (m_checkPackets)
  9287. {
  9288. if (teleportLureRequest.Info.SessionID != SessionId ||
  9289. teleportLureRequest.Info.AgentID != AgentId)
  9290. return true;
  9291. }
  9292. #endregion
  9293. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9294. if (handlerTeleportLureRequest != null)
  9295. handlerTeleportLureRequest(
  9296. teleportLureRequest.Info.LureID,
  9297. teleportLureRequest.Info.TeleportFlags,
  9298. this);
  9299. return true;
  9300. }
  9301. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9302. {
  9303. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9304. (ClassifiedInfoRequestPacket)Pack;
  9305. #region Packet Session and User Check
  9306. if (m_checkPackets)
  9307. {
  9308. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9309. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9310. return true;
  9311. }
  9312. #endregion
  9313. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9314. if (handlerClassifiedInfoRequest != null)
  9315. handlerClassifiedInfoRequest(
  9316. classifiedInfoRequest.Data.ClassifiedID,
  9317. this);
  9318. return true;
  9319. }
  9320. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9321. {
  9322. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9323. (ClassifiedInfoUpdatePacket)Pack;
  9324. #region Packet Session and User Check
  9325. if (m_checkPackets)
  9326. {
  9327. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9328. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9329. return true;
  9330. }
  9331. #endregion
  9332. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9333. if (handlerClassifiedInfoUpdate != null)
  9334. handlerClassifiedInfoUpdate(
  9335. classifiedInfoUpdate.Data.ClassifiedID,
  9336. classifiedInfoUpdate.Data.Category,
  9337. Utils.BytesToString(
  9338. classifiedInfoUpdate.Data.Name),
  9339. Utils.BytesToString(
  9340. classifiedInfoUpdate.Data.Desc),
  9341. classifiedInfoUpdate.Data.ParcelID,
  9342. classifiedInfoUpdate.Data.ParentEstate,
  9343. classifiedInfoUpdate.Data.SnapshotID,
  9344. new Vector3(
  9345. classifiedInfoUpdate.Data.PosGlobal),
  9346. classifiedInfoUpdate.Data.ClassifiedFlags,
  9347. classifiedInfoUpdate.Data.PriceForListing,
  9348. this);
  9349. return true;
  9350. }
  9351. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9352. {
  9353. ClassifiedDeletePacket classifiedDelete =
  9354. (ClassifiedDeletePacket)Pack;
  9355. #region Packet Session and User Check
  9356. if (m_checkPackets)
  9357. {
  9358. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9359. classifiedDelete.AgentData.AgentID != AgentId)
  9360. return true;
  9361. }
  9362. #endregion
  9363. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9364. if (handlerClassifiedDelete != null)
  9365. handlerClassifiedDelete(
  9366. classifiedDelete.Data.ClassifiedID,
  9367. this);
  9368. return true;
  9369. }
  9370. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9371. {
  9372. ClassifiedGodDeletePacket classifiedGodDelete =
  9373. (ClassifiedGodDeletePacket)Pack;
  9374. #region Packet Session and User Check
  9375. if (m_checkPackets)
  9376. {
  9377. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9378. classifiedGodDelete.AgentData.AgentID != AgentId)
  9379. return true;
  9380. }
  9381. #endregion
  9382. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9383. if (handlerClassifiedGodDelete != null)
  9384. handlerClassifiedGodDelete(
  9385. classifiedGodDelete.Data.ClassifiedID,
  9386. this);
  9387. return true;
  9388. }
  9389. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9390. {
  9391. EventGodDeletePacket eventGodDelete =
  9392. (EventGodDeletePacket)Pack;
  9393. #region Packet Session and User Check
  9394. if (m_checkPackets)
  9395. {
  9396. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9397. eventGodDelete.AgentData.AgentID != AgentId)
  9398. return true;
  9399. }
  9400. #endregion
  9401. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9402. if (handlerEventGodDelete != null)
  9403. handlerEventGodDelete(
  9404. eventGodDelete.EventData.EventID,
  9405. eventGodDelete.QueryData.QueryID,
  9406. Utils.BytesToString(
  9407. eventGodDelete.QueryData.QueryText),
  9408. eventGodDelete.QueryData.QueryFlags,
  9409. eventGodDelete.QueryData.QueryStart,
  9410. this);
  9411. return true;
  9412. }
  9413. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9414. {
  9415. EventNotificationAddRequestPacket eventNotificationAdd =
  9416. (EventNotificationAddRequestPacket)Pack;
  9417. #region Packet Session and User Check
  9418. if (m_checkPackets)
  9419. {
  9420. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9421. eventNotificationAdd.AgentData.AgentID != AgentId)
  9422. return true;
  9423. }
  9424. #endregion
  9425. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9426. if (handlerEventNotificationAddRequest != null)
  9427. handlerEventNotificationAddRequest(
  9428. eventNotificationAdd.EventData.EventID, this);
  9429. return true;
  9430. }
  9431. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9432. {
  9433. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9434. (EventNotificationRemoveRequestPacket)Pack;
  9435. #region Packet Session and User Check
  9436. if (m_checkPackets)
  9437. {
  9438. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9439. eventNotificationRemove.AgentData.AgentID != AgentId)
  9440. return true;
  9441. }
  9442. #endregion
  9443. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9444. if (handlerEventNotificationRemoveRequest != null)
  9445. handlerEventNotificationRemoveRequest(
  9446. eventNotificationRemove.EventData.EventID, this);
  9447. return true;
  9448. }
  9449. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9450. {
  9451. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9452. #region Packet Session and User Check
  9453. if (m_checkPackets)
  9454. {
  9455. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9456. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9457. return true;
  9458. }
  9459. #endregion
  9460. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9461. if (handlerRetrieveInstantMessages != null)
  9462. handlerRetrieveInstantMessages(this);
  9463. return true;
  9464. }
  9465. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9466. {
  9467. PickDeletePacket pickDelete =
  9468. (PickDeletePacket)Pack;
  9469. #region Packet Session and User Check
  9470. if (m_checkPackets)
  9471. {
  9472. if (pickDelete.AgentData.SessionID != SessionId ||
  9473. pickDelete.AgentData.AgentID != AgentId)
  9474. return true;
  9475. }
  9476. #endregion
  9477. PickDelete handlerPickDelete = OnPickDelete;
  9478. if (handlerPickDelete != null)
  9479. handlerPickDelete(this, pickDelete.Data.PickID);
  9480. return true;
  9481. }
  9482. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9483. {
  9484. PickGodDeletePacket pickGodDelete =
  9485. (PickGodDeletePacket)Pack;
  9486. #region Packet Session and User Check
  9487. if (m_checkPackets)
  9488. {
  9489. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9490. pickGodDelete.AgentData.AgentID != AgentId)
  9491. return true;
  9492. }
  9493. #endregion
  9494. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9495. if (handlerPickGodDelete != null)
  9496. handlerPickGodDelete(this,
  9497. pickGodDelete.AgentData.AgentID,
  9498. pickGodDelete.Data.PickID,
  9499. pickGodDelete.Data.QueryID);
  9500. return true;
  9501. }
  9502. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9503. {
  9504. PickInfoUpdatePacket pickInfoUpdate =
  9505. (PickInfoUpdatePacket)Pack;
  9506. #region Packet Session and User Check
  9507. if (m_checkPackets)
  9508. {
  9509. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9510. pickInfoUpdate.AgentData.AgentID != AgentId)
  9511. return true;
  9512. }
  9513. #endregion
  9514. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  9515. if (handlerPickInfoUpdate != null)
  9516. handlerPickInfoUpdate(this,
  9517. pickInfoUpdate.Data.PickID,
  9518. pickInfoUpdate.Data.CreatorID,
  9519. pickInfoUpdate.Data.TopPick,
  9520. Utils.BytesToString(pickInfoUpdate.Data.Name),
  9521. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  9522. pickInfoUpdate.Data.SnapshotID,
  9523. pickInfoUpdate.Data.SortOrder,
  9524. pickInfoUpdate.Data.Enabled);
  9525. return true;
  9526. }
  9527. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  9528. {
  9529. AvatarNotesUpdatePacket avatarNotesUpdate =
  9530. (AvatarNotesUpdatePacket)Pack;
  9531. #region Packet Session and User Check
  9532. if (m_checkPackets)
  9533. {
  9534. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  9535. avatarNotesUpdate.AgentData.AgentID != AgentId)
  9536. return true;
  9537. }
  9538. #endregion
  9539. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  9540. if (handlerAvatarNotesUpdate != null)
  9541. handlerAvatarNotesUpdate(this,
  9542. avatarNotesUpdate.Data.TargetID,
  9543. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  9544. return true;
  9545. }
  9546. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  9547. {
  9548. AvatarInterestsUpdatePacket avatarInterestUpdate =
  9549. (AvatarInterestsUpdatePacket)Pack;
  9550. #region Packet Session and User Check
  9551. if (m_checkPackets)
  9552. {
  9553. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  9554. avatarInterestUpdate.AgentData.AgentID != AgentId)
  9555. return true;
  9556. }
  9557. #endregion
  9558. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  9559. if (handlerAvatarInterestUpdate != null)
  9560. handlerAvatarInterestUpdate(this,
  9561. avatarInterestUpdate.PropertiesData.WantToMask,
  9562. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  9563. avatarInterestUpdate.PropertiesData.SkillsMask,
  9564. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  9565. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  9566. return true;
  9567. }
  9568. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  9569. {
  9570. GrantUserRightsPacket GrantUserRights =
  9571. (GrantUserRightsPacket)Pack;
  9572. #region Packet Session and User Check
  9573. if (m_checkPackets)
  9574. {
  9575. if (GrantUserRights.AgentData.SessionID != SessionId ||
  9576. GrantUserRights.AgentData.AgentID != AgentId)
  9577. return true;
  9578. }
  9579. #endregion
  9580. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  9581. if (GrantUserRightsHandler != null)
  9582. GrantUserRightsHandler(this,
  9583. GrantUserRights.AgentData.AgentID,
  9584. GrantUserRights.Rights[0].AgentRelated,
  9585. GrantUserRights.Rights[0].RelatedRights);
  9586. return true;
  9587. }
  9588. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  9589. {
  9590. PlacesQueryPacket placesQueryPacket =
  9591. (PlacesQueryPacket)Pack;
  9592. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  9593. if (handlerPlacesQuery != null)
  9594. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  9595. placesQueryPacket.TransactionData.TransactionID,
  9596. Utils.BytesToString(
  9597. placesQueryPacket.QueryData.QueryText),
  9598. placesQueryPacket.QueryData.QueryFlags,
  9599. (byte)placesQueryPacket.QueryData.Category,
  9600. Utils.BytesToString(
  9601. placesQueryPacket.QueryData.SimName),
  9602. this);
  9603. return true;
  9604. }
  9605. #endregion Packet Handlers
  9606. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  9607. {
  9608. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  9609. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  9610. // TODO: don't create new blocks if recycling an old packet
  9611. scriptQuestion.Data.TaskID = taskID;
  9612. scriptQuestion.Data.ItemID = itemID;
  9613. scriptQuestion.Data.Questions = question;
  9614. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  9615. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  9616. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  9617. }
  9618. private void InitDefaultAnimations()
  9619. {
  9620. using (XmlTextReader reader = new XmlTextReader("data/avataranimations.xml"))
  9621. {
  9622. XmlDocument doc = new XmlDocument();
  9623. doc.Load(reader);
  9624. if (doc.DocumentElement != null)
  9625. foreach (XmlNode nod in doc.DocumentElement.ChildNodes)
  9626. {
  9627. if (nod.Attributes["name"] != null)
  9628. {
  9629. string name = nod.Attributes["name"].Value.ToLower();
  9630. string id = nod.InnerText;
  9631. m_defaultAnimations.Add(name, (UUID)id);
  9632. }
  9633. }
  9634. }
  9635. }
  9636. public UUID GetDefaultAnimation(string name)
  9637. {
  9638. if (m_defaultAnimations.ContainsKey(name))
  9639. return m_defaultAnimations[name];
  9640. return UUID.Zero;
  9641. }
  9642. /// <summary>
  9643. /// Handler called when we receive a logout packet.
  9644. /// </summary>
  9645. /// <param name="client"></param>
  9646. /// <param name="packet"></param>
  9647. /// <returns></returns>
  9648. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  9649. {
  9650. if (packet.Type == PacketType.LogoutRequest)
  9651. {
  9652. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  9653. }
  9654. return Logout(client);
  9655. }
  9656. /// <summary>
  9657. ///
  9658. /// </summary>
  9659. /// <param name="client"></param>
  9660. /// <returns></returns>
  9661. protected virtual bool Logout(IClientAPI client)
  9662. {
  9663. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  9664. Action<IClientAPI> handlerLogout = OnLogout;
  9665. if (handlerLogout != null)
  9666. {
  9667. handlerLogout(client);
  9668. }
  9669. return true;
  9670. }
  9671. /// <summary>
  9672. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  9673. /// its appearance texture cached.
  9674. ///
  9675. /// At the moment, we always reply that there is no cached texture.
  9676. /// </summary>
  9677. /// <param name="simclient"></param>
  9678. /// <param name="packet"></param>
  9679. /// <returns></returns>
  9680. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  9681. {
  9682. //m_log.Debug("texture cached: " + packet.ToString());
  9683. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  9684. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  9685. if (cachedtex.AgentData.SessionID != SessionId) return false;
  9686. // TODO: don't create new blocks if recycling an old packet
  9687. cachedresp.AgentData.AgentID = AgentId;
  9688. cachedresp.AgentData.SessionID = m_sessionId;
  9689. cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
  9690. m_cachedTextureSerial++;
  9691. cachedresp.WearableData =
  9692. new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
  9693. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  9694. {
  9695. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  9696. cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
  9697. cachedresp.WearableData[i].TextureID = UUID.Zero;
  9698. cachedresp.WearableData[i].HostName = new byte[0];
  9699. }
  9700. cachedresp.Header.Zerocoded = true;
  9701. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  9702. return true;
  9703. }
  9704. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  9705. {
  9706. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  9707. if (multipleupdate.AgentData.SessionID != SessionId)
  9708. return false;
  9709. // m_log.DebugFormat(
  9710. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  9711. Scene tScene = (Scene)m_scene;
  9712. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  9713. {
  9714. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  9715. // Can't act on Null Data
  9716. if (block.Data != null)
  9717. {
  9718. uint localId = block.ObjectLocalID;
  9719. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  9720. if (part == null)
  9721. {
  9722. // It's a ghost! tell the client to delete it from view.
  9723. simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
  9724. localId);
  9725. }
  9726. else
  9727. {
  9728. // m_log.DebugFormat(
  9729. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  9730. // i, block.Type, part.Name, part.LocalId);
  9731. // // Do this once since fetch parts creates a new array.
  9732. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  9733. // for (int j = 0; j < parts.Length; j++)
  9734. // {
  9735. // part.StoreUndoState();
  9736. // parts[j].IgnoreUndoUpdate = true;
  9737. // }
  9738. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  9739. switch (block.Type)
  9740. {
  9741. case 1:
  9742. Vector3 pos1 = new Vector3(block.Data, 0);
  9743. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9744. if (handlerUpdatePrimSinglePosition != null)
  9745. {
  9746. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9747. handlerUpdatePrimSinglePosition(localId, pos1, this);
  9748. }
  9749. break;
  9750. case 2:
  9751. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  9752. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  9753. if (handlerUpdatePrimSingleRotation != null)
  9754. {
  9755. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  9756. handlerUpdatePrimSingleRotation(localId, rot1, this);
  9757. }
  9758. break;
  9759. case 3:
  9760. Vector3 rotPos = new Vector3(block.Data, 0);
  9761. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  9762. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  9763. if (handlerUpdatePrimSingleRotationPosition != null)
  9764. {
  9765. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  9766. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  9767. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  9768. }
  9769. break;
  9770. case 4:
  9771. case 20:
  9772. Vector3 scale4 = new Vector3(block.Data, 0);
  9773. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  9774. if (handlerUpdatePrimScale != null)
  9775. {
  9776. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  9777. handlerUpdatePrimScale(localId, scale4, this);
  9778. }
  9779. break;
  9780. case 5:
  9781. Vector3 scale1 = new Vector3(block.Data, 12);
  9782. Vector3 pos11 = new Vector3(block.Data, 0);
  9783. handlerUpdatePrimScale = OnUpdatePrimScale;
  9784. if (handlerUpdatePrimScale != null)
  9785. {
  9786. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9787. handlerUpdatePrimScale(localId, scale1, this);
  9788. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9789. if (handlerUpdatePrimSinglePosition != null)
  9790. {
  9791. handlerUpdatePrimSinglePosition(localId, pos11, this);
  9792. }
  9793. }
  9794. break;
  9795. case 9:
  9796. Vector3 pos2 = new Vector3(block.Data, 0);
  9797. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  9798. if (handlerUpdateVector != null)
  9799. {
  9800. handlerUpdateVector(localId, pos2, this);
  9801. }
  9802. break;
  9803. case 10:
  9804. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  9805. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  9806. if (handlerUpdatePrimRotation != null)
  9807. {
  9808. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  9809. handlerUpdatePrimRotation(localId, rot3, this);
  9810. }
  9811. break;
  9812. case 11:
  9813. Vector3 pos3 = new Vector3(block.Data, 0);
  9814. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  9815. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  9816. if (handlerUpdatePrimGroupRotation != null)
  9817. {
  9818. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9819. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  9820. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  9821. }
  9822. break;
  9823. case 12:
  9824. case 28:
  9825. Vector3 scale7 = new Vector3(block.Data, 0);
  9826. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  9827. if (handlerUpdatePrimGroupScale != null)
  9828. {
  9829. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  9830. handlerUpdatePrimGroupScale(localId, scale7, this);
  9831. }
  9832. break;
  9833. case 13:
  9834. Vector3 scale2 = new Vector3(block.Data, 12);
  9835. Vector3 pos4 = new Vector3(block.Data, 0);
  9836. handlerUpdatePrimScale = OnUpdatePrimScale;
  9837. if (handlerUpdatePrimScale != null)
  9838. {
  9839. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9840. handlerUpdatePrimScale(localId, scale2, this);
  9841. // Change the position based on scale (for bug number 246)
  9842. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9843. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  9844. if (handlerUpdatePrimSinglePosition != null)
  9845. {
  9846. handlerUpdatePrimSinglePosition(localId, pos4, this);
  9847. }
  9848. }
  9849. break;
  9850. case 29:
  9851. Vector3 scale5 = new Vector3(block.Data, 12);
  9852. Vector3 pos5 = new Vector3(block.Data, 0);
  9853. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  9854. if (handlerUpdatePrimGroupScale != null)
  9855. {
  9856. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9857. part.StoreUndoState(true);
  9858. part.IgnoreUndoUpdate = true;
  9859. handlerUpdatePrimGroupScale(localId, scale5, this);
  9860. handlerUpdateVector = OnUpdatePrimGroupPosition;
  9861. if (handlerUpdateVector != null)
  9862. {
  9863. handlerUpdateVector(localId, pos5, this);
  9864. }
  9865. part.IgnoreUndoUpdate = false;
  9866. }
  9867. break;
  9868. case 21:
  9869. Vector3 scale6 = new Vector3(block.Data, 12);
  9870. Vector3 pos6 = new Vector3(block.Data, 0);
  9871. handlerUpdatePrimScale = OnUpdatePrimScale;
  9872. if (handlerUpdatePrimScale != null)
  9873. {
  9874. part.StoreUndoState(false);
  9875. part.IgnoreUndoUpdate = true;
  9876. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  9877. handlerUpdatePrimScale(localId, scale6, this);
  9878. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  9879. if (handlerUpdatePrimSinglePosition != null)
  9880. {
  9881. handlerUpdatePrimSinglePosition(localId, pos6, this);
  9882. }
  9883. part.IgnoreUndoUpdate = false;
  9884. }
  9885. break;
  9886. default:
  9887. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  9888. break;
  9889. }
  9890. // for (int j = 0; j < parts.Length; j++)
  9891. // parts[j].IgnoreUndoUpdate = false;
  9892. }
  9893. }
  9894. }
  9895. return true;
  9896. }
  9897. public void RequestMapLayer()
  9898. {
  9899. //should be getting the map layer from the grid server
  9900. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  9901. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  9902. // TODO: don't create new blocks if recycling an old packet
  9903. mapReply.AgentData.AgentID = AgentId;
  9904. mapReply.AgentData.Flags = 0;
  9905. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  9906. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  9907. mapReply.LayerData[0].Bottom = 0;
  9908. mapReply.LayerData[0].Left = 0;
  9909. mapReply.LayerData[0].Top = 30000;
  9910. mapReply.LayerData[0].Right = 30000;
  9911. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  9912. mapReply.Header.Zerocoded = true;
  9913. OutPacket(mapReply, ThrottleOutPacketType.Land);
  9914. }
  9915. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  9916. {
  9917. /*
  9918. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  9919. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  9920. mbReply.AgentData.AgentId = AgentId;
  9921. int len;
  9922. if (simMapProfiles == null)
  9923. len = 0;
  9924. else
  9925. len = simMapProfiles.Count;
  9926. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  9927. int iii;
  9928. for (iii = 0; iii < len; iii++)
  9929. {
  9930. Hashtable mp = (Hashtable)simMapProfiles[iii];
  9931. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  9932. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  9933. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  9934. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  9935. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  9936. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  9937. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  9938. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  9939. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  9940. }
  9941. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  9942. */
  9943. }
  9944. /// <summary>
  9945. /// Sets the throttles from values supplied by the client
  9946. /// </summary>
  9947. /// <param name="throttles"></param>
  9948. public void SetChildAgentThrottle(byte[] throttles)
  9949. {
  9950. m_udpClient.SetThrottles(throttles);
  9951. }
  9952. /// <summary>
  9953. /// Get the current throttles for this client as a packed byte array
  9954. /// </summary>
  9955. /// <param name="multiplier">Unused</param>
  9956. /// <returns></returns>
  9957. public byte[] GetThrottlesPacked(float multiplier)
  9958. {
  9959. return m_udpClient.GetThrottlesPacked(multiplier);
  9960. }
  9961. /// <summary>
  9962. /// Cruft?
  9963. /// </summary>
  9964. public virtual void InPacket(object NewPack)
  9965. {
  9966. throw new NotImplementedException();
  9967. }
  9968. /// <summary>
  9969. /// This is the starting point for sending a simulator packet out to the client
  9970. /// </summary>
  9971. /// <param name="packet">Packet to send</param>
  9972. /// <param name="throttlePacketType">Throttling category for the packet</param>
  9973. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  9974. {
  9975. #region BinaryStats
  9976. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  9977. #endregion BinaryStats
  9978. OutPacket(packet, throttlePacketType, true);
  9979. }
  9980. /// <summary>
  9981. /// This is the starting point for sending a simulator packet out to the client
  9982. /// </summary>
  9983. /// <param name="packet">Packet to send</param>
  9984. /// <param name="throttlePacketType">Throttling category for the packet</param>
  9985. /// <param name="doAutomaticSplitting">True to automatically split oversized
  9986. /// packets (the default), or false to disable splitting if the calling code
  9987. /// handles splitting manually</param>
  9988. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  9989. {
  9990. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  9991. }
  9992. /// <summary>
  9993. /// This is the starting point for sending a simulator packet out to the client
  9994. /// </summary>
  9995. /// <param name="packet">Packet to send</param>
  9996. /// <param name="throttlePacketType">Throttling category for the packet</param>
  9997. /// <param name="doAutomaticSplitting">True to automatically split oversized
  9998. /// packets (the default), or false to disable splitting if the calling code
  9999. /// handles splitting manually</param>
  10000. /// <param name="method">The method to be called in the event this packet is reliable
  10001. /// and unacknowledged. The server will provide normal resend capability if you do not
  10002. /// provide your own method.</param>
  10003. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10004. {
  10005. if (DebugPacketLevel > 0)
  10006. {
  10007. bool logPacket = true;
  10008. if (DebugPacketLevel <= 255
  10009. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10010. logPacket = false;
  10011. if (DebugPacketLevel <= 200
  10012. && (packet.Type == PacketType.ImagePacket
  10013. || packet.Type == PacketType.ImageData
  10014. || packet.Type == PacketType.LayerData
  10015. || packet.Type == PacketType.CoarseLocationUpdate))
  10016. logPacket = false;
  10017. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10018. logPacket = false;
  10019. if (DebugPacketLevel <= 50 && packet.Type == PacketType.ImprovedTerseObjectUpdate)
  10020. logPacket = false;
  10021. if (logPacket)
  10022. m_log.DebugFormat(
  10023. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10024. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10025. }
  10026. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10027. }
  10028. public bool AddMoney(int debit)
  10029. {
  10030. if (m_moneyBalance + debit >= 0)
  10031. {
  10032. m_moneyBalance += debit;
  10033. SendMoneyBalance(UUID.Zero, true, Util.StringToBytes256("Poof Poof!"), m_moneyBalance);
  10034. return true;
  10035. }
  10036. return false;
  10037. }
  10038. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10039. {
  10040. float locx = 0;
  10041. float locy = 0;
  10042. float locz = 0;
  10043. uint regionX = 0;
  10044. uint regionY = 0;
  10045. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10046. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10047. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10048. locz = Convert.ToSingle(args[2]);
  10049. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10050. if (handlerAutoPilotGo != null)
  10051. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10052. }
  10053. /// <summary>
  10054. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10055. /// </summary>
  10056. /// <param name="Pack">OpenMetaverse.packet</param>
  10057. public void ProcessInPacket(Packet packet)
  10058. {
  10059. if (DebugPacketLevel > 0)
  10060. {
  10061. bool logPacket = true;
  10062. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10063. logPacket = false;
  10064. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10065. logPacket = false;
  10066. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10067. logPacket = false;
  10068. if (logPacket)
  10069. m_log.DebugFormat(
  10070. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10071. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10072. }
  10073. if (!ProcessPacketMethod(packet))
  10074. m_log.Warn("[CLIENT]: unhandled packet " + packet.Type);
  10075. PacketPool.Instance.ReturnPacket(packet);
  10076. }
  10077. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10078. {
  10079. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10080. shape.PCode = addPacket.ObjectData.PCode;
  10081. shape.State = addPacket.ObjectData.State;
  10082. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10083. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10084. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10085. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10086. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10087. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10088. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10089. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10090. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10091. shape.Scale = addPacket.ObjectData.Scale;
  10092. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10093. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10094. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10095. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10096. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10097. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10098. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10099. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10100. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10101. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10102. shape.TextureEntry = ntex.GetBytes();
  10103. //shape.Textures = ntex;
  10104. return shape;
  10105. }
  10106. public ClientInfo GetClientInfo()
  10107. {
  10108. ClientInfo info = m_udpClient.GetClientInfo();
  10109. info.userEP = m_userEndPoint;
  10110. info.proxyEP = null;
  10111. info.agentcircuit = RequestClientInfo();
  10112. return info;
  10113. }
  10114. public void SetClientInfo(ClientInfo info)
  10115. {
  10116. m_udpClient.SetClientInfo(info);
  10117. }
  10118. public EndPoint GetClientEP()
  10119. {
  10120. return m_userEndPoint;
  10121. }
  10122. #region Media Parcel Members
  10123. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10124. {
  10125. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10126. commandMessagePacket.CommandBlock.Flags = flags;
  10127. commandMessagePacket.CommandBlock.Command = (uint)command;
  10128. commandMessagePacket.CommandBlock.Time = time;
  10129. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10130. }
  10131. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10132. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10133. byte mediaLoop)
  10134. {
  10135. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10136. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10137. updatePacket.DataBlock.MediaID = mediaTextureID;
  10138. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10139. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10140. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10141. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10142. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10143. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10144. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10145. }
  10146. #endregion
  10147. #region Camera
  10148. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10149. {
  10150. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10151. packet.ObjectData.ObjectID = objectID;
  10152. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10153. uint idx = 0;
  10154. foreach (KeyValuePair<int, float> pair in parameters)
  10155. {
  10156. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10157. block.Type = pair.Key;
  10158. block.Value = pair.Value;
  10159. camPropBlock[idx++] = block;
  10160. }
  10161. packet.CameraProperty = camPropBlock;
  10162. OutPacket(packet, ThrottleOutPacketType.Task);
  10163. }
  10164. public void SendClearFollowCamProperties(UUID objectID)
  10165. {
  10166. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10167. packet.ObjectData.ObjectID = objectID;
  10168. OutPacket(packet, ThrottleOutPacketType.Task);
  10169. }
  10170. #endregion
  10171. public void SetClientOption(string option, string value)
  10172. {
  10173. switch (option)
  10174. {
  10175. default:
  10176. break;
  10177. }
  10178. }
  10179. public string GetClientOption(string option)
  10180. {
  10181. switch (option)
  10182. {
  10183. default:
  10184. break;
  10185. }
  10186. return string.Empty;
  10187. }
  10188. public void KillEndDone()
  10189. {
  10190. }
  10191. #region IClientCore
  10192. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10193. /// <summary>
  10194. /// Register an interface on this client, should only be called in the constructor.
  10195. /// </summary>
  10196. /// <typeparam name="T"></typeparam>
  10197. /// <param name="iface"></param>
  10198. protected void RegisterInterface<T>(T iface)
  10199. {
  10200. lock (m_clientInterfaces)
  10201. {
  10202. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10203. {
  10204. m_clientInterfaces.Add(typeof(T), iface);
  10205. }
  10206. }
  10207. }
  10208. public bool TryGet<T>(out T iface)
  10209. {
  10210. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10211. {
  10212. iface = (T)m_clientInterfaces[typeof(T)];
  10213. return true;
  10214. }
  10215. iface = default(T);
  10216. return false;
  10217. }
  10218. public T Get<T>()
  10219. {
  10220. return (T)m_clientInterfaces[typeof(T)];
  10221. }
  10222. public void Disconnect(string reason)
  10223. {
  10224. Kick(reason);
  10225. Thread.Sleep(1000);
  10226. Close();
  10227. }
  10228. public void Disconnect()
  10229. {
  10230. Close();
  10231. }
  10232. #endregion
  10233. public void RefreshGroupMembership()
  10234. {
  10235. if (m_GroupsModule != null)
  10236. {
  10237. GroupMembershipData[] GroupMembership =
  10238. m_GroupsModule.GetMembershipData(AgentId);
  10239. m_groupPowers.Clear();
  10240. if (GroupMembership != null)
  10241. {
  10242. for (int i = 0; i < GroupMembership.Length; i++)
  10243. {
  10244. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10245. }
  10246. }
  10247. }
  10248. }
  10249. public string Report()
  10250. {
  10251. return m_udpClient.GetStats();
  10252. }
  10253. public string XReport(string uptime, string version)
  10254. {
  10255. return String.Empty;
  10256. }
  10257. /// <summary>
  10258. /// Make an asset request to the asset service in response to a client request.
  10259. /// </summary>
  10260. /// <param name="transferRequest"></param>
  10261. /// <param name="taskID"></param>
  10262. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10263. {
  10264. UUID requestID = UUID.Zero;
  10265. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10266. {
  10267. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10268. }
  10269. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10270. {
  10271. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10272. }
  10273. // m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
  10274. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10275. }
  10276. /// <summary>
  10277. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10278. /// </summary>
  10279. /// <param name="id"></param>
  10280. /// <param name="sender"></param>
  10281. /// <param name="asset"></param>
  10282. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10283. {
  10284. if (asset == null)
  10285. return;
  10286. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10287. UUID requestID = UUID.Zero;
  10288. byte source = (byte)SourceType.Asset;
  10289. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10290. {
  10291. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10292. }
  10293. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10294. {
  10295. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10296. source = (byte)SourceType.SimInventoryItem;
  10297. //m_log.Debug("asset request " + requestID);
  10298. }
  10299. // Scripts cannot be retrieved by direct request
  10300. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10301. return;
  10302. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10303. AssetRequestToClient req = new AssetRequestToClient();
  10304. req.AssetInf = asset;
  10305. req.AssetRequestSource = source;
  10306. req.IsTextureRequest = false;
  10307. req.NumPackets = CalculateNumPackets(asset.Data);
  10308. req.Params = transferRequest.TransferInfo.Params;
  10309. req.RequestAssetID = requestID;
  10310. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10311. SendAsset(req);
  10312. }
  10313. /// <summary>
  10314. /// Calculate the number of packets required to send the asset to the client.
  10315. /// </summary>
  10316. /// <param name="data"></param>
  10317. /// <returns></returns>
  10318. private static int CalculateNumPackets(byte[] data)
  10319. {
  10320. const uint m_maxPacketSize = 600;
  10321. int numPackets = 1;
  10322. if (data == null)
  10323. return 0;
  10324. if (data.LongLength > m_maxPacketSize)
  10325. {
  10326. // over max number of bytes so split up file
  10327. long restData = data.LongLength - m_maxPacketSize;
  10328. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10329. numPackets += restPackets;
  10330. }
  10331. return numPackets;
  10332. }
  10333. #region IClientIPEndpoint Members
  10334. public IPAddress EndPoint
  10335. {
  10336. get
  10337. {
  10338. if (m_userEndPoint is IPEndPoint)
  10339. {
  10340. IPEndPoint ep = (IPEndPoint)m_userEndPoint;
  10341. return ep.Address;
  10342. }
  10343. return null;
  10344. }
  10345. }
  10346. #endregion
  10347. public void SendRebakeAvatarTextures(UUID textureID)
  10348. {
  10349. RebakeAvatarTexturesPacket pack =
  10350. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10351. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10352. pack.TextureData.TextureID = textureID;
  10353. OutPacket(pack, ThrottleOutPacketType.Task);
  10354. }
  10355. public struct PacketProcessor
  10356. {
  10357. public PacketMethod method;
  10358. public bool Async;
  10359. }
  10360. public class AsyncPacketProcess
  10361. {
  10362. public bool result = false;
  10363. public readonly LLClientView ClientView = null;
  10364. public readonly Packet Pack = null;
  10365. public readonly PacketMethod Method = null;
  10366. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10367. {
  10368. ClientView = pClientview;
  10369. Method = pMethod;
  10370. Pack = pPack;
  10371. }
  10372. }
  10373. public static OSD BuildEvent(string eventName, OSD eventBody)
  10374. {
  10375. OSDMap osdEvent = new OSDMap(2);
  10376. osdEvent.Add("message", new OSDString(eventName));
  10377. osdEvent.Add("body", eventBody);
  10378. return osdEvent;
  10379. }
  10380. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10381. {
  10382. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10383. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10384. packet.AgentData.AgentID = AgentId;
  10385. packet.AgentData.AvatarID = avatarID;
  10386. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10387. packet.PropertiesData.WantToMask = wantMask;
  10388. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10389. packet.PropertiesData.SkillsMask = skillsMask;
  10390. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10391. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10392. OutPacket(packet, ThrottleOutPacketType.Task);
  10393. }
  10394. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10395. {
  10396. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10397. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10398. packet.AgentData.AgentID = agentID;
  10399. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10400. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10401. packet.Rights[0].AgentRelated = friendID;
  10402. packet.Rights[0].RelatedRights = rights;
  10403. OutPacket(packet, ThrottleOutPacketType.Task);
  10404. }
  10405. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10406. {
  10407. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10408. dialog.Data.ObjectID = objectId;
  10409. dialog.Data.ChatChannel = chatChannel;
  10410. dialog.Data.ImageID = UUID.Zero;
  10411. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10412. // this is the username of the *owner*
  10413. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10414. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10415. dialog.Data.Message = Util.StringToBytes256(message);
  10416. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10417. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10418. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10419. dialog.Buttons = buttons;
  10420. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10421. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10422. dialog.OwnerData[0].OwnerID = ownerID;
  10423. OutPacket(dialog, ThrottleOutPacketType.Task);
  10424. }
  10425. public void StopFlying(ISceneEntity p)
  10426. {
  10427. if (p is ScenePresence)
  10428. {
  10429. ScenePresence presence = p as ScenePresence;
  10430. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10431. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10432. // velocity, collision plane and avatar height
  10433. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10434. // when the avatar stands up
  10435. Vector3 pos = presence.AbsolutePosition;
  10436. if (presence.Appearance.AvatarHeight != 127.0f)
  10437. pos += new Vector3(0f, 0f, (presence.Appearance.AvatarHeight/6f));
  10438. else
  10439. pos += new Vector3(0f, 0f, (1.56f/6f));
  10440. presence.AbsolutePosition = pos;
  10441. // attach a suitable collision plane regardless of the actual situation to force the LLClient to land.
  10442. // Collision plane below the avatar's position a 6th of the avatar's height is suitable.
  10443. // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a
  10444. // certain amount.. because the LLClient wouldn't land in that situation anyway.
  10445. // why are we still testing for this really old height value default???
  10446. if (presence.Appearance.AvatarHeight != 127.0f)
  10447. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - presence.Appearance.AvatarHeight/6f);
  10448. else
  10449. presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f/6f));
  10450. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10451. CreateImprovedTerseBlock(p, false);
  10452. const float TIME_DILATION = 1.0f;
  10453. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10454. ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket();
  10455. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10456. packet.RegionData.TimeDilation = timeDilation;
  10457. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10458. packet.ObjectData[0] = block;
  10459. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10460. }
  10461. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10462. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10463. }
  10464. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10465. PlacesReplyData[] data)
  10466. {
  10467. PlacesReplyPacket reply = null;
  10468. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10469. new PlacesReplyPacket.QueryDataBlock[0];
  10470. for (int i = 0 ; i < data.Length ; i++)
  10471. {
  10472. PlacesReplyPacket.QueryDataBlock block =
  10473. new PlacesReplyPacket.QueryDataBlock();
  10474. block.OwnerID = data[i].OwnerID;
  10475. block.Name = Util.StringToBytes256(data[i].Name);
  10476. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10477. block.ActualArea = data[i].ActualArea;
  10478. block.BillableArea = data[i].BillableArea;
  10479. block.Flags = data[i].Flags;
  10480. block.GlobalX = data[i].GlobalX;
  10481. block.GlobalY = data[i].GlobalY;
  10482. block.GlobalZ = data[i].GlobalZ;
  10483. block.SimName = Util.StringToBytes256(data[i].SimName);
  10484. block.SnapshotID = data[i].SnapshotID;
  10485. block.Dwell = data[i].Dwell;
  10486. block.Price = data[i].Price;
  10487. if (reply != null && reply.Length + block.Length > 1400)
  10488. {
  10489. OutPacket(reply, ThrottleOutPacketType.Task);
  10490. reply = null;
  10491. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10492. }
  10493. if (reply == null)
  10494. {
  10495. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10496. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10497. reply.AgentData.AgentID = AgentId;
  10498. reply.AgentData.QueryID = queryID;
  10499. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10500. reply.TransactionData.TransactionID = transactionID;
  10501. reply.QueryData = dataBlocks;
  10502. }
  10503. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10504. dataBlocks[dataBlocks.Length - 1] = block;
  10505. reply.QueryData = dataBlocks;
  10506. }
  10507. if (reply != null)
  10508. OutPacket(reply, ThrottleOutPacketType.Task);
  10509. }
  10510. }
  10511. }