LLClientView.cs 499 KB

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