Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Supply the map stream to getRequiredSupps() so it can read stored fil…

…enames

This allows map formats which store filenames of their tilesets to correctly
return them as supplementary items.
  • Loading branch information...
commit 8e650e21ba77253b3d36e998cb1f8c39b4457cab 1 parent 62d013c
Adam Nielsen authored August 26, 2012
14  examples/gamemap.cpp
@@ -526,12 +526,15 @@ int main(int iArgC, char *cArgV[])
526 526
 				}
527 527
 				if (cert != gm::MapType::DefinitelyNo) {
528 528
 					// We got a possible match, see if it requires any suppdata
529  
-					camoto::SuppFilenames suppList = pTestType->getRequiredSupps(strFilename);
  529
+					camoto::SuppFilenames suppList = pTestType->getRequiredSupps(psMap,
  530
+						strFilename);
530 531
 					if (suppList.size() > 0) {
531 532
 						// It has suppdata, see if it's present
532 533
 						std::cout << "  * This format requires supplemental files..." << std::endl;
533 534
 						bool bSuppOK = true;
534  
-						for (camoto::SuppFilenames::iterator i = suppList.begin(); i != suppList.end(); i++) {
  535
+						for (camoto::SuppFilenames::iterator
  536
+							i = suppList.begin(); i != suppList.end(); i++
  537
+						) {
535 538
 							try {
536 539
 								stream::file_sptr suppStream(new stream::file());
537 540
 								suppStream->open(i->second);
@@ -585,10 +588,13 @@ int main(int iArgC, char *cArgV[])
585 588
 		}
586 589
 
587 590
 		// See if the format requires any supplemental files
588  
-		camoto::SuppFilenames suppList = pMapType->getRequiredSupps(strFilename);
  591
+		camoto::SuppFilenames suppList = pMapType->getRequiredSupps(psMap,
  592
+			strFilename);
589 593
 		camoto::SuppData suppData;
590 594
 		if (suppList.size() > 0) {
591  
-			for (camoto::SuppFilenames::iterator i = suppList.begin(); i != suppList.end(); i++) {
  595
+			for (camoto::SuppFilenames::iterator
  596
+				i = suppList.begin(); i != suppList.end(); i++
  597
+			) {
592 598
 				try {
593 599
 					stream::file_sptr suppStream(new stream::file());
594 600
 					suppStream->open(i->second);
5  include/camoto/gamemaps/maptype.hpp
@@ -161,9 +161,8 @@ class MapType
161 161
 		 *         returned can have relative paths, and may even have an absolute
162 162
 		 *         path, if one was passed in with filenameMap.
163 163
 		 */
164  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
165  
-			const = 0;
166  
-
  164
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  165
+			const std::string& filename) const = 0;
167 166
 };
168 167
 
169 168
 /// Shared pointer to a MapType.
6  src/fmt-map-bash.cpp
@@ -427,11 +427,11 @@ void BashMapType::write(MapPtr map, stream::expanding_output_sptr output,
427 427
 	return;
428 428
 }
429 429
 
430  
-SuppFilenames BashMapType::getRequiredSupps(
431  
-	const std::string& filenameMap) const
  430
+SuppFilenames BashMapType::getRequiredSupps(stream::input_sptr input,
  431
+	const std::string& filename) const
432 432
 {
433 433
 	SuppFilenames supps;
434  
-	std::string baseName = filenameMap.substr(0, filenameMap.length() - 3);
  434
+	std::string baseName = filename.substr(0, filename.length() - 3);
435 435
 	supps[SuppItem::Layer1] = baseName + "mbg";
436 436
 	supps[SuppItem::Layer2] = baseName + "mfg";
437 437
 	return supps;
4  src/fmt-map-bash.hpp
@@ -40,8 +40,8 @@ class BashMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class BashForegroundLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-ccaves.cpp
@@ -219,8 +219,8 @@ void CCavesMapType::write(MapPtr map, stream::expanding_output_sptr output,
219 219
 	return;
220 220
 }
221 221
 
222  
-SuppFilenames CCavesMapType::getRequiredSupps(const std::string& filenameMap)
223  
-	const
  222
+SuppFilenames CCavesMapType::getRequiredSupps(stream::input_sptr input,
  223
+	const std::string& filename) const
224 224
 {
225 225
 	SuppFilenames supps;
226 226
 	return supps;
4  src/fmt-map-ccaves.hpp
@@ -40,8 +40,8 @@ class CCavesMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class CCavesBackgroundLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-ccomic.cpp
@@ -205,8 +205,8 @@ void CComicMapType::write(MapPtr map, stream::expanding_output_sptr output,
205 205
 	return;
206 206
 }
207 207
 
208  
-SuppFilenames CComicMapType::getRequiredSupps(const std::string& filenameMap)
209  
-	const
  208
+SuppFilenames CComicMapType::getRequiredSupps(stream::input_sptr input,
  209
+	const std::string& filename) const
210 210
 {
211 211
 	SuppFilenames supps;
212 212
 	return supps;
4  src/fmt-map-ccomic.hpp
@@ -40,8 +40,8 @@ class CComicMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class CComicBackgroundLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-cosmo.cpp
@@ -298,8 +298,8 @@ void CosmoMapType::write(MapPtr map, stream::expanding_output_sptr output,
298 298
 	return;
299 299
 }
300 300
 
301  
-SuppFilenames CosmoMapType::getRequiredSupps(const std::string& filenameMap)
302  
-	const
  301
+SuppFilenames CosmoMapType::getRequiredSupps(stream::input_sptr input,
  302
+	const std::string& filename) const
303 303
 {
304 304
 	SuppFilenames supps;
305 305
 	return supps;
4  src/fmt-map-cosmo.hpp
@@ -40,8 +40,8 @@ class CosmoMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class CosmoActorLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-ddave.cpp
@@ -265,8 +265,8 @@ void DDaveMapType::write(MapPtr map, stream::expanding_output_sptr output,
265 265
 	return;
266 266
 }
267 267
 
268  
-SuppFilenames DDaveMapType::getRequiredSupps(const std::string& filenameMap)
269  
-	const
  268
+SuppFilenames DDaveMapType::getRequiredSupps(stream::input_sptr input,
  269
+	const std::string& filename) const
270 270
 {
271 271
 	SuppFilenames supps;
272 272
 	return supps;
4  src/fmt-map-ddave.hpp
@@ -40,8 +40,8 @@ class DDaveMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class DDaveBackgroundLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-harry.cpp
@@ -460,8 +460,8 @@ void HarryMapType::write(MapPtr map, stream::expanding_output_sptr output,
460 460
 	return;
461 461
 }
462 462
 
463  
-SuppFilenames HarryMapType::getRequiredSupps(const std::string& filenameMap)
464  
-	const
  463
+SuppFilenames HarryMapType::getRequiredSupps(stream::input_sptr input,
  464
+	const std::string& filename) const
465 465
 {
466 466
 	SuppFilenames supps;
467 467
 	return supps;
4  src/fmt-map-harry.hpp
@@ -40,8 +40,8 @@ class HarryMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class HarryActorLayer: virtual public GenericMap2D::Layer
4  src/fmt-map-hocus.cpp
@@ -240,8 +240,8 @@ void HocusMapType::write(MapPtr map, stream::expanding_output_sptr output,
240 240
 	return;
241 241
 }
242 242
 
243  
-SuppFilenames HocusMapType::getRequiredSupps(const std::string& filenameMap)
244  
-	const
  243
+SuppFilenames HocusMapType::getRequiredSupps(stream::input_sptr input,
  244
+	const std::string& filename) const
245 245
 {
246 246
 	SuppFilenames supps;
247 247
 	return supps;
4  src/fmt-map-hocus.hpp
@@ -40,8 +40,8 @@ class HocusMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class HocusBackgroundLayer: virtual public GenericMap2D::Layer
6  src/fmt-map-wacky.cpp
@@ -270,11 +270,11 @@ void WackyMapType::write(MapPtr map, stream::expanding_output_sptr output,
270 270
 	return;
271 271
 }
272 272
 
273  
-SuppFilenames WackyMapType::getRequiredSupps(
274  
-	const std::string& filenameMap) const
  273
+SuppFilenames WackyMapType::getRequiredSupps(stream::input_sptr input,
  274
+	const std::string& filename) const
275 275
 {
276 276
 	SuppFilenames supps;
277  
-	std::string baseName = filenameMap.substr(0, filenameMap.length() - 1);
  277
+	std::string baseName = filename.substr(0, filename.length() - 1);
278 278
 	supps[SuppItem::Layer1] = baseName + "rd";
279 279
 	return supps;
280 280
 }
4  src/fmt-map-wacky.hpp
@@ -40,8 +40,8 @@ class WackyMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class WackyBackgroundLayer: virtual public GenericMap2D::Layer
8  src/fmt-map-wordresc.cpp
@@ -772,13 +772,13 @@ void WordRescueMapType::write(MapPtr map, stream::expanding_output_sptr output,
772 772
 	return;
773 773
 }
774 774
 
775  
-SuppFilenames WordRescueMapType::getRequiredSupps(
776  
-	const std::string& filenameMap) const
  775
+SuppFilenames WordRescueMapType::getRequiredSupps(stream::input_sptr input,
  776
+	const std::string& filename) const
777 777
 {
778 778
 	SuppFilenames supps;
779 779
 	/// Add wr1.d0 (to wr1.d14) layer file
780  
-	std::string baseName = filenameMap.substr(0, filenameMap.find_last_of('.'))
781  
-		+ ".d" + filenameMap.substr(filenameMap.find_last_of('s') + 1);
  780
+	std::string baseName = filename.substr(0, filename.find_last_of('.'))
  781
+		+ ".d" + filename.substr(filename.find_last_of('s') + 1);
782 782
 	supps[SuppItem::Layer1] = baseName;
783 783
 	return supps;
784 784
 }
4  src/fmt-map-wordresc.hpp
@@ -40,8 +40,8 @@ class WordRescueMapType: virtual public BaseMapType
40 40
 		virtual MapPtr open(stream::input_sptr input, SuppData& suppData) const;
41 41
 		virtual void write(MapPtr map, stream::expanding_output_sptr output,
42 42
 			ExpandingSuppData& suppData) const;
43  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
44  
-			const;
  43
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  44
+			const std::string& filename) const;
45 45
 };
46 46
 
47 47
 class WordRescueBackgroundLayer: virtual public GenericMap2D::Layer
10  src/fmt-map-xargon.cpp
@@ -207,8 +207,8 @@ std::vector<std::string> JillMapType::getGameList() const
207 207
 	return vcGames;
208 208
 }
209 209
 
210  
-SuppFilenames JillMapType::getRequiredSupps(
211  
-	const std::string& filenameMap) const
  210
+SuppFilenames JillMapType::getRequiredSupps(stream::input_sptr input,
  211
+	const std::string& filename) const
212 212
 {
213 213
 	SuppFilenames supps;
214 214
 	supps[SuppItem::Extra1] = "jill.dma";
@@ -252,13 +252,13 @@ std::vector<std::string> XargonMapType::getGameList() const
252 252
 	return vcGames;
253 253
 }
254 254
 
255  
-SuppFilenames XargonMapType::getRequiredSupps(
256  
-	const std::string& filenameMap) const
  255
+SuppFilenames XargonMapType::getRequiredSupps(stream::input_sptr input,
  256
+	const std::string& filename) const
257 257
 {
258 258
 	// Take the extension from the file being opened and use the corresponding
259 259
 	// tiles file, i.e. "blah.xr1" -> "tiles.xr1".  There are no ".xr0" levels.
260 260
 	SuppFilenames supps;
261  
-	std::string ext = filenameMap.substr(filenameMap.find_last_of('.'));
  261
+	std::string ext = filename.substr(filename.find_last_of('.'));
262 262
 	supps[SuppItem::Extra1] = "tiles" + ext;
263 263
 	return supps;
264 264
 }
8  src/fmt-map-xargon.hpp
@@ -54,8 +54,8 @@ class JillMapType: virtual public SweeneyMapType
54 54
 		virtual std::string getFriendlyName() const;
55 55
 		virtual std::vector<std::string> getFileExtensions() const;
56 56
 		virtual std::vector<std::string> getGameList() const;
57  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
58  
-			const;
  57
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  58
+			const std::string& filename) const;
59 59
 };
60 60
 
61 61
 /// Xargon level reader/writer.
@@ -68,8 +68,8 @@ class XargonMapType: virtual public SweeneyMapType
68 68
 		virtual std::string getFriendlyName() const;
69 69
 		virtual std::vector<std::string> getFileExtensions() const;
70 70
 		virtual std::vector<std::string> getGameList() const;
71  
-		virtual SuppFilenames getRequiredSupps(const std::string& filenameMap)
72  
-			const;
  71
+		virtual SuppFilenames getRequiredSupps(stream::input_sptr input,
  72
+			const std::string& filename) const;
73 73
 };
74 74
 
75 75
 

0 notes on commit 8e650e2

Please sign in to comment.
Something went wrong with that request. Please try again.