mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 14:56:38 +00:00 
			
		
		
		
	- Remove some files that are no longer in upstream/master
This commit is contained in:
		
							parent
							
								
									8ccec17481
								
							
						
					
					
						commit
						2cef65a056
					
				
					 2 changed files with 0 additions and 859 deletions
				
			
		|  | @ -1,735 +0,0 @@ | |||
| #ifndef _GAME_ESM_RECLISTS_H | ||||
| #define _GAME_ESM_RECLISTS_H | ||||
| 
 | ||||
| #include "components/esm/records.hpp" | ||||
| #include <map> | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include <algorithm> | ||||
| #include <cctype> | ||||
| #include <cassert> | ||||
| #include <stdexcept> | ||||
| #include <iterator> | ||||
| #include    <boost/algorithm/string.hpp> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| using namespace boost::algorithm; | ||||
| 
 | ||||
| namespace ESMS | ||||
| { | ||||
|   using namespace ESM; | ||||
| 
 | ||||
|   struct RecList | ||||
|   { | ||||
|     virtual ~RecList() {} | ||||
| 
 | ||||
|     virtual void load(ESMReader &esm, const std::string &id) = 0; | ||||
|     virtual int getSize() = 0; | ||||
|     virtual void remove(const std::string &id) {}; | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const = 0; | ||||
| 
 | ||||
|     static std::string toLower (const std::string& name) | ||||
|     { | ||||
|         std::string lowerCase; | ||||
| 
 | ||||
|         std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), | ||||
|             (int(*)(int)) std::tolower); | ||||
| 
 | ||||
|         return lowerCase; | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   typedef std::map<int,RecList*> RecListList; | ||||
| 
 | ||||
|   template <typename X> | ||||
|   struct RecListT : RecList | ||||
|   { | ||||
|     virtual ~RecListT() {} | ||||
| 
 | ||||
|     typedef std::map<std::string,X> MapType; | ||||
| 
 | ||||
|     MapType list; | ||||
| 
 | ||||
|     // Load one object of this type
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       std::string id2 = toLower (id); | ||||
|       list[id2].load(esm); | ||||
|     } | ||||
| 
 | ||||
|     // Delete the given object ID. Plugin files support this, so we need to do this, too.
 | ||||
|     void remove(const std::string &id) | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         list.erase(id2); | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID, or return NULL if not found.
 | ||||
|     const X* search(const std::string &id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         typename MapType::const_iterator iter = list.find (id2); | ||||
| 
 | ||||
|         if (iter == list.end()) | ||||
|             return NULL; | ||||
| 
 | ||||
|         return &iter->second; | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID (throws an exception if not found)
 | ||||
|     const X* find(const std::string &id) const | ||||
|     { | ||||
|         const X *object = search (id); | ||||
| 
 | ||||
|         if (!object) | ||||
|             throw std::runtime_error ("object " + id + " not found"); | ||||
| 
 | ||||
|         return object; | ||||
|     } | ||||
| 
 | ||||
|     int getSize() { return list.size(); } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   // Same as RecListT, but does not case-smash the IDs
 | ||||
|   // Note that lookups (search or find) are still case insensitive
 | ||||
|   template <typename X> | ||||
|   struct RecListCaseT : RecList | ||||
|   { | ||||
|     virtual ~RecListCaseT() {} | ||||
| 
 | ||||
|     typedef std::map<std::string,X> MapType; | ||||
| 
 | ||||
|     MapType list; | ||||
| 
 | ||||
|     // Load one object of this type
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|         //std::string id2 = toLower (id);
 | ||||
| 
 | ||||
|         list[id].load(esm); | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID, or return NULL if not found.
 | ||||
|     const X* search(const std::string &id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         for (typename MapType::const_iterator iter = list.begin(); | ||||
|             iter != list.end(); ++iter) | ||||
|         { | ||||
|             if (toLower(iter->first) == id2) | ||||
|                 return &iter->second; | ||||
|         } | ||||
| 
 | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     // non-const version
 | ||||
|     X* search(const std::string &id) | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         for (typename MapType::iterator iter = list.begin(); | ||||
|             iter != list.end(); ++iter) | ||||
|         { | ||||
|             if (toLower(iter->first) == id2) | ||||
|                 return &iter->second; | ||||
|         } | ||||
| 
 | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID (throws an exception if not found)
 | ||||
|     const X* find(const std::string &id) const | ||||
|     { | ||||
|         const X *object = search (id); | ||||
| 
 | ||||
|         if (!object) | ||||
|             throw std::runtime_error ("object " + id + " not found"); | ||||
| 
 | ||||
|         return object; | ||||
|     } | ||||
| 
 | ||||
|     int getSize() { return list.size(); } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|     /// Modified version of RecListT for records, that need to store their own ID
 | ||||
|   template <typename X> | ||||
|   struct RecListWithIDT : RecList | ||||
|   { | ||||
|     virtual ~RecListWithIDT() {} | ||||
| 
 | ||||
|     typedef std::map<std::string,X> MapType; | ||||
| 
 | ||||
|     MapType list; | ||||
| 
 | ||||
|     // Load one object of this type
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       std::string id2 = toLower (id); | ||||
|       list[id2].mId = id2; | ||||
|       list[id2].load(esm); | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID, or return NULL if not found.
 | ||||
|     const X* search(const std::string &id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         typename MapType::const_iterator iter = list.find (id2); | ||||
| 
 | ||||
|         if (iter == list.end()) | ||||
|             return NULL; | ||||
|         return &iter->second; | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID (throws an exception if not found)
 | ||||
|     const X* find(const std::string &id) const | ||||
|     { | ||||
|         const X *object = search (id); | ||||
| 
 | ||||
|         if (!object) | ||||
|             throw std::runtime_error ("object " + id + " not found"); | ||||
| 
 | ||||
|         return object; | ||||
|     } | ||||
| 
 | ||||
|     int getSize() { return list.size(); } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   // The only difference to the above is a slight change to the load()
 | ||||
|   // function. We might merge these together later, and store the id
 | ||||
|   // in all the structs.
 | ||||
|   template <typename X> | ||||
|   struct RecIDListT : RecList | ||||
|   { | ||||
|     virtual ~RecIDListT() {} | ||||
| 
 | ||||
|     typedef std::map<std::string,X> MapType; | ||||
| 
 | ||||
|     MapType list; | ||||
| 
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       std::string id2 = toLower (id); | ||||
|       X& ref = list[id2]; | ||||
| 
 | ||||
|       ref.mId = id; | ||||
|       ref.load(esm); | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID, or return NULL if not found.
 | ||||
|     const X* search(const std::string &id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         typename MapType::const_iterator iter = list.find (id2); | ||||
| 
 | ||||
|         if (iter == list.end()) | ||||
|             return NULL; | ||||
| 
 | ||||
|         return &iter->second; | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID (throws an exception if not found)
 | ||||
|     const X* find(const std::string &id) const | ||||
|     { | ||||
|         const X *object = search (id); | ||||
| 
 | ||||
|         if (!object) | ||||
|             throw std::runtime_error ("object " + id + " not found"); | ||||
| 
 | ||||
|         return object; | ||||
|     } | ||||
| 
 | ||||
|     int getSize() { return list.size(); } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   /* Land textures are indexed by an integer number
 | ||||
|    */ | ||||
|   struct LTexList : RecList | ||||
|   { | ||||
|     virtual ~LTexList() {} | ||||
| 
 | ||||
|     // For multiple ESM/ESP files we need one list per file.
 | ||||
|     typedef std::vector<LandTexture> LandTextureList; | ||||
|     std::vector<LandTextureList> ltex; | ||||
| 
 | ||||
|     LTexList() | ||||
|     { | ||||
|       ltex.push_back(LandTextureList()); | ||||
|       LandTextureList <exl = ltex[0]; | ||||
|       // More than enough to hold Morrowind.esm. Extra lists for plugins will we
 | ||||
|       //  added on-the-fly in a different method.
 | ||||
|       ltexl.reserve(128); | ||||
|     } | ||||
| 
 | ||||
|     const LandTexture* search(size_t index, size_t plugin) const | ||||
|     { | ||||
|       assert(plugin < ltex.size()); | ||||
|       const LandTextureList <exl = ltex[plugin]; | ||||
| 
 | ||||
|       assert(index < ltexl.size()); | ||||
|       return <exl.at(index); | ||||
|     } | ||||
| 
 | ||||
|     // "getSize" returns the number of individual terrain palettes.
 | ||||
|     // "getSizePlugin" returns the number of land textures in a specific palette.
 | ||||
|     int getSize() { return ltex.size(); } | ||||
|     int getSize() const { return ltex.size(); } | ||||
| 
 | ||||
|     int getSizePlugin(size_t plugin) { assert(plugin < ltex.size()); return ltex[plugin].size(); } | ||||
|     int getSizePlugin(size_t plugin) const { assert(plugin < ltex.size()); return ltex[plugin].size(); } | ||||
|      | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const {} | ||||
| 
 | ||||
|     void load(ESMReader &esm, const std::string &id, size_t plugin) | ||||
|     { | ||||
|       LandTexture lt; | ||||
|       lt.load(esm); | ||||
|       lt.mId = id; | ||||
| 
 | ||||
|       // Make sure we have room for the structure
 | ||||
|       if (plugin >= ltex.size()) { | ||||
| 	ltex.resize(plugin+1); | ||||
|       } | ||||
|       LandTextureList <exl = ltex[plugin]; | ||||
|       if(lt.mIndex + 1 > (int)ltexl.size()) | ||||
|         ltexl.resize(lt.mIndex+1); | ||||
| 
 | ||||
|       // Store it
 | ||||
|       ltexl[lt.mIndex] = lt; | ||||
|     } | ||||
| 
 | ||||
|     // Load all terrain palettes at the same size. Inherited virtual function
 | ||||
|     //  from "RecList". Mostly useless, because we need the implementation
 | ||||
|     //  above this one.
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       size_t plugin = esm.getIndex(); | ||||
|       load(esm, id, plugin); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   /* Landscapes are indexed by the X,Y coordinates of the exterior
 | ||||
|      cell they belong to. | ||||
|    */ | ||||
|   struct LandList : RecList | ||||
|   { | ||||
|     virtual ~LandList() | ||||
|     { | ||||
|       for ( LandMap::iterator itr = lands.begin(); itr != lands.end(); ++itr ) | ||||
|       { | ||||
|           delete itr->second; | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     // Map containing all landscapes
 | ||||
|     typedef std::pair<int, int> LandCoord; | ||||
|     typedef std::map<LandCoord, Land*> LandMap; | ||||
|     LandMap lands; | ||||
| 
 | ||||
|     int count; | ||||
|     LandList() : count(0) {} | ||||
|     int getSize() { return count; } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const {} | ||||
| 
 | ||||
|     // Find land for the given coordinates. Return null if no mData.
 | ||||
|     Land *search(int x, int y) const | ||||
|     { | ||||
|       LandMap::const_iterator itr = lands.find(std::make_pair (x, y)); | ||||
|       if ( itr == lands.end() ) | ||||
|       { | ||||
|         return NULL; | ||||
|       } | ||||
| 
 | ||||
|       return itr->second; | ||||
|     } | ||||
| 
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       count++; | ||||
| 
 | ||||
|       // Create the structure and load it. This actually skips the
 | ||||
|       // landscape data and remembers the file position for later.
 | ||||
|       Land *land = new Land(); | ||||
|       land->load(esm); | ||||
| 
 | ||||
|       // Store the structure
 | ||||
|       lands[std::make_pair (land->mX, land->mY)] = land; | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|     struct ciLessBoost : std::binary_function<std::string, std::string, bool> | ||||
| { | ||||
|     bool operator() (const std::string & s1, const std::string & s2) const { | ||||
|                                                //case insensitive version of is_less
 | ||||
|         return lexicographical_compare(s1, s2, is_iless()); | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
|   // Cells aren't simply indexed by name. Exterior cells are treated
 | ||||
|   // separately.
 | ||||
|   // TODO: case handling (cell names are case-insensitive, but they are also showen to the
 | ||||
|   // player, so we can't simply smash case.
 | ||||
|   struct CellList : RecList | ||||
|   { | ||||
|     // Total cell count. Used for statistics.
 | ||||
|     int count; | ||||
|     CellList() : count(0) {} | ||||
|     int getSize() { return count; } | ||||
| 
 | ||||
|     // List of interior cells. Indexed by cell name.
 | ||||
|     typedef std::map<std::string,ESM::Cell*, ciLessBoost> IntCells; | ||||
|     IntCells intCells; | ||||
| 
 | ||||
|     // List of exterior cells. Indexed as extCells[mX][mY].
 | ||||
|     typedef std::map<std::pair<int, int>, ESM::Cell*> ExtCells; | ||||
|     ExtCells extCells; | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (IntCells::const_iterator iter (intCells.begin()); iter!=intCells.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
| 
 | ||||
|     virtual ~CellList() | ||||
|     { | ||||
|       for (IntCells::iterator it = intCells.begin(); it!=intCells.end(); ++it) | ||||
|         delete it->second; | ||||
| 
 | ||||
|       for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it) | ||||
|           delete it->second; | ||||
|     } | ||||
| 
 | ||||
|     const ESM::Cell* searchInt(const std::string &id) const | ||||
|     { | ||||
|       IntCells::const_iterator iter = intCells.find(id); | ||||
| 
 | ||||
|       if (iter!=intCells.end()) | ||||
|         return iter->second; | ||||
| 
 | ||||
|       return 0; | ||||
|     } | ||||
| 
 | ||||
|     const ESM::Cell* findInt(const std::string &id) const | ||||
|     { | ||||
|       const ESM::Cell *cell = searchInt (id); | ||||
| 
 | ||||
|       if (!cell) | ||||
|          throw std::runtime_error ("Interior cell not found - " + id); | ||||
| 
 | ||||
|       return cell; | ||||
|     } | ||||
| 
 | ||||
|     const ESM::Cell *searchExt (int x, int y) const | ||||
|     { | ||||
|         ExtCells::const_iterator it = extCells.find (std::make_pair (x, y)); | ||||
| 
 | ||||
|         if (it==extCells.end()) | ||||
|             return 0; | ||||
| 
 | ||||
|         return it->second; | ||||
|     } | ||||
| 
 | ||||
|     const ESM::Cell *findExt (int x, int y) const | ||||
|     { | ||||
|         const ESM::Cell *cell = searchExt (x, y); | ||||
| 
 | ||||
|         if (!cell) | ||||
|             throw std::runtime_error ("Exterior cell not found"); | ||||
| 
 | ||||
|         return cell; | ||||
|     } | ||||
|     const ESM::Cell *searchExtByName (const std::string& id) const | ||||
|     { | ||||
|         for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) | ||||
|         { | ||||
|             if (toLower (iter->second->mName) == toLower (id)) | ||||
|                 return iter->second; | ||||
|         } | ||||
| 
 | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     const ESM::Cell *searchExtByRegion (const std::string& id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) | ||||
|             if (toLower (iter->second->mRegion)==id) | ||||
|                 return iter->second; | ||||
| 
 | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       count++; | ||||
| 
 | ||||
|       // Don't automatically assume that a new cell must be spawned. Multiple plugins write to the same cell,
 | ||||
|       //  and we merge all this data into one Cell object. However, we can't simply search for the cell id,
 | ||||
|       //  as many exterior cells do not have a name. Instead, we need to search by (x,y) coordinates - and they
 | ||||
|       //  are not available until both cells have been loaded! So first, proceed as usual.
 | ||||
|        | ||||
|       // All cells have a name record, even nameless exterior cells.
 | ||||
|       ESM::Cell *cell = new ESM::Cell; | ||||
|       cell->mName = id; | ||||
| 
 | ||||
|       // The cell itself takes care of all the hairy details
 | ||||
|       cell->load(esm); | ||||
| 
 | ||||
|       if(cell->mData.mFlags & ESM::Cell::Interior) | ||||
|         { | ||||
|           // Store interior cell by name, try to merge with existing parent data.
 | ||||
|           ESM::Cell *oldcell = const_cast<ESM::Cell*>(searchInt(id)); | ||||
|           if (oldcell) { | ||||
|               cell->mContextList.push_back(oldcell->mContextList.at(0)); | ||||
|               delete oldcell; | ||||
|           } | ||||
|           intCells[id] = cell; | ||||
|         } | ||||
|       else | ||||
|         { | ||||
|           // Store exterior cells by grid position, try to merge with existing parent data.
 | ||||
|           ESM::Cell *oldcell = const_cast<ESM::Cell*>(searchExt(cell->getGridX(), cell->getGridY())); | ||||
|           if (oldcell) { | ||||
|               // The load order is important. Push the new source context on the *back* of the existing list,
 | ||||
|               //  and then move the list to the new cell. 
 | ||||
|               oldcell->mContextList.push_back(cell->mContextList.at(0)); | ||||
|               cell->mContextList = oldcell->mContextList; | ||||
|               delete oldcell; | ||||
|           } | ||||
|           extCells[std::make_pair (cell->mData.mX, cell->mData.mY)] = cell; | ||||
|         } | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   struct PathgridList : RecList | ||||
|   { | ||||
|       int count; | ||||
| 
 | ||||
|       // List of grids for interior cells. Indexed by cell name.
 | ||||
|       typedef std::map<std::string,ESM::Pathgrid*, ciLessBoost> IntGrids; | ||||
|       IntGrids intGrids; | ||||
| 
 | ||||
|       // List of grids for exterior cells. Indexed as extCells[mX][mY].
 | ||||
|       typedef std::map<std::pair<int, int>, ESM::Pathgrid*> ExtGrids; | ||||
|       ExtGrids extGrids; | ||||
| 
 | ||||
|       PathgridList() : count(0) {} | ||||
| 
 | ||||
|       virtual ~PathgridList() | ||||
|       { | ||||
|           for (IntGrids::iterator it = intGrids.begin(); it!=intGrids.end(); ++it) | ||||
|               delete it->second; | ||||
| 
 | ||||
|           for (ExtGrids::iterator it = extGrids.begin(); it!=extGrids.end(); ++it) | ||||
|               delete it->second; | ||||
|       } | ||||
| 
 | ||||
|       int getSize() { return count; } | ||||
| 
 | ||||
|       virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|       { | ||||
|           // do nothing
 | ||||
|       } | ||||
| 
 | ||||
|       void load(ESMReader &esm, const std::string &id) | ||||
|       { | ||||
|           count++; | ||||
|           ESM::Pathgrid *grid = new ESM::Pathgrid; | ||||
|           grid->load(esm); | ||||
|           if (grid->mData.mX == 0 && grid->mData.mY == 0) | ||||
|           { | ||||
|               intGrids[grid->mCell] = grid; | ||||
|           } | ||||
|           else | ||||
|           { | ||||
|               extGrids[std::make_pair(grid->mData.mX, grid->mData.mY)] = grid; | ||||
|           } | ||||
|       } | ||||
| 
 | ||||
|       Pathgrid *find(int cellX, int cellY, const std::string &cellName) const | ||||
|       { | ||||
|           Pathgrid *result = search(cellX, cellY, cellName); | ||||
|           if (!result) | ||||
|           { | ||||
|               throw std::runtime_error("no pathgrid found for cell " + cellName); | ||||
|           } | ||||
|           return result; | ||||
|       } | ||||
| 
 | ||||
|       Pathgrid *search(int cellX, int cellY, const std::string &cellName) const | ||||
|       { | ||||
|           Pathgrid *result = NULL; | ||||
|           if (cellX == 0 && cellY == 0) // possibly interior
 | ||||
|           { | ||||
|               IntGrids::const_iterator it = intGrids.find(cellName); | ||||
|               if (it != intGrids.end()) | ||||
|                 result = it->second; | ||||
|           } | ||||
|           else | ||||
|           { | ||||
|               ExtGrids::const_iterator it = extGrids.find(std::make_pair(cellX, cellY)); | ||||
|               if (it != extGrids.end()) | ||||
|                 result = it->second; | ||||
|           } | ||||
|           return result; | ||||
|       } | ||||
| 
 | ||||
|       Pathgrid *search(const ESM::Cell &cell) const | ||||
|       { | ||||
|           int cellX, cellY; | ||||
|           if (cell.mData.mFlags & ESM::Cell::Interior) | ||||
|           { | ||||
|               cellX = cellY = 0; | ||||
|           } | ||||
|           else | ||||
|           { | ||||
|               cellX = cell.mData.mX; | ||||
|               cellY = cell.mData.mY; | ||||
|           } | ||||
|           return search(cellX, cellY, cell.mName); | ||||
|       } | ||||
|   }; | ||||
| 
 | ||||
|   template <typename X> | ||||
|   struct ScriptListT : RecList | ||||
|   { | ||||
|     virtual ~ScriptListT() {} | ||||
| 
 | ||||
|     typedef std::map<std::string,X> MapType; | ||||
| 
 | ||||
|     MapType list; | ||||
| 
 | ||||
|     // Load one object of this type
 | ||||
|     void load(ESMReader &esm, const std::string &id) | ||||
|     { | ||||
|       X ref; | ||||
|       ref.load (esm); | ||||
| 
 | ||||
|       std::string realId = toLower (ref.mData.mName.toString()); | ||||
| 
 | ||||
|       std::swap (list[realId], ref); | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID, or return NULL if not found.
 | ||||
|     const X* search(const std::string &id) const | ||||
|     { | ||||
|         std::string id2 = toLower (id); | ||||
| 
 | ||||
|         typename MapType::const_iterator iter = list.find (id2); | ||||
| 
 | ||||
|         if (iter == list.end()) | ||||
|             return NULL; | ||||
| 
 | ||||
|         return &iter->second; | ||||
|     } | ||||
| 
 | ||||
|     // Find the given object ID (throws an exception if not found)
 | ||||
|     const X* find(const std::string &id) const | ||||
|     { | ||||
|         const X *object = search (id); | ||||
| 
 | ||||
|         if (!object) | ||||
|             throw std::runtime_error ("object " + id + " not found"); | ||||
| 
 | ||||
|         return object; | ||||
|     } | ||||
| 
 | ||||
|     int getSize() { return list.size(); } | ||||
| 
 | ||||
|     virtual void listIdentifier (std::vector<std::string>& identifier) const | ||||
|     { | ||||
|         for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) | ||||
|             identifier.push_back (iter->first); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   template <typename X> | ||||
|   struct IndexListT | ||||
|   { | ||||
|         virtual ~IndexListT() {} | ||||
| 
 | ||||
|         typedef std::map<int, X> MapType; | ||||
| 
 | ||||
|         MapType list; | ||||
| 
 | ||||
|         void load(ESMReader &esm) | ||||
|         { | ||||
|             X ref; | ||||
|             ref.load (esm); | ||||
|             int index = ref.mIndex; | ||||
|             list[index] = ref; | ||||
|         } | ||||
| 
 | ||||
|         int getSize() | ||||
|         { | ||||
|             return list.size(); | ||||
|         } | ||||
| 
 | ||||
|         virtual void listIdentifier (std::vector<std::string>& identifier) const {} | ||||
| 
 | ||||
|         // Find the given object ID, or return NULL if not found.
 | ||||
|         const X* search (int id) const | ||||
|         { | ||||
|             typename MapType::const_iterator iter = list.find (id); | ||||
| 
 | ||||
|             if (iter == list.end()) | ||||
|                 return NULL; | ||||
| 
 | ||||
|             return &iter->second; | ||||
|         } | ||||
| 
 | ||||
|         // Find the given object ID (throws an exception if not found)
 | ||||
|         const X* find (int id) const | ||||
|         { | ||||
|             const X *object = search (id); | ||||
| 
 | ||||
|             if (!object) | ||||
|             { | ||||
|                 std::ostringstream error; | ||||
|                 error << "object " << id << " not found"; | ||||
|                 throw std::runtime_error (error.str()); | ||||
|             } | ||||
| 
 | ||||
|             return object; | ||||
|         } | ||||
|   }; | ||||
| 
 | ||||
|   /* We need special lists for:
 | ||||
| 
 | ||||
|      Path grids | ||||
|   */ | ||||
| } | ||||
| #endif | ||||
|  | @ -1,124 +0,0 @@ | |||
| #include <set> | ||||
| #include <iostream> | ||||
| #include "store.hpp" | ||||
| 
 | ||||
| using namespace std; | ||||
| using namespace ESM; | ||||
| using namespace ESMS; | ||||
| 
 | ||||
| /*
 | ||||
| static string toStr(int i) | ||||
| { | ||||
|   char name[5]; | ||||
|   *((int*)name) = i; | ||||
|   name[4] = 0; | ||||
|   return std::string(name); | ||||
| } | ||||
| */ | ||||
| 
 | ||||
| void ESMStore::load(ESMReader &esm) | ||||
| { | ||||
|     set<string> missing; | ||||
| 
 | ||||
|     ESM::Dialogue *dialogue = 0; | ||||
| 
 | ||||
|     // Loop through all records
 | ||||
|     while(esm.hasMoreRecs()) | ||||
|     { | ||||
|         NAME n = esm.getRecName(); | ||||
|         esm.getRecHeader(); | ||||
| 
 | ||||
|         // Look up the record type.
 | ||||
|         RecListList::iterator it = recLists.find(n.val); | ||||
| 
 | ||||
|         if(it == recLists.end()) | ||||
|         { | ||||
|             if (n.val==ESM::REC_INFO) | ||||
|             { | ||||
|                 if (dialogue) | ||||
|                 { | ||||
|                     ESM::DialInfo info; | ||||
|                     info.load (esm); | ||||
| 
 | ||||
|                     dialogue->mInfo.push_back (info); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     std::cerr << "error: info record without dialog" << std::endl; | ||||
|                     esm.skipRecord(); | ||||
|                 } | ||||
|             } | ||||
|             else if (n.val==ESM::REC_MGEF) | ||||
|             { | ||||
|                 magicEffects.load (esm); | ||||
|             } | ||||
|             else if (n.val==ESM::REC_SKIL) | ||||
|             { | ||||
|                 skills.load (esm); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 // Not found (this would be an error later)
 | ||||
|                 esm.skipRecord(); | ||||
|                 missing.insert(n.toString()); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             // Load it
 | ||||
|             std::string id = esm.getHNOString("NAME"); | ||||
|             // ... unless it got deleted! This means that the following record
 | ||||
| 	    //  has been deleted, and trying to load it using standard assumptions
 | ||||
| 	    //  on the structure will (probably) fail.
 | ||||
|             if (esm.isNextSub("DELE")) { | ||||
|               esm.skipRecord(); | ||||
|               all.erase(id); | ||||
|               it->second->remove(id); | ||||
|               continue; | ||||
|             } | ||||
|             it->second->load(esm, id); | ||||
| 
 | ||||
|             if (n.val==ESM::REC_DIAL) | ||||
|             { | ||||
|                 RecListCaseT<Dialogue>& recList = static_cast<RecListCaseT<Dialogue>& > (*it->second); | ||||
| 
 | ||||
|                 ESM::Dialogue* d = recList.search (id); | ||||
| 
 | ||||
|                 assert (d != NULL); | ||||
| 
 | ||||
|                 dialogue = d; | ||||
|             } | ||||
|             else | ||||
|                 dialogue = 0; | ||||
| 
 | ||||
|             // Insert the reference into the global lookup
 | ||||
|             if(!id.empty() && | ||||
|                 (n.val==REC_ACTI || n.val==REC_ALCH || n.val==REC_APPA || n.val==REC_ARMO || | ||||
|                 n.val==REC_BOOK || n.val==REC_CLOT || n.val==REC_CONT || n.val==REC_CREA || | ||||
|                 n.val==REC_DOOR || n.val==REC_INGR || n.val==REC_LEVC || n.val==REC_LEVI || | ||||
|                 n.val==REC_LIGH || n.val==REC_LOCK || n.val==REC_MISC || n.val==REC_NPC_ || | ||||
|                 n.val==REC_PROB || n.val==REC_REPA || n.val==REC_STAT || n.val==REC_WEAP) | ||||
|                 ) | ||||
|                 all[id] = n.val; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     for (int i = 0; i < Attribute::Length; ++i) | ||||
|     { | ||||
|         Attribute::AttributeID id = Attribute::sAttributeIds[i]; | ||||
|         attributes.list.insert(std::make_pair(id, Attribute(id, Attribute::sGmstAttributeIds[i], Attribute::sGmstAttributeDescIds[i]))); | ||||
|     } | ||||
| 
 | ||||
|   /* This information isn't needed on screen. But keep the code around
 | ||||
|      for debugging purposes later. | ||||
| 
 | ||||
|   cout << "\n" << recLists.size() << " record types:\n"; | ||||
|   for(RecListList::iterator it = recLists.begin(); it != recLists.end(); it++) | ||||
|     cout << "  " << toStr(it->first) << ": " << it->second->getSize() << endl; | ||||
|   cout << "\nNot implemented yet: "; | ||||
|   for(set<string>::iterator it = missing.begin(); | ||||
|       it != missing.end(); it++ ) | ||||
|     cout << *it << " "; | ||||
|   cout << endl; | ||||
|   */ | ||||
| } | ||||
		Loading…
	
		Reference in a new issue