Skip to content
Permalink
Browse files

Merge memorial file hotfix.

  • Loading branch information...
kevingranade committed Aug 8, 2013
2 parents 5cc688d + 5679eaa commit 822622149aa16770627096a77c08dddb9f9178be
Showing with 10 additions and 1 deletion.
  1. +10 −1 game.cpp
@@ -2847,19 +2847,28 @@ void game::write_memorial_file() {
time (&rawtime);
std::string timestamp = ctime(&rawtime);

//Fun fact: ctime puts a \n at the end of the timestamp. Get rid of it.
size_t end = timestamp.find_last_of('\n');
timestamp = timestamp.substr(0, end);

//Colons are not usable in paths, so get rid of them
for(int index = 0; index < timestamp.size(); index++) {
if(timestamp[index] == ':') {
timestamp[index] = '-';
}
}

std::string memorial_file_path = string_format("memorial/%s-%s.txt",
std::string memorial_file_path = string_format("memorial/%s-%s.txt",
u.name.c_str(), timestamp.c_str());

std::ofstream memorial_file;
memorial_file.open(memorial_file_path.c_str());

if(!memorial_file.is_open()) {
dbg(D_ERROR) << "game:write_memorial_file: Unable to open " << memorial_file_path;
debugmsg("Could not open memorial file '%s'", memorial_file_path.c_str());
}

//Header
std::string version = string_format("%s", getVersionString());
memorial_file << _("Cataclysm - Dark Days Ahead version ") << version << _(" memorial file") << "\n";

0 comments on commit 8226221

Please sign in to comment.
You can’t perform that action at this time.