Compare commits

...

2 Commits

Author SHA1 Message Date
1da050232c
scrapping some changes for HOI v1.14.1
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m41s
closes #7
2024-10-14 03:08:52 +04:00
3c76eb4844
adapt and fix for 1.14.1.e4e7 2024-09-28 02:51:44 +04:00
6 changed files with 532 additions and 582 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
__pycache__ __pycache__
.doit.db .doit.db
*.kate-swp *.kate-swp
/vanilla

47
dodo.py
View File

@ -4,14 +4,16 @@ from doit import get_var
DOIT_CONFIG = { DOIT_CONFIG = {
'default_tasks': ['build'], 'default_tasks': ['build'],
'action_string_formatting': 'new' 'action_string_formatting': 'both'
} }
def files(p): def files(p):
for i in p: for i in p:
if i.is_file(): if i.is_file():
yield i yield i
class RawFiles(list): class RawFiles(list):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.src_path = Path(kwargs.pop('src_path')) self.src_path = Path(kwargs.pop('src_path'))
@ -21,26 +23,33 @@ class RawFiles(list):
def sources(self): def sources(self):
for i in self: for i in self:
yield self.src_path/i yield self.src_path/i
def targets(self): def targets(self):
for i in self: for i in self:
yield self.image_path/i yield self.image_path/i
class BasePatchwork(dict): class BasePatchwork(dict):
patches_path = None patches_path = None
patchwork_path = None patchwork_path = None
vanilla_path = None vanilla_path = None
def __init__(self, *arkg, **kwargs): def __init__(self, *arkg, **kwargs):
self.patches_path = Path(kwargs.pop('patches_path')) self.patches_path = Path(kwargs.pop('patches_path'))
self.patchwork_path = Path(kwargs.pop('patchwork_path')) self.patchwork_path = Path(kwargs.pop('patchwork_path'))
self.vanilla_path = Path(kwargs.pop('vanilla_path')) self.vanilla_path = Path(kwargs.pop('vanilla_path'))
super().__init__(*arkg, **kwargs) super().__init__(*arkg, **kwargs)
def targets(self): def targets(self):
for i in self.keys(): for i in self.keys():
yield self.patchwork_path/i yield self.patchwork_path/i
def key_vanilla(self, orig_key): def key_vanilla(self, orig_key):
return self.vanilla_path/orig_key return self.vanilla_path/orig_key
def key_target(self, orig_key): def key_target(self, orig_key):
return self.patchwork_path/orig_key return self.patchwork_path/orig_key
def tasks(self, actions): def tasks(self, actions):
def repack_action(action, **kwargs): def repack_action(action, **kwargs):
if callable(action): if callable(action):
@ -63,7 +72,6 @@ class BasePatchwork(dict):
} }
class Patchwork(BasePatchwork): class Patchwork(BasePatchwork):
def tasks_(self, actions): def tasks_(self, actions):
for k, v in self.items(): for k, v in self.items():
@ -73,7 +81,7 @@ class Patchwork(BasePatchwork):
'targets': [self.patchwork_path/k], 'targets': [self.patchwork_path/k],
'actions': [ 'actions': [
f"mkdir -p {self.patchwork_path}/{Path(k).parent}", f"mkdir -p {self.patchwork_path}/{Path(k).parent}",
f"patch -u --binary -N -o '{self.patchwork_path}/{k}' "\ f"patch -u --binary -N -o '{self.patchwork_path}/{k}' "
f"'{self.vanilla_path}/{k}' '{self.patches_path}/{v}'" f"'{self.vanilla_path}/{k}' '{self.patches_path}/{v}'"
], # action ( mkdir, patch ) ], # action ( mkdir, patch )
'clean': True 'clean': True
@ -87,9 +95,15 @@ class ScriptedPatchwork(BasePatchwork):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
with open(file) as s: with open(file) as s:
for key, data in safe_load(s).items(): for key, data in safe_load(s).items():
discovered_source = next((Path(self.vanilla_path)/'history'/'states').glob(f"{key}*")) try:
relative_path = discovered_source.relative_to(self.vanilla_path) discovered_source = next(
(Path(self.vanilla_path)/'history'/'states').glob(f"{key}*"))
relative_path = discovered_source.relative_to(
self.vanilla_path)
self[relative_path] = data self[relative_path] = data
except StopIteration:
print(f"{key}: not found")
class RasterPatchwork(BasePatchwork): class RasterPatchwork(BasePatchwork):
@staticmethod @staticmethod
@ -135,8 +149,11 @@ class Patchset(list):
mod_name = 'randchgs' mod_name = 'randchgs'
mod_install_path = get_var('descriptor_mod_path', 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs') mod_install_path = get_var(
dir_vanilla = Path(get_var('vanilla_path', '../vanilla/current')) 'descriptor_mod_path', 'C:/Users/User/Documents/Paradox Interactive/Hearts of Iron IV/mod/randchgs')
dir_vanilla = Path(get_var('vanilla_path', './vanilla/current'))
if not dir_vanilla.is_dir():
raise EnvironmentError(dir_vanilla)
dir_image = Path('build/image') dir_image = Path('build/image')
dir_modimage = dir_image/mod_name dir_modimage = dir_image/mod_name
dir_src_raw = Path('src/raw') dir_src_raw = Path('src/raw')
@ -150,7 +167,6 @@ dir_patchwork_path = Path('build/patched')
patchwork = Patchwork( patchwork = Patchwork(
{ {
'map/definition.csv': 'map_definition.patch',
'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch', 'history/countries/ISR - Israel.txt': 'history_countries_ISR.patch',
'history/states/454-Israel.txt': 'history_states_454.patch', 'history/states/454-Israel.txt': 'history_states_454.patch',
}, },
@ -185,6 +201,7 @@ patch_set = Patchset(
modimage_path=dir_modimage modimage_path=dir_modimage
) )
def task_patch_history_states_scripted(): def task_patch_history_states_scripted():
def history_state_patch(task, provinces): def history_state_patch(task, provinces):
source = Path(next(iter(task.file_dep))) source = Path(next(iter(task.file_dep)))
@ -199,9 +216,10 @@ def task_patch_history_states_scripted():
if not wrote_history and seen_history and '{' in line_in: if not wrote_history and seen_history and '{' in line_in:
for province_id, province_info in provinces.items(): for province_id, province_info in provinces.items():
outfile.write( outfile.write(
"\t\tvictory_points = {\r\n"\ "\t\tvictory_points = {\r\n"
f"\t\t\t{province_id} {province_info['points']}\r\n"\ f"\t\t\t{province_id} {
"\t\t}\r\n"\ province_info['points']}\r\n"
"\t\t}\r\n"
) )
wrote_history = True wrote_history = True
for state_src, state_data in patchwork_scripted.items(): for state_src, state_data in patchwork_scripted.items():
@ -213,9 +231,11 @@ def task_patch_history_states_scripted():
'clean': True 'clean': True
} }
def task_patch_raster(): def task_patch_raster():
yield from patchwork_raster.tasks([patchwork_raster.patch_action]) yield from patchwork_raster.tasks([patchwork_raster.patch_action])
def task_patch(): def task_patch():
def mkdir(target, original, patch): def mkdir(target, original, patch):
Path(target).parent.mkdir(parents=True, exist_ok=True) Path(target).parent.mkdir(parents=True, exist_ok=True)
@ -224,16 +244,18 @@ def task_patch():
"patch -u --binary -N -o '{target}' '{original}' '{patch}'" "patch -u --binary -N -o '{target}' '{original}' '{patch}'"
]) ])
def task_image(): def task_image():
return { return {
'file_dep': list(patch_set.image_sources()), 'file_dep': list(patch_set.image_sources()),
'targets': list(patch_set.image_files()), 'targets': list(patch_set.image_files()),
'actions': [f"mkdir -p {dir_modimage}", 'actions': [f"mkdir -p {dir_modimage}",
f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"\ f"rsync -rv {dir_src_raw}/ {patchwork.patchwork_path}/"
f" {dir_modimage}/"], f" {dir_modimage}/"],
'clean': True 'clean': True
} }
def task_image_mod(): def task_image_mod():
def prepare_modname_mod(task): def prepare_modname_mod(task):
source = Path(next(iter(task.file_dep))) source = Path(next(iter(task.file_dep)))
@ -250,6 +272,7 @@ def task_image_mod():
'clean': True 'clean': True
} }
def task_build(): def task_build():
return { return {
'file_dep': [f"{dir_image}/{mod_name}.mod"] + list(patch_set.image_files()), 'file_dep': [f"{dir_image}/{mod_name}.mod"] + list(patch_set.image_files()),

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
--- ../vanilla/current/map/definition.csv 2023-10-10 13:46:35.000000000 +0400
+++ build/image/randchgs/map/definition.csv 2023-11-27 23:45:22.219054356 +0400
@@ -1013,7 +1013,7 @@
1012;5;17;244;sea;false;ocean;0
1013;5;18;30;land;true;plains;5
1014;5;18;85;land;true;jungle;6
-1015;5;18;135;land;true;desert;7
+1015;5;18;135;land;true;urban;7
1016;5;19;240;sea;false;ocean;0
1017;5;20;248;sea;false;ocean;0
1018;5;21;50;land;true;forest;6
@@ -1063,7 +1063,7 @@
1062;5;54;170;land;false;mountain;5
1063;5;57;30;land;true;forest;6
1064;5;57;85;land;false;desert;5
-1065;5;57;135;land;true;plains;7
+1065;5;57;135;land;true;urban;7
1066;5;60;50;land;false;mountain;6
1067;5;60;200;land;true;hills;6
1068;5;63;15;land;false;desert;5
@@ -1084,7 +1084,7 @@
1083;5;78;145;land;false;forest;6
1084;5;81;5;land;false;plains;6
1085;5;81;60;land;true;jungle;4
-1086;5;81;210;land;false;desert;7
+1086;5;81;210;land;false;urban;7
1087;5;84;25;land;false;plains;6
1088;5;84;70;land;true;plains;7
1089;5;84;175;land;true;hills;6

View File

@ -1,5 +0,0 @@
ISR_create_ships={
create_ship {
type = ship_hull_light_1
}
}

View File

@ -144,3 +144,4 @@
VICTORY_POINTS_11977:0 "Тэтджон" VICTORY_POINTS_11977:0 "Тэтджон"
VICTORY_POINTS_6928:0 "Ханнам" VICTORY_POINTS_6928:0 "Ханнам"
VICTORY_POINTS_8136:0 "Ондангва" VICTORY_POINTS_8136:0 "Ондангва"
VICTORY_POINTS_9215:0 "Сосновка"