| 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 |
sf-pippijn |
1.3 |
#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 |
sf-pippijn |
1.4 |
return name.sysname; |
| 30 |
sf-pippijn |
1.3 |
} |
| 31 |
|
|
#endif |
| 32 |
|
|
|
| 33 |
sf-pippijn |
1.1 |
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 |
sf-pippijn |
1.3 |
"osver", osver (), |
| 41 |
sf-pippijn |
1.1 |
}; |
| 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 |
|
|
} |