ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/communicator/command_parser.cpp
Revision: 1.2
Committed: Mon Oct 18 06:53:58 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.1: +3 -20 lines
Log Message:
gcc 4.5; moved some code; background colour support

File Contents

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