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

Method write

Engine/source/ts/tsShapeConstruct.cpp:2333–2397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2331}
2332
2333void TSShapeConstructor::ChangeSet::write(TSShape* shape, Stream& stream, const String& savePath)
2334{
2335 // First make a copy of the change-set
2336 ChangeSet output;
2337 for (S32 i = 0; i < mCommands.size(); i++)
2338 output.add(mCommands[i]);
2339
2340 // Remove all __backup__ sequences (used during Shape Editing)
2341 if (shape)
2342 {
2343 for (S32 i = 0; i < shape->sequences.size(); i++)
2344 {
2345 const char* seqName = shape->getName(shape->sequences[i].nameIndex);
2346 if (dStrStartsWith(seqName, "__backup__"))
2347 {
2348 Command cmd("removeSequence");
2349 cmd.addArgs(seqName);
2350 output.add(cmd);
2351 }
2352 }
2353 }
2354
2355 // Write the final change set to the stream
2356 for (U32 i = 0; i < output.mCommands.size(); i++)
2357 {
2358 const Command& cmd = output.mCommands[i];
2359
2360 // Write the command
2361 stream.writeTabs(1);
2362 stream.writeText("%this.");
2363
2364 stream.writeText(cmd.name);
2365 stream.writeText("(");
2366
2367 if (cmd.argc > 0)
2368 {
2369 // Use relative paths when possible
2370 String str(cmd.argv[0]);
2371 if (str.startsWith(savePath))
2372 {
2373 // Need to add "./" to a local file for the script file system. Otherwise
2374 // it will be assumed to be a full and complete path when it comes to loading.
2375 str = "./" + str.substr(savePath.length() + 1);
2376 }
2377
2378 stream.writeText("\"");
2379 stream.write(str.length(), str.c_str());
2380 stream.writeText("\"");
2381
2382 // Write remaining arguments and newline
2383 for (U32 j = 1; j < cmd.argc; j++)
2384 {
2385 // Use relative paths when possible
2386 String relStr(cmd.argv[j]);
2387 if (relStr.startsWith(savePath))
2388 relStr = relStr.substr(savePath.length() + 1);
2389
2390 stream.writeText(", \"");

Callers 1

Calls 11

dStrStartsWithFunction · 0.85
addArgsMethod · 0.80
writeTabsMethod · 0.80
startsWithMethod · 0.80
substrMethod · 0.80
sizeMethod · 0.45
addMethod · 0.45
getNameMethod · 0.45
writeTextMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected