[Fixed] [3.87b] LevelLocals.ChangeLevel() doesn't change level

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

[3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby m8f » Sun Dec 13, 2020 11:36 am

Steps to reproduce:
1. load
lzdoom-change-level.pk3

2. Start Doom II game.
3. Type in console "netevent lcl_test".

Expected behavior: intermission is displayed, then map02 starts.
Actual behavior: intermission is displayed, then clustertext "You have entered deeply into infested starport..." is displayed, then map01 starts again.

The bug was discovered when testing this library with LZDoom. There, the actual behavior is different. Instead of moving the player to the special "headquarters" map, the game drops to console and the following message is displayed:
Code: Select allExpand view
|ò - Unnamed

Unable to open map '|ò'

The text between quotes is different every time, looks like garbage memory.
You do not have the required permissions to view the files attached to this post.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit

Re: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby Rachael » Sun Dec 13, 2020 11:45 am

Sounds like a single (but critical) variable isn't being initialized with the function call.
User avatar
Rachael
Webmaster
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
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: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby drfrag » Sun Dec 13, 2020 1:34 pm

Too bad it doesn't work. FLevelLocals::ChangeLevel was exported recently to ZScript and in LZDoom it didn't exist so i exported G_ChangeLevel instead, I left the level refactor out becouse in theory it wasn't important. So i'm afraid this will have to wait for the 4.5 release.
Edit: actually i made a stupid mistake but it doesn't work anyway.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby drfrag » Mon Dec 14, 2020 5:27 am

I don't know why it doesn't work, it's the old setup. I merged a couple of commits and that broke everything, i managed to fix it but i was not sure (better safe than sorry) so i reverted everything. One said "wminfo has been made a local variable in G_DoCompleted. There were two places where this was accessed from outside the summary screen or its setup code, and both were incorrect." and the other "The wbstartstruct that gets passed to the level summary screen needs to be static". It was the "allow the language table to supersede the title patches, if appropriate" thing.
So now it gets here and i get that message:
Code: Select allExpand view
void G_DoWorldDone (void)
{      
   gamestate = GS_LEVEL;
   if (wminfo.next[0] == 0)
   {
      // Don't crash if no next map is given. Just repeat the current one.
      Printf ("No next map specified.\n");
   }

I think trying to fix this is risky, if someone wants to help that's another thing. Seems that G_ChangeLevel() was already broken.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby drfrag » Mon Dec 14, 2020 6:39 am

With this change the map name is junk and says "Unable to open map":
diff --git a/src/g_level.cpp b/src/g_level.cpp
Code: Select allExpand view
index 659497c0b..ea81a9391 100644
--- a/src/g_level.cpp
+++ b/src/g_level.cpp
@@ -1319,7 +1319,7 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, WorldDone)
 void G_DoWorldDone (void)
 {      
    gamestate = GS_LEVEL;
-   if (wminfo.next[0] == 0)
+   if (nextlevel.IsEmpty())
    {
       // Don't crash if no next map is given. Just repeat the current one.
       Printf ("No next map specified.\n");
Last edited by drfrag on Mon Dec 14, 2020 8:03 am, edited 1 time in total.
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby drfrag » Mon Dec 14, 2020 7:04 am

Now that i'm at it debugging i see that levelname is junk from the start, i can't see anything wrong with the export:
Code: Select allExpand view
void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill);

DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ChangeLevel, G_ChangeLevel)
{
   PARAM_PROLOGUE;
   PARAM_STRING(levelname);
   PARAM_INT(position);
   PARAM_INT(inflags);
   PARAM_INT(nextSkill);
   G_ChangeLevel(levelname, position, inflags, nextSkill);
   return 0;
}

native static void ChangeLevel(string levelname, int position = 0, int flags = 0, int skill = -1);
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: [3.87b] LevelLocals.ChangeLevel() doesn't change level

Postby drfrag » Mon Dec 14, 2020 1:08 pm

User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 2 guests