From 5b5f81dcea793c618292b05f83c617cc3f12329d Mon Sep 17 00:00:00 2001 From: KaiN Date: Sat, 17 Sep 2022 11:14:18 +0200 Subject: [PATCH] Fix tests and review problems --- doc/lua/functions.md | 194 +++++++++--------- libs/s25main/BasePlayerInfo.h | 2 +- libs/s25main/SerializedGameData.cpp | 3 +- libs/s25main/controls/ctrlBaseImage.cpp | 2 +- libs/s25main/gameData/PortraitConsts.h | 2 +- libs/s25main/network/GameMessages.h | 4 +- libs/s25main/network/GameServer.cpp | 43 +--- libs/s25main/ogl/ITexture.h | 2 +- libs/s25main/ogl/glArchivItem_Bitmap.cpp | 6 +- libs/s25main/ogl/glArchivItem_Bitmap.h | 2 +- .../ogl/glArchivItem_Bitmap_Player.cpp | 2 +- libs/s25main/ogl/glArchivItem_Bitmap_Player.h | 2 +- libs/s25main/ogl/glSmartBitmap.cpp | 18 +- libs/s25main/ogl/glSmartBitmap.h | 2 +- tests/s25Main/lua/testLuaSettings.cpp | 2 +- 15 files changed, 122 insertions(+), 164 deletions(-) diff --git a/doc/lua/functions.md b/doc/lua/functions.md index 8e13dff06..028ab3de4 100644 --- a/doc/lua/functions.md +++ b/doc/lua/functions.md @@ -21,32 +21,32 @@ There are the following objects defined: Reference: [libs/libGamedata/lua/LuaInterfaceBase.cpp](../../libs/libGamedata/lua/LuaInterfaceBase.cpp) -**rttr:GetVersion()** +**rttr:GetVersion()** Get the current major and minor version as a pair. Changes to the major version reflect breaking changes that are expected to cause errors in existing scripts. Minor version changes only add new features. The current version is **1.0**. -**rttr:Log(message)** +**rttr:Log(message)** Log the message to console. -**rttr:IsHost()** +**rttr:IsHost()** Return true/false if the local player is the host. -**rttr:GetNumPlayers()** +**rttr:GetNumPlayers()** Return the number of players. -**rttr:GetLocalPlayerIdx()** +**rttr:GetLocalPlayerIdx()** Return 0-based index of the local player. -**rttr:MsgBox(title, message, isError = false)** +**rttr:MsgBox(title, message, isError = false)** Show a message box to the current user. `isError` is used to show a red or green icon. -A scrollbar will be shown for long text. +A scrollbar will be shown for long text. Note: You can have multiple message boxes opened. First one will be on top until closed. -**rttr:MsgBoxEx(title, message, iconFile, iconIdx[, iconX, iconY])** +**rttr:MsgBoxEx(title, message, iconFile, iconIdx[, iconX, iconY])** Show a message box to the current user. `iconIdx` is the index into `iconFile` (name w/o extension) of the icon to use. The file must be loaded at this point! @@ -58,11 +58,11 @@ Place the image at the border if you don't want this. Notes: - You can have multiple message boxes opened. -First one will be on top till closed -- You can not do any action until the window is closed -- You should use an offset (`iconX`/`iconY`) as 0:0 leads to a graphic that is drawn in the upper left over the border (16,24 recommended) +First one will be on top till closed +- You can not do any action until the window is closed +- You should use an offset (`iconX`/`iconY`) as 0:0 leads to a graphic that is drawn in the upper left over the border (16,24 recommended) -**rttr:RegisterTranslations(translations)** +**rttr:RegisterTranslations(translations)** Register translations for multilanguage scripts, by passing a table containing languages as keys. Example: @@ -88,23 +88,23 @@ In order to retrieve the Value, you simply use the following call: _('World') ``` -In this example, +In this example, -- If the client language is English, `Hello World` is returned -- If the client language is German, `Hallo Welt` is returned -- If the client language is Czech (or any other than english or german), the key is returned, in this case `World` +- If the client language is English, `Hello World` is returned +- If the client language is German, `Hallo Welt` is returned +- If the client language is Czech (or any other than english or german), the key is returned, in this case `World` -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ### Settings functions (callable in settings mode only) -Reference: [lua/LuaInterfaceSettings.h](../../libs/s25main/lua/LuaInterfaceSettings.h) +Reference: [lua/LuaInterfaceSettings.h](../../libs/s25main/lua/LuaInterfaceSettings.h) **Important: All functions can only be used by the host!** -**rttr:GetPlayer(playerIdx)** +**rttr:GetPlayer(playerIdx)** Get the player with the given index, returns a [`SettingsPlayer`](#SettingsPlayer) -**rttr:SetAddon(addonId, value)** +**rttr:SetAddon(addonId, value)** Change setting of an addon. The addonId is the internal AddonID (see [const_addons.h](../../libs/s25main/addons/const_addons.h#L50)) with prefix ADDON_. @@ -112,18 +112,18 @@ The addonId is the internal AddonID (see [const_addons.h](../../libs/s25main/add rttr:SetAddon(ADDON_FRONTIER_DISTANCE_REACHABLE, true) ``` -For addons which can be enabled / disabled simply use true or false, for addons with different settings, add the number according to your setting. +For addons which can be enabled / disabled simply use true or false, for addons with different settings, add the number according to your setting. -**rttr:ResetAddons()** +**rttr:ResetAddons()** Set all addons to S2 defaults -**rttr:ResetGameSettings()** +**rttr:ResetGameSettings()** Set all settings and addons to their defaults. Note: Exploration is currently FoW. Will be classic later. -**rttr:SetGameSettings(settings)** -Set the settings with a table of keys: +**rttr:SetGameSettings(settings)** +Set the settings with a table of keys: - speed: GS_VERYSLOW, GS_SLOW, GS_NORMAL, GS_FAST, GS_VERYFAST - objective: GO_NONE, GO_CONQUER3_4, GO_TOTALDOMINATION @@ -131,28 +131,28 @@ Set the settings with a table of keys: - fow: EXP_DISABLED, EXP_CLASSIC, EXP_FOGOFWAR, EXP_FOGOFWAREXPLORED - lockedTeams, teamView, randomStartPosition: true/false -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ### Gamefunctions (callable in game mode only) -Reference: [lua/LuaInterfaceGame.h](../../libs/s25main/lua/LuaInterfaceGame.h) +Reference: [lua/LuaInterfaceGame.h](../../libs/s25main/lua/LuaInterfaceGame.h) **Important: All state-changing functions should be executed by all players at the same time (GF), or there will be asyncs!** -**rttr:ClearResources()** +**rttr:ClearResources()** Remove all workers and wares from all players warehouses. -**rttr:GetGF()** +**rttr:GetGF()** Return the current game frame number. -**rttr:FormatNumGFs(numGFs)** +**rttr:FormatNumGFs(numGFs)** Return the real time duration for this number of game frames based on the current speed. Output will be in `HH:MM:SS` format with hours omitted if zero. -**rttr:Chat(player, message)** +**rttr:Chat(player, message)** Send message to player (-1 for all players). -**rttr:MissionStatement(player, title, message, imgIdx = IM_SWORDSMAN, pause = true)** -Send mission statement to player, pauses the game in single player if pause is set. +**rttr:MissionStatement(player, title, message, imgIdx = IM_SWORDSMAN, pause = true)** +Send mission statement to player, pauses the game in single player if pause is set. Possible images: `IM_NONE, IM_SWORDSMAN, IM_READER, IM_RIDER, IM_AVATAR1-IM_AVATAR12` (see [iwMissionStatement](../../libs/s25main/ingameWindows/iwMissionStatement.h#L28)) ```lua @@ -163,119 +163,119 @@ Note: You can have multiple message boxes opened. First one will be on top till closed. _Not saved in savegame!_ -**rttr:PostMessage(player, message)** +**rttr:PostMessage(player, message)** Send post message to player. -**rttr:PostMessageWithLocation(player, message, x, y)** +**rttr:PostMessageWithLocation(player, message, x, y)** Send post message to player (with location x, y). -**rttr:GetPlayer(playerIdx)** +**rttr:GetPlayer(playerIdx)** Get the player with the given index, returns a [`GamePlayer`](#GamePlayer) -**rttr:GetWorld()** +**rttr:GetWorld()** Get the world object, returns a [`World`](#World) -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ## PlayerBase -Reference: [lua/LuaPlayerBase.h](../../libs/s25main/lua/LuaPlayerBase.h) +Reference: [lua/LuaPlayerBase.h](../../libs/s25main/lua/LuaPlayerBase.h) This is the base object for [`GamePlayer`](#GamePlayer) and [`SettingsPlayer`](#SettingsPlayer). Hence these methods are available in settings and game stage. -**GetName()** +**GetName()** Return the players name. -**GetNation()** +**GetNation()** Return the nation, one of `NAT_AFRICANS, NAT_JAPANESE, NAT_ROMANS, NAT_VIKINGS, NAT_BABYLONIANS` -**GetTeam()** -Return the players team, one of `TM_NONE, TM_RANDOM, TM_TEAM1, TM_TEAM2, TM_TEAM3, TM_TEAM4, TM_TEAM1TO2, TM_TEAM1TO3, TM_TEAM1TO4` +**GetTeam()** +Return the players team, one of `TM_NONE, TM_RANDOM, TM_TEAM1, TM_TEAM2, TM_TEAM3, TM_TEAM4, TM_TEAM1TO2, TM_TEAM1TO3, TM_TEAM1TO4` See [TeamTypes](../../libs/s25main/gameTypes/TeamTypes.h) for enums. -**GetColor()** +**GetColor()** Return color index if found or player color Color indices always have an alpha value. -**IsHuman()** +**IsHuman()** Return true if the player is controlled by a human player. -**IsAI()** +**IsAI()** Return true if the player is controlled by an AI player. -**IsClosed()** +**IsClosed()** Return true if the slot is closed. -**IsFree()** +**IsFree()** Return true if the slot is open and not controlled by a human or AI player. -**GetAILevel()** +**GetAILevel()** Return the AI difficulty level. - -1: Not an AI - 0: Dummy - 1-3: Easy-Hard -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ## SettingsPlayer -Reference: [lua/LuaServerPlayer.h](../../libs/s25main/lua/LuaServerPlayer.h) +Reference: [lua/LuaServerPlayer.h](../../libs/s25main/lua/LuaServerPlayer.h) Available in settings mode only. -**SetNation(Nation)** +**SetNation(Nation)** Change the players nation. -**SetTeam(Team)** +**SetTeam(Team)** Change the players team. -**SetColor(color or colorIdx)** +**SetColor(color or colorIdx)** Sets the players color by index or directly if its alpha value is not zero. Duplicate color values are possible, so you have to ensure unique colors if you want them! -**Close()** +**Close()** Closes a spot kicking any player or AI there. -**SetAI(level)** +**SetAI(level)** Add an AI or change its difficulty. -**SetName(name)** +**SetName(name)** Change the player's name. -**SetPortrait(portraitIndex)** +**SetPortrait(portraitIndex)** Change the player's portrait. -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ## GamePlayer -Reference: [lua/LuaPlayer.h](../../libs/s25main/lua/LuaPlayer.h) +Reference: [lua/LuaPlayer.h](../../libs/s25main/lua/LuaPlayer.h) This is the game state player object. -**player:EnableBuilding(type, notify)** +**player:EnableBuilding(type, notify)** Enable the building specified for the player. -If notify is true, the players gets a notification that the building is now available. +If notify is true, the players gets a notification that the building is now available. _Not saved in savegame!_ -**DisableBuilding(type)** +**DisableBuilding(type)** Disable the building for the player. _Not saved in savegame!_ **EnableAllBuildings()** Enable all buildings for the player. -_Not saved in savegame!_ +_Not saved in savegame!_ -**DisableAllBuildings()** +**DisableAllBuildings()** Disable all buildings for the player. _Not saved in savegame!_ -**SetRestrictedArea(x1,y1, ...)** +**SetRestrictedArea(x1,y1, ...)** Restrict the area a player may have territory in. If called without any x/y-values (e.g. `rttr:GetPlayer(1):SetRestrictedArea()`), the restrictions are lifted. Otherwise, the coordinates specify one or multiple polygons the player may have territory in (replacing older restrictions). A polygon inside a polygon will create a hole in it. To specify multiple polygons, start with a 0,0-pair followed by the first polygon, another 0,0-pair, the second polygon etc. and a final 0,0-pair at the end. -For multiple polygons, each polygons first point has to be repeated at the end of it. +For multiple polygons, each polygons first point has to be repeated at the end of it. Notes: @@ -286,82 +286,82 @@ This allows creation of mutual exclusive areas like allowing an area only for a This may cause surprises when using this function as you cannot easily describe a "real" rectangle. Generally consider the border area as a "maybe" unless you tested it exactly. 3. The current implementation uses the crossing-count method described [here](http://geomalgorithms.com/a03-_inclusion.html). -But it assumes a rectangle grid, so every 2nd row is shifted by half a triangle for the means of the algorithm. +But it assumes a rectangle grid, so every 2nd row is shifted by half a triangle for the means of the algorithm. -**IsInRestrictedArea(x, y)** +**IsInRestrictedArea(x, y)** Return true if (x,y) is in the restricted area. Restricted means, building is allowed. -The `SetRestrictedArea` function defines where you may build buildings and not where you are not allowed to. +The `SetRestrictedArea` function defines where you may build buildings and not where you are not allowed to. -**ClearResources()** +**ClearResources()** Remove all wares and workers from all warehouses -**AddWares(wareMap)** +**AddWares(wareMap)** Add the specified goods to the players first warehouse. Keys must be `GoodType`s and values unsigned numbers -**AddPeople(peopleMap)** +**AddPeople(peopleMap)** Add the specified people to the player's first warehouse. Keys must be `Job`s and values unsigned numbers -**GetNumBuildings(building_type)** +**GetNumBuildings(building_type)** Get number of buildings a player has of a given type. **GetNumBuildingSites(building_type)** Get number of building sites a player has of a given type. -**GetNumWares(ware_type)** +**GetNumWares(ware_type)** Get number of wares a player has of a given type. -**GetNumPeople(job_type)** +**GetNumPeople(job_type)** Get number of people a player has with a given job. -**AIConstructionOrder(x,y,buildingtype)** +**AIConstructionOrder(x,y,buildingtype)** Order AI to build buildingtype at the given x,y location (AI will usually retry at a nearby location if the location is bad) -Returns true, if the order was submitted, false otherwise. +Returns true, if the order was submitted, false otherwise. Ignored, if player is not the host (returns always true) -**ModifyHQ(isTent)** +**ModifyHQ(isTent)** Set whether the players HQ is shown as a tent (1) or not (0) -**IsDefeated()** +**IsDefeated()** Return true if the player is defeated -**IsAlly(otherPlayerIdx)** +**IsAlly(otherPlayerIdx)** Return true if the player is an ally of this player -**IsAttackable(otherPlayerIdx)** +**IsAttackable(otherPlayerIdx)** Return true if the player can be attacked -**SuggestPact(otherPlayerIdx, PactType, duration)** +**SuggestPact(otherPlayerIdx, PactType, duration)** Let the AI send a request to the other player for a new pact. Ignored if the current player is not controlled by AI. -**CancelPact(PactType, otherPlayerIdx)** +**CancelPact(PactType, otherPlayerIdx)** Let the AI send a request to the other player to cancel a pact. Ignored if the current player is not controlled by AI. -**GetHQPos()** +**GetHQPos()** Return x,y of the players HQ -**Surrender(destroyBuildings)** +**Surrender(destroyBuildings)** Let the player give up either keeping its buildings or destroying them. Can be called multiple times e.g. to destroy buildings later. -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) -## World +## World Reference: [libs/s25main/lua/LuaWorld.h](../../libs/s25main/lua/LuaWorld.h) -**AddEnvObject(x, y, id, file = 0xFFFF)** +**AddEnvObject(x, y, id, file = 0xFFFF)** Place a new environment object. Only environment/static objects and empty space can be overwritten. - `id`: id in file - `file`: `0xFFFF` = map_?_z.lst, `0-5` = mis?bobs.lst -**AddStaticObject(x, y, id, file = 0xFFFF, size = 0)** +**AddStaticObject(x, y, id, file = 0xFFFF, size = 0)** Place a new static object. Only environment/static objects and empty space can be overwritten. @@ -369,7 +369,7 @@ Only environment/static objects and empty space can be overwritten. - `file`: `0xFFFF` = map_?_z.lst, `0-5` = mis?bobs.lst - `size`: 0: Block nothing (destructible), 1: Block single spot, 2: Block spots like castle-sized buildings -**AddAnimal(x, y, species)** +**AddAnimal(x, y, species)** Adds an animal. If the terrain is unsuitable the animal will die soon. `species` must be a [SPEC_*](constants.md#Animals) constant. @@ -378,17 +378,17 @@ If the terrain is unsuitable the animal will die soon. rttr:GetWorld():AddAnimal(41, 44, SPEC_DUCK) ``` -[Back](#Lua-objects-and-their-methods) +[Back](#Lua-objects-and-their-methods) ## Serializer The following methods are available. Remember that this is a FIFO structure, hence what is `Push`ed first needs to be `Pop`ped first. -**PushInt(value)** -**PushBool(value)** -**PushString(value)** +**PushInt(value)** +**PushBool(value)** +**PushString(value)** -**number PopInt()** -**true/false PopBool()** +**number PopInt()** +**true/false PopBool()** **string PopString()** diff --git a/libs/s25main/BasePlayerInfo.h b/libs/s25main/BasePlayerInfo.h index 73e6048e6..5070fa9f4 100644 --- a/libs/s25main/BasePlayerInfo.h +++ b/libs/s25main/BasePlayerInfo.h @@ -18,7 +18,7 @@ struct BasePlayerInfo PlayerState ps; AI::Info aiInfo; std::string name; - unsigned int portraitIndex; + unsigned portraitIndex; Nation nation; /// Actual color (ARGB) unsigned color; diff --git a/libs/s25main/SerializedGameData.cpp b/libs/s25main/SerializedGameData.cpp index f43774af0..793e3748e 100644 --- a/libs/s25main/SerializedGameData.cpp +++ b/libs/s25main/SerializedGameData.cpp @@ -95,7 +95,8 @@ /// 7: Use helpers::push/popContainer (uses var size) /// 8: noFlag::Wares converted to static_vector /// 9: Drop serialization of node BQ -static const unsigned currentGameDataVersion = 9; +/// 10: Add portrait index serialization in player state +static const unsigned currentGameDataVersion = 10; // clang-format on std::unique_ptr SerializedGameData::Create_GameObject(const GO_Type got, const unsigned obj_id) diff --git a/libs/s25main/controls/ctrlBaseImage.cpp b/libs/s25main/controls/ctrlBaseImage.cpp index 1d4a5d6c9..dc31e6db2 100644 --- a/libs/s25main/controls/ctrlBaseImage.cpp +++ b/libs/s25main/controls/ctrlBaseImage.cpp @@ -59,5 +59,5 @@ void ctrlBaseImage::DrawImage(const Rect& dstArea, unsigned color) const dst.bottom -= halfDelta; } - img_->DrawRect(dst, srcArea, color); + img_->Draw(dst, srcArea, color); } diff --git a/libs/s25main/gameData/PortraitConsts.h b/libs/s25main/gameData/PortraitConsts.h index eede8ef0f..453ac25db 100644 --- a/libs/s25main/gameData/PortraitConsts.h +++ b/libs/s25main/gameData/PortraitConsts.h @@ -28,5 +28,5 @@ constexpr std::array SUPPRESS_UNUSED Portraits = { PortraitInfo{gettext_noop("Shaka"), ResourceId("io"), 258}, PortraitInfo{gettext_noop("Todo"), ResourceId("io"), 262}, PortraitInfo{gettext_noop("Mnga Tscha "), ResourceId("io"), 257}, - PortraitInfo{gettext_noop("Baby"), ResourceId("io_new"), 007}, + PortraitInfo{gettext_noop("Nabonidus"), ResourceId("io_new"), 7}, }; diff --git a/libs/s25main/network/GameMessages.h b/libs/s25main/network/GameMessages.h index aba613322..02689a662 100644 --- a/libs/s25main/network/GameMessages.h +++ b/libs/s25main/network/GameMessages.h @@ -345,9 +345,7 @@ class GameMessage_Player_Portrait : public GameMessageWithPlayer GameMessage_Player_Portrait() : GameMessageWithPlayer(NMS_PLAYER_PORTRAIT) {} GameMessage_Player_Portrait(uint8_t player, unsigned int portraitIndex) : GameMessageWithPlayer(NMS_PLAYER_PORTRAIT, player), playerPortraitIndex(portraitIndex) - { - LOG.writeToFile(">>> NMS_PLAYER_PORTRAIT(%u)\n") % portraitIndex; - } + {} void Serialize(Serializer& ser) const override { diff --git a/libs/s25main/network/GameServer.cpp b/libs/s25main/network/GameServer.cpp index bda9eb9b0..5704dd763 100644 --- a/libs/s25main/network/GameServer.cpp +++ b/libs/s25main/network/GameServer.cpp @@ -99,19 +99,14 @@ bool GameServer::CountDown::Update() return true; } -/////////////////////////////////////////////////////////////////////////////// -// GameServer::GameServer() : skiptogf(0), state(ServerState::Stopped), currentGF(0), lanAnnouncer(LAN_DISCOVERY_CFG) {} -/////////////////////////////////////////////////////////////////////////////// -// GameServer::~GameServer() { Stop(); } -/////////////////////////////////////////////////////////////////////////////// -// Spiel hosten +// Host the game. bool GameServer::Start(const CreateServerInfo& csi, const boost::filesystem::path& map_path, MapType map_type, const std::string& hostPw) { @@ -271,8 +266,6 @@ void GameServer::LC_Created() AnnounceStatusChange(); } -/////////////////////////////////////////////////////////////////////////////// -// Hauptschleife void GameServer::Run() { if(state == ServerState::Stopped) @@ -387,8 +380,6 @@ void GameServer::RunStateGame() ExecuteGameFrame(); } -/////////////////////////////////////////////////////////////////////////////// -// stoppt den server void GameServer::Stop() { if(state == ServerState::Stopped) @@ -524,9 +515,6 @@ bool GameServer::assignPlayersOfRandomTeams(std::vector& playerI return playerWasAssigned; } -/** - * startet das Spiel. - */ bool GameServer::StartGame() { lanAnnouncer.Stop(); @@ -602,9 +590,6 @@ void GameServer::SendNWFDone(const NWFServerInfo& info) SendToAll(GameMessage_Server_NWFDone(info.gf, info.newGFLen, info.nextNWF)); } -/** - * Nachricht an Alle - */ void GameServer::SendToAll(const GameMessage& msg) { for(GameServerPlayer& player : networkPlayers) @@ -643,7 +628,6 @@ void GameServer::KickPlayer(uint8_t playerId, KickReason cause, uint32_t param) % unsigned(param); } -/////////////////////////////////////////////////////////////////////////////// // testet, ob in der Verbindungswarteschlange Clients auf Verbindung warten void GameServer::ClientWatchDog() { @@ -815,7 +799,6 @@ bool GameServer::CheckForLaggingPlayers() return true; } -/////////////////////////////////////////////////////////////////////////////// // testet, ob in der Verbindungswarteschlange Clients auf Verbindung warten void GameServer::WaitForClients() { @@ -852,7 +835,6 @@ void GameServer::WaitForClients() } } -/////////////////////////////////////////////////////////////////////////////// // füllt die warteschlangen mit "paketen" void GameServer::FillPlayerQueues() { @@ -888,8 +870,6 @@ void GameServer::FillPlayerQueues() } while(msgReceived); } -/////////////////////////////////////////////////////////////////////////////// -// pongnachricht bool GameServer::OnGameMessage(const GameMessage_Pong& msg) { GameServerPlayer* player = GetNetworkPlayer(msg.senderPlayerID); @@ -904,8 +884,6 @@ bool GameServer::OnGameMessage(const GameMessage_Pong& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// servertype bool GameServer::OnGameMessage(const GameMessage_Server_Type& msg) { if(state != ServerState::Config) @@ -931,9 +909,6 @@ bool GameServer::OnGameMessage(const GameMessage_Server_Type& msg) return true; } -/** - * Server-Passwort-Nachricht - */ bool GameServer::OnGameMessage(const GameMessage_Server_Password& msg) { if(state != ServerState::Config) @@ -961,9 +936,6 @@ bool GameServer::OnGameMessage(const GameMessage_Server_Password& msg) return true; } -/** - * Chat-Nachricht. - */ bool GameServer::OnGameMessage(const GameMessage_Chat& msg) { int playerID = GetTargetPlayer(msg); @@ -1035,8 +1007,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_State& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// Player name bool GameServer::OnGameMessage(const GameMessage_Player_Name& msg) { if(state != ServerState::Config) @@ -1057,8 +1027,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_Name& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// Player portrait bool GameServer::OnGameMessage(const GameMessage_Player_Portrait& msg) { if(state != ServerState::Config) @@ -1079,8 +1047,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_Portrait& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// Nation weiterwechseln bool GameServer::OnGameMessage(const GameMessage_Player_Nation& msg) { if(state != ServerState::Config) @@ -1099,8 +1065,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_Nation& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// Team weiterwechseln bool GameServer::OnGameMessage(const GameMessage_Player_Team& msg) { if(state != ServerState::Config) @@ -1119,8 +1083,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_Team& msg) return true; } -/////////////////////////////////////////////////////////////////////////////// -// Farbe weiterwechseln bool GameServer::OnGameMessage(const GameMessage_Player_Color& msg) { if(state != ServerState::Config) @@ -1137,9 +1099,6 @@ bool GameServer::OnGameMessage(const GameMessage_Player_Color& msg) return true; } -/** - * Spielerstatus wechseln - */ bool GameServer::OnGameMessage(const GameMessage_Player_Ready& msg) { if(state != ServerState::Config) diff --git a/libs/s25main/ogl/ITexture.h b/libs/s25main/ogl/ITexture.h index b8ff4e1e8..529cbdb0a 100644 --- a/libs/s25main/ogl/ITexture.h +++ b/libs/s25main/ogl/ITexture.h @@ -16,5 +16,5 @@ class ITexture virtual Position GetOrigin() const = 0; virtual Extent GetSize() const = 0; virtual void DrawFull(const Position& dstPos, unsigned color = 0xFFFFFFFFu) = 0; - virtual void DrawRect(Rect dstArea, Rect srcArea, unsigned color = 0xFFFFFFFFu) = 0; + virtual void Draw(Rect dstArea, Rect srcArea, unsigned color = 0xFFFFFFFFu) = 0; }; diff --git a/libs/s25main/ogl/glArchivItem_Bitmap.cpp b/libs/s25main/ogl/glArchivItem_Bitmap.cpp index 0266f2198..86a50fd4f 100644 --- a/libs/s25main/ogl/glArchivItem_Bitmap.cpp +++ b/libs/s25main/ogl/glArchivItem_Bitmap.cpp @@ -17,7 +17,7 @@ glArchivItem_Bitmap::glArchivItem_Bitmap(const glArchivItem_Bitmap& item) /** * Zeichnet die Textur. */ -void glArchivItem_Bitmap::DrawRect(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) +void glArchivItem_Bitmap::Draw(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) { if(GetTexture() == 0) return; @@ -65,7 +65,7 @@ void glArchivItem_Bitmap::DrawRect(Rect dstArea, Rect srcArea, unsigned color /* void glArchivItem_Bitmap::DrawFull(const Rect& destArea, unsigned color) { - DrawRect(destArea, Rect(Position(0, 0), GetSize()), color); + Draw(destArea, Rect(Position(0, 0), GetSize()), color); } void glArchivItem_Bitmap::DrawFull(const DrawPoint& dstPos, unsigned color) @@ -75,7 +75,7 @@ void glArchivItem_Bitmap::DrawFull(const DrawPoint& dstPos, unsigned color) void glArchivItem_Bitmap::DrawPart(const Rect& destArea, const DrawPoint& offset, unsigned color) { - DrawRect(destArea, Rect(offset, destArea.getSize()), color); + Draw(destArea, Rect(offset, destArea.getSize()), color); } void glArchivItem_Bitmap::DrawPart(const Rect& destArea, unsigned color /*= COLOR_WHITE*/) diff --git a/libs/s25main/ogl/glArchivItem_Bitmap.h b/libs/s25main/ogl/glArchivItem_Bitmap.h index dfa82e7db..21d95b29a 100644 --- a/libs/s25main/ogl/glArchivItem_Bitmap.h +++ b/libs/s25main/ogl/glArchivItem_Bitmap.h @@ -31,7 +31,7 @@ class glArchivItem_Bitmap : public virtual libsiedler2::baseArchivItem_Bitmap, p /// Draw the texture. /// src_w/h default to the full bitmap size /// dst_w/h default the src_w/h - void DrawRect(Rect dstArea, Rect srcArea, unsigned color = COLOR_WHITE) override; + void Draw(Rect dstArea, Rect srcArea, unsigned color = COLOR_WHITE) override; protected: void FillTexture() override; diff --git a/libs/s25main/ogl/glArchivItem_Bitmap_Player.cpp b/libs/s25main/ogl/glArchivItem_Bitmap_Player.cpp index 6c76308d9..f064e28a9 100644 --- a/libs/s25main/ogl/glArchivItem_Bitmap_Player.cpp +++ b/libs/s25main/ogl/glArchivItem_Bitmap_Player.cpp @@ -42,7 +42,7 @@ void glArchivItem_Bitmap_Player::drawForPlayer(const DrawPoint& dst, unsigned pl DrawFull(dst, COLOR_WHITE, playerColor); } -void glArchivItem_Bitmap_Player::DrawRect(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) +void glArchivItem_Bitmap_Player::Draw(Rect dstArea, Rect srcArea, unsigned color /*= COLOR_WHITE*/) { Draw(dstArea, srcArea, color, COLOR_WHITE); } diff --git a/libs/s25main/ogl/glArchivItem_Bitmap_Player.h b/libs/s25main/ogl/glArchivItem_Bitmap_Player.h index 28d7c255f..2ab87505b 100644 --- a/libs/s25main/ogl/glArchivItem_Bitmap_Player.h +++ b/libs/s25main/ogl/glArchivItem_Bitmap_Player.h @@ -29,7 +29,7 @@ class glArchivItem_Bitmap_Player : public libsiedler2::ArchivItem_Bitmap_Player, virtual void DrawFull(const Position& dstPos, unsigned color = COLOR_WHITE) override; /// Draw in player colors void drawForPlayer(const DrawPoint& dst, unsigned playerColor); - void DrawRect(Rect dstArea, Rect srcArea, unsigned color = COLOR_WHITE) override; + void Draw(Rect dstArea, Rect srcArea, unsigned color = COLOR_WHITE) override; protected: void Draw(Rect dstArea, Rect srcArea, unsigned color = COLOR_WHITE, unsigned player_color = COLOR_WHITE); diff --git a/libs/s25main/ogl/glSmartBitmap.cpp b/libs/s25main/ogl/glSmartBitmap.cpp index 88d2876c1..bae24759a 100644 --- a/libs/s25main/ogl/glSmartBitmap.cpp +++ b/libs/s25main/ogl/glSmartBitmap.cpp @@ -242,7 +242,7 @@ void glSmartBitmap::generateTexture() } } -void glSmartBitmap::DrawRect(Rect dstArea, Rect srcArea, unsigned color /*= 0xFFFFFFFF*/) +void glSmartBitmap::Draw(Rect dstArea, Rect srcArea, unsigned color /*= 0xFFFFFFFF*/) { drawRect(dstArea, srcArea, color); } @@ -286,15 +286,15 @@ void glSmartBitmap::drawRect(Rect dstArea, Rect srcArea, unsigned color /*= 0xFF curTexCoords[1] = texCoords[1]; curTexCoords[2] = texCoords[2]; curTexCoords[3] = texCoords[3]; - curTexCoords[0].y = curTexCoords[3].y = helpers::lerp( - texCoords[0].y, texCoords[1].y, helpers::inverseLerp(.0f, float(size_.y), float(srcArea.getOrigin().y))); - curTexCoords[1].y = curTexCoords[2].y = helpers::lerp( - texCoords[0].y, texCoords[1].y, helpers::inverseLerp(.0f, float(size_.y), float(srcArea.getEndPt().y))); + curTexCoords[0].y = curTexCoords[3].y = helpers::lerp( + texCoords[0].y, texCoords[1].y, helpers::inverseLerp(.0f, float(size_.y), float(srcArea.getOrigin().y))); + curTexCoords[1].y = curTexCoords[2].y = helpers::lerp( + texCoords[0].y, texCoords[1].y, helpers::inverseLerp(.0f, float(size_.y), float(srcArea.getEndPt().y))); // horizontal coords - curTexCoords[0].x = curTexCoords[1].x = helpers::lerp( - texCoords[0].x, texCoords[3].x, helpers::inverseLerp(.0f, float(size_.x), float(srcArea.getOrigin().x))); - curTexCoords[2].x = curTexCoords[3].x = helpers::lerp( - texCoords[0].x, texCoords[3].x, helpers::inverseLerp(.0f, float(size_.x), float(srcArea.getEndPt().x))); + curTexCoords[0].x = curTexCoords[1].x = helpers::lerp( + texCoords[0].x, texCoords[3].x, helpers::inverseLerp(.0f, float(size_.x), float(srcArea.getOrigin().x))); + curTexCoords[2].x = curTexCoords[3].x = helpers::lerp( + texCoords[0].x, texCoords[3].x, helpers::inverseLerp(.0f, float(size_.x), float(srcArea.getEndPt().x))); int numQuads; if(player_color && hasPlayer) diff --git a/libs/s25main/ogl/glSmartBitmap.h b/libs/s25main/ogl/glSmartBitmap.h index eaa899609..27201fc12 100644 --- a/libs/s25main/ogl/glSmartBitmap.h +++ b/libs/s25main/ogl/glSmartBitmap.h @@ -59,7 +59,7 @@ class glSmartBitmap : public ITexture void generateTexture(); void DrawFull(const Position& dstPos, unsigned color = 0xFFFFFFFF) override { draw(dstPos, color); } - void DrawRect(Rect dstArea, Rect srcArea, unsigned color = 0xFFFFFFFF) override; + void Draw(Rect dstArea, Rect srcArea, unsigned color = 0xFFFFFFFF) override; void drawRect(Rect dstArea, Rect srcArea, unsigned color = 0xFFFFFFFF, unsigned player_color = 0); void draw(DrawPoint drawPt, unsigned color = 0xFFFFFFFF, unsigned player_color = 0); void drawForPlayer(DrawPoint drawPt, unsigned player_color) { draw(drawPt, 0xFFFFFFFF, player_color); } diff --git a/tests/s25Main/lua/testLuaSettings.cpp b/tests/s25Main/lua/testLuaSettings.cpp index 9c965be06..06566b857 100644 --- a/tests/s25Main/lua/testLuaSettings.cpp +++ b/tests/s25Main/lua/testLuaSettings.cpp @@ -282,7 +282,7 @@ BOOST_AUTO_TEST_CASE(PlayerSettings) BOOST_TEST(isLuaEqual("player:GetName()", "'Foo'")); executeLua("player:SetPortrait(8)"); - BOOST_TEST(players[0].portraitIndex == 8); + BOOST_TEST(players[0].portraitIndex == 8u); executeLua("player:SetColor(2)"); BOOST_TEST_REQUIRE(players[0].color == PLAYER_COLORS[2]);