kgamemessage.h
00001 /* 00002 This file is part of the TDE 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$ 00022 */ 00023 #ifndef __KGAMEMSG_H_ 00024 #define __KGAMEMSG_H_ 00025 00026 #include <tqdatastream.h> 00027 #include <kdemacros.h> 00028 00029 class KDE_EXPORT KGameMessage 00030 { 00031 public: 00044 static TQ_UINT32 createPlayerId(int player, TQ_UINT32 game); 00045 00054 static int rawPlayerId(TQ_UINT32 playerid); 00055 00063 static TQ_UINT32 rawGameId(TQ_UINT32 playerid); 00064 00071 static bool isPlayer(TQ_UINT32 id); 00072 00079 static bool isGame(TQ_UINT32 id); 00080 00088 static void createHeader(TQDataStream &msg, TQ_UINT32 sender, TQ_UINT32 receiver, int msgid); 00089 00095 static void extractHeader(TQDataStream &msg,TQ_UINT32 &sender, TQ_UINT32 &receiver, int &msgid); 00096 00100 static void createPropertyHeader(TQDataStream &msg, int id); 00101 00105 static void extractPropertyHeader(TQDataStream &msg, int &id); 00106 00110 static void createPropertyCommand(TQDataStream &msg, int cmdid, int pid, int cmd); 00111 00115 static void extractPropertyCommand(TQDataStream &msg, int &pid, int &cmd); 00116 00120 static int version(); 00121 00130 static TQString 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