davidlallen
Deity
!!!
That is a million times simpler.
That is a million times simpler.
...
!define GLOBAL_DEFINES "Assets\XML\GlobalDefines.xml"
!define GD_VERSION_LINE " <DefineName>CIV4_VERSION</DefineName>"
!define GD_VERSION_NUMBER " <iDefineIntVal>319</iDefineIntVal>"
...
The function in the above link "ReadFileLine"
...
Function findINSTDIR1
Push $0
#Search for a valid BtS registry key, and get the Install Folder
#look for standard Civ4:BTS
ReadRegStr $0 ${MACHINE_REG_ROOT} "${FIRAXIS_REG_KEY}\${BTSREG_STANDARD}" 'INSTALLDIR'
${If} ${FileExists} $0
StrCpy $INSTDIR1 $0
${If} ${FileExists} "$INSTDIR1\${GLOBAL_DEFINES}"
Push 9
Push "$INSTDIR1\${GLOBAL_DEFINES}"
Call ReadFileLine
Pop $0
${If} $0 == "${GD_VERSION_LINE}"
Push 10
Push "$INSTDIR1\${GLOBAL_DEFINES}"
Call ReadFileLine
Pop $0
${If} $0 == ${GD_VERSION_NUMBER}
StrCpy $CurrentVersion "true"
Goto done
${Else}
StrCpy $CurrentVersion == "false"
Goto done
${EndIf}
${Else}
StrCpy $CurrentVersion "${UNKNOWN}"
Goto done
${EndIf}
${Else}
StrCpy $CurrentVersion "${UNKNOWN}"
Goto done
${EndIf}
${EndIf}
But I don't understand how to use this code. How am I declaring what XML file to read? And I see I'm asking it if it gets a value of 319, which is correct, but where is this code telling it what tag to look in?
Took some searching, and you are correct. Much simpler this way. Also I'm not sure if you need the XML plug in or not for it to work, since I'm having it read an XML document, and the script I pulled and put in my Include folder says it's to find an instance in a text document. But it works for me. Also this is so much simpler then all those damned registry checks.Isn't there a simple "if $x is in $file" test so you can look for this?
<iDefineIntVal>319</iDefineIntVal>
The logic for the installer is as follows: ...
Now for the patching script I uploaded for you before. It looks for the mod's registry, uses that for the install path, and then double checks by making sure the mod's ini file is in there. If any of these checks fail, the installer will abort. How I'd suggest to deal with the users with zipped folders is to release 1.7.1 as a full release again, since your main installer is broken anyway (which is what this whole thing is about), and use the patch script for the next update, which will then require 1.7.1 to be installed.
;Look for valid BtS folder in My Documents Path
Function findCivRootDir
Call findINSTDIR1
Push $0
# locate the Civ4:BTS INI folder
StrCpy $0 "$DOCUMENTS\My Games\${BTS}"
${If} ${FileExists} "$0\${CIV_INI_FILE}"
StrCpy $CivRootDir $0
${Else}
;Civ4 config not found, use My Games folder instead, as BUG searches here, if this folder exists
StrCpy $0 "$DOCUMENTS\My Games"
${If} ${FileExists} $0
StrCpy $CivRootDir $0
;Neither a valid BtS or My Games folder found in the users My Documents directory, UserSettings folder will be installed into the main mod's folder
${Else}
StrCpy $0 "$INSTDIR1\Mods"
StrCpy $CivRootDir $0
${EndIf}
${EndIf}
Pop $0
FunctionEnd