| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102 |
- /*----------------------------------------------------------------------------*-
- ===============================
- Y Sever Includes - Objects Core
- ===============================
- Description:
- Handles object streaming for >150 objects per player. Also provides VW
- support and improved object attachment (i.e. it works). New versions
- combines mine and Peter's streaming systems to narrow down objects by
- approximation by a grid system then check all objects visible in near
- by sections.
- Legal:
- Copyright (C) 2007 Alex "Y_Less" Cole
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- MA 02110-1301, USA.
- Version:
- 0.2.7
- Changelog:
- 27/12/07:
- Fixed a bug in the moved object list system.
- 26/11/07:
- Finished up master system.
- Fixed DestroyDynamicObject not removing client objects.
- 16/11/07:
- Removed global flag as it wasn't doing anything.
- 27/10/07:
- Fixed moving objects so they actually move
- 26/10/07:
- Added object children to attach objects to each other.
- 09/10/07:
- FINALLY found compile hang bug.
- Repaired removed code.
- Put object co-ordinate code in Object_ParseSet
- 23/09/07:
- Updated FindSector, AddToSector and RemoveFromSector to use new system.
- 22/09/07:
- Started work on new sector system, minor macro changes, lots of maths.
- Wrote squareroot macro.
- Updated constructor.
- 21/09/07:
- Overhauled sector code, skips columns and interiors plus more efficient.
- 20/09/07:
- Made some core functions static so they don't get called by accident.
- Changed auto-adjust code so it rounds to nearest whole log number.
- Moved zone-find code around to skip whole columns at once.
- Added zone sorting so they're done in order of distance.
- Added breakout code so once all objects are found processing is exited.
- 19/09/07:
- Added auto-adjusting zone sizes based on object limits.
- Altered zone find code to return only possible visible zones.
- Fixed rare hanging bug in close list code.
- 18/09/07:
- My birthday - yes I'm that sad to code on it and put it in a changelog.
- Rewrote sectors code to use known sectors instead of position.
- 17/09/07:
- Rewrote find code to find closest objects instead of random close ones.
- 03/08/07:
- Updated timer system.
- 07/05/07:
- Added groups support via default settings.
- Corrected (unused) flag - bit pointless but meh.
- 02/05/07:
- Added YSI_ prefix to all globals.
- Added dynamic object API calls.
- 30/04/07:
- Fixed bug in DestroyDynamicObject with OOB objects not 1st in list.
- Exported sector removal code to Object_RemoveFromSector.
- Added SECTOR parameter to E_OBJECT for ease of modification.
- 25/04/07:
- Added 3d checking.
- Added DestroyDynamicObject API function.
- Fixed location checking on attached objects.
- Fixed loop itteration for cyclic list structure.
- 24/04/07:
- Fixed range leave checking.
- Added moving objects list.
- 18/04/07:
- Second version - completely rewritten after a chat with Peter.
- 16/04/07:
- First version - adapted from my earlier e_objects.inc include.
- Functions:
- Public:
- Object_Loop - Main loop for checking.
- Object_CoOrdRemote - Does object location manipulation remotely.
- Object_Remote - Does normal functions remotely.
- Object_UpdateUnused - Adds an object to the remote unused list.
- Object_Broadcast - Saves an object remotely.
- Object_GetLimit - Gets the number of objects the remove master can hold.
- YSIM_Objects - Processes master system instructions.
- Object_AddRem - Remote wrapper for Object_Add.
- Core:
- Object_Object - Constructor.
- Object_OnPlayerDisconnect - Disconnects objects.
- Stock:
- Object_AddToWorld - Make visible in world.
- Object_RemoveFromWorld - Make invisible in world.
- Object_AddToPlayer - Make visible to player.
- Object_RemoveFromPlayer - Make invisible to player.
- Object_AddToAllWorlds - Make visible in all worlds.
- Object_RemoveFromAllWorlds - Make invisible in all worlds.
- Object_AddToAllPlayers - Make visible to all players.
- Object_RemoveFromAllPlayers - Make invisible to all players.
- Object_IsValidModel - Checks if an object is good to be displayed.
- Object_IsGlobal - Checks if an object is visible by default.
- Object_SetViewDistance - Sets an object's view distance.
- Object_IsDescendant - Checks if an object is related to another object.
- Static:
- Object_Add - Internal add function.
- Object_FindSector - Find a location's sector.
- Object_AddToOOB - Add an object to the OOB list.
- Object_AddToSector - Add an object to the specified list.
- Object_RemoveFromSector - Remove an object from the given sector.
- Object_FindSectors - Get near sectors.
- Object_ParseSet - Check objects in list.
- Object_Update - Updates the position of a moving object.
- Object_UpdateChildSectors - Updates the sectors of moved object children.
- Object_SetPos - Moves an object to the given position.
- Object_UpdateAttach - Updates children after dynamic stop.
- Object_Move - Reursive MoveDynamicObject for children.
- Object_RemoveFromParent - Removes an object from it's parent.
- Object_AddToParent - Adds an object to another object.
- Object_AttachToPlayer - Attaches objects to a player recursively.
- Object_CheckDescendant - Recursive call for Object_IsDescendant.
- Object_Destroy - Delete an object with no checks.
- Object_AddToUpdate - Safely adds an object to the moved update list.
- Inline:
- Object_IsValid - Internal validity check.
- Object_GetAttach - Get player an object's attached to.
- Object_SetAttach - objSet player an object's attached to.
- Object_HasPlayer - Checks if a player can see an object.
- API:
- MoveDynamicObject - Wrapper for MoveObject.
- StopDynamicObject - Wrapper for StopObject.
- IsValidDynamicObject - Wrapper for IsValidObject.
- CreateDynamicObject - Wrapper for CreateObject.
- CreatePlayerDynamicObject - Wrapper for CreatePlayerObject.
- CreateVWDynamicObject - Creates an object in only one world.
- CreatePlayerVWDynamicObject - Creates an object for one player in one world.
- DestroyDynamicObject - Wrapper for DestroyObject.
- GetDynamicObjectPos - Wrapper for GetObjectPos.
- GetDynamicObjectRot - Wrapper for GetObjectRot.
- SetDynamicObjectPos = Wrapper for SetObjectPos.
- SetDynamicObjectRot - Wrapper for SetObjectRot.
- AttachDynamicObjectToPlayer - Wrapper for AttachObjectToPlayer.
- DetachDynamicObjectFromPlayer - Removes an object from a player.
- AttachObjectToObject - Attaches an object to another object.
- RemoveObjectFromParent - Removes an object from another object.
- Callbacks:
- OnDynamicObjectMoved
- Definitions:
- OBJECT_SECTOR_SIZE - Size of edge of a grid square for approximations.
- MAX_DYN_OBJECTS - Maximum number of objects.
- OBJECT_VIEW_DISTANCE - Range to stream objects for.
- NO_OBJECT - No object pointer.
- NO_SECTOR - No sector pointer.
- OBJECT_NO_SECTOR - OOB object marker.
- OBJECT_LOOP_GRANULARITY - Number of itterations per second for the loop.
- NO_ATTACH_PLAYER - Marker for object not attached to anyone.
- OBJECT_WORLDS - Maximum number of worlds objects show up in.
- OBJECT_WORLD_COUNT - Size of bit array of worlds.
- OBJECT_PLAYER_COUNT - Size of bit array of players.
- Enums:
- E_OBJECT - Structure of the dynamic object data.
- e_OBJ_FLAG - Flags for the object.
- Macros:
- OBJECT_SECTOR_EDGE - Number of sectors on one edge of the world.
- OBJECT_SECTOR_ARRAY - Number of grid squares.
- OBJECT_SIGHT - OBJECT_VIEW_DISTANCE squared for speed.
- OBJECT_VIEW_RATIO - Number of sectors per view radius.
- OBJECT_VIEW_EDGES - Max width of view range in sectors.
- OBJECT_VIEW_SECTORS - Max sectors visible at once.
- NO_OBJECT_CHECK - Invalid model.
- OBJECT_BITS - Number of bits to hold all dynamic objects.
- e_OBJ_FLAG_MOVED - Extension of e_OBJ_FLAG, both move flags together.
- NEW_SECTOR - Sector based on origin sector and current offset.
- Tags:
- e_OBJ_FLAG - Flags for objects.
- Variables:
- Global:
- -
- Static:
- YSI_g_sObjectSectors - Array of pointers to sector object lists.
- YSI_g_sObjects - Array of objects.
- YSI_g_sOtherSector - Pointer to OOB object list.
- YSI_g_sMovingObjects - Pointer to moving object list.
- YSI_g_sNoObjects - Pointer to unused object list.
- Commands:
- -
- Compile options:
- NO_PERSONAL_OBJECTS - All players see all objects.
- NO_OBJECT_ATTACH - Objects can't be attached to each other.
- NO_OBJECTS_MOVE - No processing is done for moving objects.
- OBJECT_WORLDS 0 - All objects are visible in all worlds.
- Operators:
- -
- -*----------------------------------------------------------------------------*/
- #if !defined OBJECT_BOUNDS_MINX
- #if defined OBJECT_BOUNDS
- #define OBJECT_BOUNDS_MINX (-OBJECT_BOUNDS)
- #else
- #define OBJECT_BOUNDS_MINX (-5000)
- #endif
- #endif
- #if !defined OBJECT_BOUNDS_MINY
- #if defined OBJECT_BOUNDS
- #define OBJECT_BOUNDS_MINY (-OBJECT_BOUNDS)
- #else
- #define OBJECT_BOUNDS_MINY (-5000)
- #endif
- #endif
- #if !defined OBJECT_BOUNDS_MAXX
- #if defined OBJECT_BOUNDS
- #define OBJECT_BOUNDS_MAXX (OBJECT_BOUNDS)
- #else
- #define OBJECT_BOUNDS_MAXX (5000)
- #endif
- #endif
- #if !defined OBJECT_BOUNDS_MAXY
- #if defined OBJECT_BOUNDS
- #define OBJECT_BOUNDS_MAXY (OBJECT_BOUNDS)
- #else
- #define OBJECT_BOUNDS_MAXY (5000)
- #endif
- #endif
- #define OBJECT_BOUNDS_X_SIZE (OBJECT_BOUNDS_MAXX - OBJECT_BOUNDS_MINX)
- #define OBJECT_BOUNDS_Y_SIZE (OBJECT_BOUNDS_MAXY - OBJECT_BOUNDS_MINY)
- #if !defined MAX_DYN_OBJECTS
- #define MAX_DYN_OBJECTS (10000)
- #endif
- #define AVERAGE_OBJECTS_PER_SECTOR (500)
- #define OBJECT_DISTRIBUTION (((OBJECT_BOUNDS_X_SIZE * OBJECT_BOUNDS_Y_SIZE) / MAX_DYN_OBJECTS) * AVERAGE_OBJECTS_PER_SECTOR)
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 10
- #define OBJECT_SECTOR_SIZE (1)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 100
- #define OBJECT_SECTOR_SIZE (5)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 1000
- #define OBJECT_SECTOR_SIZE (10)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 10000
- #define OBJECT_SECTOR_SIZE (50)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 100000
- #define OBJECT_SECTOR_SIZE (100)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 1000000
- #define OBJECT_SECTOR_SIZE (500)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 10000000
- #define OBJECT_SECTOR_SIZE (1000)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 100000000
- #define OBJECT_SECTOR_SIZE (5000)
- #endif
- #endif
- #if !defined OBJECT_SECTOR_SIZE
- #if OBJECT_DISTRIBUTION <= 1000000000
- #define OBJECT_SECTOR_SIZE (10000)
- #endif
- #endif
- #define OBJECT_SECTOR_X_EDGE (ceildiv(OBJECT_BOUNDS_X_SIZE, OBJECT_SECTOR_SIZE))
- #define OBJECT_SECTOR_Y_EDGE (ceildiv(OBJECT_BOUNDS_Y_SIZE, OBJECT_SECTOR_SIZE))
- #define OBJECT_SECTOR_ARRAY (OBJECT_SECTOR_X_EDGE * OBJECT_SECTOR_Y_EDGE)
- #define OBJECT_REAL_X_SECTOR_SIZE (float(OBJECT_BOUNDS_X_SIZE) / float(OBJECT_SECTOR_X_EDGE))
- #define OBJECT_REAL_Y_SECTOR_SIZE (float(OBJECT_BOUNDS_Y_SIZE) / float(OBJECT_SECTOR_Y_EDGE))
- #if !defined OBJECT_MAX_VIEW_DISTANCE
- #define OBJECT_MAX_VIEW_DISTANCE 500
- #endif
- #if !defined DEFAULT_OBJECT_VIEW
- #if defined OBJECT_VIEW_DISTANCE
- #define DEFAULT_OBJECT_VIEW (OBJECT_VIEW_DISTANCE)
- #else
- #define DEFAULT_OBJECT_VIEW (200)
- #endif
- #endif
- #define OBJECT_SIGHT (DEFAULT_OBJECT_VIEW * DEFAULT_OBJECT_VIEW)
- #define OBJECT_VIEW_RATIO (ceildiv(OBJECT_MAX_VIEW_DISTANCE, OBJECT_SECTOR_SIZE))
- #define OBJECT_VIEW_EDGES ((OBJECT_VIEW_RATIO * 2) + 1)
- #define OBJECT_VIEW_SECTORS (OBJECT_VIEW_EDGES * OBJECT_VIEW_EDGES)
- #define NO_OBJECT -1
- #define NO_OBJECT_CHECK (NO_OBJECT & _:e_OBJ_FLAG_MODEL)
- #define NO_SECTOR -1
- #define OBJECT_NO_SECTOR 0x7FFFFFFF
- #define OBJECT_LOD_SECTOR 0x6FFFFFFF
- #define OBJECT_INT_SECTOR 0x5FFFFFFF
- #define OBJECT_BITS Bit_Bits(MAX_DYN_OBJECTS)
- #if !defined OBJECT_LOOP_GRANULARITY
- #define OBJECT_LOOP_GRANULARITY 2
- #endif
- #define NO_ATTACH_PLAYER 0xFF
- #define NO_GATE (-1)
- #define SECTOR_CHECK_TIME (1000)
- #define SECTOR_CHECK_FREQUENCY ceildiv(SECTOR_CHECK_TIME, (1000 / OBJECT_LOOP_GRANULARITY))
- #define MAY_OBJECTS (150)
- #if !defined OBJECT_WORLDS
- #define OBJECT_WORLDS MAX_WORLDS
- #endif
- #if OBJECT_WORLDS > 32
- #define OBJECT_WORLD_COUNT Bit_Bits(OBJECT_WORLDS)
- #else
- #define OBJECT_WORLD_COUNT 2
- #endif
- #define GATE_AREA_TRIGGER (0x80000000)
- #define GATE_OPENING (0x40000000)
- #define ONE_OVER_ROOT_TWO (0.70710678118654752440084436210485)
- enum e_OBJ_FLAG (<<= 1)
- {
- e_OBJ_FLAG_MODEL = 0x00007FFF,
- e_OBJ_FLAG_ATTACH = 0x007F8000,
- e_OBJ_FLAG_ATTACHED = 0x00800000,
- e_OBJ_FLAG_JUMPED,
- e_OBJ_FLAG_MOVED1,
- e_OBJ_FLAG_MOVED2,
- e_OBJ_FLAG_ROTATED,
- e_OBJ_FLAG_ACTIVE,
- e_OBJ_FLAG_RECREATED,
- e_OBJ_FLAG_GATE
- }
- #define e_OBJ_FLAG_MOVED (e_OBJ_FLAG_MOVED1 | e_OBJ_FLAG_MOVED2)
- enum E_OBJECT
- {
- e_OBJ_FLAG:E_OBJECT_MODEL,
- #if defined _YSI_SETUP_MASTER
- E_OBJECT_SCRIPT,
- #endif
- Float:E_OBJECT_X,
- Float:E_OBJECT_Y,
- Float:E_OBJECT_Z,
- Float:E_OBJECT_RX,
- Float:E_OBJECT_RY,
- Float:E_OBJECT_RZ,
- Float:E_OBJECT_VIEW,
- #if OBJECT_WORLDS > 0
- Bit:E_OBJECT_WORLDS[OBJECT_WORLD_COUNT],
- #endif
- #if !defined NO_PERSONAL_OBJECTS
- Bit:E_OBJECT_PLAYERS[PLAYER_BIT_ARRAY],
- #endif
- #if !defined NO_OBJECTS_MOVE
- Float:E_OBJECT_MX,
- Float:E_OBJECT_MY,
- Float:E_OBJECT_MZ,
- Float:E_OBJECT_MS,
- #endif
- E_OBJECT_UPDATES,
- #if !defined NO_OBJECT_ATTACH
- E_OBJECT_PARENT,
- E_OBJECT_SIBLINGS,
- E_OBJECT_CHILDREN,
- #endif
- E_OBJECT_NEXT,
- E_OBJECT_SECTOR
- }
- enum E_OBJECT_ITTER
- {
- Float:E_OBJECT_ITTER_DISTANCE,
- E_OBJECT_ITTER_NEXT,
- E_OBJECT_ITTER_LAST,
- E_OBJECT_ITTER_OBJ,
- Float:E_OBJECT_ITTER_X,
- Float:E_OBJECT_ITTER_Y,
- Float:E_OBJECT_ITTER_Z
- }
- enum E_OBJ_SECTOR
- {
- E_OBJ_SECTOR_POINTER,
- Float:E_OBJ_SECTOR_MAX_VIEW
- }
- enum E_OSEC_ITTER
- {
- E_OSEC_ITTER_SECTOR,
- E_OSEC_ITTER_NEXT,
- Float:E_OSEC_ITTER_DIFF
- }
- enum
- {
- E_OBJECT_REMOTE_ISG,
- E_OBJECT_REMOTE_VIEW,
- E_OBJECT_REMOTE_DESTROY,
- E_OBJECT_REMOTE_SETPOS,
- E_OBJECT_REMOTE_SETROT,
- E_OBJECT_REMOTE_ADDW,
- E_OBJECT_REMOTE_REMW,
- E_OBJECT_REMOTE_ADDP,
- E_OBJECT_REMOTE_REMP,
- E_OBJECT_REMOTE_ALLWA,
- E_OBJECT_REMOTE_ALLWR,
- E_OBJECT_REMOTE_ALLPA,
- E_OBJECT_REMOTE_ALLPR,
- E_OBJECT_REMOTE_ISVALID,
- E_OBJECT_REMOTE_DETATCH,
- E_OBJECT_REMOTE_ATTACHOO,
- E_OBJECT_REMOTE_REMOO,
- E_OBJECT_REMOTE_STOP,
- E_OBJECT_REMOTE_GETROT,
- E_OBJECT_REMOTE_GETPOS,
- E_OBJECT_REMOTE_MOVETO,
- E_OBJECT_REMOTE_CHECKDESC,
- E_OBJECT_REMOTE_GET_AREA,
- E_OBJECT_REMOTE_GATE_POS,
- E_OBJECT_REMOTE_GATE
- }
- enum E_GATE_INFO
- {
- E_GATE_INFO_OBJECT,
- E_GATE_INFO_TIME,
- E_GATE_INFO_TRIGGER,
- E_GATE_INFO_XY,
- E_GATE_INFO_ZA
- }
- #if !defined MAX_GATE_OBJECTS
- #define MAX_GATE_OBJECTS 32
- #endif
- #if MAX_GATE_OBJECTS > 256
- #if !defined EXTENDED_GATE_CODE
- #define EXTENDED_GATE_CODE
- #endif
- #endif
- #if MAX_GATE_OBJECTS > 65536
- #if !defined NO_GATE_AREA_LOOKUP
- #error Only 65536 gates supported in lookup mode
- #endif
- #endif
- forward Object_Loop();
- #if defined _YSI_SETUP_MASTER
- forward Object_GetLimit();
- forward Object_AddRem(master, model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
- forward Object_Remote(ident, info, instruction);
- forward Object_CoOrdRemote(ident, instruction, Float:f1, Float:f2, Float:f3, Float:f4);
- forward Object_OnPlayerEnterArea(playerid, areaid);
- forward Object_Broadcast(id, e_OBJ_FLAG:model, master, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:view,
- Float:mx, Float:my, Float:mz, Float:ms, parent, siblings, children, Bit:worlds[], wCount, Bit:players[], pCount);
- forward YSIM_Objects(command);
- forward Object_UpdateUnused(obj);
- #if !defined NO_OBJECTS_MOVE
- forward Object_AttachRemote(objectid, playerid, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ);
- #endif
- #endif
- #if defined _YSI_VISUAL_AREAS
- forward Object_GateClose(gate);
- #endif
- static
- Float:YSI_g_sXSectorLocations[OBJECT_SECTOR_X_EDGE + 1],
- Float:YSI_g_sYSectorLocations[OBJECT_SECTOR_Y_EDGE + 1],
- Float:YSI_g_sXSectorSize,
- Float:YSI_g_sYSectorSize,
- YSI_g_sObjectSectors[OBJECT_SECTOR_ARRAY][E_OBJ_SECTOR],
- YSI_g_sObjects[MAX_DYN_OBJECTS][E_OBJECT],
- YSI_g_sOtherSector = NO_OBJECT,
- YSI_g_sMovingObjects = NO_OBJECT,
- YSI_g_sLODObjects = NO_OBJECT,
- YSI_g_sInteriorObjects = NO_OBJECT,
- YSI_g_sPlayerObjects[MAX_PLAYERS][MAY_OBJECTS],
- YSI_g_sSomethingMoved = NO_OBJECT,
- #if defined _YSI_SETUP_MASTER
- YSI_g_sIsMaster,
- #endif
- #if defined _YSI_VISUAL_AREAS
- YSI_g_sGateInfo[MAX_GATE_OBJECTS][E_GATE_INFO],
- #if !defined NO_GATE_AREA_LOOKUP
- YSI_g_sGateAreas[ceildiv(MAX_AREAS, 2)],
- #endif
- #endif
- YSI_g_sNoObjects;
- /*----------------------------------------------------------------------------*-
- Function:
- Object_IsValid
- Params:
- objectid - Object to check
- Return:
- -
- Notes:
- Checks if a passed id is a valid object.
- -*----------------------------------------------------------------------------*/
- #define Object_IsValid(%1) \
- ((%1) >= 0 && (%1) < MAX_DYN_OBJECTS && YSI_g_sObjects[(%1)][E_OBJECT_MODEL] & e_OBJ_FLAG_ACTIVE)
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GetAttach
- Params:
- flags - Flags to check.
- Return:
- Player the object is attached to.
- Notes:
- Actually checks a objSet of passed flags, not a passed object.
- -*----------------------------------------------------------------------------*/
- #define Object_GetAttach(%1) \
- ((_:(%1) >> 15) & NO_ATTACH_PLAYER)
- /*----------------------------------------------------------------------------*-
- Function:
- Object_IsAttached
- Params:
- flags - Flags to check.
- Return:
- If the object is attached to a player.
- Notes:
- Actually checks a objSet of passed flags, not a passed object.
- -*----------------------------------------------------------------------------*/
- #define Object_IsAttached(%1) \
- (Object_GetAttach(%1) != NO_ATTACH_PLAYER)
- /*----------------------------------------------------------------------------*-
- Function:
- Object_SetGateTarget
- Params:
- gate - Gate to objSet target for.
- Float:tx - X point to open to.
- Float:ty - Y point to open to.
- Float:tz - Z point to open to.
- Float:ts - Speed to open at.
- Return:
- -
- Notes:
- Stores a location into the two variables provided for targets. Uses
- complex bit shifting to fit the floats nicely into 2 cells. Assumes a max
- of +/-13107.2 for x, y and z and a max of 102.4 for the speed to compress.
- -*----------------------------------------------------------------------------*/
- #define Object_SetGateTarget(%1,%2,%3,%4,%5) \
- new \
- _o_sgt_y = floatround((%3) * 10); \
- YSI_g_sGateInfo[(%1)][E_GATE_INFO_XY] = ((floatround((%2) * 10) & 0x3FFFF) << 14) | (_o_sgt_y & 0x3FFF); \
- YSI_g_sGateInfo[(%1)][E_GATE_INFO_ZA] = ((_o_sgt_y & 0x3C000) << 14) | ((floatround((%4) * 10) & 0x3FFFF) << 10) | (floatround((%5) * 10) & 0x3FF)
- /*----------------------------------------------------------------------------*-
- Function:
- Object_SetAttach
- Params:
- flags - Flags to check.
- Return:
- -
- Notes:
- Actually checks a objSet of passed flags, not a passed object.
- -*----------------------------------------------------------------------------*/
- #define Object_SetAttach(%1) \
- e_OBJ_FLAG:(((%1) & NO_ATTACH_PLAYER) << 15)
- #if defined _YSI_SETUP_MASTER
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Remote
- Params:
- ident - Object to do code on.
- info - Extra data for function.
- instruction - Function to perform.
- Return:
- -
- Notes:
- Performs operations on objects remotely.
- -*----------------------------------------------------------------------------*/
- public Object_Remote(ident, info, instruction)
- {
- setproperty(0, "YSIReq", 0);
- if (!YSI_g_sIsMaster) return 0;
- switch (instruction & 0x0FFF)
- {
- case E_OBJECT_REMOTE_VIEW:
- {
- Object_SetViewDistance(ident, Float:info);
- }
- case E_OBJECT_REMOTE_DESTROY:
- {
- if (Object_IsValid(ident)) Object_Destroy(ident);
- }
- case E_OBJECT_REMOTE_ADDW:
- {
- if (Object_IsValid(ident)) Bit_Set(YSI_g_sObjects[ident][E_OBJECT_WORLDS], info, 1, OBJECT_WORLD_COUNT);
- }
- case E_OBJECT_REMOTE_REMW:
- {
- if (Object_IsValid(ident)) Bit_Set(YSI_g_sObjects[ident][E_OBJECT_WORLDS], info, 0, OBJECT_WORLD_COUNT);
- }
- case E_OBJECT_REMOTE_ADDP:
- {
- if (Object_IsValid(ident)) Bit_Set(YSI_g_sObjects[ident][E_OBJECT_PLAYERS], info, 1, PLAYER_BIT_ARRAY);
- }
- case E_OBJECT_REMOTE_REMP:
- {
- if (Object_IsValid(ident)) Bit_Set(YSI_g_sObjects[ident][E_OBJECT_PLAYERS], info, 0, PLAYER_BIT_ARRAY);
- }
- case E_OBJECT_REMOTE_ALLWA:
- {
- if (Object_IsValid(ident)) Bit_SetAll(YSI_g_sObjects[ident][E_OBJECT_WORLDS], 1, OBJECT_WORLD_COUNT);
- }
- case E_OBJECT_REMOTE_ALLWR:
- {
- if (Object_IsValid(ident)) Bit_SetAll(YSI_g_sObjects[ident][E_OBJECT_WORLDS], 0, OBJECT_WORLD_COUNT);
- }
- case E_OBJECT_REMOTE_ALLPA:
- {
- if (Object_IsValid(ident))
- {
- Bit_SetAll(YSI_g_sObjects[ident][E_OBJECT_PLAYERS], 1, PLAYER_BIT_ARRAY);
- }
- }
- case E_OBJECT_REMOTE_ALLPR:
- {
- if (Object_IsValid(ident))
- {
- Bit_SetAll(YSI_g_sObjects[ident][E_OBJECT_PLAYERS], 0, PLAYER_BIT_ARRAY);
- }
- }
- case E_OBJECT_REMOTE_ISVALID:
- {
- if (Object_IsValid(ident)) setproperty(0, "YSIReq", 1);
- }
- case E_OBJECT_REMOTE_DETATCH:
- {
- DetachDynamicObjectFromPlayer(ident);
- }
- case E_OBJECT_REMOTE_ATTACHOO:
- {
- AttachObjectToObject(ident, info);
- }
- case E_OBJECT_REMOTE_REMOO:
- {
- RemoveObjectFromParent(ident);
- }
- case E_OBJECT_REMOTE_STOP:
- {
- StopDynamicObject(ident);
- }
- case E_OBJECT_REMOTE_GETROT:
- {
- if (!Object_IsValid(ident) || Object_IsAttached(YSI_g_sObjects[ident][E_OBJECT_MODEL]))
- {
- setproperty(0, "YSIReq", 0);
- setproperty(0, "YSIReq2", 0);
- setproperty(0, "YSIReq3", 0);
- }
- else
- {
- setproperty(0, "YSIReq", _:YSI_g_sObjects[ident][E_OBJECT_RX]);
- setproperty(0, "YSIReq2", _:YSI_g_sObjects[ident][E_OBJECT_RY]);
- setproperty(0, "YSIReq3", _:YSI_g_sObjects[ident][E_OBJECT_RZ]);
- }
- }
- case E_OBJECT_REMOTE_GETPOS:
- {
- if (!Object_IsValid(ident))
- {
- setproperty(0, "YSIReq", 0);
- setproperty(0, "YSIReq2", 0);
- setproperty(0, "YSIReq3", 0);
- }
- else
- {
- new
- Float:x,
- Float:y,
- Float:z;
- Object_GetPos(ident, x, y, z);
- setproperty(0, "YSIReq", _:x);
- setproperty(0, "YSIReq2", _:y);
- setproperty(0, "YSIReq3", _:z);
- }
- }
- case E_OBJECT_REMOTE_CHECKDESC:
- {
- if (Object_CheckDescendant(ident, info)) setproperty(0, "YSIReq", 1);
- }
- case E_OBJECT_REMOTE_GET_AREA:
- {
- if (ident >= 0 && ident < MAX_GATE_OBJECTS)
- {
- setproperty(0, "YSIReq", YSI_g_sGateInfo[ident][E_GATE_INFO_TRIGGER]);
- }
- }
- case E_OBJECT_REMOTE_GATE:
- {
- setproperty(0, "YSIReq", NO_GATE);
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_VISUAL_AREAS
- if (Object_IsValid(ident) && !Object_IsAttached(YSI_g_sObjects[ident][E_OBJECT_MODEL]) && Area_IsValid(info))
- {
- new
- gate;
- while (gate < MAX_GATE_OBJECTS)
- {
- if (!YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT]) break;
- gate++;
- }
- if (gate == MAX_GATE_OBJECTS) return NO_GATE;
-
- DBGP4("Object_Remote() Gates: %d %d %d %d", gate, ident, instruction >>> 12, info);
- YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] = ident | GATE_AREA_TRIGGER;
- YSI_g_sGateInfo[gate][E_GATE_INFO_TIME] = instruction >>> 12;
- YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER] = info;
- YSI_g_sObjects[ident][E_OBJECT_MODEL] |= e_OBJ_FLAG_GATE;
- DBGP4("Object_Remote() Gate ID: %d", gate);
- #if !defined NO_GATE_AREA_LOOKUP
- new
- slot = info / 2,
- shift = (info % 2) * 16;
- YSI_g_sGateAreas[slot] = (YSI_g_sGateAreas[slot] & (0xFFFF0000 >>> shift)) | (gate << shift);
- DBGP4("Object_Remote() Lookup: %d %d %d", slot, shift, YSI_g_sGateAreas[slot]);
- #endif
- setproperty(0, "YSIReq", gate);
- DBGP4("Object_Remote() Return");
- return 1;
- }
- #endif
- #endif
- }
- }
- return 1;
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- YSIM_Objects
- Params:
- command - Instruction from the master system.
- Return:
- -
- Notes:
- Performs instructions on script start/end.
- -*----------------------------------------------------------------------------*/
- public YSIM_Objects(command)
- {
- #if OBJECT_WORLDS <= 0 || defined NO_PERSONAL_OBJECTS
- static
- sFake[2] = {-1, -1};
- #endif
- switch (command & 0xFF000000)
- {
- case E_MASTER_SET_MASTER:
- {
- YSI_g_sIsMaster = 1;
- }
- case E_MASTER_RELINQUISH:
- {
- new
- master = (command & 0x00FFFFFF);
- if (master == YSI_gMasterID)
- {
- CallRemoteFunction("Object_GetLimit", "");
- new
- parent = NO_OBJECT,
- siblings = NO_OBJECT,
- children = NO_OBJECT,
- Float:mx,
- Float:my,
- Float:mz,
- Float:ms,
- maxObjs = getproperty(0, "YSIReq"),
- i;
- for ( ; i < MAX_DYN_OBJECTS && i < maxObjs; i++)
- {
- if (YSI_g_sObjects[i][E_OBJECT_MODEL] & e_OBJ_FLAG_ACTIVE)
- {
- if (YSI_g_sObjects[i][E_OBJECT_SCRIPT] == master)
- {
- Object_Destroy(i, 0);
- }
- else
- {
- #if !defined NO_OBJECT_ATTACH
- parent = YSI_g_sObjects[i][E_OBJECT_PARENT];
- while (parent != NO_OBJECT && (YSI_g_sObjects[parent][E_OBJECT_SCRIPT] == master || parent > maxObjs))
- {
- Object_Destroy(parent, 0);
- parent = YSI_g_sObjects[i][E_OBJECT_PARENT];
- }
- siblings = YSI_g_sObjects[i][E_OBJECT_SIBLINGS];
- while (siblings != NO_OBJECT && (YSI_g_sObjects[siblings][E_OBJECT_SCRIPT] == master || siblings > maxObjs))
- {
- Object_Destroy(siblings, 0);
- siblings = YSI_g_sObjects[i][E_OBJECT_SIBLINGS];
- }
- children = YSI_g_sObjects[i][E_OBJECT_CHILDREN];
- while (children != NO_OBJECT && (YSI_g_sObjects[children][E_OBJECT_SCRIPT] == master || children > maxObjs))
- {
- Object_Destroy(children, 0);
- children = YSI_g_sObjects[i][E_OBJECT_CHILDREN];
- }
- #endif
- #if !defined NO_OBJECTS_MOVE
- mx = YSI_g_sObjects[i][E_OBJECT_MX];
- my = YSI_g_sObjects[i][E_OBJECT_MY];
- mz = YSI_g_sObjects[i][E_OBJECT_MZ];
- ms = YSI_g_sObjects[i][E_OBJECT_MS];
- #endif
- #if OBJECT_WORLDS > 0
- #if !defined NO_PERSONAL_OBJECTS
- CallRemoteFunction("Object_Broadcast", "iiifffffffffffiiiaiai", i,
- _:YSI_g_sObjects[i][E_OBJECT_MODEL],
- YSI_g_sObjects[i][E_OBJECT_SCRIPT],
- YSI_g_sObjects[i][E_OBJECT_X],
- YSI_g_sObjects[i][E_OBJECT_Y],
- YSI_g_sObjects[i][E_OBJECT_Z],
- YSI_g_sObjects[i][E_OBJECT_RX],
- YSI_g_sObjects[i][E_OBJECT_RY],
- YSI_g_sObjects[i][E_OBJECT_RZ],
- YSI_g_sObjects[i][E_OBJECT_VIEW],
- mx, my, mz, ms,
- parent, siblings, children,
- _:YSI_g_sObjects[i][E_OBJECT_WORLDS], OBJECT_WORLD_COUNT,
- _:YSI_g_sObjects[i][E_OBJECT_PLAYERS], PLAYER_BIT_ARRAY
- );
- #else
- CallRemoteFunction("Object_Broadcast", "iiifffffffffffiiiaiai", i,
- _:YSI_g_sObjects[i][E_OBJECT_MODEL],
- YSI_g_sObjects[i][E_OBJECT_SCRIPT],
- YSI_g_sObjects[i][E_OBJECT_X],
- YSI_g_sObjects[i][E_OBJECT_Y],
- YSI_g_sObjects[i][E_OBJECT_Z],
- YSI_g_sObjects[i][E_OBJECT_RX],
- YSI_g_sObjects[i][E_OBJECT_RY],
- YSI_g_sObjects[i][E_OBJECT_RZ],
- YSI_g_sObjects[i][E_OBJECT_VIEW],
- mx, my, mz, ms,
- parent, siblings, children,
- _:YSI_g_sObjects[i][E_OBJECT_WORLDS], OBJECT_WORLD_COUNT,
- sFake, 2
- );
- #endif
- #else
- #if !defined NO_PERSONAL_OBJECTS
- CallRemoteFunction("Object_Broadcast", "iiifffffffffffiiiaiai", i,
- _:YSI_g_sObjects[i][E_OBJECT_MODEL],
- YSI_g_sObjects[i][E_OBJECT_SCRIPT],
- YSI_g_sObjects[i][E_OBJECT_X],
- YSI_g_sObjects[i][E_OBJECT_Y],
- YSI_g_sObjects[i][E_OBJECT_Z],
- YSI_g_sObjects[i][E_OBJECT_RX],
- YSI_g_sObjects[i][E_OBJECT_RY],
- YSI_g_sObjects[i][E_OBJECT_RZ],
- YSI_g_sObjects[i][E_OBJECT_VIEW],
- mx, my, mz, ms,
- parent, siblings, children,
- sFake, 2,
- _:YSI_g_sObjects[i][E_OBJECT_PLAYERS], PLAYER_BIT_ARRAY
- );
- #else
- CallRemoteFunction("Object_Broadcast", "iiifffffffffffiiiaiai", i,
- _:YSI_g_sObjects[i][E_OBJECT_MODEL],
- YSI_g_sObjects[i][E_OBJECT_SCRIPT],
- YSI_g_sObjects[i][E_OBJECT_X],
- YSI_g_sObjects[i][E_OBJECT_Y],
- YSI_g_sObjects[i][E_OBJECT_Z],
- YSI_g_sObjects[i][E_OBJECT_RX],
- YSI_g_sObjects[i][E_OBJECT_RY],
- YSI_g_sObjects[i][E_OBJECT_RZ],
- YSI_g_sObjects[i][E_OBJECT_VIEW],
- mx, my, mz, ms,
- parent, siblings, children,
- sFake, 2,
- sFake, 2
- );
- #endif
- #endif
- continue;
- }
- }
- CallRemoteFunction("Object_UpdateUnused", "i", i);
- }
- while (i < maxObjs)
- {
- CallRemoteFunction("Object_UpdateUnused", "i", i);
- i++;
- }
- foreach (Player, playerid)
- {
- for (new obj = 1; obj <= MAY_OBJECTS; obj++)
- {
- if (IsValidPlayerObject(playerid, obj))
- {
- DestroyPlayerObject(playerid, obj);
- break;
- }
- }
- }
- }
- else
- {
- for (new i = 0; i < MAX_DYN_OBJECTS; i++)
- {
- if (YSI_g_sObjects[i][E_OBJECT_MODEL] & e_OBJ_FLAG_ACTIVE && YSI_g_sObjects[i][E_OBJECT_SCRIPT] == master)
- {
- Object_Destroy(i);
- }
- }
- }
- }
- case E_MASTER_NOT_MASTER:
- {
- YSI_g_sIsMaster = 0;
- }
- }
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GetLimit
- Params:
- -
- Return:
- -
- Notes:
- Sets up the new master for streaming and gets the number of objects it
- can handle.
- -*----------------------------------------------------------------------------*/
- public Object_GetLimit()
- {
- if (!YSI_g_sIsMaster) return;
- setproperty(0, "YSIReq", MAX_DYN_OBJECTS);
- YSI_g_sNoObjects = NO_OBJECT;
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Broadcast
- Params:
- id - Slot of the object.
- e_OBJ_FLAG:model - Object model data and flags.
- master - Script which owns the object.
- Float:x - X position.
- Float:y - Y position.
- Float:z - Z position.
- Float:rx - X rotation.
- Float:ry - Y rotation.
- Float:rz - Z rotation.
- Float:view - Object view distance.
- Float:mx - Movement x target.
- Float:my - Movement y target.
- Float:mz - Movement z target.
- Float:ms - Movement speed.
- parent - Object attachment parent.
- siblings - Object attachment sibling list.
- children - Object attachment children list.
- Bit:worlds[] - Worlds the object is in.
- wCount - Size of the world array.
- Bit:players[] - Players who can see the object.
- pCount - Size of the players array.
- Return:
- -
- Notes:
- Recieves data sent from the old master to the new master and stores it in
- the object data array.
- -*----------------------------------------------------------------------------*/
- public Object_Broadcast(id, e_OBJ_FLAG:model, master, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:view,
- Float:mx, Float:my, Float:mz, Float:ms, parent, siblings, children, Bit:worlds[], wCount, Bit:players[], pCount)
- {
- if (!YSI_g_sIsMaster) return 0;
- #if !defined NO_OBJECT_ATTACH
- YSI_g_sObjects[id][E_OBJECT_PARENT] = parent;
- YSI_g_sObjects[id][E_OBJECT_SIBLINGS] = siblings;
- YSI_g_sObjects[id][E_OBJECT_CHILDREN] = children;
- #else
- #pragma unused parent, siblings, children
- #endif
- #if !defined NO_OBJECTS_MOVE
- YSI_g_sObjects[id][E_OBJECT_MX] = mx;
- YSI_g_sObjects[id][E_OBJECT_MY] = my;
- YSI_g_sObjects[id][E_OBJECT_MZ] = mz;
- YSI_g_sObjects[id][E_OBJECT_MS] = ms;
- #else
- #pragma unused mx, my, mz, ms
- #endif
- YSI_g_sObjects[id][E_OBJECT_MODEL] = model | e_OBJ_FLAG_RECREATED;
- YSI_g_sObjects[id][E_OBJECT_SCRIPT] = master;
- YSI_g_sObjects[id][E_OBJECT_X] = x;
- YSI_g_sObjects[id][E_OBJECT_Y] = y;
- YSI_g_sObjects[id][E_OBJECT_Z] = z;
- YSI_g_sObjects[id][E_OBJECT_RX] = rx;
- YSI_g_sObjects[id][E_OBJECT_RY] = ry;
- YSI_g_sObjects[id][E_OBJECT_RZ] = rz;
- YSI_g_sObjects[id][E_OBJECT_VIEW] = view;
- #if OBJECT_WORLDS > 0
- for (new i = 0; i < wCount && i < Bit_Bits(OBJECT_WORLDS); i++)
- {
- YSI_g_sObjects[id][E_OBJECT_WORLDS][i] = worlds[i];
- }
- #else
- #pragma unused worlds, wCount
- #endif
- #if !defined NO_PERSONAL_OBJECTS
- for (new i = 0; i < pCount && i < PLAYER_BIT_ARRAY; i++)
- {
- YSI_g_sObjects[id][E_OBJECT_PLAYERS][i] = players[i];
- }
- #else
- #pragma unused players, pCount
- #endif
- Object_AddToUpdate(id);
- Object_AddToSector(Object_FindSector(x, y, z), id, view);
- return 1;
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- Object_UpdateUnused
- Params:
- obj - Object to add to the remote unused list.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
-
- public Object_UpdateUnused(obj)
- {
- YSI_g_sObjects[obj][E_OBJECT_NEXT] = YSI_g_sNoObjects;
- YSI_g_sNoObjects = obj;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_CoOrdRemote
- Params:
- ident - Object to do code on.
- instruction - Function to perform.
- Float:f1 - First float data.
- Float:f2 - Second float data.
- Float:f3 - Third float data.
- Float:f4 - Fourth float data.
- Return:
- -
- Notes:
- Performs operations with locations on objects remotely.
- -*----------------------------------------------------------------------------*/
- public Object_CoOrdRemote(ident, instruction, Float:f1, Float:f2, Float:f3, Float:f4)
- {
- setproperty(0, "YSIReq", 0);
- if (!YSI_g_sIsMaster) return 0;
- switch (instruction)
- {
- case E_OBJECT_REMOTE_SETROT:
- {
- if (!Object_IsValid(ident) || Object_IsAttached(YSI_g_sObjects[ident][E_OBJECT_MODEL])) return 0;
- YSI_g_sObjects[ident][E_OBJECT_RX] = f1;
- YSI_g_sObjects[ident][E_OBJECT_RY] = f2;
- YSI_g_sObjects[ident][E_OBJECT_RZ] = f3;
- YSI_g_sObjects[ident][E_OBJECT_MODEL] |= e_OBJ_FLAG_ROTATED;
- Object_AddToUpdate(ident);
- setproperty(0, "YSIReq", 1);
- return 1;
- }
- case E_OBJECT_REMOTE_SETPOS:
- {
- if (!Object_IsValid(ident) || Object_IsAttached(YSI_g_sObjects[ident][E_OBJECT_MODEL])) return 0;
- #if !defined NO_OBJECT_ATTACH
- Object_UpdateChildSectors(YSI_g_sObjects[ident][E_OBJECT_CHILDREN], f1, f2, f3);
- #endif
- setproperty(0, "YSIReq", Object_SetPos(ident, f1, f2, f3));
- }
- case E_OBJECT_REMOTE_MOVETO:
- {
- if (Object_IsValid(ident))
- {
- Object_Move(ident, f1, f2, f3, f4);
- Object_AddToUpdate(ident);
- setproperty(0, "YSIReq", 1);
- return 1;
- }
- }
- case E_OBJECT_REMOTE_GATE_POS:
- {
- Object_SetGateTarget(ident, f1, f2, f3, f4);
- }
- }
- return 0;
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- Object_SetViewDistance
- Params:
- objectid - Object to objSet custom view distance for.
- Float:view - Distance the object can be seen from.
- Return:
- -
- Notes:
- Sets how far away an object can be seen from.
- -*----------------------------------------------------------------------------*/
- stock Object_SetViewDistance(objectid, Float:view)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid))
- {
- view *= view;
- YSI_g_sObjects[objectid][E_OBJECT_VIEW] = view;
- new
- sector = YSI_g_sObjects[objectid][E_OBJECT_SECTOR];
- if (view > OBJECT_MAX_VIEW_DISTANCE)
- {
- if (sector != OBJECT_LOD_SECTOR)
- {
- Object_RemoveFromSector(sector, objectid);
- Object_AddToLOD(objectid);
- }
- }
- else if (sector == OBJECT_LOD_SECTOR)
- {
- Object_RemoveFromSector(sector, objectid);
- Object_AddToSector(Object_FindSector(YSI_g_sObjects[objectid][E_OBJECT_X], YSI_g_sObjects[objectid][E_OBJECT_Y], YSI_g_sObjects[objectid][E_OBJECT_Z]), objectid, view);
- }
- else if (sector < sizeof (YSI_g_sObjectSectors))
- {
- if (YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW] < view) YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW] = view;
- }
- return 1;
- }
- return 0;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- return CallRemoteFunction("Object_Remote", "iii", objectid, _:view, E_OBJECT_REMOTE_VIEW);
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToUpdate
- Params:
- objectid - Object to add to the update list.
- Return:
- -
- Notes:
- Safely adds an object to the moved update list.
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToUpdate(objectid)
- {
- if (YSI_g_sObjects[objectid][E_OBJECT_UPDATES] == NO_OBJECT)
- {
- YSI_g_sObjects[objectid][E_OBJECT_UPDATES] = YSI_g_sSomethingMoved;
- YSI_g_sSomethingMoved = objectid;
- }
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Object
- Params:
- -
- Return:
- -
- Notes:
- Sets up variables for initial use.
- -*----------------------------------------------------------------------------*/
- Object_Object()
- {
- static
- timer;
- if (!timer)
- {
- #if defined _YSI_SETUP_MASTER
- YSI_g_sIsMaster = Master_Add("YSIM_Objects");
- #endif
- YSI_g_sNoObjects = 0;
- new
- i;
- while (i < MAX_DYN_OBJECTS)
- {
- YSI_g_sObjects[i][E_OBJECT_UPDATES] = NO_OBJECT;
- YSI_g_sObjects[i++][E_OBJECT_NEXT] = i;
- }
- YSI_g_sObjects[MAX_DYN_OBJECTS - 1][E_OBJECT_NEXT] = NO_OBJECT;
-
- for (i = 0; i < OBJECT_SECTOR_ARRAY; i++)
- {
- YSI_g_sObjectSectors[i][E_OBJ_SECTOR_POINTER] = NO_OBJECT;
- YSI_g_sObjectSectors[i][E_OBJ_SECTOR_MAX_VIEW] = OBJECT_SIGHT;
- }
-
- YSI_g_sXSectorLocations[0] = OBJECT_BOUNDS_MINX;
- for (i = 1; i < OBJECT_SECTOR_X_EDGE; i++)
- {
- YSI_g_sXSectorLocations[i] = (float(OBJECT_BOUNDS_X_SIZE * i) / OBJECT_SECTOR_X_EDGE) + OBJECT_BOUNDS_MINX;
- }
- YSI_g_sXSectorLocations[OBJECT_SECTOR_X_EDGE] = OBJECT_BOUNDS_MAXX;
- YSI_g_sXSectorSize = (YSI_g_sXSectorLocations[1] - YSI_g_sXSectorLocations[0]);
-
- YSI_g_sYSectorLocations[0] = OBJECT_BOUNDS_MINY;
- for (i = 1; i < OBJECT_SECTOR_Y_EDGE; i++)
- {
- YSI_g_sYSectorLocations[i] = (float(OBJECT_BOUNDS_Y_SIZE * i) / OBJECT_SECTOR_Y_EDGE) + OBJECT_BOUNDS_MINY;
- }
- YSI_g_sYSectorLocations[OBJECT_SECTOR_Y_EDGE] = OBJECT_BOUNDS_MAXY;
- YSI_g_sYSectorSize = (YSI_g_sYSectorLocations[1] - YSI_g_sYSectorLocations[0]);
- #if defined _YSI_VISUAL_AREAS
- #if defined NO_GATE_AREA_LOOKUP
- for (i = 0; i < MAX_GATE_OBJECTS; i++)
- {
- YSI_g_sGateInfo[i][E_GATE_INFO_TRIGGER] = NO_GATE;
- }
- #else
- for (i = 0; i < sizeof (YSI_g_sGateAreas); i++)
- {
- YSI_g_sGateAreas[i] = NO_GATE;
- }
- #endif
- #endif
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- for (new j = 0; j < MAY_OBJECTS; j++)
- {
- YSI_g_sPlayerObjects[i][j] = NO_OBJECT;
- }
- }
- timer = Timer_Add("Object_Loop", OBJECT_LOOP_GRANULARITY);
- }
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- CreateDynamicObject
- Params:
- model - Model of object.
- Float:X - x position.
- Float:Y - y position.
- Float:Z - z position.
- Float:RX - x rotation.
- Float:RY - y rotation.
- Float:RZ - z rotation.
- Return:
- -
- Notes:
- Dynamic wrapper for CreateObject.
- -*----------------------------------------------------------------------------*/
- stock CreateDynamicObject(model, Float:X, Float:Y, Float:Z, Float:RX = 0.0, Float:RY = 0.0, Float:RZ = 0.0)
- {
- new
- object = Object_Add(model, X, Y, Z, RX, RY, RZ);
- if (object != NO_OBJECT)
- {
- Object_AddToAllWorlds(object);
- Object_AddToAllPlayers(object);
- }
- return object;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- CreatePlayerDynamicObject
- Params:
- playerid - Player to create it for.
- model - Model of object.
- Float:X - x position.
- Float:Y - y position.
- Float:Z - z position.
- Float:RX - x rotation.
- Float:RY - y rotation.
- Float:RZ - z rotation.
- Return:
- -
- Notes:
- Dynamic wrapper for CreatePlayerObject.
- -*----------------------------------------------------------------------------*/
- stock CreatePlayerDynamicObject(playerid, model, Float:X, Float:Y, Float:Z, Float:RX = 0.0, Float:RY = 0.0, Float:RZ = 0.0)
- {
- new
- object;
- #if !defined NO_PLAYER_ONLY
- object = Object_Add(model, X, Y, Z, RX, RY, RZ);
- if (object != NO_OBJECT)
- {
- Object_RemoveFromAllPlayers(object);
- Object_AddToPlayer(object, playerid);
- Object_AddToAllWorlds(object);
- }
- #else
- #pragma unused playerid
- object = CreateDynamicObject(model, X, Y, Z, RX, RY, RZ);
- #endif
- return object;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- CreateVWDynamicObject
- Params:
- virtualworld - World to create it in.
- model - Model of object.
- Float:X - x position.
- Float:Y - y position.
- Float:Z - z position.
- Float:RX - x rotation.
- Float:RY - y rotation.
- Float:RZ - z rotation.
- Return:
- -
- Notes:
- Dynamic wrapper for CreateObject with VW support.
- -*----------------------------------------------------------------------------*/
- stock CreateVWDynamicObject(virtualworld, model, Float:X, Float:Y, Float:Z, Float:RX = 0.0, Float:RY = 0.0, Float:RZ = 0.0)
- {
- new
- object;
- #if OBJECT_WORLDS > 0
- object = Object_Add(model, X, Y, Z, RX, RY, RZ);
- if (object != NO_OBJECT)
- {
- Object_RemoveFromAllWorlds(object);
- Object_AddToWorld(object, virtualworld);
- Object_AddToAllPlayers(object);
- }
- #else
- #pragma unused virtualworld
- object = CreateDynamicObject(model, X, Y, Z, RX, RY, RZ);
- #endif
- return object;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- CreatePlayerVWDynamicObject
- Params:
- playerid 0 Player to create it for.
- virtualworld - World to create it in.
- model - Model of object.
- Float:X - x position.
- Float:Y - y position.
- Float:Z - z position.
- Float:RX - x rotation.
- Float:RY - y rotation.
- Float:RZ - z rotation.
- Return:
- -
- Notes:
- Dynamic wrapper for CreatePlayerObject with VW support.
- -*----------------------------------------------------------------------------*/
- stock CreatePlayerVWDynamicObject(playerid, virtualworld, model, Float:X, Float:Y, Float:Z, Float:RX = 0.0, Float:RY = 0.0, Float:RZ = 0.0)
- {
- new
- object;
- #if !defined NO_PLAYER_ONLY
- #if OBJECT_WORLDS > 0
- object = Object_Add(model, X, Y, Z, RX, RY, RZ);
- if (object != NO_OBJECT)
- {
- Object_AddToWorld(object, virtualworld);
- Object_AddToPlayer(object, playerid);
- }
- #else
- object = CreatePlayerDynamicObject(playerid, model, X, Y, Z, RX, RY, RZ);
- #pragma unused virtualworld
- #endif
- #else
- #if OBJECT_WORLDS > 0
- object = CreateVWDynamicObject(virtualworld, model, X, Y, Z, RX, RY, RZ);
- #pragma unused playerid
- #else
- object = CreateDynamicObject(model, X, Y, Z, RX, RY, RZ);
- #pragma unused playerid, virtualworld
- #endif
- #endif
- return object;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Add
- Params:
- model - The object model.
- Float:x - X position.
- Float:y - Y position.
- Float:z - Z position.
- Float:rx - X rotation.
- Float:ry - Y rotation.
- Float:rz - Z rotation.
- Return:
- -
- Notes:
- Internal object addition function. Checks if there are any slots open
- and adds the object to the list if there are. Sets up initial flags and
- stores the position.
- -*----------------------------------------------------------------------------*/
- static stock Object_Add(model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
- {
- #if defined _YSI_SETUP_MASTER
- if (!Object_IsValidModel(model)) return NO_OBJECT;
- if (!YSI_g_sIsMaster)
- {
- CallRemoteFunction("Object_AddRem", "iiffffff", YSI_gMasterID, model, x, y, z, rx, ry, rz);
- return getproperty(0, "YSIReq");
- }
- else
- {
- return Object_AddRem(YSI_gMasterID, model, x, y, z, rx, ry, rz);
- }
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddRem
- Params:
- master - The script which owns the object being made.
- model - The object model.
- Float:x - X position.
- Float:y - Y position.
- Float:z - Z position.
- Float:rx - X rotation.
- Float:ry - Y rotation.
- Float:rz - Z rotation.
- Return:
- -
- Notes:
- Remote wrapper for Object_Add.
- -*----------------------------------------------------------------------------*/
- public Object_AddRem(master, model, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
- {
- DBGP3("Object_AddRem() start %d", YSI_gMasterID);
- if (!YSI_g_sIsMaster) return NO_OBJECT;
- DBGP3("Object_AddRem() Master");
- setproperty(0, "YSIReq", NO_OBJECT);
- #endif
- model &= _:e_OBJ_FLAG_MODEL;
- if (YSI_g_sNoObjects == NO_OBJECT) return NO_OBJECT;
- #if !defined _YSI_SETUP_MASTER
- if (!Object_IsValidModel(model)) return NO_OBJECT;
- #endif
- new
- pointer = YSI_g_sNoObjects;
- YSI_g_sNoObjects = YSI_g_sObjects[pointer][E_OBJECT_NEXT];
- #if defined _YSI_SETUP_MASTER
- YSI_g_sObjects[pointer][E_OBJECT_SCRIPT] = master;
- #endif
- YSI_g_sObjects[pointer][E_OBJECT_MODEL] = e_OBJ_FLAG:model | e_OBJ_FLAG_ACTIVE | e_OBJ_FLAG_RECREATED | Object_SetAttach(NO_ATTACH_PLAYER);
- YSI_g_sObjects[pointer][E_OBJECT_X] = x;
- YSI_g_sObjects[pointer][E_OBJECT_Y] = y;
- YSI_g_sObjects[pointer][E_OBJECT_Z] = z;
- YSI_g_sObjects[pointer][E_OBJECT_RX] = rx;
- YSI_g_sObjects[pointer][E_OBJECT_RY] = ry;
- YSI_g_sObjects[pointer][E_OBJECT_RZ] = rz;
- YSI_g_sObjects[pointer][E_OBJECT_VIEW] = OBJECT_SIGHT;
- #if !defined NO_OBJECT_ATTACH
- YSI_g_sObjects[pointer][E_OBJECT_PARENT] = NO_OBJECT;
- YSI_g_sObjects[pointer][E_OBJECT_SIBLINGS] = NO_OBJECT;
- YSI_g_sObjects[pointer][E_OBJECT_CHILDREN] = NO_OBJECT;
- #endif
- Object_AddToUpdate(pointer);
- Object_AddToSector(Object_FindSector(x, y, z), pointer, OBJECT_SIGHT);
- #if defined _YSI_SETUP_MASTER
- setproperty(0, "YSIReq", pointer);
- #endif
- return pointer;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_FindSector
- Params:
- Float:x - X point.
- Float:y - Y point.
- Float:z - Z point.
- Return:
- Point's sector.
- Notes:
- Finds the sector of a point.
- -*----------------------------------------------------------------------------*/
- static stock Object_FindSector(Float:x, Float:y, Float:z)
- {
- if (z > 800.0) return OBJECT_INT_SECTOR;
- if (x < OBJECT_BOUNDS_MINX || x >= OBJECT_BOUNDS_MAXX || y < OBJECT_BOUNDS_MINY || y >= OBJECT_BOUNDS_MAXY) return OBJECT_NO_SECTOR;
- x = floatsub(x, float(OBJECT_BOUNDS_MINX)) / OBJECT_REAL_X_SECTOR_SIZE;
- y = floatsub(y, float(OBJECT_BOUNDS_MINY)) / OBJECT_REAL_Y_SECTOR_SIZE;
- new
- val;
- val = (floatround(x, floatround_floor) * OBJECT_SECTOR_X_EDGE) + floatround(y, floatround_floor);
- return val;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToOOB
- Params:
- pointer - Index of the object to add.
- Return:
- -
- Notes:
- Adds an object to the linked list for objects out of bounds of the grid
- system (i.e. stores objects out the +/-OBJECT_BOUNDS world limit).
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToOOB(pointer)
- {
- if (YSI_g_sOtherSector == NO_OBJECT)
- {
- YSI_g_sOtherSector = pointer;
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = pointer;
- }
- else
- {
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = YSI_g_sObjects[YSI_g_sOtherSector][E_OBJECT_NEXT];
- YSI_g_sObjects[YSI_g_sOtherSector][E_OBJECT_NEXT] = pointer;
- }
- YSI_g_sObjects[pointer][E_OBJECT_SECTOR] = OBJECT_NO_SECTOR;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToLOD
- Params:
- pointer - Index of the object to add.
- Return:
- -
- Notes:
- Adds an object to the linked list for objects with views > OBJECT_MAX_VIEW
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToLOD(pointer)
- {
- if (YSI_g_sLODObjects == NO_OBJECT)
- {
- YSI_g_sLODObjects = pointer;
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = pointer;
- }
- else
- {
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = YSI_g_sObjects[YSI_g_sLODObjects][E_OBJECT_NEXT];
- YSI_g_sObjects[YSI_g_sLODObjects][E_OBJECT_NEXT] = pointer;
- }
- YSI_g_sObjects[pointer][E_OBJECT_SECTOR] = OBJECT_LOD_SECTOR;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToINT
- Params:
- pointer - Index of the object to add.
- Return:
- -
- Notes:
- Adds an object to the linked list for objects in interiors.
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToINT(pointer)
- {
- if (YSI_g_sInteriorObjects == NO_OBJECT)
- {
- YSI_g_sInteriorObjects = pointer;
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = pointer;
- }
- else
- {
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = YSI_g_sObjects[YSI_g_sInteriorObjects][E_OBJECT_NEXT];
- YSI_g_sObjects[YSI_g_sInteriorObjects][E_OBJECT_NEXT] = pointer;
- }
- YSI_g_sObjects[pointer][E_OBJECT_SECTOR] = OBJECT_LOD_SECTOR;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToMovingList
- Params:
- pointer - Index of the object to add.
- Return:
- -
- Notes:
- Adds an object to the linked list for dynamic objects.
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToMovingList(pointer)
- {
- if (YSI_g_sMovingObjects == NO_OBJECT)
- {
- YSI_g_sMovingObjects = pointer;
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = pointer;
- }
- else
- {
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = YSI_g_sObjects[YSI_g_sMovingObjects][E_OBJECT_NEXT];
- YSI_g_sObjects[YSI_g_sMovingObjects][E_OBJECT_NEXT] = pointer;
- }
- YSI_g_sObjects[pointer][E_OBJECT_SECTOR] = OBJECT_NO_SECTOR;
- }
-
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToSector
- Params:
- sector - Sector of object.
- pointer - Index of object.
- Float:view - Distance the object can be seen from.
- Return:
- -
- Notes:
- Saves an object as being in a sector.
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToSector(sector, pointer, Float:view)
- {
- if (sector == OBJECT_NO_SECTOR) Object_AddToOOB(pointer);
- else if (sector == OBJECT_INT_SECTOR) Object_AddToINT(pointer);
- else if (view > (OBJECT_MAX_VIEW_DISTANCE * OBJECT_MAX_VIEW_DISTANCE)) Object_AddToLOD(pointer);
- else
- {
- new
- data = YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_POINTER];
- if (data == NO_OBJECT)
- {
- YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_POINTER] = pointer;
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = pointer;
- }
- else
- {
- YSI_g_sObjects[pointer][E_OBJECT_NEXT] = YSI_g_sObjects[data][E_OBJECT_NEXT];
- YSI_g_sObjects[data][E_OBJECT_NEXT] = pointer;
- }
- YSI_g_sObjects[pointer][E_OBJECT_SECTOR] = sector;
- if (view > YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW]) YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW] = view;
- }
- }
- /*----------------------------------------------------------------------------*-
- Function:
- DestroyDynamicObject
- Params:
- objectid - Object to destroy.
- Return:
- -
- Notes:
- Dynamic wrapper for DestroyObject. Removes the object from it's list by
- using the cyclic property to find the previous object and repointing it to
- the object after the removed one. This ay make it point to itself but
- this is a good thing. The object is then added to the unassigned list in
- the same way as it's added to a normal list and finally the object flags
- are reset to destroy the data.
- -*----------------------------------------------------------------------------*/
- stock DestroyDynamicObject(objectid)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid))
- {
- return Object_Destroy(objectid);
- }
- return 0;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_DESTROY);
- return getproperty(0, "YSIReq");
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Destroy
- Params:
- objectid - Object to destroy.
- remove - Wether to update client side objects.
- Return:
- -
- Notes:
- Does the hard work for DestroyDynamicObject.
- -*----------------------------------------------------------------------------*/
- static stock Object_Destroy(objectid, remove = 1)
- {
- Object_RemoveFromSector(YSI_g_sObjects[objectid][E_OBJECT_SECTOR], objectid);
- if (YSI_g_sNoObjects == NO_OBJECT)
- {
- YSI_g_sNoObjects = objectid;
- YSI_g_sObjects[objectid][E_OBJECT_NEXT] = objectid;
- }
- else
- {
- YSI_g_sObjects[objectid][E_OBJECT_NEXT] = YSI_g_sObjects[YSI_g_sNoObjects][E_OBJECT_NEXT];
- YSI_g_sObjects[YSI_g_sNoObjects][E_OBJECT_NEXT] = objectid;
- }
- #if !defined NO_OBJECT_ATTACH
- new
- children = YSI_g_sObjects[objectid][E_OBJECT_CHILDREN],
- parent = YSI_g_sObjects[objectid][E_OBJECT_PARENT],
- old = NO_OBJECT,
- last = NO_OBJECT;
- while (children != NO_OBJECT)
- {
- last = children;
- YSI_g_sObjects[children][E_OBJECT_PARENT] = parent;
- children = YSI_g_sObjects[children][E_OBJECT_SIBLINGS];
- }
- if (parent != NO_OBJECT)
- {
- old = YSI_g_sObjects[parent][E_OBJECT_CHILDREN];
- if (old == objectid)
- {
- old = YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS];
- }
- else
- {
- children = old;
- new
- obj;
- do
- {
- obj = children;
- children = YSI_g_sObjects[children][E_OBJECT_SIBLINGS];
- }
- while (children != objectid);
- YSI_g_sObjects[obj][E_OBJECT_SIBLINGS] = YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS];
- }
- if (last != NO_OBJECT)
- {
- YSI_g_sObjects[last][E_OBJECT_SIBLINGS] = old;
- }
- YSI_g_sObjects[parent][E_OBJECT_CHILDREN] = YSI_g_sObjects[objectid][E_OBJECT_CHILDREN];
- }
- #endif
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] = e_OBJ_FLAG:0;
- if (remove)
- {
- foreach (Player, playerid)
- {
- for (new i = 0; i < MAY_OBJECTS; i++)
- {
- if (YSI_g_sPlayerObjects[playerid][i] == objectid)
- {
- DestroyPlayerObject(playerid, i + 1);
- break;
- }
- }
- }
- }
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromSector
- Params:
- sector - Sector list to modify.
- objectid - Object to remove.
- Return:
- -
- Notes:
- Used to be part of DestroyDynamicObject but is needed by other API
- functions.
- -*----------------------------------------------------------------------------*/
- static stock Object_RemoveFromSector(sector, objectid)
- {
- new
- pointer = objectid,
- last,
- Float:newview = OBJECT_SIGHT;
- do
- {
- last = pointer;
- pointer = YSI_g_sObjects[last][E_OBJECT_NEXT];
- if (last != objectid && YSI_g_sObjects[last][E_OBJECT_VIEW] > newview) newview = YSI_g_sObjects[last][E_OBJECT_VIEW];
- }
- while (pointer != objectid);
- if (last == objectid)
- {
- if (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED) YSI_g_sMovingObjects = NO_OBJECT;
- else if (sector == OBJECT_NO_SECTOR) YSI_g_sOtherSector = NO_OBJECT;
- else if (sector == OBJECT_LOD_SECTOR) YSI_g_sLODObjects = NO_OBJECT;
- else if (sector == OBJECT_INT_SECTOR) YSI_g_sInteriorObjects = NO_OBJECT;
- else
- {
- YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_POINTER] = NO_OBJECT;
- YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW] = OBJECT_SIGHT;
- }
- }
- else
- {
- if (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED)
- {
- if (YSI_g_sMovingObjects == objectid) YSI_g_sMovingObjects = last;
- }
- else if (sector == OBJECT_NO_SECTOR)
- {
- if (YSI_g_sOtherSector == objectid) YSI_g_sOtherSector = last;
- }
- else if (sector == OBJECT_LOD_SECTOR)
- {
- if (YSI_g_sLODObjects == objectid) YSI_g_sLODObjects = last;
- }
- else if (sector == OBJECT_INT_SECTOR)
- {
- if (YSI_g_sInteriorObjects == objectid) YSI_g_sInteriorObjects = last;
- }
- else if (YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_POINTER] == objectid)
- {
- YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_POINTER] = last;
- YSI_g_sObjectSectors[sector][E_OBJ_SECTOR_MAX_VIEW] = newview;
- }
- YSI_g_sObjects[last][E_OBJECT_NEXT] = YSI_g_sObjects[objectid][E_OBJECT_NEXT];
- }
- }
- /*----------------------------------------------------------------------------*-
- Function:
- SetDynamicObjectPos
- Params:
- objectid - Object to objSet new position of.
- Float:x - X co-ordinate.
- Float:y - Y co-ordintae.
- Float:z - Z co-ordinate.
- Return:
- -
- Notes:
- Updated to update child positions to (but NOT parent).
- -*----------------------------------------------------------------------------*/
- stock SetDynamicObjectPos(objectid, Float:x, Float:y, Float:z)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (!Object_IsValid(objectid) || Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL])) return 0;
- #if !defined NO_OBJECT_ATTACH
- Object_UpdateChildSectors(YSI_g_sObjects[objectid][E_OBJECT_CHILDREN], x, y, z);
- #endif
- return Object_SetPos(objectid, x, y, z);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_CoOrdRemote", "iiffff", objectid, E_OBJECT_REMOTE_SETPOS, x, y, z, 0.0);
- return getproperty(0, "YSIReq");
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_SetPos
- Params:
- objectid - Object to objSet new position of.
- Float:x - X co-ordinate.
- Float:y - Y co-ordintae.
- Float:z - Z co-ordinate.
- Return:
- -
- Notes:
- Does the actual relocation of an object.
- -*----------------------------------------------------------------------------*/
- static stock Object_SetPos(objectid, Float:x, Float:y, Float:z)
- {
- new
- newsec = Object_FindSector(x, y, z),
- oldsec;
- if (newsec != (oldsec = YSI_g_sObjects[objectid][E_OBJECT_SECTOR]))
- {
- Object_RemoveFromSector(oldsec, objectid);
- Object_AddToSector(newsec, objectid, YSI_g_sObjects[objectid][E_OBJECT_VIEW]);
- }
- #if !defined NO_OBJECT_ATTACH
- new
- parent = YSI_g_sObjects[objectid][E_OBJECT_PARENT];
- if (parent != NO_OBJECT)
- {
- new
- Float:nx,
- Float:ny,
- Float:nz;
- Object_GetPos(parent, nx, ny, nz);
- YSI_g_sObjects[objectid][E_OBJECT_X] = x - nx;
- YSI_g_sObjects[objectid][E_OBJECT_Y] = y - ny;
- YSI_g_sObjects[objectid][E_OBJECT_Z] = z - nz;
- }
- else
- {
- #endif
- YSI_g_sObjects[objectid][E_OBJECT_X] = x;
- YSI_g_sObjects[objectid][E_OBJECT_Y] = y;
- YSI_g_sObjects[objectid][E_OBJECT_Z] = z;
- #if !defined NO_OBJECT_ATTACH
- }
- #endif
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_JUMPED;
- Object_AddToUpdate(objectid);
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_UpdateChildSectors
- Params:
- objectid - Object to update children of.
- Float:x - X co-ordinate of parent.
- Float:y - Y co-ordintae of parent.
- Float:z - Z co-ordinate of parent.
- Return:
- -
- Notes:
- Doesn't update the position parameter as that's relative to the parent for
- child objects. Recursive function to update sectors of children of
- children.
- -*----------------------------------------------------------------------------*/
- #if !defined NO_OBJECT_ATTACH
- static stock Object_UpdateChildSectors(objectid, Float:x, Float:y, Float:z)
- {
- new
- Float:nx,
- Float:ny,
- Float:nz,
- newsec,
- oldsec;
- while (objectid != NO_OBJECT)
- {
- if (Object_IsAttached(objectid))
- {
- nx = x + YSI_g_sObjects[objectid][E_OBJECT_X];
- ny = y + YSI_g_sObjects[objectid][E_OBJECT_Y];
- nz = z + YSI_g_sObjects[objectid][E_OBJECT_Z];
- newsec = Object_FindSector(nx, ny, nz);
- if (newsec != (oldsec = YSI_g_sObjects[objectid][E_OBJECT_SECTOR]))
- {
- Object_RemoveFromSector(oldsec, objectid);
- Object_AddToSector(newsec, objectid, YSI_g_sObjects[objectid][E_OBJECT_VIEW]);
- }
- Object_UpdateChildSectors(YSI_g_sObjects[objectid][E_OBJECT_CHILDREN], nx, ny, nz);
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_JUMPED;
- }
- objectid = YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS];
- }
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- SetDynamicObjectRot
- Params:
- objectid - Object to objSet new rotation of.
- Float:x - X rotation.
- Float:y - Y rotation.
- Float:z - Z rotation.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- stock SetDynamicObjectRot(objectid, Float:x, Float:y, Float:z)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (!Object_IsValid(objectid) || Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL])) return 0;
- YSI_g_sObjects[objectid][E_OBJECT_RX] = x;
- YSI_g_sObjects[objectid][E_OBJECT_RY] = y;
- YSI_g_sObjects[objectid][E_OBJECT_RZ] = z;
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_ROTATED;
- Object_AddToUpdate(objectid);
- return 1;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_CoOrdRemote", "iiffff", objectid, E_OBJECT_REMOTE_SETROT, x, y, z, 0.0);
- return getproperty(0, "YSIReq");
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- GetDynamicObjectRot
- Params:
- objectid - Object to objSet new rotation of.
- &Float:x - X rotation store.
- &Float:y - Y rotation store.
- &Float:z - Z rotation store.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- stock GetDynamicObjectRot(objectid, &Float:x, &Float:y, &Float:z)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (!Object_IsValid(objectid) || Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL])) return 0;
- x = YSI_g_sObjects[objectid][E_OBJECT_RX];
- y = YSI_g_sObjects[objectid][E_OBJECT_RY];
- z = YSI_g_sObjects[objectid][E_OBJECT_RZ];
- return 1;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_GETROT);
- x = Float:getproperty(0, "YSIReq");
- y = Float:getproperty(0, "YSIReq2");
- z = Float:getproperty(0, "YSIReq3");
- deleteproperty(0, "YSIReq2");
- deleteproperty(0, "YSIReq3");
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToWorld
- Params:
- object - Object to add.
- world - World to add to.
- Return:
- -
- Notes:
- Makes an object visible in a world.
- -*----------------------------------------------------------------------------*/
- stock Object_AddToWorld(object, world)
- {
- #if OBJECT_WORLDS > 0
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_Set(YSI_g_sObjects[object][E_OBJECT_WORLDS], world, 1, OBJECT_WORLD_COUNT);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, world, E_OBJECT_REMOTE_ADDW);
- }
- #endif
- #else
- #pragma unused object, world
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromWorld
- Params:
- object - Object to remove.
- world - World to remove from.
- Return:
- -
- Notes:
- Makes an object invisible in a world.
- -*----------------------------------------------------------------------------*/
- stock Object_RemoveFromWorld(object, world)
- {
- #if OBJECT_WORLDS > 0
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_Set(YSI_g_sObjects[object][E_OBJECT_WORLDS], world, 0, OBJECT_WORLD_COUNT);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, world, E_OBJECT_REMOTE_REMW);
- }
- #endif
- #else
- #pragma unused object, world
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToPlayer
- Params:
- object - Object to add.
- playerid - Player to add to.
- Return:
- -
- Notes:
- Makes an object visible to a player.
- -*----------------------------------------------------------------------------*/
- stock Object_AddToPlayer(object, playerid)
- {
- #if !defined NO_PERSONAL_OBJECTS
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_Set(YSI_g_sObjects[object][E_OBJECT_PLAYERS], playerid, 1, PLAYER_BIT_ARRAY);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, playerid, E_OBJECT_REMOTE_ADDP);
- }
- #endif
- #else
- #pragma unused object, playerid
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromWorld
- Params:
- object - Object to remove.
- playerid - Player to remove from.
- Return:
- -
- Notes:
- Makes an object invisible to a player.
- -*----------------------------------------------------------------------------*/
- stock Object_RemoveFromPlayer(object, playerid)
- {
- #if !defined NO_PERSONAL_OBJECTS
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_Set(YSI_g_sObjects[object][E_OBJECT_PLAYERS], playerid, 0, PLAYER_BIT_ARRAY);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, playerid, E_OBJECT_REMOTE_REMP);
- }
- #endif
- #else
- #pragma unused object, playerid
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToAllWorlds
- Params:
- object - Object to add.
- Return:
- -
- Notes:
- Makes an object visible in all worlds.
- -*----------------------------------------------------------------------------*/
- stock Object_AddToAllWorlds(object)
- {
- #if OBJECT_WORLDS > 0
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_SetAll(YSI_g_sObjects[object][E_OBJECT_WORLDS], 1, OBJECT_WORLD_COUNT);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, 0, E_OBJECT_REMOTE_ALLWA);
- }
- #endif
- #else
- #pragma unused object
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromAllWorlds
- Params:
- object - Object to remove.
- Return:
- -
- Notes:
- Makes an object invisible in all worlds.
- -*----------------------------------------------------------------------------*/
- stock Object_RemoveFromAllWorlds(object)
- {
- #if OBJECT_WORLDS > 0
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object)) Bit_SetAll(YSI_g_sObjects[object][E_OBJECT_WORLDS], 0, OBJECT_WORLD_COUNT);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, 0, E_OBJECT_REMOTE_ALLWR);
- }
- #endif
- #else
- #pragma unused object
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToAllPlayers
- Params:
- object - Object to add.
- Return:
- -
- Notes:
- Makes an object visible to all players.
- -*----------------------------------------------------------------------------*/
- stock Object_AddToAllPlayers(object)
- {
- #if !defined NO_PERSONAL_OBJECTS
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object))
- {
- Bit_SetAll(YSI_g_sObjects[object][E_OBJECT_PLAYERS], 1, PLAYER_BIT_ARRAY);
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, 0, E_OBJECT_REMOTE_ALLPA);
- }
- #endif
- #else
- #pragma unused object
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromAllPlayers
- Params:
- object - Object to remove.
- Return:
- -
- Notes:
- Makes an object invisible to all players.
- -*----------------------------------------------------------------------------*/
- stock Object_RemoveFromAllPlayers(object)
- {
- #if !defined NO_PERSONAL_OBJECTS
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(object))
- {
- Bit_SetAll(YSI_g_sObjects[object][E_OBJECT_PLAYERS], 0, PLAYER_BIT_ARRAY);
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", object, 0, E_OBJECT_REMOTE_ALLPR);
- }
- #endif
- #else
- #pragma unused object
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GetPos
- Params:
- objectid - Object to get position of.
- &Float:x - X return.
- &Float:y - Y return.
- &Float:z - Z return.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- static stock Object_GetPos(objectid, &Float:x, &Float:y, &Float:z)
- {
- new
- playerid = Object_GetAttach(YSI_g_sObjects[objectid][E_OBJECT_MODEL]);
- if (playerid != NO_ATTACH_PLAYER && IsPlayerConnected(playerid))
- {
- GetPlayerPos(playerid, x, y, z);
- }
- #if !defined NO_OBJECT_ATTACH
- else if ((playerid = YSI_g_sObjects[objectid][E_OBJECT_PARENT]) != NO_OBJECT)
- {
- Object_GetPos(playerid, x, y, z);
- }
- #endif
- #pragma tabsize 0
- else
- #pragma tabsize 4
- {
- x = YSI_g_sObjects[objectid][E_OBJECT_X];
- y = YSI_g_sObjects[objectid][E_OBJECT_Y];
- z = YSI_g_sObjects[objectid][E_OBJECT_Z];
- return;
- }
- x += YSI_g_sObjects[objectid][E_OBJECT_X];
- y += YSI_g_sObjects[objectid][E_OBJECT_Y];
- z += YSI_g_sObjects[objectid][E_OBJECT_Z];
- }
- /*----------------------------------------------------------------------------*-
- Function:
- GetDynamicObjectPos
- Params:
- objectid - Object to get position of.
- &Float:x - X return.
- &Float:y - Y return.
- &Float:z - Z return.
- Return:
- -
- Notes:
- API wrapper for Object_GetPos.
- -*----------------------------------------------------------------------------*/
- stock GetDynamicObjectPos(objectid, &Float:x, &Float:y, &Float:z)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (!Object_IsValid(objectid)) return 0;
- Object_GetPos(objectid, x, y, z);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_GETPOS);
- x = Float:getproperty(0, "YSIReq");
- y = Float:getproperty(0, "YSIReq2");
- z = Float:getproperty(0, "YSIReq3");
- deleteproperty(0, "YSIReq2");
- deleteproperty(0, "YSIReq3");
- }
- #endif
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_HasPlayer
- Params:
- objectid - Object to check.
- playerid - Player to check.
- worldid - World to check.
- Return:
- Whether the object is visible to that player in that world.
- Notes:
- This is a variable function. Depending on the compile time settings it may
- or may not use all the parameters (it may use none).
- -*----------------------------------------------------------------------------*/
- #if !defined NO_PERSONAL_OBJECTS
- #if OBJECT_WORLDS > 0
- #define Object_HasPlayer(%1,%2,%3) \
- (Bit_Get(YSI_g_sObjects[(%1)][E_OBJECT_WORLDS], (%3)) && Bit_Get(YSI_g_sObjects[(%1)][E_OBJECT_PLAYERS], (%2)))
- #else
- #define Object_HasPlayer(%1,%2,%3) \
- (Bit_Get(YSI_g_sObjects[(%1)][E_OBJECT_PLAYERS], (%2)))
- #endif
- #else
- #if OBJECT_WORLDS > 0
- #define Object_HasPlayer(%1,%2,%3) \
- (Bit_Get(YSI_g_sObjects[(%1)][E_OBJECT_WORLDS], (%3)))
- #else
- #define Object_HasPlayer(%1,%2,%3) \
- (TRUE)
- #endif
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- IsValidDynamicObject
- Params:
- objectid - Object to check.
- Return:
- Object_IsValid.
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- stock IsValidDynamicObject(objectid)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- return Object_IsValid(objectid);
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_ISVALID);
- return getproperty(0, "YSIReq");
- }
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- AttachDynamicObjectToPlayer
- Params:
- objectid - Object to attach.
- playerid - Player to attach to.
- Float:X - X offset.
- Float:Y - Y offset.
- Float:Z - Z offset.
- Float:RX - X rotation.
- Float:RY - Y rotation.
- Float:RZ - Z rotation.
- Float:S - Speed.
- Return:
- -
- Notes:
- Updated for children.
- -*----------------------------------------------------------------------------*/
- stock AttachDynamicObjectToPlayer(objectid, playerid, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ)
- {
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid) && Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL]))
- {
- return Object_AttachToPlayer(objectid, playerid, X, Y, Z, RX, RY, RZ);
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_AttachRemote", "iiffffff", objectid, playerid, X, Y, Z, RX, RY, RZ);
- return getproperty(0, "YSIReq");
- }
- #endif
- #else
- #pragma unused objectid, X, Y, Z, S
- #endif
- return 0;
- }
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_SETUP_MASTER
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AttachRemote
- Params:
- objectid - Object to attach.
- playerid - Player to attach to.
- Float:X - X offset.
- Float:Y - Y offset.
- Float:Z - Z offset.
- Float:RX - X rotation.
- Float:RY - Y rotation.
- Float:RZ - Z rotation.
- Float:S - Speed.
- Return:
- -
- Notes:
- Remote call for AttachDynamicObjectToPlayer.
- -*----------------------------------------------------------------------------*/
-
- public Object_AttachRemote(objectid, playerid, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ)
- {
- if (!YSI_g_sIsMaster) return 0;
- setproperty(0, "YSIReq", 0);
- if (Object_IsValid(objectid) && Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL]))
- {
- setproperty(0, "YSIReq", Object_AttachToPlayer(objectid, playerid, X, Y, Z, RX, RY, RZ));
- return 1;
- }
- return 0;
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AttachToPlayer
- Params:
- objectid - Object to attach.
- playerid - Player to attach to.
- Float:X - X offset.
- Float:Y - Y offset.
- Float:Z - Z offset.
- Float:RX - X rotation.
- Float:RY - Y rotation.
- Float:RZ - Z rotation.
- Float:S - Speed.
- Return:
- -
- Notes:
- Recursive call for AttachDynamicObjectToPlayer.
- -*----------------------------------------------------------------------------*/
- static stock Object_AttachToPlayer(objectid, playerid, Float:X, Float:Y, Float:Z, Float:RX, Float:RY, Float:RZ)
- {
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_ATTACHED;
- YSI_g_sObjects[objectid][E_OBJECT_X] = X;
- YSI_g_sObjects[objectid][E_OBJECT_Y] = Y;
- YSI_g_sObjects[objectid][E_OBJECT_Z] = Z;
- YSI_g_sObjects[objectid][E_OBJECT_RX] = RX;
- YSI_g_sObjects[objectid][E_OBJECT_RY] = RY;
- YSI_g_sObjects[objectid][E_OBJECT_RZ] = RZ;
- Object_RemoveFromSector(YSI_g_sObjects[objectid][E_OBJECT_SECTOR], objectid);
- Object_AddToMovingList(objectid);
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] = (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & ~e_OBJ_FLAG_ATTACH) | Object_SetAttach(playerid);
- Object_AddToUpdate(objectid);
- #if !defined NO_OBJECT_ATTACH
- new
- child = YSI_g_sObjects[objectid][E_OBJECT_CHILDREN];
- while (child != NO_OBJECT)
- {
- Object_AttachToPlayer(child, playerid, X + YSI_g_sObjects[child][E_OBJECT_X], Y + YSI_g_sObjects[child][E_OBJECT_Y], Z + YSI_g_sObjects[child][E_OBJECT_Z], RX, RY, RZ);
- child = YSI_g_sObjects[child][E_OBJECT_SIBLINGS];
- }
- #endif
- return 1;
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- DetachDynamicObjectFromPlayer
- Params:
- objectid - Object to detach.
- Return:
- -
- Notes:
- Detaches an object from a player.
- -*----------------------------------------------------------------------------*/
- stock DetachDynamicObjectFromPlayer(objectid)
- {
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (!Object_IsValid(objectid)) return;
- new
- playerid = Object_GetAttach(YSI_g_sObjects[objectid][E_OBJECT_MODEL]);
- if (playerid != NO_ATTACH_PLAYER)
- {
- Object_RemoveFromSector(OBJECT_NO_SECTOR, objectid);
- new
- Float:x,
- Float:y,
- Float:z;
- GetPlayerPos(playerid, x, y, z);
- new
- Float:nx = YSI_g_sObjects[objectid][E_OBJECT_X],
- Float:ny = YSI_g_sObjects[objectid][E_OBJECT_Y],
- Float:nz = YSI_g_sObjects[objectid][E_OBJECT_Z];
- Object_SetPos(objectid, x + nx, y + ny, z + nz);
- #if !defined NO_OBJECT_ATTACH
- Object_UpdateAttach(YSI_g_sObjects[objectid][E_OBJECT_CHILDREN], nx, ny, nz, x + nx, y + ny, z + nz, false);
- #endif
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_ATTACHED | e_OBJ_FLAG_ATTACH | e_OBJ_FLAG_RECREATED;
- Object_AddToUpdate(objectid);
- }
- return;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_DETATCH);
- }
- #endif
- #else
- #pragma unused objectid
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_UpdateAttach
- Params:
- child - Start of children list to positionally update.
- Float:x - x offset of parent.
- Float:y - y offset of parent.
- Float:z - z offset of parent.
- Float:rx - Real x location.
- Float:ry - Real y location.
- Float:rz - Real z location.
- moved - Wether the object was previously moving or attached.
- Return:
- -
- Notes:
- Restores the object sectors and offsets from parents based on positions
- relative to other items (origin or a player).
- -*----------------------------------------------------------------------------*/
- #if !defined NO_OBJECT_ATTACH
- static stock Object_UpdateAttach(child, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, moving = true)
- {
- while (child != NO_OBJECT)
- {
- new
- Float:nx = YSI_g_sObjects[child][E_OBJECT_X],
- Float:ny = YSI_g_sObjects[child][E_OBJECT_Y],
- Float:nz = YSI_g_sObjects[child][E_OBJECT_Z],
- Float:mx = nx - x,
- Float:my = ny - y,
- Float:mz = nz - z;
- Object_UpdateAttach(YSI_g_sObjects[child][E_OBJECT_CHILDREN], nx, ny, nz, rx + mx, ry + my, rz + mz);
- YSI_g_sObjects[child][E_OBJECT_X] = mx;
- YSI_g_sObjects[child][E_OBJECT_Y] = my;
- YSI_g_sObjects[child][E_OBJECT_Z] = mz;
- Object_RemoveFromSector(OBJECT_NO_SECTOR, child);
- Object_AddToSector(Object_FindSector(rx + mx, ry + my, rz + mz), child, YSI_g_sObjects[child][E_OBJECT_VIEW]);
- child = YSI_g_sObjects[child][E_OBJECT_SIBLINGS];
- if (moving)
- {
- YSI_g_sObjects[child][E_OBJECT_MODEL] = (YSI_g_sObjects[child][E_OBJECT_MODEL] & ~(e_OBJ_FLAG_MOVED)) | e_OBJ_FLAG_RECREATED;
- }
- else
- {
- YSI_g_sObjects[child][E_OBJECT_MODEL] |= e_OBJ_FLAG_ATTACHED | e_OBJ_FLAG_ATTACH | e_OBJ_FLAG_RECREATED;
- }
- }
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- MoveDynamicObject
- Params:
- objectid - Object to move.
- Float:X - X position of target.
- Float:Y - Y position of target.
- Float:Z - Z position of target.
- Float:S - Speed.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- stock MoveDynamicObject(objectid, Float:X, Float:Y, Float:Z, Float:S)
- {
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid))
- {
- Object_Move(objectid, X, Y, Z, S);
- Object_AddToUpdate(objectid);
- return 1;
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_CoOrdRemote", "iiffff", objectid, E_OBJECT_REMOTE_MOVETO, X, Y, Z, S);
- return getproperty(0, "YSIReq");
- }
- #endif
- #else
- #pragma unused objectid, X, Y, Z, S
- #endif
- return 0;
- }
- #if !defined NO_OBJECTS_MOVE
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Move
- Params:
- objectid - Object to move.
- Float:X - X position of target.
- Float:Y - Y position of target.
- Float:Z - Z position of target.
- Float:S - Speed.
- Return:
- -
- Notes:
- Recursive function for MoveDynamicObject to move children.
- -*----------------------------------------------------------------------------*/
- static stock Object_Move(objectid, Float:X, Float:Y, Float:Z, Float:S)
- {
- if (xor:(YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED1) == xor:(YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED2))
- {
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] ^= e_OBJ_FLAG_MOVED;
- }
- else
- {
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] = (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & ~e_OBJ_FLAG_MOVED) | e_OBJ_FLAG_MOVED1;
- }
- YSI_g_sObjects[objectid][E_OBJECT_MX] = X;
- YSI_g_sObjects[objectid][E_OBJECT_MY] = Y;
- YSI_g_sObjects[objectid][E_OBJECT_MZ] = Z;
- YSI_g_sObjects[objectid][E_OBJECT_MS] = S;
- Object_RemoveFromSector(YSI_g_sObjects[objectid][E_OBJECT_SECTOR], objectid);
- Object_AddToMovingList(objectid);
- #if !defined NO_OBJECT_ATTACH
- new
- child = YSI_g_sObjects[objectid][E_OBJECT_CHILDREN];
- while (child != NO_OBJECT)
- {
- Object_Move(child, X + YSI_g_sObjects[child][E_OBJECT_X], Y + YSI_g_sObjects[child][E_OBJECT_Y], Z + YSI_g_sObjects[child][E_OBJECT_Z], S);
- child = YSI_g_sObjects[child][E_OBJECT_SIBLINGS];
- }
- #endif
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- AttachObjectToObject
- Params:
- attachobject - Object to attach.
- toobject - Object to attach to.
- Return:
- -
- Notes:
- Variables named to hopefully avoid confusion. Now checks the parent is not
- a descendent of the child to avoid infinate loops.
- -*----------------------------------------------------------------------------*/
- stock AttachObjectToObject(attachobject, toobject)
- {
- #if !defined NO_OBJECT_ATTACH
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(attachobject) && Object_IsValid(toobject))
- {
- if (Object_CheckDescendant(toobject, attachobject)) return 0;
- new
- Float:px,
- Float:py,
- Float:pz,
- Float:cx,
- Float:cy,
- Float:cz;
- Object_GetPos(toobject, px, py, pz);
- Object_GetPos(attachobject, cx, cy, cz);
- new
- parent = YSI_g_sObjects[attachobject][E_OBJECT_PARENT];
- if (parent != NO_OBJECT) Object_RemoveFromParent(attachobject, parent);
- Object_AddToParent(attachobject, toobject);
- YSI_g_sObjects[attachobject][E_OBJECT_X] = cx - px;
- YSI_g_sObjects[attachobject][E_OBJECT_Y] = cy - py;
- YSI_g_sObjects[attachobject][E_OBJECT_Z] = cz - pz;
- return 1;
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", attachobject, toobject, E_OBJECT_REMOTE_ATTACHOO);
- return getproperty(0, "YSIReq");
- }
- #endif
- #else
- #pragma unused attachobject, toobject
- #endif
- return 0;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_IsDesendant
- Params:
- objectid - Object to check.
- ancestor - Object to check family tree of for objectid.
- Return:
- -
- Notes:
- Checks if objectid is a descendant of the ancestor object.
- -*----------------------------------------------------------------------------*/
- stock Object_IsDescendant(objectid, ancestor)
- {
- #if !defined NO_OBJECT_ATTACH
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid) && Object_IsValid(ancestor))
- {
- return Object_CheckDescendant(objectid, ancestor);
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, ancestor, E_OBJECT_REMOTE_CHECKDESC);
- return getproperty(0, "YSIReq");
- }
- #endif
- #else
- #pragma unused objectid, ancestor
- #endif
- return 0;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_CheckDesendant
- Params:
- objectid - Object to check.
- ancestor - Object to check family tree of for objectid.
- Return:
- -
- Notes:
- Recursive call for Object_IsDescendant.
- -*----------------------------------------------------------------------------*/
- static stock Object_CheckDescendant(objectid, ancestor)
- {
- if (objectid == ancestor) return 1;
- new
- child = YSI_g_sObjects[ancestor][E_OBJECT_CHILDREN];
- while (child != NO_OBJECT)
- {
- if (Object_CheckDescendant(objectid, child)) return 1;
- child = YSI_g_sObjects[child][E_OBJECT_SIBLINGS];
- }
- return 0;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- RemoveObjectFromParent
- Params:
- objectid - Object to remove from it's parent.
- Return:
- -
- Notes:
- -
- -*----------------------------------------------------------------------------*/
- stock RemoveObjectFromParent(objectid)
- {
- #if !defined NO_OBJECT_ATTACH
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid))
- {
- new
- parent = YSI_g_sObjects[objectid][E_OBJECT_PARENT];
- if (parent != NO_OBJECT)
- {
- new
- Float:x,
- Float:y,
- Float:z;
- Object_GetPos(objectid, x, y, z);
- Object_RemoveFromParent(objectid, parent);
- YSI_g_sObjects[objectid][E_OBJECT_X] = x;
- YSI_g_sObjects[objectid][E_OBJECT_Y] = y;
- YSI_g_sObjects[objectid][E_OBJECT_Z] = z;
- }
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_REMOO);
- }
- #endif
- #else
- #pragma unused objectid
- #endif
- }
- #if !defined NO_OBJECT_ATTACH
- /*----------------------------------------------------------------------------*-
- Function:
- Object_RemoveFromParent
- Params:
- objectid - Object to remove from an object.
- parent - Object to remove from.
- Return:
- -
- Notes:
- Removes an object from another object's children list. Has parent passed
- as existance is checked in calling function so is already retrieved.
- -*----------------------------------------------------------------------------*/
- static stock Object_RemoveFromParent(objectid, parent)
- {
- new
- children = YSI_g_sObjects[parent][E_OBJECT_CHILDREN],
- next;
- if (children == objectid)
- {
- YSI_g_sObjects[parent][E_OBJECT_CHILDREN] = YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS];
- }
- else
- {
- while ((next = YSI_g_sObjects[children][E_OBJECT_SIBLINGS]) != objectid) children = next;
- YSI_g_sObjects[children][E_OBJECT_SIBLINGS] = YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS];
- }
- YSI_g_sObjects[objectid][E_OBJECT_PARENT] = NO_OBJECT;
- YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS] = NO_OBJECT;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_AddToParent
- Params:
- objectid - Object to attach.
- parentid - Object to attach to.
- Return:
- -
- Notes:
- Adds an object to another objects child list.
- -*----------------------------------------------------------------------------*/
- static stock Object_AddToParent(objectid, parentid)
- {
- if (YSI_g_sObjects[objectid][E_OBJECT_PARENT] == NO_OBJECT)
- {
- YSI_g_sObjects[objectid][E_OBJECT_SIBLINGS] = YSI_g_sObjects[parentid][E_OBJECT_CHILDREN];
- YSI_g_sObjects[objectid][E_OBJECT_PARENT] = parentid;
- YSI_g_sObjects[parentid][E_OBJECT_CHILDREN] = objectid;
- }
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- StopDynamicObject
- Params:
- objectid - Object to stop.
- Return:
- -
- Notes:
- Stops an object and reassigns it's sector.
- -*----------------------------------------------------------------------------*/
- stock StopDynamicObject(objectid)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- if (Object_IsValid(objectid))
- {
- Object_RemoveFromSector(OBJECT_NO_SECTOR, objectid);
- new
- Float:x,
- Float:y,
- Float:z;
- Object_GetPos(objectid, x, y, z);
- Object_AddToSector(Object_FindSector(x, y, z), objectid, YSI_g_sObjects[objectid][E_OBJECT_VIEW]);
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] = (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & ~(e_OBJ_FLAG_MOVED)) | e_OBJ_FLAG_RECREATED;
- Object_AddToUpdate(objectid);
- #if !defined NO_OBJECT_ATTACH
- Object_UpdateAttach(YSI_g_sObjects[objectid][E_OBJECT_CHILDREN], x, y, z, x, y, z);
- #endif
- }
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", objectid, 0, E_OBJECT_REMOTE_STOP);
- }
- #endif
- }
- #if !defined NO_OBJECTS_MOVE
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Update
- Params:
- objectid - Object to process.
- Float:elapsedTime - Time since last update in seconds.
- Return:
- -
- Notes:
- Updates a moving object's position in our internal memory based on speed
- and time (d = s * t)
- -*----------------------------------------------------------------------------*/
- static Object_Update(objectid, Float:elapsedTime)
- {
- new
- Float:x = YSI_g_sObjects[objectid][E_OBJECT_X],
- Float:y = YSI_g_sObjects[objectid][E_OBJECT_Y],
- Float:z = YSI_g_sObjects[objectid][E_OBJECT_Z],
- Float:mx = YSI_g_sObjects[objectid][E_OBJECT_MX],
- Float:my = YSI_g_sObjects[objectid][E_OBJECT_MY],
- Float:mz = YSI_g_sObjects[objectid][E_OBJECT_MZ],
- Float:distance = elapsedTime * YSI_g_sObjects[objectid][E_OBJECT_MS];
- x -= mx;
- y -= my;
- z -= mz;
- new
- Float:remaining = floatsqroot((x * x) + (y * y) + (z * z));
- if (distance >= remaining)
- {
- YSI_g_sObjects[objectid][E_OBJECT_X] = mx;
- YSI_g_sObjects[objectid][E_OBJECT_Y] = my;
- YSI_g_sObjects[objectid][E_OBJECT_Z] = mz;
- new
- e_OBJ_FLAG:oldmove = YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED;
- if (!Object_GateMoved(objectid)) CallRemoteFunction("OnDynamicObjectMoved", "i", objectid);
- if (oldmove == YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED)
- {
- StopDynamicObject(objectid);
- }
- return 1;
- }
- else
- {
- remaining /= distance;
- YSI_g_sObjects[objectid][E_OBJECT_X] += (0.0 - x) / remaining;
- YSI_g_sObjects[objectid][E_OBJECT_Y] += (0.0 - y) / remaining;
- YSI_g_sObjects[objectid][E_OBJECT_Z] += (0.0 - z) / remaining;
- }
- return 0;
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- Object_Loop
- Params:
- -
- Return:
- -
- Notes:
- Checks what objects are in the player's range repeatedly to stream them
- as required. Only checks objects near the player, based on sectors, and
- moving objects which are handled as their own 'sector'. If the player is
- near the edge of the grid (+/-OBJECT_BOUNDS x/y) OOB objects are also checked, only
- one sector is used for all those regardless of location. Moving objects
- and already visible objects are assumed higher priority.
-
- Now orders objects so only the closest are displayed.
-
- Fixed moving objects.
- -*----------------------------------------------------------------------------*/
- public Object_Loop()
- {
- #if defined _YSI_SETUP_MASTER
- if (!YSI_g_sIsMaster) return;
- #endif
- #if !defined NO_OBJECTS_MOVE
- static
- Float:s_fTime;
- new
- Float:tick = float(GetTickCount()) / 1000.0;
- if (YSI_g_sMovingObjects != NO_OBJECT)
- {
- new
- Float:fTime = tick - s_fTime,
- objectid = YSI_g_sMovingObjects;
- do
- {
- new
- next = YSI_g_sObjects[objectid][E_OBJECT_NEXT];
- if (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED) Object_Update(objectid, fTime);
- if (objectid == next) break;
- objectid = next;
- }
- while (objectid != NO_OBJECT);
- }
- s_fTime = tick;
- #endif
- foreach (Player, playerid)
- {
- static
- sectors[MAX_PLAYERS][OBJECT_VIEW_SECTORS][E_OSEC_ITTER],
- secStart[MAX_PLAYERS] = {-1, ...},
- Bit:objects[OBJECT_BITS],
- sObjList[MAY_OBJECTS][E_OBJECT_ITTER];
- new
- Float:x,
- Float:y,
- Float:z,
- world = GetPlayerVirtualWorld(playerid),
- i,
- j,
- objStart = -1,
- objEnd = -1,
- objCount;
- GetPlayerPos(playerid, x, y, z);
- if (z < 800.0)
- {
- Object_FindSectors(playerid, x, y, sectors[playerid], secStart[playerid]);
- i = secStart[playerid];
- while (i != -1)
- {
- if (objCount >= MAY_OBJECTS && sectors[playerid][i][E_OSEC_ITTER_DIFF] >= sObjList[objEnd][E_OBJECT_ITTER_DISTANCE]) break;
- else
- {
- if ((j = sectors[playerid][i][E_OSEC_ITTER_SECTOR]) == OBJECT_NO_SECTOR) Object_ParseSet(playerid, YSI_g_sOtherSector, x, y, z, world, sObjList, objStart, objEnd, objCount, false);
- else Object_ParseSet(playerid, YSI_g_sObjectSectors[j][E_OBJ_SECTOR_POINTER], x, y, z, world, sObjList, objStart, objEnd, objCount, false);
- }
- i = sectors[playerid][i][E_OSEC_ITTER_NEXT];
- }
- }
- else Object_ParseSet(playerid, YSI_g_sInteriorObjects, x, y, z, world, sObjList, objStart, objEnd, objCount, false);
- #if !defined NO_OBJECTS_MOVE
- Object_ParseSet(playerid, YSI_g_sMovingObjects, x, y, z, world, sObjList, objStart, objEnd, objCount, true);
- #endif
- Object_ParseSet(playerid, YSI_g_sLODObjects, x, y, z, world, sObjList, objStart, objEnd, objCount, false);
- for (j = objStart; j != -1; j = sObjList[j][E_OBJECT_ITTER_NEXT])
- {
- Bit_Let(objects, sObjList[j][E_OBJECT_ITTER_OBJ]);
- }
- new
- object;
- for (i = 0; i < MAY_OBJECTS; i++)
- {
- new
- objectid = i + 1;
- if ((object = YSI_g_sPlayerObjects[playerid][i] & 0xFFFFFF) != (NO_OBJECT & 0xFFFFFF) && IsValidPlayerObject(playerid, objectid))
- {
- if (YSI_g_sSomethingMoved != NO_OBJECT)
- {
- new
- e_OBJ_FLAG:flag = YSI_g_sObjects[object][E_OBJECT_MODEL];
- if (Bit_Get(objects, object) && !(flag & e_OBJ_FLAG_RECREATED))
- {
- #if !defined NO_OBJECTS_MOVE
- if (flag & e_OBJ_FLAG_ATTACHED)
- {
- AttachPlayerObjectToPlayer(playerid, objectid, Object_GetAttach(object), YSI_g_sObjects[object][E_OBJECT_X], YSI_g_sObjects[object][E_OBJECT_Y], YSI_g_sObjects[object][E_OBJECT_Z], YSI_g_sObjects[object][E_OBJECT_RX], YSI_g_sObjects[object][E_OBJECT_RY], YSI_g_sObjects[object][E_OBJECT_RZ]);
- }
- if (flag & e_OBJ_FLAG_MOVED != e_OBJ_FLAG:YSI_g_sPlayerObjects[playerid][i] & e_OBJ_FLAG_MOVED)
- {
- YSI_g_sPlayerObjects[playerid][i] = (YSI_g_sPlayerObjects[playerid][i] & 0xFFFFFF) | _:(flag & e_OBJ_FLAG_MOVED);
- MovePlayerObject(playerid, objectid, YSI_g_sObjects[object][E_OBJECT_MX], YSI_g_sObjects[object][E_OBJECT_MY], YSI_g_sObjects[object][E_OBJECT_MZ], YSI_g_sObjects[object][E_OBJECT_MS]);
- flag |= e_OBJ_FLAG_JUMPED;
- }
- #endif
- if (flag & e_OBJ_FLAG_JUMPED)
- {
- Object_GetPos(object, x, y, z);
- SetPlayerObjectPos(playerid, objectid, x, y, z);
- }
- if (flag & e_OBJ_FLAG_ROTATED)
- {
- SetPlayerObjectRot(playerid, objectid, YSI_g_sObjects[object][E_OBJECT_RX], YSI_g_sObjects[object][E_OBJECT_RY], YSI_g_sObjects[object][E_OBJECT_RZ]);
- }
- Bit_Set(objects, object, 0, OBJECT_BITS);
- }
- else
- {
- DestroyPlayerObject(playerid, objectid);
- YSI_g_sPlayerObjects[playerid][i] = NO_OBJECT;
- }
- }
- else
- {
- if (Bit_Get(objects, object))
- {
- Bit_Set(objects, object, 0, OBJECT_BITS);
- }
- else
- {
- DestroyPlayerObject(playerid, objectid);
- YSI_g_sPlayerObjects[playerid][i] = NO_OBJECT;
- }
- }
- }
- }
- for (i = objStart; i != -1; i = sObjList[i][E_OBJECT_ITTER_NEXT])
- {
- new
- objSet = sObjList[i][E_OBJECT_ITTER_OBJ],
- e_OBJ_FLAG:flag = YSI_g_sObjects[objSet][E_OBJECT_MODEL];
- if (Bit_Get(objects, objSet))
- {
- new
- obj = CreatePlayerObject(playerid, flag & e_OBJ_FLAG_MODEL, sObjList[i][E_OBJECT_ITTER_X], sObjList[i][E_OBJECT_ITTER_Y], sObjList[i][E_OBJECT_ITTER_Z], YSI_g_sObjects[objSet][E_OBJECT_RX], YSI_g_sObjects[objSet][E_OBJECT_RY], YSI_g_sObjects[objSet][E_OBJECT_RZ]);
- if (obj != 0xFF)
- {
- YSI_g_sPlayerObjects[playerid][obj - 1] = objSet;
- Bit_Set(objects, objSet, 0, OBJECT_BITS);
- #if !defined NO_OBJECTS_MOVE
- if (flag & e_OBJ_FLAG_MOVED)
- {
- MovePlayerObject(playerid, obj, YSI_g_sObjects[objSet][E_OBJECT_MX], YSI_g_sObjects[objSet][E_OBJECT_MY], YSI_g_sObjects[objSet][E_OBJECT_MZ], YSI_g_sObjects[objSet][E_OBJECT_MS]);
- YSI_g_sPlayerObjects[playerid][obj - 1] |= _:(flag & e_OBJ_FLAG_MOVED);
- }
- if (flag & e_OBJ_FLAG_ATTACHED)
- {
- AttachPlayerObjectToPlayer(playerid, obj, Object_GetAttach(objSet), YSI_g_sObjects[objSet][E_OBJECT_X], YSI_g_sObjects[objSet][E_OBJECT_Y], YSI_g_sObjects[objSet][E_OBJECT_Z], YSI_g_sObjects[objSet][E_OBJECT_RX], YSI_g_sObjects[objSet][E_OBJECT_RY], YSI_g_sObjects[objSet][E_OBJECT_RZ]);
- }
- #endif
- }
- }
- }
- }
- if (YSI_g_sSomethingMoved != NO_OBJECT)
- {
- for (new objectid = YSI_g_sSomethingMoved; objectid != NO_OBJECT; objectid = YSI_g_sObjects[objectid][E_OBJECT_UPDATES])
- {
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] &= ~(e_OBJ_FLAG_ATTACHED | e_OBJ_FLAG_JUMPED | e_OBJ_FLAG_ROTATED | e_OBJ_FLAG_RECREATED);
- YSI_g_sObjects[objectid][E_OBJECT_UPDATES] = NO_OBJECT;
- }
- YSI_g_sSomethingMoved = NO_OBJECT;
- }
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_ParseSet
- Params:
- playerid - Player to check for.
- objSet - Pointer to first object in the list.
- Float:x - Player's x position.
- Float:y - Player's y position.
- Float:z - Player's z position.
- world - Player's world.
- objList[][E_OBJECT_ITTER] - List of closest objects.
- &objStart - Entrypoint to list.
- &objEnd - Last object in list.
- &objCount - Number of objects in list.
- bool:dynam - Is this the dynamic objSet.
- Return:
- -
- Notes:
- Itterates through the linked list for one sector of objects and checks
- their real location relative to the player, if in range displays them.
- -*----------------------------------------------------------------------------*/
- static Object_ParseSet(playerid, objSet, Float:x, Float:y, Float:z, world, objList[][E_OBJECT_ITTER], &objStart, &objEnd, &objCount, bool:dynam)
- {
- if (objSet == NO_OBJECT) return;
- new
- #if !defined NO_OBJECTS_MOVE && defined NO_OBJECT_ATTACH
- attach,
- #endif
- start = objSet,
- Float:px,
- Float:py,
- Float:pz,
- Float:diff;
- do
- {
- new
- e_OBJ_FLAG:flag = YSI_g_sObjects[objSet][E_OBJECT_MODEL];
- if (flag & e_OBJ_FLAG_ACTIVE)
- {
- if (Object_HasPlayer(objSet, playerid, world))
- {
- #if !defined NO_OBJECT_ATTACH
- Object_GetPos(objSet, px, py, pz);
- #pragma unused dynam
- #else
- #if !defined NO_OBJECTS_MOVE
- if (!dynam || (attach = Object_GetAttach(YSI_g_sObjects[objSet][E_OBJECT_MODEL])) == NO_ATTACH_PLAYER || !IsPlayerConnected(attach))
- {
- #endif
- px = YSI_g_sObjects[objSet][E_OBJECT_X];
- py = YSI_g_sObjects[objSet][E_OBJECT_Y];
- pz = YSI_g_sObjects[objSet][E_OBJECT_Z];
- #if !defined NO_OBJECTS_MOVE
- }
- else
- {
- GetPlayerPos(attach, px, py, pz);
- px += YSI_g_sObjects[objSet][E_OBJECT_X];
- py += YSI_g_sObjects[objSet][E_OBJECT_Y];
- pz += YSI_g_sObjects[objSet][E_OBJECT_Z];
- }
- #else
- #pragma unused dynam
- #endif
- #endif
- new
- Float:ox = px - x,
- Float:oy = py - y,
- Float:oz = pz - z;
- diff = ((ox * ox) + (oy * oy) + (oz * oz)) / YSI_g_sObjects[objSet][E_OBJECT_VIEW];
- if (diff < 1.0)
- {
- if (objStart == -1)
- {
- objList[0][E_OBJECT_ITTER_NEXT] = -1;
- objList[0][E_OBJECT_ITTER_LAST] = -1;
- objList[0][E_OBJECT_ITTER_OBJ] = objSet;
- objList[0][E_OBJECT_ITTER_DISTANCE] = diff;
- objList[0][E_OBJECT_ITTER_X] = px;
- objList[0][E_OBJECT_ITTER_Y] = py;
- objList[0][E_OBJECT_ITTER_Z] = pz;
- objStart = 0;
- objEnd = 0;
- objCount = 1;
- }
- else if (objCount < MAY_OBJECTS)
- {
- objList[objCount][E_OBJECT_ITTER_OBJ] = objSet;
- objList[objCount][E_OBJECT_ITTER_DISTANCE] = diff;
- objList[objCount][E_OBJECT_ITTER_X] = px;
- objList[objCount][E_OBJECT_ITTER_Y] = py;
- objList[objCount][E_OBJECT_ITTER_Z] = pz;
- if (objList[objEnd][E_OBJECT_ITTER_DISTANCE] < diff)
- {
- objList[objCount][E_OBJECT_ITTER_LAST] = objEnd;
- objList[objCount][E_OBJECT_ITTER_NEXT] = -1;
- objList[objEnd][E_OBJECT_ITTER_NEXT] = objCount;
- objEnd = objCount++;
- }
- else
- {
- new
- i = objStart,
- j = -1;
- while (objList[i][E_OBJECT_ITTER_DISTANCE] < diff) i = objList[(j = i)][E_OBJECT_ITTER_NEXT];
- objList[objCount][E_OBJECT_ITTER_NEXT] = i;
- objList[objCount][E_OBJECT_ITTER_LAST] = j;
- objList[i][E_OBJECT_ITTER_LAST] = objCount;
- if (j == -1) objStart = objCount++;
- else objList[j][E_OBJECT_ITTER_NEXT] = objCount++;
- }
- }
- else if (objList[objEnd][E_OBJECT_ITTER_DISTANCE] > diff)
- {
- new
- i = objStart,
- j = -1,
- newend = objList[objEnd][E_OBJECT_ITTER_LAST];
- while (objList[i][E_OBJECT_ITTER_DISTANCE] < diff) i = objList[(j = i)][E_OBJECT_ITTER_NEXT];
- objList[objEnd][E_OBJECT_ITTER_OBJ] = objSet;
- objList[objEnd][E_OBJECT_ITTER_DISTANCE] = diff;
- objList[objEnd][E_OBJECT_ITTER_X] = px;
- objList[objEnd][E_OBJECT_ITTER_Y] = py;
- objList[objEnd][E_OBJECT_ITTER_Z] = pz;
- if (i != objEnd)
- {
- objList[objEnd][E_OBJECT_ITTER_NEXT] = i;
- objList[objEnd][E_OBJECT_ITTER_LAST] = j;
- objList[i][E_OBJECT_ITTER_LAST] = objEnd;
- if (j == -1) objStart = objEnd;
- else objList[j][E_OBJECT_ITTER_NEXT] = objEnd;
- objEnd = newend;
- objList[newend][E_OBJECT_ITTER_NEXT] = -1;
- }
- }
- }
- }
- }
- objSet = YSI_g_sObjects[objSet][E_OBJECT_NEXT];
- }
- while (objSet != start);
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_FindSectors
- Params:
- playerid - Player we're finding the sectors for.
- Float:x - X location to check.
- Float:y - Y location to check.
- sectors[OBJECT_VIEW_SECTORS][E_OSEC_ITTER] - Array to store all visible sectors.
- &secStart - Start point to itterator
- Return:
- -
- Notes:
- Finds all the sectors which encompas points within the sight range of the
- player. Initial checks are done as a square so some returned sectors may
- not have points within a circular range of the player.
-
- The original version tested if the edges of each sector were visible and
- if not excluded them from the list. This would have been faster in terms
- of objects checked but slower if there were no objects, which is likely to
- be more frequently the case. The code also didn't actually work but that's
- a minor point as the theory was there. This is also alot neater.
-
- Rewritten to not use Object_FindSector on a new area, just calculate the
- area from known initial area.
-
- Now also only returns the zones visible, not the zones theoretically
- visible (still assumes square vision though which the code doesn't use).
- -*----------------------------------------------------------------------------*/
- static Object_FindSectors(playerid, Float:x, Float:y, sectors[][E_OSEC_ITTER], &secStart)
- {
- static
- sLastCheck[MAX_PLAYERS],
- sLX[MAX_PLAYERS] = {cellmin, ...},
- sLY[MAX_PLAYERS] = {cellmax, ...};
- new
- xsector = floatround(((x - OBJECT_BOUNDS_MINX) / YSI_g_sXSectorSize), floatround_floor),
- ysector = floatround(((y - OBJECT_BOUNDS_MINY) / YSI_g_sYSectorSize), floatround_floor);
- if (!sLastCheck[playerid] || sLX[playerid] != xsector || sLY[playerid] != ysector)
- {
- secStart = -1;
- new
- go = 0,
- Float:diff = 10.0,
- xstart = -OBJECT_VIEW_RATIO,
- xend = OBJECT_VIEW_RATIO,
- ystart = -OBJECT_VIEW_RATIO,
- yend = OBJECT_VIEW_RATIO,
- k;
- if (xsector < -OBJECT_VIEW_RATIO)
- {
- xstart = cellmax;
- go = 1;
- diff = 0.0;
- }
- else if (xsector < OBJECT_VIEW_RATIO)
- {
- xstart = 0 - xsector;
- go = 1;
- new
- Float:nd = ((x - OBJECT_BOUNDS_MINX) * (x - OBJECT_BOUNDS_MINX)) / (OBJECT_MAX_VIEW_DISTANCE * OBJECT_MAX_VIEW_DISTANCE);
- if (nd < diff) diff = nd;
- }
- if (ysector < -OBJECT_VIEW_RATIO)
- {
- ystart = cellmax;
- go = 1;
- diff = 0.0;
- }
- else if (ysector < OBJECT_VIEW_RATIO)
- {
- ystart = 0 - ysector;
- go = 1;
- new
- Float:nd = ((y - OBJECT_BOUNDS_MINY) * (y - OBJECT_BOUNDS_MINY)) / (OBJECT_MAX_VIEW_DISTANCE * OBJECT_MAX_VIEW_DISTANCE);
- if (nd < diff) diff = nd;
- }
- if (xsector >= OBJECT_SECTOR_X_EDGE + OBJECT_VIEW_RATIO)
- {
- xend = cellmin;
- go = 1;
- diff = 0.0;
- }
- else if (xsector >= OBJECT_SECTOR_X_EDGE - OBJECT_VIEW_RATIO)
- {
- xend = OBJECT_SECTOR_X_EDGE - (xsector + 1);
- if (xsector >= OBJECT_SECTOR_X_EDGE)
- {
- go = 1;
- diff = 0.0;
- }
- else if (go == -1 || go > xend + 1)
- {
- go = 1;
- new
- Float:nd = ((x - OBJECT_BOUNDS_MAXX) * (x - OBJECT_BOUNDS_MAXX)) / (OBJECT_MAX_VIEW_DISTANCE * OBJECT_MAX_VIEW_DISTANCE);
- if (nd < diff) diff = nd;
- }
- }
- if (ysector >= OBJECT_SECTOR_Y_EDGE + OBJECT_VIEW_RATIO)
- {
- yend = cellmin;
- go = 1;
- diff = 0.0;
- }
- else if (ysector >= OBJECT_SECTOR_Y_EDGE - OBJECT_VIEW_RATIO)
- {
- yend = OBJECT_SECTOR_Y_EDGE - (ysector + 1);
- if (ysector >= OBJECT_SECTOR_Y_EDGE)
- {
- go = 1;
- diff = 0.0;
- }
- else if (go == -1 || go > yend + 1)
- {
- go = 1;
- new
- Float:nd = ((y - OBJECT_BOUNDS_MAXY) * (y - OBJECT_BOUNDS_MAXY)) / (OBJECT_MAX_VIEW_DISTANCE * OBJECT_MAX_VIEW_DISTANCE);
- if (nd < diff) diff = nd;
- }
- }
- if (go)
- {
- go = 0;
- sectors[0][E_OSEC_ITTER_SECTOR] = OBJECT_NO_SECTOR;
- sectors[0][E_OSEC_ITTER_DIFF] = diff;
- sectors[0][E_OSEC_ITTER_NEXT] = -1;
- secStart = 0;
- k = 1;
- }
- else secStart = -1;
- for (new i = xstart; i <= xend; i++)
- {
- new
- xsec = xsector + i;
- new
- Float:xsmin = x - YSI_g_sXSectorLocations[xsec + 1],
- Float:xsmax = YSI_g_sXSectorLocations[xsec] - x;
- if (i > 0)
- {
- if (xsmax < OBJECT_MAX_VIEW_DISTANCE) go = 1;
- else break;
- }
- else if (i < 0)
- {
- if (xsmin < OBJECT_MAX_VIEW_DISTANCE) go = 1;
- }
- else go = 1;
- if (go)
- {
- go = 0;
- for (new j = ystart; j <= yend; j++)
- {
- new
- ysec = ysector + j,
- cursec = (xsec * OBJECT_SECTOR_X_EDGE) + ysec;
- diff = 10.0;
- if (i || j)
- {
- new
- Float:ysmin = y - YSI_g_sYSectorLocations[ysec + 1],
- Float:ysmax = YSI_g_sYSectorLocations[ysec] - y;
- if (j > 0)
- {
- if (ysmax < OBJECT_MAX_VIEW_DISTANCE) go = 1;
- else
- {
- yend--;
- break;
- }
- }
- else if (j < 0)
- {
- if (ysmin < OBJECT_MAX_VIEW_DISTANCE) go = 1;
- else ystart++;
- }
- else go = 1;
- if (go)
- {
- go = 0;
- if (!i) diff = (j < 0) ? (ysmin * ysmin) : (ysmax * ysmax);
- else if (!j) diff = (i < 0) ? (xsmin * xsmin) : (xsmax * xsmax);
- else if (i < 0) diff = (j < 0) ? ((ysmin * ysmin) + (xsmin * xsmin)) : ((ysmax * ysmax) + (xsmin * xsmin));
- else if (i > 0) diff = (j < 0) ? ((ysmin * ysmin) + (xsmax * xsmax)) : ((ysmax * ysmax) + (xsmax * xsmax));
- diff /= YSI_g_sObjectSectors[cursec][E_OBJ_SECTOR_MAX_VIEW];
- }
- }
- else diff = 0.0;
- if (diff < 1.0)
- {
- new
- itterCur = secStart,
- itterLast = -1;
- while (itterCur != -1 && sectors[itterCur][E_OSEC_ITTER_DIFF] < diff) itterCur = sectors[(itterLast = itterCur)][E_OSEC_ITTER_NEXT];
- if (itterLast == -1) secStart = k;
- else sectors[itterLast][E_OSEC_ITTER_NEXT] = k;
- sectors[k][E_OSEC_ITTER_NEXT] = itterCur;
- sectors[k][E_OSEC_ITTER_SECTOR] = cursec;
- sectors[k][E_OSEC_ITTER_DIFF] = diff;
- k++;
- }
- }
- }
- }
- sLastCheck[playerid] = SECTOR_CHECK_FREQUENCY;
- sLX[playerid] = xsector;
- sLY[playerid] = ysector;
- }
- sLastCheck[playerid]--;
- return 1;
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_IsValidModel
- Params:
- modelid - Model to check won't crash SA.
- Return:
- -
- Notes:
- I wrote this function a long time ago and have barely updated it at all.
- The only changes are the formatting and the use of the Bit class now,
- despite the fact this was the first large bit array I did and is thus
- the founding array of the whole idea behind the bit class.
- -*----------------------------------------------------------------------------*/
- stock Object_IsValidModel(modelid)
- {
- static
- modeldat[] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128,
- -515899393, -134217729, -1, -1, 33554431, -1, -1, -1, -14337, -1, -33,
- 127, 0, 0, 0, 0, 0, -8388608, -1, -1, -1, -16385, -1, -1, -1, -1, -1,
- -1, -1, -33, -1, -771751937, -1, -9, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 33554431, -25, -1, -1, -1, -1, -1, -1,
- -1073676289, -2147483648, 34079999, 2113536, -4825600, -5, -1, -3145729,
- -1, -16777217, -63, -1, -1, -1, -1, -201326593, -1, -1, -1, -1, -1,
- -257, -1, 1073741823, -133122, -1, -1, -65, -1, -1, -1, -1, -1, -1,
- -2146435073, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1073741823, -64, -1,
- -1, -1, -1, -2635777, 134086663, 0, -64, -1, -1, -1, -1, -1, -1, -1,
- -536870927, -131069, -1, -1, -1, -1, -1, -1, -1, -1, -16384, -1,
- -33554433, -1, -1, -1, -1, -1, -1610612737, 524285, -128, -1,
- 2080309247, -1, -1, -1114113, -1, -1, -1, 66977343, -524288, -1, -1, -1,
- -1, -2031617, -1, 114687, -256, -1, -4097, -1, -4097, -1, -1,
- 1010827263, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -32768, -1, -1, -1, -1, -1,
- 2147483647, -33554434, -1, -1, -49153, -1148191169, 2147483647,
- -100781080, -262145, -57, 134217727, -8388608, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1048577, -1, -449, -1017, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1835009, -2049, -1, -1, -1, -1, -1, -1,
- -8193, -1, -536870913, -1, -1, -1, -1, -1, -87041, -1, -1, -1, -1, -1,
- -1, -209860, -1023, -8388609, -2096897, -1, -1048577, -1, -1, -1, -1,
- -1, -1, -897, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1610612737,
- -3073, -28673, -1, -1, -1, -1537, -1, -1, -13, -1, -1, -1, -1, -1985,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1056964609, -1, -1, -1,
- -1, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -236716037, -1, -1, -1, -1, -1, -1, -1, -536870913, 3, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -2097153, -2109441, -1, 201326591, -4194304, -1, -1,
- -241, -1, -1, -1, -1, -1, -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, -32768, -1, -1, -1, -2, -671096835, -1, -8388609, -66323585, -13,
- -1793, -32257, -247809, -1, -1, -513, 16252911, 0, 0, 0, -131072,
- 33554383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8356095, 0, 0, 0, 0, 0,
- 0, -256, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -268435449, -1, -1, -2049, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 92274627, -65536, -2097153, -268435457, 591191935, 1, 0, -16777216, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 127
- };
- return Bit_Get(Bit:modeldat, modelid);
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_OnPlayerDisconnect
- Params:
- playerid - Player who left.
- reason - Why they left.
- Return:
- -
- Notes:
- Just to automatically disconnect attached objects from players.
- -*----------------------------------------------------------------------------*/
- Object_OnPlayerDisconnect(playerid, reason)
- {
- #if defined _YSI_SETUP_MASTER
- if (!YSI_g_sIsMaster) return 0;
- #endif
- for (new objectid = 0; objectid < MAY_OBJECTS; objectid++)
- {
- YSI_g_sPlayerObjects[playerid][objectid] = NO_OBJECT;
- }
- #if !defined NO_OBJECTS_MOVE
- new
- sets = YSI_g_sMovingObjects;
- if (sets == NO_OBJECT) return 0;
- new
- start = sets;
- do
- {
- new
- e_OBJ_FLAG:flag = YSI_g_sObjects[sets][E_OBJECT_MODEL];
- if (flag & e_OBJ_FLAG_ACTIVE)
- {
- if (Object_GetAttach(flag) == playerid) DetachDynamicObjectFromPlayer(sets);
- }
- sets = YSI_g_sObjects[sets][E_OBJECT_NEXT];
- }
- while (sets != start);
- #endif
- return 1;
- #pragma unused reason
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_SetAreaGate
- Params:
- objectid - Object to make into a gate.
- areaid - Area to trigger gate in.
- Float:tx - X point to open to.
- Float:ty - Y point to open to.
- Float:tz - Z point to open to.
- Float:ts - Speed to open at.
- Return:
- -
- Notes:
- Just to automatically disconnect attached objects from players.
- -*----------------------------------------------------------------------------*/
- stock Object_SetAreaGate(objectid, areaid, Float:tx, Float:ty, Float:tz, Float:ts, time = 10000)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- #if !defined NO_OBJECTS_MOVE
- #if defined _YSI_VISUAL_AREAS
- if (Object_IsValid(objectid) && !Object_IsAttached(YSI_g_sObjects[objectid][E_OBJECT_MODEL]) && Area_IsValid(areaid))
- {
- new
- gate;
- while (gate < MAX_GATE_OBJECTS)
- {
- if (!YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT]) break;
- gate++;
- }
- if (gate == MAX_GATE_OBJECTS) return NO_GATE;
-
- YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] = objectid | GATE_AREA_TRIGGER;
- YSI_g_sGateInfo[gate][E_GATE_INFO_TIME] = time;
- YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER] = areaid;
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] |= e_OBJ_FLAG_GATE;
- Object_SetGateTarget(gate, tx, ty, tz, ts);
- #if !defined NO_GATE_AREA_LOOKUP
- new
- slot = areaid / 2,
- shift = (areaid % 2) * 16;
- YSI_g_sGateAreas[slot] = (YSI_g_sGateAreas[slot] & (0xFFFF0000 >>> shift)) | (gate << shift);
- #endif
- return gate;
- }
- #endif
- #endif
- return NO_GATE;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- DBGP4("Object_SetAreaGate() else: %d %d %d", objectid, areaid, time);
- CallRemoteFunction("Object_Remote", "iii", objectid, areaid, E_OBJECT_REMOTE_GATE | (time << 12));
- new
- gate = getproperty(0, "YSIReq");
- DBGP4("Object_SetAreaGate() gate: %d %d", gate, NO_GATE);
- if (gate != NO_GATE)
- {
- DBGP3("Object_SetAreaGate() ok: %.2f %.2f %.2f %.2f", tx, ty, tz, ts);
- CallRemoteFunction("Object_CoOrdRemote", "iiffff", gate, E_OBJECT_REMOTE_GATE_POS, tx, ty, tz, ts);
- }
- return gate;
- }
- #endif
- }
- #if defined _YSI_VISUAL_AREAS
- /*----------------------------------------------------------------------------*-
- Function:
- Object_OnPlayerEnterArea
- Params:
- playerid - Player who entered an area.
- areaid - Area they entered.
- Return:
- -
- Notes:
- Internal callback from YSI_areas.
- -*----------------------------------------------------------------------------*/
- #if defined _YSI_SETUP_MASTER
- public Object_OnPlayerEnterArea(playerid, areaid)
- if (!YSI_g_sIsMaster) return 0;
- else
- #else
- Object_OnPlayerEnterArea(playerid, areaid)
- #endif
- {
- DBGP2("Object_OnPlayerEnterArea() start");
- #if defined _YSI_SETUP_MASTER
- setproperty(0, "YSIReq", 0);
- #else
- #pragma unused playerid
- #endif
- #if defined NO_OBJECTS_MOVE
- return 0;
- #else
- new
- gate;
- #if defined NO_GATE_AREA_LOOKUP
- DBGP3("Object_OnPlayerEnterArea() Lookup");
- while (gate < MAX_GATE_OBJECTS)
- {
- if (YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & GATE_AREA_TRIGGER && YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER] == areaid) break;
- }
- if (gate == MAX_GATE_OBJECTS) return 0;
- #else
- gate = (YSI_g_sGateAreas[areaid / 2] >>> ((areaid % 2) * 16)) & 0xFFFF;
- DBGP3("Object_OnPlayerEnterArea() Known %d %d %d", areaid, gate, YSI_g_sGateAreas[areaid / 2]);
- if (gate == 0xFFFF) return 0;
- #endif
- #if defined _YSI_SETUP_MASTER
- setproperty(0, "YSIReq", 1);
- #endif
- DBGP3("Object_OnPlayerEnterArea() Get");
- new
- objectid = YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & (~(GATE_AREA_TRIGGER | GATE_OPENING));
- if (Object_IsValid(objectid))
- {
- DBGP3("Object_OnPlayerEnterArea() Valid");
- if (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_MOVED || YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & GATE_OPENING) return 1;
- DBGP3("Object_OnPlayerEnterArea() Static");
- new
- Float:x,
- Float:y,
- Float:z,
- Float:tx = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] >> 14) & 0x1FFFF) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] & 0x80000000) ? (-1.0) : (1.0)) / 10.0),
- Float:ty = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] & 0x03FFF) | ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] >> 14) & 0x1C000)) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x80000000) ? (-1.0) : (1.0)) / 10.0),
- Float:tz = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] >> 10) & 0x1FFFF) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x08000000) ? (-1.0) : (1.0)) / 10.0),
- Float:s = (float(YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x3FF) / 10.0);
- Object_GetPos(objectid, x, y, z);
- YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] |= GATE_OPENING;
- Object_SetGateTarget(gate, x, y, z, s);
- Object_Move(objectid, tx, ty, tz, s);
- Object_AddToUpdate(objectid);
- DBGP3("Object_OnPlayerEnterArea() Moved");
- }
- else
- {
- YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER] = NO_GATE;
- #if !defined NO_GATE_AREA_LOOKUP
- YSI_g_sGateAreas[areaid / 2] |= 0xFFFF << ((areaid % 2) * 16);
- #endif
- Area_Delete(areaid);
- }
- DBGP3("Object_OnPlayerEnterArea() end");
- return 1;
- #endif
- }
- #endif
- #if !defined NO_OBJECTS_MOVE
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GateMoved
- Params:
- objectid - Object that moved.
- Return:
- -
- Notes:
- Checks if the object which moved is a gate.
- -*----------------------------------------------------------------------------*/
- static stock Object_GateMoved(objectid)
- {
- #if defined _YSI_VISUAL_AREAS
- if (YSI_g_sObjects[objectid][E_OBJECT_MODEL] & e_OBJ_FLAG_GATE)
- {
- new
- gate = 0;
- while (gate < MAX_GATE_OBJECTS)
- {
- if (objectid == (YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & (~(GATE_AREA_TRIGGER | GATE_OPENING)))) break;
- gate++;
- }
- if (gate == MAX_GATE_OBJECTS)
- {
- YSI_g_sObjects[objectid][E_OBJECT_MODEL] &= ~e_OBJ_FLAG_GATE;
- return 0;
- }
- if (YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & (GATE_AREA_TRIGGER | GATE_OPENING) == (GATE_AREA_TRIGGER | GATE_OPENING))
- {
- SetTimerEx("Object_GateClose", 500000, 0, "i", gate);
- }
- return 1;
- }
- #else
- #pragma unused objectid
- #endif
- return 0;
- }
- #endif
- #if defined _YSI_VISUAL_AREAS
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GateClose
- Params:
- gate - Gate to close.
- Return:
- -
- Notes:
- Closes an area triggered gate after a delay.
- -*----------------------------------------------------------------------------*/
- public Object_GateClose(gate)
- {
- if (Area_IsEmpty(YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER]))
- {
- new
- objectid = YSI_g_sGateInfo[gate][E_GATE_INFO_OBJECT] & ~(GATE_AREA_TRIGGER | GATE_OPENING);
- if (Object_IsValid(objectid))
- {
- new
- Float:x,
- Float:y,
- Float:z,
- Float:tx = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] >> 14) & 0x1FFFF) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] & 0x80000000) ? (-0.1) : (0.1))),
- Float:ty = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_XY] & 0x03FFF) | ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] >> 14) & 0x1C000)) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x80000000) ? (-0.1) : (0.1))),
- Float:tz = (float((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] >> 10) & 0x1FFFF) * ((YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x08000000) ? (-0.1) : (0.1))),
- Float:s = (float(YSI_g_sGateInfo[gate][E_GATE_INFO_ZA] & 0x3FF) / 10.0);
- Object_GetPos(objectid, x, y, z);
- Object_SetGateTarget(gate, x, y, z, s);
- Object_Move(objectid, tx, ty, tz, s);
- Object_AddToUpdate(objectid);
- }
- else
- {
- new
- areaid = YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER];
- YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER] = NO_GATE;
- #if !defined NO_GATE_AREA_LOOKUP
- YSI_g_sGateAreas[areaid / 2] |= 0xFFFF << ((areaid % 2) * 16);
- #endif
- Area_Delete(areaid);
- }
- }
- else
- {
- SetTimerEx("Object_GateClose", 1000, 0, "i", gate);
- }
- }
- #endif
- /*----------------------------------------------------------------------------*-
- Function:
- CreateGate
- Params:
- modelid - Model of the gate.
- Float:x - X start location.
- Float:y - Y start location.
- Float:z - Z start location.
- Float:tx - X target location.
- Float:ty - Y target location.
- Float:tz - Z target location.
- Float:rx - X rotation.
- Float:ry - Y rotation.
- Float:rz - Z rotation.
- Float:speed - Speed the gate will move at.
- Return:
- -
- Notes:
- Creates a gate.
- -*----------------------------------------------------------------------------*/
- stock CreateGate(modelid, Float:x, Float:y, Float:z, Float:tx, Float:ty, Float:tz, Float:rx = 0.0, Float:ry = 0.0, Float:rz = 0.0, Float:speed = 2.0)
- {
- #if defined _YSI_VISUAL_AREAS
- new
- obj = CreateDynamicObject(modelid, x, y, z, rx, ry, rz);
- if (obj == NO_OBJECT) return NO_GATE;
- new
- Float:xx = floatabs(x - tx),
- Float:yy = floatabs(y - ty),
- area = Area_AddCircle(x, y, ((yy > xx) ? (yy) : (xx)) * 2.0, z + 20.0);
- if (area == NO_AREA)
- {
- DestroyDynamicObject(obj);
- return NO_GATE;
- }
- return Object_SetAreaGate(obj, area, tx, ty, tz, speed, 10000);
- #else
- #pragma unused modelid, x, y, z, tx, ty, tz, rx, ry, rz, speed
- return NO_GATE;
- #endif
- }
- /*----------------------------------------------------------------------------*-
- Function:
- Object_GetGateArea
- Params:
- gate - Gate to get the area of for permissions.
- Return:
- -
- Notes:
- Returns the areaid used by the gate for detection.
- -*----------------------------------------------------------------------------*/
- stock Object_GetGateArea(gate)
- {
- #if defined _YSI_SETUP_MASTER
- if (YSI_g_sIsMaster)
- {
- #endif
- #if defined _YSI_VISUAL_AREAS
- if (gate >= 0 && gate < MAX_GATE_OBJECTS)
- {
- return YSI_g_sGateInfo[gate][E_GATE_INFO_TRIGGER];
- }
- #else
- #pragma unused gate
- #endif
- return -1;
- #if defined _YSI_SETUP_MASTER
- }
- else
- {
- CallRemoteFunction("Object_Remote", "iii", gate, 0, E_OBJECT_REMOTE_GET_AREA);
- return getproperty(0, "YSIReq");
- }
- #endif
- }
|