Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't break if there is a cutscene dream when resting in an inn

This solution is kind of hacky, and ideally we wouldn't leave (or
reenter) the inn but I suppose it's better than breaking.
  • Loading branch information...
commit 7c2a2790828a6ab4bf14fba3a658b78da75ceab6 1 parent 21819f8
@fizzet fizzet authored
View
23 gemrb/GUIScripts/GUISTORE.py
@@ -1566,19 +1566,22 @@ def RentConfirm ():
price = Store['StoreRoomPrices'][RentIndex]
Gold = GemRB.GameGetPartyGold ()
GemRB.GameSetPartyGold (Gold-price)
- GemRB.RestParty (13, 1, RentIndex+1)
+ cutscene = GemRB.RestParty (13, 1, RentIndex+1)
if RentConfirmWindow:
RentConfirmWindow.Unload ()
Window = StoreRentWindow
- TextArea = Window.GetControl (12)
- #is there any way to change this???
- GemRB.SetToken ("HOUR", "8")
- GemRB.SetToken ("HP", "%d"%(RentIndex+1))
- TextArea.SetText (16476)
- GemRB.SetVar ("RentIndex", -1)
- Button = Window.GetControl (RentIndex+4)
- Button.SetState (IE_GUI_BUTTON_ENABLED)
- UpdateStoreRentWindow ()
+ if cutscene:
+ CloseStoreWindow ()
+ else:
+ TextArea = Window.GetControl (12)
+ #is there any way to change this???
+ GemRB.SetToken ("HOUR", "8")
+ GemRB.SetToken ("HP", "%d"%(RentIndex+1))
+ TextArea.SetText (16476)
+ GemRB.SetVar ("RentIndex", -1)
+ Button = Window.GetControl (RentIndex+4)
+ Button.SetState (IE_GUI_BUTTON_ENABLED)
+ UpdateStoreRentWindow ()
return
def RentDeny () :
View
28 gemrb/core/Game.cpp
@@ -1566,16 +1566,17 @@ void Game::TextDream()
//dream = 0 - based on area non-0 - select from list
//-1 no dream
//hp is how much hp the rest will heal
-void Game::RestParty(int checks, int dream, int hp)
+//returns true if a cutscene dream is about to be played
+bool Game::RestParty(int checks, int dream, int hp)
{
if (!(checks&REST_NOMOVE) ) {
if (!EveryoneStopped()) {
- return;
+ return false;
}
}
Actor *leader = GetPC(0, true);
if (!leader) {
- return;
+ return false;
}
Map *area = leader->GetCurrentArea();
@@ -1584,7 +1585,7 @@ void Game::RestParty(int checks, int dream, int hp)
if (!EveryoneNearPoint( area, leader->Pos, 0 ) ) {
//party too scattered
displaymsg->DisplayConstantString( STR_SCATTERED, DMC_RED );
- return;
+ return false;
}
}
@@ -1592,12 +1593,12 @@ void Game::RestParty(int checks, int dream, int hp)
//don't allow resting while in combat
if (AnyPCInCombat()) {
displaymsg->DisplayConstantString( STR_CANTRESTMONS, DMC_RED );
- return;
+ return false;
}
//don't allow resting if hostiles are nearby
if (area->AnyEnemyNearPoint(leader->Pos)) {
displaymsg->DisplayConstantString( STR_CANTRESTMONS, DMC_RED );
- return;
+ return false;
}
}
@@ -1609,13 +1610,13 @@ void Game::RestParty(int checks, int dream, int hp)
//you cannot rest here
if (area->AreaFlags&AF_NOSAVE) {
displaymsg->DisplayConstantString( STR_MAYNOTREST, DMC_RED );
- return;
+ return false;
}
//you may not rest here, find an inn
if (!(area->AreaType&(AT_OUTDOOR|AT_FOREST|AT_DUNGEON|AT_CAN_REST) ))
{
displaymsg->DisplayConstantString( STR_MAYNOTREST, DMC_RED );
- return;
+ return false;
}
//area encounters
// also advances gametime (so partial rest is possible)
@@ -1632,7 +1633,7 @@ void Game::RestParty(int checks, int dream, int hp)
hours -= hoursLeft;
// the interruption occured before any resting could be done, so just bail out
if (!hours) {
- return;
+ return false;
}
}
} else {
@@ -1656,13 +1657,15 @@ void Game::RestParty(int checks, int dream, int hp)
// abort the partial rest; we got what we wanted
if (hoursLeft) {
- return;
+ return false;
}
//movie, cutscene, and still frame dreams
+ bool cutscene = false;
if (dream>=0) {
//cutscene dreams
if (gamedata->Exists("player1d",IE_BCS_CLASS_ID, true)) {
+ cutscene = true;
PlayerDream();
} else if (gamedata->Exists("drmtxt2", IE_2DA_CLASS_ID, true)) {
TextDream();
@@ -1695,14 +1698,15 @@ void Game::RestParty(int checks, int dream, int hp)
core->GetTokenDictionary()->SetAtCopy("HOUR", hours);
//this would be bad
- if (hrsindex == -1 || restindex == -1) return;
+ if (hrsindex == -1 || restindex == -1) return cutscene;
tmpstr = core->GetString(hrsindex, 0);
//as would this
- if (!tmpstr) return;
+ if (!tmpstr) return cutscene;
core->GetTokenDictionary()->SetAtCopy("DURATION", tmpstr);
core->FreeString(tmpstr);
displaymsg->DisplayString(restindex, DMC_WHITE, 0);
+ return cutscene;
}
//timestop effect
View
2  gemrb/core/Game.h
@@ -469,7 +469,7 @@ class GEM_EXPORT Game : public Scriptable {
areas run scripts on door, infopoint, container, actors too */
void UpdateScripts();
/** runs area functionality, sets partyrested trigger */
- void RestParty(int checks, int dream, int hp);
+ bool RestParty(int checks, int dream, int hp);
/** timestop effect initiated by actor */
void TimeStop(Actor *actor, ieDword end);
/** check if the passed actor is a victim of timestop */
View
4 gemrb/plugins/GUIScript/GUIScript.cpp
@@ -9707,9 +9707,7 @@ static PyObject* GemRB_RestParty(PyObject * /*self*/, PyObject* args)
}
GET_GAME();
- game->RestParty(noareacheck, dream, hp);
- Py_INCREF( Py_None );
- return Py_None;
+ return PyInt_FromLong(game->RestParty(noareacheck, dream, hp));
}
PyDoc_STRVAR( GemRB_ChargeSpells__doc,
Please sign in to comment.
Something went wrong with that request. Please try again.