1
0

LLClientView.cs 564 KB

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