diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..c2d5a8812a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,20 @@ +name: build + +on: + push: + branches: [ "develop" ] + paths: + - '**/*.cs' + - '**/*.csproj' + pull_request: + paths: + - '**/*.cs' + - '**/*.csproj' + workflow_dispatch: + workflow_call: + +jobs: + build: + uses: KSPModdingLibs/KSPBuildTools/.github/workflows/build.yml@main + with: + artifacts: Resources/GameData LICENSE* README* CHANGELOG* diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml new file mode 100644 index 0000000000..5e024f4f47 --- /dev/null +++ b/.github/workflows/create-release.yml @@ -0,0 +1,15 @@ +name: create-release + +on: + workflow_dispatch: + inputs: + version-string: + type: string + required: true + +jobs: + create-release: + uses: KSPModdingLibs/KSPBuildTools/.github/workflows/create-release.yml@main + with: + version-string: ${{ inputs.version-string }} + artifacts: Resources/GameData LICENSE* README* CHANGELOG* diff --git a/CHANGELOG.md b/CHANGELOG.md index c318be8795..e25c5355d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,37 @@ -kOS Mod Changelog -================= +# kOS Mod Changelog -# v1.4.0.0 - Catch-up for over a year of little things +## Unreleased + +### NEW FEATURES + +- New crewmember suffixes [commit](https://github.com/KSP-KOS/KOS/commit/8b6246d328f376f431df11f32edadde3d4db7035) +- Added `COM` suffix to parts to get the accurate center of mass (thanks SofieBrink) [commit](https://github.com/KSP-KOS/KOS/commit/496bf3fe7e29b4b8917ec214a6d9d8ab3780cd46) +- 3rd party addons can now add custom suffixes to PartModules [commit](https://github.com/KSP-KOS/KOS/commit/9b83c9ee01e0fb0ce2699f42ff71028d4db71b36) +- Integrated KSPBuildTools for easier local setup and automated build process [commit](https://github.com/KSP-KOS/KOS/commit/7bde357c9d23c60f95f1d64b0490724a4b1544a4) +- Wheelsteering fixes and improvements (thanks @sug44) [commit](https://github.com/KSP-KOS/KOS/commit/cb3eb98a1cddfcf5255b61200338590c7c92dfaa) + +### PERFORMANCE IMPROVEMENTS + +- KOSNameTag modules no longer update during flight [commit](https://github.com/KSP-KOS/KOS/commit/6e9388fdedefc9f4b1287817036b6d4bbe5243df) +- Prevent KOSVesselModule from updating for unloaded vessels [commit](https://github.com/KSP-KOS/KOS/commit/fb88b460117fc4f048c9fb3b451cb8c2862e2316) + +### BUG FIXES + +- Documentation: renamed `gui` to `my_gui` to avoid conflict with global [commit](https://github.com/KSP-KOS/KOS/commit/bc2d2aad469d939b549e73a54b2f6d2f2741f376) +- Fixed an issue where probe cores in RP-1 would get incorrect cost and mass [commit 1](https://github.com/KSP-KOS/KOS/commit/96baa4836bf16ab1bf1b67524c497ea7e0b8db87) [commit 2](https://github.com/KSP-KOS/KOS/commit/142a68c0ef511cacafaf9badc083ee735066cc56) +- Quicksaveto no longer checks ClearToSave [commit](https://github.com/KSP-KOS/KOS/commit/3a24b86d9f50bc85e2aedfc1bc699dd9905e5b0b) +- Several memory leak fixes + - [when vessel is destroyed](https://github.com/KSP-KOS/KOS/commit/eb55ed8fb69fe58ba1c367d0403046406f4589eb) + - [function call results](https://github.com/KSP-KOS/KOS/commit/4aec51d6211ecb8f590fe8e8e169ddff47abf061) + - [maneuver nodes and vessels](https://github.com/KSP-KOS/KOS/commit/f66b51a04290b663f26c95d430cc0a47387eaa48) + - [commnet connectivity](https://github.com/KSP-KOS/KOS/commit/d77de08e9aa07de03954cba2c7575d3caac28af3) + - [managedwindow](https://github.com/KSP-KOS/KOS/commit/41a0a0665af6f2e6f55cc19a899f15b3cccfab09) + - [static part caches](https://github.com/KSP-KOS/KOS/commit/ba4098a08ca015bd72d66e2f3539ed3486c0596d) +- Invoke UI field change callbacks when settings fields (thanks ricmatsui) [commit](https://github.com/KSP-KOS/KOS/commit/09864894469119004eb8c9a2eca7ca91ae058a32) +- `stage:number` suffix now works correctly on non-active vessels (thanks @sug44) [commit](https://github.com/KSP-KOS/KOS/commit/c1af606dd7950bc9e37dfe8c591f379598cb6870) +- Several functions that return a strongly typed ListValue now return the kos-friendly ListValue (thanks @sug44) [commit](https://github.com/KSP-KOS/KOS/commit/b9aad87ab00036a0cd8dcdc632690709fc85157e) + +## v1.4.0.0 - Catch-up for over a year of little things It's been 3 years since the last kOS release, and a lot of small changes have trickled in. None were big enough on @@ -37,10 +67,8 @@ but CKAN didn't know that. Now it should know that.) - kOS parts are now findable by typing "kos" into the VAB's part search bar. [pull request](https://github.com/KSP-KOS/KOS/pull/2980) - - kOS parts can be placed inside the KSP cargo inventory system. [pull request](https://github.com/KSP-KOS/KOS/pull/2916) - - Comma-separated list of LOCAL or SET declarations can now be parsed. Example: @@ -68,23 +96,19 @@ but CKAN didn't know that. Now it should know that.) would be prudent before entering a critical section of code. [pull request](https://github.com/KSP-KOS/KOS/pull/2890) - - Better integration with RP-1's avionics tech progression. (No longer have to buy into the tech from the R&D building to cause the kOS cores in avionics parts to get the upgrade.) [pull request](https://github.com/KSP-KOS/KOS/pull/2955) - - Better integration with RP-1's avionics lockouts when the avionics doesn't support the mass. (Previously kOS couldn't use ANY of the controls when avionics were insufficient, even ones RP-1 meant to still work with insuficient avionics, like RCS fore and aft.) [pull request](https://github.com/KSP-KOS/KOS/pull/2971) - - kOS parts are now findable by typing "kos" into the VAB's part search bar. [pull request](https://github.com/KSP-KOS/KOS/pull/2980) - - Can now read a binary file as a LIST of numeric values (one per byte). [pull request](https://github.com/KSP-KOS/KOS/pull/2986) @@ -99,37 +123,30 @@ but CKAN didn't know that. Now it should know that.) [pull request](https://github.com/KSP-KOS/KOS/pull/2962) [pull request](https://github.com/KSP-KOS/KOS/pull/2967) [pull request](https://github.com/KSP-KOS/KOS/pull/3070) - - A change to make it backward compatible with a call kOSPropMonitor was doing. [pull request](https://github.com/KSP-KOS/KOS/pull/2865) - - Cause the mod RocketSoundEnhancement to stop muffling kOS's sounds. (By explicitly telling Unity those sounds don't emit from the kOS Part's "location" and instead are ambient.) [pull request](https://github.com/KSP-KOS/KOS/pull/2866) - - Make PART:DECOUPLER behave more consistently with what the documentation says about docking ports. [pull request](https://github.com/KSP-KOS/KOS/pull/2864) - - Reduce excessive repeats of GUI ONCONFIRM calls being triggered when they werent' supposed to be triggered. [pull request](https://github.com/KSP-KOS/KOS/pull/2872) - - Remove legacy old version of kOS's computer from the parts definition file so it can't appear by accident in the parts bin. This is no longer needed for backward compatibility like it was before because this version of kOS cannot run on the very old versions of KSP that part was for anyway. [pull request](https://github.com/KSP-KOS/KOS/pull/2893) - - When reporting the terrainheight of a geoposition, it no longer returns false results caused by seeing certain stock parts that put trigger colliders on the "terrain layer". [pull request](https://github.com/KSP-KOS/KOS/pull/2900) - - Fix SteeringManager believing RCS blocks were capable of more thrust than they were (causing steering to be tuned wrong when steering via RCS). Problem was caused when stock @@ -139,68 +156,54 @@ but CKAN didn't know that. Now it should know that.) exist in any given variant. [pull request](https://github.com/KSP-KOS/KOS/pull/2923) [pull request](https://github.com/KSP-KOS/KOS/pull/2974) - - When setting the volume name for a disk drive by copying the vessel's name to the volume's name, it now strips out characters that are not allowed in volume names (but are in vessel names, thus the bug). [pull request](https://github.com/KSP-KOS/KOS/pull/2944) - - BOUNDS now does a better job of calculating based on part's *colliders* rather than their visual meshes which don't always agree with the colliders. [pull request](https://github.com/KSP-KOS/KOS/pull/2945) - - No longer bogs down as much when someone creates the same LOCK expression repeatedly in a loop. (Still not a good idea, but kOS tolerates it better now.) [pull request](https://github.com/KSP-KOS/KOS/pull/2965) - - Performance: No longer pays the cost of tracking a stopwatch when the user doesn't even have profiling turned on so they're not looking at the timings anyway. [pull request](https://github.com/KSP-KOS/KOS/pull/2969) - - A VOICE's volume is now persisting properly after playing a NOTE. Previously playing the NOTE caused the VOICE volume setting to get clobbered by the NOTE's volume. [pull request](https://github.com/KSP-KOS/KOS/pull/2978) - - Make it so kOS's ModuleCargoPart settings don't break in older KSP 1.10.x (which doesn't have ModuleCargoPart). [pull request](https://github.com/KSP-KOS/KOS/pull/3003) - - Fix a bug when a thing that is locked is used as the left side of a suffix when setting the suffix. [pull request](https://github.com/KSP-KOS/KOS/pull/3010) - - Prevent a local variable from clobbering a builtin name [pull request](https://github.com/KSP-KOS/KOS/pull/3016) - - Allow kOS code to "see" a change to a manuever node's ETA made outside the script, after having obtained the node in a variable. [pull request](https://github.com/KSP-KOS/KOS/pull/3040) - - Fix Compiler exceptions not showing the filename correctly. [pull request](https://github.com/KSP-KOS/KOS/issues/3018) - - Fix ALT:RADAR sometimes wrong when high above ground. [pull request](https://github.com/KSP-KOS/KOS/issues/2902) - - Fix race condition that caused terminal to spam the log on scene changes and sometimes spam the log enough to lag the game for some people. [pull request](https://github.com/KSP-KOS/KOS/issues/2925) - - Fix throwing exception when setting SASMODE while the navball is hidden. [pull request](https://github.com/KSP-KOS/KOS/issues/3045) - - Made the doc generation scripts work on python 3.x [pull request](https://github.com/KSP-KOS/KOS/issues/3069) -# v1.3.2.0 - Don't Steer Me wronger +## v1.3.2.0 - Don't Steer Me wronger A quick patch to v1.3.0.0 that fixes issue #2857 that would zero controls for just a brief single physics frame if @@ -216,15 +219,14 @@ ignition.) Normally one bug fix wouldn't warrant a release, but this bug was caused by changes in v1.3.0.0, and the consumed ignition was unfair. - -# v1.3.1.0 - Don't Steer Me Wrong, this time + +## v1.3.1.0 - Don't Steer Me Wrong, this time A quick patch to v1.3.0.0 that fixed issue #2850 where one or two places in the code still used TimeSpan where they were supposed to have been changed to use TimeStamp. - -# v1.3.0.0 - Don't Steer Me Wrong +## v1.3.0.0 - Don't Steer Me Wrong There's a lot of small changes over the last year that have added up to a big release. This release supports KSP 1.10 and KSP 1.11. @@ -529,8 +531,7 @@ was an important KSM bugfix. it says zero instead). [pull request](https://github.com/KSP-KOS/KOS/pull/2646) - -# v1.2.1 Pathsep fix +## v1.2.1 Pathsep fix v1.2'S DDS fix had a backslash path separator that broke it on UNIX platoforms. This quick fix does nothing more than switch it to a @@ -541,8 +542,7 @@ but not do a similar mapping to make UNIX work with the "wrong" separator, so UNIX separators are the only cross-platform path separator to use.) - -# v1.2 Unity Update +## v1.2 Unity Update This update is mostly to make kOS compatible with KSP 1.8.x, which started using a newer version of Unity, and a newer version of .Net, @@ -607,7 +607,6 @@ KSM files need a recompile after every version update of kOS. [issue](https://github.com/KSP-KOS/KOS/issues/2565) [pull request](https://github.com/KSP-KOS/KOS/pull/2630) - ### BUG FIXES * Bound variables like SHIP, UP, VELOCITY, etc stopped existing @@ -642,7 +641,7 @@ KSM files need a recompile after every version update of kOS. ((No issue - SlimJimDodger contributed PR out of the blue.)) [pull request](https://github.com/KSP-KOS/KOS/pull/2637) -# v1.1.9.0 Breaking Bounds +## v1.1.9.0 Breaking Bounds This update is a mix of new features, mostly @@ -712,7 +711,7 @@ This update is a mix of new features, mostly focus rules for widgets, thus they won't 'steal focus' as much. [pull request](https://github.com/KSP-KOS/KOS/pull/2577). -# v1.1.8.0 Engines and KSP 1.7 compatibility +## v1.1.8.0 Engines and KSP 1.7 compatibility Mostly this was motivated by a need to get an officially recompiled-for-KSP-1.7 version out there (even though the previous @@ -808,8 +807,7 @@ cleanups. addition to claiming to be a ModuleDeployableSolarPanel. [pull request](https://github.com/KSP-KOS/KOS/pull/2504) - -# v1.1.7.0 Lets get Serial +## v1.1.7.0 Lets get Serial Mostly fixes. The motivation for this release is to get fixes out to the public before KSP 1.7 comes. @@ -886,7 +884,7 @@ Built for KSP 1.6.1 Remote Tech dialog box. [pull request](https://github.com/KSP-KOS/KOS/pull/2480) -# v1.1.6.3 Folder Path Protection +## v1.1.6.3 Folder Path Protection Built for KSP 1.6.1 @@ -901,8 +899,7 @@ set up one in the future, PLEASE see this writup: https://github.com/KSP-KOS/KOS/issues/2439 - -# v1.1.6.2 Quickfix (Image Files to DDS) +## v1.1.6.2 Quickfix (Image Files to DDS) Built for KSP 1.6.1 @@ -922,7 +919,7 @@ DDS ourselves and shipping them that way, we bypass this problem because the user's own graphics drivers aren't responsible for doing the conversion. -# v1.1.6.1 Quickfix (MAXTHRUST air pressure) +## v1.1.6.1 Quickfix (MAXTHRUST air pressure) Built for KSP 1.6.1 @@ -936,7 +933,7 @@ as if your ship was in vacuum even when it's not. This was deemed an important enough problem to warrant a quick-fix release. -# v1.1.6.0 It's been too long without a release. +## v1.1.6.0 It's been too long without a release. Built for KSP 1.6.1 @@ -1048,7 +1045,6 @@ something.) - Fix: OrbitInfo:TOSTRING now prints the body name properly. [pull request](https://github.com/KSP-KOS/KOS/pull/2408) - ### NEW FEATURES: - Made several of the string parameters to GUI widgets optional. @@ -1088,8 +1084,7 @@ something.) form a smaller download ZIP). [pull request](https://github.com/KSP-KOS/KOS/pull/2389) - -# v1.1.5.2 Basic Compatibilty for KSP 1.4.1 +## v1.1.5.2 Basic Compatibilty for KSP 1.4.1 Built for KSP 1.4.1 @@ -1104,8 +1099,7 @@ implemented when when KSP 1.4.1 came out. (Thanks to firda-cze for finding and fixing the problem.) [pull request](https://github.com/KSP-KOS/KOS/pull/2238) - -# v1.1.5.0 HotFix for nested function scope. +## v1.1.5.0 HotFix for nested function scope. Built for KSP v1.3.1 @@ -1142,7 +1136,7 @@ already for v1.1.4.0. move had happened.) It is fixed now. [pull request](https://github.com/KSP-KOS/KOS/pull/2205) -# v1.1.4.0 Does faster compilation break a work flow? +## v1.1.4.0 Does faster compilation break a work flow? Built for KSP v1.3.1 @@ -1253,7 +1247,7 @@ for the kOS computer parts themselves (slow at first, faster later). - Documentation was added for `part:hasmodule` suffix. [pull request](https://github.com/KSP-KOS/KOS/pull/2202) -# v1.1.3.2 (for KSP 1.3.1) New KSP version HOTFIX +## v1.1.3.2 (for KSP 1.3.1) New KSP version HOTFIX This version is functionally identical to v1.1.3.0, however the binaries are compiled against KSP 1.3.1 to allow it to properly load with the updated version @@ -1271,7 +1265,7 @@ of KSP (None) -# v1.1.3.1 (for KSP 1.2.2) Backward compatibility version of v1.1.3.0 +## v1.1.3.1 (for KSP 1.2.2) Backward compatibility version of v1.1.3.0 ### Only use if you are stuck on KSP 1.2.2. @@ -1284,7 +1278,7 @@ was removed, and it was re-compiled against KSP 1.2.2 libraries. (The incentive to make such a release available was mostly because Realism Overhaul typically stays a version behind for quite a while). -# v1.1.3.0 (for KSP 1.3) Bug Swatting Release +## v1.1.3.0 (for KSP 1.3) Bug Swatting Release For this release we instituted a rule partway through that only bug fixes should be allowed (some of the first few changes were enhancements rather @@ -1296,6 +1290,7 @@ hope that doing so would get a release out faster than normal. (Can't think of any.) ### NEW FEATURES + * Terminal input using any Unicode character, not just ASCII. (Technically not a new feature, but a bug fix to a feature from the previous version, but since the bug made the feature @@ -1305,6 +1300,7 @@ hope that doing so would get a release out faster than normal. [pull request](https://github.com/KSP-KOS/KOS/pull/2077) ### BUG FIXES + * A large refactor of how the various flight control methods track which vessel they control. This appears to have fixed a lot of bugs where kOS lost the ability to control the ship unless @@ -1366,14 +1362,14 @@ hope that doing so would get a release out faster than normal. exist a kOS part loaded into the scene. [pull request](https://github.com/KSP-KOS/KOS/pull/2058) -# v1.1.2 (for KSP 1.3) No change - just fixing version. +## v1.1.2 (for KSP 1.3) No change - just fixing version. There was a version number problem in our CKAN files that required us to issue an update and doing so required a version number increase. There is no other change in this version. -# v1.1.1 (for KSP 1.3) KSP 1.3 compatibility recompile. +## v1.1.1 (for KSP 1.3) KSP 1.3 compatibility recompile. No known intentional changes other than editing a few method calls to the KSP API to make it work with KSP 1.3. @@ -1381,10 +1377,10 @@ to the KSP API to make it work with KSP 1.3. Also updated the included ModuleManager to version 2.8, which is a necessity for compatibility with KSP 1.3. - -# v1.1.0 (for KSP 1.2.2) Ewww, everything's GUI. +## v1.1.0 (for KSP 1.2.2) Ewww, everything's GUI. ### BREAKING CHANGES + * Because of changes to make the terminal use a real font from your OS, we had to obsolete TERMINAL:CHARWIDTH. You can only choose TERMINAL:CHARHEIGHT. Each font has its own hardcoded notion of how wide a letter will be at a @@ -1397,6 +1393,7 @@ is a necessity for compatibility with KSP 1.3. Now it's in atmospheres to agree with the documentation.) ### NEW FEATURES + * **GUI-making toolkit**. You are now able to make a GUI window that your kerboscript code can control, including buttons, sliders, toggles, checkboxes, etc. It uses the KSP game's default skin (kind of big letters) but the skin can be customized by the @@ -1437,6 +1434,7 @@ is a necessity for compatibility with KSP 1.3. [pull request](https://github.com/KSP-KOS/KOS/pull/2001), documentation: search for "GEOPOSITIONLATLNG" (http://ksp-kos.github.io/KOS_DOC/structures/celestial_bodies/body.html#method:BODY:GEOPOSITIONLATLNG). ### BUG FIXES + * Fix kOS toolbar button sometimes failing to appear in Blizzy Toolbar Mod. [pull request](https://github.com/KSP-KOS/KOS/pull/1902) * Fix SKID Chip emulator's sync lag when physics is slow. @@ -1477,7 +1475,7 @@ is a necessity for compatibility with KSP 1.3. or two vessels join together, or a vessel blows up. [pull request](https://github.com/KSP-KOS/KOS/pull/2010) -# v1.0.3 (for KSP 1.2.2) Make a little noise! (Part Deux) +## v1.0.3 (for KSP 1.2.2) Make a little noise! (Part Deux) This release is nearly identical to v1.0.2, except that it was compiled against binaries from KSP v1.2.2 (released just before we published) and the version numbers @@ -1485,9 +1483,10 @@ have been advanced. While it appears that kOS v1.0.2 is compatible with KSP v1. we wanted to err on the side of caution and provide an explicitly compatible release. Please review the changelog for v1.0.2 if you are upgrading from an earlier version. -# v1.0.2 (for KSP 1.2.1) Make a little noise! +## v1.0.2 (for KSP 1.2.1) Make a little noise! ### BREAKING CHANGES + * As always, if you use the compiler feature to make KSM files, you should recompile the KSM files when using a new release of kOS or results will be unpredictable. @@ -1506,6 +1505,7 @@ Please review the changelog for v1.0.2 if you are upgrading from an earlier vers UI, but the UI mechanic was updated with KSP 1.2.x ### NEW FEATURES + * Official release for KSP version 1.2.1! * kOS now has a procedural sound system! You can use it to play customized error tones or make your own musical notes. @@ -1529,6 +1529,7 @@ Please review the changelog for v1.0.2 if you are upgrading from an earlier vers [pull request](https://github.com/KSP-KOS/KOS/pull/1858) ### BUG FIXES + * Fix for throwing errors when another mod uses dynamic assembly [pull request](https://github.com/KSP-KOS/KOS/pull/1851) * Update Blizzy toolbar wrapper to the most recent version @@ -1551,7 +1552,7 @@ Please review the changelog for v1.0.2 if you are upgrading from an earlier vers unlock functions too [pull request](https://github.com/KSP-KOS/KOS/pull/1889) -# v1.0.1 (for KSP 1.1.3) Let's take some input! +## v1.0.1 (for KSP 1.1.3) Let's take some input! ## Why 1.1.3 and not 1.2? @@ -1564,7 +1565,7 @@ possible have access to these latest updates. We will be releasing a version of kOS that is compatible with KSP 1.2 as soon as possible after the final build is released to the public. -### BREAKING CHANGES +### Breaking Changes * As always, if you use the compiler feature to make KSM files, you should recompile the KSM files when using a new release of kOS or results will @@ -1572,73 +1573,6 @@ released to the public. * The `stage` command/function now implements the yield behavior, waiting until the next physics tick to return. This ensures that all vessel stats are updated together. (https://github.com/KSP-KOS/KOS/pull/1807) - -### NEW FEATURES - -* Functions and opcodes can now tell the CPU to yield (wait) based on their own - arbitrary logic. This allows future functions to be "blocking" (preventing - further execution) without blocking KSP itself. - (https://github.com/KSP-KOS/KOS/issues/1805, - https://github.com/KSP-KOS/KOS/pull/1807, and - https://github.com/KSP-KOS/KOS/pull/1820) -* New `timewarp` structure, available on the `kuniverse` bound variable. This - structure provides additional information and control over time warp. The old - warp bound variables remain in place. - (https://github.com/KSP-KOS/KOS/issues/1790 and - https://github.com/KSP-KOS/KOS/pull/1820) -* Introducing a new `terminalinput` structure for keyboard interaction from - within scripts! Currently support is only provided for getting single - characters. - (https://github.com/KSP-KOS/KOS/pull/1830) - -Please check http://ksp-kos.github.io/KOS_DOC/changes.html for more detailed -explanations for the new features. - -### BUG FIXES - -* Fix for formatting of `time:clock` to pad zeros - (https://github.com/KSP-KOS/KOS/issues/1771 and - https://github.com/KSP-KOS/KOS/pull/1772) -* Fix for not being able to construct a `vessel("foo")` if "foo" is the name of - the current vessel (https://github.com/KSP-KOS/KOS/issues/1565 and - https://github.com/KSP-KOS/KOS/pull/1802) -* RemoteTech steering should be fixed. At worst you may see a 1sec gap with - the controls, as we now refresh the steering callback about once per second. - (https://github.com/KSP-KOS/KOS/issues/1806 and - https://github.com/KSP-KOS/KOS/pull/1809) -* Named functions defined within anonymous functions will no longer throw an - error (https://github.com/KSP-KOS/KOS/issues/1801 and - https://github.com/KSP-KOS/KOS/pull/1811) -* `lock steering` no longer throws an exception inside of an anonymous functions - (https://github.com/KSP-KOS/KOS/issues/1784 and - https://github.com/KSP-KOS/KOS/pull/1811) -* Compiled programs that include a large number of named functions should no - longer throw an error (https://github.com/KSP-KOS/KOS/issues/1796 and - https://github.com/KSP-KOS/KOS/pull/1812) -* Fixed the first call to `wait` after the cpu boots - (https://github.com/KSP-KOS/KOS/issues/1785) -* Various documentation fixes (https://github.com/KSP-KOS/KOS/pull/1810, - https://github.com/KSP-KOS/KOS/pull/1823, and - https://github.com/KSP-KOS/KOS/pull/1834) - - -# v1.0.0 (for KSP 1.1.3) Hey let's stop calling it Beta. - -### About the name: - -kOS has been around long enough that we figured it was long overdue -for us to stop calling it 0.something. Lots of people are using it, -and we're worried about backward compatibility enough that we're not -really treating it like a Beta anymore. This version contains mostly -a few things that we knew might break backward compatibility so we'd -been putting them off for a long time. A jump to 1.0 seems a good time -to add those changes. - -Of course, it has lots of other changes for whatever else was being -worked on since the last release. - -### BREAKING CHANGES - * As always, if you use the compiler feature to make KSM files, you should recompile the KSM files when using a new release of kOS or results will be unpredictable. @@ -1658,8 +1592,36 @@ worked on since the last release. however scripts might exist that had previously been swapping them back to compensate for this, and if there were they would now break since that swapping is no longer needed. +* `STEERINGMANAGER:SHOWRCSVECTORS` and `STEERINGMANAGER:SHOWENGINEVECTORS` are now obsolete and will throw an error. +* Triggers may now go beyond the limits of the IPU (https://github.com/KSP-KOS/KOS/pull/1542) but are no longer guaranteed to execute within a single update frame. See http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#triggers and http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#cpu-update-loop for more details. +* As usual, you must recompile any KSM files when using the new version. +* Vecdraw :SCALE no longer applied to :START. Only applied to :VEC. +* Varying power consumption might make it so if you have high IPU settings some designs might run out of power when they didn't before. (in most cases it should draw less power for most people). +* !!!! Default extension of ".ks" is no longer applied to all new filenames created. But it still will be looked for when reading existing files if you leave the extension off !!!! +* FileInfo information now moved to Volume (http://ksp-kos.github.io/KOS_DOC/structures/volumes_and_files/volume.html). +* VOLUME:FILES was returning a LIST(), now it returns a LEXICON who's keys are the filename. +* String sort-order comparisons with "<" and ">" operators were implemented wrongly and just compared lengths. Now they do a character-by-character comparison (case-insensitively). On the off chance that anyone was actually trying to use the previous weird length-comparison behavior, that would break. -### NEW FEATURES +### New Features + +* Functions and opcodes can now tell the CPU to yield (wait) based on their own + arbitrary logic. This allows future functions to be "blocking" (preventing + further execution) without blocking KSP itself. + (https://github.com/KSP-KOS/KOS/issues/1805, + https://github.com/KSP-KOS/KOS/pull/1807, and + https://github.com/KSP-KOS/KOS/pull/1820) +* New `timewarp` structure, available on the `kuniverse` bound variable. This + structure provides additional information and control over time warp. The old + warp bound variables remain in place. + (https://github.com/KSP-KOS/KOS/issues/1790 and + https://github.com/KSP-KOS/KOS/pull/1820) +* Introducing a new `terminalinput` structure for keyboard interaction from + within scripts! Currently support is only provided for getting single + characters. + (https://github.com/KSP-KOS/KOS/pull/1830) + +Please check http://ksp-kos.github.io/KOS_DOC/changes.html for more detailed +explanations for the new features. * **Subdirectories:** (http://hvacengi.github.io/KOS/commands/files.html) You are now able to store subdirectories ("folders") in your volumes, @@ -1755,8 +1717,77 @@ worked on since the last release. A collection intended for when all you care about is whether a equivalent object exists or doesn't exist yet in the collection, and everything else (order, etc) doesn't matter. +* KSP 1.1 now allows you to lock the gimbals for the three pitch/yaw/roll axes individually on engines, as 3 different settings, rather than just lock the whole gimbal for all directions. kOS now lets you access this ability (https://github.com/KSP-KOS/KOS/pull/1622). -### BUG FIXES +## v0.20.0 KSP 1.1 Hype! + +This release is functionally identical to v0.19.3, it is recompiled against the +KSP 1.1 release binaries (build 1230) + +* Profiling output via `ProfileResult()` (https://github.com/KSP-KOS/KOS/pull/1534) +* New alias KUNIVERSE:FORCEACTIVE() can be used instead of the longer name KUNIVERSE:FORCESETACTIVEVESSEL(). +* More robust use of the font_sml.png file allows for replacement of font_sml.png by the end-user. + (However this may only be useful for a limited time, as Unity5 might make us implement the font differently + anyway.) +* PIDLoop tutorial section in the docs edited to mention new PIDLoop() + function that did not exist back when that page was first written. + (http://ksp-kos.github.io/KOS_DOC/tutorials/pidloops.html) +* New Terminal GUI doodads and widgets: A brightness slider, + and the ability to zoom the character width and height. Also + made the transparency and dimming of the 'non-active' terminals + a bit less severe so you can still read them when un-focused. + Also, these new features can be script controlled by new + suffixes, however it is unclear if that feature (doing it from + a script) will remain in the future so use it with care: + (http://ksp-kos.github.io/KOS_DOC/structures/misc/terminal.html) +* Art asset rework. The meshes and textures of the kOS CPU parts have recieved an update, and a new KAL9000 high-end computer part was included. +* Varying power consumption. Units of electric charge used now varies depending on CPU speed and how much the CPU is being actually used. If your IPU setting is low, or if your program isn't doing very much and is just stuck on a `wait` statement, it won't use as much power. (http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware#electricdrain) +* Ability to read and write whole files at a time as one big string. (http://ksp-kos.github.io/KOS_DOC/structures/volumes_and_files/volumefile.html) +* User Functions can now be referred to with function pointers, or "delegates". (http://ksp-kos.github.io/KOS_DOC/language/delegates.html) +* Automatic serialization system to save/load some kinds of data values to JSON-format files (http://ksp-kos.github.io/KOS_DOC/commands/files.html#writejson-object-filename) +* User Programs and Functions now allow trailing optional parameters with defaulted values. (http://ksp-kos.github.io/KOS_DOC/language/user_functions.html#optional-parameters-parameter-defaults). +* There are now some suffixes that work on all value types, even primitive scalars. To accomplish this, a new "encapsulation" system has wrapped all kOS structures and primitive types inside a generic base type. (http://ksp-kos.github.io/KOS_DOC/structures/reflection.html) +* ENGINE type now supports multi-mode cases and has its gimbal accessible through :GIMBAL suffix (http://ksp-kos.github.io/KOS_DOC/structures/vessels/engine.html) +* Added GIMBAL:LIMIT suffix. (http://ksp-kos.github.io/KOS_DOC/structures/vessels/gimbal.html) +* Better support for DMagic's Orbital Science mod (http://ksp-kos.github.io/KOS_DOC/addons/OrbitalScience.html) +* Char() and Unchar() functions for translating unicode numbers to characters and visa versa (http://ksp-kos.github.io/KOS_DOC/math/basic.html#function:CHAR) +* New Range type for iterating over hardcoded lists (http://ksp-kos.github.io/KOS_DOC/structures/collections/range.html). +* Ability to iterate over the characters in a string using a FOR loop, as if the string was a LIST() of chars. +* New higher level cpu part. (https://github.com/KSP-KOS/KOS/pull/1380) +* HASTARGET and HASNODE functions (http://ksp-kos.github.io/KOS_DOC/bindings.html?highlight=hastarget) +* :JOIN suffix for LIST to make a string of the elements (http://ksp-kos.github.io/KOS_DOC/structures/collections/list.html#method:LIST:JOIN) +* KUNIVERSE now lets you read hours per day setting (http://ksp-kos.github.io/KOS_DOC/structures/misc/kuniverse.html#attribute:KUNIVERSE:HOURSPERDAY) +* The reserved word ARCHIVE is now a first-class citizen with proper binding, so you can do SET FOO TO ARCHIVE and it will work like you'd expect. +* New Lexicon creation syntax to make a Lexicon and populate it all in one statement. (http://ksp-kos.github.io/KOS_DOC/structures/collections/lexicon.html?highlight=lexicon#constructing-a-lexicon) + +### Bug Fixes + +* Fix for formatting of `time:clock` to pad zeros + (https://github.com/KSP-KOS/KOS/issues/1771 and + https://github.com/KSP-KOS/KOS/pull/1772) +* Fix for not being able to construct a `vessel("foo")` if "foo" is the name of + the current vessel (https://github.com/KSP-KOS/KOS/issues/1565 and + https://github.com/KSP-KOS/KOS/pull/1802) +* RemoteTech steering should be fixed. At worst you may see a 1sec gap with + the controls, as we now refresh the steering callback about once per second. + (https://github.com/KSP-KOS/KOS/issues/1806 and + https://github.com/KSP-KOS/KOS/pull/1809) +* Named functions defined within anonymous functions will no longer throw an + error (https://github.com/KSP-KOS/KOS/issues/1801 and + https://github.com/KSP-KOS/KOS/pull/1811) +* `lock steering` no longer throws an exception inside of an anonymous functions + (https://github.com/KSP-KOS/KOS/issues/1784 and + https://github.com/KSP-KOS/KOS/pull/1811) +* Compiled programs that include a large number of named functions should no + longer throw an error (https://github.com/KSP-KOS/KOS/issues/1796 and + https://github.com/KSP-KOS/KOS/pull/1812) +* Fixed the first call to `wait` after the cpu boots + (https://github.com/KSP-KOS/KOS/issues/1785) +* Various documentation fixes (https://github.com/KSP-KOS/KOS/pull/1810, + https://github.com/KSP-KOS/KOS/pull/1823, and + https://github.com/KSP-KOS/KOS/pull/1834) + +## v1.0.0 (for KSP 1.1.3) Hey let's stop calling it Beta. * In some cases (https://github.com/KSP-KOS/KOS/issues/1661) the program wouldn't stop immediately when you execute a ``kuniverse`` command that @@ -1788,7 +1819,7 @@ worked on since the last release. documentation claimed they would. (https://github.com/KSP-KOS/KOS/issues/1623) -# v0.20.1 KSP 1.1.2 and bug repair +## v0.20.1 KSP 1.1.2 and bug repair The biggest reason for this release is to handle two game-breaking problems caused by recent alterations in the API that kOS hadn't @@ -1802,41 +1833,20 @@ bug, but it also includes a few other bug fixes not related to KSP 1.1. But any new features (rather than bug fixes) in the pipeline not directly related to that "remit" are not in this release. -### BREAKING CHANGES -* `STEERINGMANAGER:SHOWRCSVECTORS` and `STEERINGMANAGER:SHOWENGINEVECTORS` are now obsolete and will throw an error. - -### BUG FIXES * Infinitely growing mass: Realism Overhaul users could not use kOS anymore, because kOS was re-adding its small module mass to the part again and again each physics tick. Even though the mass of kOS is small, adding it to the part 25 times a second quickly made the vessel grow too massive to do anything with. The bug was not caught earlier because it only happened if kOS was added to parts other than the parts kOS ships with (i.e. by using ModuleManager), and those parts also had other mass-affecting modules on them. Although discovered in Realism Overhaul, the problem could have been affecting any users who used kOS in that same fashion. The cause was traced to an incorrect use of the new mass API by kOS and has been fixed. (https://github.com/KSP-KOS/KOS/pull/1644). * "SET TARGET TO FOO." while the terminal is open was failing. Now it works. (The kOS terminal locks out all other inputs so your keypresses don't affect the ship, but as of KSP 1.1 the "all" input lock it was using to do so also includes the ability to set target, which it didn't before.) (https://github.com/KSP-KOS/KOS/pull/1636) * Incorrect value for MeanAnomalyAtEpoch fixed. It was multiplying the value by the conversion factor for radians-to-degrees twice, rather than just once. (https://github.com/KSP-KOS/KOS/pull/1642) * GeoCoordinates were not serializing properly. Now they are. (https://github.com/KSP-KOS/KOS/pull/1615). * Finally fully obsoleted the years-old suffixes for trying to do antenna range the old way (before we just relied on Remote Tech to do antenna work for us). (https://github.com/KSP-KOS/KOS/pull/1607). * Bug fixes for catching a few more cases where staging or decoupling part of the craft away was still confusing SteeringManager into trying to lock out, or take control of, the wrong half of the craft. (https://github.com/KSP-KOS/KOS/pull/1544). - -### NEW FEATURES -* KSP 1.1 now allows you to lock the gimbals for the three pitch/yaw/roll axes individually on engines, as 3 different settings, rather than just lock the whole gimbal for all directions. kOS now lets you access this ability (https://github.com/KSP-KOS/KOS/pull/1622). - -# v0.20.0 KSP 1.1 Hype! - -This release is functionally identical to v0.19.3, it is recompiled against the -KSP 1.1 release binaries (build 1230) - -### BUG FIXES * [KSP1.1] Removing a node leaves an artifact (https://github.com/KSP-KOS/KOS/issues/1572 https://github.com/KSP-KOS/KOS/issues/1576) * [KSP1.1] Toolbar button doesn't display (https://github.com/KSP-KOS/KOS/issues/1573 https://github.com/KSP-KOS/KOS/issues/1569) -# v0.19.3 Last (intended) 1.0.5 update. +## v0.19.3 Last (intended) 1.0.5 update. (This is the last planned update to work with KSP 1.0.5 unless it breaks something big that requires an emergency patch.) -### BREAKING CHANGES -* Triggers may now go beyond the limits of the IPU (https://github.com/KSP-KOS/KOS/pull/1542) but are no longer guaranteed to execute within a single update frame. See http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#triggers and http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#cpu-update-loop for more details. - -### NEW FEATURES -* Profiling output via `ProfileResult()` (https://github.com/KSP-KOS/KOS/pull/1534) - -### BUG FIXES * Removed delay when enabling/disabling auto changeover for multi mode engines (https://github.com/KSP-KOS/KOS/pull/1451) * Improve performance of various math functions (https://github.com/KSP-KOS/KOS/issues/1553 https://github.com/KSP-KOS/KOS/pull/1523 https://github.com/KSP-KOS/KOS/pull/1563) * `on` logic now evaluates expressions and suffixes, instead of requiring a raw variable (https://github.com/KSP-KOS/KOS/issues/1376 https://github.com/KSP-KOS/KOS/pull/1542) @@ -1844,23 +1854,13 @@ it breaks something big that requires an emergency patch.) * You can now use lock objects with the same identifier from within compiled scripts, like `lock throttle...` (https://github.com/KSP-KOS/KOS/issues/691 https://github.com/KSP-KOS/KOS/issues/1253 https://github.com/KSP-KOS/KOS/issues/1557 https://github.com/KSP-KOS/KOS/pull/1561) * The script parsing logic has been updated to improve compile times by roughly 50% (https://github.com/KSP-KOS/KOS/pull/1566) -# v0.19.2 +## v0.19.2 This release is here primarily to fix a problem that made the new v0.19.1 terminal unusable for users who have to use low resolution texture settings in the Unity graphics configuration panel. -### BREAKING -* Nothing new breaking in this version is known about. - -### NEW FEATURES -* New alias KUNIVERSE:FORCEACTIVE() can be used instead of the longer name KUNIVERSE:FORCESETACTIVEVESSEL(). -* More robust use of the font_sml.png file allows for replacement of font_sml.png by the end-user. - (However this may only be useful for a limited time, as Unity5 might make us implement the font differently - anyway.) - -### BUG FIXES * New terminal now works again at low texture resolution settings (https://github.com/KSP-KOS/KOS/issues/1513). * New terminal shows grey color on power-off again @@ -1873,8 +1873,7 @@ configuration panel. of a proper error message about it from kOS, kOS got stuck in recursion.) - -# v0.19.1 +## v0.19.1 This release is a patch to v0.19.0, fixing some things found by the user community in the two days shortly after @@ -1884,20 +1883,6 @@ It also happens to contain a few terminal window features that were being worked on before v0.19.0 but were not deemed ready yet when 0.19.0 was released. -### NEW FEATURES -* PIDLoop tutorial section in the docs edited to mention new PIDLoop() - function that did not exist back when that page was first written. - (http://ksp-kos.github.io/KOS_DOC/tutorials/pidloops.html) -* New Terminal GUI doodads and widgets: A brightness slider, - and the ability to zoom the character width and height. Also - made the transparency and dimming of the 'non-active' terminals - a bit less severe so you can still read them when un-focused. - Also, these new features can be script controlled by new - suffixes, however it is unclear if that feature (doing it from - a script) will remain in the future so use it with care: - (http://ksp-kos.github.io/KOS_DOC/structures/misc/terminal.html) - -### BUG FIXES * Fixed file rename bug on local hard disks: (https://github.com/KSP-KOS/KOS/issues/1498) * Fixed boot files can be larger than the local disk @@ -1914,39 +1899,8 @@ ready yet when 0.19.0 was released. * Improve steering when small control magnitudes are required. (https://github.com/KSP-KOS/KOS/issues/1512) -# v0.19.0 - -### BREAKING CHANGES -* As usual, you must recompile any KSM files when using the new version. -* Vecdraw :SCALE no longer applied to :START. Only applied to :VEC. -* Varying power consumption might make it so if you have high IPU settings some designs might run out of power when they didn't before. (in most cases it should draw less power for most people). -* !!!! Default extension of ".ks" is no longer applied to all new filenames created. But it still will be looked for when reading existing files if you leave the extension off !!!! -* FileInfo information now moved to Volume (http://ksp-kos.github.io/KOS_DOC/structures/volumes_and_files/volume.html). -* VOLUME:FILES was returning a LIST(), now it returns a LEXICON who's keys are the filename. -* String sort-order comparisons with "<" and ">" operators were implemented wrongly and just compared lengths. Now they do a character-by-character comparison (case-insensitively). On the off chance that anyone was actually trying to use the previous weird length-comparison behavior, that would break. - -### NEW FEATURES -* Art asset rework. The meshes and textures of the kOS CPU parts have recieved an update, and a new KAL9000 high-end computer part was included. -* Varying power consumption. Units of electric charge used now varies depending on CPU speed and how much the CPU is being actually used. If your IPU setting is low, or if your program isn't doing very much and is just stuck on a `wait` statement, it won't use as much power. (http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware#electricdrain) -* Ability to read and write whole files at a time as one big string. (http://ksp-kos.github.io/KOS_DOC/structures/volumes_and_files/volumefile.html) -* User Functions can now be referred to with function pointers, or "delegates". (http://ksp-kos.github.io/KOS_DOC/language/delegates.html) -* Automatic serialization system to save/load some kinds of data values to JSON-format files (http://ksp-kos.github.io/KOS_DOC/commands/files.html#writejson-object-filename) -* User Programs and Functions now allow trailing optional parameters with defaulted values. (http://ksp-kos.github.io/KOS_DOC/language/user_functions.html#optional-parameters-parameter-defaults). -* There are now some suffixes that work on all value types, even primitive scalars. To accomplish this, a new "encapsulation" system has wrapped all kOS structures and primitive types inside a generic base type. (http://ksp-kos.github.io/KOS_DOC/structures/reflection.html) -* ENGINE type now supports multi-mode cases and has its gimbal accessible through :GIMBAL suffix (http://ksp-kos.github.io/KOS_DOC/structures/vessels/engine.html) -* Added GIMBAL:LIMIT suffix. (http://ksp-kos.github.io/KOS_DOC/structures/vessels/gimbal.html) -* Better support for DMagic's Orbital Science mod (http://ksp-kos.github.io/KOS_DOC/addons/OrbitalScience.html) -* Char() and Unchar() functions for translating unicode numbers to characters and visa versa (http://ksp-kos.github.io/KOS_DOC/math/basic.html#function:CHAR) -* New Range type for iterating over hardcoded lists (http://ksp-kos.github.io/KOS_DOC/structures/collections/range.html). -* Ability to iterate over the characters in a string using a FOR loop, as if the string was a LIST() of chars. -* New higher level cpu part. (https://github.com/KSP-KOS/KOS/pull/1380) -* HASTARGET and HASNODE functions (http://ksp-kos.github.io/KOS_DOC/bindings.html?highlight=hastarget) -* :JOIN suffix for LIST to make a string of the elements (http://ksp-kos.github.io/KOS_DOC/structures/collections/list.html#method:LIST:JOIN) -* KUNIVERSE now lets you read hours per day setting (http://ksp-kos.github.io/KOS_DOC/structures/misc/kuniverse.html#attribute:KUNIVERSE:HOURSPERDAY) -* The reserved word ARCHIVE is now a first-class citizen with proper binding, so you can do SET FOO TO ARCHIVE and it will work like you'd expect. -* New Lexicon creation syntax to make a Lexicon and populate it all in one statement. (http://ksp-kos.github.io/KOS_DOC/structures/collections/lexicon.html?highlight=lexicon#constructing-a-lexicon) +## v0.19.0 -### BUG FIXES * Numerous additional checks to prevent control of other vessels the kOS CPU isn't attached to. * The error beep and keyboard click sounds now obey game's UI volume settings. (https://github.com/KSP-KOS/KOS/pull/1287) * Fixed two bugs with obtaining waypoints by name. (https://github.com/KSP-KOS/KOS/issues/1313) (https://github.com/KSP-KOS/KOS/pull/1319) @@ -1965,12 +1919,30 @@ ready yet when 0.19.0 was released. * String sort-order comparisons with "<" and ">" operators were implemented wrongly and just compared lengths. Now they do a character-by-character comparison (case-insensitively) * Small documentation edits and clarifications all over the place. -### KNOWN issues +### About The Name: + +kOS has been around long enough that we figured it was long overdue +for us to stop calling it 0.something. Lots of people are using it, +and we're worried about backward compatibility enough that we're not +really treating it like a Beta anymore. This version contains mostly +a few things that we knew might break backward compatibility so we'd +been putting them off for a long time. A jump to 1.0 seems a good time +to add those changes. + +Of course, it has lots of other changes for whatever else was being +worked on since the last release. + +### Breaking + +* Nothing new breaking in this version is known about. + +### Known Issues + * Using `lock` variables in compiled scripts with a duplicate identifier (like "throttle") throws an error (https://github.com/KSP-KOS/KOS/issues/1347 and https://github.com/KSP-KOS/KOS/issues/1253). * Occasionally staging with a probe core or root part in the ejected stage will break cooked steering (https://github.com/KSP-KOS/KOS/issues/1492). * The limitations of RemoteTech integration can be bypassed by storing a volume in a variable before the ship looses a connection to the KSC (https://github.com/KSP-KOS/KOS/issues/1464). -### CONTRIBUTORS THIS RELEASE +### Contributors This Release (These are generated from records on Github of anyone who's Pull Requests are part of this release.) (Names are simply listed here alphabetically, not by code contribution size. Anyone who even had so much as one line of change is mentioned.) @@ -1988,16 +1960,18 @@ Chris Woerz (erendrake) https://github.com/erendrake (repository owner) (name not public in github profile) (tdw89) https://github.com/TDW89 Philip Kin (pipakin) https://github.com/pipakin -# v0.18.2 +## v0.18.2 -[Insert witty title here :-P] ------------------------------- -### BREAKING CHANGES +## [Insert witty title here :-P] + +### Breaking Changes + * As usual, you MUST recompile all KSM files before running them on the new version. Some of the changes have altered how the VM works. * Nothing else... we hope. -### NEW FEATURES +### New Features + * Compatibility with KSP version 1.0.5 * `run once ...` syntax to run a script only once per session ( http://ksp-kos.github.io/KOS_DOC/commands/files.html#run-once-program ) * Volumes and processors have better integration ( http://ksp-kos.github.io/structures/vessels/volume.html#structure:VOLUME ) @@ -2006,31 +1980,35 @@ Philip Kin (pipakin) https://github.com/pipakin * `debuglog(...)` function to print directly to the KSP log file ( http://ksp-kos.github.io/KOS_DOC/structures/misc/kuniverse.html#method:KUNIVERSE:DEBUGLOG ) * New `queue` and `stack` data structures ( http://ksp-kos.github.io/KOS_DOC/structures/misc/queue.html and http://ksp-kos.github.io/KOS_DOC/structures/misc/stack.html ) -### BUG FIXES +### Bug Fixes + * The processor's mode (on/off/starved) is now saved and restored ( https://github.com/KSP-KOS/KOS/issues/1172 ) * Fixed stage resources again to address a change in KSP 1.0.5 ( https://github.com/KSP-KOS/KOS/issues/1242 ) * Fix occasional instances of flight controls getting disabled during a docking/undocking/staging event ( https://github.com/KSP-KOS/KOS/issues/1205 ) * kOS can now trigger module events with RemoteTech installed and no KSC connection ( https://github.com/RemoteTechnologiesGroup/RemoteTech/issues/437 ) * Fixed handling of multiple thrust/gimbal transforms and corrected some of their directions ( https://github.com/KSP-KOS/KOS/issues/1259 ) -# v0.18.1 +## v0.18.1 + -Steering More Much Betterer ----------------------- +## Steering More Much Betterer ### Changes + * Changed default MaxStoppingTime to 2 seconds ( was 1 ) -### BUG FIXES +### Bug Fixes + * Fixed a issue where the effect of the Kd parameter of PIDLoop was having a reversed effect #1229 * Fixes an issue where NO_FLOW resources ( eg SolidFuel ) were not reporting correctly #1231 -# v0.18 +## v0.18 -Steering Much Betterer ----------------------- -### BREAKING CHANGES +## Steering Much Betterer + +### Breaking Changes + * As usual, you MUST recompile all KSM files before running them on the new version. Some of the changes have altered how the VM works. * New LOADDISTANCE obsoletes the previous way it worked ( http://ksp-kos.github.io/KOS_DOC/structures/misc/loaddistance.html ) * Fixed broken spelling of "ACQUIRE" on docking ports. The old spelling of "AQUIRE" won't work anymore. @@ -2038,7 +2016,8 @@ Steering Much Betterer * New arg/param matching checks make some previously usable varying argument techniques not work. (We don't think anyone was using them anyway). * Disabled the ability to control vessels the kOS computer part is not actually attached to. This always used to be possible, but it shouldn't have been as it breaks the theme of kOS. This affects all the following: vessel:control, part:controlfrom, part:tag (can still get, but not set), partmodule:doaction, partmodule:doevent, partmodule:setfield (can still getfield). These things become read-only when operating on any vessel other than the one the executing kOS module is actually part of. -### NEW FEATURES +### New Features + * THE BIG ONE: Fix to Cooked Steering! Should help people using torque-less craft like with Realism Overhaul. Removed the old steering logic and replaced it with a nice auto-tuning system. ( https://github.com/KSP-KOS/KOS/pull/1118 ) * SteeringManager structure to let users tweak parts of the new steering system ( http://ksp-kos.github.io/KOS_DOC/structures/misc/steeringmanager.html ) * PIDLoop structure to let users see parts of the new steering system, and to let them use the built-in PID system for their own needs ( http://ksp-kos.github.io/KOS_DOC/structures/misc/pidloop.html ) @@ -2055,7 +2034,8 @@ Steering Much Betterer * KUniverse structure letting you break the 4th wall and revert from a script ( http://ksp-kos.github.io/KOS_DOC/structures/misc/kuniverse.html ) * Added SolarPrimeVector to provide universal longitude direction ( http://ksp-kos.github.io/KOS_DOC/bindings.html#solarprimevector ) -### BUG FIXES +### Bug Fixes + * Made `stage:liquidfuel` more sane. ( https://github.com/KSP-KOS/KOS/issues/513 ) * LIST BODIES returned unusuable structure type ( https://github.com/KSP-KOS/KOS/issues/1090 ) * Made "ORBIT" and alias for "OBT" and visa versa ( https://github.com/KSP-KOS/KOS/issues/1089 ) @@ -2067,7 +2047,6 @@ Steering Much Betterer * Unlock anything inside a Trigger body was broken ( https://github.com/KSP-KOS/KOS/issues/1151 ) * Replaced KSP's incorrect ground speed with our own calculation ( https://github.com/KSP-KOS/KOS/issues/1097 ) * SASMODE "radialin" and "raidialout" were swapped in the KSP API ( https://github.com/KSP-KOS/KOS/issues/1130 ) - * Bug with remote tech allowing access without antenna in one case ( https://github.com/KSP-KOS/KOS/pull/1171 ) * Wheelsteering by integer compass heading was broken ( https://github.com/KSP-KOS/KOS/issues/1141 ) * SHUTDOWN didn't shut down immediately ( https://github.com/KSP-KOS/KOS/issues/1120 ) @@ -2075,12 +2054,13 @@ Steering Much Betterer * Better detection of arg/param matching. ( https://github.com/KSP-KOS/KOS/issues/1107 ) * Doing PRINT AT that runs offscreen threw an error ( https://github.com/KSP-KOS/KOS/issues/813 ) -# v0.17.3 +## v0.17.3 -1.0.4 Release ------------ -### BREAKING CHANGES +## 1.0.4 Release + +### Breaking Changes + * Removed all `ETA_` and `ALT_` bindings, please use `ETA:` and `ALT:` instead * `TRUEANOMALY` and `MEANANOMALYATEPOCH` are now expressed in degrees to conform to our policy * Deprecated INCOMMRANGE - now throws an exception with instructions to use the new addons:rt methods. @@ -2090,6 +2070,7 @@ Steering Much Betterer * The Steering deadzone is much smaller now, this will allow for every precise RCS maneuvers. ### New Hotness + * You can now point RemoteTech antenna directly from script * You can now get RemoteTech's 'local control' status * Infernal Robotics integration improvements @@ -2110,7 +2091,8 @@ Steering Much Betterer * Added `CLEARVECDRAWS` that will remove all VECDRAWS * Any floating point value that has no floating component will be converted to an integer -### Old and busted +### Old And Busted + * Fixed empty return statements crashing with an argument count exception #934 * Fix setting vector:mag to a new value actually setting the magnitude to 1 #952 * Fix electricity being consumed while the game was paused #526 @@ -2134,27 +2116,26 @@ Steering Much Betterer * electricity consumption is better behaved * setting the target to an empty string will always unset target -# v0.17.2 +## v0.17.2 -1.0 Release ------------ + +## 1.0 Release ### New Hotness * New infernal robotics integration * Better error reporting - -### Old and busted +### Old And Busted * fixes keyword lexxing -# v0.17.1 +## v0.17.1 + -Corrections and omissions -------------------------- +## Corrections and omissions -### "New" features +### "New" Features * Due to erendrake's inability to correctly use git. The new list constructor was omitted from the 0.17.0 release binaries. @@ -2164,11 +2145,11 @@ Corrections and omissions * Fixed bug with setting KAC Alarm action to correct value * Fixed some unneeded log spamming +## v0.17.0 -# v0.17.0 -FUNCTIONS! FUNCTIONS! FUNCTIONS! --------------------------------- +## FUNCTIONS! FUNCTIONS! FUNCTIONS! + Big feature: You can make your own user-defined functions, that can handle recursion, and can use local variable scoping. You can build a library of your own function calls and load them into your @@ -2238,39 +2219,33 @@ http://ksp-kos.github.io/KOS_DOC/changes.html - **RECOMPILE YOUR KSM FILES!!!** - If you used the COMPILE command in the past, changes to the kOS machine code that were needed to support variable scoping ended up invalidating any existing compiled KSM files. - - **KSM FILES ARE BIGGER** - compiled KSM files are now larger than they used to be for the same source code. They might not be an efficient way to pack your code down to a small disk footprint anymore. - - *CONFIG:IPU should be slightly increased* The new default we ship with is 200, to reflect both the change in ML code, and the movement to Unity's FixedUpdate for physics ticks. However if you have played kOS in the past, your settings don't get automatically overwritten. You will need to change the setting manually. - - *DECLARE has a new syntax* DECLARE _VARNAME_ now requires an initializer syntax as follows: - DECLARE _VARNAME_ TO _VALUE_. If you leave the TO _VALUE_ off, it will now be a syntax error. Also, you can say LOCAL or GLOBAL instead of, or in addition to, the word DECLARE. - - *DECLAREd variables are now local* Using the DECLARE _VARNAME_ TO _VALUE_ statement now causes the variable to have local scope that only exists within the local block of curly braces ('{'...'}') that it was declared inside of. To get the old behavior you can explicitly say: DECLARE GLOBAL _VARNAME_ to _VALUE. - - *FOR iterator now is local* The _VARIABLE_ in loops of the form FOR _VARIABLE_ IN _SOMELIST_ now has local scope to just that loop, meaning it stops existing after the loop is done and you can't use it outside the loop's body. - -# v0.16.2 +## v0.16.2 ##HOTFIX @@ -2278,20 +2253,24 @@ http://ksp-kos.github.io/KOS_DOC/changes.html * Fixes #610 Print AT draws in the wrong place on telnet after clearscreen. * Fixes #612 doesn't update telnet screen when cur command is longer than prev and you up-arrow -# v0.16.1 +## v0.16.1 ##HOTFIX this fixes #603 the mess that I made of the Node structure, thanks Tabris from the forums for bringing this to our attention. -# v0.16.0 +## v0.16.0 + +### Breaking -### BREAKING * Body:ANGULARVEL is now a Vector instead of a Direction. (This is the same as the change that was done to Vessel:ANGULARVEL in v0.15.4, but we missed the fact that Body had the same problem). It was pretty useless before so this shouldn't hurt many scripters :) * Both Body:ANGULARVEL and Vessel:ANGULARVEL now are expressed in the same SHIP_RAW coordinate system as everything else in kOS, rather than in their own private weirdly mirrored reference frame. (Thanks to forum user @thegreatgonz for finding the problem and the fix) * #536 the 1.5m kOS part has always had trouble with clipping into other parts due to the rim of the cylinder sticking up past the attachment points. The part definition has been changed to fix this, but in KSP new part definitions don't affect vessels that have already been built or have already had their design saved in a craft file in the VAB/SPH. To see the fix you'll need to start a new vessel design from scratch, otherwise you'll still have the old clipping behavior. +* PART:UID is now a string. This will only break you if you were doing math on UIDs? +* ELEMENT:PARTCOUNT was poorly named and duplicated by ELEMENT:PARTS:LENGTH so it was removed. ### New Features + * TELNET SERVER. The biggest new feature this update is the introduction of a **telnet server** you can use to access the terminals in game. For security, it's turned off by default, but you can enable it with the config radio button. Full documentation on this new feature is at http://ksp-kos.github.io/KOS_DOC/general/telnet.html * Synopsis: * Telnet to 127.0.0.1, port 5410 @@ -2307,8 +2286,15 @@ this fixes #603 the mess that I made of the Node structure, thanks Tabris from t * #522 - Added BODY:GEOPOSITIONOF and BODY:ALTITUDEOF for getting body-relative info about a 3D point in space. * #524 and #523 - mission waypoints now have 3d positions * In game Terminal is now resizable! From a script with SET TERMINAL:WIDTH and SET TERMINAL:HEIGHT, or from dragging the lower-right corner of the GUI window. +* (AGX) Action Groups Extended Support! Thanks @SirDiazo + * Getting or setting groups 11-250 should behave the same as the stock groups if you have AGX installed. + * Groundwork is laid for getting parts and modules by the new action groups. +* Gimbals are now a well known module. providing read access to its state +* Added PART:GETMODULEBYINDEX(int). This is most useful when you have a part with the same module twice. Thanks @jwvanderbeck +* More documentation work. http://ksp-kos.github.io/KOS_DOC/ ### Bug Fixes + * Fixes #389 - LOCK STEERING broken for RCS-only (no torque) ships. * Fixes #516 - kOSTags are now applied in the correct MM pass * Fixes #541 - All BODY: suffixes should now work properly when the body is the Sun without crashing. @@ -2323,36 +2309,25 @@ this fixes #603 the mess that I made of the Node structure, thanks Tabris from t * Fixes #580 - RT "signal lost. waiting to re-aquire signal" check previously disallowed manned terminal use. Now it only disables the terminal if the vessel is unmanned. * Fixes #344 - KOSArgumentMismatchException reported wrong arg number (i.e. it would claim your 3rd argument is wrong when it's really your 1st argument). Fixed. +## v0.15.6 -# v0.15.6 - -### BREAKING -* PART:UID is now a string. This will only break you if you were doing math on UIDs? -* ELEMENT:PARTCOUNT was poorly named and duplicated by ELEMENT:PARTS:LENGTH so it was removed. - -### New Features -* (AGX) Action Groups Extended Support! Thanks @SirDiazo - * Getting or setting groups 11-250 should behave the same as the stock groups if you have AGX installed. - * Groundwork is laid for getting parts and modules by the new action groups. -* Gimbals are now a well known module. providing read access to its state -* Added PART:GETMODULEBYINDEX(int). This is most useful when you have a part with the same module twice. Thanks @jwvanderbeck -* More documentation work. http://ksp-kos.github.io/KOS_DOC/ - -### Bug Fixes * Fixes RemoteTech Integration * Structures can now be correctly ==, <> and concatenated with + * STAGE:RESOURCE[?]:CAPACITY is now spell correctly :P -# v0.15.5 +## v0.15.5 + The KSP 0.90 compatibility release. (The full thematic following of KSP 0.90's new way of thinking will come in a future version. This is just to make sure everything works.) ###BREAKING CHANGES + * Now respects the limitations of [0.90 career mode upgrades](http://ksp-kos.github.io/KOS/general/career_limits.html), which may make a few features not work anymore in career mode until you get further progressed along in your building upgrades. ###New Stuff + * Thanks to a new dev team contributer Johann Goetz (@theodoregoetz on github), we have a new, much better and cleaner looking [documentation site](http://ksp-kos.github.io/KOS_DOC/) * Better flight input handling to detect the pilot controls and keep them isolated. * "plays nice" with other autopilots a bit better, using KSP 0.90's new autopiloting hooks. @@ -2361,12 +2336,12 @@ to make sure everything works.) * Separate Dry Mass, Wet Mass, and Current Mass readings for parts and for the vessel as a whole (TODO: Link here, but the public gh-pages hasn't be regenned yet so I don't know the link yet) * Added new [WAYPOINT object](http://ksp-kos.github.io/KOS/structures/waypoint.html) to help with locations of some contracts. * Added new :POSITION and :ALTITUDEPOSITION suffixes to [Geocoordinates](http://ksp-kos.github.io/KOS/math/geocoordinates.html) to obtain 3D vectors of their positions in ship-raw coordinate space. - * ADDED muliple new ways to deal with resources. * STAGE:RESOURCES, SHIP:RESOURCES and TARGET:RESOURCES will let you get a list of the resources for the craft, the difference being that SHIP: and TARGET: includes all resources and STAGE: includes only the resoures that are for "this stage". All three of these will let you get a list of :PARTS that can contain that resource. * Part resources now gives you access to the resource's tweakable :ENABLE and :TOGGLEABLE can let you remove add a resource to the normal resource flow. ###Bug Fixes + * Better handling of range checking and loading the boot file when remotetech is installed (thanks to hvacengi for this contribution) * Boot file overwrite fix (thanks to pakrym) * (For developers) fixed compile error on UNIX platforms that was due to filename case-sensitivity differences. @@ -2375,65 +2350,67 @@ to make sure everything works.) * Fixed lonstanding [bug with geocoordinates:TERRAINHEIGHT](https://github.com/KSP-KOS/KOS/issues/478) ###Small maintenence issues + * Bundling a newer version of ModuleManager * Better use of the "skin" system for the app panel. Should see no obvious effect on the surface. +## v0.15.4 -# v0.15.4 ###BREAKING CHANGES + * Issue #431: SHIP:ANGULARMOMENTUM and SHIP:ANGULARVEL have been changed from directions to vectors to me more consistant with their nature #### New Stuff: + * Should now be compatible with KSP 0.90 #### Bug Fixes: + * Issue #421: some local files are corrupt * Issue #423: its possible to create a file with no extension * Issue #424: additional bootfile suffix protection * Issue #429: files sent to persistence file no longer get truncated +## v0.15.3 -# v0.15.3 BugFixes: + * Issue #417: No error message on nonexistent function. * Issue #413: Name tag window should get keyboard focus when invoked. * Issue #405: Equality operator is broken for Wrapped structure objects. * Issue #393: Files on local volume do not persist through save/load. -# v0.15.2 +## v0.15.2 BugFixes: + * :MODULESNAMED returns something useful now #392 * array syntax bugs #387 * Added :PORTFACING to docking ports that should always have the correct facing for the port itself #398 * BREAKING: Partfacing should now come out of the top rather than the side #394 -# v0.15.1 +## v0.15.1 BugFixes: + * All Lists have suffixes again * in the config panel, IPU no longer gets stuck at 50 +## v0.15 -# v0.15 ## NEW FEATURES: Please follow the links to see the full information on the new features. * [Added new kOS GUI panel to the KSP Applauncher system](http://ksp-kos.github.io/KOS_DOC/summary_topics/applauncher_panel/index.html). With this you can alter config values, and open/close terminals from one common panel. Just click the little kOS logo button in either the editors (VAB/SPH) or in flight view. - * [Added pilot input to flight controls](http://ksp-kos.github.io/KOS_DOC/structure/control/index.html#pilot-commands) which lets you read/write the users control state, you can use this to set the exit behavior for the mainthrottle. - * Several suffixes are now [methods that you can call](ksp-kos.github.io/KOS_DOC/#structure_methods) with arguments. * eg before to add to a list it was SET LIST:ADD TO "FOO". Now it would be LIST:ADD("FOO"). - * Suffix methods that perform an action do not need to be assigned to anything. No more having to say *SET DUMMY TO MYLIST:CLEAR.* You can now just say *MYLIST:CLEAR.* like it was a statement. - * Added suffixes to OBT for [walking orbit conic patches](http://ksp-kos.github.io/KOS_DOC/structure/orbit/index.html) * ORB:HASNEXTPATCH - A boolean that shows the presence of a future patch * ORB:NEXTPATCH - The next OBT patch - * Added better techniques for selecting the Part you want from a Vessel: * Ability to give any part any name you like with the [new nametag feature](http://ksp-kos.github.io/KOS_DOC/summary_topics/nametag/index.html). * [Directly querying a vessel for parts](http://ksp-kos.github.io/KOS_DOC/summary_topics/ship_parts_and_modules/index.html#parts), searching for [nametags](http://ksp-kos.github.io/KOS_DOC/summary_topics/nametag/index.html), or part names or part titles. @@ -2449,7 +2426,6 @@ Please follow the links to see the full information on the new features. * PART:HASPARENT - A boolean that shows the presence of a Parent PART * SHIP:ROOTPART - The first part of a ship. The start of the tree of parts. identical to SHIP:PARTS[0]. * *SET MyList TO SHIP:PARTS.* now does the same thing as *LIST PARTS IN MyList.* - * A [new system lets you access the PartModules](http://ksp-kos.github.io/KOS_DOC/structure/partmodule/index.html) that the stock game and modders put on the various parts. Through this, you now have the ability to manipulate a lot of the things that are on the rightclick menus of parts: * PART Suffixes: * GETMODULE(string) @@ -2460,7 +2436,6 @@ Please follow the links to see the full information on the new features. * DOACTION(name_of_action_) - cause one of the actions that would normally be available to action groups *even if it hasn't been assigned to an action group*. * DOEVENT(event_name) - "presses a button" on the rightclick part menu. * Several others.. - * [Lists are now saner to work with](http://ksp-kos.github.io/KOS_DOC/structure/list/index.html) with no longer needing to use weird side effects to get things done, now that there's proper methods available: * :ADD has changed: * Old Way: *SET MyList:ADD TO NewVal.* @@ -2471,23 +2446,18 @@ Please follow the links to see the full information on the new features. * :CLEAR has changed: * Old Way: *SET Dummy to MyList:CLEAR.* * New Way: *MyList:CLEAR().* - * Added ENGINE:AVAILABLETHRUST suffix. A value that respects the thrust limiter - * Added SHIP:AVAILABLETHRUST suffix. A sum of all of the ship's thrust that respects thrust limiters - * Added a [new experimental COMPILE command](http://ksp-kos.github.io/KOS_DOC/command/file/index.html#compile-1-to-2), for making smaller executable-only programs to put on your probes without punishing you for writing legible code with comments and indenting. - * [Filename convention changes](http://ksp-kos.github.io/KOS_DOC/command/file/index.html#volume-and-filename-arguments): * Commands that deal with filenames will now allow any arbitrary expressions as the filename, except for the RUN command. * *Exception*: The above does NOT apply to the ```RUN``` command. The run command requires that the filenames are known at compile time, and it cannot allow arbitrary expressions evaluated later at runtime. * Program files are now called *.ks instead of *.txt. When you first run the new version, it will give you an option to rename your files to the new name for you as they are moved to the new location. * Although the default script filenames use *.ks, you can override this and explicitly mention filename extensions in all the filename commands. What you can't do is have filenames with no extensions. - * Added support for CKAN - * Added config file so kOS will now show up in Automatic Version Checker (AVC) + ## CHANGES BREAKING OLD SCRIPTS: * BREAKING: **.txt files are now .ks files**: The new assumed default file extension for files used by kOS is *.ks rather than *.txt. This may confuse old IDE's, or your computer's assumed file associations. @@ -2497,6 +2467,7 @@ Please follow the links to see the full information on the new features. * WARNING: **Bundled ModuleManager**: Because kOS now needs ModuleManager, and ModuleMangaer complains about being run on Windows 64bit, you now see a new warning message if you run kOS on Windows 64bit, but the message is ignorable and kOS still runs. * BREAKING: **identifiers as filenames**: If you use the same name for a filename as the name of a variable, in a file command such as COPY, DELETE, etc, then kOS will no longer use the variable's name as the filename but will now use the variable's contents as the filename. + ## BUG FIXES: * [PartValue:POSITION not using ship-relative coords](https://github.com/KSP-KOS/KOS/issues/277) @@ -2506,8 +2477,6 @@ Please follow the links to see the full information on the new features. * [Parser doesn't understand THING[num]:THING[NUM] or thing[index]:suffix(arg)](https://github.com/KSP-KOS/KOS/issues/268) * [ship:obt:patches seems to be missing some of the patches](https://github.com/KSP-KOS/KOS/issues/252) (Note: in addition to fixing it, the patches list was moved to just ship:patches, which makes more sense). * [Compiler should throw exception on trying to put a WAIT in a trigger.](https://github.com/KSP-KOS/KOS/issues/254) - - - - - @@ -2517,6 +2486,7 @@ Please follow the links to see the full information on the new features. * extended button lockout to include the full throttle button (default z) * updated the reference to RemoteTech rather than RemoteTech2 + ## V0.14.1 * Kerbal Space Program 0.25 Support @@ -2525,9 +2495,10 @@ Please follow the links to see the full information on the new features. * KSP AVC Support * Added Body:RotationalPeroid -# v0.14 +## v0.14 ### New Hotness + * Updated fonts, Thanks @MrOnak * Now runtime errors show source location and call stack trace (Github issues #186 and #210). Example: ~~~ @@ -2549,19 +2520,22 @@ Please follow the links to see the full information on the new features. ![Multiple Windows!](https://github.com/KSP-KOS/KOS/blob/master/Docs/Images/MultiEdit.png) -### Old and Busted ( now fixed ) +### Old And Busted ( Now Fixed ) + * "rename" was deleting files instead of moving them. (Github issue #220). * Was parsing array index brakets "[..]" incorrectly when they were on the lefthand side of an assignment. (Github issue #219) * SHIP:SENSORS were reading the wrong ship's sensors sometimes in multi-ship scenarios. (GIthub issue #218 ) * Integer and Floating point numbers were not quite properly interchangable like they were meant to be. (Github issue #209) +## v0.13.1 -# v0.13.1 * Fixed an issue with Dependancies that kept kOS modules from registering -# v0.13 +## v0.13 + ## MAJOR + * BREAKING: Commrange has more or less been removed from stock kOS, we realized that most of the behavior of it was copied by other mods and was invisible to users * BREAKING: All direction references are now relative to the controlling part, not the vessel, this will only break on vessels there these two directions are not the same. * BREAKING: Direction:Vector will always return a unit vector. @@ -2573,6 +2547,7 @@ Please follow the links to see the full information on the new features. ## New Features + * Added the ability to get and set the current timewarp "Mode" either RAILS or PHYSICS * Added Boot files that will run when you get to the pad automatically, you select which one will run in the VAB thanks @WazWaz * Vessels and Bodies now can be used interchangeably as much as possible. @@ -2593,9 +2568,12 @@ Please follow the links to see the full information on the new features. ## Known Issues + * due to issues with the new version of RemoteTech, you will always have a connection available for use with kOS. + ## Fixes + * if you have a target and attempt to set a new target and that fails, you would no longer have a target * increased power requirement of the kOS Module * Bodies are now targetable @@ -2613,7 +2591,7 @@ Please follow the links to see the full information on the new features. * ORBIT:TRANSITION returns a string type that you can actually use. * Comments in code dont cause data loss on load/save -# v0.12.1 +## v0.12.1 BREAKING: DOCKINGPORT:ORIENTATION is now DOCKINGPORT:FACING @@ -2631,7 +2609,7 @@ BREAKING: DOCKINGPORT:ORIENTATION is now DOCKINGPORT:FACING * Added a new PRESERVE keyword for repeating a trigger. * all active triggers are removed when a script is finished. -# v0.12.0 +## v0.12.0 * the aforementioned new parser by @marianoapp with all of its speed improvements and other goodies. * There's a config SpecialValue that can be used to control how some of the mod features work, like setting the execution speed, the integration with RT2 and starting from the archive volume. @@ -2644,13 +2622,14 @@ BREAKING: DOCKINGPORT:ORIENTATION is now DOCKINGPORT:FACING * you can use variables as arguments for PRINT AT statements This version adds a new 0.625m part. Thanks to SMA on this neat new addition. + * it works as a kOS computer core * has 5000 units of code space * as a smaller part it is unlocked with "precision engineering" in career mode. * also has a light that will be controllable before the actual release - Bug fixes + * Cannot "set" a variable that later will become a "lock" #13 * Sanitize values sent to KSP #14 * Strange order of operations: "and" seems to evaluate before ">" #20 @@ -2662,11 +2641,10 @@ Bug fixes * ETA:TRANSITION returns the correct time. * Better handling of types. -# v0.11.1 +## v0.11.1 * BREAKING: Disk Space is now defined by the kOS part, existing missions might have the available space reduced to 500. (whaaw) * BREAKING: Vector * Vector Operator has been changed from V( X * X, Y * Y, Z * Z) to a dot product. - * Added Ctrl+Shift+X hotkey to close the terminal window (jwvanderbeck) * Improved RemoteTech integration (jwvanderbeck) Current state is discussed https://github.com/erendrake/KOS/pull/51 * Added engine stats to the enginevalue @@ -2675,21 +2653,17 @@ Bug fixes * ALLOWSHUTDOWN (get) * THROTTLELOCK (get) * THRUSTLIMIT (get/set) - * Added to BODY:ATM:SEALEVELPRESSURE * Added a DockingPort Part Type, You can access it by "LIST DOCKINGPORTS IN ..." * Added PART:CONTROLFROM which centers the transform on that part. - * Vector now has two new Suffixes * NORMALIZED - Vector keeps same direction, but will have a magnitude of 1. * SQRMAGNITUDE - https://docs.unity3d.com/Documentation/ScriptReference/Vector3-sqrMagnitude.html - * New math operators involving Vectors * VECTORCROSSPRODUCT (VCRS) * VECTORDOTPRODUCT (VDOT) * VECTOREXCLUDE (VXCL) - projects one vector onto another * VECTORANGLE (VANG) - Returns the angle in degrees between from and to. - * Direct control of vessel and nearby vessels (SHIP:CONTROL, TARGET:CONTROL) * __GETTERS__ * YAW - Rotation (1 to -1) @@ -2722,16 +2696,13 @@ Bug fixes * VESSELTARGET:LOAD bool - is the vessel loaded * VESSELTARGET:PACKDISTANCE - Setter for pack distance for every vessel. * Added RANDOM() generator (0 - 1) - * Power requirements are now directly tied to the active volume's size, the ARCHIVE's size is unlimited so it is capped at the equivalent of 50KB. ### 0.11.0 - Thanks to enkido and jwvanderbeck for your help. - - BREAKING: BODY, SHIP:BODY, TARGET:BODY now all return a Body structure rather than the name of the body - BREAKING: Removed NODE:APOAPSIS and NODE:PERIAPSIS. They are now available in NODE:ORBIT:APOAPSIS - - Basic RemoveTech Intergration - Added VOLUME:NAME to getting the current volume - Lists can now be populated with basic data that you can loop over or index [Full Info](/wiki/List/) @@ -2779,7 +2750,6 @@ Bug fixes - HASOXYGEN - SCALE - HEIGHT - - Added ORBIT to NODE - Added the following commands - UNSET #VARIABLE - remove the variable, ALL removes all variables Thanks a1070 @@ -2941,4 +2911,4 @@ Bug fixes - Terminal created - KerboScript designed and implemented - VAB Part created -- Flight stats and bindings created +- Flight stats and bindings created \ No newline at end of file diff --git a/Resources/GameData/kOS/kOS.version.versiontemplate b/Resources/GameData/kOS/kOS.version.versiontemplate new file mode 100644 index 0000000000..54003984d5 --- /dev/null +++ b/Resources/GameData/kOS/kOS.version.versiontemplate @@ -0,0 +1,32 @@ +{ + "NAME": "kOS", + "URL": "https://raw.githubusercontent.com/KSP-KOS/KOS/master/Resources/GameData/kOS/kOS.version", + "DOWNLOAD": "https://github.com/KSP-KOS/KOS/releases", + "CHANGE_LOG_URL": "https://raw.githubusercontent.com/KSP-KOS/KOS/master/CHANGELOG.md", + "GITHUB": { + "USERNAME": "KSP-KOS", + "REPOSITORY": "KOS", + "ALLOW_PRE_RELEASE": false + }, + "VERSION": { + "MAJOR": @VERSION_MAJOR@, + "MINOR": @VERSION_MINOR@, + "PATCH": @VERSION_PATCH@, + "BUILD": @VERSION_BUILD@ + }, + "KSP_VERSION": { + "MAJOR": 1, + "MINOR": 12, + "PATCH": 5 + }, + "KSP_VERSION_MIN": { + "MAJOR": 1, + "MINOR": 12, + "PATCH": 3 + }, + "KSP_VERSION_MAX": { + "MAJOR": 1, + "MINOR": 12, + "PATCH": 99 + } +} diff --git a/doc/source/commands/flight/cooked.rst b/doc/source/commands/flight/cooked.rst index 6519c05a8b..b76a038fa2 100644 --- a/doc/source/commands/flight/cooked.rst +++ b/doc/source/commands/flight/cooked.rst @@ -203,6 +203,13 @@ Like all ``LOCK`` expressions, the steering and throttle continually update on t It's a very bad idea to ``WAIT`` during the execution of the expression in a LOCK WHEELSTEERING. See the note in the next section below. +.. global:: WHEELSTEERINGPID + + :access: Get/Set + :type: :struct:`PIDLoop` + + The PIDLoop used to control wheelsteering. Can be used to optimize + steering performance and eliminate steering oscillations on some vessels. Don't 'WAIT' or run slow script code during cooked control calculation ---------------------------------------------------------------------- diff --git a/doc/source/structures/gui.rst b/doc/source/structures/gui.rst index 68cd1ec607..e06282d16a 100644 --- a/doc/source/structures/gui.rst +++ b/doc/source/structures/gui.rst @@ -66,14 +66,14 @@ The "Hello World" program, version 1 with "callbacks":: // "Hello World" program for kOS GUI. // // Create a GUI window - LOCAL gui IS GUI(200). + LOCAL my_gui IS GUI(200). // Add widgets to the GUI - LOCAL label IS gui:ADDLABEL("Hello world!"). + LOCAL label IS my_gui:ADDLABEL("Hello world!"). SET label:STYLE:ALIGN TO "CENTER". SET label:STYLE:HSTRETCH TO True. // Fill horizontally - LOCAL ok TO gui:ADDBUTTON("OK"). + LOCAL ok TO my_gui:ADDBUTTON("OK"). // Show the GUI. - gui:SHOW(). + my_gui:SHOW(). // Handle GUI widget interactions. // // This is the technique known as "callbacks" - instead @@ -91,21 +91,21 @@ The "Hello World" program, version 1 with "callbacks":: print "OK pressed. Now closing demo.". // Hide when done (will also hide if power lost). - gui:HIDE(). + my_gui:HIDE(). The same "Hello World" program, version 2 with "polling":: // "Hello World" program for kOS GUI. // // Create a GUI window - LOCAL gui IS GUI(200). + LOCAL my_gui IS GUI(200). // Add widgets to the GUI - LOCAL label IS gui:ADDLABEL("Hello world!"). + LOCAL label IS my_gui:ADDLABEL("Hello world!"). SET label:STYLE:ALIGN TO "CENTER". SET label:STYLE:HSTRETCH TO True. // Fill horizontally - LOCAL ok TO gui:ADDBUTTON("OK"). + LOCAL ok TO my_gui:ADDBUTTON("OK"). // Show the GUI. - gui:SHOW(). + my_gui:SHOW(). // Handle GUI widget interactions. // // This is the technique known as "polling" - In a loop you @@ -119,7 +119,7 @@ The same "Hello World" program, version 2 with "polling":: } print "OK pressed. Now closing demo.". // Hide when done (will also hide if power lost). - gui:HIDE(). + my_gui:HIDE(). @@ -135,11 +135,11 @@ manipulate to build up a GUI. If no height is specified, it will resize automatically to fit the contents you put inside it. The width can be set to 0 to force automatic width resizing too:: - SET gui TO GUI(200). - SET button TO gui:ADDBUTTON("OK"). - gui:SHOW(). + SET my_gui TO GUI(200). + SET button TO my_gui:ADDBUTTON("OK"). + my_gui:SHOW(). UNTIL button:TAKEPRESS WAIT(0.1). - gui:HIDE(). + my_gui:HIDE(). See the "ADD" functions in the :struct:`BOX` structure for the other widgets you can add. diff --git a/doc/source/tutorials/gui.rst b/doc/source/tutorials/gui.rst index 83332a8568..55152d5711 100644 --- a/doc/source/tutorials/gui.rst +++ b/doc/source/tutorials/gui.rst @@ -38,8 +38,8 @@ share the implementation with multiple KSP installs, and with others online:: Our TabWidget should be usable in any context, but in this example, we just create it at the top-level. The AddTabWidget function should however accept any VBOX as the parameter:: - LOCAL gui IS GUI(500). - LOCAL tabwidget IS AddTabWidget(gui). + LOCAL my_gui IS GUI(500). + LOCAL tabwidget IS AddTabWidget(my_gui). 3. Add tabs ^^^^^^^^^^^ @@ -74,13 +74,13 @@ tab for setting up Maneuver Nodes might be a better default:: The rest here is just boilerplate - we add a Close button to the top level, then show and run the GUI until the user presses the Close button:: - LOCAL close IS gui:ADDBUTTON("Close"). - gui:SHOW(). + LOCAL close IS my_gui:ADDBUTTON("Close"). + my_gui:SHOW(). UNTIL close:PRESSED { // Handle processing of all the widgets on all the tabs. WAIT(0). } - gui:HIDE(). + my_gui:HIDE(). The Implementation ------------------ @@ -259,7 +259,7 @@ which would mean the communication delay icon is constantly shown. We can test o artificially adding extra delay, and testing on the launch pad:: ... - SET gui:EXTRADELAY TO 2. + SET my_gui:EXTRADELAY TO 2. ... The widget continues to work perfectly. Even if the user rapidly changes tab, the pages change as expected, though diff --git a/kOS.netkan b/kOS.netkan deleted file mode 100644 index 20d946f8d5..0000000000 --- a/kOS.netkan +++ /dev/null @@ -1,35 +0,0 @@ -spec_version: 1 -identifier: kOS -$kref: '#/ckan/github/KSP-KOS/KOS' -$vref: '#/ckan/ksp-avc' -x_netkan_epoch: 1 -name: 'kOS: Scriptable Autopilot System' -abstract: >- - kOS is a scriptable autopilot mod that allows you write small programs to - automate specific tasks. -author: many KSP-KOS contributers, currently dunbaratu and hvacengi -license: GPL-3.0 -x_netkan_version_edit: ^[vV]?(?.+)$ -resources: - homepage: https://ksp-kos.github.io/KOS_DOC/ - manual: https://ksp-kos.github.io/KOS_DOC/ - repository: https://github.com/KSP-KOS/KOS -conflicts: - - name: kOS-Classic -recommends: - - name: ModuleManager - min_version: 2.5.6 - comment: >- - Earlier versions of MM have forward compatibility problems, according to - the MM release notes. -suggests: - - name: RemoteTech - min_version: 1.5.1 - comment: RT gives incentive to having local control of craft, even unmanned ones -install: - - file: GameData/kOS - install_to: GameData -x_netkan_override: - - version: 1:1.1.3.1 - override: - ksp_version_min: 1.2.0 diff --git a/kOS.props b/kOS.props new file mode 100644 index 0000000000..2139ba5bd4 --- /dev/null +++ b/kOS.props @@ -0,0 +1,6 @@ + + + + Resources\GameData\kOS\Plugins + + \ No newline at end of file diff --git a/src/kOS.sln b/kOS.sln similarity index 69% rename from src/kOS.sln rename to kOS.sln index 7231b043e1..5c1f8e53ff 100644 --- a/src/kOS.sln +++ b/kOS.sln @@ -1,32 +1,51 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27428.2015 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35027.167 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS", "kOS\kOS.csproj", "{465EC87D-723D-4A6C-B116-9777AC641DE3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS", "src\kOS\kOS.csproj", "{465EC87D-723D-4A6C-B116-9777AC641DE3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS.Safe", "kOS.Safe\kOS.Safe.csproj", "{590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS.Safe", "src\kOS.Safe\kOS.Safe.csproj", "{590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS.Safe.Test", "kOS.Safe.Test\kOS.Safe.Test.csproj", "{C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kOS.Safe.Test", "src\kOS.Safe.Test\kOS.Safe.Test.csproj", "{C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E44F4203-5064-4B07-845E-D6372CD8E17B}" + ProjectSection(SolutionItems) = preProject + CHANGELOG.md = CHANGELOG.md + CONTRIBUTING.md = CONTRIBUTING.md + kOS.netkan = kOS.netkan + Resources\GameData\kOS\kOS.version.versiontemplate = Resources\GameData\kOS\kOS.version.versiontemplate + LICENSE.md = LICENSE.md + README.md = README.md + RELEASECHECKLIST.md = RELEASECHECKLIST.md + STYLEGUIDE.md = STYLEGUIDE.md + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU + Shell|Any CPU = Shell|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {465EC87D-723D-4A6C-B116-9777AC641DE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {465EC87D-723D-4A6C-B116-9777AC641DE3}.Debug|Any CPU.Build.0 = Debug|Any CPU {465EC87D-723D-4A6C-B116-9777AC641DE3}.Release|Any CPU.ActiveCfg = Release|Any CPU {465EC87D-723D-4A6C-B116-9777AC641DE3}.Release|Any CPU.Build.0 = Release|Any CPU + {465EC87D-723D-4A6C-B116-9777AC641DE3}.Shell|Any CPU.ActiveCfg = Debug|Any CPU + {465EC87D-723D-4A6C-B116-9777AC641DE3}.Shell|Any CPU.Build.0 = Debug|Any CPU {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Debug|Any CPU.Build.0 = Debug|Any CPU {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Release|Any CPU.Build.0 = Release|Any CPU + {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Shell|Any CPU.ActiveCfg = Shell|Any CPU + {590FFDA8-7B44-4BC3-A12A-5FFE2BB7D8FD}.Shell|Any CPU.Build.0 = Shell|Any CPU {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Debug|Any CPU.Build.0 = Debug|Any CPU {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Release|Any CPU.ActiveCfg = Release|Any CPU {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Release|Any CPU.Build.0 = Release|Any CPU + {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Shell|Any CPU.ActiveCfg = Debug|Any CPU + {C9A42A44-DDC8-4D6C-8A16-D7F30F494B46}.Shell|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/kOS.Safe.Test/Properties/AssemblyInfo.cs.versiontemplate b/src/kOS.Safe.Test/Properties/AssemblyInfo.cs.versiontemplate new file mode 100644 index 0000000000..ca4b587b3c --- /dev/null +++ b/src/kOS.Safe.Test/Properties/AssemblyInfo.cs.versiontemplate @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("kOS.Safe.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("kOS.Safe.Test")] +[assembly: AssemblyCopyright("Copyright 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("651e637f-78f4-4f85-a22b-33fe26e5aeca")] + +[assembly: AssemblyFileVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] +[assembly: AssemblyVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] \ No newline at end of file diff --git a/src/kOS.Safe.Test/kOS.Safe.Test.csproj b/src/kOS.Safe.Test/kOS.Safe.Test.csproj index 8d68b2a28e..969762b98b 100644 --- a/src/kOS.Safe.Test/kOS.Safe.Test.csproj +++ b/src/kOS.Safe.Test/kOS.Safe.Test.csproj @@ -1,5 +1,7 @@  - + + + Debug AnyCPU @@ -8,9 +10,11 @@ Properties kOS.Safe.Test kOS.Safe.Test - v4.5 + v4.8 512 + + true @@ -32,18 +36,18 @@ false - - - - - - - ..\packages\NSubstitute.1.8.1.0\lib\net35\NSubstitute.dll + $(SolutionDir)packages\NSubstitute.1.8.1.0\lib\net35\NSubstitute.dll + false - ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + $(SolutionDir)packages\NUnit.2.6.4\lib\nunit.framework.dll + false + + + + @@ -100,22 +104,21 @@ + - - - - - - + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/kOS.Safe.Test/packages.config b/src/kOS.Safe.Test/packages.config index 55f87c5fc4..29102f94b0 100644 --- a/src/kOS.Safe.Test/packages.config +++ b/src/kOS.Safe.Test/packages.config @@ -1,5 +1,7 @@  - + + + \ No newline at end of file diff --git a/src/kOS.Safe/Encapsulation/Lexicon.cs b/src/kOS.Safe/Encapsulation/Lexicon.cs index e621281051..e616035670 100644 --- a/src/kOS.Safe/Encapsulation/Lexicon.cs +++ b/src/kOS.Safe/Encapsulation/Lexicon.cs @@ -115,10 +115,10 @@ private void FillWithEnumerableValues(IEnumerable values) private void InitalizeSuffixes() { AddSuffix("CLEAR", new NoArgsVoidSuffix(Clear, "Removes all items from Lexicon")); - AddSuffix("KEYS", new Suffix>(GetKeys, "Returns the lexicon keys")); + AddSuffix("KEYS", new Suffix(GetKeys, "Returns the lexicon keys")); AddSuffix("HASKEY", new OneArgsSuffix(HasKey, "Returns true if a key is in the Lexicon")); AddSuffix("HASVALUE", new OneArgsSuffix(HasValue, "Returns true if value is in the Lexicon")); - AddSuffix("VALUES", new Suffix>(GetValues, "Returns the lexicon values")); + AddSuffix("VALUES", new Suffix(GetValues, "Returns the lexicon values")); AddSuffix("COPY", new NoArgsSuffix(() => new Lexicon(this), "Returns a copy of Lexicon")); AddSuffix("LENGTH", new NoArgsSuffix(() => internalDictionary.Count, "Returns the number of elements in the collection")); AddSuffix("REMOVE", new OneArgsSuffix(one => Remove(one), "Removes the value at the given key")); @@ -158,12 +158,12 @@ private BooleanValue HasKey(Structure key) return internalDictionary.ContainsKey(key); } - public ListValue GetValues() + public ListValue GetValues() { return ListValue.CreateList(Values); } - public ListValue GetKeys() + public ListValue GetKeys() { return ListValue.CreateList(Keys); } @@ -380,9 +380,9 @@ public override BooleanValue HasSuffix(StringValue suffixName) /// to the list. /// /// - public override ListValue GetSuffixNames() + public override ListValue GetSuffixNames() { - ListValue theList = base.GetSuffixNames(); + ListValue theList = base.GetSuffixNames(); foreach (Structure key in internalDictionary.Keys) { @@ -392,7 +392,7 @@ public override ListValue GetSuffixNames() theList.Add(keyStr); } } - return new ListValue(theList.OrderBy(item => item.ToString())); + return new ListValue(theList.OrderBy(item => item.ToString())); } public override Dump Dump() { diff --git a/src/kOS.Safe/Encapsulation/StringValue.cs b/src/kOS.Safe/Encapsulation/StringValue.cs index 24f6056eff..ecbe90ac3e 100644 --- a/src/kOS.Safe/Encapsulation/StringValue.cs +++ b/src/kOS.Safe/Encapsulation/StringValue.cs @@ -239,10 +239,10 @@ System.Collections.IEnumerator IEnumerable.GetEnumerator() } // As the regular Split, except returning a ListValue rather than an array. - public ListValue SplitToList(string separator) + public ListValue SplitToList(string separator) { string[] split = Regex.Split(internalString, Regex.Escape(separator), RegexOptions.IgnoreCase); - ListValue returnList = new ListValue(); + ListValue returnList = new ListValue(); foreach (string s in split) returnList.Add(new StringValue(s)); return returnList; @@ -273,7 +273,7 @@ private void StringInitializeSuffixes() AddSuffix("PADRIGHT", new OneArgsSuffix( one => PadRight(one))); AddSuffix("REMOVE", new TwoArgsSuffix( (one, two) => Remove(one, two))); AddSuffix("REPLACE", new TwoArgsSuffix( (one, two) => Replace(one, two))); - AddSuffix("SPLIT", new OneArgsSuffix, StringValue>( one => SplitToList(one))); + AddSuffix("SPLIT", new OneArgsSuffix( one => SplitToList(one))); AddSuffix("STARTSWITH", new OneArgsSuffix( one => StartsWith(one))); AddSuffix("TOLOWER", new NoArgsSuffix(() => ToLower())); AddSuffix("TOUPPER", new NoArgsSuffix(() => ToUpper())); diff --git a/src/kOS.Safe/Encapsulation/Structure.cs b/src/kOS.Safe/Encapsulation/Structure.cs index 3027491585..4d51fc18e4 100644 --- a/src/kOS.Safe/Encapsulation/Structure.cs +++ b/src/kOS.Safe/Encapsulation/Structure.cs @@ -63,7 +63,7 @@ private void InitializeInstanceSuffixes() AddSuffix("TOSTRING", new NoArgsSuffix(() => ToString())); AddSuffix("HASSUFFIX", new OneArgsSuffix(HasSuffix)); - AddSuffix("SUFFIXNAMES", new NoArgsSuffix>(GetSuffixNames)); + AddSuffix("SUFFIXNAMES", new NoArgsSuffix(GetSuffixNames)); AddSuffix("ISSERIALIZABLE", new NoArgsSuffix(() => this is SerializableStructure)); AddSuffix("TYPENAME", new NoArgsSuffix(() => new StringValue(KOSName))); AddSuffix("ISTYPE", new OneArgsSuffix(GetKOSIsType)); @@ -208,17 +208,17 @@ public virtual BooleanValue HasSuffix(StringValue suffixName) return false; } - public virtual ListValue GetSuffixNames() + public virtual ListValue GetSuffixNames() { callInitializeSuffixes(); - List names = new List(); - - names.AddRange(instanceSuffixes.Keys.Select(item => (StringValue)item)); - names.AddRange(GetStaticSuffixesForType(GetType()).Keys.Select(item => (StringValue)item)); + List names = new List(); + + foreach (var suffix in instanceSuffixes.Keys) names.Add(suffix); + foreach (var staticSuffix in GetStaticSuffixesForType(GetType()).Keys) names.Add(staticSuffix); // Return the list alphabetized by suffix name. The key lookups above, since they're coming // from a hashed dictionary, won't be in any predictable ordering: - return new ListValue(names.OrderBy(item => item.ToString())); + return new ListValue(names.OrderBy(item => item.ToString())); } public virtual BooleanValue GetKOSIsType(StringValue queryTypeName) diff --git a/src/kOS.Safe/Function/FunctionManager.cs b/src/kOS.Safe/Function/FunctionManager.cs index c19106db5d..2c0043fb6d 100644 --- a/src/kOS.Safe/Function/FunctionManager.cs +++ b/src/kOS.Safe/Function/FunctionManager.cs @@ -1,4 +1,4 @@ -using kOS.Safe.Utilities; +using kOS.Safe.Utilities; using System; using System.Collections.Generic; using System.Linq; @@ -57,6 +57,7 @@ public void CallFunction(string functionName) function.Execute(shared); if (function.UsesAutoReturn) shared.Cpu.PushArgumentStack(function.ReturnValue); + function.ReturnValue = null; } /// diff --git a/src/kOS.Safe/Persistence/FileContent.cs b/src/kOS.Safe/Persistence/FileContent.cs index 7cff1169fd..4682984c3a 100644 --- a/src/kOS.Safe/Persistence/FileContent.cs +++ b/src/kOS.Safe/Persistence/FileContent.cs @@ -61,15 +61,10 @@ private void InitializeSuffixes() AddSuffix("EMPTY", new Suffix(() => Size == 0)); AddSuffix("TYPE", new Suffix(() => Category.ToString())); AddSuffix("STRING", new Suffix(() => String)); - AddSuffix("BINARY", new Suffix>(() => ContentAsIntList())); + AddSuffix("BINARY", new Suffix(() => new ListValue(Bytes.Select(x => new ScalarIntValue(x))))); AddSuffix("ITERATOR", new Suffix(() => new Enumerator(GetEnumerator()))); } - private ListValue ContentAsIntList() - { - return new ListValue(Bytes.Select(x => new ScalarIntValue(x))); - } - public override Dump Dump() { return new Dump { { DumpContent, PersistenceUtilities.EncodeBase64(Bytes) } }; diff --git a/src/kOS.Safe/Properties/AssemblyInfo.cs.versiontemplate b/src/kOS.Safe/Properties/AssemblyInfo.cs.versiontemplate new file mode 100644 index 0000000000..6098f435f9 --- /dev/null +++ b/src/kOS.Safe/Properties/AssemblyInfo.cs.versiontemplate @@ -0,0 +1,26 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("kOS.Safe")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("kOS.Safe")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c1a3b326-28f5-4b98-bf0f-8bd25363fbd7")] + +[assembly: AssemblyFileVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] +[assembly: AssemblyVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] +[assembly: KSPAssembly("kOS.Safe", @VERSION_MAJOR@, @VERSION_MINOR@)] diff --git a/src/kOS.Safe/Properties/Resources.Designer.cs b/src/kOS.Safe/Properties/Resources.Designer.cs index 6f962f5c19..6c9a57cc1b 100644 --- a/src/kOS.Safe/Properties/Resources.Designer.cs +++ b/src/kOS.Safe/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace kOS.Safe.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/kOS.Safe/kOS.Safe.csproj b/src/kOS.Safe/kOS.Safe.csproj index f7e5f37a4e..75ac6219ca 100644 --- a/src/kOS.Safe/kOS.Safe.csproj +++ b/src/kOS.Safe/kOS.Safe.csproj @@ -1,5 +1,7 @@  - + + + Debug @@ -9,9 +11,11 @@ Properties kOS.Safe kOS.Safe - v4.5 + v4.8 512 + + true @@ -44,17 +48,6 @@ false false - - - ..\..\Resources\GameData\kOS\Plugins\ICSharpCode.SharpZipLib.dll - - - - - - - - @@ -295,6 +288,7 @@ + @@ -303,23 +297,22 @@ - - - cp "$(TargetPath)" "$(SolutionDir)/../Resources/GameData/kOS/Plugins" - (test -h "$(SolutionDir)/../KSPdirlink" && cp "$(TargetPath)" "$(SolutionDir)/../KSPdirlink/GameData/kOS/Plugins") || true - - - xcopy "$(TargetPath)" "$(SolutionDir)\..\Resources\GameData\kOS\Plugins" /y - IF EXIST "$(SolutionDir)\..\KSPdirlink\" xcopy "$(TargetPath)" "$(SolutionDir)\..\KSPdirlink\GameData\kOS\Plugins" /y || exit /B 0 - - - + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + - --> - - + + \ No newline at end of file diff --git a/src/kOS.Safe/packages.config b/src/kOS.Safe/packages.config index e25ef8502a..98c6602907 100644 --- a/src/kOS.Safe/packages.config +++ b/src/kOS.Safe/packages.config @@ -1,4 +1,6 @@  + + \ No newline at end of file diff --git a/src/kOS/Binding/FlightControlManager.cs b/src/kOS/Binding/FlightControlManager.cs index 60878b7dc8..a92e25e28e 100644 --- a/src/kOS/Binding/FlightControlManager.cs +++ b/src/kOS/Binding/FlightControlManager.cs @@ -12,6 +12,7 @@ using kOS.Control; using kOS.Module; using kOS.Communication; +using kOS.Safe.Encapsulation; namespace kOS.Binding { @@ -49,6 +50,18 @@ public override void AddTo(SharedObjects shared) shared.BindingMgr.AddBoundVariable("SASMODE", GetAutopilotModeName, SelectAutopilotMode); shared.BindingMgr.AddBoundVariable("NAVMODE", GetNavModeName, SetNavMode); + + shared.BindingMgr.AddBoundVariable("WHEELSTEERINGPID", () => + { + return ((WheelSteeringManager)kOSVesselModule.GetInstance(shared.Vessel).GetFlightControlParameter("wheelsteering")).SteeringPID; + }, value => + { + if (value is PIDLoop pidLoop) + { + ((WheelSteeringManager)kOSVesselModule.GetInstance(shared.Vessel).GetFlightControlParameter("wheelsteering")).SteeringPID = pidLoop; + } + else throw new KOSCastException(value.GetType(), typeof(PIDLoop)); + }); } private object GetThrottleValue() diff --git a/src/kOS/Binding/FlightStats.cs b/src/kOS/Binding/FlightStats.cs index 8c30ed6bb7..90f5427799 100644 --- a/src/kOS/Binding/FlightStats.cs +++ b/src/kOS/Binding/FlightStats.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using kOS.Module; using kOS.Control; using kOS.Safe.Binding; @@ -59,12 +60,12 @@ public override void AddTo(SharedObjects shared) shared.BindingMgr.AddGetter("ALLNODES", () => GetAllNodes(shared)); } - public ListValue GetAllNodes(SharedObjects shared) + public ListValue GetAllNodes(SharedObjects shared) { var vessel = shared.Vessel; if (vessel.patchedConicSolver == null || vessel.patchedConicSolver.maneuverNodes.Count == 0) - return new ListValue(); - var ret = new ListValue(vessel.patchedConicSolver.maneuverNodes.Select(e => Node.FromExisting(vessel, e, shared))); + return new ListValue(); + var ret = new ListValue(vessel.patchedConicSolver.maneuverNodes.Select(e => Node.FromExisting(vessel, e, shared))); return ret; } } diff --git a/src/kOS/Communication/CommNetConnectivityManager.cs b/src/kOS/Communication/CommNetConnectivityManager.cs index 7f266e3a28..858266dbb6 100644 --- a/src/kOS/Communication/CommNetConnectivityManager.cs +++ b/src/kOS/Communication/CommNetConnectivityManager.cs @@ -10,7 +10,9 @@ namespace kOS.Communication /// public class CommNetConnectivityManager : IConnectivityManager { - private CommPath tempPath = new CommPath(); + // WARNING: you must call .Clear() on this object after using it! + // it will hold onto references to vessels even after they have been destroyed, causing a memory leak + private readonly CommPath tempPath = new CommPath(); /// /// Checks to see if CommNet is enabled in the current game. This should be checked often @@ -83,9 +85,10 @@ public bool HasConnectionToHome(Vessel vessel) if (!vessel.isActiveVessel) { var net = CommNetNetwork.Instance.CommNet; - tempPath = new CommPath(); net.FindHome(vessel.Connection.Comm, tempPath); - return tempPath.signalStrength > 0; + bool result = tempPath.signalStrength > 0; + tempPath.Clear(); + return result; } return vessel.Connection.IsConnectedHome; } @@ -106,9 +109,10 @@ public bool HasConnectionToControl(Vessel vessel) if (!vessel.isActiveVessel) { var net = CommNetNetwork.Instance.CommNet; - tempPath = new CommPath(); net.FindClosestControlSource(vessel.Connection.Comm, tempPath); - return tempPath.signalStrength > 0 || vessel.CurrentControlLevel >= Vessel.ControlLevel.PARTIAL_MANNED; + bool result = tempPath.signalStrength > 0 || vessel.CurrentControlLevel >= Vessel.ControlLevel.PARTIAL_MANNED; + tempPath.Clear(); + return result; } return vessel.Connection.IsConnected || vessel.CurrentControlLevel >= Vessel.ControlLevel.PARTIAL_MANNED; } @@ -128,8 +132,9 @@ public bool HasConnection(Vessel vessel1, Vessel vessel2) // This is a limitation put in place to improve performance in the stock game, and // there isn't a very good way around it. var net = CommNetNetwork.Instance.CommNet; - tempPath = new CommPath(); - return vessel1.id == vessel2.id || net.FindPath(vessel1.Connection.Comm, tempPath, vessel2.Connection.Comm) || net.FindPath(vessel2.Connection.Comm, tempPath, vessel1.Connection.Comm); + bool result = vessel1.id == vessel2.id || net.FindPath(vessel1.Connection.Comm, tempPath, vessel2.Connection.Comm) || net.FindPath(vessel2.Connection.Comm, tempPath, vessel1.Connection.Comm); + tempPath.Clear(); + return result; } public void AddAutopilotHook(Vessel vessel, FlightInputCallback hook) diff --git a/src/kOS/Control/WheelSteeringManager.cs b/src/kOS/Control/WheelSteeringManager.cs index d185990ad3..904395ec8d 100644 --- a/src/kOS/Control/WheelSteeringManager.cs +++ b/src/kOS/Control/WheelSteeringManager.cs @@ -16,6 +16,7 @@ internal class WheelSteeringManager : IFlightControlParameter public bool Enabled { get; private set; } public float Value { get; set; } + public PIDLoop SteeringPID = new PIDLoop(0.03, 0, 0); public bool FightsWithSas { get { return false; } } @@ -90,11 +91,7 @@ Vessel IFlightControlParameter.GetResponsibleVessel() object IFlightControlParameter.GetValue() { - if (Enabled) - { - return Value; - } - return internalVessel.ctrlState.mainThrottle; + return Value; } void IFlightControlParameter.UpdateAutopilot(FlightCtrlState c, ControlTypes ctrlLock) @@ -102,14 +99,18 @@ void IFlightControlParameter.UpdateAutopilot(FlightCtrlState c, ControlTypes ctr if (!Enabled) return; if (!(controlShared.Vessel.horizontalSrfSpeed > 0.1f)) return; + + float vesselHeading = VesselUtils.GetHeading(controlShared.Vessel); + float bearing = VesselUtils.AngleDelta(vesselHeading, Value); + float PIDOutput = SteeringPID.Update(controlShared.UpdateHandler.CurrentFixedTime, bearing); - if (Mathf.Abs(VesselUtils.AngleDelta(VesselUtils.GetHeading(controlShared.Vessel), VesselUtils.GetVelocityHeading(controlShared.Vessel))) <= 90) + if (Mathf.Abs(VesselUtils.AngleDelta(vesselHeading, VesselUtils.GetVelocityHeading(controlShared.Vessel))) <= 90) { - c.wheelSteer = Mathf.Clamp(Value / -10, -1, 1); + c.wheelSteer = Mathf.Clamp(PIDOutput, -1, 1); } else { - c.wheelSteer = -Mathf.Clamp(Value / -10, -1, 1); + c.wheelSteer = -Mathf.Clamp(PIDOutput, -1, 1); } } @@ -123,29 +124,21 @@ void IFlightControlParameter.UpdateValue(object value, SharedObjects shared) if (!Enabled) ((IFlightControlParameter)this).EnableControl(shared); - float bearing = 0; - - if (value is VesselTarget) + if (value is VesselTarget vessel) { - bearing = VesselUtils.GetTargetBearing(controlShared.Vessel, ((VesselTarget)value).Vessel); + Value = VesselUtils.GetTargetHeading(controlShared.Vessel, vessel.Vessel); } - else if (value is GeoCoordinates) + else if (value is GeoCoordinates gc) { - bearing = ((GeoCoordinates)value).GetBearing(); + Value = gc.GetHeading(); } else { try { - double doubleValue = Convert.ToDouble(value); - if (Utils.IsValidNumber(doubleValue)) - { - bearing = (float)(Math.Round(doubleValue) - Mathf.Round(FlightGlobals.ship_heading)); - if (bearing < -180) - bearing += 360; // i.e. 359 degrees to the left is really 1 degree to the right. - else if (bearing > 180) - bearing -= 360; // i.e. 359 degrees to the right is really 1 degree to the left - } + float heading = Convert.ToSingle(value); + if (!float.IsInfinity(heading) && !float.IsNaN(heading)) + Value = heading; } catch { @@ -157,11 +150,10 @@ void IFlightControlParameter.UpdateValue(object value, SharedObjects shared) KOSNomenclature.GetKOSName(typeof(VesselTarget)), KOSNomenclature.GetKOSName(typeof(GeoCoordinates)), KOSNomenclature.GetKOSName(typeof(ScalarValue)) - ) - ); + ) + ); } } - Value = bearing; } } } \ No newline at end of file diff --git a/src/kOS/Control/WheelThrottleManager.cs b/src/kOS/Control/WheelThrottleManager.cs index a751147a5a..5c9800afc1 100644 --- a/src/kOS/Control/WheelThrottleManager.cs +++ b/src/kOS/Control/WheelThrottleManager.cs @@ -91,7 +91,7 @@ object IFlightControlParameter.GetValue() { return Value; } - return internalVessel.ctrlState.mainThrottle; + return internalVessel.ctrlState.wheelThrottle; } void IFlightControlParameter.UpdateAutopilot(FlightCtrlState c, ControlTypes ctrlLock) diff --git a/src/kOS/Function/Suffixed.cs b/src/kOS/Function/Suffixed.cs index 3ffb2ab308..abf577fe28 100644 --- a/src/kOS/Function/Suffixed.cs +++ b/src/kOS/Function/Suffixed.cs @@ -732,7 +732,7 @@ public override void Execute(SharedObjects shared) AssertArgBottomAndConsume(shared); // no args // ReSharper disable SuggestUseVarKeywordEvident - ListValue returnList = new ListValue(); + ListValue returnList = new ListValue(); // ReSharper enable SuggestUseVarKeywordEvident WaypointManager wpm = WaypointManager.Instance(); diff --git a/src/kOS/Module/KOSNameTag.cs b/src/kOS/Module/KOSNameTag.cs index d24a9099d2..37234074f5 100644 --- a/src/kOS/Module/KOSNameTag.cs +++ b/src/kOS/Module/KOSNameTag.cs @@ -2,6 +2,7 @@ using kOS.Suffixed; using kOS.Safe.Utilities; using UnityEngine; +using System; namespace kOS.Module { @@ -61,6 +62,10 @@ public override void OnAwake() part.RemoveModule(pm); } } + + // make this module cheaper in update loops + isEnabled = false; + enabled = false; } public void TypingDone(string newValue) @@ -76,4 +81,39 @@ public void TypingCancel() typingWindow = null; } } + + // setting isEnabled to false prevents the nametag from showing up in the PAW...work around that. + [KSPAddon(KSPAddon.Startup.FlightAndEditor, false)] + class KOSNameTagActivationManager : MonoBehaviour + { + void Awake() + { + GameEvents.onPartActionUICreate.Add(OnPartActionUICreate); + GameEvents.onPartActionUIShown.Add(OnPartActionUIShown); + } + + void OnDestroy() + { + GameEvents.onPartActionUICreate.Remove(OnPartActionUICreate); + GameEvents.onPartActionUIShown.Remove(OnPartActionUIShown); + } + + private void OnPartActionUICreate(Part part) + { + var nameTagModule = part.FindModuleImplementing(); + if (nameTagModule != null) + { + nameTagModule.isEnabled = true; + } + } + + private void OnPartActionUIShown(UIPartActionWindow paw, Part part) + { + var nameTagModule = part.FindModuleImplementing(); + if (nameTagModule != null) + { + nameTagModule.isEnabled = false; + } + } + } } \ No newline at end of file diff --git a/src/kOS/Module/kOSProcessor.cs b/src/kOS/Module/kOSProcessor.cs index 83ff221726..68d02feb9f 100644 --- a/src/kOS/Module/kOSProcessor.cs +++ b/src/kOS/Module/kOSProcessor.cs @@ -64,6 +64,8 @@ public string Tag private static readonly List allMyInstances = new List(); public bool HasBooted { get; set; } private bool objectsInitialized = false; + private int numUpdatesAfterStartHappened = 0; + private bool finishedRP1ProceduralAvionicsUpdate = false; public float AdditionalMass { get; set; } @@ -108,10 +110,10 @@ public string Tag [KSPField(isPersistant = false, guiName = "CPU/Disk Upgrade Mass", guiActive = false, guiActiveEditor = true, guiUnits = "Kg", guiFormat = "0.00", groupName = PAWGroup, groupDisplayName = PAWGroup)] public float additionalMassGui = 0F; - [KSPField(isPersistant = false, guiActive = false, guiActiveEditor = false)] + [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)] public float diskSpaceCostFactor = 0.0244140625F; //implies approx 100funds for 4096bytes of diskSpace - [KSPField(isPersistant = false, guiActive = false, guiActiveEditor = false)] + [KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)] public float diskSpaceMassFactor = 0.0000000048829F; //implies approx 0.020kg for 4096bytes of diskSpace [KSPField(isPersistant = true, guiActive = false)] @@ -123,7 +125,7 @@ public string Tag // for the kOS processor. The only reason it's being given a value // here is as a fallback for those cases where an old legacy part // might be loaded from before the part files had this value. - [KSPField(isPersistant = false, guiActive = false)] + [KSPField(isPersistant = true, guiActive = false)] public float ECPerInstruction = 0.000004F; // This represents how much EC to consume per Byte of the current volume, per second. @@ -131,7 +133,7 @@ public string Tag // when you change to another volume). // IMPORTANT: The value defaults to zero and must be overriden in the module // definition for any given part (within the part.cfg file). - [KSPField(isPersistant = false, guiActive = false)] + [KSPField(isPersistant = true, guiActive = false)] public float ECPerBytePerSecond = 0F; public kOSProcessor() @@ -385,7 +387,6 @@ private void PopulateDiskSpaceUI() public float GetModuleMass(float defaultMass, ModifierStagingSituation sit) { // the 'sit' arg is irrelevant to us, but the interface requires it. - return baseModuleMass + AdditionalMass; } //implement IPartMassModifier component @@ -396,11 +397,12 @@ public ModifierChangeWhen GetModuleMassChangeWhen() public override void OnStart(StartState state) { + numUpdatesAfterStartHappened = 0; + finishedRP1ProceduralAvionicsUpdate = false; try { FindRP1Modules(); UpdateRP1TechLevel(state == StartState.Editor); - //if in Editor, populate boot script selector, diskSpace selector and etc. if (state == StartState.Editor) { @@ -410,8 +412,11 @@ public override void OnStart(StartState state) InitUI(); } - - UpdateCostAndMass(); + // Removed: UpdateCostAndMass(); + // Please do not call UpdateCostAndMass() here because during OnStart() in RP-1, diskSpaceMassFactor is still + // the very heavy default value - ProceduralAvionics Tech has not yet been updated for tech level during OnStart(), + // so if we reported our mass now back to KSP, we'd have a super heavy probe core for just one physics frame that + // might unfairly break wheels and legs and joints, etc. //Do not start from editor and at KSP first loading if (state == StartState.Editor || state == StartState.None) @@ -798,8 +803,10 @@ public static int AssignNewId() public void Update() { + bool isInEditor = false; if (HighLogic.LoadedScene == GameScenes.EDITOR && EditorLogic.fetch != null) { + isInEditor = true; if (bootListDirty) { InitUI(); @@ -814,8 +821,38 @@ public void Update() RequiredPower = this.diskSpace * ECPerBytePerSecond + SafeHouse.Config.InstructionsPerUpdate * ECPerInstruction / Time.fixedDeltaTime; } if (!IsAlive()) return; + + // Conceptually this next bit really belongs in OnStart() because it should only happen + // once up front during scene load, but when RP-1 is installed and this KOSProcessor + // is inside the same part as RP-1's ModuleProceduralAvionics, a race condition develops + // between the two if KOSProcessor.OnStart() tries to do the following work. + // The values queried from ModuleProceduralAvionics for mass cost per byte of disk + // are defaulted to the bottom rung starting 1950's tech *at first* until it has had a chance + // to run its OnStart() to correct those values to the actual avionics tech level of the part. + // Thus if KOSProcessor tried to do the following code in its OnStart(), and KOS's OnStart() + // happened before ModuleProceduralAvionics' OnStart(), the KOSProcessor would end up being + // several tonnes when it should only be a few kilograms. (Issue #3081) + // + // It is *hoped* that this work will occur before physics is turned on, so the part gets the + // corrected mass before it has a chance to start crushing landing legs and wheels and so on. + // Allegedly, Unity will invoke all the Update()s several times before KSP turns physics on so + // this *should* be okay. + if (!finishedRP1ProceduralAvionicsUpdate && !isInEditor ) + { + float massFactorBefore = diskSpaceMassFactor; + UpdateRP1TechLevel(false); + UpdateCostAndMass(); + // Stop wasting CPU time doing this recalculation when either the value has changed to a new number (proving + // that RP-1 has finally applied its tech upgrade which is why the value changed), or because we tried long + // enough to prove we really are at the default starting tech level so it's not going to change.) + if (diskSpaceMassFactor != massFactorBefore || numUpdatesAfterStartHappened > 60 ) + { + finishedRP1ProceduralAvionicsUpdate = true; + } + } UpdateVessel(); UpdateObservers(); + ++numUpdatesAfterStartHappened; } public void FixedUpdate() diff --git a/src/kOS/Module/kOSVesselModule.cs b/src/kOS/Module/kOSVesselModule.cs index d2a0b335ec..10be32d173 100644 --- a/src/kOS/Module/kOSVesselModule.cs +++ b/src/kOS/Module/kOSVesselModule.cs @@ -34,12 +34,9 @@ public Guid ID } } - - private static Dictionary allInstances = new Dictionary(); - private static Dictionary partLookup = new Dictionary(); private Dictionary flightControlParameters = new Dictionary(); - private List childParts = new List(); private int partCount = 0; + private bool hasKOSProcessor = false; #region KSP Vessel Module Events /// @@ -54,19 +51,18 @@ protected override void OnAwake() flightParametersAdded = false; autopilotRehookCounter = autopilotRehookPeriod - 2; // make sure it starts out ready to trigger soon flightControlParameters = new Dictionary(); - childParts = new List(); if (SafeHouse.Logger != null) { SafeHouse.Logger.SuperVerbose("kOSVesselModule OnAwake()!"); - if (Vessel != null) - { - allInstances[ID] = this; - } - SafeHouse.Logger.SuperVerbose(string.Format("kOSVesselModule Awake() finished on {0} ({1})", Vessel.vesselName, ID)); } } + public override Activation GetActivation() + { + return Activation.FlightScene | Activation.LoadedVessels; + } + /// /// Start is called after OnEnable activates the module. This is the second method called by /// KSP after Awake. All parts should be added to the vessel now, so it is safe to walk the @@ -86,8 +82,6 @@ public override void OnLoadVessel() // scene. So we now wait to attach to events and attempt to harvest parts until after // the vessel itself has loaded. - - allInstances[ID] = this; AddDefaultParameters(); HarvestParts(); HookEvents(); @@ -133,26 +127,18 @@ public void OnDestroy() if (SafeHouse.Logger != null) { SafeHouse.Logger.SuperVerbose("kOSVesselModule OnDestroy()!"); - if (initialized) - { - UnHookEvents(); - ClearParts(); - } - if (Vessel != null && allInstances.ContainsKey(ID) && ReferenceEquals(allInstances[ID], this)) - { - allInstances.Remove(ID); - } - foreach (var key in flightControlParameters.Keys.ToList()) - { - RemoveFlightControlParameter(key); - } - flightParametersAdded = false; - if (allInstances.Count == 0) - { - partLookup.Clear(); - } - initialized = false; } + UnHookEvents(); + if (initialized) + { + ClearParts(); + } + foreach (var key in flightControlParameters.Keys.ToList()) + { + RemoveFlightControlParameter(key); + } + flightParametersAdded = false; + initialized = false; } /// @@ -201,13 +187,7 @@ public void FixedUpdate() /// private void HarvestParts() { - var proccessorModules = Vessel.FindPartModulesImplementing(); - foreach (var proc in proccessorModules) - { - uint id = proc.part.flightID; - childParts.Add(id); - partLookup[id] = this; - } + hasKOSProcessor = vessel.FindPartModuleImplementing() != null; partCount = Vessel.Parts.Count; } @@ -216,7 +196,7 @@ private void HarvestParts() /// private void ClearParts() { - childParts.Clear(); + hasKOSProcessor = false; partCount = 0; } @@ -304,7 +284,10 @@ private void HookEvents() /// private void UnHookEvents() { - ConnectivityManager.RemoveAutopilotHook(Vessel, UpdateAutopilot); + if (ConnectivityManager.Instance != null) + { + ConnectivityManager.RemoveAutopilotHook(Vessel, UpdateAutopilot); + } if (workAroundEventsEnabled) { @@ -312,8 +295,12 @@ private void UnHookEvents() TimingManager.FixedUpdateRemove(TimingManager.TimingStage.BetterLateThanNever, resetControllable); workAroundEventsEnabled = false; } - AutopilotMsgManager.Instance.TurnOffSuppressMessage(this); - AutopilotMsgManager.Instance.TurnOffSasMessage(this); + + if (AutopilotMsgManager.Instance != null) + { + AutopilotMsgManager.Instance.TurnOffSuppressMessage(this); + AutopilotMsgManager.Instance.TurnOffSasMessage(this); + } } #region Hack to fix "Require Signal for Control" @@ -406,7 +393,7 @@ private void UpdateAutopilot(FlightCtrlState c) if (Vessel != null) { - if (childParts.Count > 0) + if (hasKOSProcessor) { foreach (var parameter in flightControlParameters.Values) { @@ -591,17 +578,9 @@ public void OnAllProcessorsStarved() /// public static kOSVesselModule GetInstance(Vessel vessel) { - kOSVesselModule ret; - if (!allInstances.TryGetValue(vessel.id, out ret)) - { - if (!vessel.isActiveAndEnabled) - throw new Safe.Exceptions.KOSException("Vessel is no longer active or enabled " + vessel.name); - ret = vessel.GetComponent(); - if (ret == null) - throw new kOS.Safe.Exceptions.KOSException("Cannot find kOSVesselModule on vessel " + vessel.name); - allInstances.Add(vessel.id, ret); - } - return ret; + if (!vessel.isActiveAndEnabled) + throw new Safe.Exceptions.KOSException("Vessel is no longer active or enabled " + vessel.name); + return vessel.FindVesselModuleImplementing(); } } } diff --git a/src/kOS/Properties/AssemblyInfo.cs.versiontemplate b/src/kOS/Properties/AssemblyInfo.cs.versiontemplate new file mode 100644 index 0000000000..2d9a833655 --- /dev/null +++ b/src/kOS/Properties/AssemblyInfo.cs.versiontemplate @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("kOS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("kOS")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("324da3fe-391b-421d-93b7-29499dcf9ef3")] + +[assembly: AssemblyFileVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] +[assembly: AssemblyVersion("@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@.@VERSION_BUILD@")] +[assembly: KSPAssembly("kOS", @VERSION_MAJOR@, @VERSION_MINOR@)] diff --git a/src/kOS/Properties/Resources.Designer.cs b/src/kOS/Properties/Resources.Designer.cs index 7a02c530ab..b75be41dec 100644 --- a/src/kOS/Properties/Resources.Designer.cs +++ b/src/kOS/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace kOS.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/kOS/Screen/GUIWindow.cs b/src/kOS/Screen/GUIWindow.cs index a5f6e30e8c..67b868e49b 100644 --- a/src/kOS/Screen/GUIWindow.cs +++ b/src/kOS/Screen/GUIWindow.cs @@ -73,11 +73,13 @@ public void Awake() OptOutOfControlLocking = true; } - public void OnDestroy() + new public void OnDestroy() { if (shared != null) shared.RemoveWindow(this); GameEvents.onHideUI.Remove(OnHideUI); GameEvents.onShowUI.Remove(OnShowUI); + + base.OnDestroy(); } void OnHideUI() diff --git a/src/kOS/Screen/KOSManagedWindow.cs b/src/kOS/Screen/KOSManagedWindow.cs index 5759c8b67e..255ed8376b 100644 --- a/src/kOS/Screen/KOSManagedWindow.cs +++ b/src/kOS/Screen/KOSManagedWindow.cs @@ -147,6 +147,10 @@ protected Vector2 MouseButtonDownPosRelative set { mouseButtonDownPosRelative = value; } } + protected void OnDestroy() + { + depthSort.Remove(this); + } /// /// Implement this for how to make your widget get the keyboard focus. diff --git a/src/kOS/Screen/TermWindow.cs b/src/kOS/Screen/TermWindow.cs index 2152912419..a84233f2be 100644 --- a/src/kOS/Screen/TermWindow.cs +++ b/src/kOS/Screen/TermWindow.cs @@ -204,11 +204,13 @@ private GUIStyle Create9SliceStyle(Texture2D fromTexture) return style; } - public void OnDestroy() + new public void OnDestroy() { LoseFocus(); GameEvents.onHideUI.Remove(OnHideUI); GameEvents.onShowUI.Remove(OnShowUI); + + base.OnDestroy(); } public kOS.Safe.Sound.ISoundMaker GetSoundMaker() diff --git a/src/kOS/SharedObjects.cs b/src/kOS/SharedObjects.cs index 28306f5fc7..ddcd53e781 100644 --- a/src/kOS/SharedObjects.cs +++ b/src/kOS/SharedObjects.cs @@ -25,10 +25,13 @@ public GameEventDispatchManager DispatchManager } public Dictionary AllVoiceValues { get; private set; } + public Dictionary NodeLookup { get; private set; } + public SharedObjects() { ManagedWindows = new List(); AllVoiceValues = new Dictionary(); + NodeLookup = new Dictionary(); } public void AddWindow(KOSManagedWindow w) @@ -38,7 +41,10 @@ public void AddWindow(KOSManagedWindow w) public void RemoveWindow(KOSManagedWindow w) { - ManagedWindows.Remove(w); + if (ManagedWindows != null) + { + ManagedWindows.Remove(w); + } } public void DestroyObjects() @@ -52,7 +58,7 @@ public void DestroyObjects() IDisposable tempDisp; foreach (var prop in props) { - if (!prop.PropertyType.IsValueType && prop.GetSetMethod() != null) + if (!prop.PropertyType.IsValueType && prop.GetSetMethod(nonPublic: true) != null) { tempDisp = prop.GetValue(this, null) as IDisposable; if (tempDisp != null) diff --git a/src/kOS/Suffixed/AggregateResourceValue.cs b/src/kOS/Suffixed/AggregateResourceValue.cs index 1f565e1a43..b3674336ab 100644 --- a/src/kOS/Suffixed/AggregateResourceValue.cs +++ b/src/kOS/Suffixed/AggregateResourceValue.cs @@ -99,10 +99,10 @@ public static ListValue PartsToList(IEnumerable parts, SharedObjec return list; } - public static ListValue FromVessel(Vessel vessel, SharedObjects shared) + public static ListValue FromVessel(Vessel vessel, SharedObjects shared) { var resources = ProspectResources(vessel.parts, shared); - return ListValue.CreateList(resources.Values); + return new ListValue(resources.Values); } } } \ No newline at end of file diff --git a/src/kOS/Suffixed/BoundsValue.cs b/src/kOS/Suffixed/BoundsValue.cs index 5f6e6b6702..876765d0e7 100644 --- a/src/kOS/Suffixed/BoundsValue.cs +++ b/src/kOS/Suffixed/BoundsValue.cs @@ -168,7 +168,7 @@ public Vector FurthestCorner(Vector ray) // Rotate the ray into the bounds box's local frame axes and that will make it clear which corner to use: // If that ray has a +x component, then you want the max X, if it has a -x component, then you want the min x, // etc for each of the 3 axes: - Vector3 orientedRay = Facing.Rotation.Inverse() * ray.Normalized().ToVector3(); + Vector3 orientedRay = Quaternion.Inverse(Facing.Rotation) * ray.Normalized().ToVector3(); float relX = orientedRay.x > 0 ? unityBounds.max.x : unityBounds.min.x; float relY = orientedRay.y > 0 ? unityBounds.max.y : unityBounds.min.y; float relZ = orientedRay.z > 0 ? unityBounds.max.z : unityBounds.min.z; diff --git a/src/kOS/Suffixed/CrewMember.cs b/src/kOS/Suffixed/CrewMember.cs index c3b27b2419..4a1fa0c94c 100644 --- a/src/kOS/Suffixed/CrewMember.cs +++ b/src/kOS/Suffixed/CrewMember.cs @@ -1,4 +1,4 @@ -using kOS.Safe.Encapsulation; +using kOS.Safe.Encapsulation; using kOS.Safe.Encapsulation.Suffixes; using kOS.Suffixed.Part; @@ -41,6 +41,9 @@ private void InitializeSuffixes() AddSuffix("TRAIT", new Suffix(() => Trait)); AddSuffix("EXPERIENCE", new Suffix(() => Experience)); AddSuffix("PART", new Suffix(() => PartValueFactory.Construct(crewMember.seat.part, shared))); + AddSuffix("STATUS", new Suffix(() => crewMember.rosterStatus.ToString())); + AddSuffix("EXPERIENCEVALUE", new Suffix(() => crewMember.experience)); + AddSuffix("KERBALTYPE", new Suffix(() => crewMember.type.ToString())); } public override string ToString() diff --git a/src/kOS/Suffixed/Direction.cs b/src/kOS/Suffixed/Direction.cs index eaa171105e..013edcb822 100644 --- a/src/kOS/Suffixed/Direction.cs +++ b/src/kOS/Suffixed/Direction.cs @@ -155,7 +155,7 @@ private void DirectionInitializeSuffixes() AddSuffix(new[] { "STARVECTOR", "RIGHTVECTOR" }, new Suffix(() => new Vector(rotation * Vector3.right), "This direction's starboard direction expressed as a unit vector.")); - AddSuffix("INVERSE", new Suffix(() => new Direction(rotation.Inverse()), "Returns the inverse of this direction - meaning the rotation that would go FROM this direction TO the universe's raw orientation.")); + AddSuffix("INVERSE", new Suffix(() => new Direction(Quaternion.Inverse(rotation)), "Returns the inverse of this direction - meaning the rotation that would go FROM this direction TO the universe's raw orientation.")); } public static Direction operator *(Direction a, Direction b) @@ -195,7 +195,7 @@ private void DirectionInitializeSuffixes() public static Direction operator -(Direction a) { - return new Direction(a.rotation.Inverse()); + return new Direction(Quaternion.Inverse(a.rotation)); } public override bool Equals(object obj) diff --git a/src/kOS/Suffixed/GeoCoordinates.cs b/src/kOS/Suffixed/GeoCoordinates.cs index c71d1f08f7..4671699604 100644 --- a/src/kOS/Suffixed/GeoCoordinates.cs +++ b/src/kOS/Suffixed/GeoCoordinates.cs @@ -127,7 +127,7 @@ public static GeoCoordinates CreateFromDump(SafeSharedObjects shared, Dump d) /// bearing public ScalarValue GetBearing() { - return VesselUtils.AngleDelta(VesselUtils.GetHeading(Shared.Vessel), (float) GetHeadingFrom()); + return VesselUtils.AngleDelta(VesselUtils.GetHeading(Shared.Vessel), (float) GetHeading()); } /// @@ -240,7 +240,7 @@ private bool RaycastForTerrain(Vector3d worldRayCastStart, Vector3d worldRayCast /// LAT/LANG position on the SOI body's surface. /// /// compass heading in degrees - private ScalarValue GetHeadingFrom() + public ScalarValue GetHeading() { var up = Shared.Vessel.upAxis; var north = VesselUtils.GetNorthVector(Shared.Vessel); @@ -321,7 +321,7 @@ private void GeoCoordsInitializeSuffixes() AddSuffix("BODY", new Suffix(()=> BodyTarget.CreateOrGetExisting(Body, Shared))); AddSuffix("TERRAINHEIGHT", new Suffix(GetTerrainAltitude)); AddSuffix("DISTANCE", new Suffix(GetDistanceFrom)); - AddSuffix("HEADING", new Suffix(GetHeadingFrom)); + AddSuffix("HEADING", new Suffix(GetHeading)); AddSuffix("BEARING", new Suffix(GetBearing)); AddSuffix("POSITION", new Suffix(GetPosition, "Get the 3-D space position relative to the ship center, of this lat/long, " + diff --git a/src/kOS/Suffixed/KUniverseValue.cs b/src/kOS/Suffixed/KUniverseValue.cs index 7ead33f7de..b46c802f11 100644 --- a/src/kOS/Suffixed/KUniverseValue.cs +++ b/src/kOS/Suffixed/KUniverseValue.cs @@ -208,7 +208,7 @@ public void QuickSaveTo(string name) private void SaveGame(string name) { - if (HighLogic.CurrentGame.Parameters.Flight.CanQuickSave && FlightGlobals.ClearToSave() == ClearToSaveStatus.CLEAR) + if (HighLogic.CurrentGame.Parameters.Flight.CanQuickSave) { var game = HighLogic.CurrentGame.Updated(); game.startScene = GameScenes.FLIGHT; diff --git a/src/kOS/Suffixed/Node.cs b/src/kOS/Suffixed/Node.cs index 73405a36f1..b7fff69fda 100644 --- a/src/kOS/Suffixed/Node.cs +++ b/src/kOS/Suffixed/Node.cs @@ -9,8 +9,6 @@ namespace kOS.Suffixed [kOS.Safe.Utilities.KOSNomenclature("Node")] public class Node : Structure { - private static readonly Dictionary nodeLookup; - public ManeuverNode NodeRef { get; private set; } private Vessel vesselRef; private readonly SharedObjects shared; @@ -19,11 +17,6 @@ public class Node : Structure private double radialOut; private double normal; - static Node() - { - nodeLookup = new Dictionary(); - } - public Node(double time, double radialOut, double normal, double prograde, SharedObjects sharedObj) : this(sharedObj) { @@ -53,7 +46,7 @@ private Node(Vessel v, ManeuverNode existingNode, SharedObjects sharedObj) NodeRef = existingNode; vesselRef = v; - nodeLookup.Add(existingNode, this); + shared.NodeLookup.Add(existingNode, this); FromNodeRef(); } @@ -141,7 +134,11 @@ private void InitializeSuffixes() public static Node FromExisting(Vessel v, ManeuverNode existingNode, SharedObjects shared) { - return nodeLookup.ContainsKey(existingNode) ? nodeLookup[existingNode] : new Node(v, existingNode, shared); + if (shared.NodeLookup.TryGetValue(existingNode, out Node kosNode)) + { + return kosNode; + } + return new Node(v, existingNode, shared); } public void AddToVessel(Vessel v) @@ -165,7 +162,7 @@ public void AddToVessel(Vessel v) v.patchedConicSolver.UpdateFlightPlan(); - nodeLookup.Add(NodeRef, this); + shared.NodeLookup.Add(NodeRef, this); } public Vector GetBurnVector() @@ -184,7 +181,7 @@ public void Remove() if (! Career.CanMakeNodes(out careerReason)) throw new KOSLowTechException("use maneuver nodes", careerReason); - nodeLookup.Remove(NodeRef); + shared.NodeLookup.Remove(NodeRef); if (vesselRef.patchedConicSolver == null) throw new KOSSituationallyInvalidException( diff --git a/src/kOS/Suffixed/Part/DockingPortValue.cs b/src/kOS/Suffixed/Part/DockingPortValue.cs index a58edd5311..4b34eb64d5 100644 --- a/src/kOS/Suffixed/Part/DockingPortValue.cs +++ b/src/kOS/Suffixed/Part/DockingPortValue.cs @@ -62,7 +62,7 @@ public PartValue GetPartner() } var otherVessel = VesselTarget.CreateOrGetExisting(otherNode.vessel, Shared); - foreach (var part in otherVessel.Parts) + foreach (PartValue part in otherVessel.Parts) { if (part.Part == otherNode.part) { diff --git a/src/kOS/Suffixed/Part/PartValue.cs b/src/kOS/Suffixed/Part/PartValue.cs index 18ac77a049..247d10f699 100644 --- a/src/kOS/Suffixed/Part/PartValue.cs +++ b/src/kOS/Suffixed/Part/PartValue.cs @@ -22,7 +22,7 @@ public class PartValue : Structure, IKOSTargetable public global::Part Part { get; private set; } public PartValue Parent { get; private set; } public DecouplerValue Decoupler { get; private set; } - public ListValue Children { get; private set; } + public ListValue Children { get; private set; } public Structure ParentValue { get { return (Structure)Parent ?? StringValue.None; } } public Structure DecouplerValue { get { return (Structure)Decoupler ?? StringValue.None; } } public int DecoupledIn { get { return (Decoupler != null) ? Decoupler.Part.inverseStage : -1; } } @@ -37,7 +37,7 @@ internal PartValue(SharedObjects shared, global::Part part, PartValue parent, De Parent = parent; Decoupler = decoupler; RegisterInitializer(PartInitializeSuffixes); - Children = new ListValue(); + Children = new ListValue(); } private void PartInitializeSuffixes() @@ -51,6 +51,7 @@ private void PartInitializeSuffixes() AddSuffix("UID", new Suffix(() => Part.flightID.ToString())); AddSuffix("ROTATION", new Suffix(() => new Direction(Part.transform.rotation))); AddSuffix("POSITION", new Suffix(() => GetPosition())); + AddSuffix("COM", new Suffix(() => GetCOM())); AddSuffix("TAG", new SetSuffix(GetTagName, SetTagName)); AddSuffix("FACING", new Suffix(() => GetFacing())); AddSuffix("BOUNDS", new Suffix(GetBoundsValue)); @@ -65,7 +66,7 @@ private void PartInitializeSuffixes() AddSuffix(new[] { "DECOUPLER", "SEPARATOR" }, new Suffix(() => DecouplerValue, "The part that will decouple/separate this part when activated")); AddSuffix(new[] { "DECOUPLEDIN", "SEPARATEDIN" }, new Suffix(() => DecoupledIn)); AddSuffix("HASPARENT", new Suffix(() => Part.parent != null, "Tells you if this part has a parent, is used to avoid null exception from PARENT")); - AddSuffix("CHILDREN", new Suffix>(() => PartValueFactory.ConstructGeneric(Part.children, Shared), "A LIST() of the children parts of this part")); + AddSuffix("CHILDREN", new Suffix(() => PartValueFactory.ConstructGeneric(Part.children, Shared), "A LIST() of the children parts of this part")); AddSuffix("DRYMASS", new Suffix(() => Part.GetDryMass(), "The Part's mass when empty")); AddSuffix("MASS", new Suffix(() => Part.CalculateCurrentMass(), "The Part's current mass")); AddSuffix("WETMASS", new Suffix(() => Part.GetWetMass(), "The Part's mass when full")); @@ -280,6 +281,12 @@ public Vector GetPosition() return new Vector(Part.transform.position - Shared.Vessel.CoMD + positionError); } + public Vector GetCOM() + { + Vector3d positionError = VesselTarget.CreateOrGetExisting(Part.vessel, Shared).GetPositionError(); + return new Vector(Part.transform.position - Shared.Vessel.CoMD + Part.transform.rotation * Part.CoMOffset + positionError); + } + private void ControlFrom() { ThrowIfNotCPUVessel(); diff --git a/src/kOS/Suffixed/Part/PartValueFactory.cs b/src/kOS/Suffixed/Part/PartValueFactory.cs index e202e18f5e..5283429211 100644 --- a/src/kOS/Suffixed/Part/PartValueFactory.cs +++ b/src/kOS/Suffixed/Part/PartValueFactory.cs @@ -12,8 +12,8 @@ public static ListValue Construct(IEnumerable parts, SharedObjects return ListValue.CreateList(parts.Select(part => Construct(part, shared)).Where(p => p != null)); } - public static ListValue ConstructGeneric(IEnumerable parts, SharedObjects shared) { - return ListValue.CreateList(parts.Select(part => Construct(part, shared)).Where(p => p != null)); + public static ListValue ConstructGeneric(IEnumerable parts, SharedObjects shared) { + return new ListValue(parts.Select(part => Construct(part, shared)).Where(p => p != null)); } public static PartValue Construct(global::Part part, SharedObjects shared) { diff --git a/src/kOS/Suffixed/PartModuleField/PartModuleFields.cs b/src/kOS/Suffixed/PartModuleField/PartModuleFields.cs index af22045cb9..9ec14cdf61 100644 --- a/src/kOS/Suffixed/PartModuleField/PartModuleFields.cs +++ b/src/kOS/Suffixed/PartModuleField/PartModuleFields.cs @@ -468,6 +468,13 @@ protected virtual void SetKSPFieldValue(StringValue suffixName, Structure newVal { object convertedValue = Convert.ChangeType(newValue, field.FieldInfo.FieldType); field.SetValue(convertedValue, partModule); + + // Some mods rely on UI callback to be called when field value is changed + UI_Control control; + if (partModule.Fields.TryGetFieldUIControl(field.name, out control)) + { + control.onFieldChanged?.Invoke(field, convertedValue); + } } else { diff --git a/src/kOS/Suffixed/PartModuleField/PartModuleFieldsFactory.cs b/src/kOS/Suffixed/PartModuleField/PartModuleFieldsFactory.cs index 9c9ea31532..11c7233ff9 100644 --- a/src/kOS/Suffixed/PartModuleField/PartModuleFieldsFactory.cs +++ b/src/kOS/Suffixed/PartModuleField/PartModuleFieldsFactory.cs @@ -3,6 +3,7 @@ using kOS.Safe.Encapsulation; using kOS.AddOns.RemoteTech; using kOS.Module; +using System; namespace kOS.Suffixed.PartModuleField { @@ -11,6 +12,8 @@ namespace kOS.Suffixed.PartModuleField /// public class PartModuleFieldsFactory { + public delegate PartModuleFields ConstructPartModuleFieldsMethod(PartModule partModule, SharedObjects shared); + public static ListValue Construct(IEnumerable modules, SharedObjects shared) { var list = modules.Select(mod => Construct(mod, shared)).ToList(); @@ -21,15 +24,32 @@ public static PartModuleFields Construct(PartModule mod, SharedObjects shared) { var moduleGimbal = mod as ModuleGimbal; if (moduleGimbal != null) + { return new GimbalFields(moduleGimbal, shared); + } var processor = mod as kOSProcessor; - if (processor != null) { + if (processor != null) + { return new kOSProcessorFields(processor, shared); } - if (mod.moduleName.Equals(RemoteTechAntennaModuleFields.RTAntennaModule)) { + // see if any addons have registered a constructor for this module; starting from most derived + for (Type moduleType = mod.GetType(); moduleType != typeof(PartModule); moduleType = moduleType.BaseType) + { + if (constructionMethods.TryGetValue(moduleType, out var constructionMethod)) + { + var moduleFields = constructionMethod(mod, shared); + if (moduleFields != null) + { + return moduleFields; + } + } + } + + if (mod.moduleName.Equals(RemoteTechAntennaModuleFields.RTAntennaModule)) + { return new RemoteTechAntennaModuleFields(mod, shared); } @@ -48,5 +68,13 @@ public static PartModuleFields Construct(PartModule mod, SharedObjects shared) return new PartModuleFields(mod, shared); } + + public static void RegisterConstructionMethod(Type moduleType, ConstructPartModuleFieldsMethod method) + { + constructionMethods[moduleType] = method; + } + + // maps a module name to a function + protected static Dictionary constructionMethods = new Dictionary(); } } \ No newline at end of file diff --git a/src/kOS/Suffixed/ResourceTransferValue.cs b/src/kOS/Suffixed/ResourceTransferValue.cs index c044843fb0..282300c583 100644 --- a/src/kOS/Suffixed/ResourceTransferValue.cs +++ b/src/kOS/Suffixed/ResourceTransferValue.cs @@ -116,11 +116,7 @@ private TransferPartType DetermineType(object toTest) { return TransferPartType.Part; } - if (toTest is ListValue) - { - return TransferPartType.Parts; - } - if (toTest is ListValue) + if (toTest is ListValue || toTest is ListValue || toTest is List) { return TransferPartType.Parts; } @@ -350,6 +346,12 @@ private double CalculateAvailableResource(IEnumerable fromParts) parts.AddRange(partListValue.Select(pv => pv.Part)); break; } + var partList= obj as List; + if (partList!= null) + { + parts.AddRange(partList.Select(pv => pv.Part)); + break; + } break; case TransferPartType.Element: var element = obj as ElementValue; diff --git a/src/kOS/Suffixed/StageValues.cs b/src/kOS/Suffixed/StageValues.cs index 3f7f3c595a..e9f814502f 100644 --- a/src/kOS/Suffixed/StageValues.cs +++ b/src/kOS/Suffixed/StageValues.cs @@ -18,7 +18,7 @@ public class StageValues : Structure private readonly SharedObjects shared; private HashSet partHash = new HashSet(); private PartSet partSet; - private ListValue resList; + private ListValue resList; private Lexicon resLex; // Set by VesselTarget (from InvalidateParts) @@ -40,23 +40,20 @@ internal StageValues(SharedObjects shared) private void InitializeSuffixes() { - // TODO: TEST IF THIS IS BROKEN WHEN CPU VESSEL != ACTIVE VESSEL - // Some of these values come from StageManager, which is part of the UI and - // only refers to the "active vessel", while others come from shared.Vessel and - // thus refer to the CPU vessel. Those aren't always the same thing: + // WARNING: StageManager refers to the active vessel and not the CPU vessel - AddSuffix("NUMBER", new Suffix(() => StageManager.CurrentStage)); + AddSuffix("NUMBER", new Suffix(() => shared.Vessel.currentStage)); AddSuffix("READY", new Suffix(() => shared.Vessel.isActiveVessel && StageManager.CanSeparate)); - AddSuffix("RESOURCES", new Suffix>(GetResourceManifest)); - AddSuffix("RESOURCESLEX", new Suffix(GetResourceDictionary)); + AddSuffix("RESOURCES", new Suffix(() => new ListValue(GetResourceManifest()))); + AddSuffix("RESOURCESLEX", new Suffix(() => new Lexicon(GetResourceDictionary()))); AddSuffix(new string[] { "NEXTDECOUPLER", "NEXTSEPARATOR" }, new Suffix(() => shared.VesselTarget.NextDecoupler ?? (Structure)StringValue.None)); AddSuffix("DELTAV", new Suffix(() => new DeltaVCalc(shared, shared.Vessel.VesselDeltaV.GetStage(shared.Vessel.currentStage)))); } - private ListValue GetResourceManifest() + private ListValue GetResourceManifest() { if (resList != null) return resList; - resList = new ListValue(); + resList = new ListValue(); CreatePartSet(); var defs = PartResourceLibrary.Instance.resourceDefinitions; foreach (var def in defs) diff --git a/src/kOS/Suffixed/Timespan.cs b/src/kOS/Suffixed/TimeSpan.cs similarity index 100% rename from src/kOS/Suffixed/Timespan.cs rename to src/kOS/Suffixed/TimeSpan.cs diff --git a/src/kOS/Suffixed/TimeWarpValue.cs b/src/kOS/Suffixed/TimeWarpValue.cs index 29d0505dd7..07fb33b98d 100644 --- a/src/kOS/Suffixed/TimeWarpValue.cs +++ b/src/kOS/Suffixed/TimeWarpValue.cs @@ -33,9 +33,9 @@ public static TimeWarpValue Instance private void InitializeSuffixes() { AddSuffix("RATE", new SetSuffix(GetRate, SetRate)); - AddSuffix("RATELIST", new Suffix>(GetRatesList)); - AddSuffix("RAILSRATELIST", new Suffix>(() => GetRatesList(TimeWarp.Modes.HIGH))); - AddSuffix("PHYSICSRATELIST", new Suffix>(() => GetRatesList(TimeWarp.Modes.LOW))); + AddSuffix("RATELIST", new Suffix(() => ListValue.CreateList(GetRateArrayForMode(TimeWarp.WarpMode)))); + AddSuffix("RAILSRATELIST", new Suffix(() => ListValue.CreateList(GetRateArrayForMode(TimeWarp.Modes.HIGH)))); + AddSuffix("PHYSICSRATELIST", new Suffix(() => ListValue.CreateList(GetRateArrayForMode(TimeWarp.Modes.LOW)))); AddSuffix("MODE", new SetSuffix(GetModeAsString, SetModeAsString)); AddSuffix("WARP", new SetSuffix(GetWarp, SetWarp)); AddSuffix("WARPTO", new OneArgsSuffix(WarpTo)); @@ -134,24 +134,6 @@ public ScalarValue GetDeltaT() return TimeWarp.fixedDeltaTime; } - public ListValue GetRatesList() - { - return GetRatesList(TimeWarp.WarpMode); - } - - public ListValue GetRatesList(TimeWarp.Modes warpMode) - { - float[] ratesArray = GetRateArrayForMode(warpMode); - - ListValue ratesKOSList = new ListValue(); - - // Have to convert the elements one at a time from (float) to (ScalarDoubleValue): - foreach (float val in ratesArray) - ratesKOSList.Add(val); - - return ratesKOSList; - } - public BooleanValue IsWarpSettled() { float expectedRate = GetRateArrayForMode(TimeWarp.WarpMode)[TimeWarp.CurrentRateIndex]; diff --git a/src/kOS/Suffixed/VesselTarget.Parts.cs b/src/kOS/Suffixed/VesselTarget.Parts.cs index 771ffc9795..0067181d1d 100644 --- a/src/kOS/Suffixed/VesselTarget.Parts.cs +++ b/src/kOS/Suffixed/VesselTarget.Parts.cs @@ -19,9 +19,9 @@ partial class VesselTarget //..... [root, child1, child2, ..., part1-1, part1-2, ..., part2-1, ... heap ;) private PartValue rootPart; private DecouplerValue nextDecoupler; - private ListValue allParts; - private ListValue dockingPorts; - private ListValue decouplers; + private ListValue allParts; + private ListValue dockingPorts; + private ListValue decouplers; private Dictionary partCache; private void InvalidateParts() @@ -53,7 +53,7 @@ public DecouplerValue NextDecoupler return nextDecoupler; } } - public ListValue Parts + public ListValue Parts { get { @@ -62,7 +62,7 @@ public ListValue Parts return allParts; } } - public ListValue DockingPorts + public ListValue DockingPorts { get { @@ -71,7 +71,7 @@ public ListValue DockingPorts return dockingPorts; } } - public ListValue Decouplers + public ListValue Decouplers { get { @@ -98,9 +98,9 @@ private void ConstructParts() { rootPart = null; nextDecoupler = null; - allParts = new ListValue(); - dockingPorts = new ListValue(); - decouplers = new ListValue(); + allParts = new ListValue(); + dockingPorts = new ListValue(); + decouplers = new ListValue(); partCache = new Dictionary(); ConstructPart(Vessel.rootPart, null, null); diff --git a/src/kOS/Suffixed/VesselTarget.cs b/src/kOS/Suffixed/VesselTarget.cs index 3e0929a58c..1ab591fd46 100644 --- a/src/kOS/Suffixed/VesselTarget.cs +++ b/src/kOS/Suffixed/VesselTarget.cs @@ -255,9 +255,9 @@ private void InitializeSuffixes() AddSuffix("PARTSTAGGED", new OneArgsSuffix(GetPartsTagged)); AddSuffix("PARTSTAGGEDPATTERN", new OneArgsSuffix(GetPartsTaggedPattern)); AddSuffix("ALLTAGGEDPARTS", new NoArgsSuffix(GetAllTaggedParts)); - AddSuffix("PARTS", new NoArgsSuffix>(() => Parts)); - AddSuffix("DOCKINGPORTS", new NoArgsSuffix>(() => DockingPorts)); - AddSuffix(new string[] { "DECOUPLERS", "SEPARATORS" }, new NoArgsSuffix>(() => Decouplers)); + AddSuffix("PARTS", new NoArgsSuffix(() => Parts)); + AddSuffix("DOCKINGPORTS", new NoArgsSuffix(() => DockingPorts)); + AddSuffix(new string[] { "DECOUPLERS", "SEPARATORS" }, new NoArgsSuffix(() => Decouplers)); AddSuffix("ELEMENTS", new NoArgsSuffix(() => Vessel.PartList("elements", Shared))); AddSuffix("ENGINES", new NoArgsSuffix(() => Vessel.PartList("engines", Shared))); @@ -291,7 +291,7 @@ private void InitializeSuffixes() AddSuffix("CONTROLPART", new Suffix(() => PartValueFactory.Construct(GetControlPart(), Shared))); AddSuffix("DRYMASS", new Suffix(() => Vessel.GetDryMass(), "The Ship's mass when empty")); AddSuffix("WETMASS", new Suffix(() => Vessel.GetWetMass(), "The Ship's mass when full")); - AddSuffix("RESOURCES", new Suffix>(() => AggregateResourceValue.FromVessel(Vessel, Shared), "The Aggregate resources from every part on the craft")); + AddSuffix("RESOURCES", new Suffix(() => AggregateResourceValue.FromVessel(Vessel, Shared), "The Aggregate resources from every part on the craft")); AddSuffix("LOADDISTANCE", new Suffix(() => new LoadDistanceValue(Vessel))); AddSuffix("ISDEAD", new NoArgsSuffix(() => (Vessel == null || Vessel.state == Vessel.State.DEAD))); AddSuffix("STATUS", new Suffix(() => Vessel.situation.ToString())); @@ -352,12 +352,12 @@ public MessageQueueStructure GetMessages() public BoundsValue GetBoundsValue() { Direction myFacing = VesselUtils.GetFacing(Vessel); - Quaternion inverseMyFacing = myFacing.Rotation.Inverse(); - Vector rootOrigin = Parts[0].GetPosition(); + Quaternion inverseMyFacing = Quaternion.Inverse(myFacing.Rotation); + Vector rootOrigin = ((PartValue)Parts[0]).GetPosition(); Bounds unionBounds = new Bounds(); for (int pNum = 0; pNum < Parts.Count; ++pNum) { - PartValue p = Parts[pNum]; + PartValue p = (PartValue)Parts[pNum]; Vector partOriginOffsetInVesselBounds = p.GetPosition() - rootOrigin; Bounds b = p.GetBoundsValue().GetUnityBounds(); Vector partCenter = new Vector(b.center); @@ -382,7 +382,7 @@ public BoundsValue GetBoundsValue() // The above operation is expensive and should force the CPU to do a WAIT 0: Shared.Cpu.YieldProgram(new YieldFinishedNextTick()); - return new BoundsValue(min, max, delegate { return Parts[0].GetPosition(); }, delegate { return VesselUtils.GetFacing(Vessel); }, Shared); + return new BoundsValue(min, max, delegate { return ((PartValue)Parts[0]).GetPosition(); }, delegate { return VesselUtils.GetFacing(Vessel); }, Shared); } public void ThrowIfNotCPUVessel() diff --git a/src/kOS/kOS.csproj b/src/kOS/kOS.csproj index 4a611d1c32..da387bdce5 100644 --- a/src/kOS/kOS.csproj +++ b/src/kOS/kOS.csproj @@ -1,5 +1,7 @@ - - + + + + Debug AnyCPU @@ -8,9 +10,11 @@ Properties kOS kOS - v4.5 + v4.8 512 + + true @@ -32,69 +36,6 @@ 4 false - - - ..\..\Resources\Assembly-CSharp.dll - - - ..\..\Resources\Assembly-CSharp-firstpass.dll - - - ..\..\Resources\GameData\kOS\Plugins\ICSharpCode.SharpZipLib.dll - - - - - - - - - ..\..\Resources\UnityEngine.AnimationModule.dll - - - ..\..\Resources\UnityEngine.AudioModule.dll - - - ..\..\Resources\UnityEngine.CoreModule.dll - - - ..\..\Resources\UnityEngine.ImageConversionModule.dll - - - ..\..\Resources\UnityEngine.IMGUIModule.dll - - - ..\..\Resources\UnityEngine.InputLegacyModule.dll - - - ..\..\Resources\UnityEngine.PhysicsModule.dll - - - ..\..\Resources\UnityEngine.TextRenderingModule.dll - - - ..\..\Resources\UnityEngine.UI.dll - - - ..\..\Resources\UnityEngine.dll - - - ..\..\Resources\UnityEngine.UIModule.dll - - - ..\..\Resources\UnityEngine.UnityWebRequestAudioModule.dll - - - ..\..\Resources\UnityEngine.UnityWebRequestModule.dll - - - ..\..\Resources\UnityEngine.UnityWebRequestWWWModule.dll - - - False - ..\..\Resources\UnityEngine.VehiclesModule.dll - - @@ -320,24 +261,22 @@ - - - cp "$(TargetPath)" "$(SolutionDir)/../Resources/GameData/kOS/Plugins" - (test -h "$(SolutionDir)/../KSPdirlink" && cp "$(TargetPath)" "$(SolutionDir)/../KSPdirlink/GameData/kOS/Plugins") || true - - - xcopy "$(TargetPath)" "$(SolutionDir)\..\Resources\GameData\kOS\Plugins" /y - IF EXIST "$(SolutionDir)\..\KSPdirlink\" xcopy "$(TargetPath)" "$(SolutionDir)\..\KSPdirlink\GameData\kOS\Plugins" /y || exit /B 0 - - - + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + \ No newline at end of file diff --git a/src/kOS/packages.config b/src/kOS/packages.config index d180f47dbf..b00c06934f 100644 --- a/src/kOS/packages.config +++ b/src/kOS/packages.config @@ -1,4 +1,6 @@  - + + + \ No newline at end of file diff --git a/src/packages/repositories.config b/src/packages/repositories.config deleted file mode 100644 index bb419be8c2..0000000000 --- a/src/packages/repositories.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file