本文整理汇总了C++中Savegame::get_filename方法的典型用法代码示例。如果您正苦于以下问题:C++ Savegame::get_filename方法的具体用法?C++ Savegame::get_filename怎么用?C++ Savegame::get_filename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Savegame
的用法示例。
在下文中一共展示了Savegame::get_filename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reader
SavegameManager::SavegameManager(const std::string& arg_filename) :
filename(System::get_userdir() + arg_filename),
savegames()
{
assert(instance_ == 0);
instance_ = this;
std::shared_ptr<lisp::Lisp> sexpr;
try
{
sexpr = lisp::Parser::parse(filename);
}
catch (const std::runtime_error& e)
{
std::cerr << "SavegameManager: " << e.what() << std::endl;
return;
}
if (!sexpr)
{
std::cerr << "SavegameManager: Couldn't find savegame file '" <<
filename << "', starting with an empty one." << std::endl;
return;
}
SExprFileReader reader(sexpr->get_list_elem(0));
if (reader.get_name() != "pingus-savegame")
{
std::cerr << "Error: " << filename << ": not a (pingus-savegame) file" << std::endl;
return;
}
const std::vector<FileReader>& sections = reader.get_sections();
for(std::vector<FileReader>::const_iterator i = sections.begin();
i != sections.end(); ++i)
{
Savegame* savegame = new Savegame(*i);
SavegameTable::iterator j = find(savegame->get_filename());
if (j != savegames.end())
{ // overwrite duplicates, shouldn't happen, but harmless
std::cout << "SavegameManager: name collision: " << savegame->get_filename() << std::endl;
delete *j;
*j = savegame;
}
else
{
savegames.push_back(savegame);
}
}
}
示例2: Savegame
void
SavegameManager::store(Savegame& arg_savegame)
{
Savegame* savegame = new Savegame(arg_savegame);
SavegameTable::iterator i = find(savegame->get_filename());
if (i == savegames.end())
{ // don't know anything about the savegame
savegames.push_back(savegame);
}
else
{ // already have such a savegame
if ((*i)->get_status() == Savegame::FINISHED
&& savegame->get_status() == Savegame::ACCESSIBLE)
{ // saved savegame is better then new game
delete savegame;
}
else
{ // new game is better or equal, save it
delete *i;
*i = savegame;
}
}
flush();
}