Author Topic: Windows batch file help?  (Read 1775 times)

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Windows batch file help?
« on: November 29, 2006, 11:27:06 AM »
I have a problem with the batch file failing to work properly for some users. For most users (including myself) the following batch does exactly what it's supposed to do and all sound and graphic files are unpacked.

Code: [Select]
@echo off
md Music\mxm#am
copy Amber\Music\*.ogg Music\mxm#am
copy Amber\Music\snd2acm.exe Music\mxm#am
copy Amber\sounds\oggdec.exe Music\mxm#am
cd Music\mxm#am
oggdec mxm#*.ogg
del mxm#*.ogg
del oggdec.exe
snd2acm.exe -wav mxm#amA.wav mxm#amA.acm
snd2acm.exe -wav mxm#amB1.wav mxm#amB1.acm
snd2acm.exe -wav mxm#amB2.wav mxm#amB2.acm
snd2acm.exe -wav mxm#amC.wav mxm#amC.acm
snd2acm.exe -wav mxm#amD.wav mxm#amD.acm
snd2acm.exe -wav mxm#amE1.wav mxm#amE1.acm
snd2acm.exe -wav mxm#amZ.wav mxm#amZ.acm
snd2acm.exe -wav mxm#amZC.wav mxm#amZC.acm
snd2acm.exe -wav mxm#amZD.wav mxm#amZD.acm
snd2acm.exe -wav mxm#amZE.wav mxm#amZE.acm
del mxm#*.wav
del snd2acm.exe
cd..
cd..
cd override
oggdec m#*.ogg
del m#*.ogg
del oggdec.exe
tisunpack m#ar*.tiz
del m#ar*.tiz
del tisunpack.exe
pause

Yet for some users the unpacking fails over and over again (re-installing does not help). What makes this more annoying is that since the unpacking is not carried by WeiDU the installation will not stop to the errors and the player will not notice anything before entering the new areas and the game crashes. (Okay, missing soundfiles can be a good hint that everything isn't okay.)

Documenting the error is also a challenge because the unpacking batch does not print a log of itself. Luckily, I managed to get a user to document these errors from the command prompt window:

Code: [Select]
oggdec is not recognized as and external or internal command
could not find g:\bgII-soa\override\m#*.ogg
could not find g:\bgII-soa\override\oggdec.exe
tisunpack is not recognized as and external or internal command
could not find g:\bgII-soa\override\m#ar*.tiz
could not find g:\bgII-soa\override\tisunpack.exe

According to the debug file the tisunpack and ogg dec are copied to the override along with the tiz and ogg files:
Code: [Select]
[...]
Copied [amber/areas/m#ar06.tiz] to [override/m#ar06.tiz]
[amber/areas/m#ar06.wed] loaded, 14678 bytes
Copied [amber/areas/m#ar06.wed] to [override/m#ar06.wed]
[amber/areas/tisunpack.exe] loaded, 94208 bytes
Copied [amber/areas/tisunpack.exe] to [override/tisunpack.exe]
Copying 1 file ...
[...]
Copied [amber/sounds/m#ymm014.ogg] to [override/m#ymm014.ogg]
[amber/sounds/m#ymm015.ogg] loaded, 106606 bytes
Copied [amber/sounds/m#ymm015.ogg] to [override/m#ymm015.ogg]
[amber/sounds/m#ymm016.ogg] loaded, 89629 bytes
Copied [amber/sounds/m#ymm016.ogg] to [override/m#ymm016.ogg]
[amber/sounds/m#ymm017.ogg] loaded, 95529 bytes
Copied [amber/sounds/m#ymm017.ogg] to [override/m#ymm017.ogg]
[amber/sounds/oggdec.exe] loaded, 155648 bytes
Copied [amber/sounds/oggdec.exe] to [override/oggdec.exe]
[...]

Any ideas what's going on and/or what I'm doing wrong in my batch file?

(There was a similar issue in the Mac version caused by using sub-optimal command to prompt the decoding program. Due that the unpacking failed unless the Mac user had the unpacking programs in the system directories.)

Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Windows batch file help?
« Reply #1 on: November 29, 2006, 06:26:42 PM »
I don't see anything wrong with the batch file per se.  Given the state of the errors and the fact it works on some systems and not others, I would guess possibly your TP2 copies some of the needed files *after* the batch execution, since the batch file itself does not do this.  You could put in some error handling logic to check for this:
Code: [Select]
cd..
cd..
cd override
IF EXIST oggdec.exe (
     oggdec m#*.ogg
     del m#*.ogg
     del oggdec.exe
 ) ELSE (
     echo Error - oggdec.exe missing.
 )
IF EXIST tisunpack.exe (
     tisunpack m#ar*.tiz
     del m#ar*.tiz
     del tisunpack.exe
 ) ELSE (
     echo Error - tisunpack.exe missing.
 )
pause

Or instead of echoing the error messages, you could have the files explicitly copied over if they don't exist where you're looking for them.

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Re: Windows batch file help?
« Reply #2 on: November 30, 2006, 10:21:38 AM »
I don't see anything wrong with the batch file per se.  Given the state of the errors and the fact it works on some systems and not others, I would guess possibly your TP2 copies some of the needed files *after* the batch execution, since the batch file itself does not do this. 

At least I *tried* to copy the files before prompting the batch, right in the beginning of the tp2:

Code: [Select]
BEGIN @150 /* @150 = ~Amber the NPC MOD for BGII:SoA~ */
REQUIRE_PREDICATE FILE_EXISTS_IN_GAME ~mel01.cre~ @151 /* @151 = ~Please install the Throne of Bhaal expansion and the official patch before installing Amber.~ */

COPY ~amber/graphics~ ~override~
COPY ~amber/areas~ ~override~
COPY ~amber/sounds~ ~override~
COPY ~amber/2da/lum#a.2da~ ~override~
COPY ~amber/music/m#blank.mus~ ~music~
COPY ~amber/music/mxm#am.mus~ ~music~
COPY_EXISTING ~songlist.2da~ ~override~
SET_2DA_ENTRY 0 2 3 ~M#BLANK.MUS~
ADD_MUSIC  ~Amber~    ~Music/mxm#am.mus~

The batch is prompted before the second component (ie. in the end of the first one):

Code: [Select]
AT_NOW ~Amber/AmberUnpack.bat~
AT_INTERACTIVE_EXIT ~Amber/AmberReadme.html~
AT_UNINSTALL ~Amber/AmberUninstall.bat~
 
// 2nd component: Multiplayer-friendly flirting

BEGIN @333 /* @333 = ~multiplayer-friendly flirting for Amber~ */
REQUIRE_PREDICATE FILE_EXISTS_IN_GAME ~m#ambr10.cre~ @334 /* @334 = ~Please install Amber NPC before installing multiplayer-friendly flirting.~ */


Or instead of echoing the error messages, you could have the files explicitly copied over if they don't exist where you're looking for them.

That could be an useful solution, thanks. I'm might need someone to check up the code, I'm pretty useless when it comes to batch files.



Offline Miloch

  • Barbarian
  • Planewalker
  • *****
  • Posts: 1032
  • Gender: Male
Re: Windows batch file help?
« Reply #3 on: November 30, 2006, 11:46:54 AM »
I could be clutching at straws, but would this issue be related?

Offline Meira

  • Planewalker
  • *****
  • Posts: 188
  • Gender: Female
  • I'm the snow on your lips
    • Amber's Home
Re: Windows batch file help?
« Reply #4 on: December 02, 2006, 03:49:38 PM »
The first report of the issue pre-dates the addition of REQUIRE_PREDICATE FILE_EXISTS_IN_GAME to my tp2. It used to be just REQUIRE_FILE, but that didn't work so well with biffed overrides. I'm not sure if I understood 100% what was the going on in the thread you linked, but since everything else (and *most* of the time the unpacking of graphics and audio too) is working in my mod just fine; I don't *think* it's that causing the problem. Maybe... :P Thanks for the thought, though. :)

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: