forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasecamp.cpp
44 lines (35 loc) · 956 Bytes
/
basecamp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <algorithm>
#include <sstream>
#include "basecamp.h"
#include "output.h"
#include "translations.h"
basecamp::basecamp()
: name(), posx(0), posy(0)
{
}
basecamp::basecamp(std::string const &name_, int const posx_, int const posy_)
: name(name_), posx(posx_), posy(posy_)
{
}
std::string basecamp::board_name() const
{
//~ Name of a basecamp
return string_format( _("%s Board"), name.c_str() );
}
std::string basecamp::save_data() const
{
std::stringstream data;
// TODO: This will lose underscores, is that a problem?
// strip spaces from name
std::string savename = name;
replace(savename.begin(), savename.end(), ' ', '_');
data << savename << " " << posx << " " << posy;
return data.str();
}
void basecamp::load_data(std::string const &data)
{
std::stringstream stream(data);
stream >> name >> posx >> posy;
// add space to name
replace(name.begin(), name.end(), '_', ' ');
}