From 1980c5276959679ced38ef7414bd27145f761429 Mon Sep 17 00:00:00 2001 From: PostScriptReal <149461738+PostScriptReal@users.noreply.github.com> Date: Thu, 3 Jul 2025 23:50:14 +1000 Subject: [PATCH 1/4] Fix typo for GoldSRC compatibility check --- menus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menus.py b/menus.py index 9120ab9..d147c69 100644 --- a/menus.py +++ b/menus.py @@ -452,7 +452,7 @@ def __init__(self, template, master, startHidden:bool=False): self.logVal = BooleanVar(self.advOpt, value=False) self.logChk = Checkbutton(self.advOpt, text="Write log to file", variable=self.logVal, command=self.setLog) self.mVal = BooleanVar(self.advOpt, value=self.presetDat["-m"]) - self.mChk = Checkbutton(self.advOpt, text="GoldSRC compatability", variable=self.mVal) + self.mChk = Checkbutton(self.advOpt, text="GoldSRC compatibility", variable=self.mVal) self.uVal = BooleanVar(self.advOpt, value=self.presetDat["-u"]) self.uChk = Checkbutton(self.advOpt, text="Fix UV shifts", variable=self.uVal) self.vVal = BooleanVar(self.advOpt, value=self.presetDat["-V"]) From 623e16584d439eef338d288452c87ea305b6e5c9 Mon Sep 17 00:00:00 2001 From: PostScriptReal <149461738+PostScriptReal@users.noreply.github.com> Date: Fri, 4 Jul 2025 17:12:02 +1000 Subject: [PATCH 2/4] Add 0.52 Alpha (v6) .mdl support for decompiler --- README.md | 4 ++ menus.py | 110 ++++++++++++++++++++++++++++++++-------- third_party/mdl6dec.exe | Bin 0 -> 20480 bytes 3 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 third_party/mdl6dec.exe diff --git a/README.md b/README.md index d5cdf04..d4e4459 100644 --- a/README.md +++ b/README.md @@ -65,5 +65,9 @@
#}X?}FmJz~Qq80`CS&WFRH_fwM Tj^b}dbp^h-_dQYz`U`Qyb_H;i~?dgBW^&ulxdd}gqcwlZq{KqR3Vm_`*h~ZJ^
zvl4K~cNxx}Z#}l+HXP=7MZ%h|&}Yk If you want a bug to be fixed, open up an issue on the Github Repo and describe the issue, with steps to reproduce, operating system information, and/or terminal logs if applicable. If the program doesn't automatically open up with a terminal by default, then open up a terminal either by right-clicking and clicking 'Open in Terminal' in the context menu that pops up on Linux systems or on Windows systems, click the bar that shows the path to Snark and type 'cmd', then type in the name of the executable and hit enter (on Linux systems you need to type in './' before the executable name, otherwise the system will think it's a terminal command and not an executable). If it is a feature request, tag it as a feature request and describe what you want to have implemented into Snark. You can check the Official Snark Development Tracker to see your bug report or feature request while it's in progress. Snark uses some open-source libraries for proper usage, these libraries along with their licenses are shown in the table below: Snark uses some libraries for proper usage, these libraries along with their licenses are shown in the table below:c
External Libraries/Programs Used
-
Library/Program
diff --git a/helpers.py b/helpers.py
index ba8d3d7..c8b0c73 100644
--- a/helpers.py
+++ b/helpers.py
@@ -150,50 +150,85 @@ def __init__(self, qc):
self.qcLoc = os.path.dirname(qc)
self.cbarFrmt = False
- def crowbarFormatCheck(self):
+ def relPathCheck(self):
checks = 0
count = -1
- cd = False
- cdTex = 0
+ cd = ""
+ cdTex = ""
newCD = ""
- cdRef = 0
+ cdLoc = 0
newCDtex = ""
- cdTexR = 0
+ cdTexLoc = 0
self.newQC = self.qcf
self.newQCPath = ""
while checks < 2:
count += 1
- qcL = self.qcf[count]
- if qcL.startswith("$cdtex"):
- if qcL.find('\"./textures/\"') != -1:
- cdTex = 1
- cdTexR = count
+ try:
+ qcL = self.qcf[count]
+ if qcL.startswith("$cdtex"):
+ cdTexLoc = count
+ # Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
+ start = 0
+ end = 0
+ if qcL.find('\"') != -1:
+ start = qcL.find('\"')
+ else:
+ start = qcL.find("\'")
+
+ if qcL.find('\"', start+1) != -1:
+ end = qcL.find('\"', start+1)
+ else:
+ end = qcL.find("\'", start+1)
+ cdTex = qcL[start+1:end]
+ print(f"cdtex directory: {cdTex}")
checks += 1
- elif qcL.find('\".\"') != -1:
- cdTex = 2
- cdTexR = count
+ elif qcL.startswith("$cd"):
+ cdLoc = count
+ # Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
+ start = 0
+ end = 0
+ if qcL.find('\"') != -1:
+ start = qcL.find('\"')
+ else:
+ start = qcL.find("\'")
+
+ if qcL.find('\"', start+1) != -1:
+ end = qcL.find('\"', start+1)
+ else:
+ end = qcL.find("\'", start+1)
+ cd = qcL[start+1:end]
+ print(f"cdtex directory: {cdTex}")
checks += 1
- elif qcL.startswith("$cd") and qcL.find('\".\"') != -1:
- cd = True
- cdRef = count
- checks += 1
- if cd or cdTex != 0:
+ except:
+ print("Something went wrong during cd checks! The model may not compile properly!")
+ break
+ if cd or cdTex != "":
self.cbarFrmt = True
print(cd)
print(cdTex)
- if cd:
- newCD = self.qcf[cdRef]
- newCD = newCD.replace('\".\"', f'\"{self.qcLoc}\"')
- self.newQC[cdRef] = newCD
+ if cd != "":
+ newCD = self.qcf[cdLoc]
+ if cd == "." or cd == "./":
+ newCD = newCD.replace(cd, f'{self.qcLoc}')
+ elif cd.startswith("./"):
+ newCD = newCD.replace(cd, f'{self.qcLoc}/{cd[2:]}')
+ else:
+ newCD = newCD.replace(cd, f'{self.qcLoc}/{cd}')
+ self.newQC[cdLoc] = newCD
print(newCD)
- if cdTex == 1:
- newCDtex = self.qcf[cdTexR]
- newCDtex = newCDtex.replace('\"./textures/\"', f'\"{self.qcLoc}/textures/\"')
- self.newQC[cdTexR] = newCDtex
+ if cdTex != "":
+ newCDtex = self.qcf[cdTexLoc]
+ if cdTex == "." or cdTex == "./":
+ newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}')
+ elif cdTex.startswith("./"):
+ newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}/{cdTex[2:]}')
+ else:
+ newCDtex = newCDtex.replace(cdTex, f'{self.qcLoc}/{cdTex}')
+ self.newQC[cdTexLoc] = newCDtex
elif cdTex == 2:
- newCDtex = self.qcf[cdTexR]
+ newCDtex = self.qcf[cdTexLoc]
newCDtex = newCDtex.replace('\".\"', f'\"{self.qcLoc}\"')
- self.newQC[cdTexR] = newCDtex
+ self.newQC[cdTexLoc] = newCDtex
self.newQCPath = os.path.join(self.qcLoc, "temp.qc")
f = open(self.newQCPath, "w")
f.write("".join(self.newQC))
@@ -221,6 +256,7 @@ def getMDLname(self):
def check1024px(self):
checks = 0
count = -1
+ cdTex = ""
newCDtex = ""
self.newQC = self.qcf
self.newQCPath = ""
@@ -229,53 +265,48 @@ def check1024px(self):
count += 1
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
- if qcL.find('\"./textures/\"') != -1:
- cdTex = 1
- checks += 1
- elif qcL.find('\".\"') != -1:
- cdTex = 2
- checks += 1
- if cdTex != 0:
- if cdTex == 1:
- count = -1
- texPath = os.path.join(self.qcLoc, "textures/")
- textures = os.listdir(texPath)
- while count < len(textures)-1:
- count += 1
- tex = textures[count]
- fTex = os.path.join(self.qcLoc,tex)
- if os.path.isfile(fTex):
- try:
- width, height = get_image_size.get_image_size(os.path.join(self.qcLoc,tex))
- except get_image_size.UnknownImageFormat:
- width, height = -1, -1
- if width > 512 or height > 512:
- self.found1024 = True
- elif cdTex == 2:
- count = -1
- files = os.listdir(self.qcLoc)
- textures = []
- while count < len(files)-1:
- count += 1
- if files[count].endswith('.bmp'):
- textures.append(files[count])
- count = -1
- while count < len(textures)-1:
- count += 1
- tex = textures[count]
- fTex = os.path.join(self.qcLoc,tex)
- if os.path.isfile(fTex):
- try:
- width, height = get_image_size.get_image_size(os.path.join(self.qcLoc,tex))
- except get_image_size.UnknownImageFormat:
- width, height = -1, -1
- if width > 512 or height > 512:
- self.found1024 = True
+ # Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
+ start = 0
+ end = 0
+ if qcL.find('\"') != -1:
+ start = qcL.find('\"')
+ else:
+ start = qcL.find("\'")
+
+ if qcL.find('\"', start+1) != -1:
+ end = qcL.find('\"', start+1)
+ else:
+ end = qcL.find("\'", start+1)
+ cdTex = qcL[start+1:end]
+ print(f"cdtex directory: {cdTex}")
+ checks += 1
+ if cdTex != "":
+ # if cdTex == 1:
+ count = -1
+ if cdTex == "." or cdTex == "./":
+ texPath = self.qcLoc
+ elif cdTex.startswith("./"):
+ texPath = os.path.join(self.qcLoc, cdTex[2:])
+ else:
+ texPath = os.path.join(self.qcLoc, cdTex)
+ textures = os.listdir(texPath)
+ while count < len(textures)-1:
+ count += 1
+ tex = textures[count]
+ fTex = os.path.join(self.qcLoc,tex)
+ if os.path.isfile(fTex) and tex.endswith(".bmp"):
+ try:
+ width, height = get_image_size.get_image_size(fTex)
+ except get_image_size.UnknownImageFormat:
+ width, height = -1, -1
+ if width > 512 or height > 512:
+ self.found1024 = True
return self.found1024
def checkCHROME(self):
checks = 0
count = -1
+ cdTex = ""
newCDtex = ""
texmodes = []
self.newQC = self.qcf
@@ -285,52 +316,44 @@ def checkCHROME(self):
count += 1
qcL = self.qcf[count]
if qcL.startswith("$cdtex"):
- if qcL.find('\"./textures/\"') != -1:
- cdTex = 1
- checks += 1
- elif qcL.find('\".\"') != -1:
- cdTex = 2
- checks += 1
- if cdTex != 0:
- if cdTex == 1:
- count = -1
- texPath = os.path.join(self.qcLoc, "textures/")
- textures = os.listdir(texPath)
- while count < len(textures)-1:
- count += 1
- tex = textures[count]
- fTex = os.path.join(self.qcLoc,tex)
- texL = tex.lower()
- print(tex)
- if texL.find("chrome") != -1 and os.path.isfile(fTex):
- try:
- width, height = get_image_size.get_image_size(os.path.join(texPath,tex))
- except get_image_size.UnknownImageFormat:
- width, height = -1, -1
- if not width == 64 or not height == 64:
- self.fndUnlChr = True
- elif cdTex == 2:
- count = -1
- files = os.listdir(self.qcLoc)
- textures = []
- while count < len(files)-1:
- count += 1
- if files[count].endswith('.bmp'):
- textures.append(files[count])
- count = -1
- while count < len(textures)-1:
- count += 1
- tex = textures[count]
- fTex = os.path.join(self.qcLoc,tex)
- texL = tex.lower()
- print(tex)
- if texL.find("chrome") != -1 and os.path.isfile(fTex):
- try:
- width, height = get_image_size.get_image_size(fTex)
- except get_image_size.UnknownImageFormat:
- width, height = -1, -1
- if not width == 64 or not height == 64:
- self.fndUnlChr = True
+ # Getting the string inside the $cdtex command, y'know, the thing inside the quotes? Yeah, that thing.
+ start = 0
+ end = 0
+ if qcL.find('\"') != -1:
+ start = qcL.find('\"')
+ else:
+ start = qcL.find("\'")
+
+ if qcL.find('\"', start+1) != -1:
+ end = qcL.find('\"', start+1)
+ else:
+ end = qcL.find("\'", start+1)
+ cdTex = qcL[start+1:end]
+ print(f"cdtex directory: {cdTex}")
+ checks += 1
+ if cdTex != "":
+ # if cdTex == 1:
+ count = -1
+ if cdTex == "." or cdTex == "./":
+ texPath = self.qcLoc
+ elif cdTex.startswith("./"):
+ texPath = os.path.join(self.qcLoc, cdTex[2:])
+ else:
+ texPath = os.path.join(self.qcLoc, cdTex)
+ textures = os.listdir(texPath)
+ while count < len(textures)-1:
+ count += 1
+ tex = textures[count]
+ fTex = os.path.join(self.qcLoc,tex)
+ texL = tex.lower()
+ print(tex)
+ if texL.find("chrome") != -1 and os.path.isfile(fTex) and tex.endswith('.bmp'):
+ try:
+ width, height = get_image_size.get_image_size(fTex)
+ except get_image_size.UnknownImageFormat:
+ width, height = -1, -1
+ if not width == 64 or not height == 64:
+ self.fndUnlChr = True
return self.fndUnlChr
def checkTRM(self, renderM:int):
count = -1
diff --git a/menus.py b/menus.py
index b069f75..624b69d 100644
--- a/menus.py
+++ b/menus.py
@@ -256,7 +256,9 @@ def __init__(self, template, master, updFunc, startHidden:bool=False):
self.gameSel.bind("<