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

Commit 6883a32

Browse files
committed
[Bug 15970] Pass stack file version as argument to save functions.
1 parent af07da0 commit 6883a32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+252
-255
lines changed

engine/src/MCBlock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class MCBlock : public MCDLlist
8888
// MW-2012-03-04: [[ StackFile5500 ]] If 'is_ext' is true then this block has
8989
// an extension style attribute section.
9090
IO_stat load(IO_handle stream, uint32_t version, bool is_ext);
91-
IO_stat save(IO_handle stream, uint4 p_part);
91+
IO_stat save(IO_handle stream, uint4 p_part, uint32_t p_version);
9292

9393
// MW-2012-02-14: [[ FontRefs ]] To open a block, we need the parent's fontref.
9494
void open(MCFontRef parent_font);
@@ -146,7 +146,7 @@ class MCBlock : public MCDLlist
146146
void importattrs(const MCFieldCharacterStyle& x_style);
147147

148148
// MW-2012-03-04: [[ StackFile5500 ]] Measure the size of the serialized attributes.
149-
uint32_t measureattrs(void);
149+
uint32_t measureattrs(uint32_t p_version);
150150

151151
#ifdef LEGACY_EXEC
152152
void setatts(Properties which, void *value);

engine/src/aclip.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -913,23 +913,23 @@ bool MCAudioClip::isPlaying()
913913
// SAVING AND LOADING
914914
//
915915

916-
IO_stat MCAudioClip::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part)
916+
IO_stat MCAudioClip::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version)
917917
{
918-
return defaultextendedsave(p_stream, p_part);
918+
return defaultextendedsave(p_stream, p_part, p_version);
919919
}
920920

921921
IO_stat MCAudioClip::extendedload(MCObjectInputStream& p_stream, uint32_t p_version, uint4 p_length)
922922
{
923923
return defaultextendedload(p_stream, p_version, p_length);
924924
}
925925

926-
IO_stat MCAudioClip::save(IO_handle stream, uint4 p_part, bool p_force_ext)
926+
IO_stat MCAudioClip::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version)
927927
{
928928
IO_stat stat;
929929

930930
if ((stat = IO_write_uint1(OT_AUDIO_CLIP, stream)) != IO_NORMAL)
931931
return stat;
932-
if ((stat = MCObject::save(stream, p_part, false)) != IO_NORMAL)
932+
if ((stat = MCObject::save(stream, p_part, false, p_version)) != IO_NORMAL)
933933
return stat;
934934
if (osamples != NULL)
935935
{
@@ -957,7 +957,7 @@ IO_stat MCAudioClip::save(IO_handle stream, uint4 p_part, bool p_force_ext)
957957
if (flags & F_LOUDNESS)
958958
if ((stat = IO_write_uint2(loudness, stream)) != IO_NORMAL)
959959
return stat;
960-
return savepropsets(stream);
960+
return savepropsets(stream, p_version);
961961
}
962962

963963
IO_stat MCAudioClip::load(IO_handle stream, uint32_t version)

engine/src/aclip.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class MCAudioClip : public MCObject
110110
void stop(Boolean abort);
111111
bool isPlaying();
112112

113-
IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext);
114-
IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part);
113+
IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version);
114+
IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version);
115115
IO_stat load(IO_handle stream, uint32_t version);
116116
IO_stat extendedload(MCObjectInputStream& p_stream, uint32_t version, uint4 p_length);
117117

engine/src/block.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,14 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
332332
return IO_NORMAL;
333333
}
334334

335-
IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
335+
IO_stat MCBlock::save(IO_handle stream, uint4 p_part, uint32_t p_version)
336336
{
337337
IO_stat stat;
338338

339339
// MW-2012-03-04: [[ StackFile5500 ]] If the block has metadata and 5.5 stackfile
340340
// format has been requested then this is an extended block.
341341
bool t_is_ext;
342-
if (MCstackfileversion >= 5500 && getflag(F_HAS_METADATA))
342+
if (p_version >= 5500 && getflag(F_HAS_METADATA))
343343
t_is_ext = true;
344344
else
345345
t_is_ext = false;
@@ -352,7 +352,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
352352
// MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block then write out
353353
// the length of the attrs.
354354
if (t_is_ext)
355-
if ((stat = IO_write_uint2or4(measureattrs(), stream)) != IO_NORMAL)
355+
if ((stat = IO_write_uint2or4(measureattrs(p_version), stream)) != IO_NORMAL)
356356
return stat;
357357

358358
uint4 oldflags = flags;
@@ -368,7 +368,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
368368

369369
// The "has unicode" flag depends on whether the paragraph is native
370370
bool t_is_unicode;
371-
if (MCstackfileversion < 7000 && MCStringIsNative(parent->GetInternalStringRef()))
371+
if (p_version < 7000 && MCStringIsNative(parent->GetInternalStringRef()))
372372
{
373373
t_is_unicode = false;
374374
flags &= ~F_HAS_UNICODE;
@@ -380,7 +380,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
380380
}
381381

382382
// SN-2014-12-04: [[ Bug 14149 ]] Add the F_HAS_TAB flag, for legacy saving
383-
if (MCstackfileversion < 7000)
383+
if (p_version < 7000)
384384
{
385385
if (segment && segment != segment -> next())
386386
flags |= F_HAS_TAB;
@@ -437,11 +437,11 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
437437
// strings.
438438
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
439439
if (flags & F_HAS_LINK)
440-
if ((stat = IO_write_stringref_new(atts->linktext, stream, MCstackfileversion >= 7000)) != IO_NORMAL)
440+
if ((stat = IO_write_stringref_new(atts->linktext, stream, p_version >= 7000)) != IO_NORMAL)
441441
return stat;
442442
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
443443
if (flags & F_HAS_IMAGE)
444-
if ((stat = IO_write_stringref_new(atts->imagesource, stream, MCstackfileversion >= 7000)) != IO_NORMAL)
444+
if ((stat = IO_write_stringref_new(atts->imagesource, stream, p_version >= 7000)) != IO_NORMAL)
445445
return stat;
446446

447447
// MW-2012-03-04: [[ StackFile5500 ]] If this is an extended block then emit the
@@ -450,7 +450,7 @@ IO_stat MCBlock::save(IO_handle stream, uint4 p_part)
450450
{
451451
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
452452
if (flags & F_HAS_METADATA)
453-
if ((stat = IO_write_stringref_new(atts -> metadata, stream, MCstackfileversion >= 7000)) != IO_NORMAL)
453+
if ((stat = IO_write_stringref_new(atts -> metadata, stream, p_version >= 7000)) != IO_NORMAL)
454454
return stat;
455455
}
456456

@@ -2245,13 +2245,13 @@ void MCBlock::importattrs(const MCFieldCharacterStyle& p_style)
22452245
}
22462246

22472247
// SN-2014-10-31: [[ Bug 13879 ]] Update the way the string is measured.
2248-
uint32_t measure_stringref(MCStringRef p_string)
2248+
uint32_t measure_stringref(MCStringRef p_string, uint32_t p_version)
22492249
{
22502250
MCStringEncoding t_encoding;
22512251
uint32_t t_additional_bytes = 0;
22522252

22532253

2254-
if (MCstackfileversion < 7000)
2254+
if (p_version < 7000)
22552255
t_encoding = kMCStringEncodingNative;
22562256
else
22572257
t_encoding = kMCStringEncodingUTF8;
@@ -2262,7 +2262,7 @@ uint32_t measure_stringref(MCStringRef p_string)
22622262
uint32_t t_length;
22632263
t_length = MCDataGetLength(*t_data);
22642264

2265-
if (MCstackfileversion < 7000)
2265+
if (p_version < 7000)
22662266
{
22672267
// Full string is written in 5.5 format:
22682268
// - length is written as a uint2
@@ -2283,14 +2283,14 @@ uint32_t measure_stringref(MCStringRef p_string)
22832283

22842284
// MW-2012-03-04: [[ StackFile5500 ]] Utility routine for computing the length of
22852285
// a nameref when serialized to disk.
2286-
uint32_t measure_nameref(MCNameRef p_name)
2286+
uint32_t measure_nameref(MCNameRef p_name, uint32_t p_version)
22872287
{
2288-
return measure_stringref(MCNameGetString(p_name));
2288+
return measure_stringref(MCNameGetString(p_name), p_version);
22892289
}
22902290

22912291
// MW-2012-03-04: [[ StackFile5500 ]] Compute the number of bytes the attributes will
22922292
// take up when serialized.
2293-
uint32_t MCBlock::measureattrs(void)
2293+
uint32_t MCBlock::measureattrs(uint32_t p_version)
22942294
{
22952295
// If there are no attrs, then the size is 0.
22962296
if (!hasatts())
@@ -2315,11 +2315,11 @@ uint32_t MCBlock::measureattrs(void)
23152315
// MW-2012-05-04: [[ Values ]] linkText / imageSource / metaData are now uniqued
23162316
// strings.
23172317
if ((flags & F_HAS_LINK) != 0)
2318-
t_size += measure_stringref(atts -> linktext);
2318+
t_size += measure_stringref(atts -> linktext, p_version);
23192319
if ((flags & F_HAS_IMAGE) != 0)
2320-
t_size += measure_stringref(atts -> imagesource);
2320+
t_size += measure_stringref(atts -> imagesource, p_version);
23212321
if ((flags & F_HAS_METADATA) != 0)
2322-
t_size += measure_stringref((MCStringRef)atts -> metadata);
2322+
t_size += measure_stringref((MCStringRef)atts -> metadata, p_version);
23232323

23242324
return t_size;
23252325
}

engine/src/button.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4406,7 +4406,7 @@ void MCButton::trytochangetonative(void)
44064406

44074407
#define BUTTON_EXTRA_ICONGRAVITY (1 << 0)
44084408

4409-
IO_stat MCButton::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part)
4409+
IO_stat MCButton::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version)
44104410
{
44114411
// Extended data area for a button consists of:
44124412
// uint4 hover_icon;
@@ -4439,7 +4439,7 @@ IO_stat MCButton::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part)
44394439
t_stat = p_stream . WriteU32(m_icon_gravity);
44404440

44414441
if (t_stat == IO_NORMAL)
4442-
t_stat = MCObject::extendedsave(p_stream, p_part);
4442+
t_stat = MCObject::extendedsave(p_stream, p_part, p_version);
44434443

44444444
return t_stat;
44454445
}
@@ -4494,7 +4494,7 @@ IO_stat MCButton::extendedload(MCObjectInputStream& p_stream, uint32_t p_version
44944494
return t_stat;
44954495
}
44964496

4497-
IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
4497+
IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version)
44984498
{
44994499
IO_stat stat;
45004500

@@ -4519,7 +4519,8 @@ IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
45194519
if (m_icon_gravity != kMCGravityNone)
45204520
t_has_extension = true;
45214521

4522-
if ((stat = MCObject::save(stream, p_part, t_has_extension || p_force_ext)) != IO_NORMAL)
4522+
if ((stat = MCObject::save(stream, p_part, t_has_extension || p_force_ext,
4523+
p_version)) != IO_NORMAL)
45234524
return stat;
45244525

45254526
if (flags & F_HAS_ICONS)
@@ -4535,7 +4536,7 @@ IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
45354536
// we need to rely on the F_LABEL flag
45364537
if (flags & F_LABEL)
45374538
{
4538-
if (MCstackfileversion < 7000)
4539+
if (p_version < 7000)
45394540
{
45404541
if ((stat = IO_write_stringref_legacy(label, stream, hasunicode())) != IO_NORMAL)
45414542
return stat;
@@ -4561,13 +4562,13 @@ IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
45614562
return stat;
45624563
}
45634564
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode.
4564-
if ((stat = IO_write_nameref_new(menuname, stream, MCstackfileversion >= 7000)) != IO_NORMAL)
4565+
if ((stat = IO_write_nameref_new(menuname, stream, p_version >= 7000)) != IO_NORMAL)
45654566
return stat;
45664567
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode; otherwise use
45674568
// legacy unicode output.
45684569
if (flags & F_MENU_STRING)
45694570
{
4570-
if (MCstackfileversion < 7000)
4571+
if (p_version < 7000)
45714572
{
45724573
if ((stat = IO_write_stringref_legacy(menustring, stream, hasunicode())) != IO_NORMAL)
45734574
return stat;
@@ -4596,7 +4597,7 @@ IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
45964597

45974598
// MW-2013-11-19: [[ UnicodeFileFormat ]] If sfv >= 7000, use unicode; otherwise use
45984599
// legacy unicode output.
4599-
if (MCstackfileversion < 7000)
4600+
if (p_version < 7000)
46004601
{
46014602
if ((stat = IO_write_stringref_legacy(acceltext, stream, hasunicode())) != IO_NORMAL)
46024603
return stat;
@@ -4614,15 +4615,15 @@ IO_stat MCButton::save(IO_handle stream, uint4 p_part, bool p_force_ext)
46144615
if ((stat = IO_write_uint1(mnemonic, stream)) != IO_NORMAL)
46154616
return stat;
46164617

4617-
if ((stat = savepropsets(stream)) != IO_NORMAL)
4618+
if ((stat = savepropsets(stream, p_version)) != IO_NORMAL)
46184619
return stat;
46194620

46204621
MCCdata *tptr = bdata;
46214622
if (tptr != NULL && (p_part == 0 || !getflag(F_SHARED_HILITE)))
46224623
{
46234624
do
46244625
{
4625-
if ((stat = tptr->save(stream, OT_BDATA, p_part)) != IO_NORMAL)
4626+
if ((stat = tptr->save(stream, OT_BDATA, p_part, p_version)) != IO_NORMAL)
46264627
return stat;
46274628
tptr = (MCCdata *)tptr->next();
46284629
}

engine/src/button.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ class MCButton : public MCControl
204204
virtual void unlockshape(MCObjectShape& shape);
205205

206206
// virtual functions from MCControl
207-
virtual IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext);
208-
virtual IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part);
207+
virtual IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version);
208+
virtual IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version);
209209
virtual IO_stat load(IO_handle stream, uint32_t version);
210210
virtual IO_stat extendedload(MCObjectInputStream& p_stream, uint32_t version, uint4 p_length);
211211

engine/src/card.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,9 +3368,9 @@ IO_stat MCCard::extendedload(MCObjectInputStream& p_stream, uint32_t p_version,
33683368
return defaultextendedload(p_stream, p_version, p_length);
33693369
}
33703370

3371-
IO_stat MCCard::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part)
3371+
IO_stat MCCard::extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version)
33723372
{
3373-
return defaultextendedsave(p_stream, p_part);
3373+
return defaultextendedsave(p_stream, p_part, p_version);
33743374
}
33753375

33763376
IO_stat MCCard::load(IO_handle stream, uint32_t version)
@@ -3489,7 +3489,7 @@ IO_stat MCCard::loadobjects(IO_handle stream, uint32_t version)
34893489
return checkloadstat(stat);
34903490
}
34913491

3492-
IO_stat MCCard::save(IO_handle stream, uint4 p_part, bool p_force_ext)
3492+
IO_stat MCCard::save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version)
34933493
{
34943494
IO_stat stat;
34953495

@@ -3501,26 +3501,26 @@ IO_stat MCCard::save(IO_handle stream, uint4 p_part, bool p_force_ext)
35013501
//---- 2.7+:
35023502
// . F_OPAQUE valid - must be true in older versions
35033503
// . ink valid - must be GXcopy in older versions
3504-
if (MCstackfileversion < 2700)
3504+
if (p_version < 2700)
35053505
{
35063506
t_old_flags = flags;
35073507
t_old_ink = GXcopy;
35083508
flags |= F_OPAQUE;
35093509
}
35103510
//---- 2.7+
35113511

3512-
if ((stat = MCObject::save(stream, p_part, p_force_ext)) != IO_NORMAL)
3512+
if ((stat = MCObject::save(stream, p_part, p_force_ext, p_version)) != IO_NORMAL)
35133513
return stat;
35143514

35153515
//---- 2.7+
3516-
if (MCstackfileversion < 2700)
3516+
if (p_version < 2700)
35173517
{
35183518
flags = t_old_flags;
35193519
ink = t_old_ink;
35203520
}
35213521
//---- 2.7+
35223522

3523-
if ((stat = savepropsets(stream)) != IO_NORMAL)
3523+
if ((stat = savepropsets(stream, p_version)) != IO_NORMAL)
35243524
return stat;
35253525
if (objptrs != NULL)
35263526
{
@@ -3536,7 +3536,7 @@ IO_stat MCCard::save(IO_handle stream, uint4 p_part, bool p_force_ext)
35363536
return IO_NORMAL;
35373537
}
35383538

3539-
IO_stat MCCard::saveobjects(IO_handle p_stream, uint4 p_part)
3539+
IO_stat MCCard::saveobjects(IO_handle p_stream, uint4 p_part, uint32_t p_version)
35403540
{
35413541
IO_stat t_stat;
35423542

@@ -3546,7 +3546,7 @@ IO_stat MCCard::saveobjects(IO_handle p_stream, uint4 p_part)
35463546
t_objptr = objptrs;
35473547
do
35483548
{
3549-
if ((t_stat = t_objptr -> getref() -> save(p_stream, p_part, false)) != IO_NORMAL)
3549+
if ((t_stat = t_objptr -> getref() -> save(p_stream, p_part, false, p_version)) != IO_NORMAL)
35503550
return t_stat;
35513551
t_objptr = t_objptr -> next();
35523552
}

engine/src/card.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ class MCCard : public MCObject
117117
// MCCard functions
118118
IO_stat load(IO_handle stream, uint32_t version);
119119
IO_stat extendedload(MCObjectInputStream& p_stream, uint32_t version, uint4 p_length);
120-
IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext);
121-
IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part);
120+
IO_stat save(IO_handle stream, uint4 p_part, bool p_force_ext, uint32_t p_version);
121+
IO_stat extendedsave(MCObjectOutputStream& p_stream, uint4 p_part, uint32_t p_version);
122122

123-
IO_stat saveobjects(IO_handle stream, uint4 p_part);
123+
IO_stat saveobjects(IO_handle stream, uint4 p_part, uint32_t p_version);
124124
IO_stat loadobjects(IO_handle stream, uint32_t version);
125125

126126
void kfocusset(MCControl *target);

engine/src/cdata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ IO_stat MCCdata::load(IO_handle stream, MCObject *parent, uint32_t version)
146146
return IO_NORMAL;
147147
}
148148

149-
IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part)
149+
IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part, uint32_t p_version)
150150
{
151151
IO_stat stat;
152152

@@ -177,7 +177,7 @@ IO_stat MCCdata::save(IO_handle stream, Object_type type, uint4 p_part)
177177
if (tptr != NULL)
178178
do
179179
{
180-
if ((stat = tptr->save(stream, p_part)) != IO_NORMAL)
180+
if ((stat = tptr->save(stream, p_part, p_version)) != IO_NORMAL)
181181
return stat;
182182
tptr = (MCParagraph *)tptr->next();
183183
}

0 commit comments

Comments
 (0)