KDEGames

kgamemessage.h
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Martin Heni (kde at heni-online.de)
4  Copyright (C) 2001 Andreas Beckermann ([email protected])
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KGAMEMESSAGE_H_
22 #define __KGAMEMESSAGE_H_
23 
24 #include <QDataStream>
25 #include "libkdegamesprivate_export.h"
26 
30 class KDEGAMESPRIVATE_EXPORT KGameMessage
31 {
32  public:
45  static quint32 createPlayerId(int player, quint32 game);
46 
55  static int rawPlayerId(quint32 playerid);
56 
64  static quint32 rawGameId(quint32 playerid);
65 
72  static bool isPlayer(quint32 id);
73 
80  static bool isGame(quint32 id);
81 
89  static void createHeader(QDataStream &msg, quint32 sender, quint32 receiver, int msgid);
90 
96  static void extractHeader(QDataStream &msg,quint32 &sender, quint32 &receiver, int &msgid);
97 
101  static void createPropertyHeader(QDataStream &msg, int id);
102 
106  static void extractPropertyHeader(QDataStream &msg, int &id);
107 
111  static void createPropertyCommand(QDataStream &msg, int cmdid, int pid, int cmd);
112 
116  static void extractPropertyCommand(QDataStream &msg, int &pid, int &cmd);
117 
121  static int version();
122 
130  static QString messageId2Text(int msgid);
131 
132 
138 // please document every new id with a short comment
139  enum GameMessageIds {
140 // game init, game load, disconnect, ...
141  IdSetupGame=1, // sent to a newly connected player
142  IdSetupGameContinue=2, // continue the setup
143  IdGameLoad=3, // load/save the game to the client
144  IdGameConnected=4, // Client successfully connected to master
145  IdSyncRandom=5, // new random seed set - sync games
146  IdDisconnect=6, // KGame object disconnects from game
147  IdGameSetupDone=7, // New game client is now operational
148 
149 // properties
150  IdPlayerProperty=20, // a player property changed
151  IdGameProperty=21, // a game property changed
152 
153 // player management
154  IdAddPlayer=30, // add a player
155  IdRemovePlayer=31, // the player will be removed
156  IdActivatePlayer=32, // Activate a player
157  IdInactivatePlayer=33, // Inactivate a player
158  IdTurn=34, // Turn to be prepared
159 
160 // to-be-categorized
161  IdError=100, // an error occurred
162  IdPlayerInput=101, // a player input occurred
163  IdIOAdded=102, // KGameIO got added to a player...init this IO
164 
165 // special ids for computer player
166  IdProcessQuery=220, // Process queries data (process only)
167  IdPlayerId=221, // PlayerId got changed (process only)
168 
169  IdUser=256 // a user specified message
170  };
171 };
172 
173 #endif
Base * createHeader(const QByteArray &type)
KDB_EXPORT KDbVersionInfo version()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:36:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.