void TwoDAFile::load(Common::SeekableReadStream &twoda) { clear(); readHeader(twoda); if ((_id != k2DAID) && (_id != k2DAIDTab)) throw Common::Exception("Not a 2DA file"); if ((_version != kVersion2a) && (_version != kVersion2b)) throw Common::Exception("Unsupported 2DA file version %08X", _version); Common::UString lineRest = Common::readStringLine(twoda, Common::kEncodingASCII); try { if (_version == kVersion2a) read2a(twoda); else if (_version == kVersion2b) read2b(twoda); // Create the map to quickly translate headers to column indices createHeaderMap(); if (twoda.err()) throw Common::Exception(Common::kReadError); } catch (Common::Exception &e) { e.add("Failed reading 2DA file"); throw; } }
void TwoDAFile::load(Common::SeekableReadStream &twoda) { readHeader(twoda); if ((_id != k2DAID) && (_id != k2DAIDTab)) throw Common::Exception("Not a 2DA file (%s)", Common::debugTag(_id).c_str()); if ((_version != kVersion2a) && (_version != kVersion2b)) throw Common::Exception("Unsupported 2DA file version %s", Common::debugTag(_version).c_str()); // Ignore the rest of the line; it's garbage Common::readStringLine(twoda, Common::kEncodingASCII); try { if (_version == kVersion2a) read2a(twoda); // ASCII else if (_version == kVersion2b) read2b(twoda); // Binary // Create the map to quickly translate headers to column indices createHeaderMap(); } catch (Common::Exception &e) { clear(); e.add("Failed reading 2DA file"); throw; } }