mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	Add NAME and DELE handling to Dialogue record
(cherry picked from commit 0b537186e5)
			
			
This commit is contained in:
		
							parent
							
								
									93736e9a81
								
							
						
					
					
						commit
						d89de1ba30
					
				
					 2 changed files with 20 additions and 12 deletions
				
			
		|  | @ -2,9 +2,12 @@ | |||
| 
 | ||||
| #include <iostream> | ||||
| 
 | ||||
| #include <cstdint> | ||||
| 
 | ||||
| #include "esmreader.hpp" | ||||
| #include "esmwriter.hpp" | ||||
| #include "defs.hpp" | ||||
| #include "util.hpp" | ||||
| 
 | ||||
| namespace ESM | ||||
| { | ||||
|  | @ -12,18 +15,19 @@ namespace ESM | |||
| 
 | ||||
| void Dialogue::load(ESMReader &esm) | ||||
| { | ||||
|     mIsDeleted = false; | ||||
| 
 | ||||
|     mId = esm.getHNString("NAME"); | ||||
|     esm.getSubNameIs("DATA"); | ||||
|     esm.getSubHeader(); | ||||
|     int si = esm.getSubSize(); | ||||
|     if (si == 1) | ||||
|         esm.getT(mType); | ||||
|     else if (si == 4) | ||||
|     else if (si == 4) // The dialogue is deleted
 | ||||
|     { | ||||
|         // These are just markers, their values are not used.
 | ||||
|         int i; | ||||
|         esm.getT(i); | ||||
|         esm.getHNT(i, "DELE"); | ||||
|         mType = Deleted; | ||||
|         int32_t empty; | ||||
|         esm.getT(empty); // Skip an empty DATA
 | ||||
|         mIsDeleted = readDeleSubRecord(esm); | ||||
|     } | ||||
|     else | ||||
|         esm.fail("Unknown sub record size"); | ||||
|  | @ -31,12 +35,15 @@ void Dialogue::load(ESMReader &esm) | |||
| 
 | ||||
| void Dialogue::save(ESMWriter &esm) const | ||||
| { | ||||
|     if (mType != Deleted) | ||||
|         esm.writeHNT("DATA", mType); | ||||
|     esm.writeHNCString("NAME", mId); | ||||
|     if (mIsDeleted) | ||||
|     { | ||||
|         esm.writeHNT("DATA", static_cast<int32_t>(0)); | ||||
|         writeDeleSubRecord(esm); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         esm.writeHNT("DATA", (int)1); | ||||
|         esm.writeHNT("DELE", (int)1); | ||||
|         esm.writeHNT("DATA", mType); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,8 +30,7 @@ struct Dialogue | |||
|         Voice = 1, | ||||
|         Greeting = 2, | ||||
|         Persuasion = 3, | ||||
|         Journal = 4, | ||||
|         Deleted = -1 | ||||
|         Journal = 4 | ||||
|     }; | ||||
| 
 | ||||
|     std::string mId; | ||||
|  | @ -46,6 +45,8 @@ struct Dialogue | |||
|     // This is only used during the loading phase to speed up DialInfo merging.
 | ||||
|     LookupMap mLookup; | ||||
| 
 | ||||
|     bool mIsDeleted; | ||||
| 
 | ||||
|     void load(ESMReader &esm); | ||||
|     void save(ESMWriter &esm) const; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue