1 // Copyright (C) 2008 Ole Laursen
2 // Copyright (C) 2008 Ben Asselstine
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Library General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 #ifndef GAME_CLIENT_DECODER_H
20 #define GAME_CLIENT_DECODER_H
23 #include "chat-client.h"
27 #include <sigc++/trackable.h>
28 #include <sigc++/signal.h>
30 #include "network-action.h"
31 #include "network-history.h"
36 class GameClientDecoder: public ChatClient
42 sigc::signal<void, std::string> game_scenario_received;
43 sigc::signal<void, Player *> remote_player_moved;
44 sigc::signal<void, Player *> remote_player_named;
45 sigc::signal<void, Player *> remote_player_died;
51 bool loadAction(std::string tag, XML_Helper* helper)
53 if (tag == Action::d_tag)
55 NetworkAction *action = &*actions.back();
56 action->setAction(Action::handle_load(helper));
59 if (tag == NetworkAction::d_tag)
61 NetworkAction * action = new NetworkAction(helper);
62 actions.push_back(action);
68 std::list<NetworkAction *> actions;
73 bool loadHistory(std::string tag, XML_Helper* helper)
75 if (tag == History::d_tag)
77 NetworkHistory *history = &*histories.back();
78 history->setHistory(History::handle_load(helper));
81 if (tag == NetworkHistory::d_tag)
83 NetworkHistory* history = new NetworkHistory(helper);
84 histories.push_back(history);
90 std::list<NetworkHistory *> histories;
95 void gotActions(const std::string &payload);
96 void gotHistories(const std::string &payload);
97 void gotScenario(const std::string &payload);
98 int decodeActions(std::list<NetworkAction*> actions,
100 int decodeHistories(std::list<NetworkHistory*> histories);