Skip to content

Commit

Permalink
Fix (#64573)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramza13 authored Mar 26, 2023
1 parent 991a477 commit 5a61270
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,9 +1286,9 @@ template<class T>
static tripoint_abs_ms get_tripoint_from_string( const std::string &type, T &d )
{
if( type == "u" ) {
return get_map().getglobal( d.actor( false )->pos() );
return d.actor( false )->global_pos();
} else if( type == "npc" ) {
return get_map().getglobal( d.actor( true )->pos() );
return d.actor( true )->global_pos();
} else if( type.find( "u_" ) == 0 ) {
var_info var = var_info( var_type::u, type.substr( 2, type.size() - 2 ) );
return get_tripoint_from_var( var, d );
Expand Down
2 changes: 1 addition & 1 deletion src/talker.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class talker
virtual monster *get_monster() {
return nullptr;
}
virtual monster *get_monster() const {
virtual const monster *get_monster() const {
return nullptr;
}
virtual Creature *get_creature() {
Expand Down
41 changes: 24 additions & 17 deletions src/talker_monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,61 @@

class time_duration;


talker_monster::talker_monster( monster *new_me )
{
me_mon = new_me;
me_mon_const = new_me;
}

std::string talker_monster_const::disp_name() const
{
return me_mon->disp_name();
return me_mon_const->disp_name();
}

int talker_monster_const::posx() const
{
return me_mon->posx();
return me_mon_const->posx();
}

int talker_monster_const::posy() const
{
return me_mon->posy();
return me_mon_const->posy();
}

int talker_monster_const::posz() const
{
return me_mon->posz();
return me_mon_const->posz();
}

tripoint talker_monster_const::pos() const
{
return me_mon->pos();
return me_mon_const->pos();
}

tripoint_abs_ms talker_monster_const::global_pos() const
{
return me_mon->get_location();
return me_mon_const->get_location();
}

tripoint_abs_omt talker_monster_const::global_omt_location() const
{
return me_mon->global_omt_location();
return me_mon_const->global_omt_location();
}

int talker_monster_const::pain_cur() const
{
return me_mon->get_pain();
return me_mon_const->get_pain();
}

bool talker_monster_const::has_effect( const efftype_id &effect_id, const bodypart_id &bp ) const
{
return me_mon->has_effect( effect_id, bp );
return me_mon_const->has_effect( effect_id, bp );
}

effect talker_monster_const::get_effect( const efftype_id &effect_id, const bodypart_id &bp ) const
{
return me_mon->get_effect( effect_id, bp );
return me_mon_const->get_effect( effect_id, bp );
}

void talker_monster::add_effect( const efftype_id &new_effect, const time_duration &dur,
Expand All @@ -81,7 +88,7 @@ void talker_monster::mod_pain( int amount )

std::string talker_monster_const:: get_value( const std::string &var_name ) const
{
return me_mon->get_value( var_name );
return me_mon_const->get_value( var_name );
}

void talker_monster::set_value( const std::string &var_name, const std::string &value )
Expand All @@ -96,12 +103,12 @@ void talker_monster::remove_value( const std::string &var_name )

std::string talker_monster_const::short_description() const
{
return me_mon->type->get_description();
return me_mon_const->type->get_description();
}

int talker_monster_const::get_anger() const
{
return me_mon->anger;
return me_mon_const->anger;
}

void talker_monster::set_anger( int new_val )
Expand All @@ -111,7 +118,7 @@ void talker_monster::set_anger( int new_val )

int talker_monster_const::morale_cur() const
{
return me_mon->morale;
return me_mon_const->morale;
}

void talker_monster::set_morale( int new_val )
Expand All @@ -121,7 +128,7 @@ void talker_monster::set_morale( int new_val )

int talker_monster_const::get_friendly() const
{
return me_mon->friendly;
return me_mon_const->friendly;
}

void talker_monster::set_friendly( int new_val )
Expand All @@ -131,12 +138,12 @@ void talker_monster::set_friendly( int new_val )

std::vector<std::string> talker_monster_const::get_topics( bool )
{
return me_mon->type->chat_topics;
return me_mon_const->type->chat_topics;
}

int talker_monster_const::get_cur_hp( const bodypart_id & ) const
{
return me_mon->get_hp();
return me_mon_const->get_hp();
}

bool talker_monster_const::will_talk_to_u( const Character &you, bool )
Expand Down
15 changes: 7 additions & 8 deletions src/talker_monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class monster;
class talker_monster_const: public talker
{
public:
explicit talker_monster_const( const monster *new_me ): me_mon( new_me ) {
explicit talker_monster_const( const monster *new_me ): me_mon_const( new_me ) {
}
~talker_monster_const() override = default;

Expand Down Expand Up @@ -57,28 +57,27 @@ class talker_monster_const: public talker
int get_cur_hp( const bodypart_id & ) const override;
protected:
talker_monster_const() = default;
const monster *me_mon;
const monster *me_mon_const;
};

class talker_monster: public talker_monster_const
{
public:
explicit talker_monster( monster *new_me ): me_mon( new_me ) {
}
explicit talker_monster( monster *new_me );
~talker_monster() override = default;

// underlying element accessor functions
monster *get_monster() override {
return me_mon;
}
monster *get_monster() const override {
return me_mon;
const monster *get_monster() const override {
return me_mon_const;
}
Creature *get_creature() override {
return me_mon;
}
Creature *get_creature() const override {
return me_mon;
const Creature *get_creature() const override {
return me_mon_const;
}

// effects and values
Expand Down

0 comments on commit 5a61270

Please sign in to comment.