LLClientView.cs 549 KB

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