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.2
Committed: Mon Oct 18 06:53:59 2010 UTC (16 years, 1 month ago) by sf-pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
gcc 4.5; moved some code; background colour support

File Contents

# User Rev Content
1 sf-pippijn 1.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 sf-pippijn 1.2 foreach (auto const &pair, map)
10 sf-pippijn 1.1 {
11     out << pair.first;
12     out << str;
13     out << pair.second;
14     out << str;
15     }
16     return out.str ();
17     }
18    
19     void
20     handshake_handler::version (Json::Value const &server_version)
21     {
22     Json::Value client_version = make::map {
23     "protver", 1,
24     "client", PACKAGE,
25     "clientver", PACKAGE_VERSION,
26     "osver", "linux/ncurses",
27     };
28     send ("version", client_version);
29    
30     std::map<char const *, int> const setup = {
31     { "itemcmd", 2 },
32     { "mapinfocmd", 1 },
33     { "extcmd", 2 },
34     { "spellmon", 1 },
35     { "excmd", 1 },
36     { "lzf", 0 },
37     { "frag", 1 },
38     { "tileset", 2 },
39     };
40     send ("setup", join (" ", setup) + "mapsize 31x31");
41    
42     send ("requestinfo", "skill_info");
43     send ("requestinfo", "spell_paths");
44    
45     {
46     Json::Value resource = make::array {
47     "resource",
48     "b",
49     "exp_table",
50     };
51     send ("exti", resource);
52     }
53    
54     send ("addme");
55     }