Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tehKaiN committed Sep 17, 2022
1 parent 4e6e275 commit 0aade21
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libs/s25main/desktops/dskGameLobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void dskGameLobby::UpdatePlayerRow(const unsigned row)
group->AddTextDeepening(ID_PLAYER_ROW_NATION, DrawPoint(240, cy), Extent(90, 22), tc,
_(NationNames[Nation::Romans]), NormalFont, COLOR_YELLOW);

auto& portrait = Portraits[player.portraitIndex];
const auto& portrait = Portraits[player.portraitIndex];
group->AddImageButton(ID_PLAYER_ROW_PORTRAIT, DrawPoint(335, cy), Extent(34, 22), tc,
LOADER.GetImageN(portrait.resourceId, portrait.resourceIndex), _(portrait.name));

Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/desktops/dskGameLobby.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class dskGameLobby final : public Desktop, public ClientInterface, public LobbyI
void ChangeTeam(unsigned player, Team);
void ChangeReady(unsigned player, bool ready);
void ChangeNation(unsigned player, Nation);
void ChangePortrait(const unsigned player, const unsigned portraitIndex);
void ChangePortrait(unsigned player, unsigned portraitIndex);
void ChangePing(unsigned playerId);
void ChangeColor(unsigned player, unsigned color);

Expand Down
3 changes: 2 additions & 1 deletion libs/s25main/lua/LuaServerPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ void LuaServerPlayer::Register(kaguya::State& state)
.addFunction("SetColor", &LuaServerPlayer::SetColor)
.addFunction("Close", &LuaServerPlayer::Close)
.addFunction("SetAI", &LuaServerPlayer::SetAI)
.addFunction("SetName", &LuaServerPlayer::SetName));
.addFunction("SetName", &LuaServerPlayer::SetName)
.addFunction("SetPortrait", &LuaServerPlayer::SetPortrait));
}

void LuaServerPlayer::SetNation(lua::SafeEnum<Nation> nat)
Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/ogl/glArchivItem_Bitmap_Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void glArchivItem_Bitmap_Player::drawForPlayer(const DrawPoint& dst, unsigned pl
void glArchivItem_Bitmap_Player::DrawRect(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/)
{
Draw(dstArea, srcArea, color, COLOR_WHITE);
};
}

void glArchivItem_Bitmap_Player::Draw(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/,
unsigned player_color /*= COLOR_WHITE*/)
Expand Down
7 changes: 5 additions & 2 deletions libs/s25main/ogl/glSmartBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "libsiedler2/PixelBufferBGRA.h"
#include "s25util/colors.h"
#include <glad/glad.h>
#include <cmath>
#include <limits>

namespace {
Expand Down Expand Up @@ -333,7 +334,9 @@ void glSmartBitmap::drawPercent(DrawPoint drawPt, unsigned percent, unsigned col
RTTR_Assert(percent <= 100);

const float partDrawn = percent / 100.f;
Rect dstArea(drawPt.x, drawPt.y + int(floor(size_.y * (1 - partDrawn))), size_.x, int(ceil(size_.y * partDrawn)));
Rect srcArea(0, int(floor(size_.y * (1 - partDrawn))), size_.x, int(ceil(size_.y * partDrawn)));
auto startY = int(std::floor(size_.y * (1 - partDrawn)));
auto endY = int(std::ceil(size_.y * partDrawn));
Rect dstArea(drawPt.x, drawPt.y + startY, size_.x, endY);
Rect srcArea(0, startY, size_.x, endY);
drawRect(dstArea, srcArea, color, player_color);
}
2 changes: 1 addition & 1 deletion tests/s25Main/integration/testWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ BOOST_FIXTURE_TEST_CASE(LoadLua, WorldFixture<UninitializedWorldCreator>)
rttr::test::LogAccessor logAcc;
BOOST_TEST_REQUIRE(!loader.LoadLuaScript(*game, lgs, invalidLuaFile.filePath));
BOOST_TEST(!world.HasLua());
RTTR_REQUIRE_LOG_CONTAINS("getRequiredLuaVersion()", false); // Should show a warning
RTTR_REQUIRE_LOG_CONTAINS("getRequiredLuaVersion ()", false); // Should show a warning
}

TmpFile validLuaFile(".lua");
Expand Down
5 changes: 4 additions & 1 deletion tests/s25Main/lua/testLuaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ struct LuaSettingsTestsFixture : public LuaBaseFixture, public IGameLobbyControl
GetJoinPlayer(playerIdx).aiInfo = aiInfo;
}
void SetName(unsigned playerIdx, const std::string& name) override { GetJoinPlayer(playerIdx).name = name; }
void SetPortrait(unsigned playerIdx, unsigned int portraitIndex) override { GetJoinPlayer(playerIdx).portraitIndex = portraitIndex; }
void SetPortrait(unsigned playerIdx, unsigned int portraitIndex) override
{
GetJoinPlayer(playerIdx).portraitIndex = portraitIndex;
}
void SetColor(unsigned playerIdx, unsigned newColor) override { GetJoinPlayer(playerIdx).color = newColor; }
void SetTeam(unsigned playerIdx, Team newTeam) override { GetJoinPlayer(playerIdx).team = newTeam; }
void SetNation(unsigned playerIdx, Nation newNation) override { GetJoinPlayer(playerIdx).nation = newNation; }
Expand Down
1 change: 1 addition & 0 deletions tests/s25Main/network/testGameClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ BOOST_DATA_TEST_CASE(ClientFollowsConnectProtocol, usesLuaScriptValues, usesLuaS
MOCK_EXPECT(callbacks.CI_NextConnectState).with(ConnectState::QueryMapInfo).once();
clientMsgInterface.OnGameMessage(GameMessage_Server_Password("true"));
BOOST_TEST_REQUIRE(dynamic_cast<GameMessage_Player_Name*>(client.GetMainPlayer().sendQueue.pop().get()));
BOOST_TEST_REQUIRE(dynamic_cast<GameMessage_Player_Portrait*>(client.GetMainPlayer().sendQueue.pop().get()));
const auto msg = boost::dynamic_pointer_cast<GameMessage_MapRequest>(client.GetMainPlayer().sendQueue.pop());
BOOST_TEST_REQUIRE(msg);
BOOST_TEST(msg->requestInfo);
Expand Down
2 changes: 1 addition & 1 deletion tests/s25Main/worldFixtures/CreateEmptyWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool CreateEmptyWorld::operator()(GameWorld& world) const
{
// Distribute player HQs evenly across map
Point<unsigned> numPlayersPerDim;
numPlayersPerDim.x = static_cast<unsigned>(ceil(sqrt(numPlayers)));
numPlayersPerDim.x = static_cast<unsigned>(std::ceil(std::sqrt(numPlayers)));
numPlayersPerDim.y = static_cast<unsigned>(std::ceil(float(numPlayers) / numPlayersPerDim.x));
// Distance between HQs
Point<unsigned> playerDist = size_ / numPlayersPerDim;
Expand Down

0 comments on commit 0aade21

Please sign in to comment.