Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions engine/src/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ MCObject::MCObject()

// MW-2012-10-10: [[ IdCache ]]
m_in_id_cache = false;

// IM-2013-04-16: Initialize to false;
m_script_encrypted = false;
}

MCObject::MCObject(const MCObject &oref) : MCDLlist(oref)
Expand Down Expand Up @@ -195,6 +198,7 @@ MCObject::MCObject(const MCObject &oref) : MCDLlist(oref)
}
opened = 0;
script = strclone(oref.script);
m_script_encrypted = oref.m_script_encrypted;
hlist = NULL;
scriptdepth = 0;
state = oref.state & ~CS_SELECTED;
Expand Down Expand Up @@ -2160,12 +2164,12 @@ Boolean MCObject::parsescript(Boolean report, Boolean force)
if (hlist == NULL)
hlist = new MCHandlerlist;

getstack() -> unsecurescript(script);
getstack() -> unsecurescript(this);

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

getstack() -> securescript(script);
getstack() -> securescript(this);

if (t_stat != PS_NORMAL)
{
Expand Down Expand Up @@ -2777,7 +2781,7 @@ IO_stat MCObject::load(IO_handle stream, const char *version)
if ((stat = IO_read_string(script, stream)) != IO_NORMAL)
return stat;

getstack() -> securescript(script);
getstack() -> securescript(this);
}

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

if (script != nil)
getstack() -> securescript(script);
getstack() -> securescript(this);
}

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

getstack() -> securescript(script);
getstack() -> securescript(this);
}

if (addflags & AF_BLEND_LEVEL)
Expand Down Expand Up @@ -3055,9 +3059,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
}
if (flags & F_SCRIPT && !(addflags & AF_LONG_SCRIPT))
{
getstack() -> unsecurescript(script);
getstack() -> unsecurescript(this);
stat = IO_write_string(script, stream);
getstack() -> securescript(script);
getstack() -> securescript(this);
if (stat != IO_NORMAL)
return stat;
}
Expand Down Expand Up @@ -3177,9 +3181,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
{
MCObjectOutputStream *t_stream = nil;
/* UNCHECKED */ MCStackSecurityCreateObjectOutputStream(stream, t_stream);
getstack() -> unsecurescript(script);
getstack() -> unsecurescript(this);
stat = t_stream -> WriteCString(script);
getstack() -> securescript(script);
getstack() -> securescript(this);
if (stat == IO_NORMAL)
stat = extendedsave(*t_stream, p_part);
if (stat == IO_NORMAL)
Expand Down Expand Up @@ -3216,9 +3220,9 @@ IO_stat MCObject::save(IO_handle stream, uint4 p_part, bool p_force_ext)
}
else if (addflags & AF_LONG_SCRIPT)
{
getstack() -> unsecurescript(script);
getstack() -> unsecurescript(this);
stat = IO_write_string(script, stream, 4);
getstack() -> securescript(script);
getstack() -> securescript(this);
if (stat != IO_NORMAL)
return stat;
}
Expand Down
4 changes: 4 additions & 0 deletions engine/src/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ class MCObject : public MCDLlist
// MW-2012-10-10: [[ IdCache ]]
bool m_in_id_cache : 1;

// IM-2013-04-16: [[ BZ 10848 ]] // flag to record encrypted state of object script
bool m_script_encrypted : 1;

char *tooltip;

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

friend class MCObjectHandle;
friend class MCEncryptedStack;
};

class MCObjectList : public MCDLlist
Expand Down
6 changes: 3 additions & 3 deletions engine/src/objectprops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ Exec_stat MCObject::getprop(uint4 parid, Properties which, MCExecPoint &ep, Bool
}
if (script != nil)
{
getstack() -> unsecurescript(script);
getstack() -> unsecurescript(this);
ep.copysvalue(script);
getstack() -> securescript(script);
getstack() -> securescript(this);
}
else
ep . clear();
Expand Down Expand Up @@ -860,7 +860,7 @@ Exec_stat MCObject::setscriptprop(MCExecPoint& ep)
else
script = data.clone();

getstack() -> securescript(script);
getstack() -> securescript(this);

flags |= F_SCRIPT;
if (MCModeCanSetObjectScript(obj_id))
Expand Down
4 changes: 2 additions & 2 deletions engine/src/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class MCStack : public MCObject
Boolean hcstack();

virtual bool iskeyed() { return true; }
virtual void securescript(char*& script) { }
virtual void unsecurescript(char *script) { }
virtual void securescript(MCObject *) { }
virtual void unsecurescript(MCObject *) { }

Boolean islocked();
Boolean isiconic();
Expand Down