/////////////////////////////////////////////////////////// // Function type: I/O // Contributors: Pokedude // Last edit by: Pokedude // Date of edit: 6/4/2016 // /////////////////////////////////////////////////////////// bool WildPokemonArea::read(const qboy::Rom &rom, UInt32 offset, UInt32 amount) { rom.seek(offset); // exception-safe this time // Reads the probability and the pointer to the encounter array m_Probability = rom.readByte(); rom.readBytes(3); // padding m_Offset = rom.readPointer(); // Determines whether the encounter array offset is valid if (!rom.seek(m_Offset)) AME_THROW(WPST_ERROR_DATA, offset + 4); // Reads the encounter array for (UInt32 i = 0; i < amount; i++) { WildPokemonEncounter *entry = new WildPokemonEncounter; entry->min = rom.readByte(); entry->max = rom.readByte(); entry->id = rom.readHWord(); m_Entries.push_back(entry); } // Loading successful return true; }