anura-engine / anura

Anura Engine
Other
384 stars 78 forks source link

Update level.cpp to use the set_next_level and set_previous_level functions. #381

Closed al0fdf closed 7 months ago

DDR0 commented 7 months ago

OK, so I have a question - what is this actually enabling? If it's pulling keys from the level document, then how did it work without the code enabled?

al0fdf commented 7 months ago

OK, so I have a question - what is this actually enabling? If it's pulling keys from the level document, then how did it work without the code enabled?

The code before my change was calling

right_portal_.level_dest = node["next_level"].as_string();
right_portal_.dest_str = "left";
right_portal_.dest_starting_pos = false;
right_portal_.automatic = true;

and I found that there were two functions: set_next_level and set_previous_level which did the exact same thing(except the name is passed in as an argument instead of directly using node["next_level"].as_string();), and these functions were not used anywhere else in the code as far as I could tell.

void Level::set_next_level(const std::string& name)
{
    right_portal_.level_dest = name;
    right_portal_.dest_str = "left";
    right_portal_.dest_starting_pos = false;
    right_portal_.automatic = true;
}

This raises an interesting question as the functions are only used once, and in terms of optimization, there's no real need for the functions to be there.

DDR0 commented 7 months ago

Ahhhhh, I'm with you now. Yeah, this makes total sense. Thank you.