Grid::Grid() { cellDistance = 360000.0f; cellSize = 300.0f; globalCell = SharedCell(new Cell()); calculateTranslationMatrix(); }
void Grid::rebuildGrid() { cells.clear(); globalCell = SharedCell(new Cell()); calculateTranslationMatrix(); for (boost::unordered_map<int, Item::SharedArea>::iterator a = core->getData()->areas.begin(); a != core->getData()->areas.end(); ++a) { addArea(a->second); } for (boost::unordered_map<int, Item::SharedCheckpoint>::iterator c = core->getData()->checkpoints.begin(); c != core->getData()->checkpoints.end(); ++c) { addCheckpoint(c->second); } for (boost::unordered_map<int, Item::SharedMapIcon>::iterator m = core->getData()->mapIcons.begin(); m != core->getData()->mapIcons.end(); ++m) { addMapIcon(m->second); } for (boost::unordered_map<int, Item::SharedObject>::iterator o = core->getData()->objects.begin(); o != core->getData()->objects.end(); ++o) { addObject(o->second); } for (boost::unordered_map<int, Item::SharedPickup>::iterator p = core->getData()->pickups.begin(); p != core->getData()->pickups.end(); ++p) { addPickup(p->second); } for (boost::unordered_map<int, Item::SharedRaceCheckpoint>::iterator r = core->getData()->raceCheckpoints.begin(); r != core->getData()->raceCheckpoints.end(); ++r) { addRaceCheckpoint(r->second); } for (boost::unordered_map<int, Item::SharedTextLabel>::iterator t = core->getData()->textLabels.begin(); t != core->getData()->textLabels.end(); ++t) { addTextLabel(t->second); } }
Player::Player(int id) { activeCheckpoint = 0; activeRaceCheckpoint = 0; currentVisibleObjects = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_OBJECT); currentVisibleTextLabels = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_3D_TEXT_LABEL); delayedCheckpoint = 0; delayedRaceCheckpoint = 0; enabledItems.set(); interiorID = 0; maxVisibleMapIcons = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_MAP_ICON); maxVisibleObjects = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_OBJECT); maxVisibleTextLabels = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_3D_TEXT_LABEL); playerID = id; position.setZero(); radiusMultipliers[STREAMER_TYPE_OBJECT] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_OBJECT); radiusMultipliers[STREAMER_TYPE_PICKUP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_PICKUP); radiusMultipliers[STREAMER_TYPE_CP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_CP); radiusMultipliers[STREAMER_TYPE_RACE_CP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_RACE_CP); radiusMultipliers[STREAMER_TYPE_MAP_ICON] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_MAP_ICON); radiusMultipliers[STREAMER_TYPE_3D_TEXT_LABEL] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_3D_TEXT_LABEL); radiusMultipliers[STREAMER_TYPE_AREA] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_AREA); radiusMultipliers[STREAMER_TYPE_VEHICLE] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_VEHICLE); updateUsingCameraPosition = false; updateWhenIdle = false; visibleCell = SharedCell(new Cell()); visibleCheckpoint = 0; visibleRaceCheckpoint = 0; worldID = 0; }
Player::Player(int id) { activeCheckpoint = 0; activeRaceCheckpoint = 0; checkedPickups = false; checkedActors = false; chunkTickCount[STREAMER_TYPE_OBJECT] = 0; chunkTickCount[STREAMER_TYPE_MAP_ICON] = 0; chunkTickCount[STREAMER_TYPE_3D_TEXT_LABEL] = 0; chunkTickRate[STREAMER_TYPE_OBJECT] = 1; chunkTickRate[STREAMER_TYPE_MAP_ICON] = 1; chunkTickRate[STREAMER_TYPE_3D_TEXT_LABEL] = 1; currentVisibleObjects = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_OBJECT); currentVisibleTextLabels = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_3D_TEXT_LABEL); delayedCheckpoint = 0; delayedRaceCheckpoint = 0; delayedUpdate = false; delayedUpdateType = 0; enabledItems.set(); interiorID = 0; maxVisibleMapIcons = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_MAP_ICON); maxVisibleObjects = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_OBJECT); maxVisibleTextLabels = core->getData()->getGlobalMaxVisibleItems(STREAMER_TYPE_3D_TEXT_LABEL); playerID = id; position.setZero(); radiusMultipliers[STREAMER_TYPE_OBJECT] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_OBJECT); radiusMultipliers[STREAMER_TYPE_PICKUP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_PICKUP); radiusMultipliers[STREAMER_TYPE_CP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_CP); radiusMultipliers[STREAMER_TYPE_RACE_CP] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_RACE_CP); radiusMultipliers[STREAMER_TYPE_MAP_ICON] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_MAP_ICON); radiusMultipliers[STREAMER_TYPE_3D_TEXT_LABEL] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_3D_TEXT_LABEL); radiusMultipliers[STREAMER_TYPE_AREA] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_AREA); radiusMultipliers[STREAMER_TYPE_ACTOR] = core->getData()->getGlobalRadiusMultiplier(STREAMER_TYPE_ACTOR); requestingClass = false; tickCount = 0; tickRate = 50; updateUsingCameraPosition = false; updateWhenIdle = false; visibleCell = SharedCell(new Cell()); visibleCheckpoint = 0; visibleRaceCheckpoint = 0; worldID = 0; }
void Grid::processDiscoveredCells(Player &player, std::vector<SharedCell> &playerCells, const boost::unordered_set<CellID> &discoveredCells) { playerCells.push_back(SharedCell(new Cell()));; if (player.enabledItems[STREAMER_TYPE_OBJECT]) { boost::unordered_map<int, Item::SharedObject>::iterator o = player.visibleCell->objects.begin(); while (o != player.visibleCell->objects.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(o->second->cell->cellID); if (d != discoveredCells.end()) { o = player.visibleCell->objects.erase(o); } else { ++o; } } playerCells.back()->objects.swap(player.visibleCell->objects); } if (player.enabledItems[STREAMER_TYPE_CP]) { boost::unordered_map<int, Item::SharedCheckpoint>::iterator c = player.visibleCell->checkpoints.begin(); while (c != player.visibleCell->checkpoints.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(c->second->cell->cellID); if (d != discoveredCells.end()) { c = player.visibleCell->checkpoints.erase(c); } else { ++c; } } playerCells.back()->checkpoints.swap(player.visibleCell->checkpoints); } if (player.enabledItems[STREAMER_TYPE_RACE_CP]) { boost::unordered_map<int, Item::SharedRaceCheckpoint>::iterator t = player.visibleCell->raceCheckpoints.begin(); while (t != player.visibleCell->raceCheckpoints.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(t->second->cell->cellID); if (d != discoveredCells.end()) { t = player.visibleCell->raceCheckpoints.erase(t); } else { ++t; } } playerCells.back()->raceCheckpoints.swap(player.visibleCell->raceCheckpoints); } if (player.enabledItems[STREAMER_TYPE_MAP_ICON]) { boost::unordered_map<int, Item::SharedMapIcon>::iterator m = player.visibleCell->mapIcons.begin(); while (m != player.visibleCell->mapIcons.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(m->second->cell->cellID); if (d != discoveredCells.end()) { m = player.visibleCell->mapIcons.erase(m); } else { ++m; } } playerCells.back()->mapIcons.swap(player.visibleCell->mapIcons); } if (player.enabledItems[STREAMER_TYPE_3D_TEXT_LABEL]) { boost::unordered_map<int, Item::SharedTextLabel>::iterator t = player.visibleCell->textLabels.begin(); while (t != player.visibleCell->textLabels.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(t->second->cell->cellID); if (d != discoveredCells.end()) { t = player.visibleCell->textLabels.erase(t); } else { ++t; } } playerCells.back()->textLabels.swap(player.visibleCell->textLabels); } if (player.enabledItems[STREAMER_TYPE_AREA]) { boost::unordered_map<int, Item::SharedArea>::iterator a = player.visibleCell->areas.begin(); while (a != player.visibleCell->areas.end()) { boost::unordered_set<CellID>::iterator d = discoveredCells.find(a->second->cell->cellID); if (d != discoveredCells.end()) { a = player.visibleCell->areas.erase(a); } else { ++a; } } playerCells.back()->areas.swap(player.visibleCell->areas); } }