Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HashTable<String, Reference<HyperspaceLocation*> > hyperspaceLocationMap;
- Class HyperspaceLocation : public Object {
- Private:
- String location;
- String scene;
- int x;
- int y;
- int z;
- }
- void parseDataTableRow(DataTableRow* row) {
- row->getValue(0, location);
- row->getValue(1, scene);
- row->getValue(2, x);
- row->getValue(3, y);
- row->getValue(4, Z);
- }
- inline String& getLocation() {
- return location;
- }
- inline String& getScene() {
- return scene;
- }
- inline int getXLocation() {
- return x();
- }
- inline int getYLocation() {
- return y();
- }
- inline int getZLocation() {
- return z();
- }
- void SpaceManager::loadClientData() {
- IffStream* iffStream = TemplateManager::instance()->openIffFile("datatables/space/hyperspace/hyperspace_locations.iff");
- if (iffStream == NULL) {
- error("Could not load hyperspace locations.");
- return;
- }
- DataTableIff dtiff;
- dtiff.readObject(iffStream);
- delete iffStream;
- for (int i = 0; i < dtiff.getTotalRows(); ++i) {
- DataTableRow* row = dtiff.getRow(i);
- Reference<HyperspaceLocation*> hyperspaceLocation = new HyperspaceLocation();
- hyperspaceLocation->parseDataTableRow(row);
- HyperspaceLocation* parent = hyperspaceLocationMap.get(hyperspaceLocation->getParentName().hashCode());
- if (parent == NULL)
- parent = rootNode;
- parent->addChild(hyperspaceLocation);
- if (hyperspaceLocationMap.put(hyperspaceLocation->getLocation().hashCode(), hyperspaceLocation) != NULL) {
- error("overwriting hyperspace location name");
- assert(0 && "hyperspace location name hashcode error");
- }
- }
- info("Successfully loaded " + String::valueOf(hyperspaceLocationMap.size()) + " hyperspace locations", true);
- }
Advertisement
Add Comment
Please, Sign In to add comment