From: ShadowFlare Date: Tue, 21 Jul 2009 04:02:00 +0000 (-0600) Subject: 1.65 X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=commitdiff_plain;h=0e6c0d4dda83f2662eb4a35b8e6c1afb6b774755;p=WinMPQ.git 1.65 ---- - Added a CWad to MPQ converter, usable by opening a CWad archive. - Added .w3x files to open MPQ dialog filter. - Fixed file extension filter box for file listing of the open archive so that it is positioned properly and only shows extensions from the current archive. --- diff --git a/About.frm b/About.frm index e6abbab..d870ecb 100644 --- a/About.frm +++ b/About.frm @@ -58,7 +58,7 @@ Begin VB.Form About Begin VB.Label Label3 AutoSize = -1 'True BackStyle = 0 'Transparent - Caption = "ShadowFlare's Realm - http://shadowflare.gameproc.com/" + Caption = "ShadowFlare's Realm - http://sfsrealm.hopto.org/" BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Times New Roman" Size = 9.75 @@ -78,7 +78,7 @@ Begin VB.Form About End Begin VB.Label Label2 AutoSize = -1 'True - Caption = "Copyright ?ShadowFlare Software" + Caption = "Copyright © ShadowFlare Software" Height = 195 Left = 120 TabIndex = 1 @@ -162,7 +162,7 @@ Label4.Font.underline = False Label5.Font.underline = False End Sub Private Sub Label3_Click() -ShellExecute hWnd, vbNullString, "http://shadowflare.gameproc.com/", vbNullString, vbNullString, 1 +ShellExecute hWnd, vbNullString, "http://sfsrealm.hopto.org/", vbNullString, vbNullString, 1 End Sub Private Sub Label3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Label3.ForeColor = &HFF00& diff --git a/CwadLib.bas b/CwadLib.bas new file mode 100644 index 0000000..a63a0e6 --- /dev/null +++ b/CwadLib.bas @@ -0,0 +1,29 @@ +Attribute VB_Name = "CwadLib" +Option Explicit + +Public Const CWAD_INFO_NUM_FILES As Long = &H03 ' Number of files in CWAD +Public Const CWAD_INFO_TYPE As Long = &H04 ' Is HANDLE a file or a CWAD? +Public Const CWAD_INFO_SIZE As Long = &H05 ' Size of CWAD or uncompressed file +Public Const CWAD_INFO_COMPRESSED_SIZE As Long = &H06 ' Size of compressed file +Public Const CWAD_INFO_FLAGS As Long = &H07 ' File flags (compressed, etc.) +Public Const CWAD_INFO_PARENT As Long = &H08 ' Handle of CWAD that file is in +Public Const CWAD_INFO_POSITION As Long = &H09 ' Position of file pointer in files +Public Const CWAD_INFO_PRIORITY As Long = &H0B ' Priority of open CWAD + +Public Const CWAD_TYPE_CWAD As Long = &H01 +Public Const CWAD_TYPE_FILE As Long = &H02 + +Public Const CWAD_SEARCH_CURRENT_ONLY As Long = &H00 ' Used with CWadOpenFile; only the archive with the handle specified will be searched for the file +Public Const CWAD_SEARCH_ALL_OPEN As Long = &H01 ' CWadOpenFile will look through all open archives for the file + +Declare Function CWadOpenArchive Lib "CwadLib.dll" (ByVal lpFileName As String, ByVal dwPriority As Long, ByRef hCWAD As Long) As Boolean +Declare Function CWadCloseArchive Lib "CwadLib.dll" (ByVal hCWAD As Long) As Boolean +Declare Function CWadListFiles Lib "CwadLib.dll" (ByVal hCWAD As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Long ' Returns required buffer size. Strings are in multi string form. (null-terminated strings with an extra null after the last string) +Declare Function CWadOpenFile Lib "CwadLib.dll" (ByVal hCWAD As Long, ByVal lpFileName As String, ByVal dwSearchScope As Long, ByRef hFile As Long) As Boolean +Declare Function CWadCloseFile Lib "CwadLib.dll" (ByVal hFile As Long) As Boolean +Declare Function CWadGetFileSize Lib "CwadLib.dll" (ByVal hFile As Long) As Long +Declare Function CWadGetFileInfo Lib "CwadLib.dll" (ByVal hFile As Long, ByVal dwInfoType As Long) As Long +Declare Function CWadSetFilePointer Lib "CwadLib.dll" (ByVal hFile As Long, ByVal lDistanceToMove As Long, ByVal dwMoveMethod As Long) As Long +Declare Function CWadReadFile Lib "CwadLib.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, ByRef lpNumberOfBytesRead As Long) As Boolean +Declare Function CWadSetArchivePriority Lib "CwadLib.dll" (ByVal hCWAD As Long, ByVal dwPriority As Long) As Boolean +Declare Function CWadFindHeader Lib "CwadLib.dll" (ByVal hFile As Long) As Long diff --git a/MpqStuff.bas b/MpqStuff.bas index 3a918d3..cf836a1 100644 --- a/MpqStuff.bas +++ b/MpqStuff.bas @@ -71,6 +71,44 @@ AboutPage = Path + "sfmpq.dll" If Not FileExists(AboutPage) Then AboutPage = "sfmpq.dll" ShellExecute 0, vbNullString, "res://" + AboutPage + "/about", vbNullString, vbNullString, 1 End Sub +Sub GetCompressFlags(File As String, ByRef cType As Integer, ByRef dwFlags As Long) +Dim bNum As Long, fExt As String +dwFlags = MAFA_REPLACE_EXISTING +If GlobalEncrypt Then dwFlags = dwFlags Or MAFA_ENCRYPT +For bNum = 1 To Len(File) + If InStr(bNum, File, ".") > 0 Then + bNum = InStr(bNum, File, ".") + Else + Exit For + End If +Next bNum +If bNum > 1 Then + fExt = Mid(File, bNum - 1) +Else + fExt = File +End If +If LCase(fExt) = ".bik" Then + cType = CInt(GetReg(AppKey + "Compression\.bik", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".smk" Then + cType = CInt(GetReg(AppKey + "Compression\.smk", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".mp3" Then + cType = CInt(GetReg(AppKey + "Compression\.mp3", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".mpq" Then + cType = CInt(GetReg(AppKey + "Compression\.mpq", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".w3m" Then + cType = CInt(GetReg(AppKey + "Compression\.w3m", "-2")) + dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) +ElseIf LCase(fExt) = ".wav" Then + cType = CInt(GetReg(AppKey + "Compression\.wav", "0")) +Else + cType = CInt(GetReg(AppKey + "Compression\" + fExt, CStr(DefaultCompressID))) +End If +End Sub + Function mOpenMpq(FileName As String) As Long Dim hMPQ As Long mOpenMpq = 0 @@ -269,41 +307,10 @@ ReDim ListedFiles(nHashEntries - 1) sListFiles = SFileListFiles(hMPQ, NewFileLists, ListedFiles(0), 0) End Function Sub mAddAutoFile(hMPQ As Long, File As String, MpqPath As String) -Dim cType As Integer, bNum As Long, fExt As String, dwFlags As Long -dwFlags = MAFA_REPLACE_EXISTING -If GlobalEncrypt Then dwFlags = dwFlags Or MAFA_ENCRYPT -For bNum = 1 To Len(File) - If InStr(bNum, File, ".") > 0 Then - bNum = InStr(bNum, File, ".") - Else - Exit For - End If -Next bNum -If bNum > 1 Then - fExt = Mid(File, bNum - 1) -Else - fExt = File -End If -If LCase(fExt) = ".bik" Then - cType = CInt(GetReg(AppKey + "Compression\.bik", "-2")) - dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) -ElseIf LCase(fExt) = ".smk" Then - cType = CInt(GetReg(AppKey + "Compression\.smk", "-2")) - dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) -ElseIf LCase(fExt) = ".mp3" Then - cType = CInt(GetReg(AppKey + "Compression\.mp3", "-2")) - dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) -ElseIf LCase(fExt) = ".mpq" Then - cType = CInt(GetReg(AppKey + "Compression\.mpq", "-2")) - dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) -ElseIf LCase(fExt) = ".w3m" Then - cType = CInt(GetReg(AppKey + "Compression\.w3m", "-2")) - dwFlags = dwFlags And (-1& Xor MAFA_ENCRYPT) -ElseIf LCase(fExt) = ".wav" Then - cType = CInt(GetReg(AppKey + "Compression\.wav", "0")) -Else - cType = CInt(GetReg(AppKey + "Compression\" + fExt, CStr(DefaultCompressID))) -End If +Dim cType As Integer, dwFlags As Long + +GetCompressFlags File, cType, dwFlags + Select Case cType Case -2 MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags, 0, 0 @@ -317,6 +324,25 @@ Case Else MpqAddFileToArchiveEx hMPQ, File, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel End Select End Sub +Sub mAddAutoFromBuffer(hMPQ As Long, ByRef buffer As Byte, BufSize As Long, MpqPath As String) +Dim cType As Integer, dwFlags As Long + +GetCompressFlags MpqPath, cType, dwFlags + +Select Case cType +Case -2 +MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags, 0, 0 +Case -1 +MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 +Case -3 +MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel +Case 0, 1, 2 +MpqAddWaveFromBuffer hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, cType +Case Else +MpqAddFileFromBufferEx hMPQ, buffer, BufSize, MpqPath, dwFlags Or MAFA_COMPRESS, DefaultCompress, DefaultCompressLevel +End Select +End Sub + Function DirEx(ByVal Path As String, Filter As String, Attributes, Recurse As Boolean) As String Dim Files() As String, lNum As Long, Folders() As String If Right(Path, 1) <> "\" And Path <> "" Then Path = Path + "\" diff --git a/WINMPQ.VBP b/WINMPQ.VBP index c50d1bd..1c93464 100644 --- a/WINMPQ.VBP +++ b/WINMPQ.VBP @@ -4,6 +4,7 @@ Module=RegistryFunctions; Registry.bas Module=FileDialog; FileDialog.bas Module=FixWindowIcon; FixIcon.bas Module=SFmpqapi; SFmpqapi.bas +Module=CwadLib; CwadLib.bas Form=Options.frm Form=ScriptOut.frm Form=About.frm @@ -14,7 +15,7 @@ Form=frmMpq.frm Form=frmAddToList.frm Form=ChLCID.frm Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.ocx -ProjWinSize=82,446,212,163 +ProjWinSize=83,934,212,163 ProjWinShow=2 IconForm="MpqEx" HelpFile="" @@ -26,11 +27,11 @@ HelpContextID="0" StartMode=0 VersionCompatible32="0" MajorVer=1 -MinorVer=64 +MinorVer=65 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="ShadowFlare Software" VersionFileDescription="ShadowFlare MPQ Archiver" -VersionLegalCopyright="Copyright © ShadowFlare Software 2001-2005" +VersionLegalCopyright="Copyright © ShadowFlare Software 2001-2009" VersionProductName="WinMPQ" diff --git a/WMpqEmbed.rtf b/WMpqEmbed.rtf index 1ca72b0..ae9c09b 100644 Binary files a/WMpqEmbed.rtf and b/WMpqEmbed.rtf differ diff --git a/WinMPQ.rtf b/WinMPQ.rtf index 8c7d860..ec6a554 100644 --- a/WinMPQ.rtf +++ b/WinMPQ.rtf @@ -1,6 +1,6 @@ {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fprq2 Arial;}{\f1\fswiss\fprq2\fcharset0 Arial;}{\f2\fmodern\fprq1 Courier New;}{\f3\fnil\fcharset2 Symbol;}} {\colortbl ;\red0\green0\blue0;} -\viewkind4\uc1\pard\b\f0\fs36 WinMPQ v1.\f1 64\b0\f0\fs20\par +{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\b\f0\fs36 WinMPQ v1.\f1 65\b0\f0\fs20\par \par \pard\li360 This program is an mpq archiver I \f1 started\f0 as an example of a program using the Mpq Control\f1 , but it now uses SFmpq directly\f0 . It currently has many features and is one of the best mpq archivers around.\par \pard\par @@ -152,6 +152,11 @@ NOTE: Each file that a MoPaQ can hold (the FileLimit) takes up 16 bytes in the M \pard\par \ul\b\fs24 Version history\ulnone\b0\fs20\par \par +\ul\b 1.\f1 65\f0 _________\par +\pard{\pntext\f3\'B7\tab}{\*\pn\pnlvlblt\pnf3\pnindent720{\pntxtb\'B7}}\fi-720\li720\ulnone\b0\f1 Added a CWad to MPQ converter, usable by opening a CWad archive.\f0\par +\f1{\pntext\f3\'B7\tab}Added .w3x files to open MPQ dialog filter.\f0\par +\f1{\pntext\f3\'B7\tab}Fixed file extension filter box for file listing of the open archive so that it is positioned properly and only shows extensions from the current archive.\f0\par +\pard\par \ul\b 1.\f1 64\f0 _________\par \pard{\pntext\f3\'B7\tab}{\*\pn\pnlvlblt\pnf3\pnindent720{\pntxtb\'B7}}\fi-720\li720\ulnone\b0\f1 Fixed a bug that caused an overflow error message when opening an archive containing files with totals that were too large to fit in the data type that I originally chose. This has been changed to handle larger sizes.\f0\par \pard\par @@ -299,6 +304,6 @@ NOTE: Each file that a MoPaQ can hold (the FileLimit) takes up 16 bytes in the M \pard\par -ShadowFlare\par \pard\li360 email:\tab blakflare@hotmail.com\par -web page:\tab http://shadowflare.\f1 gameproc.com\f0 /\par +web page:\tab http://\f1 sfsrealm.hopto.org\f0 /\par } \ No newline at end of file diff --git a/frmMpq.frm b/frmMpq.frm index 95384d5..ae3ba78 100644 --- a/frmMpq.frm +++ b/frmMpq.frm @@ -97,7 +97,7 @@ Dim MpqHeader As Long, IsEXE As Boolean, FileDialog As OPENFILENAME Private Sub cmdAdd_Click() Dim OldFileName As String, NewMpqHeader As Long, fNum As Long, Text As String, fNum2 As Long, Text2 As String, bNum As Long FileDialog.Flags = &H1000 Or &H4 Or &H2 -FileDialog.Filter = "Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx)|*.mpq;*.exe;*.snp;*.scm;*.scx|All Files (*.*)|*.*" +FileDialog.Filter = "Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x)|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x|All Files (*.*)|*.*" OldFileName = FileDialog.FileName FileDialog.hwndOwner = hWnd If ShowOpen(FileDialog) = False Then GoTo Cancel diff --git a/listing.frm b/listing.frm index a257dd8..a36ad42 100644 --- a/listing.frm +++ b/listing.frm @@ -681,6 +681,81 @@ MousePointer = 0 ShowSelected ShowTotal End Sub +Sub ConvertCwad() + Dim hCwad As Long, hMPQ As Long, hFile As Long, ListBuffer As String, BufSize As Long, Files() As String, buffer() As Byte, fLen As Long, nFile As Long, CwadName As String, dwFlags As Long + + If CWadOpenArchive(CD.FileName, 0, hCwad) Then + MsgBox "This archive must be converted to MPQ format to open it." + vbCrLf + "Enter a name for the converted archive or cancel if you do not want to perform the conversion.", vbInformation, "WinMPQ" + CwadName = CD.FileName + CD.Flags = &H1000 Or &H4 Or &H2 + CD.DefaultExt = "mpq" + CD.Filter = "Mpq Archive (*.mpq)|*.mpq" + CD.hwndOwner = hWnd + CD.FileName = CwadName + ".mpq" + If ShowSave(CD) Then + If CD.FileName = CwadName Then + MsgBox "Cannot overwrite source archive.", vbExclamation, "WinMPQ" + CWadCloseArchive hCwad + Exit Sub + End If + + BufSize = CWadListFiles(hCwad, ListBuffer, 0) + If BufSize > 0 Then ListBuffer = String$(BufSize - 1, Chr$(0)) + CWadListFiles hCwad, ListBuffer, BufSize + MultiStringToArray ListBuffer, Files + + If FileExists(CD.FileName) Then Kill CD.FileName + hMPQ = mOpenMpq(CD.FileName) + If hMPQ = 0 Then + StatBar.SimpleText = "Can't create archive " + CD.FileName + Else + dwFlags = MAFA_REPLACE_EXISTING + If GlobalEncrypt Then dwFlags = dwFlags Or MAFA_ENCRYPT + + For nFile = 1 To UBound(Files) + If CWadOpenFile(hCwad, Files(nFile), 0, hFile) Then + fLen = CWadGetFileSize(hFile) + + If fLen > 0 Then + ReDim buffer(fLen - 1) + Else + ReDim buffer(0) + End If + + CWadSetFilePointer hFile, 0, FILE_BEGIN + CWadReadFile hFile, buffer(0), fLen, fLen + CWadCloseFile hFile + + StatBar.SimpleText = "Adding " + Files(nFile) + "..." + MousePointer = 11 + If mnuMCNone.Checked Then + MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags, 0, 0 + ElseIf mnuMCStandard.Checked Then + MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_STANDARD, 0 + ElseIf mnuMCDeflate.Checked Then + MpqAddFileFromBufferEx hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, DefaultCompressLevel + ElseIf mnuMCAMedium.Checked Then + MpqAddWaveFromBuffer hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, 0 + ElseIf mnuMCAHighest.Checked Then + MpqAddWaveFromBuffer hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, 1 + ElseIf mnuMCALowest.Checked Then + MpqAddWaveFromBuffer hMPQ, buffer(0), fLen, Files(nFile), dwFlags Or MAFA_COMPRESS, 2 + ElseIf mnuMCAuto.Checked Then + mAddAutoFromBuffer hMPQ, buffer(0), fLen, Files(nFile) + End If + End If + Next nFile + + MpqCloseUpdatedArchive hMPQ, 0 + End If + Else + CD.FileName = CwadName + End If + + CWadCloseArchive hCwad + End If +End Sub + Sub DelRecentFile(rFileName As String) Dim bNum As Long, fNum As Long For bNum = 1 To 8 @@ -1587,6 +1662,11 @@ If FileExists(CD.FileName) And FileLen(CD.FileName) = 0 Then GoTo FileOpened End If On Error GoTo 0 + +If IsMPQ(CD.FileName) = False Then + ConvertCwad +End If + If IsMPQ(CD.FileName) = False Then CD.FileName = "" MsgBox "This file does not contain an MPQ archive.", vbExclamation, "WinMPQ" @@ -1634,6 +1714,7 @@ List.ListItems.Clear List.Sorted = False FileFilter = mFilter StatBar.SimpleText = "Building list... 0% complete" +mFilter.Clear For fNum = 0 To UBound(FileEntries) #If InternalListing Then If Mpq.FileExists(CD.FileName, FileList(fNum)) Then @@ -1743,6 +1824,7 @@ Caption = "WinMPQ - " + Mid(CD.FileName, bNum) AddRecentFile CD.FileName MousePointer = 0 End Sub + Sub RemoveDuplicates() Dim fNum As Long fNum = 1 @@ -1988,6 +2070,7 @@ If WindowState <> 1 Then txtCommand.Width = ScaleWidth - cmdGo.Width - Label1.Width cmdGo.Top = txtCommand.Top cmdGo.Left = txtCommand.Left + txtCommand.Width + mFilter.Left = Toolbar.Buttons.Item("filterspace").Left mFilter.Width = ScaleWidth - mFilter.Left - Toolbar.Buttons.Item("List").Width Toolbar.Buttons.Item("filterspace").Width = mFilter.Width End If @@ -2910,7 +2993,7 @@ Private Sub mnuFNew_Click() Dim TItem As Menu CD.Flags = &H1000 Or &H4 Or &H2 CD.DefaultExt = "mpq" -CD.Filter = "Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m)|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m|All Files (*.*)|*.*" +CD.Filter = "Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x)|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x|All Files (*.*)|*.*" CD.hwndOwner = hWnd If ShowSave(CD) = False Then GoTo Cancel ReDim FileList(0) As String @@ -2935,7 +3018,7 @@ End Sub Private Sub mnuFOpen_Click() Dim OldFileName As String CD.Flags = &H1000 Or &H4 Or &H2 -CD.Filter = "Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m)|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m|All Files (*.*)|*.*" +CD.Filter = "All Archives|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x;*.cwd|Mpq Archives (*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x)|*.mpq;*.exe;*.snp;*.scm;*.scx;*.w3m;*.w3x|Cwad Archives (*.cwd;*.exe)|*.cwd;*.exe|All Files (*.*)|*.*" OldFileName = CD.FileName CD.hwndOwner = hWnd If ShowOpen(CD) = False Then GoTo Cancel