• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
  • kgame
kgameerror.cpp
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4 Copyright (C) 2001 Martin Heni (martin@heni-online.de)
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 $Id$
22*/
23
24#include "kgameerror.h"
25#include "kgamemessage.h"
26
27#include <tdelocale.h>
28
29TQByteArray KGameError::errVersion(int remoteVersion)
30{
31 TQByteArray b;
32 TQDataStream s(b, IO_WriteOnly);
33 s << (TQ_INT32)KGameMessage::version();
34 s << (TQ_INT32)remoteVersion;
35 return b;
36}
37
38TQByteArray KGameError::errCookie(int localCookie, int remoteCookie)
39{
40 TQByteArray b;
41 TQDataStream s(b, IO_WriteOnly);
42 s << (TQ_INT32)localCookie;
43 s << (TQ_INT32)remoteCookie;
44 return b;
45}
46
47TQString KGameError::errorText(int errorCode, const TQByteArray& message)
48{
49 TQDataStream s(message, IO_ReadOnly);
50 return errorText(errorCode, s);
51}
52
53TQString KGameError::errorText(int errorCode, TQDataStream& s)
54{
55 TQString text;
56 switch (errorCode) {
57 case Cookie:
58 {
59 TQ_INT32 cookie1;
60 TQ_INT32 cookie2;
61 s >> cookie1;
62 s >> cookie2;
63 text = i18n("Cookie mismatch!\nExpected Cookie: %1\nReceived Cookie: %2").arg(cookie1).arg(cookie2);
64 break;
65 }
66 case Version:
67 {
68 TQ_INT32 version1;
69 TQ_INT32 version2;
70 s >> version1;
71 s >> version2;
72 text = i18n("KGame Version mismatch!\nExpected Version: %1\nReceived Version: %2\n").arg(version1).arg(version2);
73 break;
74 }
75 default:
76 text = i18n("Unknown error code %1").arg(errorCode);
77 }
78 return text;
79}
80

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.4
This website is maintained by Timothy Pearson.