Skip to content

Commit bcae9d1

Browse files
committed
urcheon/action: add compile_ase and use it for mapmodels
1 parent 6a8bbc7 commit bcae9d1

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

Urcheon/Action.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def list():
177177
# and navmesh generation
178178
CopyBsp,
179179
CompileBsp,
180+
CompileAse,
180181
# perhaps one day MergeBsp will be run on a copied bsp
181182
# so it must be called after that
182183
MergeBsp,
@@ -957,7 +958,9 @@ class DumbTransient(Action):
957958
def createTransientPath(self):
958959
build_path = self.getTargetPath()
959960
self.transient_path = tempfile.mkdtemp(suffix="_" + os.path.basename(build_path) + "_transient" + os.path.extsep + "dir")
960-
self.transient_maps_path = os.path.join(self.transient_path, "maps")
961+
logging.debug("transient path: " + self.transient_path)
962+
963+
self.transient_maps_path = os.path.join(self.transient_path, os.path.dirname(self.file_path))
961964
os.makedirs(self.transient_maps_path, exist_ok=True)
962965

963966
def buildTransientPath(self, disabled_action_list=[]):
@@ -1115,3 +1118,41 @@ def effective_run(self):
11151118

11161119
def getFileNewName(self):
11171120
return self.switchExtension("bsp")
1121+
1122+
1123+
class CompileAse(DumbTransient):
1124+
keyword = "compile_ase"
1125+
description = "compile to ase format"
1126+
1127+
def effective_run(self):
1128+
source_path = self.getSourcePath()
1129+
build_path = self.getTargetPath()
1130+
bsp_path = self.getFileBspName()
1131+
self.createSubdirs()
1132+
1133+
self.createTransientPath()
1134+
1135+
Ui.laconic("Compiling to ase: " + self.file_path)
1136+
1137+
# Do not copy the map source when building in the source directory as a prepare step.
1138+
if self.source_dir == self.build_dir:
1139+
stage_done = ["copy"]
1140+
else:
1141+
stage_done = []
1142+
1143+
map_compiler = MapCompiler.Compiler(self.source_tree, map_profile="ase")
1144+
map_compiler.compile(source_path, self.transient_maps_path, stage_done=stage_done)
1145+
1146+
os.remove(os.path.join(self.transient_path, bsp_path))
1147+
1148+
self.buildTransientPath(disabled_action_list=["copy_bsp", "compile_bsp"])
1149+
1150+
self.setTimeStamp()
1151+
1152+
return self.getProducedUnitList()
1153+
1154+
def getFileBspName(self):
1155+
return self.switchExtension("bsp")
1156+
1157+
def getFileNewName(self):
1158+
return self.switchExtension("ase")

Urcheon/MapCompiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def readConfig(self, config_file_name, is_parent=False):
162162
"light": ["vis"],
163163
"minimap": ["vis"],
164164
"nav": ["vis"],
165+
"convert": ["bsp"],
165166
}
166167

167168
for profile_name in self.profile_dict.keys():
@@ -365,7 +366,7 @@ def q3map2(self, option_list, tool_name="q3map2"):
365366
extended_option_list = []
366367

367368
# bsp stage is the one that calls -bsp, etc.
368-
for stage in ["bsp", "vis", "light", "minimap", "nav"]:
369+
for stage in ["bsp", "vis", "light", "minimap", "nav", "convert"]:
369370
if "-" + stage in option_list:
370371
stage_name = stage
371372
logging.debug("stage name: " + stage_name)
@@ -383,6 +384,8 @@ def q3map2(self, option_list, tool_name="q3map2"):
383384
source_path = bsp_path
384385
elif "-minimap" in option_list:
385386
source_path = bsp_path
387+
elif "-convert" in option_list:
388+
source_path = bsp_path
386389
else:
387390
extended_option_list = ["-prtfile", self.prt_path, "-srffile", self.srf_path, "-bspfile", bsp_path]
388391
# TODO: define the name somewhere

profile/file/daemon.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ dir_ancestor_name = "maps"
190190
description = "Map"
191191
build = "compile_bsp"
192192

193+
[daemon_ase]
194+
file_ext = "map"
195+
dir_ancestor_name = "models"
196+
description = "Map object"
197+
prepare = "compile_ase"
198+
build = "copy"
199+
193200
[daemon_bspdir_lump]
194201
dir_ancestor_name = "maps"
195202
dir_father_ext = ".bspdir"

profile/map/common.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ game="${game}"
1010

1111
[copy]
1212
copy = { tool="copy" }
13+
14+
[ase]
15+
bsp = { tool="q3map2", options="-bsp -meta -fastmeta" }
16+
convert = { tool="q3map2", options="-convert -format ase" }

0 commit comments

Comments
 (0)