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

Method readName

Engine/source/ts/tsShapeOldRead.cpp:856–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

854}
855
856S32 TSShape::readName(Stream * s, bool addName)
857{
858 static char buffer[256];
859 U32 sz;
860 S32 nameIndex = -1;
861 s->read(&sz);
862 if (sz>0 && sz<255)
863 {
864 s->read(sz,buffer);
865 buffer[sz] = '\0';
866 nameIndex = findName(buffer);
867
868 // Many modeling apps don't support spaces in names, so if the lookup
869 // failed, try the name again with spaces replaced by underscores
870 if (nameIndex < 0)
871 {
872 while (char *p = dStrchr(buffer, ' '))
873 *p = '_';
874 nameIndex = findName(buffer);
875 }
876
877 if (nameIndex<0 && addName)
878 {
879 nameIndex = names.size();
880 names.increment();
881 names.last() = buffer;
882 }
883 }
884 else
885 Con::errorf("invalid TSShape::readName length!");
886
887 return nameIndex;
888}

Callers

nothing calls this directly

Calls 6

incrementMethod · 0.80
dStrchrFunction · 0.50
errorfFunction · 0.50
readMethod · 0.45
sizeMethod · 0.45
lastMethod · 0.45

Tested by

no test coverage detected