struct board *load_board_allocate(FILE *fp, int savegame, int file_version, int world_version) { struct board *cur_board = cmalloc(sizeof(struct board)); int board_size, board_location, last_location; enum val_result result; board_size = fgetd(fp); // Skip deleted boards if(!board_size) { fseek(fp, 4, SEEK_CUR); goto err_out; } board_location = fgetd(fp); last_location = ftell(fp); if(fseek(fp, board_location, SEEK_SET)) { val_error(WORLD_BOARD_MISSING, board_location); goto err_out; } cur_board->world_version = world_version; result = load_board_direct(cur_board, fp, board_size, savegame, file_version); if(result != VAL_SUCCESS) create_blank_board(cur_board); fseek(fp, last_location, SEEK_SET); return cur_board; err_out: free(cur_board); return NULL; }
struct board *load_board_allocate(FILE *fp, int savegame, int version) { struct board *cur_board = cmalloc(sizeof(struct board)); int board_size, board_location, last_location; board_size = fgetd(fp); // Skip deleted boards if(!board_size) { fseek(fp, 4, SEEK_CUR); free(cur_board); return NULL; } board_location = fgetd(fp); last_location = ftell(fp); fseek(fp, board_location, SEEK_SET); load_board_direct(cur_board, fp, savegame, version); fseek(fp, last_location, SEEK_SET); return cur_board; }