[Fixed] 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.

System.GetTimeFrac bugged

Postby Player701 » Thu Jun 16, 2022 1:17 am

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 allExpand view
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 allExpand view
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 allExpand view
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 allExpand view
10: inf
10: inf
10: 0.342887 (29)
---
11: inf
11: inf
11: 0.400922 (29)
---
...
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: System.GetTimeFrac bugged

Postby Graf Zahl » Thu Jun 16, 2022 1:36 am

fixed. this actually didn't work at all, even the values you got are just random.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 1 guest