From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/zone__manager_8cpp-source.html | 280 ++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 docs/doxygen/nel/zone__manager_8cpp-source.html (limited to 'docs/doxygen/nel/zone__manager_8cpp-source.html') diff --git a/docs/doxygen/nel/zone__manager_8cpp-source.html b/docs/doxygen/nel/zone__manager_8cpp-source.html new file mode 100644 index 00000000..fcb93c6f --- /dev/null +++ b/docs/doxygen/nel/zone__manager_8cpp-source.html @@ -0,0 +1,280 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

zone_manager.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX D.T.C. SYSTEM.
+00010  * NEVRAX D.T.C. SYSTEM is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX D.T.C. SYSTEM is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX D.T.C. SYSTEM; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 #include <iostream>
+00029 
+00030 #include "3d/zone_manager.h"
+00031 #include "nel/misc/path.h"
+00032 #include "nel/misc/file.h"
+00033 
+00034 using namespace std;
+00035 using namespace NLMISC;
+00036 
+00037 
+00038 namespace NL3D
+00039 {
+00040 
+00041 // ------------------------------------------------------------------------------------------------
+00042 // CZoneManager
+00043 // ------------------------------------------------------------------------------------------------
+00044 
+00045 // ------------------------------------------------------------------------------------------------
+00046 CZoneManager::CZoneManager()
+00047 {
+00048         _Zone = NULL;
+00049         _AddingZone= false;
+00050         _RemovingZone= false;
+00051         _WorkInProgress = false;
+00052 }
+00053 
+00054 // ------------------------------------------------------------------------------------------------
+00055 CZoneManager::~CZoneManager()
+00056 {
+00057 }
+00058 
+00059 // ------------------------------------------------------------------------------------------------
+00060 void CZoneManager::checkZonesAround (uint x, uint y, uint area)
+00061 {
+00062         _WorkInProgress = true;
+00063         if ((_AddingZone) || (_RemovingZone)) return;
+00064 
+00065         // Obtain the new set of zones around
+00066         if ((x != _LastX) || (y != _LastY))
+00067                 getListZoneId (x, y, area, _ZoneList);
+00068         _LastX = x;
+00069         _LastY = y;
+00070 
+00071         // Look if we have zone loaded that is not needed anymore
+00072         uint32 i, j;
+00073         for (i = 0; i < _LoadedZones.size(); ++i)
+00074         {
+00075                 // If the loadedzone i do not appear in the zone list so we have to remove it
+00076                 bool bFound = false;
+00077                 uint16 nLoadedZone = _LoadedZones[i];
+00078                 for (j = 0; j < _ZoneList.size(); ++j)
+00079                 {
+00080                         if (_ZoneList[j] == nLoadedZone)
+00081                         {
+00082                                 bFound = true;
+00083                                 break;
+00084                         }
+00085                 }
+00086 
+00087                 if (!bFound)
+00088                 {
+00089                         // Remove the zone nLoadedZone
+00090                         _IdZoneToRemove = nLoadedZone;
+00091                         _RemovingZone = true;
+00092                         return;
+00093                 }
+00094         }
+00095 
+00096         // Look if we have zone not already loaded
+00097         for (i = 0; i < _ZoneList.size(); ++i)
+00098         {
+00099                 // If the zone requested do not appear in the zone loaded list so we have to load it
+00100                 bool bFound = false;
+00101                 uint16 nZone = _ZoneList[i];
+00102                 for (j = 0; j < _LoadedZones.size(); ++j)
+00103                 {
+00104                         if (_LoadedZones[j] == nZone)
+00105                         {
+00106                                 bFound = true;
+00107                                 break;
+00108                         }
+00109                 }
+00110 
+00111                 if (!bFound)
+00112                 {
+00113                         // We have to load this zone ! and return because only one load at a time
+00114                         _AddingZone = true;
+00115                         CAsyncFileManager &rAFM = CAsyncFileManager::getInstance();
+00116                         _ZoneToAddName = getZoneNameFromId(nZone);
+00117                         _ZoneToAddId = nZone;
+00118                         rAFM.addTask (new CZoneLoadingTask(_ZoneToAddName, &_Zone) );
+00119                         return;
+00120                 }
+00121         }
+00122         _WorkInProgress = false;
+00123 }
+00124 
+00125 // ------------------------------------------------------------------------------------------------
+00126 bool CZoneManager::isWorkComplete (CZoneManager::SZoneManagerWork &rWork)
+00127 {
+00128         // Check if the work is a loading
+00129         if (_AddingZone)
+00130         {
+00131                 if (_Zone != NULL)
+00132                 {
+00133                         _AddingZone= false;
+00134                         rWork.ZoneAdded = true;
+00135                         rWork.NameZoneAdded = _ZoneToAddName;
+00136                         rWork.ZoneRemoved = false;
+00137                         rWork.IdZoneToRemove = 0;
+00138                         rWork.NameZoneRemoved = "";
+00139                         rWork.Zone = const_cast<CZone*>(_Zone);
+00140                         _LoadedZones.push_back (_ZoneToAddId);
+00141                         return true;
+00142                 }
+00143                 else
+00144                 {
+00145                         return false;
+00146                 }
+00147 
+00148         }
+00149         if (_RemovingZone)
+00150         {
+00151                 _RemovingZone = false;
+00152                 rWork.ZoneAdded = false;
+00153                 rWork.NameZoneAdded = "";
+00154                 rWork.ZoneRemoved = true;
+00155                 rWork.IdZoneToRemove = _IdZoneToRemove;
+00156                 rWork.NameZoneRemoved = getZoneNameFromId(_IdZoneToRemove);
+00157                 uint32 i, j;
+00158                 for (i = 0 ; i < _LoadedZones.size(); ++i)
+00159                         if (_LoadedZones[i] == _IdZoneToRemove)
+00160                                 break;
+00161                 if (i < _LoadedZones.size())
+00162                 {
+00163                         for (j = i; j < _LoadedZones.size()-1; ++j)
+00164                                 _LoadedZones[j] = _LoadedZones[j+1];
+00165                         _LoadedZones.resize(_LoadedZones.size()-1);
+00166                 }
+00167                 rWork.Zone = NULL;
+00168                 return true;
+00169         }
+00170         return false;
+00171 }
+00172 
+00173 // ------------------------------------------------------------------------------------------------
+00174 // CZoneLoadingTask
+00175 // ------------------------------------------------------------------------------------------------
+00176 
+00177 // ------------------------------------------------------------------------------------------------
+00178 CZoneLoadingTask::CZoneLoadingTask(const std::string &sZoneName, TVolatileZonePtr *ppZone)
+00179 {
+00180         *ppZone = NULL;
+00181         _Zone = ppZone;
+00182         _ZoneName = sZoneName;
+00183 }
+00184 
+00185 // ------------------------------------------------------------------------------------------------
+00186 void CZoneLoadingTask::run(void)
+00187 {
+00188         // Lookup the zone
+00189         string zonePathLookup = CPath::lookup (_ZoneName, false, false, true);
+00190         if (zonePathLookup == "")
+00191                 zonePathLookup = _ZoneName;
+00192 
+00193         CZone *ZoneTmp = new CZone;
+00194         CIFile file;
+00195         if(file.open(zonePathLookup))
+00196         {
+00197                 ZoneTmp->serial(file);
+00198                 file.close();
+00199                 *_Zone = ZoneTmp;
+00200         }
+00201         else
+00202         {
+00203                 nldebug("CZoneLoadingTask::run(): File not found: %s", zonePathLookup.c_str ());
+00204                 delete ZoneTmp;
+00205                 *_Zone = (CZone*)-1; // Return error
+00206         }
+00207         delete this;
+00208 }
+00209 
+00210 } // NL3D
+00211 
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1