File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 55 "encoding/binary"
66 "errors"
77 "io"
8+ "strconv"
9+ "github.com/Masterminds/semver"
810)
911
1012type version16 struct {
@@ -66,7 +68,13 @@ func ReadHeader(filePath string) (Header, error) {
6668 return data , err
6769 }
6870
69- if ! data .FactorioVersion .CheckCompatibility (0 , 16 , 0 ) {
71+ Constraint , _ := semver .NewConstraint ("0.16.0 - 0.17.0" )
72+ Compatible , err := data .FactorioVersion .CheckCompatibility (Constraint )
73+ if err != nil {
74+ log .Printf ("Error checking compatibility: %s" , err )
75+ return data , err
76+ }
77+ if ! Compatible {
7078 log .Printf ("NOT COMPATIBLE Save-File" )
7179 log .Println (data )
7280 return data , ErrorIncompatible
@@ -344,6 +352,12 @@ func readSingleMod(file io.ReadCloser) (singleMod, error) {
344352 return Mod , err
345353}
346354
347- func (Version * versionShort16 ) CheckCompatibility (Major uint16 , Minor uint16 , Build uint16 ) (bool ) {
348- return Version .Major >= Major && Version .Minor >= Minor && Version .Build >= Build
355+ func (Version * versionShort16 ) CheckCompatibility (constraints * semver.Constraints ) (bool , error ) {
356+ Ver , err := semver .NewVersion (strconv .Itoa (int (Version .Major )) + "." + strconv .Itoa (int (Version .Minor )) + "." + strconv .Itoa (int (Version .Build )))
357+ if err != nil {
358+ log .Printf ("Error creating semver-version: %s" , err )
359+ return false , err
360+ }
361+
362+ return constraints .Check (Ver ), nil
349363}
You can’t perform that action at this time.
0 commit comments