Fixed broken patching and endless Steam nags introduced in SMM 1.7

This commit is contained in:
Vhati 2017-12-12 07:38:17 -05:00
parent cefb4986c0
commit a2bd02123e
7 changed files with 28 additions and 16 deletions

View file

@ -1,5 +1,10 @@
Changelog Changelog
1.8:
- Fixed endless prompting about Steam on startup for standalone distros
- Fixed mods not being added to FTL's resources
- Fixed 'stream closed' error during patching
1.7: 1.7:
- Added support for FTL 1.6.1 - Added support for FTL 1.6.1
- Added a config option to launch FTL via Steam, if possible - Added a config option to launch FTL via Steam, if possible

View file

@ -31,7 +31,7 @@ public abstract class AbstractPack {
} }
/** /**
* Adds bytes read from srcFile to the pack, as innerPath. * Adds bytes read from an InputStream to the pack, as innerPath.
*/ */
public void add( String innerPath, InputStream is ) throws IOException { public void add( String innerPath, InputStream is ) throws IOException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View file

@ -88,7 +88,7 @@ public class PackContainer {
public AbstractPack getPackFor( String innerPath ) { public AbstractPack getPackFor( String innerPath ) {
Matcher m = pathPtn.matcher( innerPath ); Matcher m = pathPtn.matcher( innerPath );
if ( m.matches() ) { if ( m.matches() ) {
String root = m.group( 1 ); String root = m.group( 2 );
AbstractPack rootPack = rootMap.get( root ); AbstractPack rootPack = rootMap.get( root );
if ( rootPack != null ) return rootPack; if ( rootPack != null ) return rootPack;

View file

@ -566,6 +566,9 @@ public class PkgPack extends AbstractPack {
return result; return result;
} }
/**
* Adds bytes read from an InputStream to the pack, as innerPath.
*/
@Override @Override
public void add( String innerPath, InputStream is ) throws IOException { public void add( String innerPath, InputStream is ) throws IOException {
if ( innerPath.indexOf( "\\" ) != -1 ) { if ( innerPath.indexOf( "\\" ) != -1 ) {
@ -608,18 +611,17 @@ public class PkgPack extends AbstractPack {
} }
// Write data. // Write data.
try {
raf.seek( entry.dataOffset ); raf.seek( entry.dataOffset );
byte[] buf = new byte[4096]; byte[] buf = new byte[4096];
int len; int len;
while ( (len = dataStream.read( buf )) >= 0 ) { while ( (len = dataStream.read( buf )) >= 0 ) {
raf.write( buf, 0, len ); raf.write( buf, 0, len );
} }
}
finally { // Attempting to close the wrapper streams would cause an exception if
try {if ( dataStream != null ) dataStream.close();} // the original stream was a ZipInputStream, which would need closeEntry().
catch ( IOException e ) {}
} // TODO: Test if compression works without closing the wrapper.
// Go back and fill in the dataSize. // Go back and fill in the dataSize.
entry.dataSize = raf.getChannel().position() - entry.dataOffset; entry.dataSize = raf.getChannel().position() - entry.dataOffset;

View file

@ -260,8 +260,11 @@ public class ModPatchThread extends Thread {
AbstractPack pack = packContainer.getPackFor( innerPath ); AbstractPack pack = packContainer.getPackFor( innerPath );
if ( pack == null ) { if ( pack == null ) {
if ( !knownRoots.contains( root ) ) if ( !knownRoots.contains( root ) ) {
log.warn( String.format( "Unexpected innerPath: %s", innerPath ) ); log.warn( String.format( "Unexpected innerPath: %s", innerPath ) );
} else {
log.debug( String.format( "Ignoring innerPath with known root: %s", innerPath ) );
}
zis.closeEntry(); zis.closeEntry();
continue; continue;
} }

View file

@ -16,6 +16,7 @@ public class SlipstreamConfig {
public static final String ALLOW_ZIP = "allow_zip"; public static final String ALLOW_ZIP = "allow_zip";
public static final String FTL_DATS_PATH = "ftl_dats_path"; public static final String FTL_DATS_PATH = "ftl_dats_path";
public static final String STEAM_DISTRO = "steam_distro";
public static final String STEAM_EXE_PATH = "steam_exe_path"; public static final String STEAM_EXE_PATH = "steam_exe_path";
public static final String RUN_STEAM_FTL = "run_steam_ftl"; public static final String RUN_STEAM_FTL = "run_steam_ftl";
public static final String NEVER_RUN_FTL = "never_run_ftl"; public static final String NEVER_RUN_FTL = "never_run_ftl";
@ -81,8 +82,9 @@ public class SlipstreamConfig {
userFieldsMap.put( ALLOW_ZIP, "Sets whether to treat .zip files as .ftl files. Default: false." ); userFieldsMap.put( ALLOW_ZIP, "Sets whether to treat .zip files as .ftl files. Default: false." );
userFieldsMap.put( FTL_DATS_PATH, "The path to FTL's resources folder. If invalid, you'll be prompted." ); userFieldsMap.put( FTL_DATS_PATH, "The path to FTL's resources folder. If invalid, you'll be prompted." );
userFieldsMap.put( STEAM_DISTRO, "If true, FTL was installed via Steam. Stops the GUI asking for a path." );
userFieldsMap.put( STEAM_EXE_PATH, "The path to Steam's executable, if FTL was installed via Steam." ); userFieldsMap.put( STEAM_EXE_PATH, "The path to Steam's executable, if FTL was installed via Steam." );
userFieldsMap.put( RUN_STEAM_FTL, "If true, SMM will use Steam to launch FTL, if possible. Default: false." ); userFieldsMap.put( RUN_STEAM_FTL, "If true, SMM will use Steam to launch FTL, if possible." );
userFieldsMap.put( NEVER_RUN_FTL, "If true, there will be no offer to run FTL after patching. Default: false." ); userFieldsMap.put( NEVER_RUN_FTL, "If true, there will be no offer to run FTL after patching. Default: false." );
userFieldsMap.put( UPDATE_CATALOG, "If a number greater than 0, check for new mod descriptions every N days." ); userFieldsMap.put( UPDATE_CATALOG, "If a number greater than 0, check for new mod descriptions every N days." );
userFieldsMap.put( UPDATE_APP, "If a number greater than 0, check for newer app versions every N days." ); userFieldsMap.put( UPDATE_APP, "If a number greater than 0, check for newer app versions every N days." );

View file

@ -54,7 +54,7 @@ public class JacksonAutoUpdateReader {
JsonNode changelogNode = historyNode.get( "changelog" ); JsonNode changelogNode = historyNode.get( "changelog" );
for ( JsonNode releaseNode : changelogNode ) { for ( JsonNode releaseNode : changelogNode ) {
// Skip any versions with optional "hidden" field set to true. // Skip any versions with optional "hidden" field set to true (true without quotes!).
if ( releaseNode.get( "hidden" ) != null && releaseNode.get( "hidden" ).booleanValue() ) { if ( releaseNode.get( "hidden" ) != null && releaseNode.get( "hidden" ).booleanValue() ) {
continue; continue;
} }