Implement loading of scenarios
- This also tweaks the scenario schemas for consistency between schemas and code, adds some unique key restraints, and makes some attributes required.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,15 +15,15 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
map_data load_map(fs::path path, bool isTown) {
|
||||
map_data load_map(std::istream& fin, bool isTown) {
|
||||
map_data data;
|
||||
ifstream fin(path.string());
|
||||
int row = 0;
|
||||
while(!fin.eof()) {
|
||||
std::string line;
|
||||
getline(fin, line);
|
||||
int n = 0, col = 0;
|
||||
eMapFeature curFeature = eMapFeature::NONE;
|
||||
// vehicle_owned = true means the party owns it
|
||||
bool vehicle_owned;
|
||||
for(char c : line) {
|
||||
if(c == '#') break; // Found a comment
|
||||
@@ -32,20 +32,20 @@ map_data load_map(fs::path path, bool isTown) {
|
||||
n += c - '0';
|
||||
} else if(isblank(c)) {
|
||||
continue;
|
||||
} else if(c == '^') {
|
||||
} else if(c == '^' && isTown) {
|
||||
data.addFeature(col, row, eMapFeature::ENTRANCE_NORTH);
|
||||
} else if(c == '<') {
|
||||
} else if(c == '<' && isTown) {
|
||||
data.addFeature(col, row, eMapFeature::ENTRANCE_WEST);
|
||||
} else if(c == 'v') {
|
||||
} else if(c == 'v' && isTown) {
|
||||
data.addFeature(col, row, eMapFeature::ENTRANCE_SOUTH);
|
||||
} else if(c == '>') {
|
||||
} else if(c == '>' && isTown) {
|
||||
data.addFeature(col, row, eMapFeature::ENTRANCE_EAST);
|
||||
} else {
|
||||
if(curFeature == eMapFeature::NONE)
|
||||
data.set(col, row, n);
|
||||
else {
|
||||
if((curFeature == eMapFeature::BOAT || curFeature == eMapFeature::HORSE) && !vehicle_owned)
|
||||
n *= -1;
|
||||
n += 10000;
|
||||
data.addFeature(col, row, curFeature, n);
|
||||
}
|
||||
n = 0;
|
||||
|
@@ -12,11 +12,8 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "location.h"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
enum class eMapFeature {
|
||||
NONE, // Special value, won't appear in the map.
|
||||
SPECIAL_NODE,
|
||||
@@ -51,6 +48,6 @@ public:
|
||||
void writeTo(std::ostream& out);
|
||||
};
|
||||
|
||||
map_data load_map(fs::path path, bool isTown);
|
||||
map_data load_map(std::istream& stream, bool isTown);
|
||||
|
||||
#endif
|
||||
|
@@ -175,18 +175,8 @@ namespace ResMgr {
|
||||
/// @tparam type The type of resource the path applies to.
|
||||
/// @return The removed path from the top of the stack.
|
||||
template<typename type> fs::path popPath() {
|
||||
fs::path path = resPool<type>::resPaths.top();
|
||||
// std::map<std::string,std::string>::iterator mapiter;
|
||||
// std::deque<std::string> toDestroy;
|
||||
// std::deque<std::string>::iterator iter;
|
||||
// for(mapiter = resPool<type>::pathFound().begin();
|
||||
// mapiter != resPool<type>::pathFound().end();
|
||||
// mapiter++)
|
||||
// if(mapiter->second == path)
|
||||
// toDestroy.push_back(mapiter->first);
|
||||
// for(iter = toDestroy.begin(); iter != toDestroy.end(); iter++)
|
||||
// resPool<type>::resources().erase(*iter);
|
||||
resPool<type>::resPaths.pop();
|
||||
fs::path path = resPool<type>::resPaths().top();
|
||||
resPool<type>::resPaths().pop();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user