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

Return-To-The-Roots / s25client / 15686629494

16 Jun 2025 04:38PM UTC coverage: 50.442% (-0.03%) from 50.467%
15686629494

Pull #1534

github

web-flow
Merge 0307ea36d into 67a057674
Pull Request #1534: Portrait support

58 of 162 new or added lines in 17 files covered. (35.8%)

23 existing lines in 5 files now uncovered.

22502 of 44610 relevant lines covered (50.44%)

33921.51 hits per line

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

97.37
/libs/s25main/BasePlayerInfo.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 "BasePlayerInfo.h"
6
#include "helpers/serializeEnums.h"
7
#include "gameData/PortraitConsts.h"
8
#include "s25util/colors.h"
9

10
BasePlayerInfo::BasePlayerInfo()
260✔
11
    : ps(PlayerState::Free), portraitIndex(0), nation(Nation::Romans), color(PLAYER_COLORS[0]), team(Team::None)
260✔
12
{}
260✔
13

14
BasePlayerInfo::BasePlayerInfo(Serializer& ser, int serializedVersion, bool lightData)
30✔
15
    : ps(helpers::popEnum<PlayerState>(ser)), aiInfo(!lightData || ps == PlayerState::AI ? ser : AI::Info())
30✔
16
{
17
    if(lightData && !isUsed())
30✔
18
    {
19
        portraitIndex = 0;
6✔
20
        nation = Nation::Romans;
6✔
21
        team = Team::None;
6✔
22
        color = PLAYER_COLORS[0];
6✔
23
    } else
24
    {
25
        name = ser.PopLongString();
24✔
26
        portraitIndex = (serializedVersion >= 1) ? ser.PopUnsignedInt() : 0;
24✔
27
        if(portraitIndex >= Portraits.size())
24✔
28
        {
NEW
29
            portraitIndex = 0;
×
30
        }
31
        nation = helpers::popEnum<Nation>(ser);
24✔
32
        color = ser.PopUnsignedInt();
24✔
33
        team = helpers::popEnum<Team>(ser);
24✔
34
    }
35
}
30✔
36

37
void BasePlayerInfo::Serialize(Serializer& ser, bool lightData) const
26✔
38
{
39
    helpers::pushEnum<uint8_t>(ser, ps);
26✔
40
    if(lightData && !isUsed())
26✔
41
        return;
5✔
42
    if(!lightData || ps == PlayerState::AI)
21✔
43
        aiInfo.serialize(ser);
13✔
44
    ser.PushLongString(name);
21✔
45
    ser.PushUnsignedInt(portraitIndex);
21✔
46
    helpers::pushEnum<uint8_t>(ser, nation);
21✔
47
    ser.PushUnsignedInt(color);
21✔
48
    helpers::pushEnum<uint8_t>(ser, team);
21✔
49
}
50

51
int BasePlayerInfo::GetColorIdx() const
2✔
52
{
53
    return GetColorIdx(color);
2✔
54
}
55

56
int BasePlayerInfo::GetColorIdx(unsigned color) //-V688
2✔
57
{
58
    for(int i = 0; i < static_cast<int>(PLAYER_COLORS.size()); ++i)
18✔
59
    {
60
        if(PLAYER_COLORS[i] == color)
17✔
61
            return i;
1✔
62
    }
63
    return -1;
1✔
64
}
65

66
int BasePlayerInfo::getCurrentVersion()
3✔
67
{
68
    // 0: Initial
69
    // 1: Added portraitIndex
70
    return 1;
3✔
71
}
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