コード例 #1
0
ファイル: Scene.cpp プロジェクト: CalebVDW/KinectParticles
Scene::Scene(SDL_Renderer* renderer, SDL_Texture* targetTexture, std::string mapFilePath, bool withoutSensor)
	:particles{ Constants::MAX_PARTICLES }, renderer{ renderer }, targetTexture{ targetTexture }, noSensor{ withoutSensor }
{
	dataCollection = noSensor ? &Scene::getMouseData : &Scene::getSensorData;
	SDL_SetRenderTarget(renderer, targetTexture);
	SDL_SetTextureBlendMode(targetTexture, SDL_BLENDMODE_BLEND);
	loadAssets();
	parseMapFile(mapFilePath);
	currentTime = SDL_GetPerformanceCounter();
}
コード例 #2
0
ファイル: parser.c プロジェクト: calumchisholm/XPilotNG-web
/*
 * Parse all command line arguments
 * and read the server defaults file and map file.
 * Then convert the map data into a World structure.
 */
bool Parser(int argc, char **argv)
{
    int i;
    char *fname;
    option_desc *desc;

    options.mapData = NULL;
    options.mapWidth = 0;
    options.mapHeight = 0;

    if (Init_options() == false)
	return false;

    for (i = 1; i < argc; i++) {
	if (Parse_check_info_request(argv, i))
	    return false;

	if (argv[i][0] == '-' || argv[i][0] == '+') {
	    desc = Find_option_by_name(argv[i] + 1);
	    if (desc != NULL) {
		if (desc->type == valBool) {
		    const char *bool_value;

		    if (argv[i][0] == '-')
			bool_value = "true";
		    else
			bool_value = "false";
		    Option_set_value(desc->name, bool_value, 1, OPT_COMMAND);
		}
		else if (desc->type == valVoid)
		    ;
		else {
		    if (i + 1 == argc)
			warn("Option '%s' needs an argument", argv[i]);
		    else {
			i++;
			Option_set_value(desc->name, argv[i], 1, OPT_COMMAND);
		    }
		}
	    }
	    else
		warn("Unknown option '%s'", argv[i]);
	}
	else
	    warn("Unknown option '%s'", argv[i]);
    }

    /*
     * Read local defaults file
     */
    if ((fname = Option_get_value("defaultsFileName", NULL)) != NULL)
	parseDefaultsFile(fname);
    else
	parseDefaultsFile(Conf_defaults_file_name());

    /*
     * Read local password file
     */
    if ((fname = Option_get_value("passwordFileName", NULL)) != NULL)
	parsePasswordFile(fname);
    else
	parsePasswordFile(Conf_password_file_name());

    /*
     * Read map file if map data not found yet.
     *
     * If "mapFileName" is defined then read it's contents from file.
     * Else read a default map.
     */
    if (!(fname = Option_get_value("mapData", NULL))) {
	if ((fname = Option_get_value("mapFileName", NULL)) != NULL) {
	    if (!parseMapFile(fname)) {
		xpprintf("Unable to read %s, trying to open %s\n",
			 fname, Conf_default_map());
		if (!parseMapFile(Conf_default_map()))
		    xpprintf("Unable to read %s\n", Conf_default_map());
	    }
	} else {
	    xpprintf("Map not specified, trying to open %s\n",
		     Conf_default_map());
	    if (!parseMapFile(Conf_default_map()))
		xpprintf("Unable to read %s\n", Conf_default_map());
	}
    }
    /*
     * Parse the options database and 'internalise' it.
     */
    Options_parse();

    Options_free();

    /*
     * Construct the World structure from the options.
     */
    return Grok_map();
}