System.GetTimeFrac bugged

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
User avatar
Player701
 
 
Posts: 1526
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Location: Russia

System.GetTimeFrac bugged

Post by Player701 »

As far as I can gather, this function is supposed to return the fraction of the current game tick that has already passed. However, its behavior appears to be bugged:
  • In release builds, the first time this function is called within any method body, the return value is always infinity.
  • In debug builds, every call appears to return infinity before some significant amount of time has passed.
The difference between debug and release builds indicates that some kind of undefined behavior might be involved.

The following example demonstrates the buggy behavior in GZDoom 4.8.0 (official release build):

Code: Select all

class TestInv : Inventory
{
    override void Tick()
    {
        Super.Tick();

        Test();
        Console.Printf("---");
        Test();
        Console.Printf("---");
    }

    private void Test()
    {
        Console.Printf("%d: %f", GetAge(), System.GetTimeFrac());
        Console.Printf("%d: %f", GetAge(), System.GetTimeFrac());
    }
}
Example output after give testinv:

Code: Select all

10: inf
10: 0.000000
---
10: inf
10: 0.000000
---
11: inf
11: 0.000000
---
11: inf
11: 0.000000
...
The following example demonstrates the buggy behavior in GZDoom g4.9pre-17-g2397b9c11 (debug configuration compiled with Visual Studio 2022):

Code: Select all

class TestInv : Inventory
{
    override void Tick()
    {
        Super.Tick();

        Console.Printf("%d: %f", GetAge(), System.GetTimeFrac());
        Console.Printf("%d: %f", GetAge(), System.GetTimeFrac());

        if (Owner != null)
        {
            let it = BlockThingsIterator.Create(Owner, 1024);
            int cnt = 0;

            while (it.Next())
            {
                cnt++;
            }

            Console.Printf("%d: %f (%d)", GetAge(), System.GetTimeFrac(), cnt);
        }

        Console.Printf("---");
    }
}
Example output after give testinv (Doom II MAP29):

Code: Select all

10: inf
10: inf
10: 0.342887 (29)
---
11: inf
11: inf
11: 0.400922 (29)
---
...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 48536
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: System.GetTimeFrac bugged

Post by Graf Zahl »

fixed. this actually didn't work at all, even the values you got are just random.

Return to “Closed Bugs [GZDoom]”