Skip to content

Commit 687f008

Browse files
committed
[[ Bug 13569 ]] Make sure changes to player in preOpenCard are not visible to the user
1 parent 06ec955 commit 687f008

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

docs/notes/bugfix-13569.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# changes to [[Player]] in preOpenCard are visible to user

engine/src/stack3.cpp

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,11 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
10521052
// again - in particular, players will keep playing.
10531053
curcard->open();
10541054

1055+
10551056
// MW-2011-11-23: [[ Bug ]] Close the old card here to ensure no players
10561057
// linger longer than they should.
10571058
oldcard -> close();
1059+
10581060

10591061
// MW-2011-09-12: [[ MacScroll ]] Use 'getnextscroll()' to see if anything needs
10601062
// changing on that score.
@@ -1067,12 +1069,39 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
10671069
updatecardsize();
10681070

10691071
// MW-2008-10-31: [[ ParentScripts ]] Send preOpenControl appropriately
1070-
if (curcard -> openbackgrounds(true, oldcard) == ES_ERROR
1071-
|| curcard != card || !opened
1072-
|| curcard->message(MCM_preopen_card) == ES_ERROR
1073-
|| curcard != card || !opened
1074-
|| curcard -> opencontrols(true) == ES_ERROR
1075-
|| curcard != card || !opened)
1072+
bool t_error;
1073+
t_error = false;
1074+
1075+
if (!t_error)
1076+
t_error = curcard -> openbackgrounds(true, oldcard) == ES_ERROR || curcard != card || !opened;
1077+
1078+
if (!t_error)
1079+
{
1080+
// PM-2014-10-13: [[ Bug 13569 ]] Hide player to avoid redraw issue on preOpenCard
1081+
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
1082+
if (t_player -> getstack() == curcard -> getstack())
1083+
{
1084+
MCExecPoint ep(nil,nil,nil);
1085+
ep.setboolean(False);
1086+
t_player -> setprop(0, P_VISIBLE, ep, False);
1087+
}
1088+
1089+
t_error = curcard->message(MCM_preopen_card) == ES_ERROR || curcard != card || !opened;
1090+
1091+
// PM-2014-10-13: [[ Bug 13569 ]] when preOpenCard handler finish, show the player
1092+
for(MCPlayer *t_player = MCplayers; t_player != nil; t_player = t_player -> getnextplayer())
1093+
if (t_player -> getstack() == curcard -> getstack())
1094+
{
1095+
MCExecPoint ep(nil,nil,nil);
1096+
ep.setboolean(True);
1097+
t_player -> setprop(0, P_VISIBLE, ep, False);
1098+
}
1099+
}
1100+
1101+
if (!t_error)
1102+
t_error = curcard -> opencontrols(true) == ES_ERROR || curcard != card || !opened;
1103+
1104+
if (t_error)
10761105
{
10771106
// MW-2011-08-18: [[ Redraw ]] Use global screen lock
10781107
MCRedrawUnlockScreen();
@@ -1086,6 +1115,7 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
10861115
return ES_ERROR;
10871116
}
10881117
}
1118+
10891119
MClockmessages = True;
10901120

10911121
if (mode == WM_TOP_LEVEL || mode == WM_TOP_LEVEL_LOCKED)
@@ -1166,6 +1196,7 @@ Exec_stat MCStack::setcard(MCCard *card, Boolean recent, Boolean dynamic)
11661196
if (MCmousestackptr == this && !mfocus(MCmousex, MCmousey))
11671197
curcard->message(MCM_mouse_enter);
11681198
}
1199+
11691200
return ES_NORMAL;
11701201
}
11711202

0 commit comments

Comments
 (0)