void JSONObject::addChild(const std::string& type, JSONObject* child) { if (!getMaps()["Children"]) getMaps()["Children"] = new JSONArray; JSONObject* jsonObject = new JSONObject(); jsonObject->getMaps()[type] = child; getMaps()["Children"]->asArray()->getArray().push_back(jsonObject); }
JSONDrawArrayLengths::JSONDrawArrayLengths(osg::DrawArrayLengths& array) { getMaps()["First"] = new JSONValue<int>(array.getFirst()); getMaps()["Mode"] = getDrawMode(array.getMode()); JSONArray* jsonArray = new JSONArray; for (unsigned int i = 0; i < array.size(); i++) { jsonArray->getArray().push_back(new JSONValue<int>(array[i])); } getMaps()["ArrayLengths"] = jsonArray; }
void Game::Init() { int flag = 0; vector<string> maps; Messages msg; //message handler int input = 0, mapNo = 0, playerType = 0; // playerType will become a type object // Game first needs to determine the type the player is. cout << msg.CLASS_SELECT << msg.CLASS_SELECT_ASSASSIN << msg.CLASS_SELECT_MAGE << msg.CLASS_SELECT_RANGER << msg.CLASS_SELECT_WARRIOR; while (flag != 1) // keep going till break { cout << msg.CLASS_SELECT_OPTION; cin >> input; switch (input) { case 1: cout << msg.NOT_REQUIRED_PHASE1; break; case 2: cout << msg.NOT_REQUIRED_PHASE1; break; case 3: cout << msg.NOT_REQUIRED_PHASE1; break; case 4: playerType = 4; flag = 1; break; } } // save player type //load maps: getMaps(maps); cout << msg.MAP_SELECT; for (int i = 0; i < maps.size(); ++i) cout << (i+1) << ". " << maps[i] << endl; cout << msg.MAP_SELECT_OPTION; cin >> mapNo; while (mapNo <= 0 || mapNo > maps.size()) { cout << msg.MAP_SELECT_OPTION; cin >> mapNo; } //eventually when a valid mapNumber is entered, the game loads the map and starts. cout << "load map" << mapNo << endl; }
/** * Add a request in the download queue * * @param m the maps containing the settings of the main.cfg file * @param url the url to add to the queue */ void addRequestToQueue(maps** m,HINTERNET* hInternet,const char* url,bool req){ hInternet->waitingRequests[hInternet->nb]=strdup(url); if(req) InternetOpenUrl(hInternet,hInternet->waitingRequests[hInternet->nb],NULL,0,INTERNET_FLAG_NO_CACHE_WRITE,0); maps *oreq=getMaps(*m,"orequests"); if(oreq==NULL){ oreq=createMaps("orequests"); oreq->content=createMap("value",url); addMapsToMaps(m,oreq); freeMaps(&oreq); free(oreq); }else{ setMapArray(oreq->content,"value",hInternet->nb-1,url); } }
int main(int argc, char** argv) { if (argc != 3) return -1; std::string executable = argv[1]; std::string directory = argv[2]; auto maps = getMaps(directory); Timer timer; for (auto map : maps) { tm.start(); tm.stop(); std::cout << map << " finished, time: " << tm.duration() << std::endl; } }
JSONDrawArray::JSONDrawArray(osg::DrawArrays& array) { getMaps()["First"] = new JSONValue<int>(array.getFirst()); getMaps()["Count"] = new JSONValue<int>(array.getCount()); getMaps()["Mode"] = getDrawMode(array.getMode()); }
bool VoronoiExpansion::calculatePotentials(unsigned char *costs, double start_x, double start_y, double end_x, double end_y, int cycles, float *potential) { if (!gotMap_) { ROS_ERROR("Global Planner: no map received!!!"); return false; } float *distance_field = distance_field_.get(); int8_t *voronoi_graph = voronoi_graph_.get(); int8_t *global_map = global_map_.get(); getMaps(distance_field, voronoi_graph, global_map); Index startPoint = Index(start_x, start_y, nx_, 0, 0, 0); Index endPoint = Index(end_x, end_y, nx_, 0, 0, 0); // EndPoint candidates //Dikjstra instead of going along the distance_field because sometimes the voronoi map is a // little bit of the distance field (if so gradient mehtod would fail) std::fill(potential, potential + ns_, POT_HIGH); Index endPointGraph = expandDijkstraToVoronoi(endPoint, startPoint, cycles, global_map, voronoi_graph, distance_field, potential); if (endPointGraph.i < 0) return false; int endPointImprovementSteps = (int)distance_field[endPointGraph.i]; endpoints_ = findVoronoiCandidates(endPointGraph, global_map, voronoi_graph, distance_field, potential, endPointImprovementSteps); // StartPoint candidates //Reset map for Start calculation (in case Start is next to end) std::fill(potential, potential + ns_, POT_HIGH); Index startPointGraph = expandDijkstraToVoronoi(startPoint, endPoint, cycles, global_map, voronoi_graph, distance_field, potential); if (startPointGraph.i < 0) return false; int startPointImprovementSteps = (int)distance_field[startPointGraph.i]; std::list<Index> startpoints = findVoronoiCandidates(startPointGraph, global_map, voronoi_graph, distance_field, potential, startPointImprovementSteps); startpoints.push_back(startPointGraph); // Start the Algorigthm by expanding on the Graph std::fill(potential, potential + ns_, POT_HIGH); // For having a high startpotential potential[startPointGraph.i] = startPointGraph.potential; Index endPointGraphReal = expandVoronoi(startPointGraph, endPointGraph, cycles, global_map, voronoi_graph, distance_field, potential); if (endPointGraphReal.i < 0) return false; // Draw lines to all startpoints and the endpoint (there is allways a straight line between voronoi Graph and // endPoint) expandLine(endPointGraphReal, endPoint, endPointGraphReal.potential, -1, potential); for (std::list<Index>::iterator it = startpoints.begin(); it != startpoints.end(); ++it) { expandLine(startPoint, *it, 0, startPointGraph.potential, potential); } return true; }