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

Method read

Engine/source/materials/materialList.cpp:158–199  ·  view source on GitHub ↗

--------------------------------------

Source from the content-addressed store, hash-verified

156
157//--------------------------------------
158bool MaterialList::read(Stream &stream)
159{
160 free();
161
162 // check the stream version
163 U8 version;
164 if ( stream.read(&version) && version != BINARY_FILE_VERSION)
165 return readText(stream,version);
166
167 // how many materials?
168 U32 count;
169 if ( !stream.read(&count) )
170 return false;
171
172 // pre-size the vectors for efficiency
173 mMaterialNames.reserve(count);
174
175 // read in the materials
176 for (U32 i=0; i<count; i++)
177 {
178 // Load the bitmap name
179 char buffer[256];
180 stream.readString(buffer);
181 if( !buffer[0] )
182 {
183 AssertWarn(0, "MaterialList::read: error reading stream");
184 return false;
185 }
186
187 // Material paths are a legacy of Tribes tools,
188 // strip them off...
189 char *name = &buffer[dStrlen(buffer)];
190 while (name != buffer && name[-1] != '/' && name[-1] != '\\')
191 name--;
192
193 // Add it to the list
194 mMaterialNames.push_back(name);
195 mMatInstList.push_back(NULL);
196 }
197
198 return (stream.getStatus() == Stream::Ok);
199}
200
201//--------------------------------------
202bool MaterialList::write(Stream &stream)

Callers 2

readTextMethod · 0.45
mathReadFunction · 0.45

Calls 6

freeFunction · 0.85
dStrlenFunction · 0.50
reserveMethod · 0.45
readStringMethod · 0.45
push_backMethod · 0.45
getStatusMethod · 0.45

Tested by

no test coverage detected