• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Return-To-The-Roots / s25client / 4621997437

pending completion
4621997437

push

github

Flow86
fix path

21886 of 43348 relevant lines covered (50.49%)

31880.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

29.03
/libs/s25main/JoinPlayerInfo.cpp
1
// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org)
2
//
3
// SPDX-License-Identifier: GPL-2.0-or-later
4

5
#include "JoinPlayerInfo.h"
6
#include "RTTR_Assert.h"
7
#include "mygettext/mygettext.h"
8
#include "s25util/Serializer.h"
9
#include <boost/format.hpp>
10

11
JoinPlayerInfo::JoinPlayerInfo() = default;
41✔
12

13
JoinPlayerInfo::JoinPlayerInfo(const BasePlayerInfo& baseInfo) : PlayerInfo(baseInfo), originName(name) {}
×
14

15
JoinPlayerInfo::JoinPlayerInfo(const PlayerInfo& playerInfo) : PlayerInfo(playerInfo), originName(name) {}
×
16

17
JoinPlayerInfo::JoinPlayerInfo(Serializer& ser)
3✔
18
    : PlayerInfo(ser), originName(ser.PopLongString()), isReady(ser.PopBool())
3✔
19
{}
3✔
20

21
void JoinPlayerInfo::Serialize(Serializer& ser) const
3✔
22
{
23
    PlayerInfo::Serialize(ser);
3✔
24
    ser.PushLongString(originName);
3✔
25
    ser.PushBool(isReady);
3✔
26
}
3✔
27

28
void JoinPlayerInfo::FixSwappedSaveSlot(JoinPlayerInfo& other)
×
29
{
30
    // TODO: This has a code smell.
31
    // Probably some composition instead of inheritance required?
32

33
    // Unswap fixed stuff
34
    using std::swap;
35
    swap(originName, other.originName);
×
36
    swap(nation, other.nation);
×
37
    swap(color, other.color);
×
38
    swap(team, other.team);
×
39
}
×
40

41
void JoinPlayerInfo::SetAIName(unsigned playerId)
×
42
{
43
    RTTR_Assert(ps == PlayerState::AI);
×
44
    name = MakeAIName(aiInfo, playerId);
×
45
}
×
46

47
std::string JoinPlayerInfo::MakeAIName(const AI::Info& aiInfo, unsigned playerId)
×
48
{
49
    std::string name =
50
      (boost::format((aiInfo.type == AI::Type::Dummy) ? _("Dummy %u") : _("Computer %u")) % playerId).str();
×
51
    name += _(" (AI)");
×
52

53
    if(aiInfo.type == AI::Type::Default)
×
54
    {
55
        switch(aiInfo.level)
×
56
        {
57
            case AI::Level::Easy: name += _(" (easy)"); break;
×
58
            case AI::Level::Medium: name += _(" (medium)"); break;
×
59
            case AI::Level::Hard: name += _(" (hard)"); break;
×
60
        }
61
    }
62

63
    return name;
×
64
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc