Browse Source

Make ResourcePack bitness-agnostic

pabloid 5 years ago
parent
commit
0ade1c781a
1 changed files with 13 additions and 13 deletions
  1. 13
    13
      pge/src/olcPGE_ResourcePack.cpp

+ 13
- 13
pge/src/olcPGE_ResourcePack.cpp View File

58
 		if (!ofs.is_open()) return olc::FAIL;
58
 		if (!ofs.is_open()) return olc::FAIL;
59
 
59
 
60
 		// 1) Write Map
60
 		// 1) Write Map
61
-		size_t nMapSize = mapFiles.size();
62
-		ofs.write((char*)&nMapSize, sizeof(size_t));
61
+		uint32_t nMapSize = mapFiles.size();
62
+		ofs.write((char*)&nMapSize, sizeof(uint32_t));
63
 		for (auto &e : mapFiles)
63
 		for (auto &e : mapFiles)
64
 		{
64
 		{
65
-			size_t nPathSize = e.first.size();
66
-			ofs.write((char*)&nPathSize, sizeof(size_t));
65
+			uint32_t nPathSize = e.first.size();
66
+			ofs.write((char*)&nPathSize, sizeof(uint32_t));
67
 			ofs.write(e.first.c_str(), nPathSize);
67
 			ofs.write(e.first.c_str(), nPathSize);
68
 			ofs.write((char*)&e.second.nID, sizeof(uint32_t));
68
 			ofs.write((char*)&e.second.nID, sizeof(uint32_t));
69
 			ofs.write((char*)&e.second.nFileSize, sizeof(uint32_t));
69
 			ofs.write((char*)&e.second.nFileSize, sizeof(uint32_t));
81
 
81
 
82
 		// 3) Rewrite Map (it has been updated with offsets now)
82
 		// 3) Rewrite Map (it has been updated with offsets now)
83
 		ofs.seekp(std::ios::beg);
83
 		ofs.seekp(std::ios::beg);
84
-		ofs.write((char*)&nMapSize, sizeof(size_t));
84
+		ofs.write((char*)&nMapSize, sizeof(uint32_t));
85
 		for (auto &e : mapFiles)
85
 		for (auto &e : mapFiles)
86
 		{
86
 		{
87
-			size_t nPathSize = e.first.size();
88
-			ofs.write((char*)&nPathSize, sizeof(size_t));
87
+			uint32_t nPathSize = e.first.size();
88
+			ofs.write((char*)&nPathSize, sizeof(uint32_t));
89
 			ofs.write(e.first.c_str(), nPathSize);
89
 			ofs.write(e.first.c_str(), nPathSize);
90
 			ofs.write((char*)&e.second.nID, sizeof(uint32_t));
90
 			ofs.write((char*)&e.second.nID, sizeof(uint32_t));
91
 			ofs.write((char*)&e.second.nFileSize, sizeof(uint32_t));
91
 			ofs.write((char*)&e.second.nFileSize, sizeof(uint32_t));
102
 		if (!ifs.is_open()) return olc::FAIL;
102
 		if (!ifs.is_open()) return olc::FAIL;
103
 
103
 
104
 		// 1) Read Map
104
 		// 1) Read Map
105
-		size_t nMapEntries;
106
-		ifs.read((char*)&nMapEntries, sizeof(size_t));
107
-		for (size_t i = 0; i < nMapEntries; i++)
105
+		uint32_t nMapEntries;
106
+		ifs.read((char*)&nMapEntries, sizeof(uint32_t));
107
+		for (uint32_t i = 0; i < nMapEntries; i++)
108
 		{
108
 		{
109
-			size_t nFilePathSize = 0;
110
-			ifs.read((char*)&nFilePathSize, sizeof(size_t));
109
+			uint32_t nFilePathSize = 0;
110
+			ifs.read((char*)&nFilePathSize, sizeof(uint32_t));
111
 
111
 
112
 			std::string sFileName(nFilePathSize, ' ');
112
 			std::string sFileName(nFilePathSize, ' ');
113
-			for (size_t j = 0; j < nFilePathSize; j++)
113
+			for (uint32_t j = 0; j < nFilePathSize; j++)
114
 				sFileName[j] = ifs.get();
114
 				sFileName[j] = ifs.get();
115
 
115
 
116
 			sEntry e;
116
 			sEntry e;

Loading…
Cancel
Save