/
players.hpp
66 lines (50 loc) · 1.26 KB
/
players.hpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Distributed under the BSD License, see accompanying LICENSE.txt
// (C) Copyright 2010 John-John Tedro et al.
#ifndef _PLAYERS_H_
#define _PLAYERS_H_
#include <string>
#include <vector>
#include <iostream>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem.hpp>
#include "global.hpp"
#include "nbt/nbt.hpp"
namespace fs = boost::filesystem;
class player {
public:
fs::path path;
std::string name;
bool grammar_error;
bool in_pos;
int pos_c;
nbt::Int xPos, yPos, zPos;
player(const fs::path path);
};
class players_db {
public:
std::vector<player> players;
players_db(settings_t& s, const fs::path path) {
fs::path full_path = fs::system_complete( path );
if (!fs::is_directory(full_path)) {
return;
}
fs::directory_iterator end_iter;
for ( fs::directory_iterator dir_itr( full_path );
dir_itr != end_iter;
++dir_itr )
{
player p(dir_itr->path());
if (p.grammar_error) {
continue;
}
if (s.show_players_set.size() > 0) {
if (s.show_players_set.find(p.name) == s.show_players_set.end()) {
continue;
}
}
players.push_back(p);
}
}
};
#endif /* _PLAYERS_H_ */