Skip to content

Commit

Permalink
xrGame/InventoryOwner.h: default initialize pointers, move initializa…
Browse files Browse the repository at this point in the history
…tion to member initializer list

Replace "read if exist" pattern with read_if_exist function
  • Loading branch information
Xottab-DUTY committed Oct 18, 2021
1 parent d8cd661 commit 1cf3c37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
38 changes: 11 additions & 27 deletions src/xrGame/InventoryOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,22 @@
#include "xrNetServer/NET_Messages.h"

CInventoryOwner::CInventoryOwner()
: m_inventory(xr_new<CInventory>()),
bDisableBreakDialog(false),
m_tmp_active_slot_num(NO_ACTIVE_SLOT),
m_play_show_hide_reload_sounds(true),
m_known_info_registry(xr_new<CInfoPortionWrapper>()),
m_pCharacterInfo(xr_new<CCharacterInfo>()),
m_need_osoznanie_mode(false),
m_deadbody_can_take(true),
m_deadbody_closed(false)
{
m_pTrade = NULL;
m_trade_parameters = 0;

m_inventory = xr_new<CInventory>();
m_pCharacterInfo = xr_new<CCharacterInfo>();

EnableTalk();
EnableTrade();
bDisableBreakDialog = false;

m_known_info_registry = xr_new<CInfoPortionWrapper>();
m_tmp_active_slot_num = NO_ACTIVE_SLOT;
m_need_osoznanie_mode = FALSE;

m_deadbody_can_take = true;
m_deadbody_closed = false;
m_play_show_hide_reload_sounds = true;
}

IFactoryObject* CInventoryOwner::_construct()
{
m_trade_parameters = 0;
m_purchase_list = 0;

return (smart_cast<IFactoryObject*>(this));
}

Expand All @@ -72,14 +63,7 @@ void CInventoryOwner::Load(LPCSTR section)
if (pSettings->line_exist(section, "inv_max_weight"))
m_inventory->SetMaxWeight(pSettings->r_float(section, "inv_max_weight"));

if (pSettings->line_exist(section, "need_osoznanie_mode"))
{
m_need_osoznanie_mode = pSettings->r_bool(section, "need_osoznanie_mode");
}
else
{
m_need_osoznanie_mode = FALSE;
}
m_need_osoznanie_mode = pSettings->read_if_exists(section, "need_osoznanie_mode", false);
}

void CInventoryOwner::reload(LPCSTR section)
Expand All @@ -91,7 +75,7 @@ void CInventoryOwner::reload(LPCSTR section)
m_money = 0;
m_bTrading = false;
m_bTalking = false;
m_pTalkPartner = NULL;
m_pTalkPartner = nullptr;

CAttachmentOwner::reload(section);
}
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/InventoryOwner.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class CInventoryOwner : public CAttachmentOwner
protected:
u32 m_money;
// торговля
CTrade* m_pTrade;
CTrade* m_pTrade{};
bool m_bTrading;
bool m_bTalking;
CInventoryOwner* m_pTalkPartner;
Expand Down Expand Up @@ -217,9 +217,9 @@ class CInventoryOwner : public CAttachmentOwner
public:
virtual bool use_simplified_visual() const { return (false); };
private:
CTradeParameters* m_trade_parameters;
CPurchaseList* m_purchase_list;
BOOL m_need_osoznanie_mode;
CTradeParameters* m_trade_parameters{};
CPurchaseList* m_purchase_list{};
bool m_need_osoznanie_mode;
bool m_deadbody_can_take;
bool m_deadbody_closed;

Expand All @@ -235,7 +235,7 @@ class CInventoryOwner : public CAttachmentOwner
virtual bool use_default_throw_force();
virtual float missile_throw_force();
virtual bool use_throw_randomness();
virtual bool NeedOsoznanieMode() { return m_need_osoznanie_mode != FALSE; }
virtual bool NeedOsoznanieMode() { return m_need_osoznanie_mode; }
void deadbody_can_take(bool status);
IC bool deadbody_can_take_status() const { return m_deadbody_can_take; }
void deadbody_closed(bool status);
Expand Down

0 comments on commit 1cf3c37

Please sign in to comment.