Skip to content

Commit

Permalink
Merge branch 'pull-review/2119' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hvacengi committed Sep 19, 2017
2 parents 8306f39 + bd693ac commit 995035e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 5 additions & 4 deletions doc/source/bindings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,11 @@ something entirely outside the in-character experience.

::

PRINT VERSION. // Returns operating system version number. e.g. 0.8.6
PRINT VERSION:MAJOR. // Returns major version number. e.g. 0
PRINT VERSION:MINOR. // Returns minor version number. e.g. 8
PRINT VERSION:BUILD. // Returns build version number. e.g. 6
PRINT VERSION. // Returns operating system version number. e.g. 0.1.2.3
PRINT VERSION:MAJOR. // Returns major version number. e.g. 0 if version is 0.1.2.3
PRINT VERSION:MINOR. // Returns minor version number. e.g. 1 if version is 0.1.2.3
PRINT VERSION:PATCH. // Returns patch version number. e.g. 2 if version is 0.1.2.3
PRINT VERSION:BUILD. // Returns build version number. e.g. 3 if version is 0.1.2.3
PRINT SESSIONTIME. // Returns amount of time, in seconds, from vessel load.

NOTE the following important difference:
Expand Down
7 changes: 5 additions & 2 deletions src/kOS.Safe/Encapsulation/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ public class VersionInfo : Structure
{
private readonly int major;
private readonly int minor;
private readonly int patch;
private readonly int build;

public VersionInfo(int major, int minor, int build)
public VersionInfo(int major, int minor, int patch, int build)
{
this.major = major;
this.minor = minor;
this.patch = patch;
this.build = build;
VersionInitializeSuffixes();
}
Expand All @@ -21,12 +23,13 @@ private void VersionInitializeSuffixes()
{
AddSuffix("MAJOR", new StaticSuffix<ScalarValue>(() => major));
AddSuffix("MINOR", new StaticSuffix<ScalarValue>(() => minor));
AddSuffix("PATCH", new StaticSuffix<ScalarValue>(() => patch));
AddSuffix("BUILD", new StaticSuffix<ScalarValue>(() => build));
}

public override string ToString()
{
return string.Format("{0}.{1}.{2}", major, minor, build);
return string.Format("{0}.{1}.{2}.{3}", major, minor, patch, build);
}
}
}
8 changes: 7 additions & 1 deletion src/kOS/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public class Core : kOSProcessorFields
static Core()
{
var ver = typeof(Core).Assembly.GetName().Version;
VersionInfo = new VersionInfo(ver.Major, ver.Minor, ver.Build);
// NOTICE: there is a clash of nomenclature here. C# calls the
// 3rd number "BUILD" and the 4th number "Revision" while the AVC mod
// (and presumably CKAN) calls the 3rd number "PATCH" and the 4th number "BUILD".
// We'll be using the AVC terminology in kerboscript, thus why this next line
// passes in "ver.Revision" where the VersionInfo's "BUILD" goes, and the
// "ver.Build" where VersionInfo's "PATCH" goes:
VersionInfo = new VersionInfo(ver.Major, ver.Minor, ver.Build, ver.Revision);
}

public Core(kOSProcessor processor, SharedObjects shared):base(processor, shared)
Expand Down

0 comments on commit 995035e

Please sign in to comment.