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