Skip to content

Commit

Permalink
Merge pull request #167 from olanti-p/misc-fixes
Browse files Browse the repository at this point in the history
Misc bugfixes from mainline
  • Loading branch information
Coolthulhu authored Oct 31, 2020
2 parents a9327e9 + 4ae00e7 commit dbc190d
Showing 15 changed files with 95 additions and 29 deletions.
2 changes: 2 additions & 0 deletions data/json/monsters/nether.json
Original file line number Diff line number Diff line change
@@ -397,6 +397,7 @@
"default_faction": "mutant",
"bodytype": "dog",
"species": [ "NETHER" ],
"diff": 2,
"volume": "62500 ml",
"weight": "81500 g",
"hp": 120,
@@ -735,6 +736,7 @@
"default_faction": "mutant",
"bodytype": "blob",
"species": [ "NETHER" ],
"diff": 2,
"volume": "92500 ml",
"weight": "120 kg",
"hp": 160,
2 changes: 1 addition & 1 deletion data/json/scenarios.json
Original file line number Diff line number Diff line change
@@ -497,7 +497,7 @@
{
"type": "scenario",
"ident": "presort",
"name": "Crazy party",
"name": "Crazy Party",
"points": 0,
"description": "You thought things couldn't get any worse when the cops came over to bust your wild party, even though you booked it at a private resort. When the guests started fighting with the police you tried to get them to calm down, only to find out they hungered for more.",
"start_name": "Private resort",
2 changes: 1 addition & 1 deletion src/activity_actor.cpp
Original file line number Diff line number Diff line change
@@ -323,7 +323,7 @@ void pickup_activity_actor::do_turn( player_activity &, Character &who )
who.cancel_activity();

if( who.get_value( "THIEF_MODE_KEEP" ) != "YES" ) {
who.set_value( "THIEF_MODE", "THIF_ASK" );
who.set_value( "THIEF_MODE", "THIEF_ASK" );
}

if( !keep_going ) {
28 changes: 12 additions & 16 deletions src/activity_item_handling.cpp
Original file line number Diff line number Diff line change
@@ -1110,22 +1110,18 @@ static bool are_requirements_nearby( const std::vector<tripoint> &loot_spots,
inventory temp_inv;
units::volume volume_allowed = p.volume_capacity() - p.volume_carried();
units::mass weight_allowed = p.weight_capacity() - p.weight_carried();
const bool check_weight = p.backlog.front().id() == ACT_MULTIPLE_FARM ||
activity_to_restore == ACT_MULTIPLE_FARM ||
p.backlog.front().id() == ACT_MULTIPLE_CHOP_PLANKS ||
activity_to_restore == ACT_MULTIPLE_CHOP_PLANKS ||
p.backlog.front().id() == ACT_MULTIPLE_BUTCHER ||
activity_to_restore == ACT_MULTIPLE_BUTCHER ||
p.backlog.front().id() == ACT_VEHICLE_DECONSTRUCTION ||
activity_to_restore == ACT_VEHICLE_DECONSTRUCTION ||
p.backlog.front().id() == ACT_VEHICLE_REPAIR ||
activity_to_restore == ACT_VEHICLE_REPAIR ||
p.backlog.front().id() == ACT_MULTIPLE_CHOP_TREES ||
activity_to_restore == ACT_MULTIPLE_CHOP_TREES ||
p.backlog.front().id() == ACT_MULTIPLE_FISH ||
activity_to_restore == ACT_MULTIPLE_FISH ||
p.backlog.front().id() == ACT_MULTIPLE_MINE ||
activity_to_restore == ACT_MULTIPLE_MINE;
static const auto check_weight_if = []( const activity_id & id ) {
return id == ACT_MULTIPLE_FARM ||
id == ACT_MULTIPLE_CHOP_PLANKS ||
id == ACT_MULTIPLE_BUTCHER ||
id == ACT_VEHICLE_DECONSTRUCTION ||
id == ACT_VEHICLE_REPAIR ||
id == ACT_MULTIPLE_CHOP_TREES ||
id == ACT_MULTIPLE_FISH ||
id == ACT_MULTIPLE_MINE;
};
const bool check_weight = check_weight_if( activity_to_restore ) || ( !p.backlog.empty() &&
check_weight_if( p.backlog.front().id() ) );
bool found_welder = false;
for( item *elem : p.inv_dump() ) {
if( elem->has_quality( qual_WELD ) ) {
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
@@ -515,6 +515,7 @@ void DynamicDataLoader::unload_data()
overmap_terrains::reset();
profession::reset();
quality::reset();
reset_monster_adjustment();
recipe_dictionary::reset();
recipe_group::reset();
requirement_data::reset();
4 changes: 4 additions & 0 deletions src/input.h
Original file line number Diff line number Diff line change
@@ -730,6 +730,10 @@ class input_context
*/
std::vector<std::string> filter_strings_by_phrase( const std::vector<std::string> &strings,
const std::string &phrase ) const;
public:
std::vector<std::string> get_registered_actions_copy() const {
return registered_actions;
}
};

/**
10 changes: 10 additions & 0 deletions src/inventory.cpp
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
#include "colony.h"
#include "flat_set.h"
#include "point.h"
#include "inventory_ui.h" // auto inventory blocking

static const std::string flag_LEAK_ALWAYS( "LEAK_ALWAYS" );
static const std::string flag_LEAK_DAM( "LEAK_DAM" );
@@ -1036,11 +1037,20 @@ void inventory::assign_empty_invlet( item &it, const Character &p, const bool fo
}
}
if( cur_inv.count() < inv_chars.size() ) {
// XXX YUCK I don't know how else to get the keybindings
// FIXME: Find a better way to get bound keys
avatar &u = g->u;
inventory_selector selector( u );

for( const auto &inv_char : inv_chars ) {
if( assigned_invlet.count( inv_char ) ) {
// don't overwrite assigned keys
continue;
}
if( !selector.action_bound_to_key( inv_char ).empty() ) {
// don't auto-assign bound keys
continue;
}
if( !cur_inv[inv_char] ) {
it.invlet = inv_char;
return;
12 changes: 12 additions & 0 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
@@ -1832,6 +1832,18 @@ const navigation_mode_data &inventory_selector::get_navigation_data( navigation_
return mode_data.at( m );
}

std::string inventory_selector::action_bound_to_key( char key ) const
{
for( const std::string &action_descriptor : ctxt.get_registered_actions_copy() ) {
for( char bound_key : ctxt.keys_bound_to( action_descriptor ) ) {
if( key == bound_key ) {
return action_descriptor;
}
}
}
return std::string();
}

item_location inventory_pick_selector::execute()
{
// FIXME: temporarily disable redrawing of lower UIs before this UI is migrated to `ui_adaptor`
3 changes: 3 additions & 0 deletions src/inventory_ui.h
Original file line number Diff line number Diff line change
@@ -623,6 +623,9 @@ class inventory_selector
bool is_empty = true;
bool display_stats = true;
bool layout_is_valid = false;

public:
std::string action_bound_to_key( char key ) const;
};

inventory_selector::stat display_stat( const std::string &caption, int cur_value, int max_value,
7 changes: 7 additions & 0 deletions src/map_selector.cpp
Original file line number Diff line number Diff line change
@@ -59,3 +59,10 @@ cata::optional<tripoint> random_point( const tripoint_range &range,
}
return random_entry( suitable );
}

map_cursor::map_cursor( const tripoint &pos ) : pos_( g ? g->m.getabs( pos ) : pos ) { }

map_cursor::operator tripoint() const
{
return g ? g->m.getlocal( pos_ ) : pos_;
}
8 changes: 6 additions & 2 deletions src/map_selector.h
Original file line number Diff line number Diff line change
@@ -7,10 +7,14 @@
#include "point.h"
#include "visitable.h"

class map_cursor : public tripoint, public visitable<map_cursor>
class map_cursor : public visitable<map_cursor>
{
private:
tripoint pos_;

public:
map_cursor( const tripoint &pos ) : tripoint( pos ) {}
map_cursor( const tripoint &pos );
operator tripoint() const;
};

class map_selector : public visitable<map_selector>
36 changes: 28 additions & 8 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
@@ -2478,14 +2478,18 @@ bool mattack::tentacle( monster *z )
// TODO: handle friendly monsters
return false;
}
Creature *target = &g->u;
if( !z->sees( g->u ) ) {
Creature *target = z->attack_target();
if( target == nullptr || rl_dist( z->pos(), target->pos() ) > 3 || !z->sees( *target ) ) {
return false;
}
add_msg( m_bad, _( "The %s lashes its tentacle at you!" ), z->name() );
game_message_type msg_type = target == &g->u ? m_bad : m_info;
target->add_msg_player_or_npc( msg_type,
_( "The %s lashes its tentacle at you!" ),
_( "The %s lashes its tentacle at <npcname>!" ),
z->name() );
z->moves -= 100;

if( g->u.uncanny_dodge() ) {
if( target->uncanny_dodge() ) {
return true;
}
// Can we dodge the attack? Uses player dodge function % chance (melee.cpp)
@@ -2497,12 +2501,28 @@ bool mattack::tentacle( monster *z )
}

const bodypart_id hit = target->get_random_body_part();
const body_part hit_token = hit->token;
int dam = rng( 10, 20 );
//~ 1$s is bodypart name, 2$d is damage value.
add_msg( m_bad, _( "Your %1$s is hit for %2$d damage!" ), body_part_name( hit->token ), dam );
g->u.deal_damage( z, hit, damage_instance( DT_BASH, dam ) );
dam = target->deal_damage( z, hit, damage_instance( DT_BASH, dam ) ).total_damage();

if( dam > 0 ) {
target->add_msg_player_or_npc( msg_type,
//~ 1$s is bodypart name, 2$d is damage value.
_( "Your %1$s is hit for %2$d damage!" ),
//~ 1$s is bodypart name, 2$d is damage value.
_( "<npcname>'s %1$s is hit for %2$d damage!" ),
body_part_name( hit_token ),
dam );
} else {
target->add_msg_player_or_npc(
_( "The %1$s lashes its tentacle at your %2$s, but glances off your armor!" ),
_( "The %1$s lashes its tentacle at <npcname>'s %2$s, but glances off their armor!" ),
z->name(),
body_part_name_accusative( hit_token ) );
}

target->on_hit( z, hit, z->type->melee_skill );
g->u.check_dead_state();
target->check_dead_state();

return true;
}
5 changes: 5 additions & 0 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
@@ -308,6 +308,11 @@ void monster_adjustment::apply( mtype &mon )

static std::vector<monster_adjustment> adjustments;

void reset_monster_adjustment()
{
adjustments.clear();
}

void load_monster_adjustment( const JsonObject &jsobj )
{
monster_adjustment adj;
1 change: 1 addition & 0 deletions src/monstergenerator.h
Original file line number Diff line number Diff line change
@@ -112,5 +112,6 @@ class MonsterGenerator
};

void load_monster_adjustment( const JsonObject &jsobj );
void reset_monster_adjustment();

#endif // CATA_SRC_MONSTERGENERATOR_H
3 changes: 2 additions & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
@@ -420,7 +420,8 @@ bool vehicle::collision( std::vector<veh_collision> &colls,
const tripoint dsp = global_pos3() + dp + parts[p].precalc[1];
veh_collision coll = part_collision( p, dsp, just_detect, bash_floor );
if( coll.type == veh_coll_nothing && info.rotor_diameter() > 0 ) {
for( const tripoint &rotor_point : g->m.points_in_radius( dsp, info.rotor_diameter() ) ) {
size_t radius = static_cast<size_t>( std::round( info.rotor_diameter() / 2.0f ) );
for( const tripoint &rotor_point : g->m.points_in_radius( dsp, radius ) ) {
veh_collision rotor_coll = part_collision( p, rotor_point, just_detect, false );
if( rotor_coll.type != veh_coll_nothing ) {
coll = rotor_coll;

0 comments on commit dbc190d

Please sign in to comment.