mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-26 14:56:39 +00:00 
			
		
		
		
	load skill and magic effect records
This commit is contained in:
		
							parent
							
								
									814d721e33
								
							
						
					
					
						commit
						0414d7f862
					
				
					 4 changed files with 56 additions and 10 deletions
				
			
		|  | @ -32,6 +32,7 @@ struct Skill | |||
| 
 | ||||
|   void load(ESMReader &esm) | ||||
|     { | ||||
|       esm.getHNT(index, "INDX"); | ||||
|       esm.getHNT(data, "SKDT", 24); | ||||
|       description = esm.getHNOString("DESC"); | ||||
|     } | ||||
|  |  | |||
|  | @ -308,12 +308,53 @@ namespace ESMS | |||
|     int getSize() { return list.size(); } | ||||
|   }; | ||||
| 
 | ||||
|   template <typename X> | ||||
|   struct IndexListT | ||||
|   { | ||||
|         typedef std::map<int, X> MapType; | ||||
| 
 | ||||
|         MapType list; | ||||
| 
 | ||||
|         void load(ESMReader &esm) | ||||
|         { | ||||
|             X ref; | ||||
|             ref.load (esm); | ||||
|             int index = ref.index; | ||||
|             list[index] = ref; | ||||
|         } | ||||
| 
 | ||||
|         int getSize() | ||||
|         { | ||||
|             return list.size(); | ||||
|         } | ||||
| 
 | ||||
|         // Find the given object ID, or return NULL if not found.
 | ||||
|         const X* search (int id) const | ||||
|         { | ||||
|             if (list.find (id) == list.end()) | ||||
|                 return NULL; | ||||
| 
 | ||||
|               return &list.find(id)->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:
 | ||||
| 
 | ||||
|      Magic effects | ||||
|      Skills | ||||
|      Dialog / Info combo | ||||
|      Scripts | ||||
|      Land | ||||
|      Path grids | ||||
|      Land textures | ||||
|  |  | |||
|  | @ -46,15 +46,21 @@ void ESMStore::load(ESMReader &esm) | |||
|                 { | ||||
|                     std::cerr << "error: info record without dialog" << std::endl; | ||||
|                     esm.skipRecord(); | ||||
|                     continue; | ||||
|                 } | ||||
|             } | ||||
|             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()); | ||||
|                 continue; | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|  |  | |||
|  | @ -71,9 +71,9 @@ namespace ESMS | |||
|     RecIDListT<GameSetting>     gameSettings; | ||||
|     //RecListT<Land>        lands;
 | ||||
|     //RecListT<LandTexture> landTexts;
 | ||||
|     //RecListT<MagicEffect> magicEffects;
 | ||||
|     IndexListT<MagicEffect>     magicEffects; | ||||
|     ScriptListT<Script>      scripts; | ||||
|     //RecListT<Skill>       skills;
 | ||||
|     IndexListT<Skill>           skills; | ||||
|     //RecListT<PathGrid>    pathgrids;
 | ||||
| 
 | ||||
|     // Lookup of all IDs. Makes looking up references faster. Just
 | ||||
|  | @ -118,7 +118,6 @@ namespace ESMS | |||
|       recLists[REC_LIGH] = &lights; | ||||
|       recLists[REC_LOCK] = &lockpicks; | ||||
|       //recLists[REC_LTEX] = &landTexts;
 | ||||
|       //recLists[REC_MGEF] = &magicEffects;
 | ||||
|       recLists[REC_MISC] = &miscItems; | ||||
|       recLists[REC_NPC_] = &npcs; | ||||
|       recLists[REC_NPCC] = &npcChange; | ||||
|  | @ -128,7 +127,6 @@ namespace ESMS | |||
|       recLists[REC_REGN] = ®ions; | ||||
|       recLists[REC_REPA] = &repairs; | ||||
|       recLists[REC_SCPT] = &scripts; | ||||
|       //recLists[REC_SKIL] = &skills;
 | ||||
|       recLists[REC_SNDG] = &soundGens; | ||||
|       recLists[REC_SOUN] = &sounds; | ||||
|       recLists[REC_SPEL] = &spells; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue