Jump to content

World::Save spits out empty file.


reepblue
 Share

Go to solution Solved by Josh,

Recommended Posts

On 10/1/2023 at 5:19 PM, Josh said:

The example you posted works without incident.

This example causes my issue.

#include "UltraEngine.h"
using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Load scene
    auto scene = LoadMap(world, "Maps/savetest2.ultra");

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_F5))
        {
            //Save the starting scene to a file
            scene->Save("game.sav");
        }

        //Reload the starting scene when space key is pressed
        if (window->KeyHit(KEY_F6))
        {
            scene->Reload("game.sav");
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

savetest2.zip

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

1 hour ago, Josh said:

I don't see anything wrong. I ran the program, pressed F5, then pressed F6. Nothing bad happened.

If I had a dollar for every time I forgot to register my components, I would have enough money to quit my job to play with Ultra Engine all day.

You're correct, that example alone does not do anything (Minus make the ground darker for some reason). Registering the component that's used in the map should cause the crash.

#include "UltraEngine.h"
using namespace UltraEngine;

#include "Components/Player/CameraControls.hpp"

int main(int argc, const char* argv[])
{
    RegisterComponent<CameraControls>();

    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create a world
    auto world = CreateWorld();

    //Create a framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Load scene
    auto scene = LoadMap(world, "Maps/savetest2.ultra");

    //Main loop
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_F5))
        {
            //Save the starting scene to a file
            scene->Save("game.sav");
        }

        //Reload the starting scene when space key is pressed
        if (window->KeyHit(KEY_F6))
        {
            scene->Reload("game.sav");
        }

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Thanks 1

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

9 minutes ago, Josh said:

Oh, okay it just looks like the ambient light is not being saved in the game save.

As I mentioned here, a lot of scene properties don't get saved from the editor. Not sure if this carries over to user saves.

But can't wait to try this. I've been very conservative about making components because I couldn't test reloading them.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I'm not sure what it is, but its not the ambient light setting actually.

I am going to lock this thread now. If something else comes up please tell me.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...