Skip to content

Commit

Permalink
Merge pull request #73838 from Procyonae/Backport71382
Browse files Browse the repository at this point in the history
Backport #71382
  • Loading branch information
dseguin authored May 16, 2024
2 parents bd1759c + ad5b0a4 commit 3cd91c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
38 changes: 27 additions & 11 deletions lang/string_extractor/parsers/mapgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,26 @@ def parse_mapgen(json, origin):
elif type(json["om_terrain"][0]) is list:
om = ", ".join(", ".join(i) for i in json["om_terrain"])

parse_mapgen_object(json["object"], origin, om)


def parse_mapgen_object(json, origin, om):
for key in ["place_specials", "place_signs"]:
if key in json["object"]:
for sign in json["object"][key]:
if key in json:
for sign in json[key]:
if "signage" in sign:
write_text(sign["signage"], origin,
comment="Signage placed on map {}".format(om))

if "signs" in json["object"]:
for sign in json["object"]["signs"]:
if "signage" in json["object"]["signs"][sign]:
write_text(json["object"]["signs"][sign]["signage"], origin,
if "signs" in json:
for sign in json["signs"]:
if "signage" in json["signs"][sign]:
write_text(json["signs"][sign]["signage"], origin,
comment="Signage placed on map {}".format(om))

if "computers" in json["object"]:
for key in json["object"]["computers"]:
com = json["object"]["computers"][key]
if "computers" in json:
for key in json["computers"]:
com = json["computers"][key]
com_name = ""
if "name" in com:
com_name = get_singular_name(com["name"])
Expand All @@ -50,8 +54,20 @@ def parse_mapgen(json, origin):
comment="Access denied message on computer \"{}\""
" placed on map {}".format(com_name, om))

if "place_computers" in json["object"]:
for computer in json["object"]["place_computers"]:
if "place_computers" in json:
for computer in json["place_computers"]:
if "name" in computer:
write_text(computer["name"], origin,
comment="Computer name placed on map {}".format(om))

if "place_monster" in json:
for m in json["place_monster"]:
if "name" in m:
desc = ""
if "monster" in m:
desc = "\"{}\"".format(m["monster"])
elif "group" in m:
desc = "group \"{}\"".format(m["group"])
write_text(m["name"], origin,
comment="Name of the monster {} placed on map {}"
.format(desc, om))
10 changes: 8 additions & 2 deletions lang/string_extractor/parsers/mission_definition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ..helper import get_singular_name
from ..write_text import write_text
from .effect import parse_effect
from .mapgen import parse_mapgen_object


def parse_mission_definition(json, origin):
Expand All @@ -20,5 +21,10 @@ def parse_mission_definition(json, origin):
format(name))

for key in ["start", "end", "fail"]:
if key in json and "effect" in json[key]:
parse_effect(json[key]["effect"], origin)
if key in json:
if "effect" in json[key]:
parse_effect(json[key]["effect"], origin)
if "update_mapgen" in json[key]:
parse_mapgen_object(json[key]["update_mapgen"], origin,
om="update on {} of mission \"{}\""
.format(key, name))
2 changes: 1 addition & 1 deletion src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ class jmapgen_monster : public jmapgen_piece
}

mongroup_id chosen_group = m_id.get( dat );
std::string chosen_name = name;
std::string chosen_name = _( name );
if( !random_name_str.empty() ) {
if( random_name_str == "female" ) {
chosen_name = SNIPPET.expand( "<female_given_name>" );
Expand Down

0 comments on commit 3cd91c4

Please sign in to comment.