Guest User

Untitled

a guest
Feb 1st, 2015
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. HashTable<String, Reference<HyperspaceLocation*> > hyperspaceLocationMap;
  2.  
  3. Class HyperspaceLocation : public Object {
  4. Private:
  5.     String location;
  6.     String scene;
  7.     int x;
  8.     int y;
  9.     int z;
  10. }
  11.  
  12. void parseDataTableRow(DataTableRow* row) {
  13.     row->getValue(0, location);
  14.     row->getValue(1, scene);
  15.     row->getValue(2, x);
  16.     row->getValue(3, y);
  17.     row->getValue(4, Z);
  18. }
  19.  
  20. inline String& getLocation() {
  21.     return location;
  22. }
  23.  
  24. inline String& getScene() {
  25.     return scene;
  26. }
  27.  
  28. inline int getXLocation() {
  29.     return x();
  30. }
  31.    
  32. inline int getYLocation() {
  33.     return y();
  34. }
  35.    
  36. inline int getZLocation() {
  37.     return z();
  38. }
  39.  
  40. void SpaceManager::loadClientData() {
  41.     IffStream* iffStream = TemplateManager::instance()->openIffFile("datatables/space/hyperspace/hyperspace_locations.iff");
  42.  
  43.     if (iffStream == NULL) {
  44.         error("Could not load hyperspace locations.");
  45.         return;
  46.     }
  47.  
  48.     DataTableIff dtiff;
  49.     dtiff.readObject(iffStream);
  50.  
  51.     delete iffStream;
  52.  
  53.     for (int i = 0; i < dtiff.getTotalRows(); ++i) {
  54.         DataTableRow* row = dtiff.getRow(i);
  55.  
  56.         Reference<HyperspaceLocation*> hyperspaceLocation = new HyperspaceLocation();
  57.         hyperspaceLocation->parseDataTableRow(row);
  58.  
  59.         HyperspaceLocation* parent = hyperspaceLocationMap.get(hyperspaceLocation->getParentName().hashCode());
  60.  
  61.         if (parent == NULL)
  62.             parent = rootNode;
  63.  
  64.         parent->addChild(hyperspaceLocation);
  65.  
  66.         if (hyperspaceLocationMap.put(hyperspaceLocation->getLocation().hashCode(), hyperspaceLocation) != NULL) {
  67.             error("overwriting hyperspace location name");
  68.  
  69.             assert(0 && "hyperspace location name hashcode error");
  70.         }
  71.     }
  72.  
  73.     info("Successfully loaded " + String::valueOf(hyperspaceLocationMap.size()) + " hyperspace locations", true);
  74. }
Advertisement
Add Comment
Please, Sign In to add comment