From 827eec9b26e05a962674a8c66fcbb5a844a789f5 Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 17 Jul 2018 02:58:33 +0300 Subject: [PATCH] fix switch button animation and alignment (TR2, TR3); minor fixes --- src/format.h | 18 ++++++++++++------ src/inventory.h | 8 ++++---- src/lara.h | 2 +- src/video.h | 4 ++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/format.h b/src/format.h index 3f933d8..518595d 100644 --- a/src/format.h +++ b/src/format.h @@ -1032,6 +1032,10 @@ namespace TR { 0, 100, 80, ::Box(vec3(-1024, -1024, -1024), vec3(1024, 1024, 512)), true, true }; + Limit SWITCH_BUTTON = { + 0, 300, 30, ::Box(vec3(-200, 0, 290), vec3(200, 0, 512)), true, true + }; + Limit PICKUP = { 0, -100, 180, ::Box(vec3(-256, -100, -256), vec3(256, 100, 100)), false, true }; @@ -3052,13 +3056,15 @@ namespace TR { } // turn off interpolation for some entities - if (id == LVL_TR2_CUT_1) - for (int i = 0; i < entitiesBaseCount; i++) { - Entity &e = entities[i]; - if (e.type == Entity::CUT_6 || e.type == Entity::CUT_8 || e.type == Entity::CUT_9) { - e.flags.smooth = false; - } + for (int i = 0; i < entitiesBaseCount; i++) { + Entity &e = entities[i]; + if ((id == LVL_TR2_CUT_1 && (e.type == Entity::CUT_6 || e.type == Entity::CUT_8 || e.type == Entity::CUT_9)) || + e.type == Entity::SWITCH_BUTTON) { + + e.flags.smooth = false; + } + } } LevelID getTitleId() const { diff --git a/src/inventory.h b/src/inventory.h index 4fd33c7..b3ba5a1 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -961,12 +961,12 @@ struct Inventory { void update() { if (titleTimer > 1.0f && ( - Input::state[0][cInventory] || Input::state[0][cAction] || Input::state[0][cJump] || - Input::state[1][cInventory] || Input::state[1][cAction] || Input::state[1][cJump] || - Input::down[ikCtrl] || Input::down[ikEnter] || Input::down[ikAlt])) + Input::state[0][cInventory] || Input::state[0][cAction] || + Input::state[1][cInventory] || Input::state[1][cAction] || + Input::down[ikCtrl])) { if (video) { - if (video->time > 0.5f) + if (video->time > 0.75f) skipVideo(); } else if (titleTimer > 1.0f && titleTimer < 2.5f) titleTimer = 1.0f; diff --git a/src/lara.h b/src/lara.h index 0bec786..74c3e1b 100644 --- a/src/lara.h +++ b/src/lara.h @@ -1814,7 +1814,7 @@ struct Lara : Character { Switch *controller = (Switch*)level->entities[info.trigCmd[cmdIndex++].args].controller; if (controller->flags.state != TR::Entity::asActive) { - limit = state == STATE_STOP ? &TR::Limits::SWITCH : &TR::Limits::SWITCH_UNDERWATER; + limit = state == STATE_STOP ? (controller->getEntity().type == TR::Entity::SWITCH_BUTTON ? &TR::Limits::SWITCH_BUTTON : &TR::Limits::SWITCH) : &TR::Limits::SWITCH_UNDERWATER; if (checkInteraction(controller, limit, Input::state[camera->cameraIndex][cAction])) { actionState = (controller->state == Switch::STATE_DOWN && stand == STAND_GROUND) ? STATE_SWITCH_UP : STATE_SWITCH_DOWN; diff --git a/src/video.h b/src/video.h index 575c654..c50abdf 100644 --- a/src/video.h +++ b/src/video.h @@ -659,9 +659,9 @@ struct Video { Y[i] = clamp(luma + offsetLUT[diff] * signLUT[sign][i], 0U, 63U); } else { - if (bs.readBit()) { + + if (bs.readBit()) luma = bs.readBit() ? bs.read(6) : ((luma + lumaLUT[bs.read(3)]) & 63); - } for (int i = 0; i < 4; i++) Y[i] = luma;