~ubuntu-branches/ubuntu/saucy/lordsawar/saucy

« back to all changes in this revision

Viewing changes to src/game-client-decoder.h

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Barry deFreese
  • Date: 2008-12-20 13:52:12 UTC
  • mfrom: (1.1.6 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081220135212-noeb2w3y98ebo7o9
Tags: 0.1.4-1
[ Barry deFreese ]
* New upstream release.
* Move 0.0.8-2.1 changelog entry to correct point in changelog.
* Make lordsawar-data suggest lordsawar.
* Update my e-mail address.
* Add build-depends on intltool, uuid-dev, and libboost-dev.
* Don't install locales since there are no translations currently.
* Add simple man page for new lordsawar-pbm binary.
* Drop gcc4.3 patches as they have been fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2008 Ole Laursen
 
2
// Copyright (C) 2008 Ben Asselstine
 
3
//
 
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 2 of the License, or
 
7
//  (at your option) any later version.
 
8
//
 
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.
 
13
//
 
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 
 
17
//  02110-1301, USA.
 
18
 
 
19
#ifndef GAME_CLIENT_DECODER_H
 
20
#define GAME_CLIENT_DECODER_H
 
21
 
 
22
#include "config.h"
 
23
#include "chat-client.h"
 
24
 
 
25
#include <list>
 
26
#include <memory>
 
27
#include <sigc++/trackable.h>
 
28
#include <sigc++/signal.h>
 
29
class XML_Helper;
 
30
#include "network-action.h"
 
31
#include "network-history.h"
 
32
 
 
33
class GameScenario;
 
34
class Player;
 
35
 
 
36
class GameClientDecoder: public ChatClient
 
37
{
 
38
public:
 
39
  GameClientDecoder();
 
40
  ~GameClientDecoder();
 
41
 
 
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;
 
46
 
 
47
protected:
 
48
  class ActionLoader 
 
49
    {
 
50
  public:
 
51
      bool loadAction(std::string tag, XML_Helper* helper)
 
52
        {
 
53
          if (tag == Action::d_tag)
 
54
            {
 
55
              NetworkAction *action = &*actions.back();
 
56
              action->setAction(Action::handle_load(helper));
 
57
              return true;
 
58
            }
 
59
          if (tag == NetworkAction::d_tag) 
 
60
            {
 
61
              NetworkAction * action = new NetworkAction(helper);
 
62
              actions.push_back(action);
 
63
              return true;
 
64
            }
 
65
          return false;
 
66
        }
 
67
 
 
68
      std::list<NetworkAction *> actions;
 
69
    };
 
70
  class HistoryLoader 
 
71
    {
 
72
  public:
 
73
      bool loadHistory(std::string tag, XML_Helper* helper)
 
74
        {
 
75
          if (tag == History::d_tag)
 
76
            {
 
77
              NetworkHistory *history = &*histories.back();
 
78
              history->setHistory(History::handle_load(helper));
 
79
              return true;
 
80
            }
 
81
          if (tag == NetworkHistory::d_tag) 
 
82
            {
 
83
              NetworkHistory* history = new NetworkHistory(helper);
 
84
              histories.push_back(history);
 
85
              return true;
 
86
            }
 
87
          return false;
 
88
        }
 
89
 
 
90
      std::list<NetworkHistory *> histories;
 
91
    };
 
92
 
 
93
 
 
94
protected:
 
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,
 
99
                    Player *player);
 
100
  int decodeHistories(std::list<NetworkHistory*> histories);
 
101
 
 
102
};
 
103
 
 
104
#endif