45 lines
929 B
C++
45 lines
929 B
C++
#include <iostream>
|
|
|
|
#include "game_data.hpp"
|
|
|
|
void error(std::string error);
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
if(argc != 3)
|
|
{
|
|
error("You need to give an input and output file");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
std::ifstream json_input_file {argv[1]};
|
|
if(!json_input_file)
|
|
{
|
|
error("Couldn't open input file");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
std::ofstream bin_output_file {argv[2], std::ios::binary};
|
|
if(!bin_output_file)
|
|
{
|
|
error("Couldn't create output file");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
json json_input = json::parse(json_input_file);
|
|
game_data_t game_data;
|
|
|
|
load_json_into_game_data(&json_input, &game_data);
|
|
|
|
write_game_data_as_bin_into_file(&game_data, &bin_output_file);
|
|
|
|
free_game_data(&game_data);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
void error(std::string error)
|
|
{
|
|
std::cerr << "\033[0;1;31mError\033[m : " << error << "\n";
|
|
}
|