161 {
162 uint32 check = 0, nameLen;
163 check += fread(&spawn.flags,
sizeof(
uint32), 1, rf);
164
165 if (!check)
166 {
167 if (ferror(rf))
168 {
169 std::cout << "Error reading ModelSpawn!\n";
170 }
171 return false;
172 }
173 check += fread(&spawn.adtId,
sizeof(
uint16), 1, rf);
174 check += fread(&spawn.ID,
sizeof(
uint32), 1, rf);
175 check += fread(&spawn.iPos, sizeof(float), 3, rf);
176 check += fread(&spawn.iRot, sizeof(float), 3, rf);
177 check += fread(&spawn.iScale, sizeof(float), 1, rf);
179 if (has_bound)
180 {
181 Vector3 bLow, bHigh;
182 check += fread(&bLow, sizeof(float), 3, rf);
183 check += fread(&bHigh, sizeof(float), 3, rf);
184 spawn.iBound = G3D::AABox(bLow, bHigh);
185 }
186 check += fread(&nameLen,
sizeof(
uint32), 1, rf);
187 if (check !=
uint32(has_bound ? 17 : 11))
188 {
189 std::cout << "Error reading ModelSpawn!\n";
190 return false;
191 }
192 char nameBuff[500];
193 if (nameLen > 500)
194 {
195 std::cout << "Error reading ModelSpawn, file name too long!\n";
196 return false;
197 }
198 check = fread(nameBuff, sizeof(char), nameLen, rf);
199 if (check != nameLen)
200 {
201 std::cout << "Error reading ModelSpawn!\n";
202 return false;
203 }
204 spawn.name = std::string(nameBuff, nameLen);
205 return true;
206 }
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
@ MOD_HAS_BOUND
Definition: ModelInstance.h:38