Skip to content

Commit

Permalink
Camp name translations, hopefully?
Browse files Browse the repository at this point in the history
Co-authored-by: Procyonae <[email protected]>
  • Loading branch information
RenechCDDA and Procyonae committed May 29, 2024
1 parent 303010b commit 55ecada
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
5 changes: 4 additions & 1 deletion lang/string_extractor/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .parsers.ammunition_type import parse_ammunition_type
from .parsers.bionic import parse_bionic
from .parsers.body_part import parse_body_part
from .parsers.camp_migration import parse_camp_migration
from .parsers.character_mod import parse_character_mod
from .parsers.city import parse_city
from .parsers.climbing_aid import parse_climbing_aid
Expand Down Expand Up @@ -61,6 +62,7 @@
from .parsers.movement_mode import parse_movement_mode
from .parsers.mutation_category import parse_mutation_category
from .parsers.overmap_land_use_code import parse_overmap_land_use_code
from .parsers.overmap_special import parse_overmap_special
from .parsers.practice import parse_practice
from .parsers.scenario import parse_scenario
from .parsers.shop_blacklist import parse_shopkeeper_blacklist
Expand Down Expand Up @@ -114,6 +116,7 @@ def dummy_parser(json, origin):
"body_part": parse_body_part,
"book": parse_generic,
"butchery_requirement": dummy_parser,
"camp_migration": parse_camp_migration,
"character_mod": parse_character_mod,
"charge_removal_blacklist": dummy_parser,
"city": parse_city,
Expand Down Expand Up @@ -193,7 +196,7 @@ def dummy_parser(json, origin):
"overmap_connection": dummy_parser,
"overmap_land_use_code": parse_overmap_land_use_code,
"overmap_location": dummy_parser,
"overmap_special": dummy_parser,
"overmap_special": parse_overmap_special,
"overmap_special_migration": dummy_parser,
"overmap_terrain": parse_overmap_terrain,
"palette": parse_palette,
Expand Down
8 changes: 8 additions & 0 deletions lang/string_extractor/parsers/overmap_special.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from ..write_text import write_text


def parse_overmap_special(json, origin):
for overmap in json["overmaps"]:
if "camp_name" in overmap:
write_text(overmap["camp_name"], origin,
comment="Name of NPC faction camp")
2 changes: 1 addition & 1 deletion src/omdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ struct overmap_special_terrain : overmap_special_locations {
oter_str_id terrain;
std::set<std::string> flags;
std::optional<faction_id> camp_owner;
std::string camp_name;
translation camp_name;

void deserialize( const JsonObject &om );
};
Expand Down
14 changes: 7 additions & 7 deletions src/overmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ struct fixed_overmap_special_data : overmap_special_data {
} else {
basecamp *temp_camp = *bcp;
temp_camp->set_owner( elem.camp_owner.value() );
temp_camp->set_name( elem.camp_name );
temp_camp->set_name( elem.camp_name.translated() );
// FIXME? Camp types are raw strings! Not ideal.
temp_camp->define_camp( camp_loc, "faction_base_bare_bones_NPC_camp_0", false );
}
Expand Down Expand Up @@ -3972,7 +3972,7 @@ void overmap::clear_connections_out()
}

static std::map<std::string, std::string> oter_id_migrations;
static std::map<oter_type_str_id, std::pair<std::string, faction_id>> camp_map;
static std::map<oter_type_str_id, std::pair<translation, faction_id>> camp_migration_map;

void overmap::load_oter_id_migration( const JsonObject &jo )
{
Expand All @@ -3990,12 +3990,12 @@ void overmap::load_oter_id_camp_migration( const JsonObject &jo )
jsobj.read( "name", name );
jsobj.read( "overmap_terrain", oter );
jsobj.read( "faction", owner );
camp_map.emplace( oter, std::pair<std::string, faction_id>( name, owner ) );
camp_migration_map.emplace( oter, std::pair<std::string, faction_id>( name, owner ) );
}

void overmap::reset_oter_id_camp_migrations()
{
camp_map.clear();
camp_migration_map.clear();
}

void overmap::reset_oter_id_migrations()
Expand All @@ -4005,7 +4005,7 @@ void overmap::reset_oter_id_migrations()

bool overmap::oter_id_should_have_camp( const oter_type_str_id &oter )
{
return camp_map.count( oter ) > 0;
return camp_migration_map.count( oter ) > 0;
}

bool overmap::is_oter_id_obsolete( const std::string &oterid )
Expand Down Expand Up @@ -4046,8 +4046,8 @@ void overmap::migrate_camps( const std::vector<tripoint_abs_omt> &points ) const
basecamp *temp_camp = *bcp;
const oter_type_str_id &keyvalue = ter( project_remain<coords::om>
( point ).remainder_tripoint )->get_type_id();
temp_camp->set_owner( camp_map[keyvalue].second );
temp_camp->set_name( camp_map[keyvalue].first );
temp_camp->set_owner( camp_migration_map[keyvalue].second );
temp_camp->set_name( camp_migration_map[keyvalue].first.translated() );
temp_camp->define_camp( point, "faction_base_bare_bones_NPC_camp_0", false );
}
}
Expand Down

0 comments on commit 55ecada

Please sign in to comment.