GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/tmwa/generalrecv.cpp Lines: 3 22 13.6 %
Date: 2017-11-29 Branches: 2 12 16.7 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "net/tmwa/generalrecv.h"
24
25
#include "client.h"
26
#include "logger.h"
27
28
#include "net/messagein.h"
29
30
#include "utils/cast.h"
31
#include "utils/gettext.h"
32
33
#include "debug.h"
34
35
namespace TmwAthena
36
{
37
38
2
ServerInfo charServer;
39
2
ServerInfo mapServer;
40
41
void GeneralRecv::processConnectionProblem(Net::MessageIn &msg)
42
{
43
    const uint8_t code = msg.readUInt8("flag");
44
    logger->log("Connection problem: %u", CAST_U32(code));
45
46
    switch (code)
47
    {
48
        case 0:
49
            // TRANSLATORS: error message
50
            errorMessage = _("Authentication failed.");
51
            break;
52
        case 1:
53
            // TRANSLATORS: error message
54
            errorMessage = _("No servers available.");
55
            break;
56
        case 2:
57
            if (client->getState() == State::GAME)
58
            {
59
                // TRANSLATORS: error message
60
                errorMessage = _("Someone else is trying to use this "
61
                         "account.");
62
            }
63
            else
64
            {
65
                // TRANSLATORS: error message
66
                errorMessage = _("This account is already logged in.");
67
            }
68
            break;
69
        case 3:
70
            // TRANSLATORS: error message
71
            errorMessage = _("Speed hack detected.");
72
            break;
73
        case 8:
74
            // TRANSLATORS: error message
75
            errorMessage = _("Duplicated login.");
76
            break;
77
        default:
78
            // TRANSLATORS: error message
79
            errorMessage = _("Unknown connection error.");
80
            break;
81
    }
82
    client->setState(State::ERROR);
83
}
84
85

6
}  // namespace TmwAthena