/* * importlev - Level importer for Luola * Copyright (C) 2005 Calle Laakkonen * * File : importlev.c * Description : Level importer tool * Author(s) : Calle Laakkonen * * Luola is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Luola is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include "SDL.h" #include "ldat.h" #include "lconf2bin.h" #include "im_vwing.h" #include "im_wings.h" #include "im_tou.h" static struct Importer importer[3]; static const int importers=3; /* * Print help message and exit */ static void print_help(void) { int r; puts("importlev - A tool to import foreign levels to Luola\n" "Usage:\n" "importlev [options] [levelfile]...\n" "Options:\n" "\t--compact\tmake a compact level file\n" "\t--lcmap\t\tconvert collisionmap to LCMAP format\n" ); fputs("Supported level formats: ",stdout); for(r=0;rcfgfile); if(settings==NULL) { printf("Couldn't load level configuration file!\n"); return 1; } /* Create archive */ lev = ldat_create(); /* Pack level files */ pack_settings(settings,lev); if(files->artwork) pack_file(files->artwork,"ARTWORK",0,lev); pack_file(files->collmap,"COLLISION",0,lev); pack_file(files->cfgfile,"SOURCE",0,lev); /* Save level */ ldat_save_file(lev,filename); ldat_free(lev); return 0; } /* * Import a level */ static int import_file(const char *filename,int makecompact,int makelcmap) { struct Files saved; char *basename; int format=-1, r; FILE *fp; /* Open file and recognize format */ fp = fopen(filename,"rb"); if(fp==NULL) { perror(filename); return 1; } printf("%s: ",filename); for(r=0;r