int main(int argc, char** argv)
{
    freopen("CON", "w", stdout); // redirects stdout because SDL redirects it to a file.

    /* Parsing the input parameters. */
    if (argc < 6)
    {
        std::cout << "Missing some input parametr. Needed at least 5 but got only " << argc - 1 << std::endl;
        return -1;
    }

	if (!initGraphics(RESX, RESY)) return -1;
	renderScene();
	displayVFB(vfb);

    try
	{
		Puzzle puzzle;
		if (!puzzle.loadMap(argv[1]))
			throw "Something is wrong with the map file!";

        puzzle.setMonsterAndFoodCoords(fromStringToInt(argv[2]), fromStringToInt(argv[3]), fromStringToInt(argv[4]), fromStringToInt(argv[5]));

        // The flag for the SDL visualization
        if (argc >= 7)
        {
            puzzle.setVisualizationFlag(fromStringToInt(argv[6]));
        }

        // The flag for the SDL visualization
        if (argc >= 8)
        {
            puzzle.setDelay(fromStringToInt(argv[7]));
        }
		puzzle.printMap(std::cout);
		puzzle.solveAndVizualize(std::cout);
		puzzle.visualizeThePath();
		puzzle.basicVisualizePath(std::cout);
		puzzle.printFormatedPath(std::cout);

	}
	catch (const char * msg)
	{
		std::cout << "Error: " << msg << std::endl;
	}
	catch (const string msg)
	{
		std::cout << "Error: " << msg << std::endl;
	}


	waitForUserExit();
	closeGraphics();
	return 0;
}
示例#2
0
文件: Field.c 项目: aivaras16/nitro
NITFPRIV(NITF_BOOL) toInt(nitf_Field * field,
                          NITF_DATA * outData,
                          size_t length, nitf_Error * error)
{
    /*  First we have to figure out what we are storing...
       See, its okay to convert a BCS-N to an int, and...
       its also okay to maintain a binary int...          */
    NITF_BOOL status = NITF_FAILURE;
    if (field->type == NITF_BINARY)
    {
        switch (field->length)
        {
            case 2:
                status = toInt16(field, (nitf_Int16 *) outData, error);
                break;
            case 4:
                status = toInt32(field, (nitf_Int32 *) outData, error);
                break;
            case 8:
                status = toInt64(field, (nitf_Int64 *) outData, error);
                break;
            default:
                nitf_Error_initf(error, NITF_CTXT,
                                 NITF_ERR_INVALID_PARAMETER,
                                 "Unexpected field size for int [%d]",
                                 field->length);
        }
    }
    else
    {
        status = fromStringToInt(field, outData, length, error);
    }
    return status;
}