Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
Checks should pass now.
  • Loading branch information
TheGiraffe3 authored Nov 2, 2024
1 parent 17d327f commit 767b9df
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 861 deletions.
10 changes: 5 additions & 5 deletions source/CustomSale.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CustomSale.cpp
Copyright (c) 2021 by Hurleveur
Copyright (c) 2024 by Hurleveur
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -56,9 +56,9 @@ void CustomSale::Load(const DataNode &node, bool eventChange)
amount += size > 2 ? line.Value(2) : 1.;
else
amount = size > 1 ? line.Value(1) : 1.;
// All values are converted into pourcentages if that is not how they are given (which would be indicated by %)
// All values are converted into percentages if that is not how they are given (which would be indicated by %)
// This means that the offset is handled as relative to the modified price instead of the default one.
// Outfitter changes always are pourcentages.
// Outfitter changes always are perrcentages.
if((mode != "outfitters"
&& (size == (2 + isAdd)
|| (size > 2 && line.Token(2 + isAdd) != "%"))))
Expand Down Expand Up @@ -160,7 +160,7 @@ void CustomSale::Load(const DataNode &node, bool eventChange)
conditions.Load(child);
}
// CustomSales are separated between outfits and outfitters in the data files.
// mode could apply to other things like shipyards and ships, later on.
// This mode could apply to other things like shipyards and ships, later on.
else if(mode == "outfits")
{
if(!add)
Expand Down Expand Up @@ -279,7 +279,7 @@ bool CustomSale::Add(const CustomSale &other, const Planet &planet, const Condit
else if(ours->second < it.second)
ours->second = it.second;
}
// For offsets, add them to each others.
// For offsets, add them to each other.
for(const auto &it : other.relativeOffsets)
{
auto ours = relativeOffsets.find(it.first);
Expand Down
8 changes: 2 additions & 6 deletions source/CustomSale.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CustomSale.h
Copyright (c) 2021 by Hurleveur
Copyright (c) 2024 by Hurleveur
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Expand All @@ -13,8 +13,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef CUSTOM_SALE_H_
#define CUSTOM_SALE_H_
#pragma once

#include "ConditionSet.h"
#include "LocationFilter.h"
Expand Down Expand Up @@ -98,6 +97,3 @@ class CustomSale {
// When loading we cannot be sure all outfits are loaded, so store those we need to convert into relative values.
std::vector<std::pair<const Outfit *, double *>> toConvert;
};

#endif

2 changes: 1 addition & 1 deletion source/CustomSaleManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CustomSaleManager.cpp
Copyright (c) 2023 by Hurleveur
Copyright (c) 2024 by Hurleveur
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Expand Down
8 changes: 2 additions & 6 deletions source/CustomSaleManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* CustomSaleManager.h
Copyright (c) 2023 by Hurleveur
Copyright (c) 2024 by Hurleveur
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Expand All @@ -13,8 +13,7 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef CUSTOM_SALE_MANAGER_H_
#define CUSTOM_SALE_MANAGER_H_
#pragma once

#include "CustomSale.h"

Expand Down Expand Up @@ -48,6 +47,3 @@ class CustomSaleManager {
private:
static std::map<CustomSale::SellType, CustomSale> customSales;
};

#endif

7 changes: 3 additions & 4 deletions source/OutfitterPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,7 @@ ShopPanel::BuyResult OutfitterPanel::CanBuy(bool onlyOwned) const
bool isInCargo = player.Cargo().Get(selectedOutfit);
bool isInStorage = player.Storage().Get(selectedOutfit);
bool isSold = CustomSaleManager::CanBuy(*selectedOutfit);
bool isInStore = (outfitter.Has(selectedOutfit) && isSold) ||
player.Stock(selectedOutfit) > 0;
bool isInStore = (outfitter.Has(selectedOutfit) && isSold) || player.Stock(selectedOutfit) > 0;
if(isInStorage && (onlyOwned || isInStore || playerShip))
{
// In storage, the outfit is certainly available to get,
Expand Down Expand Up @@ -573,8 +572,8 @@ void OutfitterPanel::Buy(bool onlyOwned)
else
{
// Check if the outfit is for sale or in stock so that we can actually buy it.
if((!outfitter.Has(selectedOutfit) && player.Stock(selectedOutfit) <= 0)
|| !CustomSaleManager::CanBuy(*selectedOutfit))
if((!outfitter.Has(selectedOutfit) && player.Stock(selectedOutfit) <= 0) ||
!CustomSaleManager::CanBuy(*selectedOutfit))
continue;
player.Cargo().Add(selectedOutfit);
int64_t price = player.StockDepreciation().Value(selectedOutfit, day);
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ list(APPEND INTEGRATION_TESTS
integration/config/plugins/integration-tests/data/tests/tests_capture_override.txt
integration/config/plugins/integration-tests/data/tests/tests_common.txt
integration/config/plugins/integration-tests/data/tests/tests_conditional_choice.txt
integration/config/plugins/integration-tests/data/tests/tests_custom_outfit_sale.txt
integration/config/plugins/integration-tests/data/tests/tests_disown.txt
integration/config/plugins/integration-tests/data/tests/tests_flagship_attribute_autoconditions.txt
integration/config/plugins/integration-tests/data/tests/tests_flagship_model_condition.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,39 +704,39 @@ test "Sell first outfit"
status partial
description "Test procedure that handles selling of the first outfit in the list."
sequence
# Goto outfitter
# Go to the outfitter.
input
key "o"
# Select the first item
# Select the first item.
input
key "Down"
# Sell the first item
# Sell the first item.
input
key "s"
# Go back to the planet menu.
input
key "l"
key "d"


test "FailBuy first outfit"
status partial
description "Try to buy the first outfit and handle the case where it fails with an error dialog."
sequence
# Goto outfitter
# Go to the outfitter.
input
key "o"
# Select the first item
# Select the first item.
input
key "Down"
# Buy the first item
# Buy the first item.
input
key "b"
# Skip the error Message, if any
# Skip the error message, if any.
input
key "return"
# Go back to the planet menu.
input
key "l"
key "d"


test "Land"
Expand Down Expand Up @@ -784,4 +784,3 @@ test "Skip Spaceport Mission"
key "Return"
input
key "Return"

Loading

0 comments on commit 767b9df

Please sign in to comment.