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

Backported 0.E fixes #41325

Merged
merged 5 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
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
18 changes: 14 additions & 4 deletions lang/extract_json_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def warning_supressed(filename):
ignorable = {
"ammo_effect",
"behavior",
"charge_removal_blacklist",
"city_building",
"colordef",
"disease_type",
"emit",
"enchantment",
"event_transformation",
Expand Down Expand Up @@ -93,6 +95,7 @@ def warning_supressed(filename):
"region_settings",
"requirement",
"rotatable_symbol",
"SCENARIO_BLACKLIST",
"scent_type",
"skill_boost",
"TRAIT_BLACKLIST",
Expand Down Expand Up @@ -247,6 +250,9 @@ def extract_martial_art(item):
if "description" in item:
writestr(outfile, item["description"],
comment="Description for martial art '{}'".format(name))
if "initiate" in item:
writestr(outfile, item["initiate"], format_strings=True,
comment="initiate message for martial art '{}'".format(name))
onhit_buffs = item.get("onhit_buffs", list())
static_buffs = item.get("static_buffs", list())
onmove_buffs = item.get("onmove_buffs", list())
Expand Down Expand Up @@ -641,18 +647,22 @@ def extract_missiondef(item):
def extract_mutation(item):
outfile = get_outfile("mutation")

item_name = found = item.get("name")
item_name_or_id = found = item.get("name")
if found is None:
raise WrongJSONItem("JSON item don't contain 'name' field", item)
writestr(outfile, found)
if "copy-from" in item:
item_name_or_id = item["id"]
else:
raise WrongJSONItem("JSON item don't contain 'name' field", item)
else:
writestr(outfile, found)

simple_fields = [ "description" ]

for f in simple_fields:
found = item.get(f)
# Need that check due format string argument
if found is not None:
writestr(outfile, found, comment="Description for {}".format(item_name))
writestr(outfile, found, comment="Description for {}".format(item_name_or_id))

if "attacks" in item:
attacks = item.get("attacks")
Expand Down
5 changes: 3 additions & 2 deletions src/computer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,11 @@ struct enum_traits<computer_failure_type> {

computer_option computer_option::from_json( const JsonObject &jo )
{
const std::string name = jo.get_string( "name" );
translation name;
jo.read( "name", name );
const computer_action action = jo.get_enum_value<computer_action>( "action" );
const int sec = jo.get_int( "security", 0 );
return computer_option( name, action, sec );
return computer_option( name.translated(), action, sec );
}

computer_failure computer_failure::from_json( const JsonObject &jo )
Expand Down
18 changes: 12 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4538,16 +4538,22 @@ template const Creature *game::critter_at<Creature>( const tripoint &, bool ) co
template<typename T>
shared_ptr_fast<T> game::shared_from( const T &critter )
{
if( const shared_ptr_fast<monster> mon_ptr = critter_tracker->find( critter.pos() ) ) {
return std::dynamic_pointer_cast<T>( mon_ptr );
}
if( static_cast<const Creature *>( &critter ) == static_cast<const Creature *>( &u ) ) {
// u is not stored in a shared_ptr, but it won't go out of scope anyway
return std::dynamic_pointer_cast<T>( u_shared_ptr );
}
for( auto &cur_npc : active_npc ) {
if( static_cast<const Creature *>( cur_npc.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( cur_npc );
if( critter.is_monster() ) {
if( const shared_ptr_fast<monster> mon_ptr = critter_tracker->find( critter.pos() ) ) {
if( static_cast<const Creature *>( mon_ptr.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( mon_ptr );
}
}
}
if( critter.is_npc() ) {
for( auto &cur_npc : active_npc ) {
if( static_cast<const Creature *>( cur_npc.get() ) == static_cast<const Creature *>( &critter ) ) {
return std::dynamic_pointer_cast<T>( cur_npc );
}
}
}
return nullptr;
Expand Down
5 changes: 2 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8486,8 +8486,7 @@ void item::process_temperature_rot( float insulation, const tripoint &pos,

const weather_generator &wgen = g->weather.get_cur_weather_gen();
const unsigned int seed = g->get_seed();
const tripoint &local = g->m.getlocal( pos );
int local_mod = g->new_game ? 0 : g->m.get_temperature( local );
int local_mod = g->new_game ? 0 : g->m.get_temperature( pos );

int enviroment_mod;
// Toilets and vending machines will try to get the heat radiation and convection during mapgen and segfault.
Expand All @@ -8510,7 +8509,7 @@ void item::process_temperature_rot( float insulation, const tripoint &pos,

//Use weather if above ground, use map temp if below
double env_temperature = 0;
if( pos.z >= 0 ) {
if( pos.z >= 0 && flag != TEMP_ROOT_CELLAR ) {
double weather_temperature = wgen.get_weather_temperature( pos, time, seed );
env_temperature = weather_temperature + enviroment_mod + local_mod;
} else {
Expand Down
19 changes: 12 additions & 7 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6687,13 +6687,13 @@ void map::loadn( const tripoint &grid, const bool update_vehicles )
abs_sub.z = old_abs_z;
}

bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
bool map::has_rotten_away( item &itm, const tripoint &pnt, const temperature_flag flag ) const
{
if( itm.is_corpse() && itm.goes_bad() ) {
itm.process_temperature_rot( 1, pnt, nullptr );
itm.process_temperature_rot( 1, pnt, nullptr, flag );
return itm.get_rot() > 10_days && !itm.can_revive();
} else if( itm.goes_bad() ) {
itm.process_temperature_rot( 1, pnt, nullptr );
itm.process_temperature_rot( 1, pnt, nullptr, flag );
return itm.has_rotten_away();
} else if( itm.type->container && itm.type->container->preserves ) {
// Containers like tin cans preserves all items inside, they do not rot at all.
Expand All @@ -6702,14 +6702,14 @@ bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
// Items inside rot but do not vanish as the container seals them in.
for( auto &c : itm.contents ) {
if( c.goes_bad() ) {
c.process_temperature_rot( 1, pnt, nullptr );
c.process_temperature_rot( 1, pnt, nullptr, flag );
}
}
return false;
} else {
// Check and remove rotten contents, but always keep the container.
for( auto it = itm.contents.begin(); it != itm.contents.end(); ) {
if( has_rotten_away( *it, pnt ) ) {
if( has_rotten_away( *it, pnt, flag ) ) {
it = itm.contents.erase( it );
} else {
++it;
Expand All @@ -6723,9 +6723,14 @@ bool map::has_rotten_away( item &itm, const tripoint &pnt ) const
template <typename Container>
void map::remove_rotten_items( Container &items, const tripoint &pnt )
{
const tripoint abs_pnt = getabs( pnt );
temperature_flag flag;
if( ter( pnt ) == t_rootcellar ) {
flag = TEMP_ROOT_CELLAR;
} else {
flag = TEMP_NORMAL;
}
for( auto it = items.begin(); it != items.end(); ) {
if( has_rotten_away( *it, abs_pnt ) ) {
if( has_rotten_away( *it, pnt, flag ) ) {
if( it->is_comestible() ) {
rotten_item_spawn( *it, pnt );
}
Expand Down
2 changes: 1 addition & 1 deletion src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ class map
* used for rot calculation.
* @return true if the item has rotten away and should be removed, false otherwise.
*/
bool has_rotten_away( item &itm, const tripoint &pnt ) const;
bool has_rotten_away( item &itm, const tripoint &pnt, temperature_flag flag = TEMP_NORMAL ) const;
/**
* Go through the list of items, update their rotten status and remove items
* that have rotten away completely.
Expand Down
7 changes: 4 additions & 3 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,14 +1439,14 @@ class jmapgen_make_rubble : public jmapgen_piece
class jmapgen_computer : public jmapgen_piece
{
public:
std::string name;
translation name;
translation access_denied;
int security;
std::vector<computer_option> options;
std::vector<computer_failure> failures;
bool target;
jmapgen_computer( const JsonObject &jsi ) {
name = jsi.get_string( "name" );
jsi.read( "name", name );
jsi.read( "access_denied", access_denied );
security = jsi.get_int( "security", 0 );
target = jsi.get_bool( "target", false );
Expand All @@ -1466,7 +1466,8 @@ class jmapgen_computer : public jmapgen_piece
const int ry = y.get();
dat.m.ter_set( point( rx, ry ), t_console );
dat.m.furn_set( point( rx, ry ), f_null );
computer *cpu = dat.m.add_computer( tripoint( rx, ry, dat.m.get_abs_sub().z ), name, security );
computer *cpu = dat.m.add_computer( tripoint( rx, ry, dat.m.get_abs_sub().z ), name.translated(),
security );
for( const auto &opt : options ) {
cpu->add_option( opt );
}
Expand Down
24 changes: 13 additions & 11 deletions src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ void npc::execute_action( npc_action action )
int oldmoves = moves;
tripoint tar = pos();
Creature *cur = current_target();
player *patient = dynamic_cast<player *>( current_ally() );
if( action == npc_flee ) {
tar = good_escape_direction( false );
} else if( cur != nullptr ) {
Expand Down Expand Up @@ -1082,18 +1081,21 @@ void npc::execute_action( npc_action action )
}
break;

case npc_heal_player:
update_path( patient->pos() );
if( path.size() == 1 ) { // We're adjacent to u, and thus can heal u
heal_player( *patient );
} else if( !path.empty() ) {
say( _( "Hold still %s, I'm coming to help you." ), patient->disp_name() );
move_to_next();
} else {
move_pause();
case npc_heal_player: {
player *patient = dynamic_cast<player *>( current_ally() );
if( patient ) {
update_path( patient->pos() );
if( path.size() == 1 ) { // We're adjacent to u, and thus can heal u
heal_player( *patient );
} else if( !path.empty() ) {
say( _( "Hold still %s, I'm coming to help you." ), patient->disp_name() );
move_to_next();
} else {
move_pause();
}
}
break;

}
case npc_follow_player:
update_path( g->u.pos() );
if( static_cast<int>( path.size() ) <= follow_distance() &&
Expand Down