Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[1.95882] Air (and helium) pumps bug
2016-08-22, 08:21 PM (This post was last modified: 2016-08-22 08:24 PM by Gladyon.)
Post: #1
[1.95882] Air (and helium) pumps bug
While modding the helium pumps I stumbled across an air pump bug.

When you add/remove a block (or if ti is destroyed/repaired), there are a possibility that the number of leaks is wrongly calculated.
In one case I managed to remove a beam, creating 7 leaks, and when I replaced it the 7 leaks were still there and the pump didn't re-pressurized.

Steps to reproduce:
- Load the attached bluerint in the desinger
- Wait for it to submerge completely
- Remove the red beam (on the top)
- The air pump indicates 7 leaks instead of 4
- Wait for the flooding to finish
- Replace the beam you removed in order to seal the leaks
- The air pump indicates 7 leaks and the room is still flooded

If you remove again the same beam, you will have 14 leaks.
The green beam (on the side) will count as one leak only (instead of 3) but will work when repaired.


I have corrected one part of the bug in my mod by calling 'RecalculationNeeded()' when the construct is modified.
So now the 7 leaks are 4 as they should, and when sealed the romm will repressurize.
But removing the green beam will still generate 1 leak.

Here is the full code:
Code:
// ********************************************************************************​***********************************************
// Project:     ProtecTech Industries mod for FtD (From The Depths)
//
// Author:      Arnaud Lewden
// Date:        2016
//
// License:     MIT (see License.txt)
// ********************************************************************************​***********************************************

using System;


namespace ProtecTech.Sources
{
    /// <summary>
    /// Correct a bug in the air pump
    /// </summary>
    class AirPump : global::AirPump
    {
        /// <summary>The method that will manage a modification in the construct</summary>
        private Func<ChangeType, ChangeEffect> m_ConstructChangedMethod = null;

        /// <summary>
        /// Initialize the block
        /// </summary>
        public override void BlockStart()
        {
            base.BlockStart();

            m_ConstructChangedMethod = ConstructChanged;
        }

        /// <summary>
        /// Manage a state change
        /// </summary>
        /// <param name="change">The origin of the modification</param>
        public override void StateChanged(IBlockStateChange change)
        {
            base.StateChanged(change);

            if (!IsOnSubConstructable)
            {
                if (change.IsAvailableToConstruct)
                {
                    GetConstructableOrSubConstructable().iUpdates.AddListener(new BlockGroupChangeListenerWithDelayAndUpdatePeriod(this, m_ConstructChangedMethod, -1, 0.0f, 1.0f), false);
                }
                else if (change.IsLostToConstructOrConstructLost)
                {
                    GetConstructableOrSubConstructable().iUpdates.RemoveListener(this, -1);
                }
            }
        }

        /// <summary>
        /// Called when the cosntruct is changed
        /// </summary>
        /// <param name="type">The type of change</param>
        /// <returns>The state of the process</returns>
        protected ChangeEffect ConstructChanged(ChangeType type)
        {
            RecalculationNeeded();

            return ChangeEffect.CompletelyUpToDate;
        }
    }
}

I'm not sure that it's the most optimal way of correcting the bug because I know that it will generates extra-calculations each time the construct is modified.
But it has the distinct advantage to do the job.


Attached File(s)
.blueprint  AirPump bug.blueprint (Size: 34.4 KB / Downloads: 11)
Find all posts by this user
Quote this message in a reply
2016-08-26, 12:21 PM
Post: #2
RE: [1.95882] Air (and helium) pumps bug
Okay should be fixed for next release thanks for reporting

Reviewed FtD on steam yet? It's the #1 thing you can do to help FtD (and future games by Brilliant Skies!), so please take the time!
Visit this user's website Find all posts by this user
Quote this message in a reply
2016-08-26, 12:25 PM
Post: #3
RE: [1.95882] Air (and helium) pumps bug
No problem.

Will under water helium pumps still be less efficient than air pumps?
Find all posts by this user
Quote this message in a reply
2016-08-26, 12:37 PM
Post: #4
RE: [1.95882] Air (and helium) pumps bug
I've still not looked at helium pumps and how they work. Been on holiday mainly this week.

Reviewed FtD on steam yet? It's the #1 thing you can do to help FtD (and future games by Brilliant Skies!), so please take the time!
Visit this user's website Find all posts by this user
Quote this message in a reply
2016-08-26, 12:50 PM
Post: #5
RE: [1.95882] Air (and helium) pumps bug
(2016-08-26 12:37 PM)Nick Smart Wrote:  I've still not looked at helium pumps and how they work. Been on holiday mainly this week.

No problem, hope you had a good time!

It's just that I have given an up force of 4 to the helium pumps for the underwater volume (they currently are set to 1 everywhere and the air pumps are set to 3).
But as the method where to put the modification isn't virtual I had to make an ugly patch and my buoyancy position is a little off.

So, if you plan to change the helium pumps behaviour, please change the 'CalculateBuoyancyMainThreadEfficient()' method in the 'AirPump' class to virtual while you're at it.
Find all posts by this user
Quote this message in a reply
2016-08-26, 01:59 PM
Post: #6
RE: [1.95882] Air (and helium) pumps bug
This is half-fixed in v1.95883.

The main part of the bug is gone, the leaking status is now OK.
But the leaks count may be off by far.

I attached a new blueprint.
Wait for it to submerge and remove the red 2m beam on the left.
That should create 2 leaks, but 84 are created.


Attached File(s)
.blueprint  AirPump bug2.blueprint (Size: 35.36 KB / Downloads: 12)
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)