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

155
dodo.py
View File

@ -3,15 +3,17 @@ from pathlib import Path
from doit import get_var 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):
@ -54,29 +63,28 @@ class BasePatchwork(dict):
patch = self.patches_path/v patch = self.patches_path/v
target = self.patchwork_path/k target = self.patchwork_path/k
yield { yield {
'name' : k, 'name': k,
'file_dep' : [ original, patch ], 'file_dep': [original, patch],
'targets' : [ target ], 'targets': [target],
'actions' : [ repack_action(action, original=original, patch=patch, target=target) 'actions': [repack_action(action, original=original, patch=patch, target=target)
for action in actions ], for action in actions],
'clean' : True 'clean': True
} }
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():
yield { yield {
'name' : k, 'name': k,
'file_dep' : [ self.patches_path/v, self.vanilla_path/k ], 'file_dep': [self.patches_path/v, self.vanilla_path/k],
'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(
self[relative_path] = data (Path(self.vanilla_path)/'history'/'states').glob(f"{key}*"))
relative_path = discovered_source.relative_to(
self.vanilla_path)
self[relative_path] = data
except StopIteration:
print(f"{key}: not found")
class RasterPatchwork(BasePatchwork): class RasterPatchwork(BasePatchwork):
@staticmethod @staticmethod
@ -135,44 +149,46 @@ 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')
dir_src_raw_files = RawFiles( dir_src_raw_files = RawFiles(
files(Path(dir_src_raw).rglob("*")), files(Path(dir_src_raw).rglob("*")),
src_path = dir_src_raw, src_path=dir_src_raw,
image_path = dir_image image_path=dir_image
) )
dir_patches_path = Path('src/patches') dir_patches_path = Path('src/patches')
dir_patchwork_path = Path('build/patched') 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',
}, },
patches_path = dir_patches_path, patches_path=dir_patches_path,
patchwork_path = dir_patchwork_path, patchwork_path=dir_patchwork_path,
vanilla_path = dir_vanilla vanilla_path=dir_vanilla
) )
patchwork_scripted = ScriptedPatchwork( patchwork_scripted = ScriptedPatchwork(
source_file = dir_patches_path/'extrapoint.yaml', source_file=dir_patches_path/'extrapoint.yaml',
patches_path = '.', patches_path='.',
patchwork_path = dir_patchwork_path, patchwork_path=dir_patchwork_path,
vanilla_path = dir_vanilla vanilla_path=dir_vanilla
) )
patchwork_raster = RasterPatchwork( patchwork_raster = RasterPatchwork(
{ {
'map/terrain.bmp' : 'terrain.bmp', 'map/terrain.bmp': 'terrain.bmp',
}, },
patches_path = dir_patches_path, patches_path=dir_patches_path,
patchwork_path = dir_patchwork_path, patchwork_path=dir_patchwork_path,
vanilla_path = dir_vanilla vanilla_path=dir_vanilla
) )
patch_set = Patchset( patch_set = Patchset(
@ -182,9 +198,10 @@ patch_set = Patchset(
patchwork_scripted, patchwork_scripted,
patchwork_raster, patchwork_raster,
), ),
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)))
@ -195,45 +212,50 @@ def task_patch_history_states_scripted():
with source.open(newline='') as infile, target.open('w') as outfile: with source.open(newline='') as infile, target.open('w') as outfile:
for line_in in infile: for line_in in infile:
outfile.write(line_in) outfile.write(line_in)
seen_history = seen_history or ( 'history' in line_in ) seen_history = seen_history or ('history' in line_in)
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():
yield { yield {
'name' : state_src, 'name': state_src,
'file_dep' : [ patchwork_scripted.key_vanilla(state_src) ], 'file_dep': [patchwork_scripted.key_vanilla(state_src)],
'targets' : [ patchwork_scripted.key_target(state_src) ], 'targets': [patchwork_scripted.key_target(state_src)],
'actions' : [ ( history_state_patch, [], {'provinces' : state_data}) ], 'actions': [(history_state_patch, [], {'provinces': state_data})],
'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)
yield from patchwork.tasks([ yield from patchwork.tasks([
mkdir, mkdir,
"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)))
@ -244,18 +266,19 @@ def task_image_mod():
o.write(s.read()) o.write(s.read())
o.write(f"\npath=\"{mod_install_path}\"\n") o.write(f"\npath=\"{mod_install_path}\"\n")
return { return {
'file_dep' : [ 'src/raw/descriptor.mod' ], 'file_dep': ['src/raw/descriptor.mod'],
'targets' : [f"{dir_image}/{mod_name}.mod" ], 'targets': [f"{dir_image}/{mod_name}.mod"],
'actions' : [ prepare_modname_mod ], 'actions': [prepare_modname_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()),
'targets' : [f"{dir_image}/{mod_name}.zip" ], 'targets': [f"{dir_image}/{mod_name}.zip"],
'actions' : [ "rm -f %(targets)s", 'actions': ["rm -f %(targets)s",
f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}", f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}",
f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}.mod" ], f"cd {dir_image} && zip -r {mod_name}.zip {mod_name}.mod"],
'clean' : [ 'rm -rf build' ] 'clean': ['rm -rf build']
} }

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 "Сосновка"