LLClientView.cs 538 KB

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