Skip to content

Commit 77658f7

Browse files
livecodestephenrunrevmark
authored andcommitted
[[ Bug 12647 ]] Save the time when locking movements and apply an offset to each movement when unlocking movements
1 parent 264107f commit 77658f7

7 files changed

Lines changed: 55 additions & 25 deletions

File tree

engine/src/cmdss.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ Exec_stat MCLock::exec(MCExecPoint &ep)
11361136
MClockmessages = True;
11371137
break;
11381138
case LC_MOVES:
1139-
MClockmoves = True;
1139+
MCscreen->setlockmoves(True);
11401140
break;
11411141
case LC_RECENT:
11421142
MClockrecent = True;
@@ -2004,7 +2004,7 @@ Exec_stat MCUnlock::exec(MCExecPoint &ep)
20042004
MClockmessages = False;
20052005
break;
20062006
case LC_MOVES:
2007-
MClockmoves = False;
2007+
MCscreen->setlockmoves(False);
20082008
break;
20092009
case LC_RECENT:
20102010
MClockrecent = False;

engine/src/globals.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ Boolean MClockcolormap;
404404
Boolean MClockerrors;
405405
Boolean MClockmenus;
406406
Boolean MClockmessages;
407-
Boolean MClockmoves;
408407
Boolean MClockrecent;
409408
Boolean MCtwelvetime = True;
410409
Boolean MCuseprivatecmap;
@@ -761,7 +760,6 @@ void X_clear_globals(void)
761760
MClockerrors = False;
762761
MClockmenus = False;
763762
MClockmessages = False;
764-
MClockmoves = False;
765763
MClockrecent = False;
766764
MCtwelvetime = True;
767765
MCuseprivatecmap = False;

engine/src/globals.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ extern Boolean MClockcolormap;
315315
extern Boolean MClockerrors;
316316
extern Boolean MClockmenus;
317317
extern Boolean MClockmessages;
318-
extern Boolean MClockmoves;
319318
extern Boolean MClockrecent;
320319
extern Boolean MCtwelvetime;
321320
extern Boolean MCuseprivatecmap;

engine/src/property.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,14 @@ Exec_stat MCProperty::set(MCExecPoint &ep)
19901990
case P_LOCK_MESSAGES:
19911991
return ep.getboolean(MClockmessages, line, pos, EE_PROPERTY_NAB);
19921992
case P_LOCK_MOVES:
1993-
return ep.getboolean(MClockmoves, line, pos, EE_PROPERTY_NAB);
1993+
{
1994+
Boolean t_new_value;
1995+
Exec_stat t_stat = ep.getboolean(t_new_value, line, pos, EE_PROPERTY_NAB);
1996+
if (t_stat == ES_NORMAL) {
1997+
MCscreen->setlockmoves(t_new_value);
1998+
}
1999+
return t_stat;
2000+
}
19942001
case P_LOCK_RECENT:
19952002
return ep.getboolean(MClockrecent, line, pos, EE_PROPERTY_NAB);
19962003
case P_PRIVATE_COLORS:
@@ -3400,7 +3407,7 @@ Exec_stat MCProperty::eval(MCExecPoint &ep)
34003407
ep.setboolean(MClockmessages);
34013408
break;
34023409
case P_LOCK_MOVES:
3403-
ep.setboolean(MClockmoves);
3410+
ep.setboolean(MCscreen->getlockmoves());
34043411
break;
34053412
case P_LOCK_RECENT:
34063413
ep.setboolean(MClockrecent);

engine/src/uidc.cpp

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ MCUIDC::MCUIDC()
193193
nmessages = maxmessages = 0;
194194
messages = NULL;
195195
moving = NULL;
196+
lockmoves = False;
197+
locktime = 0.0;
196198
ncolors = 0;
197199
colors = NULL;
198200
allocs = NULL;
@@ -1079,6 +1081,33 @@ Boolean MCUIDC::handlepending(real8& curtime, real8& eventtime, Boolean dispatch
10791081
return t_handled;
10801082
}
10811083

1084+
1085+
Boolean MCUIDC::getlockmoves() const
1086+
{
1087+
return lockmoves;
1088+
}
1089+
1090+
void MCUIDC::setlockmoves(Boolean b)
1091+
{
1092+
lockmoves = b;
1093+
1094+
if (lockmoves) {
1095+
// then save the time the lock started
1096+
locktime = MCS_time();
1097+
1098+
} else {
1099+
// adjust the start time of each movement.
1100+
real8 offset = MCS_time() - locktime;
1101+
if (moving != NULL) {
1102+
MCMovingList *mptr = moving;
1103+
do {
1104+
mptr->starttime += offset;
1105+
mptr = mptr->next();
1106+
} while (mptr != moving);
1107+
}
1108+
}
1109+
}
1110+
10821111
void MCUIDC::addmove(MCObject *optr, MCPoint *pts, uint2 npts,
10831112
real8 &duration, Boolean waiting)
10841113
{
@@ -1126,7 +1155,11 @@ void MCUIDC::addmove(MCObject *optr, MCPoint *pts, uint2 npts,
11261155
optr -> setrect(newrect);
11271156
}
11281157

1129-
mptr->starttime = MCS_time();
1158+
if (lockmoves) {
1159+
mptr->starttime = locktime;
1160+
} else {
1161+
mptr->starttime = MCS_time();
1162+
}
11301163
}
11311164

11321165
void MCUIDC::listmoves(MCExecPoint &ep)
@@ -1186,21 +1219,14 @@ void MCUIDC::stopmove(MCObject *optr, Boolean finish)
11861219

11871220
void MCUIDC::handlemoves(real8 &curtime, real8 &eventtime)
11881221
{
1189-
static real8 lasttime;
1222+
if (lockmoves)
1223+
return;
11901224
eventtime = curtime + (real8)MCsyncrate / 1000.0;
11911225
MCMovingList *mptr = moving;
11921226
Boolean moved = False;
11931227
Boolean done = False;
11941228
do
11951229
{
1196-
if (MClockmoves)
1197-
{
1198-
if (lasttime != 0.0)
1199-
mptr->starttime += curtime - lasttime;
1200-
mptr = mptr->next();
1201-
}
1202-
else
1203-
{
12041230
MCRectangle rect = mptr->object->getrect();
12051231
MCRectangle newrect = rect;
12061232
real8 dt = 0.0;
@@ -1267,13 +1293,8 @@ void MCUIDC::handlemoves(real8 &curtime, real8 &eventtime)
12671293
}
12681294
else
12691295
mptr = mptr->next();
1270-
}
12711296
}
12721297
while (mptr != NULL && mptr != moving);
1273-
if (MClockmoves)
1274-
lasttime = curtime;
1275-
else
1276-
lasttime = 0.0;
12771298

12781299
// MW-2012-12-09: [[ Bug 9905 ]] Make sure we update the screen if something
12791300
// moved (previously it only did so if there were still things to move also!).

engine/src/uidc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ class MCUIDC
243243
protected:
244244
MCMessageList *messages;
245245
MCMovingList *moving;
246+
Boolean lockmoves;
247+
real8 locktime;
246248
uint4 messageid;
247249
uint2 nmessages;
248250
uint2 maxmessages;
@@ -572,6 +574,8 @@ class MCUIDC
572574

573575
void listmessages(MCExecPoint &ep);
574576
Boolean handlepending(real8 &curtime, real8 &eventtime, Boolean dispatch);
577+
Boolean getlockmoves() const;
578+
void setlockmoves(Boolean b);
575579
void addmove(MCObject *optr, MCPoint *pts, uint2 npts,
576580
real8 &duration, Boolean waiting);
577581
void listmoves(MCExecPoint &ep);

engine/src/util.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ void MCU_resetprops(Boolean update)
148148
}
149149
}
150150
MCerrorlock = 0;
151-
MClockerrors = MClockmessages = MClockmoves = MClockrecent = False;
151+
MClockerrors = MClockmessages = MClockrecent = False;
152+
MCscreen->setlockmoves(False);
152153
MCerrorlockptr = NULL;
153154
MCinterrupt = False;
154155
MCdragspeed = 0;
@@ -167,7 +168,7 @@ void MCU_saveprops(MCSaveprops &sp)
167168
sp.errorlockptr = MCerrorlockptr;
168169
sp.lockerrors = MClockerrors;
169170
sp.lockmessages = MClockmessages;
170-
sp.lockmoves = MClockmoves;
171+
sp.lockmoves = MCscreen->getlockmoves();
171172
sp.lockrecent = MClockrecent;
172173
sp.interrupt = MCinterrupt;
173174
sp.dragspeed = MCdragspeed;
@@ -189,7 +190,7 @@ void MCU_restoreprops(MCSaveprops &sp)
189190
MCerrorlockptr = sp.errorlockptr;
190191
MClockerrors = sp.lockerrors;
191192
MClockmessages = sp.lockmessages;
192-
MClockmoves = sp.lockmoves;
193+
MCscreen->setlockmoves(sp.lockmoves);
193194
MClockrecent = sp.lockrecent;
194195
MCinterrupt = sp.interrupt;
195196
MCdragspeed = sp.dragspeed;

0 commit comments

Comments
 (0)