Skip to content

Commit

Permalink
Omit turn 0 files
Browse files Browse the repository at this point in the history
Turn 0 files not only are useless to Nu Replayer, but are often malformed. Thus, no sense in extracting them.
  • Loading branch information
ChallengeSY committed Nov 29, 2022
1 parent d37267c commit c03aac8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 41 deletions.
6 changes: 3 additions & 3 deletions NREngine.bi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const BROWSER_LONG = "Nu Replayer 0.62 (Beta 3)"
const BROWSER_LONG = "Nu Replayer 0.62a (Beta 3)"

#IFNDEF __FORCE_OFFLINE__
' Online support parameters
Expand Down Expand Up @@ -401,9 +401,9 @@ sub updateStarmap
case 3 'Beams
if PartRef <= 10 AND CountFound > 0 then .BeamCount(PartRef) = CountFound
case 4 'Tubes
if PartRef <= 10 AND CountFound > 0 then .TubeCount(PartRef) = CountFound
if PartRef <= 110 AND CountFound > 0 then .TubeCount(PartRef) = CountFound
case 5 'Torp ammo
if PartRef <= 10 AND CountFound > 0 then .TorpCount(PartRef) = CountFound
if PartRef <= 110 AND CountFound > 0 then .TorpCount(PartRef) = CountFound
end select
end with
end if
Expand Down
78 changes: 40 additions & 38 deletions NRzip.bi
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,47 @@ Function unpackZipFile(ByVal zip As zip_t Ptr, ByVal i As Integer) As Integer

Print stat.size & " bytes"
'/

'' Create directories if needed
createParentDirs(extraDirs+filename)

'' Write out the file
Dim As Integer fo = FreeFile()
If (Open(extraDirs+filename, For Binary, Access Write, As #fo)) Then
' could not open output file"
Return 1
End If

'' Input for the file comes from libzip
Dim As zip_file_t Ptr fi = zip_fopen_index(zip, i, 0)
Do
'' Write out the file content as returned by zip_fread(), which
'' also does the decoding and everything.
'' zip_fread() fills our buffer
Dim As Integer bytes = _
zip_fread(fi, buffer, BUFFER_SIZE)
If (bytes < 0) Then
'zip_fread() failed"
Return 2
End If

'' EOF?
If (bytes = 0) Then
Exit Do
End If

'' Write <bytes> amount of bytes of the file
If (Put(#fo, , *buffer, bytes)) Then
'file output failed"
Return 3

If InStr(filename, "turn0") = 0 Then
'' Create directories if needed
createParentDirs(extraDirs+filename)

'' Write out the file
Dim As Integer fo = FreeFile()
If (Open(extraDirs+filename, For Binary, Access Write, As #fo)) Then
' could not open output file"
Return 1
End If
Loop

'' Done
zip_fclose(fi)
Close #fo

'' Input for the file comes from libzip
Dim As zip_file_t Ptr fi = zip_fopen_index(zip, i, 0)
Do
'' Write out the file content as returned by zip_fread(), which
'' also does the decoding and everything.
'' zip_fread() fills our buffer
Dim As Integer bytes = _
zip_fread(fi, buffer, BUFFER_SIZE)
If (bytes < 0) Then
'zip_fread() failed"
Return 2
End If

'' EOF?
If (bytes = 0) Then
Exit Do
End If

'' Write <bytes> amount of bytes of the file
If (Put(#fo, , *buffer, bytes)) Then
'file output failed"
Return 3
End If
Loop

'' Done
zip_fclose(fi)
Close #fo
End If
Return 0
End Function

Expand Down

0 comments on commit c03aac8

Please sign in to comment.