ovcc-network-gamedata-message.vala 2.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* 
 * 
 * Copyright (C) 2011 Colomban Wendling <ban@herbesfolles.org>
 *                    Jonathan Michalon <studios.chalmion@no-log.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

/**
 * Login message with login, password and current status
 */
public class OVCC.Network.GamedataMessage : VariantMessage
{
  public override MessageType message_type  { get { return MessageType.GAMEDATA; } }
  
  public uint[]   stack_ids         = null;
  public string[] player_nicks      = null;
30
31
  public string   tiles_data        { get; set; default = null; }
  public string   tileset_data      { get; set; default = null; }
32
33
34
35
36
37
38
39
40
41
42
43

  public State    status            { get; set; default = State.OK; }

  public enum State
  {
    OK,
    FAILED
  }

  
  public GamedataMessage (uint[] ids, string[] nicks, string tiles, string tileset)
  {
44
    Object (tiles_data: tiles, tileset_data: tileset);
45
46
47
48
49
50
51
52
    stack_ids    = ids;
    player_nicks = nicks;
  }

  protected override Variant build_variant ()
  {
    Variant ids   = stack_ids;
    Variant nicks = player_nicks;
53
54

    return new Variant ("(ivvss)", status, ids, nicks, tiles_data, tileset_data);
55
56
57
58
59
60
61
62
63
64
65
66
  }
  protected override void parse_variant (uint8[] data)
  {
    State s;
    Variant ids;
    Variant nicks;
    string t;
    string ts;
    parse_data (data, "(ivvss)", out s, out ids, out nicks, out t, out ts);
    status = s;
    stack_ids = (uint[]) ids;
    player_nicks = (string[]) nicks;
67
68
    tiles_data = t;
    tileset_data = ts;
69
70
  }
}