Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 8ffab85

Browse files
committed
add flag to MCObject to indicate script encryption state
1 parent cfcf03e commit 8ffab85

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

engine/src/object.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ MCObject::MCObject()
146146

147147
// MW-2012-10-10: [[ IdCache ]]
148148
m_in_id_cache = false;
149+
150+
// IM-2013-04-16: Initialize to false;
151+
m_script_encrypted = false;
149152
}
150153

151154
MCObject::MCObject(const MCObject &oref) : MCDLlist(oref)
@@ -195,6 +198,7 @@ MCObject::MCObject(const MCObject &oref) : MCDLlist(oref)
195198
}
196199
opened = 0;
197200
script = strclone(oref.script);
201+
m_script_encrypted = oref.m_script_encrypted;
198202
hlist = NULL;
199203
scriptdepth = 0;
200204
state = oref.state & ~CS_SELECTED;
@@ -2160,12 +2164,12 @@ Boolean MCObject::parsescript(Boolean report, Boolean force)
21602164
if (hlist == NULL)
21612165
hlist = new MCHandlerlist;
21622166

2163-
getstack() -> unsecurescript(script);
2167+
getstack() -> unsecurescript(this);
21642168

21652169
Parse_stat t_stat;
21662170
t_stat = hlist -> parse(this, script);
21672171

2168-
getstack() -> securescript(script);
2172+
getstack() -> securescript(this);
21692173

21702174
if (t_stat != PS_NORMAL)
21712175
{
@@ -2777,7 +2781,7 @@ IO_stat MCObject::load(IO_handle stream, const char *version)
27772781
if ((stat = IO_read_string(script, stream)) != IO_NORMAL)
27782782
return stat;
27792783

2780-
getstack() -> securescript(script);
2784+
getstack() -> securescript(this);
27812785
}
27822786

27832787
if ((stat = IO_read_uint2(&dflags, stream)) != IO_NORMAL)
@@ -2898,7 +2902,7 @@ IO_stat MCObject::load(IO_handle stream, const char *version)
28982902
t_length -= script == NULL ? 1 : strlen(script) + 1;
28992903

29002904
if (script != nil)
2901-
getstack() -> securescript(script);
2905+
getstack() -> securescript(this);
29022906
}
29032907

29042908
if (stat == IO_NORMAL && t_length > 0)
@@ -2932,7 +2936,7 @@ IO_stat MCObject::load(IO_handle stream, const char *version)
29322936
return stat;
29332937
flags |= F_SCRIPT;
29342938

2935-
getstack() -> securescript(script);
2939+
getstack() -> securescript(this);
29362940
}
29372941

29382942
if (addflags & AF_BLEND_LEVEL)
@@ -3055,9 +3059,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
30553059
}
30563060
if (flags & F_SCRIPT && !(addflags & AF_LONG_SCRIPT))
30573061
{
3058-
getstack() -> unsecurescript(script);
3062+
getstack() -> unsecurescript(this);
30593063
stat = IO_write_string(script, stream);
3060-
getstack() -> securescript(script);
3064+
getstack() -> securescript(this);
30613065
if (stat != IO_NORMAL)
30623066
return stat;
30633067
}
@@ -3177,9 +3181,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
31773181
{
31783182
MCObjectOutputStream *t_stream = nil;
31793183
/* UNCHECKED */ MCStackSecurityCreateObjectOutputStream(stream, t_stream);
3180-
getstack() -> unsecurescript(script);
3184+
getstack() -> unsecurescript(this);
31813185
stat = t_stream -> WriteCString(script);
3182-
getstack() -> securescript(script);
3186+
getstack() -> securescript(this);
31833187
if (stat == IO_NORMAL)
31843188
stat = extendedsave(*t_stream, p_part);
31853189
if (stat == IO_NORMAL)
@@ -3216,9 +3220,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
32163220
}
32173221
else if (addflags & AF_LONG_SCRIPT)
32183222
{
3219-
getstack() -> unsecurescript(script);
3223+
getstack() -> unsecurescript(this);
32203224
stat = IO_write_string(script, stream, 4);
3221-
getstack() -> securescript(script);
3225+
getstack() -> securescript(this);
32223226
if (stat != IO_NORMAL)
32233227
return stat;
32243228
}

engine/src/object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ class MCObject : public MCDLlist
207207
// MW-2012-10-10: [[ IdCache ]]
208208
bool m_in_id_cache : 1;
209209

210+
// IM-2013-04-16: [[ BZ 10848 ]] // flag to record encrypted state of object script
211+
bool m_script_encrypted : 1;
212+
210213
char *tooltip;
211214

212215
// MW-2008-10-20: Pointer to the parent script's weak object reference.
@@ -761,6 +764,7 @@ class MCObject : public MCDLlist
761764
Exec_stat mode_getprop(uint4 parid, Properties which, MCExecPoint &, const MCString &carray, Boolean effective);
762765

763766
friend class MCObjectHandle;
767+
friend class MCEncryptedStack;
764768
};
765769

766770
class MCObjectList : public MCDLlist

engine/src/objectprops.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ Exec_stat MCObject::getprop(uint4 parid, Properties which, MCExecPoint &ep, Bool
303303
}
304304
if (script != nil)
305305
{
306-
getstack() -> unsecurescript(script);
306+
getstack() -> unsecurescript(this);
307307
ep.copysvalue(script);
308-
getstack() -> securescript(script);
308+
getstack() -> securescript(this);
309309
}
310310
else
311311
ep . clear();
@@ -860,7 +860,7 @@ Exec_stat MCObject::setscriptprop(MCExecPoint& ep)
860860
else
861861
script = data.clone();
862862

863-
getstack() -> securescript(script);
863+
getstack() -> securescript(this);
864864

865865
flags |= F_SCRIPT;
866866
if (MCModeCanSetObjectScript(obj_id))

engine/src/stack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ class MCStack : public MCObject
251251
Boolean hcstack();
252252

253253
virtual bool iskeyed() { return true; }
254-
virtual void securescript(char*& script) { }
255-
virtual void unsecurescript(char *script) { }
254+
virtual void securescript(MCObject *) { }
255+
virtual void unsecurescript(MCObject *) { }
256256

257257
Boolean islocked();
258258
Boolean isiconic();

0 commit comments

Comments
 (0)