Skip to content

Commit

Permalink
Set default values on initialization instead of constructor body (#3776)
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt authored and DSpeichert committed May 9, 2022
1 parent df1c8e4 commit 4495c4e
Showing 1 changed file with 21 additions and 44 deletions.
65 changes: 21 additions & 44 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,13 @@ struct LightInfo {
};

struct ShopInfo {
uint16_t itemId;
int32_t subType;
uint32_t buyPrice;
uint32_t sellPrice;
std::string realName;

ShopInfo() {
itemId = 0;
subType = 1;
buyPrice = 0;
sellPrice = 0;
}
uint16_t itemId = 0;
int32_t subType = 1;
uint32_t buyPrice = 0;
uint32_t sellPrice = 0;
std::string realName = "";

ShopInfo() = default;
ShopInfo(uint16_t itemId, int32_t subType = 0, uint32_t buyPrice = 0, uint32_t sellPrice = 0, std::string realName = "")
: itemId(itemId), subType(subType), buyPrice(buyPrice), sellPrice(sellPrice), realName(std::move(realName)) {}
};
Expand Down Expand Up @@ -572,29 +566,21 @@ struct HistoryMarketOffer {
};

struct MarketStatistics {
MarketStatistics() {
numTransactions = 0;
highestPrice = 0;
totalPrice = 0;
lowestPrice = 0;
}

uint32_t numTransactions;
uint32_t highestPrice;
uint64_t totalPrice;
uint32_t lowestPrice;
uint32_t numTransactions = 0;
uint32_t highestPrice = 0;
uint64_t totalPrice = 0;
uint32_t lowestPrice = 0;
};

struct ModalWindow
{
std::list<std::pair<std::string, uint8_t>> buttons, choices;
std::string title, message;
uint32_t id;
uint8_t defaultEnterButton, defaultEscapeButton;
bool priority;
uint8_t defaultEnterButton = 0xFF, defaultEscapeButton = 0xFF;
bool priority = false;

ModalWindow(uint32_t id, std::string title, std::string message)
: title(std::move(title)), message(std::move(message)), id(id), defaultEnterButton(0xFF), defaultEscapeButton(0xFF), priority(false) {}
ModalWindow(uint32_t id, std::string title, std::string message): title(std::move(title)), message(std::move(message)), id(id) {}
};

enum CombatOrigin
Expand All @@ -609,23 +595,14 @@ enum CombatOrigin
struct CombatDamage
{
struct {
CombatType_t type;
int32_t value;
} primary, secondary;

CombatOrigin origin;
BlockType_t blockType;
bool critical;
bool leeched;
CombatDamage()
{
origin = ORIGIN_NONE;
blockType = BLOCK_NONE;
primary.type = secondary.type = COMBAT_NONE;
primary.value = secondary.value = 0;
critical = false;
leeched = false;
}
CombatType_t type = COMBAT_NONE;
int32_t value = 0;
} primary = {}, secondary = {};

CombatOrigin origin = ORIGIN_NONE;
BlockType_t blockType = BLOCK_NONE;
bool critical = false;
bool leeched = false;
};

using MarketOfferList = std::list<MarketOffer>;
Expand Down

0 comments on commit 4495c4e

Please sign in to comment.