Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b533bb3
Copy files across from branch (not fork - I'm new to git, whoops)
Azrail09Code May 27, 2026
17d3e5e
Prevent new saves without terrain configs loaded from freezing
Azrail09Code May 27, 2026
6b43a61
Add debug prints to clarify whether a _ColorMap or _ColorCube was bei…
Azrail09Code May 28, 2026
02df5a1
Use .cfg files to define custom SCANsat textures and memory map them …
Azrail09Code May 30, 2026
dc6740f
Shove references to the correct terrainConfig everywhere throughout t…
Azrail09Code May 31, 2026
88e5227
Added reader support for heightMap and normalMap parameters, and adde…
Azrail09Code Jun 6, 2026
9af3a8d
Fix biome legend entries.
Azrail09Code Jun 25, 2026
fe4a2c4
Make biome legend entries space more evenly.
Azrail09Code Jun 25, 2026
506ef0f
Configs for altimetry broken, but colour methods fixed. Don't use thi…
Azrail09Code Jun 26, 2026
bf3cf1b
Changed TerrainConfig storage.
Azrail09Code Jun 27, 2026
a6f374b
Generate legend entries to 2sf instead of nearest 100m.
Azrail09Code Jun 27, 2026
61149cd
Keep biome colours intact for RGBA defined biomes
Azrail09Code Jun 27, 2026
3cebe0b
Cache Normal data in alpha channel of Visual data when caching texture.
Azrail09Code Jun 30, 2026
59f0403
Texture management into its own class and drop index reference in SCA…
Azrail09Code Jul 6, 2026
10cb442
Updated README to contain some information about what the hell I have…
Azrail09Code Jul 7, 2026
585ff45
Add readme shields to better match existing formatting.
Azrail09Code Jul 7, 2026
ab17205
Switch to single reflect check on MechJeb and add texture reload for …
Azrail09Code Jul 7, 2026
386f51d
Update build pipeline to KSPBuildTools 1.1.1
Azrail09Code Jul 8, 2026
f053d9d
Readonly fields and update main map button type from Terrain to Altim…
Azrail09Code Jul 8, 2026
ffc9f79
Set SCANsat version file to the right location.
Azrail09Code Jul 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
bin/
obj/
*.user
*.dll
*.pdb
SCANsat.Unity/Properties/launchSettings.json
GameData/SCANsat/Plugins/SCAN*
GameData/SCANsat/PluginData/Settings.cfg
GameData/SCANsat/Parts/@thumbs/
Expand Down
17 changes: 0 additions & 17 deletions GameData/SCANsat/Resources/SCANcolors.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ SCAN_Color_Config
Item
{
name = Kerbin
index = 1
minHeightRange = -1500
maxHeightRange = 6500
clampHeight = 0
Expand All @@ -25,7 +24,6 @@ SCAN_Color_Config
Item
{
name = Sun
index = 0
minHeightRange = 0
maxHeightRange = 1000
clampHeight = Null
Expand All @@ -40,7 +38,6 @@ SCAN_Color_Config
Item
{
name = Mun
index = 2
minHeightRange = -500
maxHeightRange = 7000
clampHeight = Null
Expand All @@ -55,7 +52,6 @@ SCAN_Color_Config
Item
{
name = Minmus
index = 3
minHeightRange = -500
maxHeightRange = 5500
clampHeight = Null
Expand All @@ -70,7 +66,6 @@ SCAN_Color_Config
Item
{
name = Moho
index = 4
minHeightRange = -300
maxHeightRange = 6500
clampHeight = Null
Expand All @@ -85,7 +80,6 @@ SCAN_Color_Config
Item
{
name = Eve
index = 5
minHeightRange = -2000
maxHeightRange = 7000
clampHeight = 0
Expand All @@ -100,7 +94,6 @@ SCAN_Color_Config
Item
{
name = Duna
index = 6
minHeightRange = 0
maxHeightRange = 7000
clampHeight = Null
Expand All @@ -115,7 +108,6 @@ SCAN_Color_Config
Item
{
name = Ike
index = 7
minHeightRange = 0
maxHeightRange = 12000
clampHeight = Null
Expand All @@ -130,7 +122,6 @@ SCAN_Color_Config
Item
{
name = Jool
index = 8
minHeightRange = 0
maxHeightRange = 1000
clampHeight = Null
Expand All @@ -145,7 +136,6 @@ SCAN_Color_Config
Item
{
name = Laythe
index = 9
minHeightRange = -3000
maxHeightRange = 6000
clampHeight = 0
Expand All @@ -160,7 +150,6 @@ SCAN_Color_Config
Item
{
name = Vall
index = 10
minHeightRange = -500
maxHeightRange = 7500
clampHeight = Null
Expand All @@ -175,7 +164,6 @@ SCAN_Color_Config
Item
{
name = Bop
index = 11
minHeightRange = 2000
maxHeightRange = 21500
clampHeight = Null
Expand All @@ -190,7 +178,6 @@ SCAN_Color_Config
Item
{
name = Tylo
index = 12
minHeightRange = 0
maxHeightRange = 11000
clampHeight = Null
Expand All @@ -205,7 +192,6 @@ SCAN_Color_Config
Item
{
name = Gilly
index = 13
minHeightRange = 1500
maxHeightRange = 6000
clampHeight = Null
Expand All @@ -220,7 +206,6 @@ SCAN_Color_Config
Item
{
name = Pol
index = 14
minHeightRange = 500
maxHeightRange = 5500
clampHeight = Null
Expand All @@ -235,7 +220,6 @@ SCAN_Color_Config
Item
{
name = Dres
index = 15
minHeightRange = -200
maxHeightRange = 5500
clampHeight = Null
Expand All @@ -250,7 +234,6 @@ SCAN_Color_Config
Item
{
name = Eeloo
index = 16
minHeightRange = -500
maxHeightRange = 3500
clampHeight = Null
Expand Down
7 changes: 4 additions & 3 deletions GameData/SCANsat/SCANsat.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"NAME": "SCANsat",
"URL": "https://github.com/KSPModStewards/SCANsat/releases/latest/download/SCANsat.version",
"DOWNLOAD": "https://github.com/KSPModStewards/SCANsat/releases"

"VERSION": "21.1.0.0",
"KSP_VERSION": "1.12",
"KSP_VERSION_MIN": "1.12.3",
"KSP_VERSION_MAX": "1.12"
}
7 changes: 7 additions & 0 deletions GameData/SCANsat/SCANsat/SCANsat.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"NAME": "SCANsat",
"VERSION": "21.1.0.0",
"KSP_VERSION": "1.12",
"KSP_VERSION_MIN": "1.12.3",
"KSP_VERSION_MAX": "1.12"
}
44 changes: 35 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
> ![scan your planetoid like the big boys do][bigmap-scan-10000x]
> ###### **Example SAR scan of Kerbin at 1000x and then 10,000x warp**

[![][shield:support-ksptl]][ksptl:release] 
[![][shield:support-rpm]][RPM:release] 
[![][shield:support-mm]][mm:release] 
[![][shield:support-toolbar]][toolbar:release] 
Expand All @@ -25,7 +26,8 @@
* [1. Installation and Interoperability][1]
* [a. Installation][1a]
* [b. GameData Layout][1b]
* [c. Other Add-Ons][1c]
* [c. Texture Configurations][1c]
* [d. Other Add-Ons][1d]
* [2. Types of Scans][2]
* [a. Native SCANsat][2a]
* [3. Resource Scanning][3]
Expand Down Expand Up @@ -165,7 +167,25 @@ For licensing information, please see the [included LICENSE.txt][SCANsat:rel-lic

![][SCANsat:gamedata]

#### [:top:][top] 1c. Other Add-Ons
#### [:top:][top] 1c. Texture Configurations

S.C.A.N. was originally designed to load all visual and normal textures into RAM directly from the game, as this doesn't require any additional configuration steps for planet packs to integrate directly with the mod. This, however, has led to performance issues with large scale textures and planet packs (notoriously Real Solar System scale packs like Sol).

To get around this, support has been added for memory mapping external textures through KSPTextureLoader. This works by defining the relative path to the height, normal and color textures for each planet, and defining them in a config file as shown below (recommend making one for each body titled "BodyName_SCANsat.cfg"):

```
SCANSAT_BODY_TEXTURES
{
name = Mercury // Use name of body in Kopernicus
heightMap = GameData/Sol-Textures/PluginData/01_Mercury/Kopernicus/Mercury_Height.dds
normalMap = GameData/Sol-Textures/PluginData/01_Mercury/Kopernicus/Mercury_Normal.dds
colorMap = GameData/Sol-Textures/PluginData/01_Mercury/Kopernicus/Mercury_Color.dds
}
```

With these paths defined, the CPU is able to pull data directly out of the texture from the file system without loading it into RAM. Planet pack makers are encouraged to use this new interface with their packs as this directly specifies the textures SCANsat will display in game.

#### [:top:][top] 1d. Other Add-Ons

S.C.A.N. is proud to collaborate with other KSP mods and modding teams. Following is a table of all of the mods, add-ons, or software that we interoperate with.

Expand All @@ -175,14 +195,14 @@ S.C.A.N. is proud to collaborate with other KSP mods and modding teams. Followin
[**Blizzy78's Toolbar**][toolbar:release] | [![Support for Karbonite][karbonite:logo]][karbonite:release]
[**ModuleManager**][mm:release] | [![Support for ALCOR][alcor:logo]][alcor:release]
[**RasterPropMonitor**][rpm:release] |
[**KSPTextureLoader**][ksptl:release] |

* **SCANsat**
* [x] [**v16.0**][SCANsat:rel-thread] SCANsat Release **version: v16.0**
* [x] [**v15.0**][SCANsat:dev-thread] SCANsat Dev **version: v15.0**
**MM**, **RPM**, **MechJeb** and **Toolbar** are all **soft** dependencies. This means your experience with SCANsat will be enhanced if you are using these mods, but they are not necessary.

**MM**, **RPM**, **MechJeb**, and **Toolbar** are all **soft** dependencies. This means your experience with SCANsat will be enhanced if you are using these mods, but they are not necessary.
**KSPTextureLoader** is a built dependency, however, as all planets that have external texture files are strongly recommended to use memory mapped textures, with RAM cached variants only being a fallback. This ensures that no errors occur with shader configs and that the exact texture desired ends up displayed in game.

**SCANsat** is built against the following mods:
* [x] [![][shield:support-ksptl]][ksptl:release]
* [x] [![][shield:support-mm]][mm:release]
* [x] [![][shield:support-rpm]][rpm:release]
* [x] [![][shield:support-alcor]][alcor:release]
Expand All @@ -200,6 +220,8 @@ scanning modules or parts).
* **RadarHi**: Advanced, High-Resolution RADAR Altimetry (in color, unlimited zoom)
* **Slope**: Slope Data converted from RADAR data
* **Biome**: Biome Detection and Classification (in color, unlimited zoom)
* **VisualLo**: Basic, Low-Resolution Visual Imaging (b&w, limited zoom)
* **VisualHi**: Full Color, High Resolution Visual Imaging
* **Anomaly**: Anomaly Detection and Labeling
* **Resource**: Scan for chemical or mineral resource on the surface.

Expand Down Expand Up @@ -815,7 +837,8 @@ sneaky then they can of course be sneaky.
[1]: #top-1-installation-and-interoperability
[1a]: #top-1a-installation
[1b]: #top-1b-gamedata-layout
[1c]: #top-1c-other-add-ons
[1c]: #top-1c-texture-configurations
[1d]: #top-1d-other-add-ons
[2]: #top-2-types-of-scans
[2a]: #top-2a-scansat-scans
[3]: #top-3-resource-scanning
Expand Down Expand Up @@ -863,8 +886,9 @@ sneaky then they can of course be sneaky.

[shield:jenkins-dev]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-dev.svg
[shield:jenkins-rel]: http://img.shields.io/jenkins/s/https/ksp.sarbian.com/jenkins/SCANsat-release.svg
[shield:support-ksp]: http://img.shields.io/badge/for%20KSP-v1.4.1-bad455.svg
[shield:support-ksp]: http://img.shields.io/badge/for%20KSP-v1.12.x-bad455.svg
[shield:support-rpm]: http://img.shields.io/badge/works%20with%20RPM-v0.28.x-a31f34.svg
[shield:support-ksptl]: https://img.shields.io/badge/requires%20KSPTextureLoader-1.0.34+-84e0d7.svg
[shield:support-mm]: http://img.shields.io/badge/works%20with%20MM-v3.x-40b7c0.svg
[shield:support-toolbar]: http://img.shields.io/badge/works%20with%20Blizzy's%20Toolbar-1.7.x-7c69c0.svg
[shield:support-alcor]: http://img.shields.io/badge/works%20with%20ALCOR-0.9-299bc7.svg
Expand Down Expand Up @@ -961,7 +985,9 @@ sneaky then they can of course be sneaky.

[toolbar:release]: http://forum.kerbalspaceprogram.com/threads/60863

[rpm:release]: http://forum.kerbalspaceprogram.com/threads/117471
[rpm:release]: https://github.com/FirstPersonKSP/RasterPropMonitor/releases

[ksptl:release]: https://github.com/Phantomical/KSPTextureLoader/releases

[cconfig:release]: http://forum.kerbalspaceprogram.com/threads/101604

Expand Down
60 changes: 55 additions & 5 deletions SCANmechjeb/SCANmechjeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
using System.Collections;
using SCANsat;
using SCANsat.SCAN_Data;
using log = SCANsat.SCAN_Platform.Logging.ConsoleLogger;
using palette = SCANsat.SCAN_UI.UI_Framework.SCANcolorUtil;
using Log = KSPCommunityLib.Logging.Log;
using MuMech;

using UnityEngine;
using UnityEngine.Events;
using System.Reflection;

namespace SCANmechjeb
{
Expand All @@ -36,6 +36,55 @@ class SCANmechjeb : MonoBehaviour
private Vector2d coords = new Vector2d();
private bool shutdown, mjOnboard, mjTechTreeLocked;

// Store references to required fields - type name changes between Target / Hidden and target / hidden across MechJeb versions
private static FieldInfo targetField;
private static FieldInfo hiddenField;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because these are only set in the static constructor you can mark them as readonly. In general it's good practice to do so.


/// <summary>
/// Reflectively fetches MechJebCore fields, tolerating the
/// 'Target'/'target' field rename across MechJeb versions. Returns null
/// (and logs) if the field can't be resolved under any known name.
/// </summary>
static SCANmechjeb()
{
var t = new MechJebCore().GetType();
targetField = t.GetField("Target") ?? t.GetField("target");
if (targetField == null)
{
Log.Message("MechJebCore 'target' field could not be found under any known name; MechJeb support broken.");
}

hiddenField = t.GetField("Hidden") ?? t.GetField("hidden");
if (hiddenField == null)
{
Log.Message("MechJebGuidanceModule 'hidden' field could not be found under any known name; MechJeb support broken.");
}
}

#region Helpers

/// <summary>
/// Reflectively fetches MechJebCore's target controller, tolerating the
/// 'Target'/'target' field rename across MechJeb versions. Returns null
/// (and logs) if the field can't be resolved under any known name.
/// </summary>
private static MechJebModuleTargetController GetMJCoreTarget(MechJebCore mjc)
{
return targetField?.GetValue(mjc) as MechJebModuleTargetController;
}

/// <summary>
/// Reflectively reads the guidance module's hidden flag, tolerating the
/// 'Hidden'/'hidden' field rename across MechJeb versions. Returns null
/// (and logs) if the field can't be resolved under any known name.
/// </summary>
private static bool? IsMJGuidanceModuleHidden(DisplayModule gm)
{
return hiddenField?.GetValue(gm) as bool?;
}

#endregion

private void Start()
{
GameEvents.onVesselWasModified.Add(VesselChange);
Expand Down Expand Up @@ -227,7 +276,7 @@ private void RefereshAfterVesselChange()
return;
}

target = mjCore.target;
target = GetMJCoreTarget(mjCore);

if (target == null)
{
Expand Down Expand Up @@ -256,7 +305,8 @@ private void RefereshAfterVesselChange()

guidanceModule.UnlockCheck();

if (guidanceModule.hidden)
var hidden = IsMJGuidanceModuleHidden(guidanceModule);
if (hidden ?? true) // Defaults to a hidden state if the field cannot be found
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
Expand All @@ -270,4 +320,4 @@ private void RefereshAfterVesselChange()
mjTechTreeLocked = false;
}
}
}
}
19 changes: 9 additions & 10 deletions SCANmechjeb/SCANmechjeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
<OutputType>Library</OutputType>
<RootNamespace>SCANmechjeb</RootNamespace>
<AssemblyName>SCANmechjeb</AssemblyName>
<TargetFramework>net4.8</TargetFramework>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GenerateKSPAssemblyAttribute>true</GenerateKSPAssemblyAttribute>
<GenerateKSPAssemblyDependencyAttributes>true</GenerateKSPAssemblyDependencyAttributes>
<KSPBT_GenerateAssemblyAttribute>true</KSPBT_GenerateAssemblyAttribute>
<KSPBT_GenerateDependencyAttributes>true</KSPBT_GenerateDependencyAttributes>
</PropertyGroup>
<ItemGroup>
<Reference Include="MechJeb2">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(KSPRoot)\GameData\MechJeb2\Plugins\MechJeb2.dll</HintPath>
<Private>False</Private>
<ModReference Include="MechJeb2">
<DLLPath>GameData/MechJeb2/Plugins/MechJeb2.dll</DLLPath>
<CKANIdentifier>MechJeb2</CKANIdentifier>
<KSPAssemblyVersion>2.5</KSPAssemblyVersion>
</Reference>
<KSPAssemblyVersion>2.5</KSPAssemblyVersion>
</ModReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="KSPBuildTools" Version="0.0.4" />
<PackageReference Include="KSPBuildTools" Version="1.1.1" />
<PackageReference Include="KSPCommunityLib" Version="0.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SCANsat\SCANsat.csproj" />
Expand Down
Loading
Loading