OutdoorLightStats OutdoorLighting::getLightStats(int time) { // ASSUME: only 24 light info records, one for each whole hour //! \todo generalize this if the data file changes in the future OutdoorLightStats out; OutdoorLightStats *a, *b; int ta = time / 120; int tb = (ta + 1) % 24; float r = (time - (ta * 120)) / 120.0f; a = &lightStats[ta]; b = &lightStats[tb]; out.interpolate(a, b, r); return out; }
OutdoorLighting::OutdoorLighting(const std::string& fname) { MPQFile f(fname); unsigned int n, d; f.seekRelative(4); f.read(&n, 4); // it's the same thing twice? :| f.seekRelative(4); f.read(&d, 4); // d is now the final offset f.seek(8 + n * 8); while (f.getPos() < d) { OutdoorLightStats ols; ols.init(&f); lightStats.push_back(ols); } f.close(); }
OutdoorLighting::OutdoorLighting(char *fname) { MPQFile f(fname); unsigned int n,d; f.seekRelative(4); // nFields - Number of fields f.read(&n, 4); // Number of fields (again), it's the same thing twice? :| f.seekRelative(4); // Always 0x53 f.read(&d, 4); // d is now the final offset f.seek(8 + n * 8); while (f.getPos() < d) { OutdoorLightStats ols; ols.init(f); lightStats.push_back(ols); } f.close(); }