From 457b96a8afa46375aeed6add3d5d201658dfb66d Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 9 Sep 2014 00:00:55 +0200 Subject: [PATCH] Reset bounty and crime immediately when going to jail (Fixes #1892) --- apps/openmw/mwscript/miscextensions.cpp | 1 - apps/openmw/mwworld/worldimp.cpp | 22 ++++++++++++++-------- apps/openmw/mwworld/worldimp.hpp | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 52957b00f5..6da047196f 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -871,7 +871,6 @@ namespace MWScript { MWBase::World* world = MWBase::Environment::get().getWorld(); world->goToJail(); - MWBase::Environment::get().getWorld()->getPlayer().recordCrimeId(); } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index b8c83e09b7..fdf1cff41a 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -149,7 +149,7 @@ namespace MWWorld mActivationDistanceOverride (activationDistanceOverride), mFallback(fallbackMap), mTeleportEnabled(true), mLevitationEnabled(true), mGodMode(false), mContentFiles (contentFiles), - mGoToJail(false), + mGoToJail(false), mDaysInPrison(0), mStartCell (startCell), mStartupScript(startupScript) { mPhysics = new PhysicsSystem(renderer); @@ -2810,8 +2810,19 @@ namespace MWWorld { if (!mGoToJail) { - // Save for next update, since the player should be able to read the dialog text first + // Reset bounty and forget the crime now, but don't change cell yet (the player should be able to read the dialog text first) mGoToJail = true; + + MWWorld::Ptr player = getPlayerPtr(); + + int bounty = player.getClass().getNpcStats(player).getBounty(); + player.getClass().getNpcStats(player).setBounty(0); + mPlayer->recordCrimeId(); + confiscateStolenItems(player); + + int iDaysinPrisonMod = getStore().get().find("iDaysinPrisonMod")->getInt(); + mDaysInPrison = std::max(1, bounty / iDaysinPrisonMod); + return; } else @@ -2822,13 +2833,8 @@ namespace MWWorld MWWorld::Ptr player = getPlayerPtr(); teleportToClosestMarker(player, "prisonmarker"); - int bounty = player.getClass().getNpcStats(player).getBounty(); - player.getClass().getNpcStats(player).setBounty(0); - confiscateStolenItems(player); - - int iDaysinPrisonMod = getStore().get().find("iDaysinPrisonMod")->getInt(); - int days = std::max(1, bounty / iDaysinPrisonMod); + int days = mDaysInPrison; advanceTime(days * 24); for (int i=0; irest (true); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index eddd056e01..dd77293317 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -143,6 +143,7 @@ namespace MWWorld bool mTeleportEnabled; bool mLevitationEnabled; bool mGoToJail; + int mDaysInPrison; float feetToGameUnits(float feet);