ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/handshake_handler/version.h
Revision: 1.4
Committed: Wed Oct 20 08:33:42 2010 UTC (16 years, 1 month ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
Log Message:
2 glyphs / map space

File Contents

# Content
1 #include "autoconf.h"
2
3 #include <json/json.h>
4
5 static std::string
6 join (char const *str, std::map<char const *, int> const &map)
7 {
8 std::ostringstream out;
9 foreach (auto const &pair, map)
10 {
11 out << pair.first;
12 out << str;
13 out << pair.second;
14 out << str;
15 }
16 return out.str ();
17 }
18
19 #if _WIN32
20 static char const *osver () { return "mswin32"; }
21 #else
22 # include <sys/utsname.h>
23
24 static std::string
25 osver ()
26 {
27 utsname name;
28 uname (&name);
29 return name.sysname;
30 }
31 #endif
32
33 void
34 handshake_handler::version (Json::Value const &server_version)
35 {
36 Json::Value client_version = make::map {
37 "protver", 1,
38 "client", PACKAGE,
39 "clientver", PACKAGE_VERSION,
40 "osver", osver (),
41 };
42 send ("version", client_version);
43
44 std::map<char const *, int> const setup = {
45 { "itemcmd", 2 },
46 { "mapinfocmd", 1 },
47 { "extcmd", 2 },
48 { "spellmon", 1 },
49 { "excmd", 1 },
50 { "lzf", 0 },
51 { "frag", 1 },
52 { "tileset", 2 },
53 };
54 send ("setup", join (" ", setup) + "mapsize 31x31");
55
56 send ("requestinfo", "skill_info");
57 send ("requestinfo", "spell_paths");
58
59 {
60 Json::Value resource = make::array {
61 "resource",
62 "b",
63 "exp_table",
64 };
65 send ("exti", resource);
66 }
67
68 send ("addme");
69 }