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

Return-To-The-Roots / s25client / 15651837780

14 Jun 2025 12:06PM UTC coverage: 50.443% (-0.03%) from 50.476%
15651837780

Pull #1534

github

web-flow
Merge 4685d273f into 19c9b91c8
Pull Request #1534: Portrait support

56 of 155 new or added lines in 18 files covered. (36.13%)

23 existing lines in 5 files now uncovered.

22500 of 44605 relevant lines covered (50.44%)

35606.31 hits per line

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

6.0
/libs/s25main/network/GameClientCommands.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 "Game.h"
6
#include "GamePlayer.h"
7
#include "ai/AIPlayer.h"
8
#include "network/ClientInterface.h"
9
#include "network/GameClient.h"
10
#include "network/GameMessages.h"
11

12
/**
13
 *  Chatbefehl, hängt eine Textnachricht in die Sende-Queue.
14
 *
15
 *  @param[in] text        Der Text
16
 *  @param[in] destination Ziel der Nachricht
17
 */
18
void GameClient::Command_Chat(const std::string& text, const ChatDestination cd)
×
19
{
20
    // Replaymodus oder kein Text --> nichts senden
21
    if(IsReplayModeOn() || text.empty())
×
22
        return;
×
23

24
    mainPlayer.sendMsgAsync(new GameMessage_Chat(0xff, cd, text));
×
25
}
26

27
void GameClient::Command_SetNation(Nation newNation)
×
28
{
29
    mainPlayer.sendMsgAsync(new GameMessage_Player_Nation(0xff, newNation));
×
30
}
×
31

NEW
32
void GameClient::Command_SetPortrait(unsigned portraitIndex)
×
33
{
NEW
34
    mainPlayer.sendMsgAsync(new GameMessage_Player_Portrait(0xff, portraitIndex));
×
NEW
35
}
×
36

UNCOV
37
void GameClient::Command_SetTeam(Team newTeam)
×
38
{
39
    mainPlayer.sendMsgAsync(new GameMessage_Player_Team(0xff, newTeam));
×
40
}
×
41

42
/**
43
 *  sendet den "Bereit"-Status.
44
 */
45
void GameClient::Command_SetReady(bool isReady)
1✔
46
{
47
    mainPlayer.sendMsgAsync(new GameMessage_Player_Ready(0xFF, isReady));
1✔
48
}
1✔
49

50
void GameClient::Command_SetColor(unsigned newColor)
×
51
{
52
    mainPlayer.sendMsgAsync(new GameMessage_Player_Color(0xFF, newColor));
×
53
}
×
54

55
/**
56
 *  wechselt einen Spieler.
57
 *
58
 *  @param[in] old_id Alte Spieler-ID
59
 *  @param[in] new_id Neue Spieler-ID
60
 */
61
void GameClient::ChangePlayerIngame(const unsigned char playerId1, const unsigned char playerId2)
×
62
{
63
    RTTR_Assert(state == ClientState::Game); // Must be ingame
×
64

65
    LOG.write("GameClient::ChangePlayer %i - %i \n") % static_cast<unsigned>(playerId1)
×
66
      % static_cast<unsigned>(playerId2);
×
67
    // Gleiche ID - wäre unsinnig zu wechseln
68
    if(playerId1 == playerId2)
×
69
        return;
×
70

71
    // ID auch innerhalb der Spielerzahl?
72
    if(playerId2 >= GetNumPlayers() || playerId1 >= GetNumPlayers())
×
73
        return;
×
74

75
    if(IsReplayModeOn())
×
76
    {
77
        RTTR_Assert(playerId1 == GetPlayerId());
×
78
        // There must be someone at this slot
79
        if(!GetPlayer(playerId2).isUsed())
×
80
            return;
×
81

82
        // In replay mode we don't touch the player
83
    } else
84
    {
85
        // old_id must be a player
86
        GamePlayer& player1 = GetPlayer(playerId1);
×
87
        if(player1.ps != PlayerState::Occupied)
×
88
            return;
×
89
        // new_id must be an AI
90
        GamePlayer& player2 = GetPlayer(playerId2);
×
91
        if(player2.ps != PlayerState::AI)
×
92
            return;
×
93

94
        std::swap(player1.ps, player2.ps);
×
95
        std::swap(player1.aiInfo, player2.aiInfo);
×
96
        if(IsHost())
×
97
        {
98
            // Switch AIs
99
            game->aiPlayers_.erase_if([playerId2](const auto& player) { return player.GetPlayerId() == playerId2; });
×
100
            game->AddAIPlayer(CreateAIPlayer(playerId1, AI::Info(AI::Type::Dummy)));
×
101
        }
102
        GetPlayer(playerId1).ps = PlayerState::AI;
×
103
        GetPlayer(playerId2).ps = PlayerState::Occupied;
×
104
    }
105

106
    // Wenn wir betroffen waren, unsere ID neu setzen
107
    if(mainPlayer.playerId == playerId1)
×
108
    {
109
        mainPlayer.playerId = playerId2;
×
110

111
        if(!IsReplayModeOn())
×
112
        {
113
            // Our currently accumulated gamecommands are invalid after the change, as they would modify the old player
114
            gameCommands_.clear();
×
115
        }
116
    }
117

118
    if(ci)
×
119
        ci->CI_PlayersSwapped(playerId1, playerId2);
×
120
}
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