Revision | 3a92fdfd97a02d1fa364647baccb99f1de296f64 (tree) |
---|---|
Time | 2022-02-14 01:39:00 |
Author | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
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.
@@ -7681,6 +7681,18 @@ | ||
7681 | 7681 | case ACSF_GetMapRotationInfo: |
7682 | 7682 | { |
7683 | 7683 | ULONG ulPosition = ( args[0] <= 0 ) ? MAPROTATION_GetCurrentPosition() : ( args[0] - 1 ); |
7684 | + level_info_t *rotationMap = MAPROTATION_GetMap( ulPosition ); | |
7685 | + | |
7686 | + // [AK] If the map position's level info is invalid, this could mean that there's no maplist | |
7687 | + // or that the position is invalid, so return zero (or an empty string if we wanted the name). | |
7688 | + // If we're checking the current map position, make sure it's the current level too. | |
7689 | + if (( rotationMap == NULL ) || (( args[0] <= 0 ) && ( stricmp( level.mapname, rotationMap->mapname ) != 0 ))) | |
7690 | + { | |
7691 | + if (( args[1] == MAPROTATION_Name ) || ( args[1] == MAPROTATION_LumpName )) | |
7692 | + return GlobalACSStrings.AddString( "" ); | |
7693 | + | |
7694 | + return 0; | |
7695 | + } | |
7684 | 7696 | |
7685 | 7697 | switch ( args[1] ) |
7686 | 7698 | { |
@@ -7693,13 +7705,7 @@ | ||
7693 | 7705 | |
7694 | 7706 | case MAPROTATION_Name: |
7695 | 7707 | case MAPROTATION_LumpName: |
7696 | - { | |
7697 | - level_info_t *level = MAPROTATION_GetMap( ulPosition ); | |
7698 | - if ( level == NULL ) | |
7699 | - return GlobalACSStrings.AddString( "" ); | |
7700 | - | |
7701 | - return GlobalACSStrings.AddString( args[1] == MAPROTATION_Name ? level->LookupLevelName().GetChars() : level->mapname ); | |
7702 | - } | |
7708 | + return GlobalACSStrings.AddString( args[1] == MAPROTATION_Name ? rotationMap->LookupLevelName().GetChars() : rotationMap->mapname ); | |
7703 | 7709 | } |
7704 | 7710 | |
7705 | 7711 | return 0; |