MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / save

Method save

Engine/source/console/simObjectMemento.cpp:42–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42void SimObjectMemento::save( SimObject *object )
43{
44 // Cleanup any existing state data.
45 dFree( mState );
46 mObjectName = String::EmptyString;
47
48 // Use a stream to save the state.
49 MemStream stream( 256 );
50
51 U32 writeFlags = 0;
52 SimDataBlock* db = dynamic_cast<SimDataBlock*>(object);
53 if( !db )
54 stream.write( sizeof( "return " ) - 1, "return " );
55 else
56 {
57 mIsDatablock = true;
58
59 // Cull the datablock name from the output so that
60 // we can easily replace it in case the datablock's name
61 // is already taken when we call restore(). We can't use the same
62 // setup as with non-datablock classes as the return semantics
63 // are not the same.
64
65 writeFlags |= SimObject::NoName;
66 }
67
68 object->write( stream, 0, writeFlags );
69 stream.write( (UTF8)0 );
70
71 // Steal the data away from the stream.
72 mState = (UTF8*)stream.takeBuffer();
73 mObjectName = object->getName();
74}
75
76SimObject *SimObjectMemento::restore() const
77{

Callers

nothing calls this directly

Calls 4

takeBufferMethod · 0.80
dFreeFunction · 0.50
writeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected