From 03e8f0e355b8b20d68f947cfd144e910640ba3b3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 25 Mar 2009 23:29:00 +0000 Subject: [PATCH] - Removed some obsolete code from G_InitLevelLocals that was causing problems with maps that have no name. - Fixed: The inner loop in AWeaponSlot::PickWeapon could endlessly loop when the counter variable became negative. SVN r1504 (trunk) --- docs/rh-log.txt | 4 +++ src/g_level.cpp | 57 +++++++++++++------------------------- src/g_shared/a_weapons.cpp | 2 +- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index b00386464..f9f349257 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ March 25, 2009 (Changes by Graf Zahl) +- Removed some obsolete code from G_InitLevelLocals that was causing problems + with maps that have no name. +- Fixed: The inner loop in AWeaponSlot::PickWeapon could endlessly loop when + the counter variable became negative. - Fixed: Implicitly defined clusters were not initialized when being created. March 24, 2009 (Changes by Graf Zahl) diff --git a/src/g_level.cpp b/src/g_level.cpp index 93f67a821..d5c7d0f67 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1262,45 +1262,28 @@ void G_InitLevelLocals () G_AirControlChanged (); - if (!info->LevelName.IsEmpty()) - { - cluster_info_t *clus = FindClusterInfo (info->cluster); + cluster_info_t *clus = FindClusterInfo (info->cluster); - level.partime = info->partime; - level.sucktime = info->sucktime; - level.cluster = info->cluster; - level.clusterflags = clus ? clus->flags : 0; - level.flags |= info->flags; - level.flags2 |= info->flags2; - level.levelnum = info->levelnum; - level.Music = info->Music; - level.musicorder = info->musicorder; + level.partime = info->partime; + level.sucktime = info->sucktime; + level.cluster = info->cluster; + level.clusterflags = clus ? clus->flags : 0; + level.flags |= info->flags; + level.flags2 |= info->flags2; + level.levelnum = info->levelnum; + level.Music = info->Music; + level.musicorder = info->musicorder; - level.LevelName = level.info->LookupLevelName(); - strncpy (level.nextmap, info->nextmap, 8); - level.nextmap[8] = 0; - strncpy (level.secretmap, info->secretmap, 8); - level.secretmap[8] = 0; - strncpy (level.skypic1, info->skypic1, 8); - level.skypic1[8] = 0; - if (!level.skypic2[0]) - strncpy (level.skypic2, level.skypic1, 8); - level.skypic2[8] = 0; - } - else - { - level.partime = level.cluster = 0; - level.sucktime = 0; - level.LevelName = "Unnamed"; - level.nextmap[0] = - level.secretmap[0] = 0; - level.Music = ""; - strcpy (level.skypic1, "SKY1"); - strcpy (level.skypic2, "SKY1"); - level.flags = 0; - level.flags2 = 0; - level.levelnum = 1; - } + level.LevelName = level.info->LookupLevelName(); + strncpy (level.nextmap, info->nextmap, 8); + level.nextmap[8] = 0; + strncpy (level.secretmap, info->secretmap, 8); + level.secretmap[8] = 0; + strncpy (level.skypic1, info->skypic1, 8); + level.skypic1[8] = 0; + if (!level.skypic2[0]) + strncpy (level.skypic2, level.skypic1, 8); + level.skypic2[8] = 0; compatflags.Callback(); diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 8bfe74007..11829f857 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -763,7 +763,7 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player) { for (j = (unsigned)(i - 1) % Weapons.Size(); j != i; - j = (unsigned)(j - 1) % Weapons.Size()) + j = (unsigned)(j + Weapons.Size() - 1) % Weapons.Size()) // + Weapons.Size is to avoid underflows { AWeapon *weap = static_cast (player->mo->FindInventory(Weapons[j].Type));