kgamemessage.h

00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Martin Heni (martin@heni-online.de)
00004     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 /*
00021     $Id: kgamemessage.h 465369 2005-09-29 14:33:08Z mueller $
00022 */
00023 #ifndef __KGAMEMSG_H_
00024 #define __KGAMEMSG_H_
00025 
00026 #include <qdatastream.h>
00027 #include <kdemacros.h>
00028 
00029 class KDE_EXPORT KGameMessage
00030 {
00031   public:
00044     static Q_UINT32 createPlayerId(int player, Q_UINT32 game);
00045 
00054     static int rawPlayerId(Q_UINT32 playerid);
00055 
00063     static Q_UINT32 rawGameId(Q_UINT32 playerid);
00064 
00071     static bool isPlayer(Q_UINT32 id);
00072 
00079     static bool isGame(Q_UINT32 id);
00080 
00088     static void createHeader(QDataStream &msg, Q_UINT32 sender, Q_UINT32 receiver, int msgid);
00089 
00095     static void extractHeader(QDataStream &msg,Q_UINT32 &sender, Q_UINT32 &receiver, int &msgid);
00096 
00100     static void createPropertyHeader(QDataStream &msg, int id);
00101 
00105     static void extractPropertyHeader(QDataStream &msg, int &id);
00106 
00110     static void createPropertyCommand(QDataStream &msg, int cmdid, int pid, int cmd);
00111 
00115     static void extractPropertyCommand(QDataStream &msg, int &pid, int &cmd);
00116 
00120     static int version();
00121 
00130     static QString messageId2Text(int msgid);
00131 
00132 
00138 // please document every new id with a short comment
00139   enum GameMessageIds {
00140 // game init, game load, disconnect, ...
00141     IdSetupGame=1,         // sent to a newly connected player
00142     IdSetupGameContinue=2, // continue the setup
00143     IdGameLoad=3,          // load/save the game to the client
00144     IdGameConnected=4,     // Client successfully connected to master
00145     IdSyncRandom=5,        // new random seed set - sync games
00146     IdDisconnect=6,        // KGame object disconnects from game
00147     IdGameSetupDone=7,     // New game client is now operational
00148 
00149 // properties
00150     IdPlayerProperty=20,   // a player property changed
00151     IdGameProperty=21,     // a game property changed
00152 
00153 // player management
00154     IdAddPlayer=30,         // add a player
00155     IdRemovePlayer=31,      // the player will be removed
00156     IdActivatePlayer=32,    // Activate a player
00157     IdInactivatePlayer=33,  // Inactivate a player
00158     IdTurn=34,              // Turn to be prepared
00159 
00160 // to-be-categorized
00161     IdError=100,            // an error occurred
00162     IdPlayerInput=101,      // a player input occurred
00163     IdIOAdded=102,          // KGameIO got added to a player...init this IO
00164 
00165 // special ids for computer player
00166     IdProcessQuery=220,     // Process queries data (process only)
00167     IdPlayerId=221,         // PlayerId got changed (process only)
00168 
00169     IdUser=256          // a user specified message
00170   };
00171 };
00172 
00173 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys