diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-05-11 08:47:28 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-05-11 08:47:28 -0400 |
commit | cab9a8f66e683d79b67a1a4d78b6e68009642534 (patch) | |
tree | 43b0499fb795a3e8e0d2a5835123ec97c8e36758 /src/brice.cpp | |
parent | dffd910115fb0b36310bb7b32ad0650727d58216 (diff) |
changelog update!
Diffstat (limited to 'src/brice.cpp')
-rw-r--r-- | src/brice.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/brice.cpp b/src/brice.cpp index 6b64d88..fb9834d 100644 --- a/src/brice.cpp +++ b/src/brice.cpp @@ -41,7 +41,7 @@ namespace game { UserError("Cannot open brice data file"); for (const auto& i : brice) { - data.append(i.first + ',' ); + data.append(i.first + '\n'); data.append(i.second + '\n'); } @@ -51,10 +51,16 @@ namespace game { void briceLoad(void) { const char *data = readFile("brice.dat"); - auto datas = StringTokenizer(data, ','); + auto datas = StringTokenizer(data, '\n'); - for (const auto& d : datas) - std::cout << d << '\n'; + if (datas.size() != 0) { + const unsigned int count = datas[0][0] - '0'; + + for (unsigned int i = 1; i <= count; i += 2) { + std::cout << datas[i] << ' ' << datas[i + 1] << '\n'; + brice.emplace(std::make_pair(datas[i], datas[i + 1])); + } + } delete[] data; } @@ -64,7 +70,7 @@ namespace game { int val; try { val = std::stoi(getValue(id)); - } catch (std::invalid_argument &e) { + } catch (const std::invalid_argument &e) { val = 0; } return val; @@ -77,5 +83,9 @@ namespace game { // attempt to load actual values canJump = getIntValue("canJump"); canSprint = getIntValue("canSprint"); + + // re-save values + setValue("canJump", std::to_string(canJump)); + setValue("canSprint", std::to_string(canSprint)); } } |