ManaPlus
charserverrecv.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "net/ea/charserverrecv.h"
25 
26 #include "client.h"
27 
29 #include "gui/windows/okdialog.h"
30 
32 
33 #include "net/character.h"
34 #include "net/charserverhandler.h"
35 #include "net/messagein.h"
36 
37 #include "utils/gettext.h"
38 
39 #include "debug.h"
40 
41 namespace Ea
42 {
43 
45 {
46  BLOCK_START("CharServerRecv::processCharLoginError")
47  switch (msg.readUInt8("error"))
48  {
49  case 0:
50  // TRANSLATORS: error message
51  errorMessage = _("Access denied. Most likely, there are "
52  "too many players on this server.");
53  break;
54  case 1:
55  // TRANSLATORS: error message
56  errorMessage = _("Cannot use this ID.");
57  break;
58  default:
59  // TRANSLATORS: error message
60  errorMessage = _("Unknown char-server failure.");
61  break;
62  }
64  BLOCK_END("CharServerRecv::processCharLoginError")
65 }
66 
68 {
69  BLOCK_START("CharServerRecv::processCharCreateFailed")
70  switch (msg.readUInt8("error"))
71  {
72  case 1:
73  case 0:
74  default:
75  // TRANSLATORS: error message
76  errorMessage = _("Failed to create character. Most "
77  "likely the name is already taken.");
78  break;
79  case 2:
80  // TRANSLATORS: error message
81  errorMessage = _("Wrong name.");
82  break;
83  case 3:
84  // TRANSLATORS: error message
85  errorMessage = _("Incorrect stats.");
86  break;
87  case 4:
88  // TRANSLATORS: error message
89  errorMessage = _("Incorrect hair.");
90  break;
91  case 5:
92  // TRANSLATORS: error message
93  errorMessage = _("Incorrect slot.");
94  break;
95  case 6:
96  // TRANSLATORS: error message
97  errorMessage = _("Incorrect race.");
98  break;
99  case 7:
100  // TRANSLATORS: error message
101  errorMessage = _("Incorrect look.");
102  break;
103  }
105  // TRANSLATORS: error message header
106  _("Error"),
107  errorMessage,
108  // TRANSLATORS: ok dialog button
109  _("OK"),
111  Modal_true,
113  nullptr,
114  260);
117  BLOCK_END("CharServerRecv::processCharCreateFailed")
118 }
119 
121 {
122  BLOCK_START("CharServerRecv::processCharDelete")
130  // TRANSLATORS: info message header
131  _("Info"),
132  // TRANSLATORS: info message
133  _("Character deleted."),
134  // TRANSLATORS: ok dialog button
135  _("OK"),
137  Modal_true,
139  nullptr,
140  260);
141  BLOCK_END("CharServerRecv::processCharDelete")
142 }
143 
144 } // namespace Ea
void setState(const StateT state)
Definition: client.h:66
static void unlockCharSelectDialog()
static void updateCharSelectDialog()
static Net::Character * mSelectedCharacter
static Net::Characters mCharacters
static CharCreateDialog * mCharCreateDialog
#define CREATEWIDGET(type,...)
Definition: createwidget.h:29
Client * client
Definition: client.cpp:118
std::string errorMessage
Definition: client.cpp:116
#define _(s)
Definition: gettext.h:35
#define A_UNUSED
Definition: localconsts.h:160
const bool Modal_true
Definition: modal.h:30
bool msg(InputEvent &event)
Definition: chat.cpp:39
void processCharLoginError(Net::MessageIn &msg)
void processCharCreateFailed(Net::MessageIn &msg)
void processCharDelete(Net::MessageIn &msg)
@ ERROR
Definition: state.h:35
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
const bool ShowCenter_true
Definition: showcenter.h:30