# HG changeset patch # User Adam Kaminski # Date 1644770340 18000 # Sun Feb 13 11:39:00 2022 -0500 # Node ID f4be71348dd702914e4db5ad14f6c51a30b5ab91 # Parent ddb966a92da9f0853e4f284dcbc38a75d796990c Fixed: GetMapRotationInfo now always returns zero (or an empty string) if the maplist is empty, the map position's level info is invalid, or if the current map position isn't the current level. diff -r ddb966a92da9 -r f4be71348dd7 src/p_acs.cpp --- a/src/p_acs.cpp Thu Feb 10 12:28:30 2022 -0500 +++ b/src/p_acs.cpp Sun Feb 13 11:39:00 2022 -0500 @@ -7681,6 +7681,18 @@ case ACSF_GetMapRotationInfo: { ULONG ulPosition = ( args[0] <= 0 ) ? MAPROTATION_GetCurrentPosition() : ( args[0] - 1 ); + level_info_t *rotationMap = MAPROTATION_GetMap( ulPosition ); + + // [AK] If the map position's level info is invalid, this could mean that there's no maplist + // or that the position is invalid, so return zero (or an empty string if we wanted the name). + // If we're checking the current map position, make sure it's the current level too. + if (( rotationMap == NULL ) || (( args[0] <= 0 ) && ( stricmp( level.mapname, rotationMap->mapname ) != 0 ))) + { + if (( args[1] == MAPROTATION_Name ) || ( args[1] == MAPROTATION_LumpName )) + return GlobalACSStrings.AddString( "" ); + + return 0; + } switch ( args[1] ) { @@ -7693,13 +7705,7 @@ case MAPROTATION_Name: case MAPROTATION_LumpName: - { - level_info_t *level = MAPROTATION_GetMap( ulPosition ); - if ( level == NULL ) - return GlobalACSStrings.AddString( "" ); - - return GlobalACSStrings.AddString( args[1] == MAPROTATION_Name ? level->LookupLevelName().GetChars() : level->mapname ); - } + return GlobalACSStrings.AddString( args[1] == MAPROTATION_Name ? rotationMap->LookupLevelName().GetChars() : rotationMap->mapname ); } return 0;