From 94944dfc4684b7dcb39dcbc8955b30339902adb7 Mon Sep 17 00:00:00 2001 From: XProger Date: Mon, 22 Oct 2018 08:47:55 +0300 Subject: [PATCH] fix cross-level items in savegame --- src/format.h | 44 ++++++++++++++++++++++++-------------------- src/level.h | 3 ++- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/format.h b/src/format.h index 03dff23..cfb21b6 100644 --- a/src/format.h +++ b/src/format.h @@ -1799,25 +1799,6 @@ namespace TR { return type >= DOOR_1 && type <= DOOR_8; } - static bool isPickup(Type type) { - return (type >= PISTOLS && type <= AMMO_UZIS) || - (type >= PUZZLE_1 && type <= PUZZLE_4) || - (type >= KEY_ITEM_1 && type <= KEY_ITEM_4) || - (type == MEDIKIT_SMALL || type == MEDIKIT_BIG) || - (type == SCION_PICKUP_QUALOPEC || type == SCION_PICKUP_DROP || type == SCION_PICKUP_HOLDER || type == LEADBAR) || - (type == CRYSTAL) || - (type >= SECRET_1 && type <= SECRET_3) || - (type == M16 || type == AMMO_M16) || - (type == MP5 || type == AMMO_MP5) || - (type == AUTOPISTOLS || type == AMMO_AUTOPISTOLS) || - (type == DESERT_EAGLE || type == AMMO_DESERT_EAGLE) || - (type == GRENADE || type == AMMO_GRENADE) || - (type == ROCKET || type == AMMO_ROCKET) || - (type == HARPOON || type == AMMO_HARPOON) || - (type == FLARES || type == FLARE) || - (type >= STONE_ITEM_1 && type <= STONE_ITEM_4); - } - static bool isPuzzleItem(Type type) { return type >= PUZZLE_1 && type <= PUZZLE_4; } @@ -1826,8 +1807,31 @@ namespace TR { return type >= KEY_ITEM_1 && type <= KEY_ITEM_4; } + static bool isWeapon(Type type) { + return (type >= PISTOLS && type <= AMMO_UZIS) || + (type == M16 || type == AMMO_M16) || + (type == MP5 || type == AMMO_MP5) || + (type == AUTOPISTOLS || type == AMMO_AUTOPISTOLS) || + (type == DESERT_EAGLE || type == AMMO_DESERT_EAGLE) || + (type == GRENADE || type == AMMO_GRENADE) || + (type == ROCKET || type == AMMO_ROCKET) || + (type == HARPOON || type == AMMO_HARPOON); + } + + static bool isPickup(Type type) { + return isPuzzleItem(type) || + isKeyItem(type) || + isWeapon(type) || + (type == MEDIKIT_SMALL || type == MEDIKIT_BIG) || + (type == SCION_PICKUP_QUALOPEC || type == SCION_PICKUP_DROP || type == SCION_PICKUP_HOLDER || type == LEADBAR) || + (type == CRYSTAL) || + (type >= SECRET_1 && type <= SECRET_3) || + (type == FLARES || type == FLARE) || + (type >= STONE_ITEM_1 && type <= STONE_ITEM_4); + } + static bool isCrossLevelItem(Type type) { - return isPickup(type) && !isPuzzleItem(type) && !isKeyItem(type) && (type != LEADBAR); + return isPickup(type) && !isPuzzleItem(type) && !isKeyItem(type) && (type != LEADBAR) && !(type >= SECRET_1 && type <= SECRET_3); } bool isPickup() const { diff --git a/src/level.h b/src/level.h index 3d39bad..768c2c2 100644 --- a/src/level.h +++ b/src/level.h @@ -144,7 +144,8 @@ struct Level : IGame { for (int i = 0; i < inventory->itemsCount; i++) { Inventory::Item *invItem = inventory->items[i]; - if (!TR::Entity::isCrossLevelItem(TR::Entity::convFromInv(invItem->type))) continue; + if (!TR::Entity::isPickup(TR::Entity::convFromInv(invItem->type))) continue; + if (!checkpoint && !TR::Entity::isCrossLevelItem(TR::Entity::convFromInv(invItem->type))) continue; SaveItem *item = (SaveItem*)ptr; ptr += sizeof(*item);