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 <iostream> | ||||||
| 
 | 
 | ||||||
|  | #include <cstdint> | ||||||
|  | 
 | ||||||
| #include "esmreader.hpp" | #include "esmreader.hpp" | ||||||
| #include "esmwriter.hpp" | #include "esmwriter.hpp" | ||||||
| #include "defs.hpp" | #include "defs.hpp" | ||||||
|  | #include "util.hpp" | ||||||
| 
 | 
 | ||||||
| namespace ESM | namespace ESM | ||||||
| { | { | ||||||
|  | @ -12,18 +15,19 @@ namespace ESM | ||||||
| 
 | 
 | ||||||
| void Dialogue::load(ESMReader &esm) | void Dialogue::load(ESMReader &esm) | ||||||
| { | { | ||||||
|  |     mIsDeleted = false; | ||||||
|  | 
 | ||||||
|  |     mId = esm.getHNString("NAME"); | ||||||
|     esm.getSubNameIs("DATA"); |     esm.getSubNameIs("DATA"); | ||||||
|     esm.getSubHeader(); |     esm.getSubHeader(); | ||||||
|     int si = esm.getSubSize(); |     int si = esm.getSubSize(); | ||||||
|     if (si == 1) |     if (si == 1) | ||||||
|         esm.getT(mType); |         esm.getT(mType); | ||||||
|     else if (si == 4) |     else if (si == 4) // The dialogue is deleted
 | ||||||
|     { |     { | ||||||
|         // These are just markers, their values are not used.
 |         int32_t empty; | ||||||
|         int i; |         esm.getT(empty); // Skip an empty DATA
 | ||||||
|         esm.getT(i); |         mIsDeleted = readDeleSubRecord(esm); | ||||||
|         esm.getHNT(i, "DELE"); |  | ||||||
|         mType = Deleted; |  | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|         esm.fail("Unknown sub record size"); |         esm.fail("Unknown sub record size"); | ||||||
|  | @ -31,12 +35,15 @@ void Dialogue::load(ESMReader &esm) | ||||||
| 
 | 
 | ||||||
| void Dialogue::save(ESMWriter &esm) const | void Dialogue::save(ESMWriter &esm) const | ||||||
| { | { | ||||||
|     if (mType != Deleted) |     esm.writeHNCString("NAME", mId); | ||||||
|         esm.writeHNT("DATA", mType); |     if (mIsDeleted) | ||||||
|  |     { | ||||||
|  |         esm.writeHNT("DATA", static_cast<int32_t>(0)); | ||||||
|  |         writeDeleSubRecord(esm); | ||||||
|  |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         esm.writeHNT("DATA", (int)1); |         esm.writeHNT("DATA", mType); | ||||||
|         esm.writeHNT("DELE", (int)1); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -30,8 +30,7 @@ struct Dialogue | ||||||
|         Voice = 1, |         Voice = 1, | ||||||
|         Greeting = 2, |         Greeting = 2, | ||||||
|         Persuasion = 3, |         Persuasion = 3, | ||||||
|         Journal = 4, |         Journal = 4 | ||||||
|         Deleted = -1 |  | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     std::string mId; |     std::string mId; | ||||||
|  | @ -46,6 +45,8 @@ struct Dialogue | ||||||
|     // This is only used during the loading phase to speed up DialInfo merging.
 |     // This is only used during the loading phase to speed up DialInfo merging.
 | ||||||
|     LookupMap mLookup; |     LookupMap mLookup; | ||||||
| 
 | 
 | ||||||
|  |     bool mIsDeleted; | ||||||
|  | 
 | ||||||
|     void load(ESMReader &esm); |     void load(ESMReader &esm); | ||||||
|     void save(ESMWriter &esm) const; |     void save(ESMWriter &esm) const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue