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

Method read

Engine/source/materials/materialList.cpp:148–189  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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