From 2709fd910feaeefad72cd409ffefc11e83f006f4 Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Fri, 14 Mar 2008 18:23:13 +0000 Subject: [PATCH] Commented on importance of correct ordering in mission response scripts. (Oh, and r1479 _is_ a fix for the nova problem, I wasn't reading it right.) git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1481 127b21dd-08f5-0310-b4b7-95ae10353056 --- Resources/Scripts/oolite-nova-mission.js | 22 ++++++++------------ Resources/Scripts/oolite-trumbles-mission.js | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Resources/Scripts/oolite-nova-mission.js b/Resources/Scripts/oolite-nova-mission.js index f0c47323..3f6e279a 100644 --- a/Resources/Scripts/oolite-nova-mission.js +++ b/Resources/Scripts/oolite-nova-mission.js @@ -45,7 +45,6 @@ this.missionOffers = function () if (missionVariables.nova == "TWO_HRS_TO_ZERO") { mission.runMissionScreen("nova_1", "solar.png", "nova_yesno"); - log("nova.missionOffers", "Setting this.novaOffer to \"NOVA_CHOICE\""); this.novaOffer = "NOVA_CHOICE"; // use a temporary variable for the offering. this.novaMissionTimer.stop(); } @@ -77,18 +76,10 @@ this.missionOffers = function () this.choiceEvaluation = function() { - if (!this.novaOffer) + if (this.novaOffer && this.novaOffer == "NOVA_CHOICE") { - log("nova.choicesEvaluation", "Exiting early because !this.novaOffer."); - return; - } - - if (this.novaOffer == "NOVA_CHOICE") - { - log("nova.choicesEvaluation", "Evaluating this.novaOffer == \"NOVA_CHOICE\""); if (mission.choice == "YES") { - log("nova.choicesEvaluation", "mission.choice == YES, player loaded refugees."); player.useSpecialCargo(expandDescription("[oolite-nova-refugees]")); mission.setInstructionsKey("nova_missiondesc"); missionVariables.nova = "NOVA_ESCAPE_HERO"; @@ -99,7 +90,6 @@ this.choiceEvaluation = function() } else { - log("nova.choicesEvaluation", "mission.choice == " + mission.choice + ", player refused to help."); // mission.choice = "NO", or null when player launched without a choice. missionVariables.nova = "NOVA_ESCAPE_COWARD"; player.commsMessage(expandDescription("[oolite-nova-coward]"), 4.5); @@ -107,9 +97,15 @@ this.choiceEvaluation = function() missionVariables.novacount = null; } + /* IMPORTANT + The line "mission.choice = null" causes a missionChoiceWasReset() + event to occur. Our missionChoiceWasReset() handler calls back into + choiceEvaluation(). It is therefore imperative that this.novaOffer + is cleared _before_ mission.choice, or we end up in the else branch + above. + */ delete this.novaOffer; - mission.choice = null; //reset mission choice now - log("nova.choicesEvaluation", "deleted this.novaOffer, this.novaOffer is now " + (this.novaOffer ? this.novaOffer : 'undefined')); + mission.choice = null; } } diff --git a/Resources/Scripts/oolite-trumbles-mission.js b/Resources/Scripts/oolite-trumbles-mission.js index bc915920..972e3f43 100644 --- a/Resources/Scripts/oolite-trumbles-mission.js +++ b/Resources/Scripts/oolite-trumbles-mission.js @@ -87,16 +87,16 @@ this.missionScreenEnded = function () if (mission.choice == "OOLITE_TRUMBLE_YES") { // Trumble bought. - mission.choice = null; missionVariables.trumbles = "TRUMBLE_BOUGHT"; + mission.choice = null; player.credits -= 30; player.awardEquipment("EQ_TRUMBLE"); } else if (mission.choice == "OOLITE_TRUMBLE_NO") { // Trumble bought. - mission.choice = null; missionVariables.trumbles = "NOT_NOW"; + mission.choice = null; } // else it was someone else's mission screen, so we do nothing. }