~ubuntu-branches/ubuntu/trusty/qgo/trusty-proposed

« back to all changes in this revision

Viewing changes to src/network/playergamelistings.h

  • Committer: Package Import Robot
  • Author(s): Yann Dirson
  • Date: 2013-12-03 21:07:19 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20131203210719-beh10ojeb81rdx2v
Tags: 2.0~git-20131123-1
* Snapshot from new upstream tree.
  * Working interface for managing credentials (Closes: #596439).
  * Avoid looping too much waiting for GTP engine (Closes: #419855).
  * Dropping patches 01_gnugo, 04_desktop, included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#ifndef PLAYERGAMELISTING_H
24
24
#define PLAYERGAMELISTING_H
25
25
 
 
26
#include <QString>
 
27
 
26
28
class GameData;
27
29
 
 
30
/* Private constructors and destructors ensure that only the
 
31
 * friend class Room
 
32
 * can create or destroy instances of these classes */
 
33
 
28
34
class PlayerListing
29
35
{
 
36
private:
 
37
    PlayerListing() : id(0),
 
38
    online(false),
 
39
    name(""),
 
40
    notnickname(""),
 
41
    info(""),
 
42
    idletime(""),
 
43
    seconds_idle(0),
 
44
    rank(""),
 
45
    rank_score(0),
 
46
    country(""),
 
47
    wins(0),
 
48
    losses(0),
 
49
    rated_games(0),
 
50
    observing(0),
 
51
    playing(0),
 
52
    extInfo(""),
 
53
    email_address(""),
 
54
    nmatch(0),
 
55
    nmatch_handicapMin(0),
 
56
    specialbyte(0),
 
57
    pro(false),
 
58
    dialog_opened(false),
 
59
    game_dialog_opened(false),
 
60
    friendWatchType(none),
 
61
    notify(false),
 
62
    hidden(false) {}
 
63
    ~PlayerListing() {}
 
64
    friend class Room;
30
65
public:
31
66
        unsigned short id;
32
67
        bool online;
64
99
        bool game_dialog_opened;
65
100
        enum FriendWatchType { none, friended, watched, blocked } friendWatchType;
66
101
        bool notify;
67
 
        bool hidden;
68
 
        PlayerListing() : id(0), 
69
 
        online(0),
70
 
        name(""),
71
 
        notnickname(""),
72
 
        info(""),
73
 
        idletime(""),
74
 
        seconds_idle(0),
75
 
        rank(""),
76
 
        rank_score(0),
77
 
        country(""),
78
 
        wins(0), 
79
 
        losses(0),
80
 
        rated_games(0),
81
 
        observing(0),
82
 
        playing(0), 
83
 
        extInfo(""),
84
 
        email_address(""),
85
 
        nmatch(0),
86
 
        nmatch_handicapMin(0),
87
 
        specialbyte(0),
88
 
        pro(false),
89
 
        dialog_opened(false),
90
 
        game_dialog_opened(false),
91
 
        friendWatchType(none),
92
 
        notify(false),
93
 
        hidden(false) {};
 
102
    bool hidden;
94
103
};
95
104
 
96
105
/* We need to alter copy constructor to have and respect a bit field.
98
107
 * existing listing before change and update.*/
99
108
class GameListing
100
109
{
 
110
private:
 
111
    GameListing() : running(false),
 
112
    moves(0),
 
113
    board_size(19),
 
114
    handicap(0),
 
115
    komi(6.5),
 
116
    white(0),
 
117
    black(0),
 
118
    _white_name("-"),
 
119
    _black_name("-"),
 
120
    _white_rank("-"),
 
121
    _black_rank("-"),
 
122
    _white_rank_score(0),
 
123
    _black_rank_score(0),
 
124
    observers(0),
 
125
    result(""),
 
126
      By(""), FR(""), comment(""),
 
127
    flags(IN_PROGRESS),
 
128
    rated(0),
 
129
    owner_id(0),
 
130
    isRoomOnly(false),
 
131
    isBroadcast(false),
 
132
    isBetting(false),
 
133
    isLocked(false),
 
134
    gameData(NULL) {}
 
135
    ~GameListing() {}
 
136
    friend class Room;
101
137
public:
102
138
    bool running;
103
139
        unsigned int number;
113
149
        QString _white_rank;
114
150
        QString _black_rank;
115
151
        unsigned int _white_rank_score;
116
 
        unsigned int _black_rank_score;
117
 
        /* FIXME neither const or & removal kept the below from
118
 
        * crashing */
 
152
    unsigned int _black_rank_score;
119
153
        const QString & white_name(void) const
120
 
        {
121
 
                if(white)
 
154
    {
 
155
        if(white)
122
156
                        return white->name;
123
 
                else
 
157
        else
124
158
                        return _white_name;
125
 
        };
 
159
    }
126
160
        const QString & white_rank(void) const
127
 
        {
128
 
                if(white)
 
161
    {
 
162
        if(white)
129
163
                        return white->rank;
130
 
                else
 
164
        else
131
165
                        return _white_rank;
132
 
        };
 
166
    }
133
167
        unsigned int white_rank_score(void) const               //for sorting
134
168
        {
135
 
                if(white)
 
169
        if(white)
136
170
                        return white->rank_score;
137
 
                else
 
171
        else
138
172
                        return _white_rank_score;
139
 
        };
 
173
    }
140
174
        const QString & black_name(void) const
141
175
        {
142
 
                if(black)
 
176
        if(black)
143
177
                        return black->name;
144
 
                else
 
178
        else
145
179
                        return _black_name;
146
 
        };
 
180
    }
147
181
        const QString & black_rank(void) const
148
182
        {
149
 
                if(black)
 
183
        if(black)
150
184
                        return black->rank;
151
 
                else
 
185
        else
152
186
                        return _black_rank;
153
 
        };
 
187
    }
154
188
        unsigned int black_rank_score(void) const       //for sorting
155
189
        {
156
190
                if(black)
157
191
                        return black->rank_score;
158
192
                else
159
193
                        return _black_rank_score;
160
 
        };
 
194
    }
 
195
 
161
196
        unsigned int observers;
162
197
        QString result;
163
198
        GameMode gameType;              //this needs to be consistent
177
212
        std::vector <PlayerListing *> observer_list;
178
213
        GameData * gameData;
179
214
        /* Also need byomi time, one color go, running, private, flags, ranked, etc.*/
180
 
        GameListing() : running(0), 
181
 
        moves(0), 
182
 
        board_size(19), 
183
 
        handicap(0), 
184
 
        komi(6.5), 
185
 
        white(0), 
186
 
        black(0), 
187
 
        _white_name("-"), 
188
 
        _black_name("-"), 
189
 
        _white_rank("-"), 
190
 
        _black_rank("-"), 
191
 
        _white_rank_score(0), 
192
 
        _black_rank_score(0), 
193
 
        observers(0), 
194
 
        result(""),
195
 
        flags(IN_PROGRESS),
196
 
        rated(0), 
197
 
        owner_id(0), 
198
 
        isRoomOnly(false),
199
 
        isBroadcast(false),
200
 
        isBetting(false),
201
 
        isLocked(false),
202
 
        gameData(NULL) {};
203
215
};
204
216
#endif //PLAYERGAMELISTINGS_H