mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Open all files with utf-8 encoding
- will not be used for binary read/writes (rb,wb)! - prevents a bug where units with special characters in the unit name can not be tracked anymore as there will be a name mismatch due to wrong encoding
This commit is contained in:
parent
c80d0e5378
commit
b5b0d82a1a
@ -23,6 +23,7 @@ Saves from 4.x are not compatible with 5.0.
|
|||||||
## Fixes
|
## Fixes
|
||||||
|
|
||||||
* **[Campaign]** Naval control points will no longer claim ground objectives during campaign generation and prevent them from spawning.
|
* **[Campaign]** Naval control points will no longer claim ground objectives during campaign generation and prevent them from spawning.
|
||||||
|
* **[Mission Generation]** Mission results and other files will now be opened with enforced utf-8 encoding to prevent an issue where destroyed ground units were untracked because of special characters in their names.
|
||||||
* **[UI]** Selling of Units is now visible again in the UI dialog and shows the correct amount of sold units
|
* **[UI]** Selling of Units is now visible again in the UI dialog and shows the correct amount of sold units
|
||||||
|
|
||||||
# 4.1.1
|
# 4.1.1
|
||||||
|
|||||||
@ -325,7 +325,7 @@ class AircraftType(UnitType[Type[FlyingType]]):
|
|||||||
logging.warning(f"No data for {aircraft.id}; it will not be available")
|
logging.warning(f"No data for {aircraft.id}; it will not be available")
|
||||||
return
|
return
|
||||||
|
|
||||||
with data_path.open() as data_file:
|
with data_path.open(encoding="utf-8") as data_file:
|
||||||
data = yaml.safe_load(data_file)
|
data = yaml.safe_load(data_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class GroundUnitType(UnitType[Type[VehicleType]]):
|
|||||||
logging.warning(f"No data for {vehicle.id}; it will not be available")
|
logging.warning(f"No data for {vehicle.id}; it will not be available")
|
||||||
return
|
return
|
||||||
|
|
||||||
with data_path.open() as data_file:
|
with data_path.open(encoding="utf-8") as data_file:
|
||||||
data = yaml.safe_load(data_file)
|
data = yaml.safe_load(data_file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -386,7 +386,7 @@ class PollDebriefingFileThread(threading.Thread):
|
|||||||
os.path.isfile("state.json")
|
os.path.isfile("state.json")
|
||||||
and os.path.getmtime("state.json") > last_modified
|
and os.path.getmtime("state.json") > last_modified
|
||||||
):
|
):
|
||||||
with open("state.json", "r") as json_file:
|
with open("state.json", "r", encoding="utf-8") as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
||||||
self.callback(debriefing)
|
self.callback(debriefing)
|
||||||
|
|||||||
@ -65,7 +65,7 @@ class Operation:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def prepare(cls, game: Game) -> None:
|
def prepare(cls, game: Game) -> None:
|
||||||
with open("resources/default_options.lua", "r") as f:
|
with open("resources/default_options.lua", "r", encoding="utf-8") as f:
|
||||||
options_dict = loads(f.read())["options"]
|
options_dict = loads(f.read())["options"]
|
||||||
cls._set_mission(Mission(game.theater.terrain))
|
cls._set_mission(Mission(game.theater.terrain))
|
||||||
cls.game = game
|
cls.game = game
|
||||||
|
|||||||
@ -12,7 +12,7 @@ def _build_version_string() -> str:
|
|||||||
]
|
]
|
||||||
build_number_path = Path("resources/buildnumber")
|
build_number_path = Path("resources/buildnumber")
|
||||||
if build_number_path.exists():
|
if build_number_path.exists():
|
||||||
with build_number_path.open("r") as build_number_file:
|
with build_number_path.open("r", encoding="utf-8") as build_number_file:
|
||||||
components.append(build_number_file.readline())
|
components.append(build_number_file.readline())
|
||||||
|
|
||||||
if not Path("resources/final").exists():
|
if not Path("resources/final").exists():
|
||||||
|
|||||||
@ -64,7 +64,8 @@ def run_ui(game: Optional[Game]) -> None:
|
|||||||
# init the theme and load the stylesheet based on the theme index
|
# init the theme and load the stylesheet based on the theme index
|
||||||
liberation_theme.init()
|
liberation_theme.init()
|
||||||
with open(
|
with open(
|
||||||
"./resources/stylesheets/" + liberation_theme.get_theme_css_file()
|
"./resources/stylesheets/" + liberation_theme.get_theme_css_file(),
|
||||||
|
encoding="utf-8",
|
||||||
) as stylesheet:
|
) as stylesheet:
|
||||||
logging.info("Loading stylesheet: %s", liberation_theme.get_theme_css_file())
|
logging.info("Loading stylesheet: %s", liberation_theme.get_theme_css_file())
|
||||||
app.setStyleSheet(stylesheet.read())
|
app.setStyleSheet(stylesheet.read())
|
||||||
|
|||||||
@ -228,7 +228,7 @@ class QWaitingForMissionResultWindow(QDialog):
|
|||||||
)
|
)
|
||||||
print(file)
|
print(file)
|
||||||
try:
|
try:
|
||||||
with open(file[0], "r") as json_file:
|
with open(file[0], "r", encoding="utf-8") as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
json_data["mission_ended"] = True
|
json_data["mission_ended"] = True
|
||||||
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
debriefing = Debriefing(json_data, self.game, self.unit_map)
|
||||||
|
|||||||
@ -43,7 +43,7 @@ class Campaign:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_file(cls, path: Path) -> Campaign:
|
def from_file(cls, path: Path) -> Campaign:
|
||||||
with path.open() as campaign_file:
|
with path.open(encoding="utf-8") as campaign_file:
|
||||||
if path.suffix == ".yaml":
|
if path.suffix == ".yaml":
|
||||||
data = yaml.safe_load(campaign_file)
|
data = yaml.safe_load(campaign_file)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user