LLClientView.cs 569 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Reflection;
  32. using System.Text;
  33. using System.Threading;
  34. using System.Timers;
  35. using System.Xml;
  36. using log4net;
  37. using OpenMetaverse;
  38. using OpenMetaverse.Packets;
  39. using OpenMetaverse.Messages.Linden;
  40. using OpenMetaverse.StructuredData;
  41. using OpenSim.Framework;
  42. using OpenSim.Framework.Client;
  43. using OpenSim.Framework.Monitoring;
  44. using OpenSim.Region.Framework.Interfaces;
  45. using OpenSim.Region.Framework.Scenes;
  46. using OpenSim.Services.Interfaces;
  47. using Timer = System.Timers.Timer;
  48. using AssetLandmark = OpenSim.Framework.AssetLandmark;
  49. using RegionFlags = OpenMetaverse.RegionFlags;
  50. using Nini.Config;
  51. using System.IO;
  52. using PermissionMask = OpenSim.Framework.PermissionMask;
  53. namespace OpenSim.Region.ClientStack.LindenUDP
  54. {
  55. public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
  56. /// <summary>
  57. /// Handles new client connections
  58. /// Constructor takes a single Packet and authenticates everything
  59. /// </summary>
  60. public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientInventory, IStatsCollector
  61. {
  62. /// <value>
  63. /// Debug packet level. See OpenSim.RegisterConsoleCommands() for more details.
  64. /// </value>
  65. public int DebugPacketLevel { get; set; }
  66. #region Events
  67. public event GenericMessage OnGenericMessage;
  68. public event BinaryGenericMessage OnBinaryGenericMessage;
  69. public event Action<IClientAPI> OnLogout;
  70. public event ObjectPermissions OnObjectPermissions;
  71. public event Action<IClientAPI> OnConnectionClosed;
  72. public event ViewerEffectEventHandler OnViewerEffect;
  73. public event ImprovedInstantMessage OnInstantMessage;
  74. public event ChatMessage OnChatFromClient;
  75. public event TextureRequest OnRequestTexture;
  76. public event RezObject OnRezObject;
  77. public event DeRezObject OnDeRezObject;
  78. public event ModifyTerrain OnModifyTerrain;
  79. public event Action<IClientAPI> OnRegionHandShakeReply;
  80. public event GenericCall1 OnRequestWearables;
  81. public event CachedTextureRequest OnCachedTextureRequest;
  82. public event SetAppearance OnSetAppearance;
  83. public event AvatarNowWearing OnAvatarNowWearing;
  84. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  85. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  86. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  87. public event ObjectAttach OnObjectAttach;
  88. public event ObjectDeselect OnObjectDetach;
  89. public event ObjectDrop OnObjectDrop;
  90. public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
  91. public event UpdateAgent OnPreAgentUpdate;
  92. public event UpdateAgent OnAgentUpdate;
  93. public event UpdateAgent OnAgentCameraUpdate;
  94. public event AgentRequestSit OnAgentRequestSit;
  95. public event AgentSit OnAgentSit;
  96. public event AvatarPickerRequest OnAvatarPickerRequest;
  97. public event StartAnim OnStartAnim;
  98. public event StopAnim OnStopAnim;
  99. public event Action<IClientAPI> OnRequestAvatarsData;
  100. public event LinkObjects OnLinkObjects;
  101. public event DelinkObjects OnDelinkObjects;
  102. public event GrabObject OnGrabObject;
  103. public event DeGrabObject OnDeGrabObject;
  104. public event SpinStart OnSpinStart;
  105. public event SpinStop OnSpinStop;
  106. public event ObjectDuplicate OnObjectDuplicate;
  107. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  108. public event MoveObject OnGrabUpdate;
  109. public event SpinObject OnSpinUpdate;
  110. public event AddNewPrim OnAddPrim;
  111. public event RequestGodlikePowers OnRequestGodlikePowers;
  112. public event GodKickUser OnGodKickUser;
  113. public event ObjectExtraParams OnUpdateExtraParams;
  114. public event UpdateShape OnUpdatePrimShape;
  115. public event ObjectRequest OnObjectRequest;
  116. public event ObjectSelect OnObjectSelect;
  117. public event ObjectDeselect OnObjectDeselect;
  118. public event GenericCall7 OnObjectDescription;
  119. public event GenericCall7 OnObjectName;
  120. public event GenericCall7 OnObjectClickAction;
  121. public event GenericCall7 OnObjectMaterial;
  122. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  123. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  124. public event UpdatePrimFlags OnUpdatePrimFlags;
  125. public event UpdatePrimTexture OnUpdatePrimTexture;
  126. public event UpdateVector OnUpdatePrimGroupPosition;
  127. public event UpdateVector OnUpdatePrimSinglePosition;
  128. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  129. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  130. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  131. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  132. public event UpdateVector OnUpdatePrimScale;
  133. public event UpdateVector OnUpdatePrimGroupScale;
  134. public event StatusChange OnChildAgentStatus;
  135. public event GenericCall2 OnStopMovement;
  136. public event Action<UUID> OnRemoveAvatar;
  137. public event RequestMapBlocks OnRequestMapBlocks;
  138. public event RequestMapName OnMapNameRequest;
  139. public event TeleportLocationRequest OnTeleportLocationRequest;
  140. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  141. public event TeleportCancel OnTeleportCancel;
  142. public event DisconnectUser OnDisconnectUser;
  143. public event RequestAvatarProperties OnRequestAvatarProperties;
  144. public event SetAlwaysRun OnSetAlwaysRun;
  145. public event FetchInventory OnAgentDataUpdateRequest;
  146. public event TeleportLocationRequest OnSetStartLocationRequest;
  147. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  148. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  149. public event LinkInventoryItem OnLinkInventoryItem;
  150. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  151. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  152. public event MoveInventoryFolder OnMoveInventoryFolder;
  153. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  154. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  155. public event FetchInventory OnFetchInventory;
  156. public event RequestTaskInventory OnRequestTaskInventory;
  157. public event UpdateInventoryItem OnUpdateInventoryItem;
  158. public event CopyInventoryItem OnCopyInventoryItem;
  159. public event MoveInventoryItem OnMoveInventoryItem;
  160. public event RemoveInventoryItem OnRemoveInventoryItem;
  161. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  162. public event UDPAssetUploadRequest OnAssetUploadRequest;
  163. public event XferReceive OnXferReceive;
  164. public event RequestXfer OnRequestXfer;
  165. public event ConfirmXfer OnConfirmXfer;
  166. public event AbortXfer OnAbortXfer;
  167. public event RequestTerrain OnRequestTerrain;
  168. public event RezScript OnRezScript;
  169. public event UpdateTaskInventory OnUpdateTaskInventory;
  170. public event MoveTaskInventory OnMoveTaskItem;
  171. public event RemoveTaskInventory OnRemoveTaskItem;
  172. public event RequestAsset OnRequestAsset;
  173. public event UUIDNameRequest OnNameFromUUIDRequest;
  174. public event ParcelAccessListRequest OnParcelAccessListRequest;
  175. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  176. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  177. public event ParcelDivideRequest OnParcelDivideRequest;
  178. public event ParcelJoinRequest OnParcelJoinRequest;
  179. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  180. public event ParcelSelectObjects OnParcelSelectObjects;
  181. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  182. public event ParcelAbandonRequest OnParcelAbandonRequest;
  183. public event ParcelGodForceOwner OnParcelGodForceOwner;
  184. public event ParcelReclaim OnParcelReclaim;
  185. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  186. public event ParcelDeedToGroup OnParcelDeedToGroup;
  187. public event RegionInfoRequest OnRegionInfoRequest;
  188. public event EstateCovenantRequest OnEstateCovenantRequest;
  189. public event FriendActionDelegate OnApproveFriendRequest;
  190. public event FriendActionDelegate OnDenyFriendRequest;
  191. public event FriendshipTermination OnTerminateFriendship;
  192. public event GrantUserFriendRights OnGrantUserRights;
  193. public event MoneyTransferRequest OnMoneyTransferRequest;
  194. public event EconomyDataRequest OnEconomyDataRequest;
  195. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  196. public event ParcelBuy OnParcelBuy;
  197. public event UUIDNameRequest OnTeleportHomeRequest;
  198. public event UUIDNameRequest OnUUIDGroupNameRequest;
  199. public event ScriptAnswer OnScriptAnswer;
  200. public event RequestPayPrice OnRequestPayPrice;
  201. public event ObjectSaleInfo OnObjectSaleInfo;
  202. public event ObjectBuy OnObjectBuy;
  203. public event BuyObjectInventory OnBuyObjectInventory;
  204. public event AgentSit OnUndo;
  205. public event AgentSit OnRedo;
  206. public event LandUndo OnLandUndo;
  207. public event ForceReleaseControls OnForceReleaseControls;
  208. public event GodLandStatRequest OnLandStatRequest;
  209. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  210. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  211. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  212. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  213. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  214. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  215. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  216. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  217. public event BakeTerrain OnBakeTerrain;
  218. public event RequestTerrain OnUploadTerrain;
  219. public event EstateChangeInfo OnEstateChangeInfo;
  220. public event EstateManageTelehub OnEstateManageTelehub;
  221. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  222. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  223. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  224. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  225. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  226. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  227. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  228. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  229. public event RegionHandleRequest OnRegionHandleRequest;
  230. public event ParcelInfoRequest OnParcelInfoRequest;
  231. public event ScriptReset OnScriptReset;
  232. public event GetScriptRunning OnGetScriptRunning;
  233. public event SetScriptRunning OnSetScriptRunning;
  234. public event Action<Vector3, bool, bool> OnAutoPilotGo;
  235. public event TerrainUnacked OnUnackedTerrain;
  236. public event ActivateGesture OnActivateGesture;
  237. public event DeactivateGesture OnDeactivateGesture;
  238. public event ObjectOwner OnObjectOwner;
  239. public event DirPlacesQuery OnDirPlacesQuery;
  240. public event DirFindQuery OnDirFindQuery;
  241. public event DirLandQuery OnDirLandQuery;
  242. public event DirPopularQuery OnDirPopularQuery;
  243. public event DirClassifiedQuery OnDirClassifiedQuery;
  244. public event EventInfoRequest OnEventInfoRequest;
  245. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  246. public event MapItemRequest OnMapItemRequest;
  247. public event OfferCallingCard OnOfferCallingCard;
  248. public event AcceptCallingCard OnAcceptCallingCard;
  249. public event DeclineCallingCard OnDeclineCallingCard;
  250. public event SoundTrigger OnSoundTrigger;
  251. public event StartLure OnStartLure;
  252. public event TeleportLureRequest OnTeleportLureRequest;
  253. public event NetworkStats OnNetworkStatsUpdate;
  254. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  255. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  256. public event ClassifiedDelete OnClassifiedDelete;
  257. public event ClassifiedDelete OnClassifiedGodDelete;
  258. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  259. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  260. public event EventGodDelete OnEventGodDelete;
  261. public event ParcelDwellRequest OnParcelDwellRequest;
  262. public event UserInfoRequest OnUserInfoRequest;
  263. public event UpdateUserInfo OnUpdateUserInfo;
  264. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  265. public event PickDelete OnPickDelete;
  266. public event PickGodDelete OnPickGodDelete;
  267. public event PickInfoUpdate OnPickInfoUpdate;
  268. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  269. public event MuteListRequest OnMuteListRequest;
  270. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  271. public event PlacesQuery OnPlacesQuery;
  272. public event AgentFOV OnAgentFOV;
  273. public event FindAgentUpdate OnFindAgent;
  274. public event TrackAgentUpdate OnTrackAgent;
  275. public event NewUserReport OnUserReport;
  276. public event SaveStateHandler OnSaveState;
  277. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  278. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  279. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  280. public event FreezeUserUpdate OnParcelFreezeUser;
  281. public event EjectUserUpdate OnParcelEjectUser;
  282. public event ParcelBuyPass OnParcelBuyPass;
  283. public event ParcelGodMark OnParcelGodMark;
  284. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  285. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  286. public event SimWideDeletesDelegate OnSimWideDeletes;
  287. public event SendPostcard OnSendPostcard;
  288. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  289. public event MuteListEntryRemove OnRemoveMuteListEntry;
  290. public event GodlikeMessage onGodlikeMessage;
  291. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  292. #endregion Events
  293. #region Class Members
  294. // LLClientView Only
  295. public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
  296. /// <summary>Used to adjust Sun Orbit values so Linden based viewers properly position sun</summary>
  297. private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
  298. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  299. protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
  300. /// <summary>
  301. /// Handles UDP texture download.
  302. /// </summary>
  303. public LLImageManager ImageManager { get; private set; }
  304. private readonly LLUDPServer m_udpServer;
  305. private readonly LLUDPClient m_udpClient;
  306. private readonly UUID m_sessionId;
  307. private readonly UUID m_secureSessionId;
  308. protected readonly UUID m_agentId;
  309. private readonly uint m_circuitCode;
  310. private readonly byte[] m_channelVersion = Utils.EmptyBytes;
  311. private readonly IGroupsModule m_GroupsModule;
  312. private PriorityQueue m_entityUpdates;
  313. private PriorityQueue m_entityProps;
  314. private Prioritizer m_prioritizer;
  315. private bool m_disableFacelights = false;
  316. private volatile bool m_justEditedTerrain = false;
  317. /// <value>
  318. /// List used in construction of data blocks for an object update packet. This is to stop us having to
  319. /// continually recreate it.
  320. /// </value>
  321. protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
  322. /// <value>
  323. /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
  324. /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
  325. /// ownerless phantom.
  326. ///
  327. /// All manipulation of this set has to occur under a lock
  328. ///
  329. /// </value>
  330. protected HashSet<uint> m_killRecord;
  331. // protected HashSet<uint> m_attachmentsSent;
  332. private int m_animationSequenceNumber = 1;
  333. private bool m_SendLogoutPacketWhenClosing = true;
  334. /// <summary>
  335. /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for
  336. /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it
  337. /// is doing absolutely nothing.
  338. /// </summary>
  339. /// <remarks>
  340. /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
  341. /// cannot retain a reference to it outside of that method.
  342. /// </remarks>
  343. private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
  344. protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
  345. protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
  346. protected Scene m_scene;
  347. protected string m_firstName;
  348. protected string m_lastName;
  349. protected Thread m_clientThread;
  350. protected Vector3 m_startpos;
  351. protected UUID m_activeGroupID;
  352. protected string m_activeGroupName = String.Empty;
  353. protected ulong m_activeGroupPowers;
  354. protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
  355. protected int m_terrainCheckerCount;
  356. protected uint m_agentFOVCounter;
  357. protected IAssetService m_assetService;
  358. private const bool m_checkPackets = true;
  359. #endregion Class Members
  360. #region Properties
  361. public LLUDPClient UDPClient { get { return m_udpClient; } }
  362. public LLUDPServer UDPServer { get { return m_udpServer; } }
  363. public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
  364. public UUID SecureSessionId { get { return m_secureSessionId; } }
  365. public IScene Scene { get { return m_scene; } }
  366. public UUID SessionId { get { return m_sessionId; } }
  367. public Vector3 StartPos
  368. {
  369. get { return m_startpos; }
  370. set { m_startpos = value; }
  371. }
  372. public UUID AgentId { get { return m_agentId; } }
  373. public ISceneAgent SceneAgent { get; set; }
  374. public UUID ActiveGroupId { get { return m_activeGroupID; } }
  375. public string ActiveGroupName { get { return m_activeGroupName; } }
  376. public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
  377. public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
  378. /// <summary>
  379. /// Entity update queues
  380. /// </summary>
  381. public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
  382. /// <summary>
  383. /// First name of the agent/avatar represented by the client
  384. /// </summary>
  385. public string FirstName { get { return m_firstName; } }
  386. /// <summary>
  387. /// Last name of the agent/avatar represented by the client
  388. /// </summary>
  389. public string LastName { get { return m_lastName; } }
  390. /// <summary>
  391. /// Full name of the client (first name and last name)
  392. /// </summary>
  393. public string Name { get { return FirstName + " " + LastName; } }
  394. public uint CircuitCode { get { return m_circuitCode; } }
  395. public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } }
  396. /// <summary>
  397. /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
  398. /// prevent race conditions by different threads calling Close().
  399. /// </summary>
  400. public bool IsActive { get; set; }
  401. /// <summary>
  402. /// Used to synchronise threads when client is being closed.
  403. /// </summary>
  404. public Object CloseSyncLock { get; private set; }
  405. public bool IsLoggingOut { get; set; }
  406. public bool DisableFacelights
  407. {
  408. get { return m_disableFacelights; }
  409. set { m_disableFacelights = value; }
  410. }
  411. public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
  412. #endregion Properties
  413. // ~LLClientView()
  414. // {
  415. // m_log.DebugFormat("[LLCLIENTVIEW]: Destructor called for {0}, circuit code {1}", Name, CircuitCode);
  416. // }
  417. /// <summary>
  418. /// Constructor
  419. /// </summary>
  420. public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
  421. UUID agentId, UUID sessionId, uint circuitCode)
  422. {
  423. // DebugPacketLevel = 1;
  424. CloseSyncLock = new Object();
  425. RegisterInterface<IClientIM>(this);
  426. RegisterInterface<IClientInventory>(this);
  427. RegisterInterface<IClientChat>(this);
  428. m_scene = scene;
  429. m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
  430. m_entityProps = new PriorityQueue(m_scene.Entities.Count);
  431. m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
  432. m_killRecord = new HashSet<uint>();
  433. // m_attachmentsSent = new HashSet<uint>();
  434. m_assetService = m_scene.RequestModuleInterface<IAssetService>();
  435. m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
  436. ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
  437. m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
  438. m_agentId = agentId;
  439. m_sessionId = sessionId;
  440. m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
  441. m_circuitCode = circuitCode;
  442. m_firstName = sessionInfo.LoginInfo.First;
  443. m_lastName = sessionInfo.LoginInfo.Last;
  444. m_startpos = sessionInfo.LoginInfo.StartPos;
  445. m_udpServer = udpServer;
  446. m_udpClient = udpClient;
  447. m_udpClient.OnQueueEmpty += HandleQueueEmpty;
  448. m_udpClient.HasUpdates += HandleHasUpdates;
  449. m_udpClient.OnPacketStats += PopulateStats;
  450. m_prioritizer = new Prioritizer(m_scene);
  451. RegisterLocalPacketHandlers();
  452. IsActive = true;
  453. }
  454. #region Client Methods
  455. public void Close()
  456. {
  457. Close(false);
  458. }
  459. public void Close(bool force)
  460. {
  461. // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
  462. // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
  463. lock (CloseSyncLock)
  464. {
  465. // We still perform a force close inside the sync lock since this is intended to attempt close where
  466. // there is some unidentified connection problem, not where we have issues due to deadlock
  467. if (!IsActive && !force)
  468. {
  469. m_log.DebugFormat(
  470. "[CLIENT]: Not attempting to close inactive client {0} in {1} since force flag is not set",
  471. Name, m_scene.Name);
  472. return;
  473. }
  474. IsActive = false;
  475. CloseWithoutChecks();
  476. }
  477. }
  478. /// <summary>
  479. /// Closes down the client view without first checking whether it is active.
  480. /// </summary>
  481. /// <remarks>
  482. /// This exists because LLUDPServer has to set IsActive = false in earlier synchronous code before calling
  483. /// CloseWithoutIsActiveCheck asynchronously.
  484. ///
  485. /// Callers must lock ClosingSyncLock before calling.
  486. /// </remarks>
  487. public void CloseWithoutChecks()
  488. {
  489. m_log.DebugFormat(
  490. "[CLIENT]: Close has been called for {0} attached to scene {1}",
  491. Name, m_scene.RegionInfo.RegionName);
  492. // Shutdown the image manager
  493. ImageManager.Close();
  494. // Fire the callback for this connection closing
  495. if (OnConnectionClosed != null)
  496. OnConnectionClosed(this);
  497. // Flush all of the packets out of the UDP server for this client
  498. if (m_udpServer != null)
  499. m_udpServer.Flush(m_udpClient);
  500. // Remove ourselves from the scene
  501. m_scene.RemoveClient(AgentId, true);
  502. SceneAgent = null;
  503. // We can't reach into other scenes and close the connection
  504. // We need to do this over grid communications
  505. //m_scene.CloseAllAgents(CircuitCode);
  506. // Disable UDP handling for this client
  507. m_udpClient.Shutdown();
  508. //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
  509. //GC.Collect();
  510. //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
  511. }
  512. public void Kick(string message)
  513. {
  514. if (!SceneAgent.IsChildAgent)
  515. {
  516. KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
  517. kupack.UserInfo.AgentID = AgentId;
  518. kupack.UserInfo.SessionID = SessionId;
  519. kupack.TargetBlock.TargetIP = 0;
  520. kupack.TargetBlock.TargetPort = 0;
  521. kupack.UserInfo.Reason = Util.StringToBytes256(message);
  522. OutPacket(kupack, ThrottleOutPacketType.Task);
  523. // You must sleep here or users get no message!
  524. Thread.Sleep(500);
  525. }
  526. }
  527. public void Stop()
  528. {
  529. }
  530. #endregion Client Methods
  531. #region Packet Handling
  532. public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
  533. {
  534. NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
  535. if (handlerNetworkStatsUpdate != null)
  536. {
  537. handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
  538. }
  539. }
  540. public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
  541. {
  542. bool result = false;
  543. lock (PacketHandlers)
  544. {
  545. if (!PacketHandlers.ContainsKey(packetType))
  546. {
  547. PacketHandlers.Add(packetType, handler);
  548. result = true;
  549. }
  550. }
  551. return result;
  552. }
  553. /// <summary>
  554. /// Add a handler for the given packet type.
  555. /// </summary>
  556. /// <remarks>
  557. /// The packet is handled on its own thread. If packets must be handled in the order in which they
  558. /// are received then please use the synchronous version of this method.
  559. /// </remarks>
  560. /// <param name="packetType"></param>
  561. /// <param name="handler"></param>
  562. /// <returns>true if the handler was added. This is currently always the case.</returns>
  563. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
  564. {
  565. return AddLocalPacketHandler(packetType, handler, true);
  566. }
  567. /// <summary>
  568. /// Add a handler for the given packet type.
  569. /// </summary>
  570. /// <param name="packetType"></param>
  571. /// <param name="handler"></param>
  572. /// <param name="doAsync">
  573. /// If true, when the packet is received it is handled on its own thread rather than on the main inward bound
  574. /// packet handler thread. This vastly increases respnosiveness but some packets need to be handled
  575. /// synchronously.
  576. /// </param>
  577. /// <returns>true if the handler was added. This is currently always the case.</returns>
  578. public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
  579. {
  580. bool result = false;
  581. lock (m_packetHandlers)
  582. {
  583. if (!m_packetHandlers.ContainsKey(packetType))
  584. {
  585. m_packetHandlers.Add(packetType, new PacketProcessor() { method = handler, Async = doAsync });
  586. result = true;
  587. }
  588. }
  589. return result;
  590. }
  591. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  592. {
  593. MethodName = MethodName.ToLower().Trim();
  594. bool result = false;
  595. lock (m_genericPacketHandlers)
  596. {
  597. if (!m_genericPacketHandlers.ContainsKey(MethodName))
  598. {
  599. m_genericPacketHandlers.Add(MethodName, handler);
  600. result = true;
  601. }
  602. }
  603. return result;
  604. }
  605. /// <summary>
  606. /// Try to process a packet using registered packet handlers
  607. /// </summary>
  608. /// <param name="packet"></param>
  609. /// <returns>True if a handler was found which successfully processed the packet.</returns>
  610. protected virtual bool ProcessPacketMethod(Packet packet)
  611. {
  612. bool result = false;
  613. PacketProcessor pprocessor;
  614. if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
  615. {
  616. //there is a local handler for this packet type
  617. if (pprocessor.Async)
  618. {
  619. ClientInfo cinfo = UDPClient.GetClientInfo();
  620. if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
  621. cinfo.AsyncRequests[packet.Type.ToString()] = 0;
  622. cinfo.AsyncRequests[packet.Type.ToString()]++;
  623. object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
  624. Util.FireAndForget(ProcessSpecificPacketAsync, obj);
  625. result = true;
  626. }
  627. else
  628. {
  629. ClientInfo cinfo = UDPClient.GetClientInfo();
  630. if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
  631. cinfo.SyncRequests[packet.Type.ToString()] = 0;
  632. cinfo.SyncRequests[packet.Type.ToString()]++;
  633. result = pprocessor.method(this, packet);
  634. }
  635. }
  636. else
  637. {
  638. //there is not a local handler so see if there is a Global handler
  639. PacketMethod method = null;
  640. bool found;
  641. lock (PacketHandlers)
  642. {
  643. found = PacketHandlers.TryGetValue(packet.Type, out method);
  644. }
  645. if (found)
  646. {
  647. ClientInfo cinfo = UDPClient.GetClientInfo();
  648. if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
  649. cinfo.GenericRequests[packet.Type.ToString()] = 0;
  650. cinfo.GenericRequests[packet.Type.ToString()]++;
  651. result = method(this, packet);
  652. }
  653. }
  654. return result;
  655. }
  656. public void ProcessSpecificPacketAsync(object state)
  657. {
  658. AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
  659. try
  660. {
  661. packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
  662. }
  663. catch (Exception e)
  664. {
  665. // Make sure that we see any exception caused by the asynchronous operation.
  666. m_log.ErrorFormat(
  667. "[LLCLIENTVIEW]: Caught exception while processing {0} for {1}, {2} {3}",
  668. packetObject.Pack, Name, e.Message, e.StackTrace);
  669. }
  670. }
  671. #endregion Packet Handling
  672. # region Setup
  673. public virtual void Start()
  674. {
  675. m_scene.AddNewAgent(this, PresenceType.User);
  676. RefreshGroupMembership();
  677. }
  678. # endregion
  679. public void ActivateGesture(UUID assetId, UUID gestureId)
  680. {
  681. }
  682. public void DeactivateGesture(UUID assetId, UUID gestureId)
  683. {
  684. }
  685. // Sound
  686. public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
  687. {
  688. }
  689. #region Scene/Avatar to Client
  690. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  691. {
  692. RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
  693. handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
  694. handshake.RegionInfo.BillableFactor = args.billableFactor;
  695. handshake.RegionInfo.IsEstateManager = args.isEstateManager;
  696. handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
  697. handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
  698. handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
  699. handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
  700. handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
  701. handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
  702. handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
  703. handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
  704. handshake.RegionInfo.SimAccess = args.simAccess;
  705. handshake.RegionInfo.WaterHeight = args.waterHeight;
  706. handshake.RegionInfo.RegionFlags = args.regionFlags;
  707. handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
  708. handshake.RegionInfo.SimOwner = args.SimOwner;
  709. handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
  710. handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
  711. handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
  712. handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
  713. handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
  714. handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
  715. handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
  716. handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
  717. handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
  718. handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
  719. handshake.RegionInfo2.RegionID = regionInfo.RegionID;
  720. handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
  721. handshake.RegionInfo3.CPUClassID = 9;
  722. handshake.RegionInfo3.CPURatio = 1;
  723. handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
  724. handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
  725. handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
  726. handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
  727. handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
  728. handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
  729. handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
  730. OutPacket(handshake, ThrottleOutPacketType.Unknown);
  731. }
  732. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  733. {
  734. AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
  735. mov.SimData.ChannelVersion = m_channelVersion;
  736. mov.AgentData.SessionID = m_sessionId;
  737. mov.AgentData.AgentID = AgentId;
  738. mov.Data.RegionHandle = regInfo.RegionHandle;
  739. mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
  740. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  741. {
  742. mov.Data.Position = m_startpos;
  743. }
  744. else
  745. {
  746. mov.Data.Position = pos;
  747. }
  748. mov.Data.LookAt = look;
  749. // Hack to get this out immediately and skip the throttles
  750. OutPacket(mov, ThrottleOutPacketType.Unknown);
  751. }
  752. public void SendChatMessage(
  753. string message, byte type, Vector3 fromPos, string fromName,
  754. UUID fromAgentID, UUID ownerID, byte source, byte audible)
  755. {
  756. ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
  757. reply.ChatData.Audible = audible;
  758. reply.ChatData.Message = Util.StringToBytes1024(message);
  759. reply.ChatData.ChatType = type;
  760. reply.ChatData.SourceType = source;
  761. reply.ChatData.Position = fromPos;
  762. reply.ChatData.FromName = Util.StringToBytes256(fromName);
  763. reply.ChatData.OwnerID = ownerID;
  764. reply.ChatData.SourceID = fromAgentID;
  765. OutPacket(reply, ThrottleOutPacketType.Task);
  766. }
  767. /// <summary>
  768. /// Send an instant message to this client
  769. /// </summary>
  770. //
  771. // Don't remove transaction ID! Groups and item gives need to set it!
  772. public void SendInstantMessage(GridInstantMessage im)
  773. {
  774. if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
  775. {
  776. ImprovedInstantMessagePacket msg
  777. = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
  778. msg.AgentData.AgentID = new UUID(im.fromAgentID);
  779. msg.AgentData.SessionID = UUID.Zero;
  780. msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
  781. msg.MessageBlock.Dialog = im.dialog;
  782. msg.MessageBlock.FromGroup = im.fromGroup;
  783. if (im.imSessionID == UUID.Zero.Guid)
  784. msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
  785. else
  786. msg.MessageBlock.ID = new UUID(im.imSessionID);
  787. msg.MessageBlock.Offline = im.offline;
  788. msg.MessageBlock.ParentEstateID = im.ParentEstateID;
  789. msg.MessageBlock.Position = im.Position;
  790. msg.MessageBlock.RegionID = new UUID(im.RegionID);
  791. msg.MessageBlock.Timestamp = im.timestamp;
  792. msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
  793. msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
  794. msg.MessageBlock.BinaryBucket = im.binaryBucket;
  795. if (im.message.StartsWith("[grouptest]"))
  796. { // this block is test code for implementing group IM - delete when group IM is finished
  797. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  798. if (eq != null)
  799. {
  800. im.dialog = 17;
  801. //eq.ChatterboxInvitation(
  802. // new UUID("00000000-68f9-1111-024e-222222111123"),
  803. // "OpenSimulator Testing", im.fromAgentID, im.message, im.toAgentID, im.fromAgentName, im.dialog, 0,
  804. // false, 0, new Vector3(), 1, im.imSessionID, im.fromGroup, im.binaryBucket);
  805. eq.ChatterboxInvitation(
  806. new UUID("00000000-68f9-1111-024e-222222111123"),
  807. "OpenSimulator Testing", new UUID(im.fromAgentID), im.message, new UUID(im.toAgentID), im.fromAgentName, im.dialog, 0,
  808. false, 0, new Vector3(), 1, new UUID(im.imSessionID), im.fromGroup, Util.StringToBytes256("OpenSimulator Testing"));
  809. eq.ChatterBoxSessionAgentListUpdates(
  810. new UUID("00000000-68f9-1111-024e-222222111123"),
  811. new UUID(im.fromAgentID), new UUID(im.toAgentID), false, false, false);
  812. }
  813. Console.WriteLine("SendInstantMessage: " + msg);
  814. }
  815. else
  816. OutPacket(msg, ThrottleOutPacketType.Task);
  817. }
  818. }
  819. public void SendGenericMessage(string method, UUID invoice, List<string> message)
  820. {
  821. GenericMessagePacket gmp = new GenericMessagePacket();
  822. gmp.AgentData.AgentID = AgentId;
  823. gmp.AgentData.SessionID = m_sessionId;
  824. gmp.AgentData.TransactionID = invoice;
  825. gmp.MethodData.Method = Util.StringToBytes256(method);
  826. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  827. int i = 0;
  828. foreach (string val in message)
  829. {
  830. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  831. gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
  832. }
  833. OutPacket(gmp, ThrottleOutPacketType.Task);
  834. }
  835. public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
  836. {
  837. GenericMessagePacket gmp = new GenericMessagePacket();
  838. gmp.AgentData.AgentID = AgentId;
  839. gmp.AgentData.SessionID = m_sessionId;
  840. gmp.AgentData.TransactionID = invoice;
  841. gmp.MethodData.Method = Util.StringToBytes256(method);
  842. gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
  843. int i = 0;
  844. foreach (byte[] val in message)
  845. {
  846. gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
  847. gmp.ParamList[i++].Parameter = val;
  848. }
  849. OutPacket(gmp, ThrottleOutPacketType.Task);
  850. }
  851. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  852. {
  853. int i = 0;
  854. foreach (GroupActiveProposals Proposal in Proposals)
  855. {
  856. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  857. GAPIRP.AgentData.AgentID = AgentId;
  858. GAPIRP.AgentData.GroupID = groupID;
  859. GAPIRP.TransactionData.TransactionID = transactionID;
  860. GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
  861. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  862. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  863. ProposalData.VoteCast = Utils.StringToBytes("false");
  864. ProposalData.VoteID = new UUID(Proposal.VoteID);
  865. ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
  866. ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
  867. ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
  868. ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
  869. ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
  870. ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
  871. ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
  872. ProposalData.AlreadyVoted = false;
  873. GAPIRP.ProposalData[i] = ProposalData;
  874. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  875. i++;
  876. }
  877. if (Proposals.Length == 0)
  878. {
  879. GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
  880. GAPIRP.AgentData.AgentID = AgentId;
  881. GAPIRP.AgentData.GroupID = groupID;
  882. GAPIRP.TransactionData.TransactionID = transactionID;
  883. GAPIRP.TransactionData.TotalNumItems = 1;
  884. GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
  885. GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
  886. ProposalData.VoteCast = Utils.StringToBytes("false");
  887. ProposalData.VoteID = UUID.Zero;
  888. ProposalData.VoteInitiator = UUID.Zero;
  889. ProposalData.Majority = 0;
  890. ProposalData.Quorum = 0;
  891. ProposalData.TerseDateID = Utils.StringToBytes("");
  892. ProposalData.StartDateTime = Utils.StringToBytes("");
  893. ProposalData.EndDateTime = Utils.StringToBytes("");
  894. ProposalData.ProposalText = Utils.StringToBytes("");
  895. ProposalData.AlreadyVoted = false;
  896. GAPIRP.ProposalData[0] = ProposalData;
  897. OutPacket(GAPIRP, ThrottleOutPacketType.Task);
  898. }
  899. }
  900. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  901. {
  902. int i = 0;
  903. foreach (GroupVoteHistory Vote in Votes)
  904. {
  905. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  906. GVHIRP.AgentData.AgentID = AgentId;
  907. GVHIRP.AgentData.GroupID = groupID;
  908. GVHIRP.TransactionData.TransactionID = transactionID;
  909. GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
  910. GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
  911. GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
  912. GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
  913. GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
  914. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
  915. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
  916. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
  917. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
  918. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
  919. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
  920. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  921. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  922. VoteItem.CandidateID = UUID.Zero;
  923. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  924. VoteItem.VoteCast = Utils.StringToBytes("Yes");
  925. GVHIRP.VoteItem[i] = VoteItem;
  926. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  927. i++;
  928. }
  929. if (Votes.Length == 0)
  930. {
  931. GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
  932. GVHIRP.AgentData.AgentID = AgentId;
  933. GVHIRP.AgentData.GroupID = groupID;
  934. GVHIRP.TransactionData.TransactionID = transactionID;
  935. GVHIRP.TransactionData.TotalNumItems = 0;
  936. GVHIRP.HistoryItemData.VoteID = UUID.Zero;
  937. GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
  938. GVHIRP.HistoryItemData.Majority = 0;
  939. GVHIRP.HistoryItemData.Quorum = 0;
  940. GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
  941. GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
  942. GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
  943. GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
  944. GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
  945. GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
  946. GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
  947. GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
  948. VoteItem.CandidateID = UUID.Zero;
  949. VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
  950. VoteItem.VoteCast = Utils.StringToBytes("No");
  951. GVHIRP.VoteItem[0] = VoteItem;
  952. OutPacket(GVHIRP, ThrottleOutPacketType.Task);
  953. }
  954. }
  955. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  956. {
  957. GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
  958. GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
  959. GADRP.AgentData.AgentID = sender.AgentId;
  960. GADRP.AgentData.GroupID = groupID;
  961. GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
  962. GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
  963. GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
  964. GADRP.MoneyData.CurrentInterval = 0;
  965. GADRP.MoneyData.IntervalDays = 7;
  966. GADRP.MoneyData.RequestID = transactionID;
  967. GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  968. History.Amount = amt;
  969. History.Description = Utils.StringToBytes("");
  970. GADRP.HistoryData[0] = History;
  971. OutPacket(GADRP, ThrottleOutPacketType.Task);
  972. }
  973. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  974. {
  975. GroupAccountSummaryReplyPacket GASRP =
  976. (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
  977. PacketType.GroupAccountSummaryReply);
  978. GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
  979. GASRP.AgentData.AgentID = sender.AgentId;
  980. GASRP.AgentData.GroupID = groupID;
  981. GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
  982. GASRP.MoneyData.Balance = (int)moneyAmt;
  983. GASRP.MoneyData.TotalCredits = totalTier;
  984. GASRP.MoneyData.TotalDebits = usedTier;
  985. GASRP.MoneyData.StartDate = new byte[1];
  986. GASRP.MoneyData.CurrentInterval = 1;
  987. GASRP.MoneyData.GroupTaxCurrent = 0;
  988. GASRP.MoneyData.GroupTaxEstimate = 0;
  989. GASRP.MoneyData.IntervalDays = 0;
  990. GASRP.MoneyData.LandTaxCurrent = 0;
  991. GASRP.MoneyData.LandTaxEstimate = 0;
  992. GASRP.MoneyData.LastTaxDate = new byte[1];
  993. GASRP.MoneyData.LightTaxCurrent = 0;
  994. GASRP.MoneyData.TaxDate = new byte[1];
  995. GASRP.MoneyData.RequestID = sender.AgentId;
  996. GASRP.MoneyData.ParcelDirFeeEstimate = 0;
  997. GASRP.MoneyData.ParcelDirFeeCurrent = 0;
  998. GASRP.MoneyData.ObjectTaxEstimate = 0;
  999. GASRP.MoneyData.NonExemptMembers = 0;
  1000. GASRP.MoneyData.ObjectTaxCurrent = 0;
  1001. GASRP.MoneyData.LightTaxEstimate = 0;
  1002. OutPacket(GASRP, ThrottleOutPacketType.Task);
  1003. }
  1004. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1005. {
  1006. GroupAccountTransactionsReplyPacket GATRP =
  1007. (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
  1008. PacketType.GroupAccountTransactionsReply);
  1009. GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
  1010. GATRP.AgentData.AgentID = sender.AgentId;
  1011. GATRP.AgentData.GroupID = groupID;
  1012. GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
  1013. GATRP.MoneyData.CurrentInterval = 0;
  1014. GATRP.MoneyData.IntervalDays = 7;
  1015. GATRP.MoneyData.RequestID = transactionID;
  1016. GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
  1017. GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
  1018. GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
  1019. History.Amount = 0;
  1020. History.Item = Utils.StringToBytes("");
  1021. History.Time = Utils.StringToBytes("");
  1022. History.Type = 0;
  1023. History.User = Utils.StringToBytes("");
  1024. GATRP.HistoryData[0] = History;
  1025. OutPacket(GATRP, ThrottleOutPacketType.Task);
  1026. }
  1027. /// <summary>
  1028. /// Send the region heightmap to the client
  1029. /// </summary>
  1030. /// <param name="map">heightmap</param>
  1031. public virtual void SendLayerData(float[] map)
  1032. {
  1033. Util.FireAndForget(DoSendLayerData, map);
  1034. }
  1035. /// <summary>
  1036. /// Send terrain layer information to the client.
  1037. /// </summary>
  1038. /// <param name="o"></param>
  1039. private void DoSendLayerData(object o)
  1040. {
  1041. float[] map = LLHeightFieldMoronize((float[])o);
  1042. try
  1043. {
  1044. //for (int y = 0; y < 16; y++)
  1045. //{
  1046. // for (int x = 0; x < 16; x++)
  1047. // {
  1048. // SendLayerData(x, y, map);
  1049. // }
  1050. //}
  1051. // Send LayerData in a spiral pattern. Fun!
  1052. SendLayerTopRight(map, 0, 0, 15, 15);
  1053. }
  1054. catch (Exception e)
  1055. {
  1056. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1057. }
  1058. }
  1059. private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
  1060. {
  1061. // Row
  1062. for (int i = x1; i <= x2; i++)
  1063. SendLayerData(i, y1, map);
  1064. // Column
  1065. for (int j = y1 + 1; j <= y2; j++)
  1066. SendLayerData(x2, j, map);
  1067. if (x2 - x1 > 0)
  1068. SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
  1069. }
  1070. void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
  1071. {
  1072. // Row in reverse
  1073. for (int i = x2; i >= x1; i--)
  1074. SendLayerData(i, y2, map);
  1075. // Column in reverse
  1076. for (int j = y2 - 1; j >= y1; j--)
  1077. SendLayerData(x1, j, map);
  1078. if (x2 - x1 > 0)
  1079. SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
  1080. }
  1081. /// <summary>
  1082. /// Sends a set of four patches (x, x+1, ..., x+3) to the client
  1083. /// </summary>
  1084. /// <param name="map">heightmap</param>
  1085. /// <param name="px">X coordinate for patches 0..12</param>
  1086. /// <param name="py">Y coordinate for patches 0..15</param>
  1087. // private void SendLayerPacket(float[] map, int y, int x)
  1088. // {
  1089. // int[] patches = new int[4];
  1090. // patches[0] = x + 0 + y * 16;
  1091. // patches[1] = x + 1 + y * 16;
  1092. // patches[2] = x + 2 + y * 16;
  1093. // patches[3] = x + 3 + y * 16;
  1094. // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
  1095. // OutPacket(layerpack, ThrottleOutPacketType.Land);
  1096. // }
  1097. /// <summary>
  1098. /// Sends a specified patch to a client
  1099. /// </summary>
  1100. /// <param name="px">Patch coordinate (x) 0..15</param>
  1101. /// <param name="py">Patch coordinate (y) 0..15</param>
  1102. /// <param name="map">heightmap</param>
  1103. public void SendLayerData(int px, int py, float[] map)
  1104. {
  1105. try
  1106. {
  1107. int[] patches = new int[] { py * 16 + px };
  1108. float[] heightmap = (map.Length == 65536) ?
  1109. map :
  1110. LLHeightFieldMoronize(map);
  1111. LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
  1112. // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
  1113. // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
  1114. // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
  1115. // invalidating previous packets for that area.
  1116. // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
  1117. // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
  1118. // One last note on this topic, by the time users are going to be editing the terrain, it's extremely likely that the sim will
  1119. // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
  1120. // patches.
  1121. // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
  1122. if (m_justEditedTerrain)
  1123. {
  1124. layerpack.Header.Reliable = false;
  1125. OutPacket(layerpack,
  1126. ThrottleOutPacketType.Unknown );
  1127. }
  1128. else
  1129. {
  1130. layerpack.Header.Reliable = true;
  1131. OutPacket(layerpack,
  1132. ThrottleOutPacketType.Land);
  1133. }
  1134. }
  1135. catch (Exception e)
  1136. {
  1137. m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// Munges heightfield into the LLUDP backed in restricted heightfield.
  1142. /// </summary>
  1143. /// <param name="map">float array in the base; Constants.RegionSize</param>
  1144. /// <returns>float array in the base 256</returns>
  1145. internal float[] LLHeightFieldMoronize(float[] map)
  1146. {
  1147. if (map.Length == 65536)
  1148. return map;
  1149. else
  1150. {
  1151. float[] returnmap = new float[65536];
  1152. if (map.Length < 65535)
  1153. {
  1154. // rebase the vector stride to 256
  1155. for (int i = 0; i < Constants.RegionSize; i++)
  1156. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, (int)Constants.RegionSize);
  1157. }
  1158. else
  1159. {
  1160. for (int i = 0; i < 256; i++)
  1161. Array.Copy(map, i * (int)Constants.RegionSize, returnmap, i * 256, 256);
  1162. }
  1163. //Array.Copy(map,0,returnmap,0,(map.Length < 65536)? map.Length : 65536);
  1164. return returnmap;
  1165. }
  1166. }
  1167. /// <summary>
  1168. /// Send the wind matrix to the client
  1169. /// </summary>
  1170. /// <param name="windSpeeds">16x16 array of wind speeds</param>
  1171. public virtual void SendWindData(Vector2[] windSpeeds)
  1172. {
  1173. Util.FireAndForget(DoSendWindData, windSpeeds);
  1174. }
  1175. /// <summary>
  1176. /// Send the cloud matrix to the client
  1177. /// </summary>
  1178. /// <param name="windSpeeds">16x16 array of cloud densities</param>
  1179. public virtual void SendCloudData(float[] cloudDensity)
  1180. {
  1181. Util.FireAndForget(DoSendCloudData, cloudDensity);
  1182. }
  1183. /// <summary>
  1184. /// Send wind layer information to the client.
  1185. /// </summary>
  1186. /// <param name="o"></param>
  1187. private void DoSendWindData(object o)
  1188. {
  1189. Vector2[] windSpeeds = (Vector2[])o;
  1190. TerrainPatch[] patches = new TerrainPatch[2];
  1191. patches[0] = new TerrainPatch();
  1192. patches[0].Data = new float[16 * 16];
  1193. patches[1] = new TerrainPatch();
  1194. patches[1].Data = new float[16 * 16];
  1195. for (int y = 0; y < 16; y++)
  1196. {
  1197. for (int x = 0; x < 16; x++)
  1198. {
  1199. patches[0].Data[y * 16 + x] = windSpeeds[y * 16 + x].X;
  1200. patches[1].Data[y * 16 + x] = windSpeeds[y * 16 + x].Y;
  1201. }
  1202. }
  1203. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Wind);
  1204. layerpack.Header.Zerocoded = true;
  1205. OutPacket(layerpack, ThrottleOutPacketType.Wind);
  1206. }
  1207. /// <summary>
  1208. /// Send cloud layer information to the client.
  1209. /// </summary>
  1210. /// <param name="o"></param>
  1211. private void DoSendCloudData(object o)
  1212. {
  1213. float[] cloudCover = (float[])o;
  1214. TerrainPatch[] patches = new TerrainPatch[1];
  1215. patches[0] = new TerrainPatch();
  1216. patches[0].Data = new float[16 * 16];
  1217. for (int y = 0; y < 16; y++)
  1218. {
  1219. for (int x = 0; x < 16; x++)
  1220. {
  1221. patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
  1222. }
  1223. }
  1224. LayerDataPacket layerpack = TerrainCompressor.CreateLayerDataPacket(patches, TerrainPatch.LayerType.Cloud);
  1225. layerpack.Header.Zerocoded = true;
  1226. OutPacket(layerpack, ThrottleOutPacketType.Cloud);
  1227. }
  1228. /// <summary>
  1229. /// Tell the client that the given neighbour region is ready to receive a child agent.
  1230. /// </summary>
  1231. public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
  1232. {
  1233. IPAddress neighbourIP = neighbourEndPoint.Address;
  1234. ushort neighbourPort = (ushort)neighbourEndPoint.Port;
  1235. EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
  1236. // TODO: don't create new blocks if recycling an old packet
  1237. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  1238. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  1239. byte[] byteIP = neighbourIP.GetAddressBytes();
  1240. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  1241. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  1242. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  1243. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  1244. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  1245. enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
  1246. OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
  1247. }
  1248. public AgentCircuitData RequestClientInfo()
  1249. {
  1250. AgentCircuitData agentData = new AgentCircuitData();
  1251. agentData.AgentID = AgentId;
  1252. agentData.SessionID = m_sessionId;
  1253. agentData.SecureSessionID = SecureSessionId;
  1254. agentData.circuitcode = m_circuitCode;
  1255. agentData.child = false;
  1256. agentData.firstname = m_firstName;
  1257. agentData.lastname = m_lastName;
  1258. ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
  1259. if (capsModule == null) // can happen when shutting down.
  1260. return agentData;
  1261. agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
  1262. agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
  1263. return agentData;
  1264. }
  1265. public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
  1266. string capsURL)
  1267. {
  1268. Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  1269. //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
  1270. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  1271. // TODO: don't create new blocks if recycling an old packet
  1272. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  1273. newSimPack.AgentData.AgentID = AgentId;
  1274. newSimPack.AgentData.SessionID = m_sessionId;
  1275. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  1276. newSimPack.Info.Position = pos;
  1277. newSimPack.Info.LookAt = look;
  1278. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  1279. newSimPack.RegionData.RegionHandle = newRegionHandle;
  1280. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  1281. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  1282. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  1283. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  1284. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  1285. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  1286. newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
  1287. // Hack to get this out immediately and skip throttles
  1288. OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
  1289. }
  1290. internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
  1291. {
  1292. MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
  1293. // TODO: don't create new blocks if recycling an old packet
  1294. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1295. mapReply.AgentData.AgentID = AgentId;
  1296. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
  1297. mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
  1298. mapReply.AgentData.Flags = flag;
  1299. for (int i = 0; i < mapBlocks2.Length; i++)
  1300. {
  1301. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  1302. mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
  1303. //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
  1304. mapReply.Data[i].X = mapBlocks2[i].X;
  1305. mapReply.Data[i].Y = mapBlocks2[i].Y;
  1306. mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
  1307. mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
  1308. mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
  1309. mapReply.Data[i].Access = mapBlocks2[i].Access;
  1310. mapReply.Data[i].Agents = mapBlocks2[i].Agents;
  1311. // TODO: hookup varregion sim size here
  1312. mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
  1313. mapReply.Size[i].SizeX = 256;
  1314. mapReply.Size[i].SizeY = 256;
  1315. }
  1316. OutPacket(mapReply, ThrottleOutPacketType.Land);
  1317. }
  1318. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  1319. {
  1320. MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
  1321. int maxsend = 10;
  1322. //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
  1323. List<MapBlockData> sendingBlocks = new List<MapBlockData>();
  1324. for (int i = 0; i < mapBlocks2.Length; i++)
  1325. {
  1326. sendingBlocks.Add(mapBlocks2[i]);
  1327. if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
  1328. {
  1329. SendMapBlockSplit(sendingBlocks, flag);
  1330. sendingBlocks = new List<MapBlockData>();
  1331. }
  1332. }
  1333. }
  1334. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  1335. {
  1336. TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
  1337. tpLocal.Info.AgentID = AgentId;
  1338. tpLocal.Info.TeleportFlags = flags;
  1339. tpLocal.Info.LocationID = 2;
  1340. tpLocal.Info.LookAt = lookAt;
  1341. tpLocal.Info.Position = position;
  1342. // Hack to get this out immediately and skip throttles
  1343. OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
  1344. }
  1345. public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
  1346. uint flags, string capsURL)
  1347. {
  1348. //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
  1349. TeleportFinishPacket teleport = new TeleportFinishPacket();
  1350. teleport.Info.AgentID = AgentId;
  1351. teleport.Info.RegionHandle = regionHandle;
  1352. teleport.Info.SimAccess = simAccess;
  1353. teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
  1354. IPAddress oIP = newRegionEndPoint.Address;
  1355. byte[] byteIP = oIP.GetAddressBytes();
  1356. uint ip = (uint)byteIP[3] << 24;
  1357. ip += (uint)byteIP[2] << 16;
  1358. ip += (uint)byteIP[1] << 8;
  1359. ip += (uint)byteIP[0];
  1360. teleport.Info.SimIP = ip;
  1361. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  1362. teleport.Info.LocationID = 4;
  1363. teleport.Info.TeleportFlags = 1 << 4;
  1364. // Hack to get this out immediately and skip throttles.
  1365. OutPacket(teleport, ThrottleOutPacketType.Unknown);
  1366. }
  1367. /// <summary>
  1368. /// Inform the client that a teleport attempt has failed
  1369. /// </summary>
  1370. public void SendTeleportFailed(string reason)
  1371. {
  1372. TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
  1373. tpFailed.Info.AgentID = AgentId;
  1374. tpFailed.Info.Reason = Util.StringToBytes256(reason);
  1375. tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
  1376. // Hack to get this out immediately and skip throttles
  1377. OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
  1378. }
  1379. /// <summary>
  1380. ///
  1381. /// </summary>
  1382. public void SendTeleportStart(uint flags)
  1383. {
  1384. TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
  1385. //TeleportStartPacket tpStart = new TeleportStartPacket();
  1386. tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
  1387. // Hack to get this out immediately and skip throttles
  1388. OutPacket(tpStart, ThrottleOutPacketType.Unknown);
  1389. }
  1390. public void SendTeleportProgress(uint flags, string message)
  1391. {
  1392. TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
  1393. tpProgress.AgentData.AgentID = this.AgentId;
  1394. tpProgress.Info.TeleportFlags = flags;
  1395. tpProgress.Info.Message = Util.StringToBytes256(message);
  1396. // Hack to get this out immediately and skip throttles
  1397. OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
  1398. }
  1399. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
  1400. {
  1401. MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
  1402. money.MoneyData.AgentID = AgentId;
  1403. money.MoneyData.TransactionID = transaction;
  1404. money.MoneyData.TransactionSuccess = success;
  1405. money.MoneyData.Description = description;
  1406. money.MoneyData.MoneyBalance = balance;
  1407. money.TransactionInfo.TransactionType = transactionType;
  1408. money.TransactionInfo.SourceID = sourceID;
  1409. money.TransactionInfo.IsSourceGroup = sourceIsGroup;
  1410. money.TransactionInfo.DestID = destID;
  1411. money.TransactionInfo.IsDestGroup = destIsGroup;
  1412. money.TransactionInfo.Amount = amount;
  1413. money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
  1414. OutPacket(money, ThrottleOutPacketType.Task);
  1415. }
  1416. public void SendPayPrice(UUID objectID, int[] payPrice)
  1417. {
  1418. if (payPrice[0] == 0 &&
  1419. payPrice[1] == 0 &&
  1420. payPrice[2] == 0 &&
  1421. payPrice[3] == 0 &&
  1422. payPrice[4] == 0)
  1423. return;
  1424. PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
  1425. payPriceReply.ObjectData.ObjectID = objectID;
  1426. payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
  1427. payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
  1428. payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
  1429. payPriceReply.ButtonData[0].PayButton = payPrice[1];
  1430. payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
  1431. payPriceReply.ButtonData[1].PayButton = payPrice[2];
  1432. payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
  1433. payPriceReply.ButtonData[2].PayButton = payPrice[3];
  1434. payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
  1435. payPriceReply.ButtonData[3].PayButton = payPrice[4];
  1436. OutPacket(payPriceReply, ThrottleOutPacketType.Task);
  1437. }
  1438. public void SendStartPingCheck(byte seq)
  1439. {
  1440. StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
  1441. pc.Header.Reliable = false;
  1442. pc.PingID.PingID = seq;
  1443. // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
  1444. pc.PingID.OldestUnacked = 0;
  1445. OutPacket(pc, ThrottleOutPacketType.Unknown);
  1446. }
  1447. public void SendKillObject(List<uint> localIDs)
  1448. {
  1449. // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
  1450. KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
  1451. // TODO: don't create new blocks if recycling an old packet
  1452. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
  1453. for (int i = 0 ; i < localIDs.Count ; i++ )
  1454. {
  1455. kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
  1456. kill.ObjectData[i].ID = localIDs[i];
  1457. }
  1458. kill.Header.Reliable = true;
  1459. kill.Header.Zerocoded = true;
  1460. if (localIDs.Count == 1 && m_scene.GetScenePresence(localIDs[0]) != null)
  1461. {
  1462. OutPacket(kill, ThrottleOutPacketType.Task);
  1463. }
  1464. else
  1465. {
  1466. // We MUST lock for both manipulating the kill record and sending the packet, in order to avoid a race
  1467. // condition where a kill can be processed before an out-of-date update for the same object.
  1468. // ProcessEntityUpdates() also takes the m_killRecord lock.
  1469. lock (m_killRecord)
  1470. {
  1471. foreach (uint localID in localIDs)
  1472. m_killRecord.Add(localID);
  1473. // The throttle queue used here must match that being used for updates. Otherwise, there is a
  1474. // chance that a kill packet put on a separate queue will be sent to the client before an existing
  1475. // update packet on another queue. Receiving updates after kills results in unowned and undeletable
  1476. // scene objects in a viewer until that viewer is relogged in.
  1477. OutPacket(kill, ThrottleOutPacketType.Task);
  1478. }
  1479. }
  1480. }
  1481. /// <summary>
  1482. /// Send information about the items contained in a folder to the client.
  1483. /// </summary>
  1484. /// <remarks>
  1485. /// XXX This method needs some refactoring loving
  1486. /// </remarks>
  1487. /// <param name="ownerID">The owner of the folder</param>
  1488. /// <param name="folderID">The id of the folder</param>
  1489. /// <param name="items">The items contained in the folder identified by folderID</param>
  1490. /// <param name="folders"></param>
  1491. /// <param name="fetchFolders">Do we need to send folder information?</param>
  1492. /// <param name="fetchItems">Do we need to send item information?</param>
  1493. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
  1494. List<InventoryFolderBase> folders, int version,
  1495. bool fetchFolders, bool fetchItems)
  1496. {
  1497. // An inventory descendents packet consists of a single agent section and an inventory details
  1498. // section for each inventory item. The size of each inventory item is approximately 550 bytes.
  1499. // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
  1500. // packets containing metadata for in excess of 100 items. But in practice, there may be other
  1501. // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
  1502. //
  1503. // http://opensimulator.org/mantis/view.php?id=226
  1504. //
  1505. // for one example of this kind of thing. In fact, the Linden servers appear to only send about
  1506. // 6 to 7 items at a time, so let's stick with 6
  1507. int MAX_ITEMS_PER_PACKET = 5;
  1508. int MAX_FOLDERS_PER_PACKET = 6;
  1509. int totalItems = fetchItems ? items.Count : 0;
  1510. int totalFolders = fetchFolders ? folders.Count : 0;
  1511. int itemsSent = 0;
  1512. int foldersSent = 0;
  1513. int foldersToSend = 0;
  1514. int itemsToSend = 0;
  1515. InventoryDescendentsPacket currentPacket = null;
  1516. // Handle empty folders
  1517. //
  1518. if (totalItems == 0 && totalFolders == 0)
  1519. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
  1520. // To preserve SL compatibility, we will NOT combine folders and items in one packet
  1521. //
  1522. while (itemsSent < totalItems || foldersSent < totalFolders)
  1523. {
  1524. if (currentPacket == null) // Start a new packet
  1525. {
  1526. foldersToSend = totalFolders - foldersSent;
  1527. if (foldersToSend > MAX_FOLDERS_PER_PACKET)
  1528. foldersToSend = MAX_FOLDERS_PER_PACKET;
  1529. if (foldersToSend == 0)
  1530. {
  1531. itemsToSend = totalItems - itemsSent;
  1532. if (itemsToSend > MAX_ITEMS_PER_PACKET)
  1533. itemsToSend = MAX_ITEMS_PER_PACKET;
  1534. }
  1535. currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
  1536. }
  1537. if (foldersToSend-- > 0)
  1538. currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
  1539. else if (itemsToSend-- > 0)
  1540. currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
  1541. else
  1542. {
  1543. // m_log.DebugFormat(
  1544. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1545. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1546. currentPacket = null;
  1547. }
  1548. }
  1549. if (currentPacket != null)
  1550. {
  1551. // m_log.DebugFormat(
  1552. // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
  1553. OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
  1554. }
  1555. }
  1556. private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
  1557. {
  1558. InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
  1559. newBlock.FolderID = folder.ID;
  1560. newBlock.Name = Util.StringToBytes256(folder.Name);
  1561. newBlock.ParentID = folder.ParentID;
  1562. newBlock.Type = (sbyte)folder.Type;
  1563. return newBlock;
  1564. }
  1565. private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
  1566. {
  1567. InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
  1568. newBlock.ItemID = item.ID;
  1569. newBlock.AssetID = item.AssetID;
  1570. newBlock.CreatorID = item.CreatorIdAsUuid;
  1571. newBlock.BaseMask = item.BasePermissions;
  1572. newBlock.Description = Util.StringToBytes256(item.Description);
  1573. newBlock.EveryoneMask = item.EveryOnePermissions;
  1574. newBlock.OwnerMask = item.CurrentPermissions;
  1575. newBlock.FolderID = item.Folder;
  1576. newBlock.InvType = (sbyte)item.InvType;
  1577. newBlock.Name = Util.StringToBytes256(item.Name);
  1578. newBlock.NextOwnerMask = item.NextPermissions;
  1579. newBlock.OwnerID = item.Owner;
  1580. newBlock.Type = (sbyte)item.AssetType;
  1581. newBlock.GroupID = item.GroupID;
  1582. newBlock.GroupOwned = item.GroupOwned;
  1583. newBlock.GroupMask = item.GroupPermissions;
  1584. newBlock.CreationDate = item.CreationDate;
  1585. newBlock.SalePrice = item.SalePrice;
  1586. newBlock.SaleType = item.SaleType;
  1587. newBlock.Flags = item.Flags;
  1588. newBlock.CRC =
  1589. Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
  1590. newBlock.InvType, newBlock.Type,
  1591. newBlock.AssetID, newBlock.GroupID,
  1592. newBlock.SalePrice,
  1593. newBlock.OwnerID, newBlock.CreatorID,
  1594. newBlock.ItemID, newBlock.FolderID,
  1595. newBlock.EveryoneMask,
  1596. newBlock.Flags, newBlock.OwnerMask,
  1597. newBlock.GroupMask, newBlock.NextOwnerMask);
  1598. return newBlock;
  1599. }
  1600. private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
  1601. {
  1602. packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
  1603. packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
  1604. packet.FolderData[0].FolderID = UUID.Zero;
  1605. packet.FolderData[0].ParentID = UUID.Zero;
  1606. packet.FolderData[0].Type = -1;
  1607. packet.FolderData[0].Name = new byte[0];
  1608. }
  1609. private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
  1610. {
  1611. packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
  1612. packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
  1613. packet.ItemData[0].ItemID = UUID.Zero;
  1614. packet.ItemData[0].AssetID = UUID.Zero;
  1615. packet.ItemData[0].CreatorID = UUID.Zero;
  1616. packet.ItemData[0].BaseMask = 0;
  1617. packet.ItemData[0].Description = new byte[0];
  1618. packet.ItemData[0].EveryoneMask = 0;
  1619. packet.ItemData[0].OwnerMask = 0;
  1620. packet.ItemData[0].FolderID = UUID.Zero;
  1621. packet.ItemData[0].InvType = (sbyte)0;
  1622. packet.ItemData[0].Name = new byte[0];
  1623. packet.ItemData[0].NextOwnerMask = 0;
  1624. packet.ItemData[0].OwnerID = UUID.Zero;
  1625. packet.ItemData[0].Type = -1;
  1626. packet.ItemData[0].GroupID = UUID.Zero;
  1627. packet.ItemData[0].GroupOwned = false;
  1628. packet.ItemData[0].GroupMask = 0;
  1629. packet.ItemData[0].CreationDate = 0;
  1630. packet.ItemData[0].SalePrice = 0;
  1631. packet.ItemData[0].SaleType = 0;
  1632. packet.ItemData[0].Flags = 0;
  1633. // No need to add CRC
  1634. }
  1635. private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
  1636. {
  1637. InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
  1638. descend.Header.Zerocoded = true;
  1639. descend.AgentData.AgentID = AgentId;
  1640. descend.AgentData.OwnerID = ownerID;
  1641. descend.AgentData.FolderID = folderID;
  1642. descend.AgentData.Version = version;
  1643. descend.AgentData.Descendents = descendents;
  1644. if (folders > 0)
  1645. descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
  1646. else
  1647. AddNullFolderBlockToDecendentsPacket(ref descend);
  1648. if (items > 0)
  1649. descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
  1650. else
  1651. AddNullItemBlockToDescendentsPacket(ref descend);
  1652. return descend;
  1653. }
  1654. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  1655. {
  1656. // Fudge this value. It's only needed to make the CRC anyway
  1657. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1658. FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
  1659. // TODO: don't create new blocks if recycling an old packet
  1660. inventoryReply.AgentData.AgentID = AgentId;
  1661. inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
  1662. inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
  1663. inventoryReply.InventoryData[0].ItemID = item.ID;
  1664. inventoryReply.InventoryData[0].AssetID = item.AssetID;
  1665. inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
  1666. inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
  1667. inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
  1668. inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
  1669. inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
  1670. inventoryReply.InventoryData[0].FolderID = item.Folder;
  1671. inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
  1672. inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
  1673. inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
  1674. inventoryReply.InventoryData[0].OwnerID = item.Owner;
  1675. inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
  1676. inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
  1677. inventoryReply.InventoryData[0].GroupID = item.GroupID;
  1678. inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
  1679. inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
  1680. inventoryReply.InventoryData[0].Flags = item.Flags;
  1681. inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
  1682. inventoryReply.InventoryData[0].SaleType = item.SaleType;
  1683. inventoryReply.InventoryData[0].CRC =
  1684. Helpers.InventoryCRC(
  1685. 1000, 0, inventoryReply.InventoryData[0].InvType,
  1686. inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
  1687. inventoryReply.InventoryData[0].GroupID, 100,
  1688. inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
  1689. inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
  1690. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1691. FULL_MASK_PERMISSIONS);
  1692. inventoryReply.Header.Zerocoded = true;
  1693. OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
  1694. }
  1695. protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
  1696. {
  1697. // We will use the same transaction id for all the separate packets to be sent out in this update.
  1698. UUID transactionId = UUID.Random();
  1699. List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
  1700. = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1701. SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
  1702. if (folderDataBlocks.Count > 0)
  1703. {
  1704. // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
  1705. // Send these now
  1706. BulkUpdateInventoryPacket bulkUpdate
  1707. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1708. bulkUpdate.Header.Zerocoded = true;
  1709. bulkUpdate.AgentData.AgentID = AgentId;
  1710. bulkUpdate.AgentData.TransactionID = transactionId;
  1711. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1712. List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
  1713. bulkUpdate.ItemData = foo.ToArray();
  1714. //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
  1715. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1716. }
  1717. }
  1718. /// <summary>
  1719. /// Recursively construct bulk update packets to send folders and items
  1720. /// </summary>
  1721. /// <param name="folder"></param>
  1722. /// <param name="folderDataBlocks"></param>
  1723. /// <param name="transactionId"></param>
  1724. private void SendBulkUpdateInventoryFolderRecursive(
  1725. InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
  1726. UUID transactionId)
  1727. {
  1728. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1729. const int MAX_ITEMS_PER_PACKET = 5;
  1730. IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
  1731. // If there are any items then we have to start sending them off in this packet - the next folder will have
  1732. // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
  1733. // being used on the Linden grid at 20081203).
  1734. InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
  1735. List<InventoryItemBase> items = contents.Items;
  1736. while (items.Count > 0)
  1737. {
  1738. BulkUpdateInventoryPacket bulkUpdate
  1739. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1740. bulkUpdate.Header.Zerocoded = true;
  1741. bulkUpdate.AgentData.AgentID = AgentId;
  1742. bulkUpdate.AgentData.TransactionID = transactionId;
  1743. bulkUpdate.FolderData = folderDataBlocks.ToArray();
  1744. int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
  1745. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
  1746. for (int i = 0; i < itemsToSend; i++)
  1747. {
  1748. // Remove from the end of the list so that we don't incur a performance penalty
  1749. bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
  1750. items.RemoveAt(items.Count - 1);
  1751. }
  1752. //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
  1753. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1754. folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
  1755. // If we're going to be sending another items packet then it needs to contain just the folder to which those
  1756. // items belong.
  1757. if (items.Count > 0)
  1758. folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
  1759. }
  1760. List<InventoryFolderBase> subFolders = contents.Folders;
  1761. foreach (InventoryFolderBase subFolder in subFolders)
  1762. {
  1763. SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
  1764. }
  1765. }
  1766. /// <summary>
  1767. /// Generate a bulk update inventory data block for the given folder
  1768. /// </summary>
  1769. /// <param name="folder"></param>
  1770. /// <returns></returns>
  1771. private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
  1772. {
  1773. BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
  1774. folderBlock.FolderID = folder.ID;
  1775. folderBlock.ParentID = folder.ParentID;
  1776. //folderBlock.Type = -1;
  1777. folderBlock.Type = (sbyte)folder.Type;
  1778. folderBlock.Name = Util.StringToBytes256(folder.Name);
  1779. return folderBlock;
  1780. }
  1781. /// <summary>
  1782. /// Generate a bulk update inventory data block for the given item
  1783. /// </summary>
  1784. /// <param name="item"></param>
  1785. /// <returns></returns>
  1786. private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
  1787. {
  1788. BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
  1789. itemBlock.ItemID = item.ID;
  1790. itemBlock.AssetID = item.AssetID;
  1791. itemBlock.CreatorID = item.CreatorIdAsUuid;
  1792. itemBlock.BaseMask = item.BasePermissions;
  1793. itemBlock.Description = Util.StringToBytes256(item.Description);
  1794. itemBlock.EveryoneMask = item.EveryOnePermissions;
  1795. itemBlock.FolderID = item.Folder;
  1796. itemBlock.InvType = (sbyte)item.InvType;
  1797. itemBlock.Name = Util.StringToBytes256(item.Name);
  1798. itemBlock.NextOwnerMask = item.NextPermissions;
  1799. itemBlock.OwnerID = item.Owner;
  1800. itemBlock.OwnerMask = item.CurrentPermissions;
  1801. itemBlock.Type = (sbyte)item.AssetType;
  1802. itemBlock.GroupID = item.GroupID;
  1803. itemBlock.GroupOwned = item.GroupOwned;
  1804. itemBlock.GroupMask = item.GroupPermissions;
  1805. itemBlock.Flags = item.Flags;
  1806. itemBlock.SalePrice = item.SalePrice;
  1807. itemBlock.SaleType = item.SaleType;
  1808. itemBlock.CreationDate = item.CreationDate;
  1809. itemBlock.CRC =
  1810. Helpers.InventoryCRC(
  1811. 1000, 0, itemBlock.InvType,
  1812. itemBlock.Type, itemBlock.AssetID,
  1813. itemBlock.GroupID, 100,
  1814. itemBlock.OwnerID, itemBlock.CreatorID,
  1815. itemBlock.ItemID, itemBlock.FolderID,
  1816. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  1817. (uint)PermissionMask.All);
  1818. return itemBlock;
  1819. }
  1820. public void SendBulkUpdateInventory(InventoryNodeBase node)
  1821. {
  1822. if (node is InventoryItemBase)
  1823. SendBulkUpdateInventoryItem((InventoryItemBase)node);
  1824. else if (node is InventoryFolderBase)
  1825. SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
  1826. else if (node != null)
  1827. m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
  1828. else
  1829. m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
  1830. }
  1831. protected void SendBulkUpdateInventoryItem(InventoryItemBase item)
  1832. {
  1833. const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
  1834. BulkUpdateInventoryPacket bulkUpdate
  1835. = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
  1836. bulkUpdate.AgentData.AgentID = AgentId;
  1837. bulkUpdate.AgentData.TransactionID = UUID.Random();
  1838. bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
  1839. bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
  1840. bulkUpdate.FolderData[0].FolderID = UUID.Zero;
  1841. bulkUpdate.FolderData[0].ParentID = UUID.Zero;
  1842. bulkUpdate.FolderData[0].Type = -1;
  1843. bulkUpdate.FolderData[0].Name = new byte[0];
  1844. bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
  1845. bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
  1846. bulkUpdate.ItemData[0].ItemID = item.ID;
  1847. bulkUpdate.ItemData[0].AssetID = item.AssetID;
  1848. bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
  1849. bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
  1850. bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
  1851. bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
  1852. bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
  1853. bulkUpdate.ItemData[0].FolderID = item.Folder;
  1854. bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
  1855. bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
  1856. bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
  1857. bulkUpdate.ItemData[0].OwnerID = item.Owner;
  1858. bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
  1859. bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
  1860. bulkUpdate.ItemData[0].GroupID = item.GroupID;
  1861. bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
  1862. bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
  1863. bulkUpdate.ItemData[0].Flags = item.Flags;
  1864. bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
  1865. bulkUpdate.ItemData[0].SaleType = item.SaleType;
  1866. bulkUpdate.ItemData[0].CRC =
  1867. Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
  1868. bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
  1869. bulkUpdate.ItemData[0].GroupID, 100,
  1870. bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
  1871. bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
  1872. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1873. FULL_MASK_PERMISSIONS);
  1874. bulkUpdate.Header.Zerocoded = true;
  1875. OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
  1876. }
  1877. /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
  1878. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  1879. {
  1880. const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
  1881. UpdateCreateInventoryItemPacket InventoryReply
  1882. = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
  1883. PacketType.UpdateCreateInventoryItem);
  1884. // TODO: don't create new blocks if recycling an old packet
  1885. InventoryReply.AgentData.AgentID = AgentId;
  1886. InventoryReply.AgentData.SimApproved = true;
  1887. InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
  1888. InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
  1889. InventoryReply.InventoryData[0].ItemID = Item.ID;
  1890. InventoryReply.InventoryData[0].AssetID = Item.AssetID;
  1891. InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
  1892. InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
  1893. InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
  1894. InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
  1895. InventoryReply.InventoryData[0].FolderID = Item.Folder;
  1896. InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
  1897. InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
  1898. InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
  1899. InventoryReply.InventoryData[0].OwnerID = Item.Owner;
  1900. InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
  1901. InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
  1902. InventoryReply.InventoryData[0].CallbackID = callbackId;
  1903. InventoryReply.InventoryData[0].GroupID = Item.GroupID;
  1904. InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
  1905. InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
  1906. InventoryReply.InventoryData[0].Flags = Item.Flags;
  1907. InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
  1908. InventoryReply.InventoryData[0].SaleType = Item.SaleType;
  1909. InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
  1910. InventoryReply.InventoryData[0].CRC =
  1911. Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
  1912. InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
  1913. InventoryReply.InventoryData[0].GroupID, 100,
  1914. InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
  1915. InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
  1916. FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
  1917. FULL_MASK_PERMISSIONS);
  1918. InventoryReply.Header.Zerocoded = true;
  1919. OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
  1920. }
  1921. public void SendRemoveInventoryItem(UUID itemID)
  1922. {
  1923. RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
  1924. // TODO: don't create new blocks if recycling an old packet
  1925. remove.AgentData.AgentID = AgentId;
  1926. remove.AgentData.SessionID = m_sessionId;
  1927. remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
  1928. remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
  1929. remove.InventoryData[0].ItemID = itemID;
  1930. remove.Header.Zerocoded = true;
  1931. OutPacket(remove, ThrottleOutPacketType.Asset);
  1932. }
  1933. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  1934. {
  1935. ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
  1936. ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
  1937. ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
  1938. ddata.Controls = (uint)controls;
  1939. ddata.PassToAgent = passToAgent;
  1940. ddata.TakeControls = TakeControls;
  1941. data[0] = ddata;
  1942. scriptcontrol.Data = data;
  1943. OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
  1944. }
  1945. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  1946. {
  1947. ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
  1948. replytask.InventoryData.TaskID = taskID;
  1949. replytask.InventoryData.Serial = serial;
  1950. replytask.InventoryData.Filename = fileName;
  1951. OutPacket(replytask, ThrottleOutPacketType.Asset);
  1952. }
  1953. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  1954. {
  1955. SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
  1956. sendXfer.XferID.ID = xferID;
  1957. sendXfer.XferID.Packet = packet;
  1958. sendXfer.DataPacket.Data = data;
  1959. OutPacket(sendXfer, ThrottleOutPacketType.Asset);
  1960. }
  1961. public void SendAbortXferPacket(ulong xferID)
  1962. {
  1963. AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
  1964. xferItem.XferID.ID = xferID;
  1965. OutPacket(xferItem, ThrottleOutPacketType.Asset);
  1966. }
  1967. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
  1968. int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
  1969. int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
  1970. int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  1971. {
  1972. EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
  1973. economyData.Info.EnergyEfficiency = EnergyEfficiency;
  1974. economyData.Info.ObjectCapacity = ObjectCapacity;
  1975. economyData.Info.ObjectCount = ObjectCount;
  1976. economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
  1977. economyData.Info.PriceGroupCreate = PriceGroupCreate;
  1978. economyData.Info.PriceObjectClaim = PriceObjectClaim;
  1979. economyData.Info.PriceObjectRent = PriceObjectRent;
  1980. economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
  1981. economyData.Info.PriceParcelClaim = PriceParcelClaim;
  1982. economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
  1983. economyData.Info.PriceParcelRent = PriceParcelRent;
  1984. economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
  1985. economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
  1986. economyData.Info.PriceRentLight = PriceRentLight;
  1987. economyData.Info.PriceUpload = PriceUpload;
  1988. economyData.Info.TeleportMinPrice = TeleportMinPrice;
  1989. economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
  1990. economyData.Header.Reliable = true;
  1991. OutPacket(economyData, ThrottleOutPacketType.Task);
  1992. }
  1993. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  1994. {
  1995. //construct the AvatarPickerReply packet.
  1996. AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
  1997. replyPacket.AgentData.AgentID = AgentData.AgentID;
  1998. replyPacket.AgentData.QueryID = AgentData.QueryID;
  1999. //int i = 0;
  2000. List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
  2001. foreach (AvatarPickerReplyDataArgs arg in Data)
  2002. {
  2003. AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
  2004. db.AvatarID = arg.AvatarID;
  2005. db.FirstName = arg.FirstName;
  2006. db.LastName = arg.LastName;
  2007. data_block.Add(db);
  2008. }
  2009. replyPacket.Data = data_block.ToArray();
  2010. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  2011. }
  2012. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  2013. {
  2014. m_activeGroupID = activegroupid;
  2015. m_activeGroupName = groupname;
  2016. m_activeGroupPowers = grouppowers;
  2017. AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
  2018. sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
  2019. sendAgentDataUpdate.AgentData.AgentID = agentid;
  2020. sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
  2021. sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
  2022. sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
  2023. sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
  2024. sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
  2025. OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
  2026. }
  2027. /// <summary>
  2028. /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
  2029. /// blue information box in the bottom right hand corner.
  2030. /// </summary>
  2031. /// <param name="message"></param>
  2032. public void SendAlertMessage(string message)
  2033. {
  2034. AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
  2035. alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
  2036. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2037. alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
  2038. OutPacket(alertPack, ThrottleOutPacketType.Task);
  2039. }
  2040. /// <summary>
  2041. /// Send an agent alert message to the client.
  2042. /// </summary>
  2043. /// <param name="message"></param>
  2044. /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
  2045. /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
  2046. /// the AlertMessage packet).</param>
  2047. public void SendAgentAlertMessage(string message, bool modal)
  2048. {
  2049. OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
  2050. }
  2051. /// <summary>
  2052. /// Construct an agent alert packet
  2053. /// </summary>
  2054. /// <param name="message"></param>
  2055. /// <param name="modal"></param>
  2056. /// <returns></returns>
  2057. public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
  2058. {
  2059. // Prepend a slash to make the message come up in the top right
  2060. // again.
  2061. // Allow special formats to be sent from aware modules.
  2062. if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
  2063. message = "/" + message;
  2064. AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
  2065. alertPack.AgentData.AgentID = AgentId;
  2066. alertPack.AlertData.Message = Util.StringToBytes256(message);
  2067. alertPack.AlertData.Modal = modal;
  2068. return alertPack;
  2069. }
  2070. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
  2071. string url)
  2072. {
  2073. LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
  2074. loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
  2075. loadURL.Data.ObjectID = objectID;
  2076. loadURL.Data.OwnerID = ownerID;
  2077. loadURL.Data.OwnerIsGroup = groupOwned;
  2078. loadURL.Data.Message = Util.StringToBytes256(message);
  2079. loadURL.Data.URL = Util.StringToBytes256(url);
  2080. OutPacket(loadURL, ThrottleOutPacketType.Task);
  2081. }
  2082. public void SendDialog(
  2083. string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
  2084. UUID textureID, int ch, string[] buttonlabels)
  2085. {
  2086. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  2087. dialog.Data.ObjectID = objectID;
  2088. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  2089. // this is the username of the *owner*
  2090. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  2091. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  2092. dialog.Data.Message = Util.StringToBytes1024(msg);
  2093. dialog.Data.ImageID = textureID;
  2094. dialog.Data.ChatChannel = ch;
  2095. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
  2096. for (int i = 0; i < buttonlabels.Length; i++)
  2097. {
  2098. buttons[i] = new ScriptDialogPacket.ButtonsBlock();
  2099. buttons[i].ButtonLabel = Util.StringToBytes256(buttonlabels[i]);
  2100. }
  2101. dialog.Buttons = buttons;
  2102. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  2103. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  2104. dialog.OwnerData[0].OwnerID = ownerID;
  2105. OutPacket(dialog, ThrottleOutPacketType.Task);
  2106. }
  2107. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  2108. {
  2109. PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
  2110. // TODO: don't create new blocks if recycling an old packet
  2111. preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
  2112. preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
  2113. preSound.DataBlock[0].ObjectID = objectID;
  2114. preSound.DataBlock[0].OwnerID = ownerID;
  2115. preSound.DataBlock[0].SoundID = soundID;
  2116. preSound.Header.Zerocoded = true;
  2117. OutPacket(preSound, ThrottleOutPacketType.Task);
  2118. }
  2119. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  2120. {
  2121. AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
  2122. sound.DataBlock.SoundID = soundID;
  2123. sound.DataBlock.ObjectID = objectID;
  2124. sound.DataBlock.OwnerID = ownerID;
  2125. sound.DataBlock.Gain = gain;
  2126. sound.DataBlock.Flags = flags;
  2127. OutPacket(sound, ThrottleOutPacketType.Task);
  2128. }
  2129. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  2130. {
  2131. SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
  2132. sound.SoundData.SoundID = soundID;
  2133. sound.SoundData.OwnerID = ownerID;
  2134. sound.SoundData.ObjectID = objectID;
  2135. sound.SoundData.ParentID = parentID;
  2136. sound.SoundData.Handle = handle;
  2137. sound.SoundData.Position = position;
  2138. sound.SoundData.Gain = gain;
  2139. OutPacket(sound, ThrottleOutPacketType.Task);
  2140. }
  2141. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  2142. {
  2143. AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
  2144. sound.DataBlock.ObjectID = objectID;
  2145. sound.DataBlock.Gain = gain;
  2146. OutPacket(sound, ThrottleOutPacketType.Task);
  2147. }
  2148. public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  2149. {
  2150. // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
  2151. // So adjust for that
  2152. // Contributed by: Godfrey
  2153. if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
  2154. {
  2155. OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
  2156. }
  2157. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2158. viewertime.TimeInfo.SunDirection = Position;
  2159. viewertime.TimeInfo.SunAngVelocity = Velocity;
  2160. // Sun module used to add 6 hours to adjust for linden sun hour, adding here
  2161. // to prevent existing code from breaking if it assumed that 6 hours were included.
  2162. // 21600 == 6 hours * 60 minutes * 60 Seconds
  2163. viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
  2164. viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
  2165. viewertime.TimeInfo.SecPerYear = SecondsPerYear;
  2166. viewertime.TimeInfo.SunPhase = OrbitalPosition;
  2167. viewertime.Header.Reliable = false;
  2168. viewertime.Header.Zerocoded = true;
  2169. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2170. }
  2171. // Currently Deprecated
  2172. public void SendViewerTime(int phase)
  2173. {
  2174. /*
  2175. Console.WriteLine("SunPhase: {0}", phase);
  2176. SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
  2177. //viewertime.TimeInfo.SecPerDay = 86400;
  2178. //viewertime.TimeInfo.SecPerYear = 31536000;
  2179. viewertime.TimeInfo.SecPerDay = 1000;
  2180. viewertime.TimeInfo.SecPerYear = 365000;
  2181. viewertime.TimeInfo.SunPhase = 1;
  2182. int sunPhase = (phase + 2) / 2;
  2183. if ((sunPhase < 6) || (sunPhase > 36))
  2184. {
  2185. viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
  2186. Console.WriteLine("sending night");
  2187. }
  2188. else
  2189. {
  2190. if (sunPhase < 12)
  2191. {
  2192. sunPhase = 12;
  2193. }
  2194. sunPhase = sunPhase - 12;
  2195. float yValue = 0.1f * (sunPhase);
  2196. Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
  2197. if (yValue > 1.2f)
  2198. {
  2199. yValue = yValue - 1.2f;
  2200. }
  2201. yValue = Util.Clip(yValue, 0, 1);
  2202. if (sunPhase < 14)
  2203. {
  2204. yValue = 1 - yValue;
  2205. }
  2206. if (sunPhase < 12)
  2207. {
  2208. yValue *= -1;
  2209. }
  2210. viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
  2211. Console.WriteLine("sending sun update " + yValue);
  2212. }
  2213. viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
  2214. viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
  2215. viewertime.Header.Reliable = false;
  2216. OutPacket(viewertime, ThrottleOutPacketType.Task);
  2217. */
  2218. }
  2219. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  2220. {
  2221. ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
  2222. packet.Header.Reliable = false;
  2223. packet.Header.Zerocoded = true;
  2224. packet.AgentData.AgentID = AgentId;
  2225. packet.AgentData.SessionID = SessionId;
  2226. packet.Effect = effectBlocks;
  2227. // OutPacket(packet, ThrottleOutPacketType.State);
  2228. OutPacket(packet, ThrottleOutPacketType.Task);
  2229. }
  2230. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
  2231. string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
  2232. UUID partnerID)
  2233. {
  2234. AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
  2235. avatarReply.AgentData.AgentID = AgentId;
  2236. avatarReply.AgentData.AvatarID = avatarID;
  2237. if (aboutText != null)
  2238. avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
  2239. else
  2240. avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
  2241. avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
  2242. avatarReply.PropertiesData.CharterMember = charterMember;
  2243. if (flAbout != null)
  2244. avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
  2245. else
  2246. avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
  2247. avatarReply.PropertiesData.Flags = flags;
  2248. avatarReply.PropertiesData.FLImageID = flImageID;
  2249. avatarReply.PropertiesData.ImageID = imageID;
  2250. avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
  2251. avatarReply.PropertiesData.PartnerID = partnerID;
  2252. OutPacket(avatarReply, ThrottleOutPacketType.Task);
  2253. }
  2254. /// <summary>
  2255. /// Send the client an Estate message blue box pop-down with a single OK button
  2256. /// </summary>
  2257. /// <param name="FromAvatarID"></param>
  2258. /// <param name="fromSessionID"></param>
  2259. /// <param name="FromAvatarName"></param>
  2260. /// <param name="Message"></param>
  2261. public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
  2262. {
  2263. if (!SceneAgent.IsChildAgent)
  2264. SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
  2265. //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
  2266. }
  2267. public void SendLogoutPacket()
  2268. {
  2269. // I know this is a bit of a hack, however there are times when you don't
  2270. // want to send this, but still need to do the rest of the shutdown process
  2271. // this method gets called from the packet server.. which makes it practically
  2272. // impossible to do any other way.
  2273. if (m_SendLogoutPacketWhenClosing)
  2274. {
  2275. LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
  2276. // TODO: don't create new blocks if recycling an old packet
  2277. logReply.AgentData.AgentID = AgentId;
  2278. logReply.AgentData.SessionID = SessionId;
  2279. logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
  2280. logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
  2281. logReply.InventoryData[0].ItemID = UUID.Zero;
  2282. OutPacket(logReply, ThrottleOutPacketType.Task);
  2283. }
  2284. }
  2285. public void SendHealth(float health)
  2286. {
  2287. HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
  2288. healthpacket.HealthData.Health = health;
  2289. OutPacket(healthpacket, ThrottleOutPacketType.Task);
  2290. }
  2291. public void SendAgentOnline(UUID[] agentIDs)
  2292. {
  2293. OnlineNotificationPacket onp = new OnlineNotificationPacket();
  2294. OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2295. for (int i = 0; i < agentIDs.Length; i++)
  2296. {
  2297. OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
  2298. onpbl.AgentID = agentIDs[i];
  2299. onpb[i] = onpbl;
  2300. }
  2301. onp.AgentBlock = onpb;
  2302. onp.Header.Reliable = true;
  2303. OutPacket(onp, ThrottleOutPacketType.Task);
  2304. }
  2305. public void SendAgentOffline(UUID[] agentIDs)
  2306. {
  2307. OfflineNotificationPacket offp = new OfflineNotificationPacket();
  2308. OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
  2309. for (int i = 0; i < agentIDs.Length; i++)
  2310. {
  2311. OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
  2312. onpbl.AgentID = agentIDs[i];
  2313. offpb[i] = onpbl;
  2314. }
  2315. offp.AgentBlock = offpb;
  2316. offp.Header.Reliable = true;
  2317. OutPacket(offp, ThrottleOutPacketType.Task);
  2318. }
  2319. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
  2320. Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  2321. {
  2322. AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
  2323. avatarSitResponse.SitObject.ID = TargetID;
  2324. avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
  2325. avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
  2326. avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
  2327. avatarSitResponse.SitTransform.AutoPilot = autopilot;
  2328. avatarSitResponse.SitTransform.SitPosition = OffsetPos;
  2329. avatarSitResponse.SitTransform.SitRotation = SitOrientation;
  2330. OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
  2331. }
  2332. public void SendAdminResponse(UUID Token, uint AdminLevel)
  2333. {
  2334. GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
  2335. GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
  2336. GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
  2337. adb.AgentID = AgentId;
  2338. adb.SessionID = SessionId; // More security
  2339. gdb.GodLevel = (byte)AdminLevel;
  2340. gdb.Token = Token;
  2341. //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
  2342. respondPacket.GrantData = gdb;
  2343. respondPacket.AgentData = adb;
  2344. OutPacket(respondPacket, ThrottleOutPacketType.Task);
  2345. }
  2346. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  2347. {
  2348. m_groupPowers.Clear();
  2349. AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
  2350. AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
  2351. for (int i = 0; i < GroupMembership.Length; i++)
  2352. {
  2353. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  2354. AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
  2355. Group.AcceptNotices = GroupMembership[i].AcceptNotices;
  2356. Group.Contribution = GroupMembership[i].Contribution;
  2357. Group.GroupID = GroupMembership[i].GroupID;
  2358. Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
  2359. Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
  2360. Group.GroupPowers = GroupMembership[i].GroupPowers;
  2361. Groups[i] = Group;
  2362. }
  2363. Groupupdate.GroupData = Groups;
  2364. Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
  2365. Groupupdate.AgentData.AgentID = AgentId;
  2366. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2367. try
  2368. {
  2369. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2370. if (eq != null)
  2371. {
  2372. eq.GroupMembership(Groupupdate, this.AgentId);
  2373. }
  2374. }
  2375. catch (Exception ex)
  2376. {
  2377. m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
  2378. m_log.Warn("sending group membership data via UDP");
  2379. OutPacket(Groupupdate, ThrottleOutPacketType.Task);
  2380. }
  2381. }
  2382. public void SendPartPhysicsProprieties(ISceneEntity entity)
  2383. {
  2384. SceneObjectPart part = (SceneObjectPart)entity;
  2385. if (part != null && AgentId != UUID.Zero)
  2386. {
  2387. try
  2388. {
  2389. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  2390. if (eq != null)
  2391. {
  2392. uint localid = part.LocalId;
  2393. byte physshapetype = part.PhysicsShapeType;
  2394. float density = part.Density;
  2395. float friction = part.Friction;
  2396. float bounce = part.Restitution;
  2397. float gravmod = part.GravityModifier;
  2398. eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
  2399. }
  2400. }
  2401. catch (Exception ex)
  2402. {
  2403. m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
  2404. }
  2405. part.UpdatePhysRequired = false;
  2406. }
  2407. }
  2408. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  2409. {
  2410. UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
  2411. UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
  2412. UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
  2413. uidnamebloc.ID = groupLLUID;
  2414. uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
  2415. uidnameblock[0] = uidnamebloc;
  2416. pack.UUIDNameBlock = uidnameblock;
  2417. OutPacket(pack, ThrottleOutPacketType.Task);
  2418. }
  2419. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  2420. {
  2421. LandStatReplyPacket lsrp = new LandStatReplyPacket();
  2422. // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
  2423. LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
  2424. //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2425. // lsrepdb.
  2426. lsrp.RequestData.ReportType = reportType;
  2427. lsrp.RequestData.RequestFlags = requestFlags;
  2428. lsrp.RequestData.TotalObjectCount = resultCount;
  2429. for (int i = 0; i < lsrpia.Length; i++)
  2430. {
  2431. LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
  2432. lsrepdb.LocationX = lsrpia[i].LocationX;
  2433. lsrepdb.LocationY = lsrpia[i].LocationY;
  2434. lsrepdb.LocationZ = lsrpia[i].LocationZ;
  2435. lsrepdb.Score = lsrpia[i].Score;
  2436. lsrepdb.TaskID = lsrpia[i].TaskID;
  2437. lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
  2438. lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
  2439. lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
  2440. lsrepdba[i] = lsrepdb;
  2441. }
  2442. lsrp.ReportData = lsrepdba;
  2443. OutPacket(lsrp, ThrottleOutPacketType.Task);
  2444. }
  2445. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  2446. {
  2447. ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
  2448. scriptRunningReply.Script.ObjectID = objectID;
  2449. scriptRunningReply.Script.ItemID = itemID;
  2450. scriptRunningReply.Script.Running = running;
  2451. OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
  2452. }
  2453. public void SendAsset(AssetRequestToClient req)
  2454. {
  2455. if (req.AssetInf.Data == null)
  2456. {
  2457. m_log.ErrorFormat("Cannot send asset {0} ({1}), asset data is null",
  2458. req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
  2459. return;
  2460. }
  2461. //m_log.Debug("sending asset " + req.RequestAssetID);
  2462. TransferInfoPacket Transfer = new TransferInfoPacket();
  2463. Transfer.TransferInfo.ChannelType = 2;
  2464. Transfer.TransferInfo.Status = 0;
  2465. Transfer.TransferInfo.TargetType = 0;
  2466. if (req.AssetRequestSource == 2)
  2467. {
  2468. Transfer.TransferInfo.Params = new byte[20];
  2469. Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2470. int assType = req.AssetInf.Type;
  2471. Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
  2472. }
  2473. else if (req.AssetRequestSource == 3)
  2474. {
  2475. Transfer.TransferInfo.Params = req.Params;
  2476. // Transfer.TransferInfo.Params = new byte[100];
  2477. //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
  2478. //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
  2479. }
  2480. Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
  2481. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2482. Transfer.Header.Zerocoded = true;
  2483. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2484. if (req.NumPackets == 1)
  2485. {
  2486. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2487. TransferPacket.TransferData.Packet = 0;
  2488. TransferPacket.TransferData.ChannelType = 2;
  2489. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2490. TransferPacket.TransferData.Data = req.AssetInf.Data;
  2491. TransferPacket.TransferData.Status = 1;
  2492. TransferPacket.Header.Zerocoded = true;
  2493. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2494. }
  2495. else
  2496. {
  2497. int processedLength = 0;
  2498. int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
  2499. int packetNumber = 0;
  2500. while (processedLength < req.AssetInf.Data.Length)
  2501. {
  2502. TransferPacketPacket TransferPacket = new TransferPacketPacket();
  2503. TransferPacket.TransferData.Packet = packetNumber;
  2504. TransferPacket.TransferData.ChannelType = 2;
  2505. TransferPacket.TransferData.TransferID = req.TransferRequestID;
  2506. int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
  2507. byte[] chunk = new byte[chunkSize];
  2508. Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
  2509. TransferPacket.TransferData.Data = chunk;
  2510. // 0 indicates more packets to come, 1 indicates last packet
  2511. if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
  2512. {
  2513. TransferPacket.TransferData.Status = 0;
  2514. }
  2515. else
  2516. {
  2517. TransferPacket.TransferData.Status = 1;
  2518. }
  2519. TransferPacket.Header.Zerocoded = true;
  2520. OutPacket(TransferPacket, ThrottleOutPacketType.Asset);
  2521. processedLength += chunkSize;
  2522. packetNumber++;
  2523. }
  2524. }
  2525. }
  2526. public void SendAssetNotFound(AssetRequestToClient req)
  2527. {
  2528. TransferInfoPacket Transfer = new TransferInfoPacket();
  2529. Transfer.TransferInfo.ChannelType = 2;
  2530. Transfer.TransferInfo.Status = -2;
  2531. Transfer.TransferInfo.TargetType = 0;
  2532. Transfer.TransferInfo.Params = req.Params;
  2533. Transfer.TransferInfo.Size = 0;
  2534. Transfer.TransferInfo.TransferID = req.TransferRequestID;
  2535. Transfer.Header.Zerocoded = true;
  2536. OutPacket(Transfer, ThrottleOutPacketType.Asset);
  2537. }
  2538. public void SendTexture(AssetBase TextureAsset)
  2539. {
  2540. }
  2541. public void SendRegionHandle(UUID regionID, ulong handle)
  2542. {
  2543. RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
  2544. reply.ReplyBlock.RegionID = regionID;
  2545. reply.ReplyBlock.RegionHandle = handle;
  2546. OutPacket(reply, ThrottleOutPacketType.Land);
  2547. }
  2548. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  2549. {
  2550. float dwell = 0.0f;
  2551. IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
  2552. if (dwellModule != null)
  2553. dwell = dwellModule.GetDwell(land.GlobalID);
  2554. ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
  2555. reply.AgentData.AgentID = m_agentId;
  2556. reply.Data.ParcelID = parcelID;
  2557. reply.Data.OwnerID = land.OwnerID;
  2558. reply.Data.Name = Utils.StringToBytes(land.Name);
  2559. reply.Data.Desc = Utils.StringToBytes(land.Description);
  2560. reply.Data.ActualArea = land.Area;
  2561. reply.Data.BillableArea = land.Area; // TODO: what is this?
  2562. // Bit 0: Mature, bit 7: on sale, other bits: no idea
  2563. reply.Data.Flags = (byte)(
  2564. (info.AccessLevel > 13 ? (1 << 0) : 0) +
  2565. ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
  2566. Vector3 pos = land.UserLocation;
  2567. if (pos.Equals(Vector3.Zero))
  2568. {
  2569. pos = (land.AABBMax + land.AABBMin) * 0.5f;
  2570. }
  2571. reply.Data.GlobalX = info.RegionLocX + x;
  2572. reply.Data.GlobalY = info.RegionLocY + y;
  2573. reply.Data.GlobalZ = pos.Z;
  2574. reply.Data.SimName = Utils.StringToBytes(info.RegionName);
  2575. reply.Data.SnapshotID = land.SnapshotID;
  2576. reply.Data.Dwell = dwell;
  2577. reply.Data.SalePrice = land.SalePrice;
  2578. reply.Data.AuctionID = (int)land.AuctionID;
  2579. OutPacket(reply, ThrottleOutPacketType.Land);
  2580. }
  2581. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  2582. {
  2583. ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
  2584. packet.Data.ObjectName = Utils.StringToBytes(objName);
  2585. packet.Data.SimName = Utils.StringToBytes(simName);
  2586. packet.Data.SimPosition = pos;
  2587. packet.Data.LookAt = lookAt;
  2588. OutPacket(packet, ThrottleOutPacketType.Task);
  2589. }
  2590. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  2591. {
  2592. DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2593. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2594. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2595. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2596. packet.AgentData.AgentID = AgentId;
  2597. packet.QueryData[0].QueryID = queryID;
  2598. DirPlacesReplyPacket.QueryRepliesBlock[] replies =
  2599. new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2600. DirPlacesReplyPacket.StatusDataBlock[] status =
  2601. new DirPlacesReplyPacket.StatusDataBlock[0];
  2602. packet.QueryReplies = replies;
  2603. packet.StatusData = status;
  2604. foreach (DirPlacesReplyData d in data)
  2605. {
  2606. int idx = replies.Length;
  2607. Array.Resize(ref replies, idx + 1);
  2608. Array.Resize(ref status, idx + 1);
  2609. replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
  2610. status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
  2611. replies[idx].ParcelID = d.parcelID;
  2612. replies[idx].Name = Utils.StringToBytes(d.name);
  2613. replies[idx].ForSale = d.forSale;
  2614. replies[idx].Auction = d.auction;
  2615. replies[idx].Dwell = d.dwell;
  2616. status[idx].Status = d.Status;
  2617. packet.QueryReplies = replies;
  2618. packet.StatusData = status;
  2619. if (packet.Length >= 1000)
  2620. {
  2621. OutPacket(packet, ThrottleOutPacketType.Task);
  2622. packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
  2623. packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
  2624. packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
  2625. packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
  2626. packet.AgentData.AgentID = AgentId;
  2627. packet.QueryData[0].QueryID = queryID;
  2628. replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
  2629. status = new DirPlacesReplyPacket.StatusDataBlock[0];
  2630. }
  2631. }
  2632. if (replies.Length > 0 || data.Length == 0)
  2633. OutPacket(packet, ThrottleOutPacketType.Task);
  2634. }
  2635. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  2636. {
  2637. DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
  2638. packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
  2639. packet.AgentData.AgentID = AgentId;
  2640. packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
  2641. packet.QueryData.QueryID = queryID;
  2642. packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
  2643. data.Length];
  2644. int i = 0;
  2645. foreach (DirPeopleReplyData d in data)
  2646. {
  2647. packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
  2648. packet.QueryReplies[i].AgentID = d.agentID;
  2649. packet.QueryReplies[i].FirstName =
  2650. Utils.StringToBytes(d.firstName);
  2651. packet.QueryReplies[i].LastName =
  2652. Utils.StringToBytes(d.lastName);
  2653. packet.QueryReplies[i].Group =
  2654. Utils.StringToBytes(d.group);
  2655. packet.QueryReplies[i].Online = d.online;
  2656. packet.QueryReplies[i].Reputation = d.reputation;
  2657. i++;
  2658. }
  2659. OutPacket(packet, ThrottleOutPacketType.Task);
  2660. }
  2661. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  2662. {
  2663. DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
  2664. packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
  2665. packet.AgentData.AgentID = AgentId;
  2666. packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
  2667. packet.QueryData.QueryID = queryID;
  2668. packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
  2669. data.Length];
  2670. packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
  2671. data.Length];
  2672. int i = 0;
  2673. foreach (DirEventsReplyData d in data)
  2674. {
  2675. packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
  2676. packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
  2677. packet.QueryReplies[i].OwnerID = d.ownerID;
  2678. packet.QueryReplies[i].Name =
  2679. Utils.StringToBytes(d.name);
  2680. packet.QueryReplies[i].EventID = d.eventID;
  2681. packet.QueryReplies[i].Date =
  2682. Utils.StringToBytes(d.date);
  2683. packet.QueryReplies[i].UnixTime = d.unixTime;
  2684. packet.QueryReplies[i].EventFlags = d.eventFlags;
  2685. packet.StatusData[i].Status = d.Status;
  2686. i++;
  2687. }
  2688. OutPacket(packet, ThrottleOutPacketType.Task);
  2689. }
  2690. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  2691. {
  2692. DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
  2693. packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
  2694. packet.AgentData.AgentID = AgentId;
  2695. packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
  2696. packet.QueryData.QueryID = queryID;
  2697. packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
  2698. data.Length];
  2699. int i = 0;
  2700. foreach (DirGroupsReplyData d in data)
  2701. {
  2702. packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
  2703. packet.QueryReplies[i].GroupID = d.groupID;
  2704. packet.QueryReplies[i].GroupName =
  2705. Utils.StringToBytes(d.groupName);
  2706. packet.QueryReplies[i].Members = d.members;
  2707. packet.QueryReplies[i].SearchOrder = d.searchOrder;
  2708. i++;
  2709. }
  2710. OutPacket(packet, ThrottleOutPacketType.Task);
  2711. }
  2712. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  2713. {
  2714. DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
  2715. packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
  2716. packet.AgentData.AgentID = AgentId;
  2717. packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
  2718. packet.QueryData.QueryID = queryID;
  2719. packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
  2720. data.Length];
  2721. packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
  2722. data.Length];
  2723. int i = 0;
  2724. foreach (DirClassifiedReplyData d in data)
  2725. {
  2726. packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
  2727. packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
  2728. packet.QueryReplies[i].ClassifiedID = d.classifiedID;
  2729. packet.QueryReplies[i].Name =
  2730. Utils.StringToBytes(d.name);
  2731. packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
  2732. packet.QueryReplies[i].CreationDate = d.creationDate;
  2733. packet.QueryReplies[i].ExpirationDate = d.expirationDate;
  2734. packet.QueryReplies[i].PriceForListing = d.price;
  2735. packet.StatusData[i].Status = d.Status;
  2736. i++;
  2737. }
  2738. OutPacket(packet, ThrottleOutPacketType.Task);
  2739. }
  2740. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  2741. {
  2742. DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
  2743. packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
  2744. packet.AgentData.AgentID = AgentId;
  2745. packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
  2746. packet.QueryData.QueryID = queryID;
  2747. packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
  2748. data.Length];
  2749. int i = 0;
  2750. foreach (DirLandReplyData d in data)
  2751. {
  2752. packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
  2753. packet.QueryReplies[i].ParcelID = d.parcelID;
  2754. packet.QueryReplies[i].Name =
  2755. Utils.StringToBytes(d.name);
  2756. packet.QueryReplies[i].Auction = d.auction;
  2757. packet.QueryReplies[i].ForSale = d.forSale;
  2758. packet.QueryReplies[i].SalePrice = d.salePrice;
  2759. packet.QueryReplies[i].ActualArea = d.actualArea;
  2760. i++;
  2761. }
  2762. OutPacket(packet, ThrottleOutPacketType.Task);
  2763. }
  2764. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  2765. {
  2766. DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
  2767. packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
  2768. packet.AgentData.AgentID = AgentId;
  2769. packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
  2770. packet.QueryData.QueryID = queryID;
  2771. packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
  2772. data.Length];
  2773. int i = 0;
  2774. foreach (DirPopularReplyData d in data)
  2775. {
  2776. packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
  2777. packet.QueryReplies[i].ParcelID = d.parcelID;
  2778. packet.QueryReplies[i].Name =
  2779. Utils.StringToBytes(d.name);
  2780. packet.QueryReplies[i].Dwell = d.dwell;
  2781. i++;
  2782. }
  2783. OutPacket(packet, ThrottleOutPacketType.Task);
  2784. }
  2785. public void SendEventInfoReply(EventData data)
  2786. {
  2787. EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
  2788. packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
  2789. packet.AgentData.AgentID = AgentId;
  2790. packet.EventData = new EventInfoReplyPacket.EventDataBlock();
  2791. packet.EventData.EventID = data.eventID;
  2792. packet.EventData.Creator = Utils.StringToBytes(data.creator);
  2793. packet.EventData.Name = Utils.StringToBytes(data.name);
  2794. packet.EventData.Category = Utils.StringToBytes(data.category);
  2795. packet.EventData.Desc = Utils.StringToBytes(data.description);
  2796. packet.EventData.Date = Utils.StringToBytes(data.date);
  2797. packet.EventData.DateUTC = data.dateUTC;
  2798. packet.EventData.Duration = data.duration;
  2799. packet.EventData.Cover = data.cover;
  2800. packet.EventData.Amount = data.amount;
  2801. packet.EventData.SimName = Utils.StringToBytes(data.simName);
  2802. packet.EventData.GlobalPos = new Vector3d(data.globalPos);
  2803. packet.EventData.EventFlags = data.eventFlags;
  2804. OutPacket(packet, ThrottleOutPacketType.Task);
  2805. }
  2806. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  2807. {
  2808. MapItemReplyPacket mirplk = new MapItemReplyPacket();
  2809. mirplk.AgentData.AgentID = AgentId;
  2810. mirplk.RequestData.ItemType = mapitemtype;
  2811. mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
  2812. for (int i = 0; i < replies.Length; i++)
  2813. {
  2814. MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
  2815. mrdata.X = replies[i].x;
  2816. mrdata.Y = replies[i].y;
  2817. mrdata.ID = replies[i].id;
  2818. mrdata.Extra = replies[i].Extra;
  2819. mrdata.Extra2 = replies[i].Extra2;
  2820. mrdata.Name = Utils.StringToBytes(replies[i].name);
  2821. mirplk.Data[i] = mrdata;
  2822. }
  2823. //m_log.Debug(mirplk.ToString());
  2824. OutPacket(mirplk, ThrottleOutPacketType.Task);
  2825. }
  2826. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  2827. {
  2828. // a bit special, as this uses AgentID to store the source instead
  2829. // of the destination. The destination (the receiver) goes into destID
  2830. OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
  2831. p.AgentData.AgentID = srcID;
  2832. p.AgentData.SessionID = UUID.Zero;
  2833. p.AgentBlock.DestID = AgentId;
  2834. p.AgentBlock.TransactionID = transactionID;
  2835. OutPacket(p, ThrottleOutPacketType.Task);
  2836. }
  2837. public void SendAcceptCallingCard(UUID transactionID)
  2838. {
  2839. AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
  2840. p.AgentData.AgentID = AgentId;
  2841. p.AgentData.SessionID = UUID.Zero;
  2842. p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
  2843. p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
  2844. p.FolderData[0].FolderID = UUID.Zero;
  2845. OutPacket(p, ThrottleOutPacketType.Task);
  2846. }
  2847. public void SendDeclineCallingCard(UUID transactionID)
  2848. {
  2849. DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
  2850. p.AgentData.AgentID = AgentId;
  2851. p.AgentData.SessionID = UUID.Zero;
  2852. p.TransactionBlock.TransactionID = transactionID;
  2853. OutPacket(p, ThrottleOutPacketType.Task);
  2854. }
  2855. public void SendTerminateFriend(UUID exFriendID)
  2856. {
  2857. TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
  2858. p.AgentData.AgentID = AgentId;
  2859. p.AgentData.SessionID = SessionId;
  2860. p.ExBlock.OtherID = exFriendID;
  2861. OutPacket(p, ThrottleOutPacketType.Task);
  2862. }
  2863. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  2864. {
  2865. OSDMap llsd = new OSDMap(3);
  2866. OSDArray AgentData = new OSDArray(1);
  2867. OSDMap AgentDataMap = new OSDMap(1);
  2868. AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
  2869. AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
  2870. AgentData.Add(AgentDataMap);
  2871. llsd.Add("AgentData", AgentData);
  2872. OSDArray GroupData = new OSDArray(data.Length);
  2873. OSDArray NewGroupData = new OSDArray(data.Length);
  2874. foreach (GroupMembershipData m in data)
  2875. {
  2876. OSDMap GroupDataMap = new OSDMap(6);
  2877. OSDMap NewGroupDataMap = new OSDMap(1);
  2878. GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
  2879. GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
  2880. GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
  2881. GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
  2882. GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
  2883. GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
  2884. NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
  2885. GroupData.Add(GroupDataMap);
  2886. NewGroupData.Add(NewGroupDataMap);
  2887. }
  2888. llsd.Add("GroupData", GroupData);
  2889. llsd.Add("NewGroupData", NewGroupData);
  2890. IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
  2891. if (eq != null)
  2892. {
  2893. eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
  2894. }
  2895. }
  2896. public void SendJoinGroupReply(UUID groupID, bool success)
  2897. {
  2898. JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
  2899. p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
  2900. p.AgentData.AgentID = AgentId;
  2901. p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
  2902. p.GroupData.GroupID = groupID;
  2903. p.GroupData.Success = success;
  2904. OutPacket(p, ThrottleOutPacketType.Task);
  2905. }
  2906. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  2907. {
  2908. EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
  2909. p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
  2910. p.AgentData.AgentID = agentID;
  2911. p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
  2912. p.GroupData.GroupID = groupID;
  2913. p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
  2914. p.EjectData.Success = success;
  2915. OutPacket(p, ThrottleOutPacketType.Task);
  2916. }
  2917. public void SendLeaveGroupReply(UUID groupID, bool success)
  2918. {
  2919. LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
  2920. p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
  2921. p.AgentData.AgentID = AgentId;
  2922. p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
  2923. p.GroupData.GroupID = groupID;
  2924. p.GroupData.Success = success;
  2925. OutPacket(p, ThrottleOutPacketType.Task);
  2926. }
  2927. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  2928. {
  2929. if (classifiedID.Length != name.Length)
  2930. return;
  2931. AvatarClassifiedReplyPacket ac =
  2932. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  2933. PacketType.AvatarClassifiedReply);
  2934. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  2935. ac.AgentData.AgentID = AgentId;
  2936. ac.AgentData.TargetID = targetID;
  2937. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
  2938. int i;
  2939. for (i = 0; i < classifiedID.Length; i++)
  2940. {
  2941. ac.Data[i].ClassifiedID = classifiedID[i];
  2942. ac.Data[i].Name = Utils.StringToBytes(name[i]);
  2943. }
  2944. OutPacket(ac, ThrottleOutPacketType.Task);
  2945. }
  2946. 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)
  2947. {
  2948. ClassifiedInfoReplyPacket cr =
  2949. (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
  2950. PacketType.ClassifiedInfoReply);
  2951. cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
  2952. cr.AgentData.AgentID = AgentId;
  2953. cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
  2954. cr.Data.ClassifiedID = classifiedID;
  2955. cr.Data.CreatorID = creatorID;
  2956. cr.Data.CreationDate = creationDate;
  2957. cr.Data.ExpirationDate = expirationDate;
  2958. cr.Data.Category = category;
  2959. cr.Data.Name = Utils.StringToBytes(name);
  2960. cr.Data.Desc = Utils.StringToBytes(description);
  2961. cr.Data.ParcelID = parcelID;
  2962. cr.Data.ParentEstate = parentEstate;
  2963. cr.Data.SnapshotID = snapshotID;
  2964. cr.Data.SimName = Utils.StringToBytes(simName);
  2965. cr.Data.PosGlobal = new Vector3d(globalPos);
  2966. cr.Data.ParcelName = Utils.StringToBytes(parcelName);
  2967. cr.Data.ClassifiedFlags = classifiedFlags;
  2968. cr.Data.PriceForListing = price;
  2969. OutPacket(cr, ThrottleOutPacketType.Task);
  2970. }
  2971. public void SendAgentDropGroup(UUID groupID)
  2972. {
  2973. AgentDropGroupPacket dg =
  2974. (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
  2975. PacketType.AgentDropGroup);
  2976. dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
  2977. dg.AgentData.AgentID = AgentId;
  2978. dg.AgentData.GroupID = groupID;
  2979. OutPacket(dg, ThrottleOutPacketType.Task);
  2980. }
  2981. public void SendAvatarNotesReply(UUID targetID, string text)
  2982. {
  2983. AvatarNotesReplyPacket an =
  2984. (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
  2985. PacketType.AvatarNotesReply);
  2986. an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
  2987. an.AgentData.AgentID = AgentId;
  2988. an.Data = new AvatarNotesReplyPacket.DataBlock();
  2989. an.Data.TargetID = targetID;
  2990. an.Data.Notes = Utils.StringToBytes(text);
  2991. OutPacket(an, ThrottleOutPacketType.Task);
  2992. }
  2993. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  2994. {
  2995. AvatarPicksReplyPacket ap =
  2996. (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
  2997. PacketType.AvatarPicksReply);
  2998. ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
  2999. ap.AgentData.AgentID = AgentId;
  3000. ap.AgentData.TargetID = targetID;
  3001. ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
  3002. int i = 0;
  3003. foreach (KeyValuePair<UUID, string> pick in picks)
  3004. {
  3005. ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
  3006. ap.Data[i].PickID = pick.Key;
  3007. ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
  3008. i++;
  3009. }
  3010. OutPacket(ap, ThrottleOutPacketType.Task);
  3011. }
  3012. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  3013. {
  3014. AvatarClassifiedReplyPacket ac =
  3015. (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
  3016. PacketType.AvatarClassifiedReply);
  3017. ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
  3018. ac.AgentData.AgentID = AgentId;
  3019. ac.AgentData.TargetID = targetID;
  3020. ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
  3021. int i = 0;
  3022. foreach (KeyValuePair<UUID, string> classified in classifieds)
  3023. {
  3024. ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
  3025. ac.Data[i].ClassifiedID = classified.Key;
  3026. ac.Data[i].Name = Utils.StringToBytes(classified.Value);
  3027. i++;
  3028. }
  3029. OutPacket(ac, ThrottleOutPacketType.Task);
  3030. }
  3031. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  3032. {
  3033. ParcelDwellReplyPacket pd =
  3034. (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
  3035. PacketType.ParcelDwellReply);
  3036. pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
  3037. pd.AgentData.AgentID = AgentId;
  3038. pd.Data = new ParcelDwellReplyPacket.DataBlock();
  3039. pd.Data.LocalID = localID;
  3040. pd.Data.ParcelID = parcelID;
  3041. pd.Data.Dwell = dwell;
  3042. OutPacket(pd, ThrottleOutPacketType.Land);
  3043. }
  3044. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  3045. {
  3046. UserInfoReplyPacket ur =
  3047. (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
  3048. PacketType.UserInfoReply);
  3049. string Visible = "hidden";
  3050. if (visible)
  3051. Visible = "default";
  3052. ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
  3053. ur.AgentData.AgentID = AgentId;
  3054. ur.UserData = new UserInfoReplyPacket.UserDataBlock();
  3055. ur.UserData.IMViaEMail = imViaEmail;
  3056. ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
  3057. ur.UserData.EMail = Utils.StringToBytes(email);
  3058. OutPacket(ur, ThrottleOutPacketType.Task);
  3059. }
  3060. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  3061. {
  3062. CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
  3063. createGroupReply.AgentData =
  3064. new CreateGroupReplyPacket.AgentDataBlock();
  3065. createGroupReply.ReplyData =
  3066. new CreateGroupReplyPacket.ReplyDataBlock();
  3067. createGroupReply.AgentData.AgentID = AgentId;
  3068. createGroupReply.ReplyData.GroupID = groupID;
  3069. createGroupReply.ReplyData.Success = success;
  3070. createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
  3071. OutPacket(createGroupReply, ThrottleOutPacketType.Task);
  3072. }
  3073. public void SendUseCachedMuteList()
  3074. {
  3075. UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
  3076. useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
  3077. useCachedMuteList.AgentData.AgentID = AgentId;
  3078. OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
  3079. }
  3080. public void SendMuteListUpdate(string filename)
  3081. {
  3082. MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
  3083. muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
  3084. muteListUpdate.MuteData.AgentID = AgentId;
  3085. muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
  3086. OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
  3087. }
  3088. 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)
  3089. {
  3090. PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
  3091. pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
  3092. pickInfoReply.AgentData.AgentID = AgentId;
  3093. pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
  3094. pickInfoReply.Data.PickID = pickID;
  3095. pickInfoReply.Data.CreatorID = creatorID;
  3096. pickInfoReply.Data.TopPick = topPick;
  3097. pickInfoReply.Data.ParcelID = parcelID;
  3098. pickInfoReply.Data.Name = Utils.StringToBytes(name);
  3099. pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
  3100. pickInfoReply.Data.SnapshotID = snapshotID;
  3101. pickInfoReply.Data.User = Utils.StringToBytes(user);
  3102. pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
  3103. pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
  3104. pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
  3105. pickInfoReply.Data.SortOrder = sortOrder;
  3106. pickInfoReply.Data.Enabled = enabled;
  3107. OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
  3108. }
  3109. #endregion Scene/Avatar to Client
  3110. // Gesture
  3111. #region Appearance/ Wearables Methods
  3112. public void SendWearables(AvatarWearable[] wearables, int serial)
  3113. {
  3114. AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
  3115. aw.AgentData.AgentID = AgentId;
  3116. aw.AgentData.SerialNum = (uint)serial;
  3117. aw.AgentData.SessionID = m_sessionId;
  3118. int count = 0;
  3119. for (int i = 0; i < wearables.Length; i++)
  3120. count += wearables[i].Count;
  3121. // TODO: don't create new blocks if recycling an old packet
  3122. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
  3123. AgentWearablesUpdatePacket.WearableDataBlock awb;
  3124. int idx = 0;
  3125. for (int i = 0; i < wearables.Length; i++)
  3126. {
  3127. for (int j = 0; j < wearables[i].Count; j++)
  3128. {
  3129. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  3130. awb.WearableType = (byte)i;
  3131. awb.AssetID = wearables[i][j].AssetID;
  3132. awb.ItemID = wearables[i][j].ItemID;
  3133. aw.WearableData[idx] = awb;
  3134. idx++;
  3135. // m_log.DebugFormat(
  3136. // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
  3137. // awb.ItemID, awb.AssetID, i, Name);
  3138. }
  3139. }
  3140. OutPacket(aw, ThrottleOutPacketType.Task);
  3141. }
  3142. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  3143. {
  3144. // m_log.DebugFormat(
  3145. // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
  3146. // agentID, textureEntry.Length, Name, AgentId);
  3147. AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
  3148. // TODO: don't create new blocks if recycling an old packet
  3149. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
  3150. avp.ObjectData.TextureEntry = textureEntry;
  3151. AvatarAppearancePacket.VisualParamBlock avblock = null;
  3152. for (int i = 0; i < visualParams.Length; i++)
  3153. {
  3154. avblock = new AvatarAppearancePacket.VisualParamBlock();
  3155. avblock.ParamValue = visualParams[i];
  3156. avp.VisualParam[i] = avblock;
  3157. }
  3158. avp.Sender.IsTrial = false;
  3159. avp.Sender.ID = agentID;
  3160. avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
  3161. //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
  3162. OutPacket(avp, ThrottleOutPacketType.Task);
  3163. }
  3164. public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  3165. {
  3166. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
  3167. AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
  3168. // TODO: don't create new blocks if recycling an old packet
  3169. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
  3170. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  3171. ani.Sender.ID = sourceAgentId;
  3172. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
  3173. ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
  3174. for (int i = 0; i < animations.Length; ++i)
  3175. {
  3176. ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
  3177. ani.AnimationList[i].AnimID = animations[i];
  3178. ani.AnimationList[i].AnimSequenceID = seqs[i];
  3179. ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
  3180. if (objectIDs[i].Equals(sourceAgentId))
  3181. ani.AnimationSourceList[i].ObjectID = UUID.Zero;
  3182. else
  3183. ani.AnimationSourceList[i].ObjectID = objectIDs[i];
  3184. }
  3185. ani.Header.Reliable = false;
  3186. OutPacket(ani, ThrottleOutPacketType.Task);
  3187. }
  3188. #endregion
  3189. #region Avatar Packet/Data Sending Methods
  3190. /// <summary>
  3191. /// Send an ObjectUpdate packet with information about an avatar
  3192. /// </summary>
  3193. public void SendAvatarDataImmediate(ISceneEntity avatar)
  3194. {
  3195. // m_log.DebugFormat(
  3196. // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
  3197. // avatar.Name, avatar.UUID, Name, AgentId);
  3198. ScenePresence presence = avatar as ScenePresence;
  3199. if (presence == null)
  3200. return;
  3201. ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3202. objupdate.Header.Zerocoded = true;
  3203. objupdate.RegionData.RegionHandle = presence.RegionHandle;
  3204. objupdate.RegionData.TimeDilation = ushort.MaxValue;
  3205. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  3206. objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
  3207. OutPacket(objupdate, ThrottleOutPacketType.Task);
  3208. // We need to record the avatar local id since the root prim of an attachment points to this.
  3209. // m_attachmentsSent.Add(avatar.LocalId);
  3210. }
  3211. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  3212. {
  3213. // We don't need to update inactive clients.
  3214. if (!IsActive)
  3215. return;
  3216. CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
  3217. loc.Header.Reliable = false;
  3218. // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
  3219. // a CoarseLocationUpdate packet is received. Oh well.
  3220. int total = Math.Min(CoarseLocations.Count, 60);
  3221. CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
  3222. loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
  3223. loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
  3224. int selfindex = -1;
  3225. for (int i = 0; i < total; i++)
  3226. {
  3227. CoarseLocationUpdatePacket.LocationBlock lb =
  3228. new CoarseLocationUpdatePacket.LocationBlock();
  3229. lb.X = (byte)CoarseLocations[i].X;
  3230. lb.Y = (byte)CoarseLocations[i].Y;
  3231. lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
  3232. loc.Location[i] = lb;
  3233. loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
  3234. loc.AgentData[i].AgentID = users[i];
  3235. if (users[i] == AgentId)
  3236. selfindex = i;
  3237. }
  3238. ib.You = (short)selfindex;
  3239. ib.Prey = -1;
  3240. loc.Index = ib;
  3241. OutPacket(loc, ThrottleOutPacketType.Task);
  3242. }
  3243. #endregion Avatar Packet/Data Sending Methods
  3244. #region Primitive Packet/Data Sending Methods
  3245. /// <summary>
  3246. /// Generate one of the object update packets based on PrimUpdateFlags
  3247. /// and broadcast the packet to clients
  3248. /// </summary>
  3249. public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
  3250. {
  3251. //double priority = m_prioritizer.GetUpdatePriority(this, entity);
  3252. uint priority = m_prioritizer.GetUpdatePriority(this, entity);
  3253. lock (m_entityUpdates.SyncRoot)
  3254. m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
  3255. }
  3256. /// <summary>
  3257. /// Requeue an EntityUpdate when it was not acknowledged by the client.
  3258. /// We will update the priority and put it in the correct queue, merging update flags
  3259. /// with any other updates that may be queued for the same entity.
  3260. /// The original update time is used for the merged update.
  3261. /// </summary>
  3262. private void ResendPrimUpdate(EntityUpdate update)
  3263. {
  3264. // If the update exists in priority queue, it will be updated.
  3265. // If it does not exist then it will be added with the current (rather than its original) priority
  3266. uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
  3267. lock (m_entityUpdates.SyncRoot)
  3268. m_entityUpdates.Enqueue(priority, update);
  3269. }
  3270. /// <summary>
  3271. /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
  3272. /// We will update the priority and put it in the correct queue, merging update flags
  3273. /// with any other updates that may be queued for the same entity.
  3274. /// The original update time is used for the merged update.
  3275. /// </summary>
  3276. private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
  3277. {
  3278. // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
  3279. // Remove the update packet from the list of packets waiting for acknowledgement
  3280. // because we are requeuing the list of updates. They will be resent in new packets
  3281. // with the most recent state and priority.
  3282. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3283. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3284. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3285. // We're not going to worry about interlock yet since its not currently critical that this total count
  3286. // is 100% correct
  3287. m_udpServer.PacketsResentCount++;
  3288. foreach (EntityUpdate update in updates)
  3289. ResendPrimUpdate(update);
  3290. }
  3291. // OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3292. // OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3293. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3294. // OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3295. //
  3296. // OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3297. // OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3298. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3299. // OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3300. private void ProcessEntityUpdates(int maxUpdates)
  3301. {
  3302. OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
  3303. OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
  3304. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3305. OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
  3306. OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3307. OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3308. OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3309. OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
  3310. // objectUpdateBlocks.Value.Clear();
  3311. // compressedUpdateBlocks.Value.Clear();
  3312. // terseUpdateBlocks.Value.Clear();
  3313. // terseAgentUpdateBlocks.Value.Clear();
  3314. // objectUpdates.Value.Clear();
  3315. // compressedUpdates.Value.Clear();
  3316. // terseUpdates.Value.Clear();
  3317. // terseAgentUpdates.Value.Clear();
  3318. // Check to see if this is a flush
  3319. if (maxUpdates <= 0)
  3320. {
  3321. maxUpdates = Int32.MaxValue;
  3322. }
  3323. int updatesThisCall = 0;
  3324. // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
  3325. // condition where a kill can be processed before an out-of-date update for the same object.
  3326. lock (m_killRecord)
  3327. {
  3328. float avgTimeDilation = 1.0f;
  3329. IEntityUpdate iupdate;
  3330. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3331. while (updatesThisCall < maxUpdates)
  3332. {
  3333. lock (m_entityUpdates.SyncRoot)
  3334. if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
  3335. break;
  3336. EntityUpdate update = (EntityUpdate)iupdate;
  3337. avgTimeDilation += update.TimeDilation;
  3338. avgTimeDilation *= 0.5f;
  3339. if (update.Entity is SceneObjectPart)
  3340. {
  3341. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3342. // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
  3343. // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
  3344. // safety measure.
  3345. //
  3346. // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
  3347. // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
  3348. // updates and kills on different threads with different scheduling strategies, hence this protection.
  3349. //
  3350. // This doesn't appear to apply to child prims - a client will happily ignore these updates
  3351. // after the root prim has been deleted.
  3352. if (m_killRecord.Contains(part.LocalId))
  3353. {
  3354. // m_log.WarnFormat(
  3355. // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
  3356. // part.LocalId, Name);
  3357. continue;
  3358. }
  3359. if (part.ParentGroup.IsAttachment && m_disableFacelights)
  3360. {
  3361. if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
  3362. part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
  3363. {
  3364. part.Shape.LightEntry = false;
  3365. }
  3366. }
  3367. if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
  3368. {
  3369. // Ensure that mesh has at least 8 valid faces
  3370. part.Shape.ProfileBegin = 12500;
  3371. part.Shape.ProfileEnd = 0;
  3372. part.Shape.ProfileHollow = 27500;
  3373. }
  3374. }
  3375. #region UpdateFlags to packet type conversion
  3376. PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
  3377. bool canUseCompressed = true;
  3378. bool canUseImproved = true;
  3379. // Compressed object updates only make sense for LL primitives
  3380. if (!(update.Entity is SceneObjectPart))
  3381. {
  3382. canUseCompressed = false;
  3383. }
  3384. if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
  3385. {
  3386. canUseCompressed = false;
  3387. canUseImproved = false;
  3388. }
  3389. else
  3390. {
  3391. if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
  3392. updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
  3393. updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
  3394. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3395. {
  3396. canUseCompressed = false;
  3397. }
  3398. if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
  3399. updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
  3400. updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
  3401. updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
  3402. updateFlags.HasFlag(PrimUpdateFlags.Text) ||
  3403. updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
  3404. updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
  3405. updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
  3406. updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
  3407. updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
  3408. updateFlags.HasFlag(PrimUpdateFlags.Material) ||
  3409. updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
  3410. updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
  3411. updateFlags.HasFlag(PrimUpdateFlags.Joint))
  3412. {
  3413. canUseImproved = false;
  3414. }
  3415. }
  3416. #endregion UpdateFlags to packet type conversion
  3417. #region Block Construction
  3418. // TODO: Remove this once we can build compressed updates
  3419. canUseCompressed = false;
  3420. if (!canUseImproved && !canUseCompressed)
  3421. {
  3422. ObjectUpdatePacket.ObjectDataBlock updateBlock;
  3423. if (update.Entity is ScenePresence)
  3424. {
  3425. updateBlock = CreateAvatarUpdateBlock((ScenePresence)update.Entity);
  3426. }
  3427. else
  3428. {
  3429. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3430. updateBlock = CreatePrimUpdateBlock(part, AgentId);
  3431. // If the part has become a private hud since the update was scheduled then we do not
  3432. // want to send it to other avatars.
  3433. if (part.ParentGroup.IsAttachment
  3434. && part.ParentGroup.HasPrivateAttachmentPoint
  3435. && part.ParentGroup.AttachedAvatar != AgentId)
  3436. continue;
  3437. // If the part has since been deleted, then drop the update. In the case of attachments,
  3438. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3439. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3440. // of the test above).
  3441. //
  3442. // Actual deletions (kills) happen in another method.
  3443. if (part.ParentGroup.IsDeleted)
  3444. continue;
  3445. }
  3446. objectUpdateBlocks.Value.Add(updateBlock);
  3447. objectUpdates.Value.Add(update);
  3448. }
  3449. else if (!canUseImproved)
  3450. {
  3451. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3452. ObjectUpdateCompressedPacket.ObjectDataBlock compressedBlock
  3453. = CreateCompressedUpdateBlock(part, updateFlags);
  3454. // If the part has since been deleted, then drop the update. In the case of attachments,
  3455. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3456. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3457. // of the test above).
  3458. //
  3459. // Actual deletions (kills) happen in another method.
  3460. if (part.ParentGroup.IsDeleted)
  3461. continue;
  3462. compressedUpdateBlocks.Value.Add(compressedBlock);
  3463. compressedUpdates.Value.Add(update);
  3464. }
  3465. else
  3466. {
  3467. if (update.Entity is ScenePresence && ((ScenePresence)update.Entity).UUID == AgentId)
  3468. {
  3469. // Self updates go into a special list
  3470. terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
  3471. terseAgentUpdates.Value.Add(update);
  3472. }
  3473. else
  3474. {
  3475. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseUpdateBlock
  3476. = CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures));
  3477. // Everything else goes here
  3478. if (update.Entity is SceneObjectPart)
  3479. {
  3480. SceneObjectPart part = (SceneObjectPart)update.Entity;
  3481. // If the part has become a private hud since the update was scheduled then we do not
  3482. // want to send it to other avatars.
  3483. if (part.ParentGroup.IsAttachment
  3484. && part.ParentGroup.HasPrivateAttachmentPoint
  3485. && part.ParentGroup.AttachedAvatar != AgentId)
  3486. continue;
  3487. // If the part has since been deleted, then drop the update. In the case of attachments,
  3488. // this is to avoid spurious updates to other viewers since post-processing of attachments
  3489. // has to change the IsAttachment flag for various reasons (which will end up in a pass
  3490. // of the test above).
  3491. //
  3492. // Actual deletions (kills) happen in another method.
  3493. if (part.ParentGroup.IsDeleted)
  3494. continue;
  3495. }
  3496. terseUpdateBlocks.Value.Add(terseUpdateBlock);
  3497. terseUpdates.Value.Add(update);
  3498. }
  3499. }
  3500. ++updatesThisCall;
  3501. #endregion Block Construction
  3502. }
  3503. #region Packet Sending
  3504. ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f);
  3505. if (terseAgentUpdateBlocks.IsValueCreated)
  3506. {
  3507. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
  3508. ImprovedTerseObjectUpdatePacket packet
  3509. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
  3510. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3511. packet.RegionData.TimeDilation = timeDilation;
  3512. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3513. for (int i = 0; i < blocks.Count; i++)
  3514. packet.ObjectData[i] = blocks[i];
  3515. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3516. OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseAgentUpdates.Value, oPacket); });
  3517. }
  3518. if (objectUpdateBlocks.IsValueCreated)
  3519. {
  3520. List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
  3521. ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
  3522. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3523. packet.RegionData.TimeDilation = timeDilation;
  3524. packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3525. for (int i = 0; i < blocks.Count; i++)
  3526. packet.ObjectData[i] = blocks[i];
  3527. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3528. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(objectUpdates.Value, oPacket); });
  3529. }
  3530. if (compressedUpdateBlocks.IsValueCreated)
  3531. {
  3532. List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
  3533. ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
  3534. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3535. packet.RegionData.TimeDilation = timeDilation;
  3536. packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
  3537. for (int i = 0; i < blocks.Count; i++)
  3538. packet.ObjectData[i] = blocks[i];
  3539. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3540. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(compressedUpdates.Value, oPacket); });
  3541. }
  3542. if (terseUpdateBlocks.IsValueCreated)
  3543. {
  3544. List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
  3545. ImprovedTerseObjectUpdatePacket packet
  3546. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  3547. PacketType.ImprovedTerseObjectUpdate);
  3548. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  3549. packet.RegionData.TimeDilation = timeDilation;
  3550. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
  3551. for (int i = 0; i < blocks.Count; i++)
  3552. packet.ObjectData[i] = blocks[i];
  3553. // If any of the packets created from this call go unacknowledged, all of the updates will be resent
  3554. OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
  3555. }
  3556. }
  3557. #endregion Packet Sending
  3558. }
  3559. public void ReprioritizeUpdates()
  3560. {
  3561. lock (m_entityUpdates.SyncRoot)
  3562. m_entityUpdates.Reprioritize(UpdatePriorityHandler);
  3563. }
  3564. private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
  3565. {
  3566. if (entity != null)
  3567. {
  3568. priority = m_prioritizer.GetUpdatePriority(this, entity);
  3569. return true;
  3570. }
  3571. return false;
  3572. }
  3573. public void FlushPrimUpdates()
  3574. {
  3575. m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
  3576. while (m_entityUpdates.Count > 0)
  3577. ProcessEntityUpdates(-1);
  3578. }
  3579. #endregion Primitive Packet/Data Sending Methods
  3580. // These are used to implement an adaptive backoff in the number
  3581. // of updates converted to packets. Since we don't want packets
  3582. // to sit in the queue with old data, only convert enough updates
  3583. // to packets that can be sent in 200ms.
  3584. private Int32 m_LastQueueFill = 0;
  3585. private Int32 m_maxUpdates = 0;
  3586. void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
  3587. {
  3588. // if (!m_udpServer.IsRunningOutbound)
  3589. // return;
  3590. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3591. {
  3592. // if (!m_udpServer.IsRunningOutbound)
  3593. // return;
  3594. if (m_maxUpdates == 0 || m_LastQueueFill == 0)
  3595. {
  3596. m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
  3597. }
  3598. else
  3599. {
  3600. if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
  3601. m_maxUpdates += 5;
  3602. else
  3603. m_maxUpdates = m_maxUpdates >> 1;
  3604. }
  3605. m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
  3606. m_LastQueueFill = Util.EnvironmentTickCount();
  3607. if (m_entityUpdates.Count > 0)
  3608. ProcessEntityUpdates(m_maxUpdates);
  3609. if (m_entityProps.Count > 0)
  3610. ProcessEntityPropertyRequests(m_maxUpdates);
  3611. }
  3612. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3613. ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
  3614. }
  3615. internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
  3616. {
  3617. bool hasUpdates = false;
  3618. if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
  3619. {
  3620. if (m_entityUpdates.Count > 0)
  3621. hasUpdates = true;
  3622. else if (m_entityProps.Count > 0)
  3623. hasUpdates = true;
  3624. }
  3625. if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
  3626. {
  3627. if (ImageManager.HasUpdates())
  3628. hasUpdates = true;
  3629. }
  3630. return hasUpdates;
  3631. }
  3632. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  3633. {
  3634. AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
  3635. newPack.AssetBlock.Type = AssetType;
  3636. newPack.AssetBlock.Success = Success;
  3637. newPack.AssetBlock.UUID = AssetFullID;
  3638. newPack.Header.Zerocoded = true;
  3639. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3640. }
  3641. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  3642. {
  3643. RequestXferPacket newPack = new RequestXferPacket();
  3644. newPack.XferID.ID = XferID;
  3645. newPack.XferID.VFileType = AssetType;
  3646. newPack.XferID.VFileID = vFileID;
  3647. newPack.XferID.FilePath = FilePath;
  3648. newPack.XferID.Filename = FileName;
  3649. newPack.Header.Zerocoded = true;
  3650. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3651. }
  3652. public void SendConfirmXfer(ulong xferID, uint PacketID)
  3653. {
  3654. ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
  3655. newPack.XferID.ID = xferID;
  3656. newPack.XferID.Packet = PacketID;
  3657. newPack.Header.Zerocoded = true;
  3658. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3659. }
  3660. public void SendInitiateDownload(string simFileName, string clientFileName)
  3661. {
  3662. InitiateDownloadPacket newPack = new InitiateDownloadPacket();
  3663. newPack.AgentData.AgentID = AgentId;
  3664. newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
  3665. newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
  3666. OutPacket(newPack, ThrottleOutPacketType.Asset);
  3667. }
  3668. public void SendImageFirstPart(
  3669. ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  3670. {
  3671. ImageDataPacket im = new ImageDataPacket();
  3672. im.Header.Reliable = false;
  3673. im.ImageID.Packets = numParts;
  3674. im.ImageID.ID = ImageUUID;
  3675. if (ImageSize > 0)
  3676. im.ImageID.Size = ImageSize;
  3677. im.ImageData.Data = ImageData;
  3678. im.ImageID.Codec = imageCodec;
  3679. im.Header.Zerocoded = true;
  3680. OutPacket(im, ThrottleOutPacketType.Texture);
  3681. }
  3682. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  3683. {
  3684. ImagePacketPacket im = new ImagePacketPacket();
  3685. im.Header.Reliable = false;
  3686. im.ImageID.Packet = partNumber;
  3687. im.ImageID.ID = imageUuid;
  3688. im.ImageData.Data = imageData;
  3689. OutPacket(im, ThrottleOutPacketType.Texture);
  3690. }
  3691. public void SendImageNotFound(UUID imageid)
  3692. {
  3693. ImageNotInDatabasePacket notFoundPacket
  3694. = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
  3695. notFoundPacket.ImageID.ID = imageid;
  3696. OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
  3697. }
  3698. public void SendShutdownConnectionNotice()
  3699. {
  3700. OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
  3701. }
  3702. public void SendSimStats(SimStats stats)
  3703. {
  3704. SimStatsPacket pack = new SimStatsPacket();
  3705. pack.Region = new SimStatsPacket.RegionBlock();
  3706. pack.Region.RegionX = stats.RegionX;
  3707. pack.Region.RegionY = stats.RegionY;
  3708. pack.Region.RegionFlags = stats.RegionFlags;
  3709. pack.Region.ObjectCapacity = stats.ObjectCapacity;
  3710. //pack.Region = //stats.RegionBlock;
  3711. pack.Stat = stats.StatsBlock;
  3712. pack.Header.Reliable = false;
  3713. pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
  3714. OutPacket(pack, ThrottleOutPacketType.Task);
  3715. }
  3716. private class ObjectPropertyUpdate : IEntityUpdate
  3717. {
  3718. internal bool SendFamilyProps;
  3719. internal bool SendObjectProps;
  3720. public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
  3721. : base(entity,flags)
  3722. {
  3723. SendFamilyProps = sendfam;
  3724. SendObjectProps = sendobj;
  3725. }
  3726. public void Update(ObjectPropertyUpdate update)
  3727. {
  3728. SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
  3729. SendObjectProps = SendObjectProps || update.SendObjectProps;
  3730. // other properties may need to be updated by base class
  3731. base.Update(update);
  3732. }
  3733. }
  3734. public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
  3735. {
  3736. uint priority = 0; // time based ordering only
  3737. lock (m_entityProps.SyncRoot)
  3738. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
  3739. }
  3740. private void ResendPropertyUpdate(ObjectPropertyUpdate update)
  3741. {
  3742. uint priority = 0;
  3743. lock (m_entityProps.SyncRoot)
  3744. m_entityProps.Enqueue(priority, update);
  3745. }
  3746. private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
  3747. {
  3748. // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
  3749. // Remove the update packet from the list of packets waiting for acknowledgement
  3750. // because we are requeuing the list of updates. They will be resent in new packets
  3751. // with the most recent state.
  3752. m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
  3753. // Count this as a resent packet since we are going to requeue all of the updates contained in it
  3754. Interlocked.Increment(ref m_udpClient.PacketsResent);
  3755. // We're not going to worry about interlock yet since its not currently critical that this total count
  3756. // is 100% correct
  3757. m_udpServer.PacketsResentCount++;
  3758. foreach (ObjectPropertyUpdate update in updates)
  3759. ResendPropertyUpdate(update);
  3760. }
  3761. public void SendObjectPropertiesReply(ISceneEntity entity)
  3762. {
  3763. uint priority = 0; // time based ordering only
  3764. lock (m_entityProps.SyncRoot)
  3765. m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
  3766. }
  3767. private void ProcessEntityPropertyRequests(int maxUpdates)
  3768. {
  3769. OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
  3770. new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
  3771. OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
  3772. new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
  3773. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
  3774. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3775. OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
  3776. new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
  3777. IEntityUpdate iupdate;
  3778. Int32 timeinqueue; // this is just debugging code & can be dropped later
  3779. int updatesThisCall = 0;
  3780. while (updatesThisCall < m_maxUpdates)
  3781. {
  3782. lock (m_entityProps.SyncRoot)
  3783. if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
  3784. break;
  3785. ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
  3786. if (update.SendFamilyProps)
  3787. {
  3788. if (update.Entity is SceneObjectPart)
  3789. {
  3790. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3791. ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
  3792. objectFamilyBlocks.Value.Add(objPropDB);
  3793. familyUpdates.Value.Add(update);
  3794. }
  3795. }
  3796. if (update.SendObjectProps)
  3797. {
  3798. if (update.Entity is SceneObjectPart)
  3799. {
  3800. SceneObjectPart sop = (SceneObjectPart)update.Entity;
  3801. ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
  3802. objectPropertiesBlocks.Value.Add(objPropDB);
  3803. propertyUpdates.Value.Add(update);
  3804. }
  3805. }
  3806. updatesThisCall++;
  3807. }
  3808. // Int32 ppcnt = 0;
  3809. // Int32 pbcnt = 0;
  3810. if (objectPropertiesBlocks.IsValueCreated)
  3811. {
  3812. List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
  3813. List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
  3814. ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3815. packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
  3816. for (int i = 0; i < blocks.Count; i++)
  3817. packet.ObjectData[i] = blocks[i];
  3818. packet.Header.Zerocoded = true;
  3819. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3820. // of the object rather than the properties when the packet was created
  3821. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3822. delegate(OutgoingPacket oPacket)
  3823. {
  3824. ResendPropertyUpdates(updates, oPacket);
  3825. });
  3826. // pbcnt += blocks.Count;
  3827. // ppcnt++;
  3828. }
  3829. // Int32 fpcnt = 0;
  3830. // Int32 fbcnt = 0;
  3831. if (objectFamilyBlocks.IsValueCreated)
  3832. {
  3833. List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
  3834. // one packet per object block... uggh...
  3835. for (int i = 0; i < blocks.Count; i++)
  3836. {
  3837. ObjectPropertiesFamilyPacket packet =
  3838. (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
  3839. packet.ObjectData = blocks[i];
  3840. packet.Header.Zerocoded = true;
  3841. // Pass in the delegate so that if this packet needs to be resent, we send the current properties
  3842. // of the object rather than the properties when the packet was created
  3843. List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
  3844. updates.Add(familyUpdates.Value[i]);
  3845. OutPacket(packet, ThrottleOutPacketType.Task, true,
  3846. delegate(OutgoingPacket oPacket)
  3847. {
  3848. ResendPropertyUpdates(updates, oPacket);
  3849. });
  3850. // fpcnt++;
  3851. // fbcnt++;
  3852. }
  3853. }
  3854. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
  3855. // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
  3856. }
  3857. private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
  3858. {
  3859. ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
  3860. block.RequestFlags = requestFlags;
  3861. block.ObjectID = sop.UUID;
  3862. if (sop.OwnerID == sop.GroupID)
  3863. block.OwnerID = UUID.Zero;
  3864. else
  3865. block.OwnerID = sop.OwnerID;
  3866. block.GroupID = sop.GroupID;
  3867. block.BaseMask = sop.BaseMask;
  3868. block.OwnerMask = sop.OwnerMask;
  3869. block.GroupMask = sop.GroupMask;
  3870. block.EveryoneMask = sop.EveryoneMask;
  3871. block.NextOwnerMask = sop.NextOwnerMask;
  3872. // TODO: More properties are needed in SceneObjectPart!
  3873. block.OwnershipCost = sop.OwnershipCost;
  3874. block.SaleType = sop.ObjectSaleType;
  3875. block.SalePrice = sop.SalePrice;
  3876. block.Category = sop.Category;
  3877. block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
  3878. block.Name = Util.StringToBytes256(sop.Name);
  3879. block.Description = Util.StringToBytes256(sop.Description);
  3880. return block;
  3881. }
  3882. private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
  3883. {
  3884. //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
  3885. // TODO: don't create new blocks if recycling an old packet
  3886. ObjectPropertiesPacket.ObjectDataBlock block =
  3887. new ObjectPropertiesPacket.ObjectDataBlock();
  3888. block.ObjectID = sop.UUID;
  3889. block.Name = Util.StringToBytes256(sop.Name);
  3890. block.Description = Util.StringToBytes256(sop.Description);
  3891. block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
  3892. block.CreatorID = sop.CreatorID;
  3893. block.GroupID = sop.GroupID;
  3894. block.LastOwnerID = sop.LastOwnerID;
  3895. if (sop.OwnerID == sop.GroupID)
  3896. block.OwnerID = UUID.Zero;
  3897. else
  3898. block.OwnerID = sop.OwnerID;
  3899. block.ItemID = sop.FromUserInventoryItemID;
  3900. block.FolderID = UUID.Zero; // sog.FromFolderID ??
  3901. block.FromTaskID = UUID.Zero; // ???
  3902. block.InventorySerial = (short)sop.InventorySerial;
  3903. SceneObjectPart root = sop.ParentGroup.RootPart;
  3904. block.TouchName = Util.StringToBytes256(root.TouchName);
  3905. // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
  3906. // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
  3907. // copy is really needed since it's less efficient to be constantly recreating this byte array.
  3908. // using (MemoryStream memStream = new MemoryStream())
  3909. // {
  3910. // using (BinaryWriter binWriter = new BinaryWriter(memStream))
  3911. // {
  3912. // for (int i = 0; i < sop.GetNumberOfSides(); i++)
  3913. // {
  3914. // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
  3915. //
  3916. // UUID textureID;
  3917. //
  3918. // if (teFace != null)
  3919. // textureID = teFace.TextureID;
  3920. // else
  3921. // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
  3922. //
  3923. // binWriter.Write(textureID.GetBytes());
  3924. // }
  3925. //
  3926. // block.TextureID = memStream.ToArray();
  3927. // }
  3928. // }
  3929. block.TextureID = new byte[0]; // TextureID ???
  3930. block.SitName = Util.StringToBytes256(root.SitName);
  3931. block.OwnerMask = root.OwnerMask;
  3932. block.NextOwnerMask = root.NextOwnerMask;
  3933. block.GroupMask = root.GroupMask;
  3934. block.EveryoneMask = root.EveryoneMask;
  3935. block.BaseMask = root.BaseMask;
  3936. block.SaleType = root.ObjectSaleType;
  3937. block.SalePrice = root.SalePrice;
  3938. return block;
  3939. }
  3940. #region Estate Data Sending Methods
  3941. private static bool convertParamStringToBool(byte[] field)
  3942. {
  3943. string s = Utils.BytesToString(field);
  3944. if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
  3945. {
  3946. return true;
  3947. }
  3948. return false;
  3949. }
  3950. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  3951. {
  3952. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3953. packet.AgentData.TransactionID = UUID.Random();
  3954. packet.AgentData.AgentID = AgentId;
  3955. packet.AgentData.SessionID = SessionId;
  3956. packet.MethodData.Invoice = invoice;
  3957. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  3958. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
  3959. for (int i = 0; i < (6 + Data.Length); i++)
  3960. {
  3961. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  3962. }
  3963. int j = 0;
  3964. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  3965. returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
  3966. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3967. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3968. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3969. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  3970. j = 2; // Agents
  3971. if ((code & 2) != 0)
  3972. j = 3; // Groups
  3973. if ((code & 8) != 0)
  3974. j = 5; // Managers
  3975. returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
  3976. j = 6;
  3977. for (int i = 0; i < Data.Length; i++)
  3978. {
  3979. returnblock[j].Parameter = Data[i].GetBytes(); j++;
  3980. }
  3981. packet.ParamList = returnblock;
  3982. packet.Header.Reliable = true;
  3983. OutPacket(packet, ThrottleOutPacketType.Task);
  3984. }
  3985. public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
  3986. {
  3987. List<UUID> BannedUsers = new List<UUID>();
  3988. for (int i = 0; i < bl.Length; i++)
  3989. {
  3990. if (bl[i] == null)
  3991. continue;
  3992. if (bl[i].BannedUserID == UUID.Zero)
  3993. continue;
  3994. BannedUsers.Add(bl[i].BannedUserID);
  3995. if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
  3996. {
  3997. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  3998. packet.AgentData.TransactionID = UUID.Random();
  3999. packet.AgentData.AgentID = AgentId;
  4000. packet.AgentData.SessionID = SessionId;
  4001. packet.MethodData.Invoice = invoice;
  4002. packet.MethodData.Method = Utils.StringToBytes("setaccess");
  4003. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
  4004. int j;
  4005. for (j = 0; j < (6 + BannedUsers.Count); j++)
  4006. {
  4007. returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
  4008. }
  4009. j = 0;
  4010. returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
  4011. returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
  4012. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4013. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4014. returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
  4015. returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
  4016. foreach (UUID banned in BannedUsers)
  4017. {
  4018. returnblock[j].Parameter = banned.GetBytes(); j++;
  4019. }
  4020. packet.ParamList = returnblock;
  4021. packet.Header.Reliable = true;
  4022. OutPacket(packet, ThrottleOutPacketType.Task);
  4023. BannedUsers.Clear();
  4024. }
  4025. }
  4026. }
  4027. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  4028. {
  4029. RegionInfoPacket rinfopack = new RegionInfoPacket();
  4030. RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
  4031. rinfopack.AgentData.AgentID = AgentId;
  4032. rinfopack.AgentData.SessionID = SessionId;
  4033. rinfoblk.BillableFactor = args.billableFactor;
  4034. rinfoblk.EstateID = args.estateID;
  4035. rinfoblk.MaxAgents = args.maxAgents;
  4036. rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
  4037. rinfoblk.ParentEstateID = args.parentEstateID;
  4038. rinfoblk.PricePerMeter = args.pricePerMeter;
  4039. rinfoblk.RedirectGridX = args.redirectGridX;
  4040. rinfoblk.RedirectGridY = args.redirectGridY;
  4041. rinfoblk.RegionFlags = args.regionFlags;
  4042. rinfoblk.SimAccess = args.simAccess;
  4043. rinfoblk.SunHour = args.sunHour;
  4044. rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
  4045. rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
  4046. rinfoblk.UseEstateSun = args.useEstateSun;
  4047. rinfoblk.WaterHeight = args.waterHeight;
  4048. rinfoblk.SimName = Utils.StringToBytes(args.simName);
  4049. rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
  4050. rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
  4051. rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
  4052. rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
  4053. rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
  4054. rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
  4055. rinfopack.HasVariableBlocks = true;
  4056. rinfopack.RegionInfo = rinfoblk;
  4057. rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
  4058. rinfopack.AgentData.AgentID = AgentId;
  4059. rinfopack.AgentData.SessionID = SessionId;
  4060. rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
  4061. OutPacket(rinfopack, ThrottleOutPacketType.Task);
  4062. }
  4063. public void SendEstateCovenantInformation(UUID covenant)
  4064. {
  4065. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
  4066. EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
  4067. EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
  4068. edata.CovenantID = covenant;
  4069. edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
  4070. edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
  4071. edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
  4072. einfopack.Data = edata;
  4073. OutPacket(einfopack, ThrottleOutPacketType.Task);
  4074. }
  4075. public void SendDetailedEstateData(
  4076. UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
  4077. UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
  4078. {
  4079. // m_log.DebugFormat(
  4080. // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
  4081. EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
  4082. packet.MethodData.Invoice = invoice;
  4083. packet.AgentData.TransactionID = UUID.Random();
  4084. packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
  4085. EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
  4086. for (int i = 0; i < 10; i++)
  4087. {
  4088. returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
  4089. }
  4090. //Sending Estate Settings
  4091. returnblock[0].Parameter = Utils.StringToBytes(estateName);
  4092. returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
  4093. returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
  4094. returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
  4095. returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
  4096. returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
  4097. returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
  4098. returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
  4099. returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
  4100. returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
  4101. packet.ParamList = returnblock;
  4102. packet.Header.Reliable = false;
  4103. //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
  4104. OutPacket(packet, ThrottleOutPacketType.Task);
  4105. }
  4106. public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
  4107. {
  4108. TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
  4109. packet.TelehubBlock.ObjectID = ObjectID;
  4110. packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
  4111. packet.TelehubBlock.TelehubPos = ObjectPos;
  4112. packet.TelehubBlock.TelehubRot = ObjectRot;
  4113. packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
  4114. for (int n = 0; n < SpawnPoint.Count; n++)
  4115. {
  4116. packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
  4117. }
  4118. OutPacket(packet, ThrottleOutPacketType.Task);
  4119. }
  4120. #endregion
  4121. #region Land Data Sending Methods
  4122. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  4123. {
  4124. ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
  4125. packet.ParcelData.Data = data;
  4126. packet.ParcelData.SequenceID = sequence_id;
  4127. packet.Header.Zerocoded = true;
  4128. OutPacket(packet, ThrottleOutPacketType.Task);
  4129. }
  4130. public void SendLandProperties(
  4131. int sequence_id, bool snap_selection, int request_result, ILandObject lo,
  4132. float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  4133. {
  4134. // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
  4135. LandData landData = lo.LandData;
  4136. ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
  4137. updateMessage.AABBMax = landData.AABBMax;
  4138. updateMessage.AABBMin = landData.AABBMin;
  4139. updateMessage.Area = landData.Area;
  4140. updateMessage.AuctionID = landData.AuctionID;
  4141. updateMessage.AuthBuyerID = landData.AuthBuyerID;
  4142. updateMessage.Bitmap = landData.Bitmap;
  4143. updateMessage.Desc = landData.Description;
  4144. updateMessage.Category = landData.Category;
  4145. updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
  4146. updateMessage.ClaimPrice = landData.ClaimPrice;
  4147. updateMessage.GroupID = landData.GroupID;
  4148. updateMessage.IsGroupOwned = landData.IsGroupOwned;
  4149. updateMessage.LandingType = (LandingType) landData.LandingType;
  4150. updateMessage.LocalID = landData.LocalID;
  4151. if (landData.Area > 0)
  4152. {
  4153. updateMessage.MaxPrims = parcelObjectCapacity;
  4154. }
  4155. else
  4156. {
  4157. updateMessage.MaxPrims = 0;
  4158. }
  4159. updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
  4160. updateMessage.MediaID = landData.MediaID;
  4161. updateMessage.MediaURL = landData.MediaURL;
  4162. updateMessage.MusicURL = landData.MusicURL;
  4163. updateMessage.Name = landData.Name;
  4164. updateMessage.OtherCleanTime = landData.OtherCleanTime;
  4165. updateMessage.OtherCount = 0; //TODO: Unimplemented
  4166. updateMessage.OwnerID = landData.OwnerID;
  4167. updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
  4168. updateMessage.ParcelPrimBonus = simObjectBonusFactor;
  4169. updateMessage.PassHours = landData.PassHours;
  4170. updateMessage.PassPrice = landData.PassPrice;
  4171. updateMessage.PublicCount = 0; //TODO: Unimplemented
  4172. updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
  4173. updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
  4174. //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
  4175. //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
  4176. updateMessage.RentPrice = 0;
  4177. updateMessage.RequestResult = (ParcelResult) request_result;
  4178. updateMessage.SalePrice = landData.SalePrice;
  4179. updateMessage.SelfCount = 0; //TODO: Unimplemented
  4180. updateMessage.SequenceID = sequence_id;
  4181. if (landData.SimwideArea > 0)
  4182. {
  4183. int simulatorCapacity = (int)(((float)landData.SimwideArea / 65536.0f) * (float)m_scene.RegionInfo.ObjectCapacity * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus);
  4184. updateMessage.SimWideMaxPrims = simulatorCapacity;
  4185. }
  4186. else
  4187. {
  4188. updateMessage.SimWideMaxPrims = 0;
  4189. }
  4190. updateMessage.SnapSelection = snap_selection;
  4191. updateMessage.SnapshotID = landData.SnapshotID;
  4192. updateMessage.Status = (ParcelStatus) landData.Status;
  4193. updateMessage.UserLocation = landData.UserLocation;
  4194. updateMessage.UserLookAt = landData.UserLookAt;
  4195. updateMessage.MediaType = landData.MediaType;
  4196. updateMessage.MediaDesc = landData.MediaDescription;
  4197. updateMessage.MediaWidth = landData.MediaWidth;
  4198. updateMessage.MediaHeight = landData.MediaHeight;
  4199. updateMessage.MediaLoop = landData.MediaLoop;
  4200. updateMessage.ObscureMusic = landData.ObscureMusic;
  4201. updateMessage.ObscureMedia = landData.ObscureMedia;
  4202. IPrimCounts pc = lo.PrimCounts;
  4203. updateMessage.OwnerPrims = pc.Owner;
  4204. updateMessage.GroupPrims = pc.Group;
  4205. updateMessage.OtherPrims = pc.Others;
  4206. updateMessage.SelectedPrims = pc.Selected;
  4207. updateMessage.TotalPrims = pc.Total;
  4208. updateMessage.SimWideTotalPrims = pc.Simulator;
  4209. try
  4210. {
  4211. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  4212. if (eq != null)
  4213. {
  4214. eq.ParcelProperties(updateMessage, this.AgentId);
  4215. }
  4216. else
  4217. {
  4218. m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
  4219. }
  4220. }
  4221. catch (Exception ex)
  4222. {
  4223. m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
  4224. }
  4225. }
  4226. public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
  4227. {
  4228. ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
  4229. replyPacket.Data.AgentID = AgentId;
  4230. replyPacket.Data.Flags = accessFlag;
  4231. replyPacket.Data.LocalID = localLandID;
  4232. replyPacket.Data.SequenceID = 0;
  4233. List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
  4234. foreach (LandAccessEntry entry in accessList)
  4235. {
  4236. ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
  4237. block.Flags = accessFlag;
  4238. block.ID = entry.AgentID;
  4239. block.Time = entry.Expires;
  4240. list.Add(block);
  4241. }
  4242. replyPacket.List = list.ToArray();
  4243. replyPacket.Header.Zerocoded = true;
  4244. OutPacket(replyPacket, ThrottleOutPacketType.Task);
  4245. }
  4246. public void SendForceClientSelectObjects(List<uint> ObjectIDs)
  4247. {
  4248. // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
  4249. bool firstCall = true;
  4250. const int MAX_OBJECTS_PER_PACKET = 251;
  4251. ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
  4252. ForceObjectSelectPacket.DataBlock[] data;
  4253. while (ObjectIDs.Count > 0)
  4254. {
  4255. if (firstCall)
  4256. {
  4257. pack._Header.ResetList = true;
  4258. firstCall = false;
  4259. }
  4260. else
  4261. {
  4262. pack._Header.ResetList = false;
  4263. }
  4264. if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
  4265. {
  4266. data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
  4267. }
  4268. else
  4269. {
  4270. data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
  4271. }
  4272. int i;
  4273. for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
  4274. {
  4275. data[i] = new ForceObjectSelectPacket.DataBlock();
  4276. data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
  4277. ObjectIDs.RemoveAt(0);
  4278. }
  4279. pack.Data = data;
  4280. pack.Header.Zerocoded = true;
  4281. OutPacket(pack, ThrottleOutPacketType.Task);
  4282. }
  4283. }
  4284. public void SendCameraConstraint(Vector4 ConstraintPlane)
  4285. {
  4286. CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
  4287. cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
  4288. cpack.CameraCollidePlane.Plane = ConstraintPlane;
  4289. //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
  4290. OutPacket(cpack, ThrottleOutPacketType.Task);
  4291. }
  4292. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  4293. {
  4294. int notifyCount = ownersAndCount.Count;
  4295. ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
  4296. if (notifyCount > 0)
  4297. {
  4298. if (notifyCount > 32)
  4299. {
  4300. m_log.InfoFormat(
  4301. "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
  4302. + " - a developer might want to investigate whether this is a hard limit", 32);
  4303. notifyCount = 32;
  4304. }
  4305. ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
  4306. = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
  4307. int num = 0;
  4308. foreach (UUID owner in ownersAndCount.Keys)
  4309. {
  4310. dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
  4311. dataBlock[num].Count = ownersAndCount[owner];
  4312. if (land.GroupID == owner || groups.Contains(owner))
  4313. dataBlock[num].IsGroupOwned = true;
  4314. dataBlock[num].OnlineStatus = true; //TODO: fix me later
  4315. dataBlock[num].OwnerID = owner;
  4316. num++;
  4317. if (num >= notifyCount)
  4318. {
  4319. break;
  4320. }
  4321. }
  4322. pack.Data = dataBlock;
  4323. }
  4324. else
  4325. {
  4326. pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
  4327. }
  4328. pack.Header.Zerocoded = true;
  4329. this.OutPacket(pack, ThrottleOutPacketType.Task);
  4330. }
  4331. #endregion
  4332. #region Helper Methods
  4333. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
  4334. {
  4335. #region ScenePresence/SOP Handling
  4336. bool avatar = (entity is ScenePresence);
  4337. uint localID = entity.LocalId;
  4338. uint attachPoint;
  4339. Vector4 collisionPlane;
  4340. Vector3 position, velocity, acceleration, angularVelocity;
  4341. Quaternion rotation;
  4342. byte[] textureEntry;
  4343. if (entity is ScenePresence)
  4344. {
  4345. ScenePresence presence = (ScenePresence)entity;
  4346. // m_log.DebugFormat(
  4347. // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
  4348. attachPoint = presence.State;
  4349. collisionPlane = presence.CollisionPlane;
  4350. position = presence.OffsetPosition;
  4351. velocity = presence.Velocity;
  4352. acceleration = Vector3.Zero;
  4353. // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
  4354. // in that direction, even though we don't model this on the server. Implementing this in the future
  4355. // may improve movement smoothness.
  4356. // acceleration = new Vector3(1, 0, 0);
  4357. angularVelocity = presence.AngularVelocity;
  4358. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4359. // it rotates around.
  4360. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4361. // excessive up and down movements of the camera when looking up and down.
  4362. // See http://opensimulator.org/mantis/view.php?id=3274
  4363. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4364. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4365. // the rotation in this case.
  4366. rotation = presence.Rotation;
  4367. if (!presence.IsSatOnObject)
  4368. {
  4369. rotation.X = 0;
  4370. rotation.Y = 0;
  4371. }
  4372. if (sendTexture)
  4373. textureEntry = presence.Appearance.Texture.GetBytes();
  4374. else
  4375. textureEntry = null;
  4376. }
  4377. else
  4378. {
  4379. SceneObjectPart part = (SceneObjectPart)entity;
  4380. attachPoint = part.ParentGroup.AttachmentPoint;
  4381. attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
  4382. // m_log.DebugFormat(
  4383. // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
  4384. // attachPoint, part.Name, part.LocalId, Name);
  4385. collisionPlane = Vector4.Zero;
  4386. position = part.RelativePosition;
  4387. velocity = part.Velocity;
  4388. acceleration = part.Acceleration;
  4389. angularVelocity = part.AngularVelocity;
  4390. rotation = part.RotationOffset;
  4391. if (sendTexture)
  4392. textureEntry = part.Shape.TextureEntry;
  4393. else
  4394. textureEntry = null;
  4395. }
  4396. #endregion ScenePresence/SOP Handling
  4397. int pos = 0;
  4398. byte[] data = new byte[(avatar ? 60 : 44)];
  4399. // LocalID
  4400. Utils.UIntToBytes(localID, data, pos);
  4401. pos += 4;
  4402. // Avatar/CollisionPlane
  4403. data[pos++] = (byte) attachPoint;
  4404. if (avatar)
  4405. {
  4406. data[pos++] = 1;
  4407. if (collisionPlane == Vector4.Zero)
  4408. collisionPlane = Vector4.UnitW;
  4409. //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
  4410. collisionPlane.ToBytes(data, pos);
  4411. pos += 16;
  4412. }
  4413. else
  4414. {
  4415. ++pos;
  4416. }
  4417. // Position
  4418. position.ToBytes(data, pos);
  4419. pos += 12;
  4420. // Velocity
  4421. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
  4422. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
  4423. Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
  4424. // Acceleration
  4425. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
  4426. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4427. Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4428. // Rotation
  4429. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
  4430. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
  4431. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
  4432. Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
  4433. // Angular Velocity
  4434. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
  4435. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
  4436. Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
  4437. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
  4438. = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
  4439. block.Data = data;
  4440. if (textureEntry != null && textureEntry.Length > 0)
  4441. {
  4442. byte[] teBytesFinal = new byte[textureEntry.Length + 4];
  4443. // Texture Length
  4444. Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
  4445. // Texture
  4446. Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
  4447. block.TextureEntry = teBytesFinal;
  4448. }
  4449. else
  4450. {
  4451. block.TextureEntry = Utils.EmptyBytes;
  4452. }
  4453. return block;
  4454. }
  4455. protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
  4456. {
  4457. // m_log.DebugFormat(
  4458. // "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name);
  4459. byte[] objectData = new byte[76];
  4460. data.CollisionPlane.ToBytes(objectData, 0);
  4461. data.OffsetPosition.ToBytes(objectData, 16);
  4462. // data.Velocity.ToBytes(objectData, 28);
  4463. // data.Acceleration.ToBytes(objectData, 40);
  4464. // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis
  4465. // it rotates around.
  4466. // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted
  4467. // excessive up and down movements of the camera when looking up and down.
  4468. // See http://opensimulator.org/mantis/view.php?id=3274
  4469. // This does not affect head movement, since this is controlled entirely by camera movement rather than
  4470. // body rotation. We still need to transmit X and Y for sitting avatars but mouselook does not change
  4471. // the rotation in this case.
  4472. Quaternion rot = data.Rotation;
  4473. if (!data.IsSatOnObject)
  4474. {
  4475. rot.X = 0;
  4476. rot.Y = 0;
  4477. }
  4478. rot.ToBytes(objectData, 52);
  4479. //data.AngularVelocity.ToBytes(objectData, 64);
  4480. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4481. update.Data = Utils.EmptyBytes;
  4482. update.ExtraParams = new byte[1];
  4483. update.FullID = data.UUID;
  4484. update.ID = data.LocalId;
  4485. update.Material = (byte)Material.Flesh;
  4486. update.MediaURL = Utils.EmptyBytes;
  4487. update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
  4488. data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
  4489. update.ObjectData = objectData;
  4490. SceneObjectPart parentPart = data.ParentPart;
  4491. if (parentPart != null)
  4492. update.ParentID = parentPart.ParentGroup.LocalId;
  4493. else
  4494. update.ParentID = 0;
  4495. update.PathCurve = 16;
  4496. update.PathScaleX = 100;
  4497. update.PathScaleY = 100;
  4498. update.PCode = (byte)PCode.Avatar;
  4499. update.ProfileCurve = 1;
  4500. update.PSBlock = Utils.EmptyBytes;
  4501. update.Scale = new Vector3(0.45f, 0.6f, 1.9f);
  4502. update.Text = Utils.EmptyBytes;
  4503. update.TextColor = new byte[4];
  4504. // Don't send texture anim for avatars - this has no meaning for them.
  4505. update.TextureAnim = Utils.EmptyBytes;
  4506. // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
  4507. update.TextureEntry = Utils.EmptyBytes;
  4508. // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
  4509. update.UpdateFlags = (uint)(
  4510. PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
  4511. PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
  4512. PrimFlags.ObjectOwnerModify);
  4513. return update;
  4514. }
  4515. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
  4516. {
  4517. byte[] objectData = new byte[60];
  4518. data.RelativePosition.ToBytes(objectData, 0);
  4519. data.Velocity.ToBytes(objectData, 12);
  4520. data.Acceleration.ToBytes(objectData, 24);
  4521. try
  4522. {
  4523. data.RotationOffset.ToBytes(objectData, 36);
  4524. }
  4525. catch (Exception e)
  4526. {
  4527. m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
  4528. OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
  4529. }
  4530. data.AngularVelocity.ToBytes(objectData, 48);
  4531. ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
  4532. update.ClickAction = (byte)data.ClickAction;
  4533. update.CRC = 0;
  4534. update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
  4535. update.FullID = data.UUID;
  4536. update.ID = data.LocalId;
  4537. //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
  4538. //update.JointPivot = Vector3.Zero;
  4539. //update.JointType = 0;
  4540. update.Material = data.Material;
  4541. update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
  4542. if (data.ParentGroup.IsAttachment)
  4543. {
  4544. update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
  4545. update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
  4546. }
  4547. else
  4548. {
  4549. update.NameValue = Utils.EmptyBytes;
  4550. // The root part state is the canonical state for all parts of the object. The other part states in the
  4551. // case for attachments may contain conflicting values that can end up crashing the viewer.
  4552. update.State = data.ParentGroup.RootPart.Shape.State;
  4553. }
  4554. // m_log.DebugFormat(
  4555. // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
  4556. // update.State, data.Name, data.LocalId, Name);
  4557. update.ObjectData = objectData;
  4558. update.ParentID = data.ParentID;
  4559. update.PathBegin = data.Shape.PathBegin;
  4560. update.PathCurve = data.Shape.PathCurve;
  4561. update.PathEnd = data.Shape.PathEnd;
  4562. update.PathRadiusOffset = data.Shape.PathRadiusOffset;
  4563. update.PathRevolutions = data.Shape.PathRevolutions;
  4564. update.PathScaleX = data.Shape.PathScaleX;
  4565. update.PathScaleY = data.Shape.PathScaleY;
  4566. update.PathShearX = data.Shape.PathShearX;
  4567. update.PathShearY = data.Shape.PathShearY;
  4568. update.PathSkew = data.Shape.PathSkew;
  4569. update.PathTaperX = data.Shape.PathTaperX;
  4570. update.PathTaperY = data.Shape.PathTaperY;
  4571. update.PathTwist = data.Shape.PathTwist;
  4572. update.PathTwistBegin = data.Shape.PathTwistBegin;
  4573. update.PCode = data.Shape.PCode;
  4574. update.ProfileBegin = data.Shape.ProfileBegin;
  4575. update.ProfileCurve = data.Shape.ProfileCurve;
  4576. update.ProfileEnd = data.Shape.ProfileEnd;
  4577. update.ProfileHollow = data.Shape.ProfileHollow;
  4578. update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
  4579. update.TextColor = data.GetTextColor().GetBytes(false);
  4580. update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
  4581. update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
  4582. update.Scale = data.Shape.Scale;
  4583. update.Text = Util.StringToBytes256(data.Text);
  4584. update.MediaURL = Util.StringToBytes256(data.MediaUrl);
  4585. #region PrimFlags
  4586. PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
  4587. // Don't send the CreateSelected flag to everyone
  4588. flags &= ~PrimFlags.CreateSelected;
  4589. if (recipientID == data.OwnerID)
  4590. {
  4591. if (data.CreateSelected)
  4592. {
  4593. // Only send this flag once, then unset it
  4594. flags |= PrimFlags.CreateSelected;
  4595. data.CreateSelected = false;
  4596. }
  4597. }
  4598. // m_log.DebugFormat(
  4599. // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
  4600. // data.Name, update.FullID, flags, update.ID);
  4601. update.UpdateFlags = (uint)flags;
  4602. #endregion PrimFlags
  4603. if (data.Sound != UUID.Zero)
  4604. {
  4605. update.Sound = data.Sound;
  4606. update.OwnerID = data.OwnerID;
  4607. update.Gain = (float)data.SoundGain;
  4608. update.Radius = (float)data.SoundRadius;
  4609. update.Flags = data.SoundFlags;
  4610. }
  4611. switch ((PCode)data.Shape.PCode)
  4612. {
  4613. case PCode.Grass:
  4614. case PCode.Tree:
  4615. case PCode.NewTree:
  4616. update.Data = new byte[] { data.Shape.State };
  4617. break;
  4618. default:
  4619. update.Data = Utils.EmptyBytes;
  4620. break;
  4621. }
  4622. return update;
  4623. }
  4624. protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
  4625. {
  4626. // TODO: Implement this
  4627. return null;
  4628. }
  4629. public void SendNameReply(UUID profileId, string firstname, string lastname)
  4630. {
  4631. UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
  4632. // TODO: don't create new blocks if recycling an old packet
  4633. packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
  4634. packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
  4635. packet.UUIDNameBlock[0].ID = profileId;
  4636. packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
  4637. packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
  4638. OutPacket(packet, ThrottleOutPacketType.Task);
  4639. }
  4640. public ulong GetGroupPowers(UUID groupID)
  4641. {
  4642. if (groupID == m_activeGroupID)
  4643. return m_activeGroupPowers;
  4644. if (m_groupPowers.ContainsKey(groupID))
  4645. return m_groupPowers[groupID];
  4646. return 0;
  4647. }
  4648. #endregion
  4649. /// <summary>
  4650. /// This is a different way of processing packets then ProcessInPacket
  4651. /// </summary>
  4652. protected virtual void RegisterLocalPacketHandlers()
  4653. {
  4654. AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
  4655. // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
  4656. // for each AgentUpdate packet.
  4657. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
  4658. AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
  4659. AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
  4660. AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
  4661. AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
  4662. AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
  4663. AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
  4664. AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
  4665. AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage);
  4666. AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest);
  4667. AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
  4668. AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate);
  4669. AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
  4670. AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
  4671. AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
  4672. AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
  4673. AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
  4674. AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
  4675. AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
  4676. AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
  4677. AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
  4678. AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
  4679. AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
  4680. AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
  4681. AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
  4682. AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
  4683. AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
  4684. AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
  4685. AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
  4686. AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
  4687. AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
  4688. AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
  4689. AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
  4690. AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
  4691. AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
  4692. AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
  4693. AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
  4694. AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
  4695. AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
  4696. AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
  4697. AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
  4698. AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
  4699. AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
  4700. AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
  4701. AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
  4702. AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
  4703. AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
  4704. AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
  4705. AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
  4706. AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
  4707. AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
  4708. AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
  4709. AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
  4710. AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
  4711. AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
  4712. AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
  4713. AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
  4714. AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
  4715. // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
  4716. // some clients will send out a separate ObjectImage packet for each face
  4717. AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
  4718. AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
  4719. AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
  4720. AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
  4721. AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
  4722. AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
  4723. AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
  4724. AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
  4725. AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
  4726. AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
  4727. AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
  4728. AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
  4729. AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
  4730. AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
  4731. AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
  4732. AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
  4733. AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
  4734. AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
  4735. AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
  4736. AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
  4737. AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
  4738. AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
  4739. AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
  4740. AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
  4741. AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
  4742. AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
  4743. AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
  4744. AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
  4745. AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
  4746. AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
  4747. AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
  4748. AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
  4749. AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
  4750. AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
  4751. AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
  4752. AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
  4753. AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
  4754. AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
  4755. AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
  4756. AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
  4757. AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
  4758. AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
  4759. AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
  4760. AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
  4761. AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
  4762. AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
  4763. AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
  4764. AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
  4765. AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
  4766. AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
  4767. AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
  4768. AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
  4769. AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
  4770. AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
  4771. AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
  4772. AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
  4773. AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
  4774. AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
  4775. AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
  4776. AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
  4777. AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
  4778. AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
  4779. AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
  4780. AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
  4781. AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
  4782. AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
  4783. AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
  4784. AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
  4785. AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
  4786. AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
  4787. AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
  4788. AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
  4789. AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
  4790. AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
  4791. AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
  4792. AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
  4793. AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
  4794. AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
  4795. AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
  4796. AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
  4797. AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
  4798. AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
  4799. AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
  4800. AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
  4801. AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
  4802. AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
  4803. AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
  4804. AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
  4805. AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
  4806. AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
  4807. AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
  4808. AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
  4809. AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
  4810. AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
  4811. AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
  4812. AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
  4813. AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
  4814. AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
  4815. AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
  4816. AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
  4817. AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
  4818. AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
  4819. AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
  4820. AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
  4821. AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
  4822. AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
  4823. AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
  4824. AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
  4825. AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
  4826. AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
  4827. AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
  4828. AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
  4829. AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
  4830. AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
  4831. AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
  4832. AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
  4833. AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
  4834. AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
  4835. AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
  4836. AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
  4837. AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
  4838. AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
  4839. AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
  4840. AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
  4841. AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
  4842. AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
  4843. AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
  4844. AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
  4845. AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
  4846. AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
  4847. AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
  4848. AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
  4849. AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
  4850. AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
  4851. AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate);
  4852. AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate);
  4853. AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
  4854. AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
  4855. AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
  4856. AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
  4857. AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
  4858. AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
  4859. AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
  4860. AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
  4861. AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
  4862. AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
  4863. AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
  4864. AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
  4865. AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
  4866. AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
  4867. AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
  4868. AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
  4869. AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
  4870. AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
  4871. AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
  4872. AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
  4873. AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
  4874. AddGenericPacketHandler("autopilot", HandleAutopilot);
  4875. }
  4876. #region Packet Handlers
  4877. public int TotalAgentUpdates { get; set; }
  4878. #region Scene/Avatar
  4879. // Threshold for body rotation to be a significant agent update
  4880. private const float QDELTA = 0.000001f;
  4881. // Threshold for camera rotation to be a significant agent update
  4882. private const float VDELTA = 0.01f;
  4883. /// <summary>
  4884. /// This checks the update significance against the last update made.
  4885. /// </summary>
  4886. /// <remarks>Can only be called by one thread at a time</remarks>
  4887. /// <returns></returns>
  4888. /// <param name='x'></param>
  4889. public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4890. {
  4891. return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
  4892. }
  4893. /// <summary>
  4894. /// This checks the movement/state update significance against the last update made.
  4895. /// </summary>
  4896. /// <remarks>Can only be called by one thread at a time</remarks>
  4897. /// <returns></returns>
  4898. /// <param name='x'></param>
  4899. private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4900. {
  4901. float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2);
  4902. //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2);
  4903. bool movementSignificant =
  4904. (qdelta1 > QDELTA) // significant if body rotation above threshold
  4905. // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
  4906. // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold
  4907. || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
  4908. || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
  4909. || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
  4910. || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
  4911. || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
  4912. ;
  4913. //if (movementSignificant)
  4914. //{
  4915. //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
  4916. // qdelta1, qdelta2);
  4917. //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
  4918. // x.ControlFlags, x.Flags, x.Far, x.State);
  4919. //}
  4920. return movementSignificant;
  4921. }
  4922. /// <summary>
  4923. /// This checks the camera update significance against the last update made.
  4924. /// </summary>
  4925. /// <remarks>Can only be called by one thread at a time</remarks>
  4926. /// <returns></returns>
  4927. /// <param name='x'></param>
  4928. private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
  4929. {
  4930. float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
  4931. float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
  4932. float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
  4933. float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
  4934. bool cameraSignificant =
  4935. (vdelta1 > VDELTA) ||
  4936. (vdelta2 > VDELTA) ||
  4937. (vdelta3 > VDELTA) ||
  4938. (vdelta4 > VDELTA)
  4939. ;
  4940. //if (cameraSignificant)
  4941. //{
  4942. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
  4943. // x.CameraAtAxis, x.CameraCenter);
  4944. //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
  4945. // x.CameraLeftAxis, x.CameraUpAxis);
  4946. //}
  4947. return cameraSignificant;
  4948. }
  4949. private bool HandleAgentUpdate(IClientAPI sener, Packet packet)
  4950. {
  4951. // We got here, which means that something in agent update was significant
  4952. AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
  4953. AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
  4954. if (x.AgentID != AgentId || x.SessionID != SessionId)
  4955. return false;
  4956. // Before we update the current m_thisAgentUpdateArgs, let's check this again
  4957. // to see what exactly changed
  4958. bool movement = CheckAgentMovementUpdateSignificance(x);
  4959. bool camera = CheckAgentCameraUpdateSignificance(x);
  4960. m_thisAgentUpdateArgs.AgentID = x.AgentID;
  4961. m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
  4962. m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
  4963. m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
  4964. m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
  4965. m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
  4966. m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
  4967. m_thisAgentUpdateArgs.Far = x.Far;
  4968. m_thisAgentUpdateArgs.Flags = x.Flags;
  4969. m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
  4970. m_thisAgentUpdateArgs.SessionID = x.SessionID;
  4971. m_thisAgentUpdateArgs.State = x.State;
  4972. UpdateAgent handlerAgentUpdate = OnAgentUpdate;
  4973. UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
  4974. UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
  4975. // Was there a significant movement/state change?
  4976. if (movement)
  4977. {
  4978. if (handlerPreAgentUpdate != null)
  4979. OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
  4980. if (handlerAgentUpdate != null)
  4981. OnAgentUpdate(this, m_thisAgentUpdateArgs);
  4982. }
  4983. // Was there a significant camera(s) change?
  4984. if (camera)
  4985. if (handlerAgentCameraUpdate != null)
  4986. handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
  4987. handlerAgentUpdate = null;
  4988. handlerPreAgentUpdate = null;
  4989. handlerAgentCameraUpdate = null;
  4990. PacketPool.Instance.ReturnPacket(packet);
  4991. return true;
  4992. }
  4993. private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
  4994. {
  4995. MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
  4996. // validate the agent owns the agentID and sessionID
  4997. if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
  4998. money.AgentData.SessionID == sender.SessionId)
  4999. {
  5000. MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
  5001. if (handlerMoneyTransferRequest != null)
  5002. {
  5003. handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
  5004. money.MoneyData.Amount, money.MoneyData.TransactionType,
  5005. Util.FieldToString(money.MoneyData.Description));
  5006. }
  5007. return true;
  5008. }
  5009. return false;
  5010. }
  5011. private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
  5012. {
  5013. ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
  5014. (ParcelGodMarkAsContentPacket)Packet;
  5015. ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
  5016. if (ParcelGodMarkAsContentHandler != null)
  5017. {
  5018. ParcelGodMarkAsContentHandler(this,
  5019. ParcelGodMarkAsContent.AgentData.AgentID,
  5020. ParcelGodMarkAsContent.ParcelData.LocalID);
  5021. return true;
  5022. }
  5023. return false;
  5024. }
  5025. private bool HandleFreezeUser(IClientAPI client, Packet Packet)
  5026. {
  5027. FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
  5028. FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
  5029. if (FreezeUserHandler != null)
  5030. {
  5031. FreezeUserHandler(this,
  5032. FreezeUser.AgentData.AgentID,
  5033. FreezeUser.Data.Flags,
  5034. FreezeUser.Data.TargetID);
  5035. return true;
  5036. }
  5037. return false;
  5038. }
  5039. private bool HandleEjectUser(IClientAPI client, Packet Packet)
  5040. {
  5041. EjectUserPacket EjectUser =
  5042. (EjectUserPacket)Packet;
  5043. EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
  5044. if (EjectUserHandler != null)
  5045. {
  5046. EjectUserHandler(this,
  5047. EjectUser.AgentData.AgentID,
  5048. EjectUser.Data.Flags,
  5049. EjectUser.Data.TargetID);
  5050. return true;
  5051. }
  5052. return false;
  5053. }
  5054. private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
  5055. {
  5056. ParcelBuyPassPacket ParcelBuyPass =
  5057. (ParcelBuyPassPacket)Packet;
  5058. ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
  5059. if (ParcelBuyPassHandler != null)
  5060. {
  5061. ParcelBuyPassHandler(this,
  5062. ParcelBuyPass.AgentData.AgentID,
  5063. ParcelBuyPass.ParcelData.LocalID);
  5064. return true;
  5065. }
  5066. return false;
  5067. }
  5068. private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
  5069. {
  5070. ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
  5071. if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
  5072. {
  5073. ParcelBuy handlerParcelBuy = OnParcelBuy;
  5074. if (handlerParcelBuy != null)
  5075. {
  5076. handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
  5077. parcel.Data.IsGroupOwned,
  5078. parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
  5079. parcel.ParcelData.Price,
  5080. false);
  5081. }
  5082. return true;
  5083. }
  5084. return false;
  5085. }
  5086. private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
  5087. {
  5088. UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
  5089. for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
  5090. {
  5091. UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
  5092. if (handlerUUIDGroupNameRequest != null)
  5093. {
  5094. handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
  5095. }
  5096. }
  5097. return true;
  5098. }
  5099. public bool HandleGenericMessage(IClientAPI sender, Packet pack)
  5100. {
  5101. GenericMessagePacket gmpack = (GenericMessagePacket)pack;
  5102. if (m_genericPacketHandlers.Count == 0) return false;
  5103. if (gmpack.AgentData.SessionID != SessionId) return false;
  5104. GenericMessage handlerGenericMessage = null;
  5105. string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
  5106. if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
  5107. {
  5108. List<string> msg = new List<string>();
  5109. List<byte[]> msgBytes = new List<byte[]>();
  5110. if (handlerGenericMessage != null)
  5111. {
  5112. foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
  5113. {
  5114. msg.Add(Util.FieldToString(block.Parameter));
  5115. msgBytes.Add(block.Parameter);
  5116. }
  5117. try
  5118. {
  5119. if (OnBinaryGenericMessage != null)
  5120. {
  5121. OnBinaryGenericMessage(this, method, msgBytes.ToArray());
  5122. }
  5123. handlerGenericMessage(sender, method, msg);
  5124. return true;
  5125. }
  5126. catch (Exception e)
  5127. {
  5128. m_log.ErrorFormat(
  5129. "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
  5130. }
  5131. }
  5132. }
  5133. //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
  5134. return false;
  5135. }
  5136. public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
  5137. {
  5138. ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
  5139. if (ogpack.AgentData.SessionID != SessionId) return false;
  5140. RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
  5141. if (handlerObjectGroupRequest != null)
  5142. {
  5143. for (int i = 0; i < ogpack.ObjectData.Length; i++)
  5144. {
  5145. handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
  5146. }
  5147. }
  5148. return true;
  5149. }
  5150. private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
  5151. {
  5152. ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
  5153. if (viewer.AgentData.SessionID != SessionId) return false;
  5154. ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
  5155. if (handlerViewerEffect != null)
  5156. {
  5157. int length = viewer.Effect.Length;
  5158. List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
  5159. for (int i = 0; i < length; i++)
  5160. {
  5161. //copy the effects block arguments into the event handler arg.
  5162. ViewerEffectEventHandlerArg argument = new ViewerEffectEventHandlerArg();
  5163. argument.AgentID = viewer.Effect[i].AgentID;
  5164. argument.Color = viewer.Effect[i].Color;
  5165. argument.Duration = viewer.Effect[i].Duration;
  5166. argument.ID = viewer.Effect[i].ID;
  5167. argument.Type = viewer.Effect[i].Type;
  5168. argument.TypeData = viewer.Effect[i].TypeData;
  5169. args.Add(argument);
  5170. }
  5171. handlerViewerEffect(sender, args);
  5172. }
  5173. return true;
  5174. }
  5175. private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
  5176. {
  5177. AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
  5178. #region Packet Session and User Check
  5179. if (m_checkPackets)
  5180. {
  5181. if (avatarProperties.AgentData.SessionID != SessionId ||
  5182. avatarProperties.AgentData.AgentID != AgentId)
  5183. return true;
  5184. }
  5185. #endregion
  5186. RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
  5187. if (handlerRequestAvatarProperties != null)
  5188. {
  5189. handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
  5190. }
  5191. return true;
  5192. }
  5193. private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
  5194. {
  5195. ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
  5196. #region Packet Session and User Check
  5197. if (m_checkPackets)
  5198. {
  5199. if (inchatpack.AgentData.SessionID != SessionId ||
  5200. inchatpack.AgentData.AgentID != AgentId)
  5201. return true;
  5202. }
  5203. #endregion
  5204. string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
  5205. byte[] message = inchatpack.ChatData.Message;
  5206. byte type = inchatpack.ChatData.Type;
  5207. Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
  5208. // UUID fromAgentID = AgentId;
  5209. int channel = inchatpack.ChatData.Channel;
  5210. if (OnChatFromClient != null)
  5211. {
  5212. OSChatMessage args = new OSChatMessage();
  5213. args.Channel = channel;
  5214. args.From = fromName;
  5215. args.Message = Utils.BytesToString(message);
  5216. args.Type = (ChatTypeEnum)type;
  5217. args.Position = fromPos;
  5218. args.Scene = Scene;
  5219. args.Sender = this;
  5220. args.SenderUUID = this.AgentId;
  5221. ChatMessage handlerChatFromClient = OnChatFromClient;
  5222. if (handlerChatFromClient != null)
  5223. handlerChatFromClient(this, args);
  5224. }
  5225. return true;
  5226. }
  5227. private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
  5228. {
  5229. AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
  5230. #region Packet Session and User Check
  5231. if (m_checkPackets)
  5232. {
  5233. if (avatarProps.AgentData.SessionID != SessionId ||
  5234. avatarProps.AgentData.AgentID != AgentId)
  5235. return true;
  5236. }
  5237. #endregion
  5238. UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
  5239. if (handlerUpdateAvatarProperties != null)
  5240. {
  5241. AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
  5242. UserProfileData UserProfile = new UserProfileData();
  5243. UserProfile.ID = AgentId;
  5244. UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
  5245. UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
  5246. UserProfile.FirstLifeImage = Properties.FLImageID;
  5247. UserProfile.Image = Properties.ImageID;
  5248. UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
  5249. UserProfile.UserFlags &= ~3;
  5250. UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
  5251. UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
  5252. handlerUpdateAvatarProperties(this, UserProfile);
  5253. }
  5254. return true;
  5255. }
  5256. private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
  5257. {
  5258. ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
  5259. //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
  5260. #region Packet Session and User Check
  5261. if (m_checkPackets)
  5262. {
  5263. if (rdialog.AgentData.SessionID != SessionId ||
  5264. rdialog.AgentData.AgentID != AgentId)
  5265. return true;
  5266. }
  5267. #endregion
  5268. int ch = rdialog.Data.ChatChannel;
  5269. byte[] msg = rdialog.Data.ButtonLabel;
  5270. if (OnChatFromClient != null)
  5271. {
  5272. OSChatMessage args = new OSChatMessage();
  5273. args.Channel = ch;
  5274. args.From = String.Empty;
  5275. args.Message = Utils.BytesToString(msg);
  5276. args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
  5277. args.Position = new Vector3();
  5278. args.Scene = Scene;
  5279. args.Sender = this;
  5280. ChatMessage handlerChatFromClient2 = OnChatFromClient;
  5281. if (handlerChatFromClient2 != null)
  5282. handlerChatFromClient2(this, args);
  5283. }
  5284. return true;
  5285. }
  5286. private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
  5287. {
  5288. ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
  5289. #region Packet Session and User Check
  5290. if (m_checkPackets)
  5291. {
  5292. if (msgpack.AgentData.SessionID != SessionId ||
  5293. msgpack.AgentData.AgentID != AgentId)
  5294. return true;
  5295. }
  5296. #endregion
  5297. string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
  5298. string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
  5299. ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
  5300. if (handlerInstantMessage != null)
  5301. {
  5302. GridInstantMessage im = new GridInstantMessage(Scene,
  5303. msgpack.AgentData.AgentID,
  5304. IMfromName,
  5305. msgpack.MessageBlock.ToAgentID,
  5306. msgpack.MessageBlock.Dialog,
  5307. msgpack.MessageBlock.FromGroup,
  5308. IMmessage,
  5309. msgpack.MessageBlock.ID,
  5310. msgpack.MessageBlock.Offline != 0 ? true : false,
  5311. msgpack.MessageBlock.Position,
  5312. msgpack.MessageBlock.BinaryBucket,
  5313. true);
  5314. handlerInstantMessage(this, im);
  5315. }
  5316. return true;
  5317. }
  5318. private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
  5319. {
  5320. AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
  5321. #region Packet Session and User Check
  5322. if (m_checkPackets)
  5323. {
  5324. if (afriendpack.AgentData.SessionID != SessionId ||
  5325. afriendpack.AgentData.AgentID != AgentId)
  5326. return true;
  5327. }
  5328. #endregion
  5329. // My guess is this is the folder to stick the calling card into
  5330. List<UUID> callingCardFolders = new List<UUID>();
  5331. UUID transactionID = afriendpack.TransactionBlock.TransactionID;
  5332. for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
  5333. {
  5334. callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
  5335. }
  5336. FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
  5337. if (handlerApproveFriendRequest != null)
  5338. {
  5339. handlerApproveFriendRequest(this, transactionID, callingCardFolders);
  5340. }
  5341. return true;
  5342. }
  5343. private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
  5344. {
  5345. DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
  5346. #region Packet Session and User Check
  5347. if (m_checkPackets)
  5348. {
  5349. if (dfriendpack.AgentData.SessionID != SessionId ||
  5350. dfriendpack.AgentData.AgentID != AgentId)
  5351. return true;
  5352. }
  5353. #endregion
  5354. if (OnDenyFriendRequest != null)
  5355. {
  5356. OnDenyFriendRequest(this,
  5357. dfriendpack.TransactionBlock.TransactionID,
  5358. null);
  5359. }
  5360. return true;
  5361. }
  5362. private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
  5363. {
  5364. TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
  5365. #region Packet Session and User Check
  5366. if (m_checkPackets)
  5367. {
  5368. if (tfriendpack.AgentData.SessionID != SessionId ||
  5369. tfriendpack.AgentData.AgentID != AgentId)
  5370. return true;
  5371. }
  5372. #endregion
  5373. UUID exFriendID = tfriendpack.ExBlock.OtherID;
  5374. FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
  5375. if (TerminateFriendshipHandler != null)
  5376. {
  5377. TerminateFriendshipHandler(this, exFriendID);
  5378. return true;
  5379. }
  5380. return false;
  5381. }
  5382. private bool HandleFindAgent(IClientAPI client, Packet Packet)
  5383. {
  5384. FindAgentPacket FindAgent =
  5385. (FindAgentPacket)Packet;
  5386. FindAgentUpdate FindAgentHandler = OnFindAgent;
  5387. if (FindAgentHandler != null)
  5388. {
  5389. FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
  5390. return true;
  5391. }
  5392. return false;
  5393. }
  5394. private bool HandleTrackAgent(IClientAPI client, Packet Packet)
  5395. {
  5396. TrackAgentPacket TrackAgent =
  5397. (TrackAgentPacket)Packet;
  5398. TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
  5399. if (TrackAgentHandler != null)
  5400. {
  5401. TrackAgentHandler(this,
  5402. TrackAgent.AgentData.AgentID,
  5403. TrackAgent.TargetData.PreyID);
  5404. return true;
  5405. }
  5406. return false;
  5407. }
  5408. private bool HandlerRezObject(IClientAPI sender, Packet Pack)
  5409. {
  5410. RezObjectPacket rezPacket = (RezObjectPacket)Pack;
  5411. #region Packet Session and User Check
  5412. if (m_checkPackets)
  5413. {
  5414. if (rezPacket.AgentData.SessionID != SessionId ||
  5415. rezPacket.AgentData.AgentID != AgentId)
  5416. return true;
  5417. }
  5418. #endregion
  5419. RezObject handlerRezObject = OnRezObject;
  5420. if (handlerRezObject != null)
  5421. {
  5422. handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
  5423. rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
  5424. rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
  5425. rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
  5426. rezPacket.RezData.FromTaskID);
  5427. }
  5428. return true;
  5429. }
  5430. private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
  5431. {
  5432. DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
  5433. #region Packet Session and User Check
  5434. if (m_checkPackets)
  5435. {
  5436. if (DeRezPacket.AgentData.SessionID != SessionId ||
  5437. DeRezPacket.AgentData.AgentID != AgentId)
  5438. return true;
  5439. }
  5440. #endregion
  5441. DeRezObject handlerDeRezObject = OnDeRezObject;
  5442. if (handlerDeRezObject != null)
  5443. {
  5444. List<uint> deRezIDs = new List<uint>();
  5445. foreach (DeRezObjectPacket.ObjectDataBlock data in
  5446. DeRezPacket.ObjectData)
  5447. {
  5448. deRezIDs.Add(data.ObjectLocalID);
  5449. }
  5450. // It just so happens that the values on the DeRezAction enumerator match the Destination
  5451. // values given by a Second Life client
  5452. handlerDeRezObject(this, deRezIDs,
  5453. DeRezPacket.AgentBlock.GroupID,
  5454. (DeRezAction)DeRezPacket.AgentBlock.Destination,
  5455. DeRezPacket.AgentBlock.DestinationID);
  5456. }
  5457. return true;
  5458. }
  5459. private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
  5460. {
  5461. ModifyLandPacket modify = (ModifyLandPacket)Pack;
  5462. #region Packet Session and User Check
  5463. if (m_checkPackets)
  5464. {
  5465. if (modify.AgentData.SessionID != SessionId ||
  5466. modify.AgentData.AgentID != AgentId)
  5467. return true;
  5468. }
  5469. #endregion
  5470. //m_log.Info("[LAND]: LAND:" + modify.ToString());
  5471. if (modify.ParcelData.Length > 0)
  5472. {
  5473. // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
  5474. // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
  5475. m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
  5476. if (OnModifyTerrain != null)
  5477. {
  5478. for (int i = 0; i < modify.ParcelData.Length; i++)
  5479. {
  5480. ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
  5481. if (handlerModifyTerrain != null)
  5482. {
  5483. handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
  5484. modify.ModifyBlock.BrushSize,
  5485. modify.ModifyBlock.Action, modify.ParcelData[i].North,
  5486. modify.ParcelData[i].West, modify.ParcelData[i].South,
  5487. modify.ParcelData[i].East, AgentId);
  5488. }
  5489. }
  5490. }
  5491. m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
  5492. }
  5493. return true;
  5494. }
  5495. private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
  5496. {
  5497. Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
  5498. if (handlerRegionHandShakeReply != null)
  5499. {
  5500. handlerRegionHandShakeReply(this);
  5501. }
  5502. return true;
  5503. }
  5504. private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
  5505. {
  5506. GenericCall1 handlerRequestWearables = OnRequestWearables;
  5507. if (handlerRequestWearables != null)
  5508. {
  5509. handlerRequestWearables(sender);
  5510. }
  5511. Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
  5512. if (handlerRequestAvatarsData != null)
  5513. {
  5514. handlerRequestAvatarsData(this);
  5515. }
  5516. return true;
  5517. }
  5518. private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
  5519. {
  5520. AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
  5521. #region Packet Session and User Check
  5522. if (m_checkPackets)
  5523. {
  5524. if (appear.AgentData.SessionID != SessionId ||
  5525. appear.AgentData.AgentID != AgentId)
  5526. return true;
  5527. }
  5528. #endregion
  5529. SetAppearance handlerSetAppearance = OnSetAppearance;
  5530. if (handlerSetAppearance != null)
  5531. {
  5532. // Temporarily protect ourselves from the mantis #951 failure.
  5533. // However, we could do this for several other handlers where a failure isn't terminal
  5534. // for the client session anyway, in order to protect ourselves against bad code in plugins
  5535. try
  5536. {
  5537. byte[] visualparams = new byte[appear.VisualParam.Length];
  5538. for (int i = 0; i < appear.VisualParam.Length; i++)
  5539. visualparams[i] = appear.VisualParam[i].ParamValue;
  5540. Primitive.TextureEntry te = null;
  5541. if (appear.ObjectData.TextureEntry.Length > 1)
  5542. te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
  5543. List<CachedTextureRequestArg> hashes = new List<CachedTextureRequestArg>();
  5544. for (int i = 0; i < appear.WearableData.Length; i++)
  5545. {
  5546. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  5547. arg.BakedTextureIndex = appear.WearableData[i].TextureIndex;
  5548. arg.WearableHashID = appear.WearableData[i].CacheID;
  5549. hashes.Add(arg);
  5550. }
  5551. handlerSetAppearance(sender, te, visualparams, hashes);
  5552. }
  5553. catch (Exception e)
  5554. {
  5555. m_log.ErrorFormat(
  5556. "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
  5557. e);
  5558. }
  5559. }
  5560. return true;
  5561. }
  5562. private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
  5563. {
  5564. if (OnAvatarNowWearing != null)
  5565. {
  5566. AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
  5567. #region Packet Session and User Check
  5568. if (m_checkPackets)
  5569. {
  5570. if (nowWearing.AgentData.SessionID != SessionId ||
  5571. nowWearing.AgentData.AgentID != AgentId)
  5572. return true;
  5573. }
  5574. #endregion
  5575. AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
  5576. for (int i = 0; i < nowWearing.WearableData.Length; i++)
  5577. {
  5578. //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
  5579. AvatarWearingArgs.Wearable wearable =
  5580. new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
  5581. nowWearing.WearableData[i].WearableType);
  5582. wearingArgs.NowWearing.Add(wearable);
  5583. }
  5584. AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
  5585. if (handlerAvatarNowWearing != null)
  5586. {
  5587. handlerAvatarNowWearing(this, wearingArgs);
  5588. }
  5589. }
  5590. return true;
  5591. }
  5592. private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
  5593. {
  5594. RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
  5595. if (handlerRezSingleAttachment != null)
  5596. {
  5597. RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
  5598. #region Packet Session and User Check
  5599. if (m_checkPackets)
  5600. {
  5601. if (rez.AgentData.SessionID != SessionId ||
  5602. rez.AgentData.AgentID != AgentId)
  5603. return true;
  5604. }
  5605. #endregion
  5606. handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
  5607. rez.ObjectData.AttachmentPt);
  5608. }
  5609. return true;
  5610. }
  5611. private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
  5612. {
  5613. RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
  5614. if (handlerRezMultipleAttachments != null)
  5615. {
  5616. List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
  5617. foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
  5618. rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
  5619. handlerRezMultipleAttachments(this, rezlist);
  5620. }
  5621. return true;
  5622. }
  5623. private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
  5624. {
  5625. UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
  5626. if (handlerDetachAttachmentIntoInv != null)
  5627. {
  5628. DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
  5629. #region Packet Session and User Check
  5630. // UNSUPPORTED ON THIS PACKET
  5631. #endregion
  5632. UUID itemID = detachtoInv.ObjectData.ItemID;
  5633. // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
  5634. handlerDetachAttachmentIntoInv(itemID, this);
  5635. }
  5636. return true;
  5637. }
  5638. private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
  5639. {
  5640. if (OnObjectAttach != null)
  5641. {
  5642. ObjectAttachPacket att = (ObjectAttachPacket)Pack;
  5643. #region Packet Session and User Check
  5644. if (m_checkPackets)
  5645. {
  5646. if (att.AgentData.SessionID != SessionId ||
  5647. att.AgentData.AgentID != AgentId)
  5648. return true;
  5649. }
  5650. #endregion
  5651. ObjectAttach handlerObjectAttach = OnObjectAttach;
  5652. if (handlerObjectAttach != null)
  5653. {
  5654. if (att.ObjectData.Length > 0)
  5655. {
  5656. handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
  5657. }
  5658. }
  5659. }
  5660. return true;
  5661. }
  5662. private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
  5663. {
  5664. ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
  5665. #region Packet Session and User Check
  5666. if (m_checkPackets)
  5667. {
  5668. if (dett.AgentData.SessionID != SessionId ||
  5669. dett.AgentData.AgentID != AgentId)
  5670. return true;
  5671. }
  5672. #endregion
  5673. for (int j = 0; j < dett.ObjectData.Length; j++)
  5674. {
  5675. uint obj = dett.ObjectData[j].ObjectLocalID;
  5676. ObjectDeselect handlerObjectDetach = OnObjectDetach;
  5677. if (handlerObjectDetach != null)
  5678. {
  5679. handlerObjectDetach(obj, this);
  5680. }
  5681. }
  5682. return true;
  5683. }
  5684. private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
  5685. {
  5686. ObjectDropPacket dropp = (ObjectDropPacket)Pack;
  5687. #region Packet Session and User Check
  5688. if (m_checkPackets)
  5689. {
  5690. if (dropp.AgentData.SessionID != SessionId ||
  5691. dropp.AgentData.AgentID != AgentId)
  5692. return true;
  5693. }
  5694. #endregion
  5695. for (int j = 0; j < dropp.ObjectData.Length; j++)
  5696. {
  5697. uint obj = dropp.ObjectData[j].ObjectLocalID;
  5698. ObjectDrop handlerObjectDrop = OnObjectDrop;
  5699. if (handlerObjectDrop != null)
  5700. {
  5701. handlerObjectDrop(obj, this);
  5702. }
  5703. }
  5704. return true;
  5705. }
  5706. private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
  5707. {
  5708. SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
  5709. #region Packet Session and User Check
  5710. if (m_checkPackets)
  5711. {
  5712. if (run.AgentData.SessionID != SessionId ||
  5713. run.AgentData.AgentID != AgentId)
  5714. return true;
  5715. }
  5716. #endregion
  5717. SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
  5718. if (handlerSetAlwaysRun != null)
  5719. handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
  5720. return true;
  5721. }
  5722. private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
  5723. {
  5724. Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
  5725. if (handlerCompleteMovementToRegion != null)
  5726. {
  5727. handlerCompleteMovementToRegion(sender, true);
  5728. }
  5729. handlerCompleteMovementToRegion = null;
  5730. return true;
  5731. }
  5732. private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
  5733. {
  5734. AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
  5735. #region Packet Session and User Check
  5736. if (m_checkPackets)
  5737. {
  5738. if (AgentAni.AgentData.SessionID != SessionId ||
  5739. AgentAni.AgentData.AgentID != AgentId)
  5740. return true;
  5741. }
  5742. #endregion
  5743. StartAnim handlerStartAnim = null;
  5744. StopAnim handlerStopAnim = null;
  5745. for (int i = 0; i < AgentAni.AnimationList.Length; i++)
  5746. {
  5747. if (AgentAni.AnimationList[i].StartAnim)
  5748. {
  5749. handlerStartAnim = OnStartAnim;
  5750. if (handlerStartAnim != null)
  5751. {
  5752. handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
  5753. }
  5754. }
  5755. else
  5756. {
  5757. handlerStopAnim = OnStopAnim;
  5758. if (handlerStopAnim != null)
  5759. {
  5760. handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
  5761. }
  5762. }
  5763. }
  5764. return true;
  5765. }
  5766. private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
  5767. {
  5768. if (OnAgentRequestSit != null)
  5769. {
  5770. AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
  5771. #region Packet Session and User Check
  5772. if (m_checkPackets)
  5773. {
  5774. if (agentRequestSit.AgentData.SessionID != SessionId ||
  5775. agentRequestSit.AgentData.AgentID != AgentId)
  5776. return true;
  5777. }
  5778. #endregion
  5779. if (SceneAgent.IsChildAgent)
  5780. {
  5781. SendCantSitBecauseChildAgentResponse();
  5782. return true;
  5783. }
  5784. AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
  5785. if (handlerAgentRequestSit != null)
  5786. handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
  5787. agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
  5788. }
  5789. return true;
  5790. }
  5791. private bool HandleAgentSit(IClientAPI sender, Packet Pack)
  5792. {
  5793. if (OnAgentSit != null)
  5794. {
  5795. AgentSitPacket agentSit = (AgentSitPacket)Pack;
  5796. #region Packet Session and User Check
  5797. if (m_checkPackets)
  5798. {
  5799. if (agentSit.AgentData.SessionID != SessionId ||
  5800. agentSit.AgentData.AgentID != AgentId)
  5801. return true;
  5802. }
  5803. #endregion
  5804. if (SceneAgent.IsChildAgent)
  5805. {
  5806. SendCantSitBecauseChildAgentResponse();
  5807. return true;
  5808. }
  5809. AgentSit handlerAgentSit = OnAgentSit;
  5810. if (handlerAgentSit != null)
  5811. {
  5812. OnAgentSit(this, agentSit.AgentData.AgentID);
  5813. }
  5814. }
  5815. return true;
  5816. }
  5817. /// <summary>
  5818. /// Used when a child agent gets a sit response which should not be fulfilled.
  5819. /// </summary>
  5820. private void SendCantSitBecauseChildAgentResponse()
  5821. {
  5822. SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
  5823. }
  5824. private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
  5825. {
  5826. SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
  5827. #region Packet Session and User Check
  5828. if (m_checkPackets)
  5829. {
  5830. // UNSUPPORTED ON THIS PACKET
  5831. }
  5832. #endregion
  5833. SoundTrigger handlerSoundTrigger = OnSoundTrigger;
  5834. if (handlerSoundTrigger != null)
  5835. {
  5836. // UUIDS are sent as zeroes by the client, substitute agent's id
  5837. handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
  5838. AgentId, AgentId,
  5839. soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
  5840. soundTriggerPacket.SoundData.Handle, 0);
  5841. }
  5842. return true;
  5843. }
  5844. private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
  5845. {
  5846. AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
  5847. #region Packet Session and User Check
  5848. if (m_checkPackets)
  5849. {
  5850. if (avRequestQuery.AgentData.SessionID != SessionId ||
  5851. avRequestQuery.AgentData.AgentID != AgentId)
  5852. return true;
  5853. }
  5854. #endregion
  5855. AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
  5856. AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
  5857. //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
  5858. AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
  5859. if (handlerAvatarPickerRequest != null)
  5860. {
  5861. handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
  5862. Utils.BytesToString(querydata.Name));
  5863. }
  5864. return true;
  5865. }
  5866. private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
  5867. {
  5868. AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
  5869. #region Packet Session and User Check
  5870. if (m_checkPackets)
  5871. {
  5872. if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
  5873. avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
  5874. return true;
  5875. }
  5876. #endregion
  5877. FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
  5878. if (handlerAgentDataUpdateRequest != null)
  5879. {
  5880. handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
  5881. }
  5882. return true;
  5883. }
  5884. private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
  5885. {
  5886. UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
  5887. if (handlerUserInfoRequest != null)
  5888. {
  5889. handlerUserInfoRequest(this);
  5890. }
  5891. else
  5892. {
  5893. SendUserInfoReply(false, true, "");
  5894. }
  5895. return true;
  5896. }
  5897. private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
  5898. {
  5899. UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
  5900. #region Packet Session and User Check
  5901. if (m_checkPackets)
  5902. {
  5903. if (updateUserInfo.AgentData.SessionID != SessionId ||
  5904. updateUserInfo.AgentData.AgentID != AgentId)
  5905. return true;
  5906. }
  5907. #endregion
  5908. UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
  5909. if (handlerUpdateUserInfo != null)
  5910. {
  5911. bool visible = true;
  5912. string DirectoryVisibility =
  5913. Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
  5914. if (DirectoryVisibility == "hidden")
  5915. visible = false;
  5916. handlerUpdateUserInfo(
  5917. updateUserInfo.UserData.IMViaEMail,
  5918. visible, this);
  5919. }
  5920. return true;
  5921. }
  5922. private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
  5923. {
  5924. SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
  5925. #region Packet Session and User Check
  5926. if (m_checkPackets)
  5927. {
  5928. if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
  5929. avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
  5930. return true;
  5931. }
  5932. #endregion
  5933. if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
  5934. {
  5935. // Linden Client limitation..
  5936. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
  5937. || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5938. {
  5939. ScenePresence avatar = null;
  5940. if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
  5941. {
  5942. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
  5943. {
  5944. avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
  5945. }
  5946. if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
  5947. {
  5948. avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
  5949. }
  5950. }
  5951. }
  5952. TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
  5953. if (handlerSetStartLocationRequest != null)
  5954. {
  5955. handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
  5956. avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
  5957. avSetStartLocationRequestPacket.StartLocationData.LocationID);
  5958. }
  5959. }
  5960. return true;
  5961. }
  5962. private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
  5963. {
  5964. AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
  5965. #region Packet Session and User Check
  5966. if (m_checkPackets)
  5967. {
  5968. if (atpack.AgentData.SessionID != SessionId ||
  5969. atpack.AgentData.AgentID != AgentId)
  5970. return true;
  5971. }
  5972. #endregion
  5973. m_udpClient.SetThrottles(atpack.Throttle.Throttles);
  5974. return true;
  5975. }
  5976. private bool HandleAgentPause(IClientAPI sender, Packet Pack)
  5977. {
  5978. m_udpClient.IsPaused = true;
  5979. return true;
  5980. }
  5981. private bool HandleAgentResume(IClientAPI sender, Packet Pack)
  5982. {
  5983. m_udpClient.IsPaused = false;
  5984. SendStartPingCheck(m_udpClient.CurrentPingSequence++);
  5985. return true;
  5986. }
  5987. private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
  5988. {
  5989. ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
  5990. if (handlerForceReleaseControls != null)
  5991. {
  5992. handlerForceReleaseControls(this, AgentId);
  5993. }
  5994. return true;
  5995. }
  5996. #endregion Scene/Avatar
  5997. #region Objects/m_sceneObjects
  5998. private bool HandleObjectLink(IClientAPI sender, Packet Pack)
  5999. {
  6000. ObjectLinkPacket link = (ObjectLinkPacket)Pack;
  6001. #region Packet Session and User Check
  6002. if (m_checkPackets)
  6003. {
  6004. if (link.AgentData.SessionID != SessionId ||
  6005. link.AgentData.AgentID != AgentId)
  6006. return true;
  6007. }
  6008. #endregion
  6009. uint parentprimid = 0;
  6010. List<uint> childrenprims = new List<uint>();
  6011. if (link.ObjectData.Length > 1)
  6012. {
  6013. parentprimid = link.ObjectData[0].ObjectLocalID;
  6014. for (int i = 1; i < link.ObjectData.Length; i++)
  6015. {
  6016. childrenprims.Add(link.ObjectData[i].ObjectLocalID);
  6017. }
  6018. }
  6019. LinkObjects handlerLinkObjects = OnLinkObjects;
  6020. if (handlerLinkObjects != null)
  6021. {
  6022. handlerLinkObjects(this, parentprimid, childrenprims);
  6023. }
  6024. return true;
  6025. }
  6026. private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
  6027. {
  6028. ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
  6029. #region Packet Session and User Check
  6030. if (m_checkPackets)
  6031. {
  6032. if (delink.AgentData.SessionID != SessionId ||
  6033. delink.AgentData.AgentID != AgentId)
  6034. return true;
  6035. }
  6036. #endregion
  6037. // It appears the prim at index 0 is not always the root prim (for
  6038. // instance, when one prim of a link set has been edited independently
  6039. // of the others). Therefore, we'll pass all the ids onto the delink
  6040. // method for it to decide which is the root.
  6041. List<uint> prims = new List<uint>();
  6042. for (int i = 0; i < delink.ObjectData.Length; i++)
  6043. {
  6044. prims.Add(delink.ObjectData[i].ObjectLocalID);
  6045. }
  6046. DelinkObjects handlerDelinkObjects = OnDelinkObjects;
  6047. if (handlerDelinkObjects != null)
  6048. {
  6049. handlerDelinkObjects(prims, this);
  6050. }
  6051. return true;
  6052. }
  6053. private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
  6054. {
  6055. if (OnAddPrim != null)
  6056. {
  6057. ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
  6058. #region Packet Session and User Check
  6059. if (m_checkPackets)
  6060. {
  6061. if (addPacket.AgentData.SessionID != SessionId ||
  6062. addPacket.AgentData.AgentID != AgentId)
  6063. return true;
  6064. }
  6065. #endregion
  6066. PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
  6067. // m_log.Info("[REZData]: " + addPacket.ToString());
  6068. //BypassRaycast: 1
  6069. //RayStart: <69.79469, 158.2652, 98.40343>
  6070. //RayEnd: <61.97724, 141.995, 92.58341>
  6071. //RayTargetID: 00000000-0000-0000-0000-000000000000
  6072. //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
  6073. //object from rezing initially
  6074. AddNewPrim handlerAddPrim = OnAddPrim;
  6075. if (handlerAddPrim != null)
  6076. handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
  6077. }
  6078. return true;
  6079. }
  6080. private bool HandleObjectShape(IClientAPI sender, Packet Pack)
  6081. {
  6082. ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
  6083. #region Packet Session and User Check
  6084. if (m_checkPackets)
  6085. {
  6086. if (shapePacket.AgentData.SessionID != SessionId ||
  6087. shapePacket.AgentData.AgentID != AgentId)
  6088. return true;
  6089. }
  6090. #endregion
  6091. UpdateShape handlerUpdatePrimShape = null;
  6092. for (int i = 0; i < shapePacket.ObjectData.Length; i++)
  6093. {
  6094. handlerUpdatePrimShape = OnUpdatePrimShape;
  6095. if (handlerUpdatePrimShape != null)
  6096. {
  6097. UpdateShapeArgs shapeData = new UpdateShapeArgs();
  6098. shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
  6099. shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
  6100. shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
  6101. shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
  6102. shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
  6103. shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
  6104. shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
  6105. shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
  6106. shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
  6107. shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
  6108. shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
  6109. shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
  6110. shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
  6111. shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
  6112. shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
  6113. shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
  6114. shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
  6115. shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
  6116. shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
  6117. handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
  6118. shapeData);
  6119. }
  6120. }
  6121. return true;
  6122. }
  6123. private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
  6124. {
  6125. ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
  6126. #region Packet Session and User Check
  6127. if (m_checkPackets)
  6128. {
  6129. if (extraPar.AgentData.SessionID != SessionId ||
  6130. extraPar.AgentData.AgentID != AgentId)
  6131. return true;
  6132. }
  6133. #endregion
  6134. ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
  6135. if (handlerUpdateExtraParams != null)
  6136. {
  6137. for (int i = 0; i < extraPar.ObjectData.Length; i++)
  6138. {
  6139. handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
  6140. extraPar.ObjectData[i].ParamType,
  6141. extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
  6142. }
  6143. }
  6144. return true;
  6145. }
  6146. private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
  6147. {
  6148. ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
  6149. #region Packet Session and User Check
  6150. if (m_checkPackets)
  6151. {
  6152. if (dupe.AgentData.SessionID != SessionId ||
  6153. dupe.AgentData.AgentID != AgentId)
  6154. return true;
  6155. }
  6156. #endregion
  6157. // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
  6158. ObjectDuplicate handlerObjectDuplicate = null;
  6159. for (int i = 0; i < dupe.ObjectData.Length; i++)
  6160. {
  6161. handlerObjectDuplicate = OnObjectDuplicate;
  6162. if (handlerObjectDuplicate != null)
  6163. {
  6164. handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
  6165. dupe.SharedData.DuplicateFlags, AgentId,
  6166. m_activeGroupID);
  6167. }
  6168. }
  6169. return true;
  6170. }
  6171. private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
  6172. {
  6173. RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
  6174. #region Packet Session and User Check
  6175. if (m_checkPackets)
  6176. {
  6177. if (incomingRequest.AgentData.SessionID != SessionId ||
  6178. incomingRequest.AgentData.AgentID != AgentId)
  6179. return true;
  6180. }
  6181. #endregion
  6182. ObjectRequest handlerObjectRequest = null;
  6183. for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
  6184. {
  6185. handlerObjectRequest = OnObjectRequest;
  6186. if (handlerObjectRequest != null)
  6187. {
  6188. handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
  6189. }
  6190. }
  6191. return true;
  6192. }
  6193. private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
  6194. {
  6195. ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
  6196. #region Packet Session and User Check
  6197. if (m_checkPackets)
  6198. {
  6199. if (incomingselect.AgentData.SessionID != SessionId ||
  6200. incomingselect.AgentData.AgentID != AgentId)
  6201. return true;
  6202. }
  6203. #endregion
  6204. ObjectSelect handlerObjectSelect = null;
  6205. for (int i = 0; i < incomingselect.ObjectData.Length; i++)
  6206. {
  6207. handlerObjectSelect = OnObjectSelect;
  6208. if (handlerObjectSelect != null)
  6209. {
  6210. handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
  6211. }
  6212. }
  6213. return true;
  6214. }
  6215. private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
  6216. {
  6217. ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
  6218. #region Packet Session and User Check
  6219. if (m_checkPackets)
  6220. {
  6221. if (incomingdeselect.AgentData.SessionID != SessionId ||
  6222. incomingdeselect.AgentData.AgentID != AgentId)
  6223. return true;
  6224. }
  6225. #endregion
  6226. ObjectDeselect handlerObjectDeselect = null;
  6227. for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
  6228. {
  6229. handlerObjectDeselect = OnObjectDeselect;
  6230. if (handlerObjectDeselect != null)
  6231. {
  6232. OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
  6233. }
  6234. }
  6235. return true;
  6236. }
  6237. private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
  6238. {
  6239. // DEPRECATED: but till libsecondlife removes it, people will use it
  6240. ObjectPositionPacket position = (ObjectPositionPacket)Pack;
  6241. #region Packet Session and User Check
  6242. if (m_checkPackets)
  6243. {
  6244. if (position.AgentData.SessionID != SessionId ||
  6245. position.AgentData.AgentID != AgentId)
  6246. return true;
  6247. }
  6248. #endregion
  6249. for (int i = 0; i < position.ObjectData.Length; i++)
  6250. {
  6251. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  6252. if (handlerUpdateVector != null)
  6253. handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
  6254. }
  6255. return true;
  6256. }
  6257. private bool HandleObjectScale(IClientAPI sender, Packet Pack)
  6258. {
  6259. // DEPRECATED: but till libsecondlife removes it, people will use it
  6260. ObjectScalePacket scale = (ObjectScalePacket)Pack;
  6261. #region Packet Session and User Check
  6262. if (m_checkPackets)
  6263. {
  6264. if (scale.AgentData.SessionID != SessionId ||
  6265. scale.AgentData.AgentID != AgentId)
  6266. return true;
  6267. }
  6268. #endregion
  6269. for (int i = 0; i < scale.ObjectData.Length; i++)
  6270. {
  6271. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  6272. if (handlerUpdatePrimGroupScale != null)
  6273. handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
  6274. }
  6275. return true;
  6276. }
  6277. private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
  6278. {
  6279. // DEPRECATED: but till libsecondlife removes it, people will use it
  6280. ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
  6281. #region Packet Session and User Check
  6282. if (m_checkPackets)
  6283. {
  6284. if (rotation.AgentData.SessionID != SessionId ||
  6285. rotation.AgentData.AgentID != AgentId)
  6286. return true;
  6287. }
  6288. #endregion
  6289. for (int i = 0; i < rotation.ObjectData.Length; i++)
  6290. {
  6291. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  6292. if (handlerUpdatePrimRotation != null)
  6293. handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
  6294. }
  6295. return true;
  6296. }
  6297. private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
  6298. {
  6299. ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
  6300. #region Packet Session and User Check
  6301. if (m_checkPackets)
  6302. {
  6303. if (flags.AgentData.SessionID != SessionId ||
  6304. flags.AgentData.AgentID != AgentId)
  6305. return true;
  6306. }
  6307. #endregion
  6308. UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
  6309. if (handlerUpdatePrimFlags != null)
  6310. {
  6311. // byte[] data = Pack.ToBytes();
  6312. // 46,47,48 are special positions within the packet
  6313. // This may change so perhaps we need a better way
  6314. // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
  6315. /*
  6316. bool UsePhysics = (data[46] != 0) ? true : false;
  6317. bool IsTemporary = (data[47] != 0) ? true : false;
  6318. bool IsPhantom = (data[48] != 0) ? true : false;
  6319. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
  6320. */
  6321. bool UsePhysics = flags.AgentData.UsePhysics;
  6322. bool IsPhantom = flags.AgentData.IsPhantom;
  6323. bool IsTemporary = flags.AgentData.IsTemporary;
  6324. ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
  6325. ExtraPhysicsData physdata = new ExtraPhysicsData();
  6326. if (blocks == null || blocks.Length == 0)
  6327. {
  6328. physdata.PhysShapeType = PhysShapeType.invalid;
  6329. }
  6330. else
  6331. {
  6332. ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
  6333. physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
  6334. physdata.Bounce = phsblock.Restitution;
  6335. physdata.Density = phsblock.Density;
  6336. physdata.Friction = phsblock.Friction;
  6337. physdata.GravitationModifier = phsblock.GravityMultiplier;
  6338. }
  6339. handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
  6340. }
  6341. return true;
  6342. }
  6343. private bool HandleObjectImage(IClientAPI sender, Packet Pack)
  6344. {
  6345. ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
  6346. UpdatePrimTexture handlerUpdatePrimTexture = null;
  6347. for (int i = 0; i < imagePack.ObjectData.Length; i++)
  6348. {
  6349. handlerUpdatePrimTexture = OnUpdatePrimTexture;
  6350. if (handlerUpdatePrimTexture != null)
  6351. {
  6352. handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
  6353. imagePack.ObjectData[i].TextureEntry, this);
  6354. }
  6355. }
  6356. return true;
  6357. }
  6358. private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
  6359. {
  6360. ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
  6361. #region Packet Session and User Check
  6362. if (m_checkPackets)
  6363. {
  6364. if (grab.AgentData.SessionID != SessionId ||
  6365. grab.AgentData.AgentID != AgentId)
  6366. return true;
  6367. }
  6368. #endregion
  6369. GrabObject handlerGrabObject = OnGrabObject;
  6370. if (handlerGrabObject != null)
  6371. {
  6372. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6373. if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
  6374. {
  6375. foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
  6376. {
  6377. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6378. arg.Binormal = surfaceInfo.Binormal;
  6379. arg.FaceIndex = surfaceInfo.FaceIndex;
  6380. arg.Normal = surfaceInfo.Normal;
  6381. arg.Position = surfaceInfo.Position;
  6382. arg.STCoord = surfaceInfo.STCoord;
  6383. arg.UVCoord = surfaceInfo.UVCoord;
  6384. touchArgs.Add(arg);
  6385. }
  6386. }
  6387. handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
  6388. }
  6389. return true;
  6390. }
  6391. private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
  6392. {
  6393. ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
  6394. #region Packet Session and User Check
  6395. if (m_checkPackets)
  6396. {
  6397. if (grabUpdate.AgentData.SessionID != SessionId ||
  6398. grabUpdate.AgentData.AgentID != AgentId)
  6399. return true;
  6400. }
  6401. #endregion
  6402. MoveObject handlerGrabUpdate = OnGrabUpdate;
  6403. if (handlerGrabUpdate != null)
  6404. {
  6405. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6406. if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
  6407. {
  6408. foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
  6409. {
  6410. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6411. arg.Binormal = surfaceInfo.Binormal;
  6412. arg.FaceIndex = surfaceInfo.FaceIndex;
  6413. arg.Normal = surfaceInfo.Normal;
  6414. arg.Position = surfaceInfo.Position;
  6415. arg.STCoord = surfaceInfo.STCoord;
  6416. arg.UVCoord = surfaceInfo.UVCoord;
  6417. touchArgs.Add(arg);
  6418. }
  6419. }
  6420. handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
  6421. grabUpdate.ObjectData.GrabPosition, this, touchArgs);
  6422. }
  6423. return true;
  6424. }
  6425. private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
  6426. {
  6427. ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
  6428. #region Packet Session and User Check
  6429. if (m_checkPackets)
  6430. {
  6431. if (deGrab.AgentData.SessionID != SessionId ||
  6432. deGrab.AgentData.AgentID != AgentId)
  6433. return true;
  6434. }
  6435. #endregion
  6436. DeGrabObject handlerDeGrabObject = OnDeGrabObject;
  6437. if (handlerDeGrabObject != null)
  6438. {
  6439. List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
  6440. if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
  6441. {
  6442. foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
  6443. {
  6444. SurfaceTouchEventArgs arg = new SurfaceTouchEventArgs();
  6445. arg.Binormal = surfaceInfo.Binormal;
  6446. arg.FaceIndex = surfaceInfo.FaceIndex;
  6447. arg.Normal = surfaceInfo.Normal;
  6448. arg.Position = surfaceInfo.Position;
  6449. arg.STCoord = surfaceInfo.STCoord;
  6450. arg.UVCoord = surfaceInfo.UVCoord;
  6451. touchArgs.Add(arg);
  6452. }
  6453. }
  6454. handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
  6455. }
  6456. return true;
  6457. }
  6458. private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
  6459. {
  6460. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
  6461. ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
  6462. #region Packet Session and User Check
  6463. if (m_checkPackets)
  6464. {
  6465. if (spinStart.AgentData.SessionID != SessionId ||
  6466. spinStart.AgentData.AgentID != AgentId)
  6467. return true;
  6468. }
  6469. #endregion
  6470. SpinStart handlerSpinStart = OnSpinStart;
  6471. if (handlerSpinStart != null)
  6472. {
  6473. handlerSpinStart(spinStart.ObjectData.ObjectID, this);
  6474. }
  6475. return true;
  6476. }
  6477. private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
  6478. {
  6479. //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
  6480. ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
  6481. #region Packet Session and User Check
  6482. if (m_checkPackets)
  6483. {
  6484. if (spinUpdate.AgentData.SessionID != SessionId ||
  6485. spinUpdate.AgentData.AgentID != AgentId)
  6486. return true;
  6487. }
  6488. #endregion
  6489. Vector3 axis;
  6490. float angle;
  6491. spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
  6492. //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
  6493. SpinObject handlerSpinUpdate = OnSpinUpdate;
  6494. if (handlerSpinUpdate != null)
  6495. {
  6496. handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
  6497. }
  6498. return true;
  6499. }
  6500. private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
  6501. {
  6502. //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
  6503. ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
  6504. #region Packet Session and User Check
  6505. if (m_checkPackets)
  6506. {
  6507. if (spinStop.AgentData.SessionID != SessionId ||
  6508. spinStop.AgentData.AgentID != AgentId)
  6509. return true;
  6510. }
  6511. #endregion
  6512. SpinStop handlerSpinStop = OnSpinStop;
  6513. if (handlerSpinStop != null)
  6514. {
  6515. handlerSpinStop(spinStop.ObjectData.ObjectID, this);
  6516. }
  6517. return true;
  6518. }
  6519. private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
  6520. {
  6521. ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
  6522. #region Packet Session and User Check
  6523. if (m_checkPackets)
  6524. {
  6525. if (objDes.AgentData.SessionID != SessionId ||
  6526. objDes.AgentData.AgentID != AgentId)
  6527. return true;
  6528. }
  6529. #endregion
  6530. GenericCall7 handlerObjectDescription = null;
  6531. for (int i = 0; i < objDes.ObjectData.Length; i++)
  6532. {
  6533. handlerObjectDescription = OnObjectDescription;
  6534. if (handlerObjectDescription != null)
  6535. {
  6536. handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
  6537. Util.FieldToString(objDes.ObjectData[i].Description));
  6538. }
  6539. }
  6540. return true;
  6541. }
  6542. private bool HandleObjectName(IClientAPI sender, Packet Pack)
  6543. {
  6544. ObjectNamePacket objName = (ObjectNamePacket)Pack;
  6545. #region Packet Session and User Check
  6546. if (m_checkPackets)
  6547. {
  6548. if (objName.AgentData.SessionID != SessionId ||
  6549. objName.AgentData.AgentID != AgentId)
  6550. return true;
  6551. }
  6552. #endregion
  6553. GenericCall7 handlerObjectName = null;
  6554. for (int i = 0; i < objName.ObjectData.Length; i++)
  6555. {
  6556. handlerObjectName = OnObjectName;
  6557. if (handlerObjectName != null)
  6558. {
  6559. handlerObjectName(this, objName.ObjectData[i].LocalID,
  6560. Util.FieldToString(objName.ObjectData[i].Name));
  6561. }
  6562. }
  6563. return true;
  6564. }
  6565. private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
  6566. {
  6567. if (OnObjectPermissions != null)
  6568. {
  6569. ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
  6570. #region Packet Session and User Check
  6571. if (m_checkPackets)
  6572. {
  6573. if (newobjPerms.AgentData.SessionID != SessionId ||
  6574. newobjPerms.AgentData.AgentID != AgentId)
  6575. return true;
  6576. }
  6577. #endregion
  6578. UUID AgentID = newobjPerms.AgentData.AgentID;
  6579. UUID SessionID = newobjPerms.AgentData.SessionID;
  6580. ObjectPermissions handlerObjectPermissions = null;
  6581. for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
  6582. {
  6583. ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
  6584. byte field = permChanges.Field;
  6585. uint localID = permChanges.ObjectLocalID;
  6586. uint mask = permChanges.Mask;
  6587. byte set = permChanges.Set;
  6588. handlerObjectPermissions = OnObjectPermissions;
  6589. if (handlerObjectPermissions != null)
  6590. handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
  6591. }
  6592. }
  6593. // Here's our data,
  6594. // PermField contains the field the info goes into
  6595. // PermField determines which mask we're changing
  6596. //
  6597. // chmask is the mask of the change
  6598. // setTF is whether we're adding it or taking it away
  6599. //
  6600. // objLocalID is the localID of the object.
  6601. // Unfortunately, we have to pass the event the packet because objData is an array
  6602. // That means multiple object perms may be updated in a single packet.
  6603. return true;
  6604. }
  6605. private bool HandleUndo(IClientAPI sender, Packet Pack)
  6606. {
  6607. UndoPacket undoitem = (UndoPacket)Pack;
  6608. #region Packet Session and User Check
  6609. if (m_checkPackets)
  6610. {
  6611. if (undoitem.AgentData.SessionID != SessionId ||
  6612. undoitem.AgentData.AgentID != AgentId)
  6613. return true;
  6614. }
  6615. #endregion
  6616. if (undoitem.ObjectData.Length > 0)
  6617. {
  6618. for (int i = 0; i < undoitem.ObjectData.Length; i++)
  6619. {
  6620. UUID objiD = undoitem.ObjectData[i].ObjectID;
  6621. AgentSit handlerOnUndo = OnUndo;
  6622. if (handlerOnUndo != null)
  6623. {
  6624. handlerOnUndo(this, objiD);
  6625. }
  6626. }
  6627. }
  6628. return true;
  6629. }
  6630. private bool HandleLandUndo(IClientAPI sender, Packet Pack)
  6631. {
  6632. UndoLandPacket undolanditem = (UndoLandPacket)Pack;
  6633. #region Packet Session and User Check
  6634. if (m_checkPackets)
  6635. {
  6636. if (undolanditem.AgentData.SessionID != SessionId ||
  6637. undolanditem.AgentData.AgentID != AgentId)
  6638. return true;
  6639. }
  6640. #endregion
  6641. LandUndo handlerOnUndo = OnLandUndo;
  6642. if (handlerOnUndo != null)
  6643. {
  6644. handlerOnUndo(this);
  6645. }
  6646. return true;
  6647. }
  6648. private bool HandleRedo(IClientAPI sender, Packet Pack)
  6649. {
  6650. RedoPacket redoitem = (RedoPacket)Pack;
  6651. #region Packet Session and User Check
  6652. if (m_checkPackets)
  6653. {
  6654. if (redoitem.AgentData.SessionID != SessionId ||
  6655. redoitem.AgentData.AgentID != AgentId)
  6656. return true;
  6657. }
  6658. #endregion
  6659. if (redoitem.ObjectData.Length > 0)
  6660. {
  6661. for (int i = 0; i < redoitem.ObjectData.Length; i++)
  6662. {
  6663. UUID objiD = redoitem.ObjectData[i].ObjectID;
  6664. AgentSit handlerOnRedo = OnRedo;
  6665. if (handlerOnRedo != null)
  6666. {
  6667. handlerOnRedo(this, objiD);
  6668. }
  6669. }
  6670. }
  6671. return true;
  6672. }
  6673. private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
  6674. {
  6675. ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
  6676. #region Packet Session and User Check
  6677. if (m_checkPackets)
  6678. {
  6679. if (dupeOnRay.AgentData.SessionID != SessionId ||
  6680. dupeOnRay.AgentData.AgentID != AgentId)
  6681. return true;
  6682. }
  6683. #endregion
  6684. ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
  6685. for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
  6686. {
  6687. handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
  6688. if (handlerObjectDuplicateOnRay != null)
  6689. {
  6690. handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
  6691. AgentId, m_activeGroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
  6692. dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
  6693. dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
  6694. }
  6695. }
  6696. return true;
  6697. }
  6698. private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
  6699. {
  6700. //This powers the little tooltip that appears when you move your mouse over an object
  6701. RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
  6702. #region Packet Session and User Check
  6703. if (m_checkPackets)
  6704. {
  6705. if (packToolTip.AgentData.SessionID != SessionId ||
  6706. packToolTip.AgentData.AgentID != AgentId)
  6707. return true;
  6708. }
  6709. #endregion
  6710. RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
  6711. RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
  6712. if (handlerRequestObjectPropertiesFamily != null)
  6713. {
  6714. handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
  6715. packObjBlock.ObjectID);
  6716. }
  6717. return true;
  6718. }
  6719. private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
  6720. {
  6721. //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
  6722. ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
  6723. ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
  6724. #region Packet Session and User Check
  6725. if (m_checkPackets)
  6726. {
  6727. if (packInSearch.AgentData.SessionID != SessionId ||
  6728. packInSearch.AgentData.AgentID != AgentId)
  6729. return true;
  6730. }
  6731. #endregion
  6732. foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
  6733. {
  6734. bool inSearch = objData.IncludeInSearch;
  6735. uint localID = objData.ObjectLocalID;
  6736. handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
  6737. if (handlerObjectIncludeInSearch != null)
  6738. {
  6739. handlerObjectIncludeInSearch(this, inSearch, localID);
  6740. }
  6741. }
  6742. return true;
  6743. }
  6744. private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
  6745. {
  6746. ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
  6747. #region Packet Session and User Check
  6748. if (m_checkPackets)
  6749. {
  6750. if (scriptAnswer.AgentData.SessionID != SessionId ||
  6751. scriptAnswer.AgentData.AgentID != AgentId)
  6752. return true;
  6753. }
  6754. #endregion
  6755. ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
  6756. if (handlerScriptAnswer != null)
  6757. {
  6758. handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
  6759. }
  6760. return true;
  6761. }
  6762. private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
  6763. {
  6764. ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
  6765. #region Packet Session and User Check
  6766. if (m_checkPackets)
  6767. {
  6768. if (ocpacket.AgentData.SessionID != SessionId ||
  6769. ocpacket.AgentData.AgentID != AgentId)
  6770. return true;
  6771. }
  6772. #endregion
  6773. GenericCall7 handlerObjectClickAction = OnObjectClickAction;
  6774. if (handlerObjectClickAction != null)
  6775. {
  6776. foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
  6777. {
  6778. byte action = odata.ClickAction;
  6779. uint localID = odata.ObjectLocalID;
  6780. handlerObjectClickAction(this, localID, action.ToString());
  6781. }
  6782. }
  6783. return true;
  6784. }
  6785. private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
  6786. {
  6787. ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
  6788. #region Packet Session and User Check
  6789. if (m_checkPackets)
  6790. {
  6791. if (ompacket.AgentData.SessionID != SessionId ||
  6792. ompacket.AgentData.AgentID != AgentId)
  6793. return true;
  6794. }
  6795. #endregion
  6796. GenericCall7 handlerObjectMaterial = OnObjectMaterial;
  6797. if (handlerObjectMaterial != null)
  6798. {
  6799. foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
  6800. {
  6801. byte material = odata.Material;
  6802. uint localID = odata.ObjectLocalID;
  6803. handlerObjectMaterial(this, localID, material.ToString());
  6804. }
  6805. }
  6806. return true;
  6807. }
  6808. #endregion Objects/m_sceneObjects
  6809. #region Inventory/Asset/Other related packets
  6810. private bool HandleRequestImage(IClientAPI sender, Packet Pack)
  6811. {
  6812. RequestImagePacket imageRequest = (RequestImagePacket)Pack;
  6813. //m_log.Debug("image request: " + Pack.ToString());
  6814. #region Packet Session and User Check
  6815. if (m_checkPackets)
  6816. {
  6817. if (imageRequest.AgentData.SessionID != SessionId ||
  6818. imageRequest.AgentData.AgentID != AgentId)
  6819. return true;
  6820. }
  6821. #endregion
  6822. //handlerTextureRequest = null;
  6823. for (int i = 0; i < imageRequest.RequestImage.Length; i++)
  6824. {
  6825. TextureRequestArgs args = new TextureRequestArgs();
  6826. RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
  6827. args.RequestedAssetID = block.Image;
  6828. args.DiscardLevel = block.DiscardLevel;
  6829. args.PacketNumber = block.Packet;
  6830. args.Priority = block.DownloadPriority;
  6831. args.requestSequence = imageRequest.Header.Sequence;
  6832. // NOTE: This is not a built in part of the LLUDP protocol, but we double the
  6833. // priority of avatar textures to get avatars rezzing in faster than the
  6834. // surrounding scene
  6835. if ((ImageType)block.Type == ImageType.Baked)
  6836. args.Priority *= 2.0f;
  6837. ImageManager.EnqueueReq(args);
  6838. }
  6839. return true;
  6840. }
  6841. /// <summary>
  6842. /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
  6843. /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
  6844. /// </summary>
  6845. /// <param name="sender"></param>
  6846. /// <param name="Pack"></param>
  6847. /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
  6848. private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
  6849. {
  6850. //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
  6851. TransferRequestPacket transfer = (TransferRequestPacket)Pack;
  6852. UUID taskID = UUID.Zero;
  6853. if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  6854. {
  6855. if (!(((Scene)m_scene).Permissions.BypassPermissions()))
  6856. {
  6857. // We're spawning a thread because the permissions check can block this thread
  6858. Util.FireAndForget(delegate
  6859. {
  6860. // This requests the asset if needed
  6861. HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
  6862. });
  6863. return true;
  6864. }
  6865. }
  6866. else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
  6867. {
  6868. //TransferRequestPacket does not include covenant uuid?
  6869. //get scene covenant uuid
  6870. taskID = m_scene.RegionInfo.RegionSettings.Covenant;
  6871. }
  6872. // This is non-blocking
  6873. MakeAssetRequest(transfer, taskID);
  6874. return true;
  6875. }
  6876. private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
  6877. {
  6878. UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
  6879. UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
  6880. UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
  6881. //m_log.DebugFormat(
  6882. // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
  6883. // requestID, itemID, taskID, Name);
  6884. //m_log.Debug("Transfer Request: " + transfer.ToString());
  6885. // Validate inventory transfers
  6886. // Has to be done here, because AssetCache can't do it
  6887. //
  6888. if (taskID != UUID.Zero) // Prim
  6889. {
  6890. SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
  6891. if (part == null)
  6892. {
  6893. m_log.WarnFormat(
  6894. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
  6895. Name, requestID, itemID, taskID);
  6896. return;
  6897. }
  6898. TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
  6899. if (tii == null)
  6900. {
  6901. m_log.WarnFormat(
  6902. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
  6903. Name, requestID, itemID, taskID);
  6904. return;
  6905. }
  6906. if (tii.Type == (int)AssetType.LSLText)
  6907. {
  6908. if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
  6909. return;
  6910. }
  6911. else if (tii.Type == (int)AssetType.Notecard)
  6912. {
  6913. if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
  6914. return;
  6915. }
  6916. else
  6917. {
  6918. // TODO: Change this code to allow items other than notecards and scripts to be successfully
  6919. // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
  6920. if (part.OwnerID != AgentId)
  6921. {
  6922. m_log.WarnFormat(
  6923. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
  6924. Name, requestID, itemID, taskID, part.OwnerID);
  6925. return;
  6926. }
  6927. if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
  6928. {
  6929. m_log.WarnFormat(
  6930. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
  6931. Name, requestID, itemID, taskID);
  6932. return;
  6933. }
  6934. if (tii.OwnerID != AgentId)
  6935. {
  6936. m_log.WarnFormat(
  6937. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
  6938. Name, requestID, itemID, taskID, tii.OwnerID);
  6939. return;
  6940. }
  6941. if ((
  6942. tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6943. != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
  6944. {
  6945. m_log.WarnFormat(
  6946. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
  6947. Name, requestID, itemID, taskID);
  6948. return;
  6949. }
  6950. if (tii.AssetID != requestID)
  6951. {
  6952. m_log.WarnFormat(
  6953. "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
  6954. Name, requestID, itemID, taskID, tii.AssetID);
  6955. return;
  6956. }
  6957. }
  6958. }
  6959. else // Agent
  6960. {
  6961. IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
  6962. if (invAccess != null)
  6963. {
  6964. if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
  6965. return;
  6966. }
  6967. else
  6968. {
  6969. return;
  6970. }
  6971. }
  6972. // Permissions out of the way, let's request the asset
  6973. MakeAssetRequest(transfer, taskID);
  6974. }
  6975. private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
  6976. {
  6977. AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
  6978. // m_log.Debug("upload request " + request.ToString());
  6979. // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
  6980. UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
  6981. UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
  6982. if (handlerAssetUploadRequest != null)
  6983. {
  6984. handlerAssetUploadRequest(this, temp,
  6985. request.AssetBlock.TransactionID, request.AssetBlock.Type,
  6986. request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
  6987. request.AssetBlock.Tempfile);
  6988. }
  6989. return true;
  6990. }
  6991. private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
  6992. {
  6993. RequestXferPacket xferReq = (RequestXferPacket)Pack;
  6994. RequestXfer handlerRequestXfer = OnRequestXfer;
  6995. if (handlerRequestXfer != null)
  6996. {
  6997. handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
  6998. }
  6999. return true;
  7000. }
  7001. private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
  7002. {
  7003. SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
  7004. XferReceive handlerXferReceive = OnXferReceive;
  7005. if (handlerXferReceive != null)
  7006. {
  7007. handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
  7008. }
  7009. return true;
  7010. }
  7011. private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
  7012. {
  7013. ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
  7014. ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
  7015. if (handlerConfirmXfer != null)
  7016. {
  7017. handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
  7018. }
  7019. return true;
  7020. }
  7021. private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
  7022. {
  7023. AbortXferPacket abortXfer = (AbortXferPacket)Pack;
  7024. AbortXfer handlerAbortXfer = OnAbortXfer;
  7025. if (handlerAbortXfer != null)
  7026. {
  7027. handlerAbortXfer(this, abortXfer.XferID.ID);
  7028. }
  7029. return true;
  7030. }
  7031. private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
  7032. {
  7033. CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
  7034. #region Packet Session and User Check
  7035. if (m_checkPackets)
  7036. {
  7037. if (invFolder.AgentData.SessionID != SessionId ||
  7038. invFolder.AgentData.AgentID != AgentId)
  7039. return true;
  7040. }
  7041. #endregion
  7042. CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
  7043. if (handlerCreateInventoryFolder != null)
  7044. {
  7045. handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
  7046. (ushort)invFolder.FolderData.Type,
  7047. Util.FieldToString(invFolder.FolderData.Name),
  7048. invFolder.FolderData.ParentID);
  7049. }
  7050. return true;
  7051. }
  7052. private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
  7053. {
  7054. if (OnUpdateInventoryFolder != null)
  7055. {
  7056. UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
  7057. #region Packet Session and User Check
  7058. if (m_checkPackets)
  7059. {
  7060. if (invFolderx.AgentData.SessionID != SessionId ||
  7061. invFolderx.AgentData.AgentID != AgentId)
  7062. return true;
  7063. }
  7064. #endregion
  7065. UpdateInventoryFolder handlerUpdateInventoryFolder = null;
  7066. for (int i = 0; i < invFolderx.FolderData.Length; i++)
  7067. {
  7068. handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
  7069. if (handlerUpdateInventoryFolder != null)
  7070. {
  7071. OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
  7072. (ushort)invFolderx.FolderData[i].Type,
  7073. Util.FieldToString(invFolderx.FolderData[i].Name),
  7074. invFolderx.FolderData[i].ParentID);
  7075. }
  7076. }
  7077. }
  7078. return true;
  7079. }
  7080. private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
  7081. {
  7082. if (OnMoveInventoryFolder != null)
  7083. {
  7084. MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
  7085. #region Packet Session and User Check
  7086. if (m_checkPackets)
  7087. {
  7088. if (invFoldery.AgentData.SessionID != SessionId ||
  7089. invFoldery.AgentData.AgentID != AgentId)
  7090. return true;
  7091. }
  7092. #endregion
  7093. MoveInventoryFolder handlerMoveInventoryFolder = null;
  7094. for (int i = 0; i < invFoldery.InventoryData.Length; i++)
  7095. {
  7096. handlerMoveInventoryFolder = OnMoveInventoryFolder;
  7097. if (handlerMoveInventoryFolder != null)
  7098. {
  7099. OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
  7100. invFoldery.InventoryData[i].ParentID);
  7101. }
  7102. }
  7103. }
  7104. return true;
  7105. }
  7106. private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
  7107. {
  7108. CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
  7109. #region Packet Session and User Check
  7110. if (m_checkPackets)
  7111. {
  7112. if (createItem.AgentData.SessionID != SessionId ||
  7113. createItem.AgentData.AgentID != AgentId)
  7114. return true;
  7115. }
  7116. #endregion
  7117. CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
  7118. if (handlerCreateNewInventoryItem != null)
  7119. {
  7120. handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
  7121. createItem.InventoryBlock.FolderID,
  7122. createItem.InventoryBlock.CallbackID,
  7123. Util.FieldToString(createItem.InventoryBlock.Description),
  7124. Util.FieldToString(createItem.InventoryBlock.Name),
  7125. createItem.InventoryBlock.InvType,
  7126. createItem.InventoryBlock.Type,
  7127. createItem.InventoryBlock.WearableType,
  7128. createItem.InventoryBlock.NextOwnerMask,
  7129. Util.UnixTimeSinceEpoch());
  7130. }
  7131. return true;
  7132. }
  7133. private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
  7134. {
  7135. LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
  7136. #region Packet Session and User Check
  7137. if (m_checkPackets)
  7138. {
  7139. if (createLink.AgentData.SessionID != SessionId ||
  7140. createLink.AgentData.AgentID != AgentId)
  7141. return true;
  7142. }
  7143. #endregion
  7144. LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
  7145. if (linkInventoryItem != null)
  7146. {
  7147. linkInventoryItem(
  7148. this,
  7149. createLink.InventoryBlock.TransactionID,
  7150. createLink.InventoryBlock.FolderID,
  7151. createLink.InventoryBlock.CallbackID,
  7152. Util.FieldToString(createLink.InventoryBlock.Description),
  7153. Util.FieldToString(createLink.InventoryBlock.Name),
  7154. createLink.InventoryBlock.InvType,
  7155. createLink.InventoryBlock.Type,
  7156. createLink.InventoryBlock.OldItemID);
  7157. }
  7158. return true;
  7159. }
  7160. private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
  7161. {
  7162. if (OnFetchInventory != null)
  7163. {
  7164. FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
  7165. #region Packet Session and User Check
  7166. if (m_checkPackets)
  7167. {
  7168. if (FetchInventoryx.AgentData.SessionID != SessionId ||
  7169. FetchInventoryx.AgentData.AgentID != AgentId)
  7170. return true;
  7171. }
  7172. #endregion
  7173. FetchInventory handlerFetchInventory = null;
  7174. for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
  7175. {
  7176. handlerFetchInventory = OnFetchInventory;
  7177. if (handlerFetchInventory != null)
  7178. {
  7179. OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
  7180. FetchInventoryx.InventoryData[i].OwnerID);
  7181. }
  7182. }
  7183. }
  7184. return true;
  7185. }
  7186. private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
  7187. {
  7188. FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
  7189. #region Packet Session and User Check
  7190. if (m_checkPackets)
  7191. {
  7192. if (Fetch.AgentData.SessionID != SessionId ||
  7193. Fetch.AgentData.AgentID != AgentId)
  7194. return true;
  7195. }
  7196. #endregion
  7197. FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
  7198. if (handlerFetchInventoryDescendents != null)
  7199. {
  7200. handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
  7201. Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
  7202. Fetch.InventoryData.SortOrder);
  7203. }
  7204. return true;
  7205. }
  7206. private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
  7207. {
  7208. PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
  7209. #region Packet Session and User Check
  7210. if (m_checkPackets)
  7211. {
  7212. if (Purge.AgentData.SessionID != SessionId ||
  7213. Purge.AgentData.AgentID != AgentId)
  7214. return true;
  7215. }
  7216. #endregion
  7217. PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
  7218. if (handlerPurgeInventoryDescendents != null)
  7219. {
  7220. handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
  7221. }
  7222. return true;
  7223. }
  7224. private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
  7225. {
  7226. UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
  7227. #region Packet Session and User Check
  7228. if (m_checkPackets)
  7229. {
  7230. if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
  7231. inventoryItemUpdate.AgentData.AgentID != AgentId)
  7232. return true;
  7233. }
  7234. #endregion
  7235. if (OnUpdateInventoryItem != null)
  7236. {
  7237. UpdateInventoryItem handlerUpdateInventoryItem = null;
  7238. for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
  7239. {
  7240. handlerUpdateInventoryItem = OnUpdateInventoryItem;
  7241. if (handlerUpdateInventoryItem != null)
  7242. {
  7243. InventoryItemBase itemUpd = new InventoryItemBase();
  7244. itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
  7245. itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
  7246. itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
  7247. itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
  7248. itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
  7249. itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
  7250. itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
  7251. itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
  7252. itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
  7253. itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
  7254. itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
  7255. itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
  7256. itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
  7257. itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
  7258. OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
  7259. inventoryItemUpdate.InventoryData[i].ItemID,
  7260. itemUpd);
  7261. }
  7262. }
  7263. }
  7264. return true;
  7265. }
  7266. private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
  7267. {
  7268. CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
  7269. #region Packet Session and User Check
  7270. if (m_checkPackets)
  7271. {
  7272. if (copyitem.AgentData.SessionID != SessionId ||
  7273. copyitem.AgentData.AgentID != AgentId)
  7274. return true;
  7275. }
  7276. #endregion
  7277. CopyInventoryItem handlerCopyInventoryItem = null;
  7278. if (OnCopyInventoryItem != null)
  7279. {
  7280. foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
  7281. {
  7282. handlerCopyInventoryItem = OnCopyInventoryItem;
  7283. if (handlerCopyInventoryItem != null)
  7284. {
  7285. handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
  7286. datablock.OldItemID, datablock.NewFolderID,
  7287. Util.FieldToString(datablock.NewName));
  7288. }
  7289. }
  7290. }
  7291. return true;
  7292. }
  7293. private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
  7294. {
  7295. MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
  7296. #region Packet Session and User Check
  7297. if (m_checkPackets)
  7298. {
  7299. if (moveitem.AgentData.SessionID != SessionId ||
  7300. moveitem.AgentData.AgentID != AgentId)
  7301. return true;
  7302. }
  7303. #endregion
  7304. if (OnMoveInventoryItem != null)
  7305. {
  7306. MoveInventoryItem handlerMoveInventoryItem = null;
  7307. InventoryItemBase itm = null;
  7308. List<InventoryItemBase> items = new List<InventoryItemBase>();
  7309. foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
  7310. {
  7311. itm = new InventoryItemBase(datablock.ItemID, AgentId);
  7312. itm.Folder = datablock.FolderID;
  7313. itm.Name = Util.FieldToString(datablock.NewName);
  7314. // weird, comes out as empty string
  7315. //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
  7316. items.Add(itm);
  7317. }
  7318. handlerMoveInventoryItem = OnMoveInventoryItem;
  7319. if (handlerMoveInventoryItem != null)
  7320. {
  7321. handlerMoveInventoryItem(this, items);
  7322. }
  7323. }
  7324. return true;
  7325. }
  7326. private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
  7327. {
  7328. RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
  7329. #region Packet Session and User Check
  7330. if (m_checkPackets)
  7331. {
  7332. if (removeItem.AgentData.SessionID != SessionId ||
  7333. removeItem.AgentData.AgentID != AgentId)
  7334. return true;
  7335. }
  7336. #endregion
  7337. if (OnRemoveInventoryItem != null)
  7338. {
  7339. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7340. List<UUID> uuids = new List<UUID>();
  7341. foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
  7342. {
  7343. uuids.Add(datablock.ItemID);
  7344. }
  7345. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7346. if (handlerRemoveInventoryItem != null)
  7347. {
  7348. handlerRemoveInventoryItem(this, uuids);
  7349. }
  7350. }
  7351. return true;
  7352. }
  7353. private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
  7354. {
  7355. RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
  7356. #region Packet Session and User Check
  7357. if (m_checkPackets)
  7358. {
  7359. if (removeFolder.AgentData.SessionID != SessionId ||
  7360. removeFolder.AgentData.AgentID != AgentId)
  7361. return true;
  7362. }
  7363. #endregion
  7364. if (OnRemoveInventoryFolder != null)
  7365. {
  7366. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7367. List<UUID> uuids = new List<UUID>();
  7368. foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
  7369. {
  7370. uuids.Add(datablock.FolderID);
  7371. }
  7372. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7373. if (handlerRemoveInventoryFolder != null)
  7374. {
  7375. handlerRemoveInventoryFolder(this, uuids);
  7376. }
  7377. }
  7378. return true;
  7379. }
  7380. private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
  7381. {
  7382. RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
  7383. #region Packet Session and User Check
  7384. if (m_checkPackets)
  7385. {
  7386. if (removeObject.AgentData.SessionID != SessionId ||
  7387. removeObject.AgentData.AgentID != AgentId)
  7388. return true;
  7389. }
  7390. #endregion
  7391. if (OnRemoveInventoryFolder != null)
  7392. {
  7393. RemoveInventoryFolder handlerRemoveInventoryFolder = null;
  7394. List<UUID> uuids = new List<UUID>();
  7395. foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
  7396. {
  7397. uuids.Add(datablock.FolderID);
  7398. }
  7399. handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
  7400. if (handlerRemoveInventoryFolder != null)
  7401. {
  7402. handlerRemoveInventoryFolder(this, uuids);
  7403. }
  7404. }
  7405. if (OnRemoveInventoryItem != null)
  7406. {
  7407. RemoveInventoryItem handlerRemoveInventoryItem = null;
  7408. List<UUID> uuids = new List<UUID>();
  7409. foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
  7410. {
  7411. uuids.Add(datablock.ItemID);
  7412. }
  7413. handlerRemoveInventoryItem = OnRemoveInventoryItem;
  7414. if (handlerRemoveInventoryItem != null)
  7415. {
  7416. handlerRemoveInventoryItem(this, uuids);
  7417. }
  7418. }
  7419. return true;
  7420. }
  7421. private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
  7422. {
  7423. RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
  7424. #region Packet Session and User Check
  7425. if (m_checkPackets)
  7426. {
  7427. if (requesttask.AgentData.SessionID != SessionId ||
  7428. requesttask.AgentData.AgentID != AgentId)
  7429. return true;
  7430. }
  7431. #endregion
  7432. RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
  7433. if (handlerRequestTaskInventory != null)
  7434. {
  7435. handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
  7436. }
  7437. return true;
  7438. }
  7439. private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
  7440. {
  7441. UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
  7442. #region Packet Session and User Check
  7443. if (m_checkPackets)
  7444. {
  7445. if (updatetask.AgentData.SessionID != SessionId ||
  7446. updatetask.AgentData.AgentID != AgentId)
  7447. return true;
  7448. }
  7449. #endregion
  7450. if (OnUpdateTaskInventory != null)
  7451. {
  7452. if (updatetask.UpdateData.Key == 0)
  7453. {
  7454. UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
  7455. if (handlerUpdateTaskInventory != null)
  7456. {
  7457. TaskInventoryItem newTaskItem = new TaskInventoryItem();
  7458. newTaskItem.ItemID = updatetask.InventoryData.ItemID;
  7459. newTaskItem.ParentID = updatetask.InventoryData.FolderID;
  7460. newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
  7461. newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
  7462. newTaskItem.GroupID = updatetask.InventoryData.GroupID;
  7463. newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
  7464. newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
  7465. newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
  7466. newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
  7467. newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
  7468. // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
  7469. // different
  7470. //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
  7471. newTaskItem.Type = updatetask.InventoryData.Type;
  7472. newTaskItem.InvType = updatetask.InventoryData.InvType;
  7473. newTaskItem.Flags = updatetask.InventoryData.Flags;
  7474. //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
  7475. //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
  7476. newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
  7477. newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
  7478. newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
  7479. handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
  7480. newTaskItem, updatetask.UpdateData.LocalID);
  7481. }
  7482. }
  7483. }
  7484. return true;
  7485. }
  7486. private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
  7487. {
  7488. RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
  7489. #region Packet Session and User Check
  7490. if (m_checkPackets)
  7491. {
  7492. if (removeTask.AgentData.SessionID != SessionId ||
  7493. removeTask.AgentData.AgentID != AgentId)
  7494. return true;
  7495. }
  7496. #endregion
  7497. RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
  7498. if (handlerRemoveTaskItem != null)
  7499. {
  7500. handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
  7501. }
  7502. return true;
  7503. }
  7504. private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
  7505. {
  7506. MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
  7507. #region Packet Session and User Check
  7508. if (m_checkPackets)
  7509. {
  7510. if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
  7511. moveTaskInventoryPacket.AgentData.AgentID != AgentId)
  7512. return true;
  7513. }
  7514. #endregion
  7515. MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
  7516. if (handlerMoveTaskItem != null)
  7517. {
  7518. handlerMoveTaskItem(
  7519. this, moveTaskInventoryPacket.AgentData.FolderID,
  7520. moveTaskInventoryPacket.InventoryData.LocalID,
  7521. moveTaskInventoryPacket.InventoryData.ItemID);
  7522. }
  7523. return true;
  7524. }
  7525. private bool HandleRezScript(IClientAPI sender, Packet Pack)
  7526. {
  7527. //m_log.Debug(Pack.ToString());
  7528. RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
  7529. #region Packet Session and User Check
  7530. if (m_checkPackets)
  7531. {
  7532. if (rezScriptx.AgentData.SessionID != SessionId ||
  7533. rezScriptx.AgentData.AgentID != AgentId)
  7534. return true;
  7535. }
  7536. #endregion
  7537. RezScript handlerRezScript = OnRezScript;
  7538. InventoryItemBase item = new InventoryItemBase();
  7539. item.ID = rezScriptx.InventoryBlock.ItemID;
  7540. item.Folder = rezScriptx.InventoryBlock.FolderID;
  7541. item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
  7542. item.Owner = rezScriptx.InventoryBlock.OwnerID;
  7543. item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
  7544. item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
  7545. item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
  7546. item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
  7547. item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
  7548. item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
  7549. item.GroupID = rezScriptx.InventoryBlock.GroupID;
  7550. item.AssetType = rezScriptx.InventoryBlock.Type;
  7551. item.InvType = rezScriptx.InventoryBlock.InvType;
  7552. item.Flags = rezScriptx.InventoryBlock.Flags;
  7553. item.SaleType = rezScriptx.InventoryBlock.SaleType;
  7554. item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
  7555. item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
  7556. item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
  7557. item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
  7558. if (handlerRezScript != null)
  7559. {
  7560. handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
  7561. }
  7562. return true;
  7563. }
  7564. private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
  7565. {
  7566. RequestMapLayer();
  7567. return true;
  7568. }
  7569. private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
  7570. {
  7571. MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
  7572. #region Packet Session and User Check
  7573. if (m_checkPackets)
  7574. {
  7575. if (MapRequest.AgentData.SessionID != SessionId ||
  7576. MapRequest.AgentData.AgentID != AgentId)
  7577. return true;
  7578. }
  7579. #endregion
  7580. RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
  7581. if (handlerRequestMapBlocks != null)
  7582. {
  7583. handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
  7584. MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
  7585. }
  7586. return true;
  7587. }
  7588. private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
  7589. {
  7590. MapNameRequestPacket map = (MapNameRequestPacket)Pack;
  7591. #region Packet Session and User Check
  7592. if (m_checkPackets)
  7593. {
  7594. if (map.AgentData.SessionID != SessionId ||
  7595. map.AgentData.AgentID != AgentId)
  7596. return true;
  7597. }
  7598. #endregion
  7599. string mapName = Util.UTF8.GetString(map.NameData.Name, 0,
  7600. map.NameData.Name.Length - 1);
  7601. RequestMapName handlerMapNameRequest = OnMapNameRequest;
  7602. if (handlerMapNameRequest != null)
  7603. {
  7604. handlerMapNameRequest(this, mapName, map.AgentData.Flags);
  7605. }
  7606. return true;
  7607. }
  7608. private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
  7609. {
  7610. TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
  7611. #region Packet Session and User Check
  7612. if (m_checkPackets)
  7613. {
  7614. if (tpReq.Info.SessionID != SessionId ||
  7615. tpReq.Info.AgentID != AgentId)
  7616. return true;
  7617. }
  7618. #endregion
  7619. UUID lmid = tpReq.Info.LandmarkID;
  7620. AssetLandmark lm;
  7621. if (lmid != UUID.Zero)
  7622. {
  7623. //AssetBase lma = m_assetCache.GetAsset(lmid, false);
  7624. AssetBase lma = m_assetService.Get(lmid.ToString());
  7625. if (lma == null)
  7626. {
  7627. // Failed to find landmark
  7628. // Let's try to search in the user's home asset server
  7629. lma = FindAssetInUserAssetServer(lmid.ToString());
  7630. if (lma == null)
  7631. {
  7632. // Really doesn't exist
  7633. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7634. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7635. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7636. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7637. }
  7638. }
  7639. try
  7640. {
  7641. lm = new AssetLandmark(lma);
  7642. }
  7643. catch (NullReferenceException)
  7644. {
  7645. // asset not found generates null ref inside the assetlandmark constructor.
  7646. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7647. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7648. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7649. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7650. return true;
  7651. }
  7652. }
  7653. else
  7654. {
  7655. // Teleport home request
  7656. UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
  7657. if (handlerTeleportHomeRequest != null)
  7658. {
  7659. handlerTeleportHomeRequest(AgentId, this);
  7660. }
  7661. return true;
  7662. }
  7663. TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
  7664. if (handlerTeleportLandmarkRequest != null)
  7665. {
  7666. handlerTeleportLandmarkRequest(this, lm);
  7667. }
  7668. else
  7669. {
  7670. //no event handler so cancel request
  7671. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7672. tpCancel.Info.AgentID = tpReq.Info.AgentID;
  7673. tpCancel.Info.SessionID = tpReq.Info.SessionID;
  7674. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7675. }
  7676. return true;
  7677. }
  7678. private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
  7679. {
  7680. TeleportCancel handlerTeleportCancel = OnTeleportCancel;
  7681. if (handlerTeleportCancel != null)
  7682. {
  7683. handlerTeleportCancel(this);
  7684. }
  7685. return true;
  7686. }
  7687. private AssetBase FindAssetInUserAssetServer(string id)
  7688. {
  7689. AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
  7690. if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
  7691. {
  7692. string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
  7693. return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
  7694. }
  7695. return null;
  7696. }
  7697. private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
  7698. {
  7699. TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
  7700. // m_log.Debug(tpLocReq.ToString());
  7701. #region Packet Session and User Check
  7702. if (m_checkPackets)
  7703. {
  7704. if (tpLocReq.AgentData.SessionID != SessionId ||
  7705. tpLocReq.AgentData.AgentID != AgentId)
  7706. return true;
  7707. }
  7708. #endregion
  7709. TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
  7710. if (handlerTeleportLocationRequest != null)
  7711. {
  7712. handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
  7713. tpLocReq.Info.LookAt, 16);
  7714. }
  7715. else
  7716. {
  7717. //no event handler so cancel request
  7718. TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
  7719. tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
  7720. tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
  7721. OutPacket(tpCancel, ThrottleOutPacketType.Task);
  7722. }
  7723. return true;
  7724. }
  7725. #endregion Inventory/Asset/Other related packets
  7726. private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
  7727. {
  7728. UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
  7729. foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
  7730. {
  7731. UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
  7732. if (handlerNameRequest != null)
  7733. {
  7734. handlerNameRequest(UUIDBlock.ID, this);
  7735. }
  7736. }
  7737. return true;
  7738. }
  7739. #region Parcel related packets
  7740. private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
  7741. {
  7742. RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
  7743. RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
  7744. if (handlerRegionHandleRequest != null)
  7745. {
  7746. handlerRegionHandleRequest(this, rhrPack.RequestBlock.RegionID);
  7747. }
  7748. return true;
  7749. }
  7750. private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
  7751. {
  7752. ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
  7753. #region Packet Session and User Check
  7754. if (m_checkPackets)
  7755. {
  7756. if (pirPack.AgentData.SessionID != SessionId ||
  7757. pirPack.AgentData.AgentID != AgentId)
  7758. return true;
  7759. }
  7760. #endregion
  7761. ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
  7762. if (handlerParcelInfoRequest != null)
  7763. {
  7764. handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
  7765. }
  7766. return true;
  7767. }
  7768. private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
  7769. {
  7770. ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
  7771. #region Packet Session and User Check
  7772. if (m_checkPackets)
  7773. {
  7774. if (requestPacket.AgentData.SessionID != SessionId ||
  7775. requestPacket.AgentData.AgentID != AgentId)
  7776. return true;
  7777. }
  7778. #endregion
  7779. ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
  7780. if (handlerParcelAccessListRequest != null)
  7781. {
  7782. handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
  7783. requestPacket.Data.Flags, requestPacket.Data.SequenceID,
  7784. requestPacket.Data.LocalID, this);
  7785. }
  7786. return true;
  7787. }
  7788. private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
  7789. {
  7790. ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
  7791. #region Packet Session and User Check
  7792. if (m_checkPackets)
  7793. {
  7794. if (updatePacket.AgentData.SessionID != SessionId ||
  7795. updatePacket.AgentData.AgentID != AgentId)
  7796. return true;
  7797. }
  7798. #endregion
  7799. List<LandAccessEntry> entries = new List<LandAccessEntry>();
  7800. foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
  7801. {
  7802. LandAccessEntry entry = new LandAccessEntry();
  7803. entry.AgentID = block.ID;
  7804. entry.Flags = (AccessList)block.Flags;
  7805. entry.Expires = block.Time;
  7806. entries.Add(entry);
  7807. }
  7808. ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
  7809. if (handlerParcelAccessListUpdateRequest != null)
  7810. {
  7811. handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
  7812. updatePacket.Data.Flags,
  7813. updatePacket.Data.LocalID,
  7814. updatePacket.Data.TransactionID,
  7815. updatePacket.Data.SequenceID,
  7816. updatePacket.Data.Sections,
  7817. entries, this);
  7818. }
  7819. return true;
  7820. }
  7821. private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
  7822. {
  7823. ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
  7824. #region Packet Session and User Check
  7825. if (m_checkPackets)
  7826. {
  7827. if (propertiesRequest.AgentData.SessionID != SessionId ||
  7828. propertiesRequest.AgentData.AgentID != AgentId)
  7829. return true;
  7830. }
  7831. #endregion
  7832. ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
  7833. if (handlerParcelPropertiesRequest != null)
  7834. {
  7835. handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
  7836. (int)Math.Round(propertiesRequest.ParcelData.South),
  7837. (int)Math.Round(propertiesRequest.ParcelData.East),
  7838. (int)Math.Round(propertiesRequest.ParcelData.North),
  7839. propertiesRequest.ParcelData.SequenceID,
  7840. propertiesRequest.ParcelData.SnapSelection, this);
  7841. }
  7842. return true;
  7843. }
  7844. private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
  7845. {
  7846. ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
  7847. #region Packet Session and User Check
  7848. if (m_checkPackets)
  7849. {
  7850. if (landDivide.AgentData.SessionID != SessionId ||
  7851. landDivide.AgentData.AgentID != AgentId)
  7852. return true;
  7853. }
  7854. #endregion
  7855. ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
  7856. if (handlerParcelDivideRequest != null)
  7857. {
  7858. handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
  7859. (int)Math.Round(landDivide.ParcelData.South),
  7860. (int)Math.Round(landDivide.ParcelData.East),
  7861. (int)Math.Round(landDivide.ParcelData.North), this);
  7862. }
  7863. return true;
  7864. }
  7865. private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
  7866. {
  7867. ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
  7868. #region Packet Session and User Check
  7869. if (m_checkPackets)
  7870. {
  7871. if (landJoin.AgentData.SessionID != SessionId ||
  7872. landJoin.AgentData.AgentID != AgentId)
  7873. return true;
  7874. }
  7875. #endregion
  7876. ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
  7877. if (handlerParcelJoinRequest != null)
  7878. {
  7879. handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
  7880. (int)Math.Round(landJoin.ParcelData.South),
  7881. (int)Math.Round(landJoin.ParcelData.East),
  7882. (int)Math.Round(landJoin.ParcelData.North), this);
  7883. }
  7884. return true;
  7885. }
  7886. private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
  7887. {
  7888. ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
  7889. #region Packet Session and User Check
  7890. if (m_checkPackets)
  7891. {
  7892. if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
  7893. parcelPropertiesPacket.AgentData.AgentID != AgentId)
  7894. return true;
  7895. }
  7896. #endregion
  7897. ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
  7898. if (handlerParcelPropertiesUpdateRequest != null)
  7899. {
  7900. LandUpdateArgs args = new LandUpdateArgs();
  7901. args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
  7902. args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
  7903. args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
  7904. args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
  7905. args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
  7906. args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
  7907. args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
  7908. args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
  7909. args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
  7910. args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
  7911. args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
  7912. args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
  7913. args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
  7914. args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
  7915. args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
  7916. args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
  7917. args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
  7918. handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
  7919. }
  7920. return true;
  7921. }
  7922. private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
  7923. {
  7924. ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
  7925. #region Packet Session and User Check
  7926. if (m_checkPackets)
  7927. {
  7928. if (selectPacket.AgentData.SessionID != SessionId ||
  7929. selectPacket.AgentData.AgentID != AgentId)
  7930. return true;
  7931. }
  7932. #endregion
  7933. List<UUID> returnIDs = new List<UUID>();
  7934. foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
  7935. selectPacket.ReturnIDs)
  7936. {
  7937. returnIDs.Add(rb.ReturnID);
  7938. }
  7939. ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
  7940. if (handlerParcelSelectObjects != null)
  7941. {
  7942. handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
  7943. Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
  7944. }
  7945. return true;
  7946. }
  7947. private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
  7948. {
  7949. ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
  7950. #region Packet Session and User Check
  7951. if (m_checkPackets)
  7952. {
  7953. if (reqPacket.AgentData.SessionID != SessionId ||
  7954. reqPacket.AgentData.AgentID != AgentId)
  7955. return true;
  7956. }
  7957. #endregion
  7958. ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
  7959. if (handlerParcelObjectOwnerRequest != null)
  7960. {
  7961. handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
  7962. }
  7963. return true;
  7964. }
  7965. private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
  7966. {
  7967. ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
  7968. #region Packet Session and User Check
  7969. if (m_checkPackets)
  7970. {
  7971. if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
  7972. godForceOwnerPacket.AgentData.AgentID != AgentId)
  7973. return true;
  7974. }
  7975. #endregion
  7976. ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
  7977. if (handlerParcelGodForceOwner != null)
  7978. {
  7979. handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
  7980. }
  7981. return true;
  7982. }
  7983. private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
  7984. {
  7985. ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
  7986. #region Packet Session and User Check
  7987. if (m_checkPackets)
  7988. {
  7989. if (releasePacket.AgentData.SessionID != SessionId ||
  7990. releasePacket.AgentData.AgentID != AgentId)
  7991. return true;
  7992. }
  7993. #endregion
  7994. ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
  7995. if (handlerParcelAbandonRequest != null)
  7996. {
  7997. handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
  7998. }
  7999. return true;
  8000. }
  8001. private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
  8002. {
  8003. ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
  8004. #region Packet Session and User Check
  8005. if (m_checkPackets)
  8006. {
  8007. if (reclaimPacket.AgentData.SessionID != SessionId ||
  8008. reclaimPacket.AgentData.AgentID != AgentId)
  8009. return true;
  8010. }
  8011. #endregion
  8012. ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
  8013. if (handlerParcelReclaim != null)
  8014. {
  8015. handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
  8016. }
  8017. return true;
  8018. }
  8019. private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
  8020. {
  8021. ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
  8022. #region Packet Session and User Check
  8023. if (m_checkPackets)
  8024. {
  8025. if (parcelReturnObjects.AgentData.SessionID != SessionId ||
  8026. parcelReturnObjects.AgentData.AgentID != AgentId)
  8027. return true;
  8028. }
  8029. #endregion
  8030. UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
  8031. for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
  8032. puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
  8033. UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
  8034. for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
  8035. puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
  8036. ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
  8037. if (handlerParcelReturnObjectsRequest != null)
  8038. {
  8039. handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
  8040. }
  8041. return true;
  8042. }
  8043. private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
  8044. {
  8045. ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
  8046. #region Packet Session and User Check
  8047. if (m_checkPackets)
  8048. {
  8049. if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
  8050. parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
  8051. return true;
  8052. }
  8053. #endregion
  8054. ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
  8055. if (handlerParcelSetOtherCleanTime != null)
  8056. {
  8057. handlerParcelSetOtherCleanTime(this,
  8058. parcelSetOtherCleanTimePacket.ParcelData.LocalID,
  8059. parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
  8060. }
  8061. return true;
  8062. }
  8063. private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
  8064. {
  8065. LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
  8066. #region Packet Session and User Check
  8067. if (m_checkPackets)
  8068. {
  8069. if (lsrp.AgentData.SessionID != SessionId ||
  8070. lsrp.AgentData.AgentID != AgentId)
  8071. return true;
  8072. }
  8073. #endregion
  8074. GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
  8075. if (handlerLandStatRequest != null)
  8076. {
  8077. handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
  8078. }
  8079. return true;
  8080. }
  8081. private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
  8082. {
  8083. ParcelDwellRequestPacket dwellrq =
  8084. (ParcelDwellRequestPacket)Pack;
  8085. #region Packet Session and User Check
  8086. if (m_checkPackets)
  8087. {
  8088. if (dwellrq.AgentData.SessionID != SessionId ||
  8089. dwellrq.AgentData.AgentID != AgentId)
  8090. return true;
  8091. }
  8092. #endregion
  8093. ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
  8094. if (handlerParcelDwellRequest != null)
  8095. {
  8096. handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
  8097. }
  8098. return true;
  8099. }
  8100. #endregion Parcel related packets
  8101. #region Estate Packets
  8102. private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
  8103. {
  8104. EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
  8105. // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
  8106. GodLandStatRequest handlerLandStatRequest;
  8107. #region Packet Session and User Check
  8108. if (m_checkPackets)
  8109. {
  8110. if (messagePacket.AgentData.SessionID != SessionId ||
  8111. messagePacket.AgentData.AgentID != AgentId)
  8112. return true;
  8113. }
  8114. #endregion
  8115. string method = Utils.BytesToString(messagePacket.MethodData.Method);
  8116. switch (method)
  8117. {
  8118. case "getinfo":
  8119. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8120. {
  8121. OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
  8122. }
  8123. return true;
  8124. case "setregioninfo":
  8125. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8126. {
  8127. OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
  8128. convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
  8129. Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
  8130. (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
  8131. Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
  8132. convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
  8133. }
  8134. return true;
  8135. // case "texturebase":
  8136. // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8137. // {
  8138. // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8139. // {
  8140. // string s = Utils.BytesToString(block.Parameter);
  8141. // string[] splitField = s.Split(' ');
  8142. // if (splitField.Length == 2)
  8143. // {
  8144. // UUID tempUUID = new UUID(splitField[1]);
  8145. // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
  8146. // }
  8147. // }
  8148. // }
  8149. // break;
  8150. case "texturedetail":
  8151. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8152. {
  8153. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8154. {
  8155. string s = Utils.BytesToString(block.Parameter);
  8156. string[] splitField = s.Split(' ');
  8157. if (splitField.Length == 2)
  8158. {
  8159. Int16 corner = Convert.ToInt16(splitField[0]);
  8160. UUID textureUUID = new UUID(splitField[1]);
  8161. OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
  8162. }
  8163. }
  8164. }
  8165. return true;
  8166. case "textureheights":
  8167. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8168. {
  8169. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8170. {
  8171. string s = Utils.BytesToString(block.Parameter);
  8172. string[] splitField = s.Split(' ');
  8173. if (splitField.Length == 3)
  8174. {
  8175. Int16 corner = Convert.ToInt16(splitField[0]);
  8176. float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
  8177. float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
  8178. OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
  8179. }
  8180. }
  8181. }
  8182. return true;
  8183. case "texturecommit":
  8184. OnCommitEstateTerrainTextureRequest(this);
  8185. return true;
  8186. case "setregionterrain":
  8187. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8188. {
  8189. if (messagePacket.ParamList.Length != 9)
  8190. {
  8191. m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
  8192. }
  8193. else
  8194. {
  8195. try
  8196. {
  8197. string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8198. if (!tmp.Contains(".")) tmp += ".00";
  8199. float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8200. tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8201. if (!tmp.Contains(".")) tmp += ".00";
  8202. float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8203. tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
  8204. if (!tmp.Contains(".")) tmp += ".00";
  8205. float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
  8206. bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
  8207. bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
  8208. float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
  8209. bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
  8210. bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
  8211. float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
  8212. OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
  8213. }
  8214. catch (Exception ex)
  8215. {
  8216. m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
  8217. }
  8218. }
  8219. }
  8220. return true;
  8221. case "restart":
  8222. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8223. {
  8224. // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
  8225. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8226. {
  8227. float timeSeconds;
  8228. Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
  8229. timeSeconds = (int)timeSeconds;
  8230. OnEstateRestartSimRequest(this, (int)timeSeconds);
  8231. }
  8232. }
  8233. return true;
  8234. case "estatechangecovenantid":
  8235. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8236. {
  8237. foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
  8238. {
  8239. UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
  8240. OnEstateChangeCovenantRequest(this, newCovenantID);
  8241. }
  8242. }
  8243. return true;
  8244. case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
  8245. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8246. {
  8247. int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8248. OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
  8249. }
  8250. return true;
  8251. case "simulatormessage":
  8252. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8253. {
  8254. UUID invoice = messagePacket.MethodData.Invoice;
  8255. UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8256. string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8257. string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8258. UUID sessionID = messagePacket.AgentData.SessionID;
  8259. OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8260. }
  8261. return true;
  8262. case "instantmessage":
  8263. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8264. {
  8265. if (messagePacket.ParamList.Length < 2)
  8266. return true;
  8267. UUID invoice = messagePacket.MethodData.Invoice;
  8268. UUID sessionID = messagePacket.AgentData.SessionID;
  8269. UUID SenderID;
  8270. string SenderName;
  8271. string Message;
  8272. if (messagePacket.ParamList.Length < 5)
  8273. {
  8274. SenderID = AgentId;
  8275. SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8276. Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
  8277. }
  8278. else
  8279. {
  8280. SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8281. SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
  8282. Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
  8283. }
  8284. OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
  8285. }
  8286. return true;
  8287. case "setregiondebug":
  8288. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8289. {
  8290. UUID invoice = messagePacket.MethodData.Invoice;
  8291. UUID SenderID = messagePacket.AgentData.AgentID;
  8292. bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
  8293. bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
  8294. bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
  8295. OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
  8296. }
  8297. return true;
  8298. case "teleporthomeuser":
  8299. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8300. {
  8301. UUID invoice = messagePacket.MethodData.Invoice;
  8302. UUID SenderID = messagePacket.AgentData.AgentID;
  8303. UUID Prey;
  8304. UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
  8305. OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
  8306. }
  8307. return true;
  8308. case "teleporthomeallusers":
  8309. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8310. {
  8311. UUID invoice = messagePacket.MethodData.Invoice;
  8312. UUID SenderID = messagePacket.AgentData.AgentID;
  8313. OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
  8314. }
  8315. return true;
  8316. case "colliders":
  8317. handlerLandStatRequest = OnLandStatRequest;
  8318. if (handlerLandStatRequest != null)
  8319. {
  8320. handlerLandStatRequest(0, 1, 0, "", this);
  8321. }
  8322. return true;
  8323. case "scripts":
  8324. handlerLandStatRequest = OnLandStatRequest;
  8325. if (handlerLandStatRequest != null)
  8326. {
  8327. handlerLandStatRequest(0, 0, 0, "", this);
  8328. }
  8329. return true;
  8330. case "terrain":
  8331. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8332. {
  8333. if (messagePacket.ParamList.Length > 0)
  8334. {
  8335. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
  8336. {
  8337. BakeTerrain handlerBakeTerrain = OnBakeTerrain;
  8338. if (handlerBakeTerrain != null)
  8339. {
  8340. handlerBakeTerrain(this);
  8341. }
  8342. }
  8343. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
  8344. {
  8345. if (messagePacket.ParamList.Length > 1)
  8346. {
  8347. RequestTerrain handlerRequestTerrain = OnRequestTerrain;
  8348. if (handlerRequestTerrain != null)
  8349. {
  8350. handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8351. }
  8352. }
  8353. }
  8354. if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
  8355. {
  8356. if (messagePacket.ParamList.Length > 1)
  8357. {
  8358. RequestTerrain handlerUploadTerrain = OnUploadTerrain;
  8359. if (handlerUploadTerrain != null)
  8360. {
  8361. handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8362. }
  8363. }
  8364. }
  8365. }
  8366. }
  8367. return true;
  8368. case "estatechangeinfo":
  8369. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8370. {
  8371. UUID invoice = messagePacket.MethodData.Invoice;
  8372. UUID SenderID = messagePacket.AgentData.AgentID;
  8373. UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8374. UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
  8375. EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
  8376. if (handlerEstateChangeInfo != null)
  8377. {
  8378. handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
  8379. }
  8380. }
  8381. return true;
  8382. case "telehub":
  8383. if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
  8384. {
  8385. UUID invoice = messagePacket.MethodData.Invoice;
  8386. UUID SenderID = messagePacket.AgentData.AgentID;
  8387. UInt32 param1 = 0u;
  8388. string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
  8389. if (command != "info ui")
  8390. {
  8391. try
  8392. {
  8393. param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
  8394. }
  8395. catch
  8396. {
  8397. }
  8398. }
  8399. EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
  8400. if (handlerEstateManageTelehub != null)
  8401. {
  8402. handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
  8403. }
  8404. }
  8405. return true;
  8406. default:
  8407. m_log.WarnFormat(
  8408. "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
  8409. method, Name, Scene.Name);
  8410. for (int i = 0; i < messagePacket.ParamList.Length; i++)
  8411. {
  8412. EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
  8413. string data = (string)Utils.BytesToString(block.Parameter);
  8414. m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
  8415. }
  8416. return true;
  8417. }
  8418. //int parcelID, uint reportType, uint requestflags, string filter
  8419. //lsrp.RequestData.ParcelLocalID;
  8420. //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
  8421. //lsrp.RequestData.RequestFlags;
  8422. //lsrp.RequestData.Filter;
  8423. }
  8424. private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
  8425. {
  8426. RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
  8427. #region Packet Session and User Check
  8428. if (m_checkPackets)
  8429. {
  8430. if (mPacket.SessionID != SessionId ||
  8431. mPacket.AgentID != AgentId)
  8432. return true;
  8433. }
  8434. #endregion
  8435. RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
  8436. if (handlerRegionInfoRequest != null)
  8437. {
  8438. handlerRegionInfoRequest(this);
  8439. }
  8440. return true;
  8441. }
  8442. private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
  8443. {
  8444. //EstateCovenantRequestPacket.AgentDataBlock epack =
  8445. // ((EstateCovenantRequestPacket)Pack).AgentData;
  8446. EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
  8447. if (handlerEstateCovenantRequest != null)
  8448. {
  8449. handlerEstateCovenantRequest(this);
  8450. }
  8451. return true;
  8452. }
  8453. #endregion Estate Packets
  8454. #region GodPackets
  8455. private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
  8456. {
  8457. RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
  8458. RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
  8459. UUID token = rblock.Token;
  8460. RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
  8461. RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
  8462. if (handlerReqGodlikePowers != null)
  8463. {
  8464. handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
  8465. }
  8466. return true;
  8467. }
  8468. private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
  8469. {
  8470. GodUpdateRegionInfoPacket GodUpdateRegionInfo =
  8471. (GodUpdateRegionInfoPacket)Packet;
  8472. GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
  8473. if (handlerGodUpdateRegionInfo != null)
  8474. {
  8475. handlerGodUpdateRegionInfo(this,
  8476. GodUpdateRegionInfo.RegionInfo.BillableFactor,
  8477. GodUpdateRegionInfo.RegionInfo.EstateID,
  8478. GodUpdateRegionInfo.RegionInfo.RegionFlags,
  8479. GodUpdateRegionInfo.RegionInfo.SimName,
  8480. GodUpdateRegionInfo.RegionInfo.RedirectGridX,
  8481. GodUpdateRegionInfo.RegionInfo.RedirectGridY);
  8482. return true;
  8483. }
  8484. return false;
  8485. }
  8486. private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
  8487. {
  8488. SimWideDeletesPacket SimWideDeletesRequest =
  8489. (SimWideDeletesPacket)Packet;
  8490. SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
  8491. if (handlerSimWideDeletesRequest != null)
  8492. {
  8493. handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
  8494. return true;
  8495. }
  8496. return false;
  8497. }
  8498. private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
  8499. {
  8500. GodlikeMessagePacket GodlikeMessage =
  8501. (GodlikeMessagePacket)Packet;
  8502. GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
  8503. if (handlerGodlikeMessage != null)
  8504. {
  8505. handlerGodlikeMessage(this,
  8506. GodlikeMessage.MethodData.Invoice,
  8507. GodlikeMessage.MethodData.Method,
  8508. GodlikeMessage.ParamList[0].Parameter);
  8509. return true;
  8510. }
  8511. return false;
  8512. }
  8513. private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
  8514. {
  8515. StateSavePacket SaveStateMessage =
  8516. (StateSavePacket)Packet;
  8517. SaveStateHandler handlerSaveStatePacket = OnSaveState;
  8518. if (handlerSaveStatePacket != null)
  8519. {
  8520. handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
  8521. return true;
  8522. }
  8523. return false;
  8524. }
  8525. private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
  8526. {
  8527. GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
  8528. if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
  8529. {
  8530. GodKickUser handlerGodKickUser = OnGodKickUser;
  8531. if (handlerGodKickUser != null)
  8532. {
  8533. handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
  8534. gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
  8535. }
  8536. }
  8537. else
  8538. {
  8539. SendAgentAlertMessage("Kick request denied", false);
  8540. }
  8541. //KickUserPacket kupack = new KickUserPacket();
  8542. //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
  8543. //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
  8544. //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
  8545. //kupack.TargetBlock.TargetIP = (uint)0;
  8546. //kupack.TargetBlock.TargetPort = (ushort)0;
  8547. //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
  8548. //OutPacket(kupack, ThrottleOutPacketType.Task);
  8549. return true;
  8550. }
  8551. #endregion GodPackets
  8552. #region Economy/Transaction Packets
  8553. private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
  8554. {
  8555. MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
  8556. #region Packet Session and User Check
  8557. if (m_checkPackets)
  8558. {
  8559. if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
  8560. moneybalancerequestpacket.AgentData.AgentID != AgentId)
  8561. return true;
  8562. }
  8563. #endregion
  8564. MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
  8565. if (handlerMoneyBalanceRequest != null)
  8566. {
  8567. handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
  8568. }
  8569. return true;
  8570. }
  8571. private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
  8572. {
  8573. EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
  8574. if (handlerEconomoyDataRequest != null)
  8575. {
  8576. handlerEconomoyDataRequest(this);
  8577. }
  8578. return true;
  8579. }
  8580. private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
  8581. {
  8582. RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
  8583. RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
  8584. if (handlerRequestPayPrice != null)
  8585. {
  8586. handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
  8587. }
  8588. return true;
  8589. }
  8590. private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
  8591. {
  8592. ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
  8593. #region Packet Session and User Check
  8594. if (m_checkPackets)
  8595. {
  8596. if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
  8597. objectSaleInfoPacket.AgentData.AgentID != AgentId)
  8598. return true;
  8599. }
  8600. #endregion
  8601. ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
  8602. if (handlerObjectSaleInfo != null)
  8603. {
  8604. foreach (ObjectSaleInfoPacket.ObjectDataBlock d
  8605. in objectSaleInfoPacket.ObjectData)
  8606. {
  8607. handlerObjectSaleInfo(this,
  8608. objectSaleInfoPacket.AgentData.AgentID,
  8609. objectSaleInfoPacket.AgentData.SessionID,
  8610. d.LocalID,
  8611. d.SaleType,
  8612. d.SalePrice);
  8613. }
  8614. }
  8615. return true;
  8616. }
  8617. private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
  8618. {
  8619. ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
  8620. #region Packet Session and User Check
  8621. if (m_checkPackets)
  8622. {
  8623. if (objectBuyPacket.AgentData.SessionID != SessionId ||
  8624. objectBuyPacket.AgentData.AgentID != AgentId)
  8625. return true;
  8626. }
  8627. #endregion
  8628. ObjectBuy handlerObjectBuy = OnObjectBuy;
  8629. if (handlerObjectBuy != null)
  8630. {
  8631. foreach (ObjectBuyPacket.ObjectDataBlock d
  8632. in objectBuyPacket.ObjectData)
  8633. {
  8634. handlerObjectBuy(this,
  8635. objectBuyPacket.AgentData.AgentID,
  8636. objectBuyPacket.AgentData.SessionID,
  8637. objectBuyPacket.AgentData.GroupID,
  8638. objectBuyPacket.AgentData.CategoryID,
  8639. d.ObjectLocalID,
  8640. d.SaleType,
  8641. d.SalePrice);
  8642. }
  8643. }
  8644. return true;
  8645. }
  8646. #endregion Economy/Transaction Packets
  8647. #region Script Packets
  8648. private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
  8649. {
  8650. GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
  8651. GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
  8652. if (handlerGetScriptRunning != null)
  8653. {
  8654. handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
  8655. }
  8656. return true;
  8657. }
  8658. private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
  8659. {
  8660. SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
  8661. #region Packet Session and User Check
  8662. if (m_checkPackets)
  8663. {
  8664. if (setScriptRunning.AgentData.SessionID != SessionId ||
  8665. setScriptRunning.AgentData.AgentID != AgentId)
  8666. return true;
  8667. }
  8668. #endregion
  8669. SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
  8670. if (handlerSetScriptRunning != null)
  8671. {
  8672. handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
  8673. }
  8674. return true;
  8675. }
  8676. private bool HandleScriptReset(IClientAPI sender, Packet Pack)
  8677. {
  8678. ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
  8679. #region Packet Session and User Check
  8680. if (m_checkPackets)
  8681. {
  8682. if (scriptResetPacket.AgentData.SessionID != SessionId ||
  8683. scriptResetPacket.AgentData.AgentID != AgentId)
  8684. return true;
  8685. }
  8686. #endregion
  8687. ScriptReset handlerScriptReset = OnScriptReset;
  8688. if (handlerScriptReset != null)
  8689. {
  8690. handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
  8691. }
  8692. return true;
  8693. }
  8694. #endregion Script Packets
  8695. #region Gesture Managment
  8696. private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
  8697. {
  8698. ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
  8699. #region Packet Session and User Check
  8700. if (m_checkPackets)
  8701. {
  8702. if (activateGesturePacket.AgentData.SessionID != SessionId ||
  8703. activateGesturePacket.AgentData.AgentID != AgentId)
  8704. return true;
  8705. }
  8706. #endregion
  8707. ActivateGesture handlerActivateGesture = OnActivateGesture;
  8708. if (handlerActivateGesture != null)
  8709. {
  8710. handlerActivateGesture(this,
  8711. activateGesturePacket.Data[0].AssetID,
  8712. activateGesturePacket.Data[0].ItemID);
  8713. }
  8714. else m_log.Error("Null pointer for activateGesture");
  8715. return true;
  8716. }
  8717. private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
  8718. {
  8719. DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
  8720. #region Packet Session and User Check
  8721. if (m_checkPackets)
  8722. {
  8723. if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
  8724. deactivateGesturePacket.AgentData.AgentID != AgentId)
  8725. return true;
  8726. }
  8727. #endregion
  8728. DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
  8729. if (handlerDeactivateGesture != null)
  8730. {
  8731. handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
  8732. }
  8733. return true;
  8734. }
  8735. private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
  8736. {
  8737. ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
  8738. #region Packet Session and User Check
  8739. if (m_checkPackets)
  8740. {
  8741. if (objectOwnerPacket.AgentData.SessionID != SessionId ||
  8742. objectOwnerPacket.AgentData.AgentID != AgentId)
  8743. return true;
  8744. }
  8745. #endregion
  8746. List<uint> localIDs = new List<uint>();
  8747. foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
  8748. localIDs.Add(d.ObjectLocalID);
  8749. ObjectOwner handlerObjectOwner = OnObjectOwner;
  8750. if (handlerObjectOwner != null)
  8751. {
  8752. handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
  8753. }
  8754. return true;
  8755. }
  8756. #endregion Gesture Managment
  8757. private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
  8758. {
  8759. AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
  8760. if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
  8761. {
  8762. m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
  8763. AgentFOV handlerAgentFOV = OnAgentFOV;
  8764. if (handlerAgentFOV != null)
  8765. {
  8766. handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
  8767. }
  8768. }
  8769. return true;
  8770. }
  8771. #region unimplemented handlers
  8772. private bool HandleViewerStats(IClientAPI sender, Packet Pack)
  8773. {
  8774. // TODO: handle this packet
  8775. //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
  8776. return true;
  8777. }
  8778. private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
  8779. {
  8780. MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
  8781. #region Packet Session and User Check
  8782. if (m_checkPackets)
  8783. {
  8784. if (mirpk.AgentData.SessionID != SessionId ||
  8785. mirpk.AgentData.AgentID != AgentId)
  8786. return true;
  8787. }
  8788. #endregion
  8789. //m_log.Debug(mirpk.ToString());
  8790. MapItemRequest handlerMapItemRequest = OnMapItemRequest;
  8791. if (handlerMapItemRequest != null)
  8792. {
  8793. handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
  8794. mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
  8795. mirpk.RequestData.RegionHandle);
  8796. }
  8797. return true;
  8798. }
  8799. private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
  8800. {
  8801. return true;
  8802. }
  8803. private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
  8804. {
  8805. MuteListRequestPacket muteListRequest =
  8806. (MuteListRequestPacket)Pack;
  8807. #region Packet Session and User Check
  8808. if (m_checkPackets)
  8809. {
  8810. if (muteListRequest.AgentData.SessionID != SessionId ||
  8811. muteListRequest.AgentData.AgentID != AgentId)
  8812. return true;
  8813. }
  8814. #endregion
  8815. MuteListRequest handlerMuteListRequest = OnMuteListRequest;
  8816. if (handlerMuteListRequest != null)
  8817. {
  8818. handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
  8819. }
  8820. else
  8821. {
  8822. SendUseCachedMuteList();
  8823. }
  8824. return true;
  8825. }
  8826. private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
  8827. {
  8828. UpdateMuteListEntryPacket UpdateMuteListEntry =
  8829. (UpdateMuteListEntryPacket)Packet;
  8830. MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
  8831. if (handlerUpdateMuteListEntry != null)
  8832. {
  8833. handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
  8834. Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
  8835. UpdateMuteListEntry.MuteData.MuteType,
  8836. UpdateMuteListEntry.AgentData.AgentID);
  8837. return true;
  8838. }
  8839. return false;
  8840. }
  8841. private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
  8842. {
  8843. RemoveMuteListEntryPacket RemoveMuteListEntry =
  8844. (RemoveMuteListEntryPacket)Packet;
  8845. MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
  8846. if (handlerRemoveMuteListEntry != null)
  8847. {
  8848. handlerRemoveMuteListEntry(this,
  8849. RemoveMuteListEntry.MuteData.MuteID,
  8850. Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName),
  8851. RemoveMuteListEntry.AgentData.AgentID);
  8852. return true;
  8853. }
  8854. return false;
  8855. }
  8856. private bool HandleUserReport(IClientAPI client, Packet Packet)
  8857. {
  8858. UserReportPacket UserReport =
  8859. (UserReportPacket)Packet;
  8860. NewUserReport handlerUserReport = OnUserReport;
  8861. if (handlerUserReport != null)
  8862. {
  8863. handlerUserReport(this,
  8864. Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
  8865. UserReport.ReportData.AbuserID,
  8866. UserReport.ReportData.Category,
  8867. UserReport.ReportData.CheckFlags,
  8868. Utils.BytesToString(UserReport.ReportData.Details),
  8869. UserReport.ReportData.ObjectID,
  8870. UserReport.ReportData.Position,
  8871. UserReport.ReportData.ReportType,
  8872. UserReport.ReportData.ScreenshotID,
  8873. Utils.BytesToString(UserReport.ReportData.Summary),
  8874. UserReport.AgentData.AgentID);
  8875. return true;
  8876. }
  8877. return false;
  8878. }
  8879. private bool HandleSendPostcard(IClientAPI client, Packet packet)
  8880. {
  8881. // SendPostcardPacket SendPostcard =
  8882. // (SendPostcardPacket)packet;
  8883. SendPostcard handlerSendPostcard = OnSendPostcard;
  8884. if (handlerSendPostcard != null)
  8885. {
  8886. handlerSendPostcard(this);
  8887. return true;
  8888. }
  8889. return false;
  8890. }
  8891. private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
  8892. {
  8893. return true;
  8894. }
  8895. private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
  8896. {
  8897. return true;
  8898. }
  8899. private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
  8900. {
  8901. return true;
  8902. }
  8903. #endregion unimplemented handlers
  8904. #region Dir handlers
  8905. private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
  8906. {
  8907. DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
  8908. //m_log.Debug(dirPlacesQueryPacket.ToString());
  8909. #region Packet Session and User Check
  8910. if (m_checkPackets)
  8911. {
  8912. if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
  8913. dirPlacesQueryPacket.AgentData.AgentID != AgentId)
  8914. return true;
  8915. }
  8916. #endregion
  8917. DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
  8918. if (handlerDirPlacesQuery != null)
  8919. {
  8920. handlerDirPlacesQuery(this,
  8921. dirPlacesQueryPacket.QueryData.QueryID,
  8922. Utils.BytesToString(
  8923. dirPlacesQueryPacket.QueryData.QueryText),
  8924. (int)dirPlacesQueryPacket.QueryData.QueryFlags,
  8925. (int)dirPlacesQueryPacket.QueryData.Category,
  8926. Utils.BytesToString(
  8927. dirPlacesQueryPacket.QueryData.SimName),
  8928. dirPlacesQueryPacket.QueryData.QueryStart);
  8929. }
  8930. return true;
  8931. }
  8932. private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
  8933. {
  8934. DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
  8935. #region Packet Session and User Check
  8936. if (m_checkPackets)
  8937. {
  8938. if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
  8939. dirFindQueryPacket.AgentData.AgentID != AgentId)
  8940. return true;
  8941. }
  8942. #endregion
  8943. DirFindQuery handlerDirFindQuery = OnDirFindQuery;
  8944. if (handlerDirFindQuery != null)
  8945. {
  8946. handlerDirFindQuery(this,
  8947. dirFindQueryPacket.QueryData.QueryID,
  8948. Utils.BytesToString(
  8949. dirFindQueryPacket.QueryData.QueryText),
  8950. dirFindQueryPacket.QueryData.QueryFlags,
  8951. dirFindQueryPacket.QueryData.QueryStart);
  8952. }
  8953. return true;
  8954. }
  8955. private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
  8956. {
  8957. DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
  8958. #region Packet Session and User Check
  8959. if (m_checkPackets)
  8960. {
  8961. if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
  8962. dirLandQueryPacket.AgentData.AgentID != AgentId)
  8963. return true;
  8964. }
  8965. #endregion
  8966. DirLandQuery handlerDirLandQuery = OnDirLandQuery;
  8967. if (handlerDirLandQuery != null)
  8968. {
  8969. handlerDirLandQuery(this,
  8970. dirLandQueryPacket.QueryData.QueryID,
  8971. dirLandQueryPacket.QueryData.QueryFlags,
  8972. dirLandQueryPacket.QueryData.SearchType,
  8973. dirLandQueryPacket.QueryData.Price,
  8974. dirLandQueryPacket.QueryData.Area,
  8975. dirLandQueryPacket.QueryData.QueryStart);
  8976. }
  8977. return true;
  8978. }
  8979. private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
  8980. {
  8981. DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
  8982. #region Packet Session and User Check
  8983. if (m_checkPackets)
  8984. {
  8985. if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
  8986. dirPopularQueryPacket.AgentData.AgentID != AgentId)
  8987. return true;
  8988. }
  8989. #endregion
  8990. DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
  8991. if (handlerDirPopularQuery != null)
  8992. {
  8993. handlerDirPopularQuery(this,
  8994. dirPopularQueryPacket.QueryData.QueryID,
  8995. dirPopularQueryPacket.QueryData.QueryFlags);
  8996. }
  8997. return true;
  8998. }
  8999. private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
  9000. {
  9001. DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
  9002. #region Packet Session and User Check
  9003. if (m_checkPackets)
  9004. {
  9005. if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
  9006. dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
  9007. return true;
  9008. }
  9009. #endregion
  9010. DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
  9011. if (handlerDirClassifiedQuery != null)
  9012. {
  9013. handlerDirClassifiedQuery(this,
  9014. dirClassifiedQueryPacket.QueryData.QueryID,
  9015. Utils.BytesToString(
  9016. dirClassifiedQueryPacket.QueryData.QueryText),
  9017. dirClassifiedQueryPacket.QueryData.QueryFlags,
  9018. dirClassifiedQueryPacket.QueryData.Category,
  9019. dirClassifiedQueryPacket.QueryData.QueryStart);
  9020. }
  9021. return true;
  9022. }
  9023. private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
  9024. {
  9025. EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
  9026. #region Packet Session and User Check
  9027. if (m_checkPackets)
  9028. {
  9029. if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
  9030. eventInfoRequestPacket.AgentData.AgentID != AgentId)
  9031. return true;
  9032. }
  9033. #endregion
  9034. if (OnEventInfoRequest != null)
  9035. {
  9036. OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
  9037. }
  9038. return true;
  9039. }
  9040. #endregion
  9041. #region Calling Card
  9042. private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
  9043. {
  9044. OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
  9045. #region Packet Session and User Check
  9046. if (m_checkPackets)
  9047. {
  9048. if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
  9049. offerCallingCardPacket.AgentData.AgentID != AgentId)
  9050. return true;
  9051. }
  9052. #endregion
  9053. if (OnOfferCallingCard != null)
  9054. {
  9055. OnOfferCallingCard(this,
  9056. offerCallingCardPacket.AgentBlock.DestID,
  9057. offerCallingCardPacket.AgentBlock.TransactionID);
  9058. }
  9059. return true;
  9060. }
  9061. private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
  9062. {
  9063. AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
  9064. #region Packet Session and User Check
  9065. if (m_checkPackets)
  9066. {
  9067. if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
  9068. acceptCallingCardPacket.AgentData.AgentID != AgentId)
  9069. return true;
  9070. }
  9071. #endregion
  9072. // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
  9073. // contain exactly one entry
  9074. if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
  9075. {
  9076. OnAcceptCallingCard(this,
  9077. acceptCallingCardPacket.TransactionBlock.TransactionID,
  9078. acceptCallingCardPacket.FolderData[0].FolderID);
  9079. }
  9080. return true;
  9081. }
  9082. private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
  9083. {
  9084. DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
  9085. #region Packet Session and User Check
  9086. if (m_checkPackets)
  9087. {
  9088. if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
  9089. declineCallingCardPacket.AgentData.AgentID != AgentId)
  9090. return true;
  9091. }
  9092. #endregion
  9093. if (OnDeclineCallingCard != null)
  9094. {
  9095. OnDeclineCallingCard(this,
  9096. declineCallingCardPacket.TransactionBlock.TransactionID);
  9097. }
  9098. return true;
  9099. }
  9100. #endregion Calling Card
  9101. #region Groups
  9102. private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
  9103. {
  9104. ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
  9105. #region Packet Session and User Check
  9106. if (m_checkPackets)
  9107. {
  9108. if (activateGroupPacket.AgentData.SessionID != SessionId ||
  9109. activateGroupPacket.AgentData.AgentID != AgentId)
  9110. return true;
  9111. }
  9112. #endregion
  9113. if (m_GroupsModule != null)
  9114. {
  9115. m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
  9116. m_GroupsModule.SendAgentGroupDataUpdate(this);
  9117. }
  9118. return true;
  9119. }
  9120. private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
  9121. {
  9122. GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
  9123. (GroupVoteHistoryRequestPacket)Packet;
  9124. GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
  9125. if (handlerGroupVoteHistoryRequest != null)
  9126. {
  9127. handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
  9128. return true;
  9129. }
  9130. return false;
  9131. }
  9132. private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
  9133. {
  9134. GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
  9135. (GroupActiveProposalsRequestPacket)Packet;
  9136. GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
  9137. if (handlerGroupActiveProposalsRequest != null)
  9138. {
  9139. handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
  9140. return true;
  9141. }
  9142. return false;
  9143. }
  9144. private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
  9145. {
  9146. GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
  9147. (GroupAccountDetailsRequestPacket)Packet;
  9148. GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
  9149. if (handlerGroupAccountDetailsRequest != null)
  9150. {
  9151. handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
  9152. return true;
  9153. }
  9154. return false;
  9155. }
  9156. private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
  9157. {
  9158. GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
  9159. (GroupAccountSummaryRequestPacket)Packet;
  9160. GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
  9161. if (handlerGroupAccountSummaryRequest != null)
  9162. {
  9163. handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
  9164. return true;
  9165. }
  9166. return false;
  9167. }
  9168. private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
  9169. {
  9170. GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
  9171. (GroupAccountTransactionsRequestPacket)Packet;
  9172. GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
  9173. if (handlerGroupAccountTransactionsRequest != null)
  9174. {
  9175. handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
  9176. return true;
  9177. }
  9178. return false;
  9179. }
  9180. private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
  9181. {
  9182. GroupTitlesRequestPacket groupTitlesRequest =
  9183. (GroupTitlesRequestPacket)Pack;
  9184. #region Packet Session and User Check
  9185. if (m_checkPackets)
  9186. {
  9187. if (groupTitlesRequest.AgentData.SessionID != SessionId ||
  9188. groupTitlesRequest.AgentData.AgentID != AgentId)
  9189. return true;
  9190. }
  9191. #endregion
  9192. if (m_GroupsModule != null)
  9193. {
  9194. GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
  9195. groupTitlesReply.AgentData =
  9196. new GroupTitlesReplyPacket.AgentDataBlock();
  9197. groupTitlesReply.AgentData.AgentID = AgentId;
  9198. groupTitlesReply.AgentData.GroupID =
  9199. groupTitlesRequest.AgentData.GroupID;
  9200. groupTitlesReply.AgentData.RequestID =
  9201. groupTitlesRequest.AgentData.RequestID;
  9202. List<GroupTitlesData> titles =
  9203. m_GroupsModule.GroupTitlesRequest(this,
  9204. groupTitlesRequest.AgentData.GroupID);
  9205. groupTitlesReply.GroupData =
  9206. new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
  9207. int i = 0;
  9208. foreach (GroupTitlesData d in titles)
  9209. {
  9210. groupTitlesReply.GroupData[i] =
  9211. new GroupTitlesReplyPacket.GroupDataBlock();
  9212. groupTitlesReply.GroupData[i].Title =
  9213. Util.StringToBytes256(d.Name);
  9214. groupTitlesReply.GroupData[i].RoleID =
  9215. d.UUID;
  9216. groupTitlesReply.GroupData[i].Selected =
  9217. d.Selected;
  9218. i++;
  9219. }
  9220. OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
  9221. }
  9222. return true;
  9223. }
  9224. private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
  9225. {
  9226. GroupProfileRequestPacket groupProfileRequest =
  9227. (GroupProfileRequestPacket)Pack;
  9228. #region Packet Session and User Check
  9229. if (m_checkPackets)
  9230. {
  9231. if (groupProfileRequest.AgentData.SessionID != SessionId ||
  9232. groupProfileRequest.AgentData.AgentID != AgentId)
  9233. return true;
  9234. }
  9235. #endregion
  9236. if (m_GroupsModule != null)
  9237. {
  9238. GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
  9239. groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
  9240. groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
  9241. groupProfileReply.AgentData.AgentID = AgentId;
  9242. GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
  9243. groupProfileRequest.GroupData.GroupID);
  9244. groupProfileReply.GroupData.GroupID = d.GroupID;
  9245. groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
  9246. groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
  9247. groupProfileReply.GroupData.ShowInList = d.ShowInList;
  9248. groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
  9249. groupProfileReply.GroupData.PowersMask = d.PowersMask;
  9250. groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
  9251. groupProfileReply.GroupData.FounderID = d.FounderID;
  9252. groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
  9253. groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
  9254. groupProfileReply.GroupData.Money = d.Money;
  9255. groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
  9256. groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
  9257. groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
  9258. groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
  9259. groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
  9260. OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
  9261. }
  9262. return true;
  9263. }
  9264. private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
  9265. {
  9266. GroupMembersRequestPacket groupMembersRequestPacket =
  9267. (GroupMembersRequestPacket)Pack;
  9268. #region Packet Session and User Check
  9269. if (m_checkPackets)
  9270. {
  9271. if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
  9272. groupMembersRequestPacket.AgentData.AgentID != AgentId)
  9273. return true;
  9274. }
  9275. #endregion
  9276. if (m_GroupsModule != null)
  9277. {
  9278. List<GroupMembersData> members =
  9279. m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
  9280. int memberCount = members.Count;
  9281. while (true)
  9282. {
  9283. int blockCount = members.Count;
  9284. if (blockCount > 40)
  9285. blockCount = 40;
  9286. GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
  9287. groupMembersReply.AgentData =
  9288. new GroupMembersReplyPacket.AgentDataBlock();
  9289. groupMembersReply.GroupData =
  9290. new GroupMembersReplyPacket.GroupDataBlock();
  9291. groupMembersReply.MemberData =
  9292. new GroupMembersReplyPacket.MemberDataBlock[
  9293. blockCount];
  9294. groupMembersReply.AgentData.AgentID = AgentId;
  9295. groupMembersReply.GroupData.GroupID =
  9296. groupMembersRequestPacket.GroupData.GroupID;
  9297. groupMembersReply.GroupData.RequestID =
  9298. groupMembersRequestPacket.GroupData.RequestID;
  9299. groupMembersReply.GroupData.MemberCount = memberCount;
  9300. for (int i = 0; i < blockCount; i++)
  9301. {
  9302. GroupMembersData m = members[0];
  9303. members.RemoveAt(0);
  9304. groupMembersReply.MemberData[i] =
  9305. new GroupMembersReplyPacket.MemberDataBlock();
  9306. groupMembersReply.MemberData[i].AgentID =
  9307. m.AgentID;
  9308. groupMembersReply.MemberData[i].Contribution =
  9309. m.Contribution;
  9310. groupMembersReply.MemberData[i].OnlineStatus =
  9311. Util.StringToBytes256(m.OnlineStatus);
  9312. groupMembersReply.MemberData[i].AgentPowers =
  9313. m.AgentPowers;
  9314. groupMembersReply.MemberData[i].Title =
  9315. Util.StringToBytes256(m.Title);
  9316. groupMembersReply.MemberData[i].IsOwner =
  9317. m.IsOwner;
  9318. }
  9319. OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
  9320. if (members.Count == 0)
  9321. return true;
  9322. }
  9323. }
  9324. return true;
  9325. }
  9326. private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
  9327. {
  9328. GroupRoleDataRequestPacket groupRolesRequest =
  9329. (GroupRoleDataRequestPacket)Pack;
  9330. #region Packet Session and User Check
  9331. if (m_checkPackets)
  9332. {
  9333. if (groupRolesRequest.AgentData.SessionID != SessionId ||
  9334. groupRolesRequest.AgentData.AgentID != AgentId)
  9335. return true;
  9336. }
  9337. #endregion
  9338. if (m_GroupsModule != null)
  9339. {
  9340. GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
  9341. groupRolesReply.AgentData =
  9342. new GroupRoleDataReplyPacket.AgentDataBlock();
  9343. groupRolesReply.AgentData.AgentID = AgentId;
  9344. groupRolesReply.GroupData =
  9345. new GroupRoleDataReplyPacket.GroupDataBlock();
  9346. groupRolesReply.GroupData.GroupID =
  9347. groupRolesRequest.GroupData.GroupID;
  9348. groupRolesReply.GroupData.RequestID =
  9349. groupRolesRequest.GroupData.RequestID;
  9350. List<GroupRolesData> titles =
  9351. m_GroupsModule.GroupRoleDataRequest(this,
  9352. groupRolesRequest.GroupData.GroupID);
  9353. groupRolesReply.GroupData.RoleCount =
  9354. titles.Count;
  9355. groupRolesReply.RoleData =
  9356. new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
  9357. int i = 0;
  9358. foreach (GroupRolesData d in titles)
  9359. {
  9360. groupRolesReply.RoleData[i] =
  9361. new GroupRoleDataReplyPacket.RoleDataBlock();
  9362. groupRolesReply.RoleData[i].RoleID =
  9363. d.RoleID;
  9364. groupRolesReply.RoleData[i].Name =
  9365. Util.StringToBytes256(d.Name);
  9366. groupRolesReply.RoleData[i].Title =
  9367. Util.StringToBytes256(d.Title);
  9368. groupRolesReply.RoleData[i].Description =
  9369. Util.StringToBytes1024(d.Description);
  9370. groupRolesReply.RoleData[i].Powers =
  9371. d.Powers;
  9372. groupRolesReply.RoleData[i].Members =
  9373. (uint)d.Members;
  9374. i++;
  9375. }
  9376. OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
  9377. }
  9378. return true;
  9379. }
  9380. private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
  9381. {
  9382. GroupRoleMembersRequestPacket groupRoleMembersRequest =
  9383. (GroupRoleMembersRequestPacket)Pack;
  9384. #region Packet Session and User Check
  9385. if (m_checkPackets)
  9386. {
  9387. if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
  9388. groupRoleMembersRequest.AgentData.AgentID != AgentId)
  9389. return true;
  9390. }
  9391. #endregion
  9392. if (m_GroupsModule != null)
  9393. {
  9394. List<GroupRoleMembersData> mappings =
  9395. m_GroupsModule.GroupRoleMembersRequest(this,
  9396. groupRoleMembersRequest.GroupData.GroupID);
  9397. int mappingsCount = mappings.Count;
  9398. while (mappings.Count > 0)
  9399. {
  9400. int pairs = mappings.Count;
  9401. if (pairs > 32)
  9402. pairs = 32;
  9403. GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
  9404. groupRoleMembersReply.AgentData =
  9405. new GroupRoleMembersReplyPacket.AgentDataBlock();
  9406. groupRoleMembersReply.AgentData.AgentID =
  9407. AgentId;
  9408. groupRoleMembersReply.AgentData.GroupID =
  9409. groupRoleMembersRequest.GroupData.GroupID;
  9410. groupRoleMembersReply.AgentData.RequestID =
  9411. groupRoleMembersRequest.GroupData.RequestID;
  9412. groupRoleMembersReply.AgentData.TotalPairs =
  9413. (uint)mappingsCount;
  9414. groupRoleMembersReply.MemberData =
  9415. new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
  9416. for (int i = 0; i < pairs; i++)
  9417. {
  9418. GroupRoleMembersData d = mappings[0];
  9419. mappings.RemoveAt(0);
  9420. groupRoleMembersReply.MemberData[i] =
  9421. new GroupRoleMembersReplyPacket.MemberDataBlock();
  9422. groupRoleMembersReply.MemberData[i].RoleID =
  9423. d.RoleID;
  9424. groupRoleMembersReply.MemberData[i].MemberID =
  9425. d.MemberID;
  9426. }
  9427. OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
  9428. }
  9429. }
  9430. return true;
  9431. }
  9432. private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
  9433. {
  9434. CreateGroupRequestPacket createGroupRequest =
  9435. (CreateGroupRequestPacket)Pack;
  9436. #region Packet Session and User Check
  9437. if (m_checkPackets)
  9438. {
  9439. if (createGroupRequest.AgentData.SessionID != SessionId ||
  9440. createGroupRequest.AgentData.AgentID != AgentId)
  9441. return true;
  9442. }
  9443. #endregion
  9444. if (m_GroupsModule != null)
  9445. {
  9446. m_GroupsModule.CreateGroup(this,
  9447. Utils.BytesToString(createGroupRequest.GroupData.Name),
  9448. Utils.BytesToString(createGroupRequest.GroupData.Charter),
  9449. createGroupRequest.GroupData.ShowInList,
  9450. createGroupRequest.GroupData.InsigniaID,
  9451. createGroupRequest.GroupData.MembershipFee,
  9452. createGroupRequest.GroupData.OpenEnrollment,
  9453. createGroupRequest.GroupData.AllowPublish,
  9454. createGroupRequest.GroupData.MaturePublish);
  9455. }
  9456. return true;
  9457. }
  9458. private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
  9459. {
  9460. UpdateGroupInfoPacket updateGroupInfo =
  9461. (UpdateGroupInfoPacket)Pack;
  9462. #region Packet Session and User Check
  9463. if (m_checkPackets)
  9464. {
  9465. if (updateGroupInfo.AgentData.SessionID != SessionId ||
  9466. updateGroupInfo.AgentData.AgentID != AgentId)
  9467. return true;
  9468. }
  9469. #endregion
  9470. if (m_GroupsModule != null)
  9471. {
  9472. m_GroupsModule.UpdateGroupInfo(this,
  9473. updateGroupInfo.GroupData.GroupID,
  9474. Utils.BytesToString(updateGroupInfo.GroupData.Charter),
  9475. updateGroupInfo.GroupData.ShowInList,
  9476. updateGroupInfo.GroupData.InsigniaID,
  9477. updateGroupInfo.GroupData.MembershipFee,
  9478. updateGroupInfo.GroupData.OpenEnrollment,
  9479. updateGroupInfo.GroupData.AllowPublish,
  9480. updateGroupInfo.GroupData.MaturePublish);
  9481. }
  9482. return true;
  9483. }
  9484. private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
  9485. {
  9486. SetGroupAcceptNoticesPacket setGroupAcceptNotices =
  9487. (SetGroupAcceptNoticesPacket)Pack;
  9488. #region Packet Session and User Check
  9489. if (m_checkPackets)
  9490. {
  9491. if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
  9492. setGroupAcceptNotices.AgentData.AgentID != AgentId)
  9493. return true;
  9494. }
  9495. #endregion
  9496. if (m_GroupsModule != null)
  9497. {
  9498. m_GroupsModule.SetGroupAcceptNotices(this,
  9499. setGroupAcceptNotices.Data.GroupID,
  9500. setGroupAcceptNotices.Data.AcceptNotices,
  9501. setGroupAcceptNotices.NewData.ListInProfile);
  9502. }
  9503. return true;
  9504. }
  9505. private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
  9506. {
  9507. GroupTitleUpdatePacket groupTitleUpdate =
  9508. (GroupTitleUpdatePacket)Pack;
  9509. #region Packet Session and User Check
  9510. if (m_checkPackets)
  9511. {
  9512. if (groupTitleUpdate.AgentData.SessionID != SessionId ||
  9513. groupTitleUpdate.AgentData.AgentID != AgentId)
  9514. return true;
  9515. }
  9516. #endregion
  9517. if (m_GroupsModule != null)
  9518. {
  9519. m_GroupsModule.GroupTitleUpdate(this,
  9520. groupTitleUpdate.AgentData.GroupID,
  9521. groupTitleUpdate.AgentData.TitleRoleID);
  9522. }
  9523. return true;
  9524. }
  9525. private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
  9526. {
  9527. ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
  9528. if (m_GroupsModule != null)
  9529. {
  9530. ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
  9531. if (handlerParcelDeedToGroup != null)
  9532. {
  9533. handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
  9534. }
  9535. }
  9536. return true;
  9537. }
  9538. private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
  9539. {
  9540. GroupNoticesListRequestPacket groupNoticesListRequest =
  9541. (GroupNoticesListRequestPacket)Pack;
  9542. #region Packet Session and User Check
  9543. if (m_checkPackets)
  9544. {
  9545. if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
  9546. groupNoticesListRequest.AgentData.AgentID != AgentId)
  9547. return true;
  9548. }
  9549. #endregion
  9550. if (m_GroupsModule != null)
  9551. {
  9552. GroupNoticeData[] gn =
  9553. m_GroupsModule.GroupNoticesListRequest(this,
  9554. groupNoticesListRequest.Data.GroupID);
  9555. GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
  9556. groupNoticesListReply.AgentData =
  9557. new GroupNoticesListReplyPacket.AgentDataBlock();
  9558. groupNoticesListReply.AgentData.AgentID = AgentId;
  9559. groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
  9560. groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
  9561. int i = 0;
  9562. foreach (GroupNoticeData g in gn)
  9563. {
  9564. groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
  9565. groupNoticesListReply.Data[i].NoticeID =
  9566. g.NoticeID;
  9567. groupNoticesListReply.Data[i].Timestamp =
  9568. g.Timestamp;
  9569. groupNoticesListReply.Data[i].FromName =
  9570. Util.StringToBytes256(g.FromName);
  9571. groupNoticesListReply.Data[i].Subject =
  9572. Util.StringToBytes256(g.Subject);
  9573. groupNoticesListReply.Data[i].HasAttachment =
  9574. g.HasAttachment;
  9575. groupNoticesListReply.Data[i].AssetType =
  9576. g.AssetType;
  9577. i++;
  9578. }
  9579. OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
  9580. }
  9581. return true;
  9582. }
  9583. private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
  9584. {
  9585. GroupNoticeRequestPacket groupNoticeRequest =
  9586. (GroupNoticeRequestPacket)Pack;
  9587. #region Packet Session and User Check
  9588. if (m_checkPackets)
  9589. {
  9590. if (groupNoticeRequest.AgentData.SessionID != SessionId ||
  9591. groupNoticeRequest.AgentData.AgentID != AgentId)
  9592. return true;
  9593. }
  9594. #endregion
  9595. if (m_GroupsModule != null)
  9596. {
  9597. m_GroupsModule.GroupNoticeRequest(this,
  9598. groupNoticeRequest.Data.GroupNoticeID);
  9599. }
  9600. return true;
  9601. }
  9602. private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
  9603. {
  9604. GroupRoleUpdatePacket groupRoleUpdate =
  9605. (GroupRoleUpdatePacket)Pack;
  9606. #region Packet Session and User Check
  9607. if (m_checkPackets)
  9608. {
  9609. if (groupRoleUpdate.AgentData.SessionID != SessionId ||
  9610. groupRoleUpdate.AgentData.AgentID != AgentId)
  9611. return true;
  9612. }
  9613. #endregion
  9614. if (m_GroupsModule != null)
  9615. {
  9616. foreach (GroupRoleUpdatePacket.RoleDataBlock d in
  9617. groupRoleUpdate.RoleData)
  9618. {
  9619. m_GroupsModule.GroupRoleUpdate(this,
  9620. groupRoleUpdate.AgentData.GroupID,
  9621. d.RoleID,
  9622. Utils.BytesToString(d.Name),
  9623. Utils.BytesToString(d.Description),
  9624. Utils.BytesToString(d.Title),
  9625. d.Powers,
  9626. d.UpdateType);
  9627. }
  9628. m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
  9629. }
  9630. return true;
  9631. }
  9632. private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
  9633. {
  9634. GroupRoleChangesPacket groupRoleChanges =
  9635. (GroupRoleChangesPacket)Pack;
  9636. #region Packet Session and User Check
  9637. if (m_checkPackets)
  9638. {
  9639. if (groupRoleChanges.AgentData.SessionID != SessionId ||
  9640. groupRoleChanges.AgentData.AgentID != AgentId)
  9641. return true;
  9642. }
  9643. #endregion
  9644. if (m_GroupsModule != null)
  9645. {
  9646. foreach (GroupRoleChangesPacket.RoleChangeBlock d in
  9647. groupRoleChanges.RoleChange)
  9648. {
  9649. m_GroupsModule.GroupRoleChanges(this,
  9650. groupRoleChanges.AgentData.GroupID,
  9651. d.RoleID,
  9652. d.MemberID,
  9653. d.Change);
  9654. }
  9655. m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
  9656. }
  9657. return true;
  9658. }
  9659. private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
  9660. {
  9661. JoinGroupRequestPacket joinGroupRequest =
  9662. (JoinGroupRequestPacket)Pack;
  9663. #region Packet Session and User Check
  9664. if (m_checkPackets)
  9665. {
  9666. if (joinGroupRequest.AgentData.SessionID != SessionId ||
  9667. joinGroupRequest.AgentData.AgentID != AgentId)
  9668. return true;
  9669. }
  9670. #endregion
  9671. if (m_GroupsModule != null)
  9672. {
  9673. m_GroupsModule.JoinGroupRequest(this,
  9674. joinGroupRequest.GroupData.GroupID);
  9675. }
  9676. return true;
  9677. }
  9678. private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
  9679. {
  9680. LeaveGroupRequestPacket leaveGroupRequest =
  9681. (LeaveGroupRequestPacket)Pack;
  9682. #region Packet Session and User Check
  9683. if (m_checkPackets)
  9684. {
  9685. if (leaveGroupRequest.AgentData.SessionID != SessionId ||
  9686. leaveGroupRequest.AgentData.AgentID != AgentId)
  9687. return true;
  9688. }
  9689. #endregion
  9690. if (m_GroupsModule != null)
  9691. {
  9692. m_GroupsModule.LeaveGroupRequest(this,
  9693. leaveGroupRequest.GroupData.GroupID);
  9694. }
  9695. return true;
  9696. }
  9697. private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
  9698. {
  9699. EjectGroupMemberRequestPacket ejectGroupMemberRequest =
  9700. (EjectGroupMemberRequestPacket)Pack;
  9701. #region Packet Session and User Check
  9702. if (m_checkPackets)
  9703. {
  9704. if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
  9705. ejectGroupMemberRequest.AgentData.AgentID != AgentId)
  9706. return true;
  9707. }
  9708. #endregion
  9709. if (m_GroupsModule != null)
  9710. {
  9711. foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
  9712. in ejectGroupMemberRequest.EjectData)
  9713. {
  9714. m_GroupsModule.EjectGroupMemberRequest(this,
  9715. ejectGroupMemberRequest.GroupData.GroupID,
  9716. e.EjecteeID);
  9717. }
  9718. }
  9719. return true;
  9720. }
  9721. private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
  9722. {
  9723. InviteGroupRequestPacket inviteGroupRequest =
  9724. (InviteGroupRequestPacket)Pack;
  9725. #region Packet Session and User Check
  9726. if (m_checkPackets)
  9727. {
  9728. if (inviteGroupRequest.AgentData.SessionID != SessionId ||
  9729. inviteGroupRequest.AgentData.AgentID != AgentId)
  9730. return true;
  9731. }
  9732. #endregion
  9733. if (m_GroupsModule != null)
  9734. {
  9735. foreach (InviteGroupRequestPacket.InviteDataBlock b in
  9736. inviteGroupRequest.InviteData)
  9737. {
  9738. m_GroupsModule.InviteGroupRequest(this,
  9739. inviteGroupRequest.GroupData.GroupID,
  9740. b.InviteeID,
  9741. b.RoleID);
  9742. }
  9743. }
  9744. return true;
  9745. }
  9746. #endregion Groups
  9747. private bool HandleStartLure(IClientAPI sender, Packet Pack)
  9748. {
  9749. StartLurePacket startLureRequest = (StartLurePacket)Pack;
  9750. #region Packet Session and User Check
  9751. if (m_checkPackets)
  9752. {
  9753. if (startLureRequest.AgentData.SessionID != SessionId ||
  9754. startLureRequest.AgentData.AgentID != AgentId)
  9755. return true;
  9756. }
  9757. #endregion
  9758. StartLure handlerStartLure = OnStartLure;
  9759. if (handlerStartLure != null)
  9760. handlerStartLure(startLureRequest.Info.LureType,
  9761. Utils.BytesToString(
  9762. startLureRequest.Info.Message),
  9763. startLureRequest.TargetData[0].TargetID,
  9764. this);
  9765. return true;
  9766. }
  9767. private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
  9768. {
  9769. TeleportLureRequestPacket teleportLureRequest =
  9770. (TeleportLureRequestPacket)Pack;
  9771. #region Packet Session and User Check
  9772. if (m_checkPackets)
  9773. {
  9774. if (teleportLureRequest.Info.SessionID != SessionId ||
  9775. teleportLureRequest.Info.AgentID != AgentId)
  9776. return true;
  9777. }
  9778. #endregion
  9779. TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
  9780. if (handlerTeleportLureRequest != null)
  9781. handlerTeleportLureRequest(
  9782. teleportLureRequest.Info.LureID,
  9783. teleportLureRequest.Info.TeleportFlags,
  9784. this);
  9785. return true;
  9786. }
  9787. private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
  9788. {
  9789. ClassifiedInfoRequestPacket classifiedInfoRequest =
  9790. (ClassifiedInfoRequestPacket)Pack;
  9791. #region Packet Session and User Check
  9792. if (m_checkPackets)
  9793. {
  9794. if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
  9795. classifiedInfoRequest.AgentData.AgentID != AgentId)
  9796. return true;
  9797. }
  9798. #endregion
  9799. ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
  9800. if (handlerClassifiedInfoRequest != null)
  9801. handlerClassifiedInfoRequest(
  9802. classifiedInfoRequest.Data.ClassifiedID,
  9803. this);
  9804. return true;
  9805. }
  9806. private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
  9807. {
  9808. ClassifiedInfoUpdatePacket classifiedInfoUpdate =
  9809. (ClassifiedInfoUpdatePacket)Pack;
  9810. #region Packet Session and User Check
  9811. if (m_checkPackets)
  9812. {
  9813. if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
  9814. classifiedInfoUpdate.AgentData.AgentID != AgentId)
  9815. return true;
  9816. }
  9817. #endregion
  9818. ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
  9819. if (handlerClassifiedInfoUpdate != null)
  9820. handlerClassifiedInfoUpdate(
  9821. classifiedInfoUpdate.Data.ClassifiedID,
  9822. classifiedInfoUpdate.Data.Category,
  9823. Utils.BytesToString(
  9824. classifiedInfoUpdate.Data.Name),
  9825. Utils.BytesToString(
  9826. classifiedInfoUpdate.Data.Desc),
  9827. classifiedInfoUpdate.Data.ParcelID,
  9828. classifiedInfoUpdate.Data.ParentEstate,
  9829. classifiedInfoUpdate.Data.SnapshotID,
  9830. new Vector3(
  9831. classifiedInfoUpdate.Data.PosGlobal),
  9832. classifiedInfoUpdate.Data.ClassifiedFlags,
  9833. classifiedInfoUpdate.Data.PriceForListing,
  9834. this);
  9835. return true;
  9836. }
  9837. private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
  9838. {
  9839. ClassifiedDeletePacket classifiedDelete =
  9840. (ClassifiedDeletePacket)Pack;
  9841. #region Packet Session and User Check
  9842. if (m_checkPackets)
  9843. {
  9844. if (classifiedDelete.AgentData.SessionID != SessionId ||
  9845. classifiedDelete.AgentData.AgentID != AgentId)
  9846. return true;
  9847. }
  9848. #endregion
  9849. ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
  9850. if (handlerClassifiedDelete != null)
  9851. handlerClassifiedDelete(
  9852. classifiedDelete.Data.ClassifiedID,
  9853. this);
  9854. return true;
  9855. }
  9856. private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
  9857. {
  9858. ClassifiedGodDeletePacket classifiedGodDelete =
  9859. (ClassifiedGodDeletePacket)Pack;
  9860. #region Packet Session and User Check
  9861. if (m_checkPackets)
  9862. {
  9863. if (classifiedGodDelete.AgentData.SessionID != SessionId ||
  9864. classifiedGodDelete.AgentData.AgentID != AgentId)
  9865. return true;
  9866. }
  9867. #endregion
  9868. ClassifiedDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
  9869. if (handlerClassifiedGodDelete != null)
  9870. handlerClassifiedGodDelete(
  9871. classifiedGodDelete.Data.ClassifiedID,
  9872. this);
  9873. return true;
  9874. }
  9875. private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
  9876. {
  9877. EventGodDeletePacket eventGodDelete =
  9878. (EventGodDeletePacket)Pack;
  9879. #region Packet Session and User Check
  9880. if (m_checkPackets)
  9881. {
  9882. if (eventGodDelete.AgentData.SessionID != SessionId ||
  9883. eventGodDelete.AgentData.AgentID != AgentId)
  9884. return true;
  9885. }
  9886. #endregion
  9887. EventGodDelete handlerEventGodDelete = OnEventGodDelete;
  9888. if (handlerEventGodDelete != null)
  9889. handlerEventGodDelete(
  9890. eventGodDelete.EventData.EventID,
  9891. eventGodDelete.QueryData.QueryID,
  9892. Utils.BytesToString(
  9893. eventGodDelete.QueryData.QueryText),
  9894. eventGodDelete.QueryData.QueryFlags,
  9895. eventGodDelete.QueryData.QueryStart,
  9896. this);
  9897. return true;
  9898. }
  9899. private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
  9900. {
  9901. EventNotificationAddRequestPacket eventNotificationAdd =
  9902. (EventNotificationAddRequestPacket)Pack;
  9903. #region Packet Session and User Check
  9904. if (m_checkPackets)
  9905. {
  9906. if (eventNotificationAdd.AgentData.SessionID != SessionId ||
  9907. eventNotificationAdd.AgentData.AgentID != AgentId)
  9908. return true;
  9909. }
  9910. #endregion
  9911. EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
  9912. if (handlerEventNotificationAddRequest != null)
  9913. handlerEventNotificationAddRequest(
  9914. eventNotificationAdd.EventData.EventID, this);
  9915. return true;
  9916. }
  9917. private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
  9918. {
  9919. EventNotificationRemoveRequestPacket eventNotificationRemove =
  9920. (EventNotificationRemoveRequestPacket)Pack;
  9921. #region Packet Session and User Check
  9922. if (m_checkPackets)
  9923. {
  9924. if (eventNotificationRemove.AgentData.SessionID != SessionId ||
  9925. eventNotificationRemove.AgentData.AgentID != AgentId)
  9926. return true;
  9927. }
  9928. #endregion
  9929. EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
  9930. if (handlerEventNotificationRemoveRequest != null)
  9931. handlerEventNotificationRemoveRequest(
  9932. eventNotificationRemove.EventData.EventID, this);
  9933. return true;
  9934. }
  9935. private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
  9936. {
  9937. RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
  9938. #region Packet Session and User Check
  9939. if (m_checkPackets)
  9940. {
  9941. if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
  9942. rimpInstantMessagePack.AgentData.AgentID != AgentId)
  9943. return true;
  9944. }
  9945. #endregion
  9946. RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
  9947. if (handlerRetrieveInstantMessages != null)
  9948. handlerRetrieveInstantMessages(this);
  9949. return true;
  9950. }
  9951. private bool HandlePickDelete(IClientAPI sender, Packet Pack)
  9952. {
  9953. PickDeletePacket pickDelete =
  9954. (PickDeletePacket)Pack;
  9955. #region Packet Session and User Check
  9956. if (m_checkPackets)
  9957. {
  9958. if (pickDelete.AgentData.SessionID != SessionId ||
  9959. pickDelete.AgentData.AgentID != AgentId)
  9960. return true;
  9961. }
  9962. #endregion
  9963. PickDelete handlerPickDelete = OnPickDelete;
  9964. if (handlerPickDelete != null)
  9965. handlerPickDelete(this, pickDelete.Data.PickID);
  9966. return true;
  9967. }
  9968. private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
  9969. {
  9970. PickGodDeletePacket pickGodDelete =
  9971. (PickGodDeletePacket)Pack;
  9972. #region Packet Session and User Check
  9973. if (m_checkPackets)
  9974. {
  9975. if (pickGodDelete.AgentData.SessionID != SessionId ||
  9976. pickGodDelete.AgentData.AgentID != AgentId)
  9977. return true;
  9978. }
  9979. #endregion
  9980. PickGodDelete handlerPickGodDelete = OnPickGodDelete;
  9981. if (handlerPickGodDelete != null)
  9982. handlerPickGodDelete(this,
  9983. pickGodDelete.AgentData.AgentID,
  9984. pickGodDelete.Data.PickID,
  9985. pickGodDelete.Data.QueryID);
  9986. return true;
  9987. }
  9988. private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
  9989. {
  9990. PickInfoUpdatePacket pickInfoUpdate =
  9991. (PickInfoUpdatePacket)Pack;
  9992. #region Packet Session and User Check
  9993. if (m_checkPackets)
  9994. {
  9995. if (pickInfoUpdate.AgentData.SessionID != SessionId ||
  9996. pickInfoUpdate.AgentData.AgentID != AgentId)
  9997. return true;
  9998. }
  9999. #endregion
  10000. PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
  10001. if (handlerPickInfoUpdate != null)
  10002. handlerPickInfoUpdate(this,
  10003. pickInfoUpdate.Data.PickID,
  10004. pickInfoUpdate.Data.CreatorID,
  10005. pickInfoUpdate.Data.TopPick,
  10006. Utils.BytesToString(pickInfoUpdate.Data.Name),
  10007. Utils.BytesToString(pickInfoUpdate.Data.Desc),
  10008. pickInfoUpdate.Data.SnapshotID,
  10009. pickInfoUpdate.Data.SortOrder,
  10010. pickInfoUpdate.Data.Enabled);
  10011. return true;
  10012. }
  10013. private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
  10014. {
  10015. AvatarNotesUpdatePacket avatarNotesUpdate =
  10016. (AvatarNotesUpdatePacket)Pack;
  10017. #region Packet Session and User Check
  10018. if (m_checkPackets)
  10019. {
  10020. if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
  10021. avatarNotesUpdate.AgentData.AgentID != AgentId)
  10022. return true;
  10023. }
  10024. #endregion
  10025. AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
  10026. if (handlerAvatarNotesUpdate != null)
  10027. handlerAvatarNotesUpdate(this,
  10028. avatarNotesUpdate.Data.TargetID,
  10029. Utils.BytesToString(avatarNotesUpdate.Data.Notes));
  10030. return true;
  10031. }
  10032. private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
  10033. {
  10034. AvatarInterestsUpdatePacket avatarInterestUpdate =
  10035. (AvatarInterestsUpdatePacket)Pack;
  10036. #region Packet Session and User Check
  10037. if (m_checkPackets)
  10038. {
  10039. if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
  10040. avatarInterestUpdate.AgentData.AgentID != AgentId)
  10041. return true;
  10042. }
  10043. #endregion
  10044. AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
  10045. if (handlerAvatarInterestUpdate != null)
  10046. handlerAvatarInterestUpdate(this,
  10047. avatarInterestUpdate.PropertiesData.WantToMask,
  10048. Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
  10049. avatarInterestUpdate.PropertiesData.SkillsMask,
  10050. Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
  10051. Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
  10052. return true;
  10053. }
  10054. private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
  10055. {
  10056. GrantUserRightsPacket GrantUserRights =
  10057. (GrantUserRightsPacket)Pack;
  10058. #region Packet Session and User Check
  10059. if (m_checkPackets)
  10060. {
  10061. if (GrantUserRights.AgentData.SessionID != SessionId ||
  10062. GrantUserRights.AgentData.AgentID != AgentId)
  10063. return true;
  10064. }
  10065. #endregion
  10066. GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
  10067. if (GrantUserRightsHandler != null)
  10068. GrantUserRightsHandler(this,
  10069. GrantUserRights.Rights[0].AgentRelated,
  10070. GrantUserRights.Rights[0].RelatedRights);
  10071. return true;
  10072. }
  10073. private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
  10074. {
  10075. PlacesQueryPacket placesQueryPacket =
  10076. (PlacesQueryPacket)Pack;
  10077. PlacesQuery handlerPlacesQuery = OnPlacesQuery;
  10078. if (handlerPlacesQuery != null)
  10079. handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
  10080. placesQueryPacket.TransactionData.TransactionID,
  10081. Utils.BytesToString(
  10082. placesQueryPacket.QueryData.QueryText),
  10083. placesQueryPacket.QueryData.QueryFlags,
  10084. (byte)placesQueryPacket.QueryData.Category,
  10085. Utils.BytesToString(
  10086. placesQueryPacket.QueryData.SimName),
  10087. this);
  10088. return true;
  10089. }
  10090. #endregion Packet Handlers
  10091. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  10092. {
  10093. ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
  10094. scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
  10095. // TODO: don't create new blocks if recycling an old packet
  10096. scriptQuestion.Data.TaskID = taskID;
  10097. scriptQuestion.Data.ItemID = itemID;
  10098. scriptQuestion.Data.Questions = question;
  10099. scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
  10100. scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
  10101. OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
  10102. }
  10103. /// <summary>
  10104. /// Handler called when we receive a logout packet.
  10105. /// </summary>
  10106. /// <param name="client"></param>
  10107. /// <param name="packet"></param>
  10108. /// <returns></returns>
  10109. protected virtual bool HandleLogout(IClientAPI client, Packet packet)
  10110. {
  10111. if (packet.Type == PacketType.LogoutRequest)
  10112. {
  10113. if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
  10114. }
  10115. return Logout(client);
  10116. }
  10117. /// <summary>
  10118. ///
  10119. /// </summary>
  10120. /// <param name="client"></param>
  10121. /// <returns></returns>
  10122. protected virtual bool Logout(IClientAPI client)
  10123. {
  10124. m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
  10125. Action<IClientAPI> handlerLogout = OnLogout;
  10126. if (handlerLogout != null)
  10127. {
  10128. handlerLogout(client);
  10129. }
  10130. return true;
  10131. }
  10132. /// <summary>
  10133. /// </summary>
  10134. /// <remarks>
  10135. /// At the moment, we always reply that there is no cached texture.
  10136. /// </remarks>
  10137. /// <param name="simclient"></param>
  10138. /// <param name="packet"></param>
  10139. /// <returns></returns>
  10140. protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
  10141. {
  10142. AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
  10143. if (cachedtex.AgentData.SessionID != SessionId)
  10144. return false;
  10145. List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
  10146. for (int i = 0; i < cachedtex.WearableData.Length; i++)
  10147. {
  10148. CachedTextureRequestArg arg = new CachedTextureRequestArg();
  10149. arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
  10150. arg.WearableHashID = cachedtex.WearableData[i].ID;
  10151. requestArgs.Add(arg);
  10152. }
  10153. try
  10154. {
  10155. CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
  10156. if (handlerCachedTextureRequest != null)
  10157. {
  10158. handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
  10159. }
  10160. }
  10161. catch (Exception e)
  10162. {
  10163. m_log.ErrorFormat("[CLIENT VIEW]: AgentTextureCached packet handler threw an exception, {0}", e);
  10164. return false;
  10165. }
  10166. return true;
  10167. }
  10168. /// <summary>
  10169. /// Send a response back to a client when it asks the asset server (via the region server) if it has
  10170. /// its appearance texture cached.
  10171. /// </summary>
  10172. /// <param name="avatar"></param>
  10173. /// <param name="serial"></param>
  10174. /// <param name="cachedTextures"></param>
  10175. /// <returns></returns>
  10176. public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
  10177. {
  10178. ScenePresence presence = avatar as ScenePresence;
  10179. if (presence == null)
  10180. return;
  10181. AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
  10182. // TODO: don't create new blocks if recycling an old packet
  10183. cachedresp.AgentData.AgentID = m_agentId;
  10184. cachedresp.AgentData.SessionID = m_sessionId;
  10185. cachedresp.AgentData.SerialNum = serial;
  10186. cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
  10187. for (int i = 0; i < cachedTextures.Count; i++)
  10188. {
  10189. cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
  10190. cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
  10191. cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
  10192. cachedresp.WearableData[i].HostName = new byte[0];
  10193. }
  10194. cachedresp.Header.Zerocoded = true;
  10195. OutPacket(cachedresp, ThrottleOutPacketType.Task);
  10196. }
  10197. protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
  10198. {
  10199. MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
  10200. if (multipleupdate.AgentData.SessionID != SessionId)
  10201. return false;
  10202. // m_log.DebugFormat(
  10203. // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
  10204. Scene tScene = (Scene)m_scene;
  10205. for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
  10206. {
  10207. MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
  10208. // Can't act on Null Data
  10209. if (block.Data != null)
  10210. {
  10211. uint localId = block.ObjectLocalID;
  10212. SceneObjectPart part = tScene.GetSceneObjectPart(localId);
  10213. if (part == null)
  10214. {
  10215. // It's a ghost! tell the client to delete it from view.
  10216. simClient.SendKillObject(new List<uint> { localId });
  10217. }
  10218. else
  10219. {
  10220. // m_log.DebugFormat(
  10221. // "[CLIENT]: Processing block {0} type {1} for {2} {3}",
  10222. // i, block.Type, part.Name, part.LocalId);
  10223. // // Do this once since fetch parts creates a new array.
  10224. // SceneObjectPart[] parts = part.ParentGroup.Parts;
  10225. // for (int j = 0; j < parts.Length; j++)
  10226. // {
  10227. // part.StoreUndoState();
  10228. // parts[j].IgnoreUndoUpdate = true;
  10229. // }
  10230. UpdatePrimGroupRotation handlerUpdatePrimGroupRotation;
  10231. switch (block.Type)
  10232. {
  10233. case 1:
  10234. Vector3 pos1 = new Vector3(block.Data, 0);
  10235. UpdateVector handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10236. if (handlerUpdatePrimSinglePosition != null)
  10237. {
  10238. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10239. handlerUpdatePrimSinglePosition(localId, pos1, this);
  10240. }
  10241. break;
  10242. case 2:
  10243. Quaternion rot1 = new Quaternion(block.Data, 0, true);
  10244. UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
  10245. if (handlerUpdatePrimSingleRotation != null)
  10246. {
  10247. // m_log.Info("new tab rotation is " + rot1.X + " , " + rot1.Y + " , " + rot1.Z + " , " + rot1.W);
  10248. handlerUpdatePrimSingleRotation(localId, rot1, this);
  10249. }
  10250. break;
  10251. case 3:
  10252. Vector3 rotPos = new Vector3(block.Data, 0);
  10253. Quaternion rot2 = new Quaternion(block.Data, 12, true);
  10254. UpdatePrimSingleRotationPosition handlerUpdatePrimSingleRotationPosition = OnUpdatePrimSingleRotationPosition;
  10255. if (handlerUpdatePrimSingleRotationPosition != null)
  10256. {
  10257. // m_log.Debug("new mouse rotation position is " + rotPos.X + " , " + rotPos.Y + " , " + rotPos.Z);
  10258. // m_log.Info("new mouse rotation is " + rot2.X + " , " + rot2.Y + " , " + rot2.Z + " , " + rot2.W);
  10259. handlerUpdatePrimSingleRotationPosition(localId, rot2, rotPos, this);
  10260. }
  10261. break;
  10262. case 4:
  10263. case 20:
  10264. Vector3 scale4 = new Vector3(block.Data, 0);
  10265. UpdateVector handlerUpdatePrimScale = OnUpdatePrimScale;
  10266. if (handlerUpdatePrimScale != null)
  10267. {
  10268. // m_log.Debug("new scale is " + scale4.X + " , " + scale4.Y + " , " + scale4.Z);
  10269. handlerUpdatePrimScale(localId, scale4, this);
  10270. }
  10271. break;
  10272. case 5:
  10273. Vector3 scale1 = new Vector3(block.Data, 12);
  10274. Vector3 pos11 = new Vector3(block.Data, 0);
  10275. handlerUpdatePrimScale = OnUpdatePrimScale;
  10276. if (handlerUpdatePrimScale != null)
  10277. {
  10278. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10279. handlerUpdatePrimScale(localId, scale1, this);
  10280. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10281. if (handlerUpdatePrimSinglePosition != null)
  10282. {
  10283. handlerUpdatePrimSinglePosition(localId, pos11, this);
  10284. }
  10285. }
  10286. break;
  10287. case 9:
  10288. Vector3 pos2 = new Vector3(block.Data, 0);
  10289. UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
  10290. if (handlerUpdateVector != null)
  10291. {
  10292. handlerUpdateVector(localId, pos2, this);
  10293. }
  10294. break;
  10295. case 10:
  10296. Quaternion rot3 = new Quaternion(block.Data, 0, true);
  10297. UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
  10298. if (handlerUpdatePrimRotation != null)
  10299. {
  10300. // Console.WriteLine("new rotation is " + rot3.X + " , " + rot3.Y + " , " + rot3.Z + " , " + rot3.W);
  10301. handlerUpdatePrimRotation(localId, rot3, this);
  10302. }
  10303. break;
  10304. case 11:
  10305. Vector3 pos3 = new Vector3(block.Data, 0);
  10306. Quaternion rot4 = new Quaternion(block.Data, 12, true);
  10307. handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
  10308. if (handlerUpdatePrimGroupRotation != null)
  10309. {
  10310. // m_log.Debug("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10311. // m_log.Debug("new group mouse rotation is " + rot4.X + " , " + rot4.Y + " , " + rot4.Z + " , " + rot4.W);
  10312. handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
  10313. }
  10314. break;
  10315. case 12:
  10316. case 28:
  10317. Vector3 scale7 = new Vector3(block.Data, 0);
  10318. UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10319. if (handlerUpdatePrimGroupScale != null)
  10320. {
  10321. // m_log.Debug("new scale is " + scale7.X + " , " + scale7.Y + " , " + scale7.Z);
  10322. handlerUpdatePrimGroupScale(localId, scale7, this);
  10323. }
  10324. break;
  10325. case 13:
  10326. Vector3 scale2 = new Vector3(block.Data, 12);
  10327. Vector3 pos4 = new Vector3(block.Data, 0);
  10328. handlerUpdatePrimScale = OnUpdatePrimScale;
  10329. if (handlerUpdatePrimScale != null)
  10330. {
  10331. //m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10332. handlerUpdatePrimScale(localId, scale2, this);
  10333. // Change the position based on scale (for bug number 246)
  10334. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10335. // m_log.Debug("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
  10336. if (handlerUpdatePrimSinglePosition != null)
  10337. {
  10338. handlerUpdatePrimSinglePosition(localId, pos4, this);
  10339. }
  10340. }
  10341. break;
  10342. case 29:
  10343. Vector3 scale5 = new Vector3(block.Data, 12);
  10344. Vector3 pos5 = new Vector3(block.Data, 0);
  10345. handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
  10346. if (handlerUpdatePrimGroupScale != null)
  10347. {
  10348. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10349. part.StoreUndoState(true);
  10350. part.IgnoreUndoUpdate = true;
  10351. handlerUpdatePrimGroupScale(localId, scale5, this);
  10352. handlerUpdateVector = OnUpdatePrimGroupPosition;
  10353. if (handlerUpdateVector != null)
  10354. {
  10355. handlerUpdateVector(localId, pos5, this);
  10356. }
  10357. part.IgnoreUndoUpdate = false;
  10358. }
  10359. break;
  10360. case 21:
  10361. Vector3 scale6 = new Vector3(block.Data, 12);
  10362. Vector3 pos6 = new Vector3(block.Data, 0);
  10363. handlerUpdatePrimScale = OnUpdatePrimScale;
  10364. if (handlerUpdatePrimScale != null)
  10365. {
  10366. part.StoreUndoState(false);
  10367. part.IgnoreUndoUpdate = true;
  10368. // m_log.Debug("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
  10369. handlerUpdatePrimScale(localId, scale6, this);
  10370. handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
  10371. if (handlerUpdatePrimSinglePosition != null)
  10372. {
  10373. handlerUpdatePrimSinglePosition(localId, pos6, this);
  10374. }
  10375. part.IgnoreUndoUpdate = false;
  10376. }
  10377. break;
  10378. default:
  10379. m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
  10380. break;
  10381. }
  10382. // for (int j = 0; j < parts.Length; j++)
  10383. // parts[j].IgnoreUndoUpdate = false;
  10384. }
  10385. }
  10386. }
  10387. return true;
  10388. }
  10389. public void RequestMapLayer()
  10390. {
  10391. //should be getting the map layer from the grid server
  10392. //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
  10393. MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
  10394. // TODO: don't create new blocks if recycling an old packet
  10395. mapReply.AgentData.AgentID = AgentId;
  10396. mapReply.AgentData.Flags = 0;
  10397. mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
  10398. mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
  10399. mapReply.LayerData[0].Bottom = 0;
  10400. mapReply.LayerData[0].Left = 0;
  10401. mapReply.LayerData[0].Top = 30000;
  10402. mapReply.LayerData[0].Right = 30000;
  10403. mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
  10404. mapReply.Header.Zerocoded = true;
  10405. OutPacket(mapReply, ThrottleOutPacketType.Land);
  10406. }
  10407. public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
  10408. {
  10409. /*
  10410. IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
  10411. MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
  10412. mbReply.AgentData.AgentId = AgentId;
  10413. int len;
  10414. if (simMapProfiles == null)
  10415. len = 0;
  10416. else
  10417. len = simMapProfiles.Count;
  10418. mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
  10419. int iii;
  10420. for (iii = 0; iii < len; iii++)
  10421. {
  10422. Hashtable mp = (Hashtable)simMapProfiles[iii];
  10423. mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
  10424. mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
  10425. mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
  10426. mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
  10427. mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
  10428. mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
  10429. mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
  10430. mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
  10431. mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
  10432. }
  10433. this.OutPacket(mbReply, ThrottleOutPacketType.Land);
  10434. */
  10435. }
  10436. /// <summary>
  10437. /// Sets the throttles from values supplied by the client
  10438. /// </summary>
  10439. /// <param name="throttles"></param>
  10440. public void SetChildAgentThrottle(byte[] throttles)
  10441. {
  10442. m_udpClient.SetThrottles(throttles);
  10443. }
  10444. /// <summary>
  10445. /// Get the current throttles for this client as a packed byte array
  10446. /// </summary>
  10447. /// <param name="multiplier">Unused</param>
  10448. /// <returns></returns>
  10449. public byte[] GetThrottlesPacked(float multiplier)
  10450. {
  10451. return m_udpClient.GetThrottlesPacked(multiplier);
  10452. }
  10453. /// <summary>
  10454. /// Cruft?
  10455. /// </summary>
  10456. public virtual void InPacket(object NewPack)
  10457. {
  10458. throw new NotImplementedException();
  10459. }
  10460. /// <summary>
  10461. /// This is the starting point for sending a simulator packet out to the client
  10462. /// </summary>
  10463. /// <param name="packet">Packet to send</param>
  10464. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10465. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
  10466. {
  10467. #region BinaryStats
  10468. LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
  10469. #endregion BinaryStats
  10470. OutPacket(packet, throttlePacketType, true);
  10471. }
  10472. /// <summary>
  10473. /// This is the starting point for sending a simulator packet out to the client
  10474. /// </summary>
  10475. /// <param name="packet">Packet to send</param>
  10476. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10477. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10478. /// packets (the default), or false to disable splitting if the calling code
  10479. /// handles splitting manually</param>
  10480. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
  10481. {
  10482. OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
  10483. }
  10484. /// <summary>
  10485. /// This is the starting point for sending a simulator packet out to the client
  10486. /// </summary>
  10487. /// <param name="packet">Packet to send</param>
  10488. /// <param name="throttlePacketType">Throttling category for the packet</param>
  10489. /// <param name="doAutomaticSplitting">True to automatically split oversized
  10490. /// packets (the default), or false to disable splitting if the calling code
  10491. /// handles splitting manually</param>
  10492. /// <param name="method">The method to be called in the event this packet is reliable
  10493. /// and unacknowledged. The server will provide normal resend capability if you do not
  10494. /// provide your own method.</param>
  10495. protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
  10496. {
  10497. if (DebugPacketLevel > 0)
  10498. {
  10499. bool logPacket = true;
  10500. if (DebugPacketLevel <= 255
  10501. && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
  10502. logPacket = false;
  10503. if (DebugPacketLevel <= 200
  10504. && (packet.Type == PacketType.ImagePacket
  10505. || packet.Type == PacketType.ImageData
  10506. || packet.Type == PacketType.LayerData
  10507. || packet.Type == PacketType.CoarseLocationUpdate))
  10508. logPacket = false;
  10509. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
  10510. logPacket = false;
  10511. if (DebugPacketLevel <= 50
  10512. && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
  10513. logPacket = false;
  10514. if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
  10515. logPacket = false;
  10516. if (logPacket)
  10517. m_log.DebugFormat(
  10518. "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
  10519. Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
  10520. }
  10521. m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
  10522. }
  10523. protected void HandleAutopilot(Object sender, string method, List<String> args)
  10524. {
  10525. float locx = 0;
  10526. float locy = 0;
  10527. float locz = 0;
  10528. uint regionX = 0;
  10529. uint regionY = 0;
  10530. Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
  10531. locx = Convert.ToSingle(args[0]) - (float)regionX;
  10532. locy = Convert.ToSingle(args[1]) - (float)regionY;
  10533. locz = Convert.ToSingle(args[2]);
  10534. Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
  10535. if (handlerAutoPilotGo != null)
  10536. handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
  10537. }
  10538. /// <summary>
  10539. /// Entryway from the client to the simulator. All UDP packets from the client will end up here
  10540. /// </summary>
  10541. /// <param name="Pack">OpenMetaverse.packet</param>
  10542. public void ProcessInPacket(Packet packet)
  10543. {
  10544. if (DebugPacketLevel > 0)
  10545. {
  10546. bool logPacket = true;
  10547. if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
  10548. logPacket = false;
  10549. if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
  10550. logPacket = false;
  10551. if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
  10552. logPacket = false;
  10553. if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
  10554. logPacket = false;
  10555. if (logPacket)
  10556. m_log.DebugFormat(
  10557. "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
  10558. Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
  10559. }
  10560. if (!ProcessPacketMethod(packet))
  10561. m_log.WarnFormat(
  10562. "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
  10563. packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
  10564. }
  10565. private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
  10566. {
  10567. PrimitiveBaseShape shape = new PrimitiveBaseShape();
  10568. shape.PCode = addPacket.ObjectData.PCode;
  10569. shape.State = addPacket.ObjectData.State;
  10570. shape.LastAttachPoint = addPacket.ObjectData.State;
  10571. shape.PathBegin = addPacket.ObjectData.PathBegin;
  10572. shape.PathEnd = addPacket.ObjectData.PathEnd;
  10573. shape.PathScaleX = addPacket.ObjectData.PathScaleX;
  10574. shape.PathScaleY = addPacket.ObjectData.PathScaleY;
  10575. shape.PathShearX = addPacket.ObjectData.PathShearX;
  10576. shape.PathShearY = addPacket.ObjectData.PathShearY;
  10577. shape.PathSkew = addPacket.ObjectData.PathSkew;
  10578. shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  10579. shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  10580. shape.Scale = addPacket.ObjectData.Scale;
  10581. shape.PathCurve = addPacket.ObjectData.PathCurve;
  10582. shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  10583. shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  10584. shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  10585. shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  10586. shape.PathTaperX = addPacket.ObjectData.PathTaperX;
  10587. shape.PathTaperY = addPacket.ObjectData.PathTaperY;
  10588. shape.PathTwist = addPacket.ObjectData.PathTwist;
  10589. shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  10590. Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
  10591. shape.TextureEntry = ntex.GetBytes();
  10592. //shape.Textures = ntex;
  10593. return shape;
  10594. }
  10595. public ClientInfo GetClientInfo()
  10596. {
  10597. ClientInfo info = m_udpClient.GetClientInfo();
  10598. info.proxyEP = null;
  10599. if (info.agentcircuit == null)
  10600. info.agentcircuit = RequestClientInfo();
  10601. return info;
  10602. }
  10603. public void SetClientInfo(ClientInfo info)
  10604. {
  10605. m_udpClient.SetClientInfo(info);
  10606. }
  10607. #region Media Parcel Members
  10608. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  10609. {
  10610. ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
  10611. commandMessagePacket.CommandBlock.Flags = flags;
  10612. commandMessagePacket.CommandBlock.Command = (uint)command;
  10613. commandMessagePacket.CommandBlock.Time = time;
  10614. OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
  10615. }
  10616. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
  10617. byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
  10618. byte mediaLoop)
  10619. {
  10620. ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
  10621. updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
  10622. updatePacket.DataBlock.MediaID = mediaTextureID;
  10623. updatePacket.DataBlock.MediaAutoScale = autoScale;
  10624. updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
  10625. updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
  10626. updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
  10627. updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
  10628. updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
  10629. OutPacket(updatePacket, ThrottleOutPacketType.Task);
  10630. }
  10631. #endregion
  10632. #region Camera
  10633. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  10634. {
  10635. SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
  10636. packet.ObjectData.ObjectID = objectID;
  10637. SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
  10638. uint idx = 0;
  10639. foreach (KeyValuePair<int, float> pair in parameters)
  10640. {
  10641. SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
  10642. block.Type = pair.Key;
  10643. block.Value = pair.Value;
  10644. camPropBlock[idx++] = block;
  10645. }
  10646. packet.CameraProperty = camPropBlock;
  10647. OutPacket(packet, ThrottleOutPacketType.Task);
  10648. }
  10649. public void SendClearFollowCamProperties(UUID objectID)
  10650. {
  10651. ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
  10652. packet.ObjectData.ObjectID = objectID;
  10653. OutPacket(packet, ThrottleOutPacketType.Task);
  10654. }
  10655. #endregion
  10656. public void SetClientOption(string option, string value)
  10657. {
  10658. switch (option)
  10659. {
  10660. default:
  10661. break;
  10662. }
  10663. }
  10664. public string GetClientOption(string option)
  10665. {
  10666. switch (option)
  10667. {
  10668. default:
  10669. break;
  10670. }
  10671. return string.Empty;
  10672. }
  10673. #region IClientCore
  10674. private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
  10675. /// <summary>
  10676. /// Register an interface on this client, should only be called in the constructor.
  10677. /// </summary>
  10678. /// <typeparam name="T"></typeparam>
  10679. /// <param name="iface"></param>
  10680. protected void RegisterInterface<T>(T iface)
  10681. {
  10682. lock (m_clientInterfaces)
  10683. {
  10684. if (!m_clientInterfaces.ContainsKey(typeof(T)))
  10685. {
  10686. m_clientInterfaces.Add(typeof(T), iface);
  10687. }
  10688. }
  10689. }
  10690. public bool TryGet<T>(out T iface)
  10691. {
  10692. if (m_clientInterfaces.ContainsKey(typeof(T)))
  10693. {
  10694. iface = (T)m_clientInterfaces[typeof(T)];
  10695. return true;
  10696. }
  10697. iface = default(T);
  10698. return false;
  10699. }
  10700. public T Get<T>()
  10701. {
  10702. return (T)m_clientInterfaces[typeof(T)];
  10703. }
  10704. public void Disconnect(string reason)
  10705. {
  10706. Kick(reason);
  10707. Thread.Sleep(1000);
  10708. Disconnect();
  10709. }
  10710. public void Disconnect()
  10711. {
  10712. Close();
  10713. }
  10714. #endregion
  10715. public void RefreshGroupMembership()
  10716. {
  10717. if (m_GroupsModule != null)
  10718. {
  10719. GroupMembershipData[] GroupMembership =
  10720. m_GroupsModule.GetMembershipData(AgentId);
  10721. m_groupPowers.Clear();
  10722. if (GroupMembership != null)
  10723. {
  10724. for (int i = 0; i < GroupMembership.Length; i++)
  10725. {
  10726. m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
  10727. }
  10728. }
  10729. }
  10730. }
  10731. public string Report()
  10732. {
  10733. return m_udpClient.GetStats();
  10734. }
  10735. public string XReport(string uptime, string version)
  10736. {
  10737. return String.Empty;
  10738. }
  10739. public OSDMap OReport(string uptime, string version)
  10740. {
  10741. return new OSDMap();
  10742. }
  10743. /// <summary>
  10744. /// Make an asset request to the asset service in response to a client request.
  10745. /// </summary>
  10746. /// <param name="transferRequest"></param>
  10747. /// <param name="taskID"></param>
  10748. protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
  10749. {
  10750. UUID requestID = UUID.Zero;
  10751. int sourceType = transferRequest.TransferInfo.SourceType;
  10752. if (sourceType == (int)SourceType.Asset)
  10753. {
  10754. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10755. }
  10756. else if (sourceType == (int)SourceType.SimInventoryItem)
  10757. {
  10758. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10759. }
  10760. else if (sourceType == (int)SourceType.SimEstate)
  10761. {
  10762. requestID = taskID;
  10763. }
  10764. // m_log.DebugFormat(
  10765. // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
  10766. // requestID, taskID, (SourceType)sourceType, Name);
  10767. m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
  10768. }
  10769. /// <summary>
  10770. /// When we get a reply back from the asset service in response to a client request, send back the data.
  10771. /// </summary>
  10772. /// <param name="id"></param>
  10773. /// <param name="sender"></param>
  10774. /// <param name="asset"></param>
  10775. protected void AssetReceived(string id, Object sender, AssetBase asset)
  10776. {
  10777. TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
  10778. UUID requestID = UUID.Zero;
  10779. byte source = (byte)SourceType.Asset;
  10780. AssetRequestToClient req = new AssetRequestToClient();
  10781. if (asset == null)
  10782. {
  10783. req.AssetInf = null;
  10784. req.AssetRequestSource = source;
  10785. req.IsTextureRequest = false;
  10786. req.NumPackets = 0;
  10787. req.Params = transferRequest.TransferInfo.Params;
  10788. req.RequestAssetID = requestID;
  10789. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10790. SendAssetNotFound(req);
  10791. return;
  10792. }
  10793. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
  10794. {
  10795. requestID = new UUID(transferRequest.TransferInfo.Params, 0);
  10796. }
  10797. else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
  10798. {
  10799. requestID = new UUID(transferRequest.TransferInfo.Params, 80);
  10800. source = (byte)SourceType.SimInventoryItem;
  10801. //m_log.Debug("asset request " + requestID);
  10802. }
  10803. // Scripts cannot be retrieved by direct request
  10804. if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
  10805. return;
  10806. // The asset is known to exist and is in our cache, so add it to the AssetRequests list
  10807. req.AssetInf = asset;
  10808. req.AssetRequestSource = source;
  10809. req.IsTextureRequest = false;
  10810. req.NumPackets = CalculateNumPackets(asset.Data);
  10811. req.Params = transferRequest.TransferInfo.Params;
  10812. req.RequestAssetID = requestID;
  10813. req.TransferRequestID = transferRequest.TransferInfo.TransferID;
  10814. SendAsset(req);
  10815. }
  10816. /// <summary>
  10817. /// Calculate the number of packets required to send the asset to the client.
  10818. /// </summary>
  10819. /// <param name="data"></param>
  10820. /// <returns></returns>
  10821. private static int CalculateNumPackets(byte[] data)
  10822. {
  10823. const uint m_maxPacketSize = 600;
  10824. int numPackets = 1;
  10825. if (data == null)
  10826. return 0;
  10827. if (data.LongLength > m_maxPacketSize)
  10828. {
  10829. // over max number of bytes so split up file
  10830. long restData = data.LongLength - m_maxPacketSize;
  10831. int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
  10832. numPackets += restPackets;
  10833. }
  10834. return numPackets;
  10835. }
  10836. public void SendRebakeAvatarTextures(UUID textureID)
  10837. {
  10838. RebakeAvatarTexturesPacket pack =
  10839. (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
  10840. pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
  10841. pack.TextureData.TextureID = textureID;
  10842. OutPacket(pack, ThrottleOutPacketType.Task);
  10843. }
  10844. public struct PacketProcessor
  10845. {
  10846. public PacketMethod method;
  10847. public bool Async;
  10848. }
  10849. public class AsyncPacketProcess
  10850. {
  10851. public bool result = false;
  10852. public readonly LLClientView ClientView = null;
  10853. public readonly Packet Pack = null;
  10854. public readonly PacketMethod Method = null;
  10855. public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
  10856. {
  10857. ClientView = pClientview;
  10858. Method = pMethod;
  10859. Pack = pPack;
  10860. }
  10861. }
  10862. public static OSD BuildEvent(string eventName, OSD eventBody)
  10863. {
  10864. OSDMap osdEvent = new OSDMap(2);
  10865. osdEvent.Add("message", new OSDString(eventName));
  10866. osdEvent.Add("body", eventBody);
  10867. return osdEvent;
  10868. }
  10869. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  10870. {
  10871. AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
  10872. packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
  10873. packet.AgentData.AgentID = AgentId;
  10874. packet.AgentData.AvatarID = avatarID;
  10875. packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
  10876. packet.PropertiesData.WantToMask = wantMask;
  10877. packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
  10878. packet.PropertiesData.SkillsMask = skillsMask;
  10879. packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
  10880. packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
  10881. OutPacket(packet, ThrottleOutPacketType.Task);
  10882. }
  10883. public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
  10884. {
  10885. ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
  10886. packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
  10887. packet.AgentData.AgentID = agentID;
  10888. packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
  10889. packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
  10890. packet.Rights[0].AgentRelated = friendID;
  10891. packet.Rights[0].RelatedRights = rights;
  10892. OutPacket(packet, ThrottleOutPacketType.Task);
  10893. }
  10894. public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
  10895. {
  10896. ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
  10897. dialog.Data.ObjectID = objectId;
  10898. dialog.Data.ChatChannel = chatChannel;
  10899. dialog.Data.ImageID = UUID.Zero;
  10900. dialog.Data.ObjectName = Util.StringToBytes256(objectname);
  10901. // this is the username of the *owner*
  10902. dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
  10903. dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
  10904. dialog.Data.Message = Util.StringToBytes256(message);
  10905. ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
  10906. buttons[0] = new ScriptDialogPacket.ButtonsBlock();
  10907. buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
  10908. dialog.Buttons = buttons;
  10909. dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
  10910. dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
  10911. dialog.OwnerData[0].OwnerID = ownerID;
  10912. OutPacket(dialog, ThrottleOutPacketType.Task);
  10913. }
  10914. public void SendAgentTerseUpdate(ISceneEntity p)
  10915. {
  10916. if (p is ScenePresence)
  10917. {
  10918. // m_log.DebugFormat(
  10919. // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
  10920. // p.Name, Name, Scene.Name);
  10921. // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
  10922. // There's no explicit message to send the client to tell it to stop flying.. it relies on the
  10923. // velocity, collision plane and avatar height
  10924. // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
  10925. // when the avatar stands up
  10926. ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
  10927. CreateImprovedTerseBlock(p, false);
  10928. const float TIME_DILATION = 1.0f;
  10929. ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
  10930. ImprovedTerseObjectUpdatePacket packet
  10931. = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
  10932. PacketType.ImprovedTerseObjectUpdate);
  10933. packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
  10934. packet.RegionData.TimeDilation = timeDilation;
  10935. packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  10936. packet.ObjectData[0] = block;
  10937. OutPacket(packet, ThrottleOutPacketType.Task, true);
  10938. }
  10939. //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
  10940. // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
  10941. }
  10942. public void SendPlacesReply(UUID queryID, UUID transactionID,
  10943. PlacesReplyData[] data)
  10944. {
  10945. PlacesReplyPacket reply = null;
  10946. PlacesReplyPacket.QueryDataBlock[] dataBlocks =
  10947. new PlacesReplyPacket.QueryDataBlock[0];
  10948. for (int i = 0 ; i < data.Length ; i++)
  10949. {
  10950. PlacesReplyPacket.QueryDataBlock block =
  10951. new PlacesReplyPacket.QueryDataBlock();
  10952. block.OwnerID = data[i].OwnerID;
  10953. block.Name = Util.StringToBytes256(data[i].Name);
  10954. block.Desc = Util.StringToBytes1024(data[i].Desc);
  10955. block.ActualArea = data[i].ActualArea;
  10956. block.BillableArea = data[i].BillableArea;
  10957. block.Flags = data[i].Flags;
  10958. block.GlobalX = data[i].GlobalX;
  10959. block.GlobalY = data[i].GlobalY;
  10960. block.GlobalZ = data[i].GlobalZ;
  10961. block.SimName = Util.StringToBytes256(data[i].SimName);
  10962. block.SnapshotID = data[i].SnapshotID;
  10963. block.Dwell = data[i].Dwell;
  10964. block.Price = data[i].Price;
  10965. if (reply != null && reply.Length + block.Length > 1400)
  10966. {
  10967. OutPacket(reply, ThrottleOutPacketType.Task);
  10968. reply = null;
  10969. dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
  10970. }
  10971. if (reply == null)
  10972. {
  10973. reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
  10974. reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
  10975. reply.AgentData.AgentID = AgentId;
  10976. reply.AgentData.QueryID = queryID;
  10977. reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
  10978. reply.TransactionData.TransactionID = transactionID;
  10979. reply.QueryData = dataBlocks;
  10980. }
  10981. Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
  10982. dataBlocks[dataBlocks.Length - 1] = block;
  10983. reply.QueryData = dataBlocks;
  10984. }
  10985. if (reply != null)
  10986. OutPacket(reply, ThrottleOutPacketType.Task);
  10987. }
  10988. public void SendRemoveInventoryItems(UUID[] items)
  10989. {
  10990. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  10991. if (eq == null)
  10992. {
  10993. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  10994. return;
  10995. }
  10996. OSDMap llsd = new OSDMap(3);
  10997. OSDMap AgentDataMap = new OSDMap(1);
  10998. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  10999. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11000. OSDArray AgentData = new OSDArray(1);
  11001. AgentData.Add(AgentDataMap);
  11002. llsd.Add("AgentData", AgentData);
  11003. OSDArray ItemData = new OSDArray();
  11004. foreach (UUID item in items)
  11005. {
  11006. OSDMap ItemDataMap = new OSDMap(2);
  11007. ItemDataMap.Add("ItemID", OSD.FromUUID(item));
  11008. ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11009. ItemData.Add(ItemDataMap);
  11010. }
  11011. llsd.Add("InventoryData", ItemData);
  11012. eq.Enqueue(BuildEvent("RemoveInventoryItem",
  11013. llsd), AgentId);
  11014. }
  11015. public void SendRemoveInventoryFolders(UUID[] folders)
  11016. {
  11017. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11018. if (eq == null)
  11019. {
  11020. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11021. return;
  11022. }
  11023. OSDMap llsd = new OSDMap(3);
  11024. OSDMap AgentDataMap = new OSDMap(1);
  11025. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11026. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11027. OSDArray AgentData = new OSDArray(1);
  11028. AgentData.Add(AgentDataMap);
  11029. llsd.Add("AgentData", AgentData);
  11030. OSDArray FolderData = new OSDArray();
  11031. foreach (UUID folder in folders)
  11032. {
  11033. OSDMap FolderDataMap = new OSDMap(2);
  11034. FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
  11035. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11036. FolderData.Add(FolderDataMap);
  11037. }
  11038. llsd.Add("FolderData", FolderData);
  11039. eq.Enqueue(BuildEvent("RemoveInventoryFolder",
  11040. llsd), AgentId);
  11041. }
  11042. private byte[] EncodeU32(uint val)
  11043. {
  11044. byte[] ret = BitConverter.GetBytes(val);
  11045. if (BitConverter.IsLittleEndian)
  11046. Array.Reverse(ret);
  11047. return ret;
  11048. }
  11049. public void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
  11050. {
  11051. IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
  11052. if (eq == null)
  11053. {
  11054. m_log.DebugFormat("[LLCLIENT]: Null event queue");
  11055. return;
  11056. }
  11057. OSDMap llsd = new OSDMap(3);
  11058. OSDMap AgentDataMap = new OSDMap(1);
  11059. AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11060. AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
  11061. AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
  11062. OSDArray AgentData = new OSDArray(1);
  11063. AgentData.Add(AgentDataMap);
  11064. llsd.Add("AgentData", AgentData);
  11065. OSDArray FolderData = new OSDArray();
  11066. foreach (InventoryFolderBase folder in folders)
  11067. {
  11068. OSDMap FolderDataMap = new OSDMap(5);
  11069. FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
  11070. FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
  11071. FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
  11072. FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
  11073. FolderDataMap.Add("Name", OSD.FromString(folder.Name));
  11074. FolderData.Add(FolderDataMap);
  11075. }
  11076. llsd.Add("FolderData", FolderData);
  11077. OSDArray ItemData = new OSDArray();
  11078. foreach (InventoryItemBase item in items)
  11079. {
  11080. OSDMap ItemDataMap = new OSDMap();
  11081. ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
  11082. ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
  11083. ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
  11084. ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
  11085. ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
  11086. ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
  11087. ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
  11088. ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
  11089. ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
  11090. ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
  11091. ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
  11092. ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
  11093. ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
  11094. ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
  11095. ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
  11096. ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
  11097. ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
  11098. ItemDataMap.Add("Name", OSD.FromString(item.Name));
  11099. ItemDataMap.Add("Description", OSD.FromString(item.Description));
  11100. ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
  11101. ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
  11102. Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
  11103. (sbyte)item.AssetType, item.AssetID,
  11104. item.GroupID, 100,
  11105. item.Owner, item.CreatorIdAsUuid,
  11106. item.ID, item.Folder,
  11107. (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
  11108. (uint)PermissionMask.All)
  11109. )));
  11110. ItemDataMap.Add("CallbackID", 0);
  11111. ItemData.Add(ItemDataMap);
  11112. }
  11113. llsd.Add("ItemData", ItemData);
  11114. eq.Enqueue(BuildEvent("BulkUpdateInventory",
  11115. llsd), AgentId);
  11116. }
  11117. }
  11118. }