Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default values on initialization instead of constructor body #3776

Merged
1 commit merged into from
Nov 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -610,23 +596,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