ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/dclient/src/backend/communicator/command_parser.cpp
Revision: 1.3
Committed: Mon Oct 18 14:11:45 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.2: +1 -3 lines
Log Message:
check and log but do not die when ncurses stuff fails

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include "deliantra/command_parser.h"
2    
3 sf-pippijn 1.2 #include "adt/reverse_view.h"
4    
5 sf-pippijn 1.1 #include <cassert>
6     #include <sstream>
7     #include <stdexcept>
8    
9     void
10     command_parser::receive (std::string const &cmd, std::string const &args)
11     {
12     std::istringstream argstream (args);
13     if (false) ;
14     else if (cmd == "addme_success") on_addme_success (argstream);
15     else if (cmd == "addspell" ) on_addspell (argstream);
16     else if (cmd == "anim" ) on_anim (argstream);
17     else if (cmd == "delinv" ) on_delinv (argstream);
18     else if (cmd == "delitem" ) on_delitem (argstream);
19     else if (cmd == "drawinfo" ) on_drawinfo (argstream);
20     else if (cmd == "ext" ) on_ext (argstream);
21     else if (cmd == "fx" ) on_fx (argstream);
22     else if (cmd == "item2" ) on_item2 (argstream);
23     else if (cmd == "map1a" ) on_map1a (argstream);
24     else if (cmd == "mapinfo" ) on_mapinfo (argstream);
25     else if (cmd == "map_scroll" ) on_map_scroll (argstream);
26     else if (cmd == "msg" ) on_msg (argstream);
27     else if (cmd == "newmap" ) on_newmap (argstream);
28     else if (cmd == "player" ) on_player (argstream);
29     else if (cmd == "query" ) on_query (argstream);
30     else if (cmd == "replyinfo" ) on_replyinfo (argstream);
31     else if (cmd == "setup" ) on_setup (argstream);
32     else if (cmd == "stats" ) on_stats (argstream);
33     else if (cmd == "upditem" ) on_upditem (argstream);
34     else if (cmd == "updspell" ) on_updspell (argstream);
35     else if (cmd == "version" ) on_version (argstream);
36     else
37     {
38 sf-pippijn 1.3 LOG () << "unhandled command: " << cmd << " " << args << "\n";
39 sf-pippijn 1.1 throw std::runtime_error ("unknown command: `" + cmd + "' args:" + args);
40     }
41     }
42    
43     void
44     command_parser::add_command_handler (interface::command_handler &handler)
45     {
46     handlers.push_back (&handler);
47     }
48    
49    
50     #include "deliantra/netio.h"
51    
52     static std::pair<std::string, std::string>
53     split2 (std::string const &s, char ch)
54     {
55     size_t pos = s.find_first_of (ch);
56     return { s.substr (0, pos), s.substr (pos + 1) };
57     }
58    
59 sf-pippijn 1.2 #define emit foreach (interface::command_handler *handler, reverse (handlers)) handler->
60 sf-pippijn 1.1
61     #include "command_parser/addme_success.h"
62     #include "command_parser/addspell.h"
63     #include "command_parser/anim.h"
64     #include "command_parser/delinv.h"
65     #include "command_parser/delitem.h"
66     #include "command_parser/drawinfo.h"
67     #include "command_parser/ext.h"
68     #include "command_parser/fx.h"
69     #include "command_parser/item2.h"
70     #include "command_parser/map1a.h"
71     #include "command_parser/mapinfo.h"
72     #include "command_parser/map_scroll.h"
73     #include "command_parser/msg.h"
74     #include "command_parser/newmap.h"
75     #include "command_parser/player.h"
76     #include "command_parser/query.h"
77     #include "command_parser/replyinfo.h"
78     #include "command_parser/setup.h"
79     #include "command_parser/stats.h"
80     #include "command_parser/upditem.h"
81     #include "command_parser/updspell.h"
82     #include "command_parser/version.h"