From: curt Date: Tue, 28 Apr 1998 21:42:50 +0000 (+0000) Subject: Wrapped zlib calls up so we can conditionally comment out zlib support. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=09bd08b93142d7383aa54691a99c04b053dd2c36;p=flightgear.git Wrapped zlib calls up so we can conditionally comment out zlib support. --- diff --git a/Main/airports.cxx b/Main/airports.cxx index 2422a8351..e85fe2dcb 100644 --- a/Main/airports.cxx +++ b/Main/airports.cxx @@ -29,7 +29,7 @@ #include #include -#include +#include #include "airports.hxx" @@ -42,10 +42,10 @@ fgAIRPORTS::fgAIRPORTS( void ) { // load the data int fgAIRPORTS::load( char *file ) { fgGENERAL *g; - char path[256], gzpath[256], line[256]; + char path[256], fgpath[256], line[256]; char id[5]; double lon, lat, elev; - gzFile f; + fgFile f; g = &general; @@ -54,30 +54,36 @@ int fgAIRPORTS::load( char *file ) { strcat(path, g->root_dir); strcat(path, "/Scenery/"); strcat(path, "Airports"); - strcpy(gzpath, path); - strcat(gzpath, ".gz"); + strcpy(fgpath, path); + strcat(fgpath, ".gz"); // first try "path.gz" - if ( (f = gzopen(gzpath, "rb")) == NULL ) { + if ( (f = fgopen(fgpath, "rb")) == NULL ) { // next try "path" - if ( (f = gzopen(path, "rb")) == NULL ) { + if ( (f = fgopen(path, "rb")) == NULL ) { fgPrintf(FG_GENERAL, FG_EXIT, "Cannot open file: %s\n", path); } } size = 0; - while ( gzgets(f, line, 250) != NULL ) { + while ( fggets(f, line, 250) != NULL ) { // printf("%s", line); - sscanf( line, "%s %lf %lf %lfl\n", id, &lon, &lat, &elev ); - strcpy(airports[size].id, id); - airports[size].longitude = lon; - airports[size].latitude = lat; - airports[size].elevation = elev; + + if ( size < MAX_AIRPORTS ) { + sscanf( line, "%s %lf %lf %lfl\n", id, &lon, &lat, &elev ); + strcpy(airports[size].id, id); + airports[size].longitude = lon; + airports[size].latitude = lat; + airports[size].elevation = elev; + } else { + fgPrintf( FG_GENERAL, FG_EXIT, + "Overran size of airport list in fgAIRPORTS::load()\n"); + } size++; } - gzclose(f); + fgclose(f); } @@ -103,6 +109,9 @@ fgAIRPORTS::~fgAIRPORTS( void ) { // $Log$ +// Revision 1.2 1998/04/28 21:42:50 curt +// Wrapped zlib calls up so we can conditionally comment out zlib support. +// // Revision 1.1 1998/04/25 15:11:11 curt // Added an command line option to set starting position based on airport ID. // diff --git a/Scenery/obj.c b/Scenery/obj.c index d9283a228..e8f18370d 100644 --- a/Scenery/obj.c +++ b/Scenery/obj.c @@ -40,11 +40,11 @@ #include #include +#include #include #include #include #include -#include #define MAXNODES 100000 @@ -98,28 +98,32 @@ float calc_lat(double x, double y, double z) { /* Load a .obj file and generate the GL call list */ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) { - char gzpath[256], line[256], winding_str[256]; + char fgpath[256], line[256], winding_str[256]; double approx_normal[3], normal[3], scale; // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin; GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 }; GLint tile; - gzFile f; + fgFile f; int first, ncount, vncount, n1, n2, n3, n4; static int use_per_vertex_norms = 1; int winding; int last1, last2, odd; // First try "path.obz" (compressed format) - strcpy(gzpath, path); - strcat(gzpath, ".obz"); - if ( (f = gzopen(gzpath, "rb")) == NULL ) { + strcpy(fgpath, path); + strcat(fgpath, ".obz"); + if ( (f = fgopen(fgpath, "rb")) == NULL ) { // Next try "path.obj" (uncompressed format) - strcat(path, ".obj"); - if ( (f = gzopen(path, "rb")) == NULL ) { + strcpy(fgpath, path); + strcat(fgpath, ".obj"); + if ( (f = fgopen(fgpath, "rb")) == NULL ) { // Next try "path.obj.gz" (compressed format) - strcat(path, ".gz"); - if ( (f = gzopen(path, "rb")) == NULL ) { - fgPrintf(FG_TERRAIN, FG_ALERT, "Cannot open file: %s\n", path); + strcat(fgpath, ".gz"); + if ( (f = fgopen(fgpath, "rb")) == NULL ) { + strcpy(fgpath, path); + strcat(fgpath, ".obj"); + fgPrintf( FG_TERRAIN, FG_ALERT, + "Cannot open file: %s\n", fgpath ); return(-1); } } @@ -143,7 +147,7 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) { ncount = 1; vncount = 1; - while ( gzgets(f, line, 250) != NULL ) { + while ( fggets(f, line, 250) != NULL ) { if ( line[0] == '#' ) { /* comment -- ignore */ } else if ( line[0] == '\n' ) { @@ -463,7 +467,7 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) { xglEndList(); - gzclose(f); + fgclose(f); /* reference point is the "center" (now included in input file) */ /* @@ -477,11 +481,14 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) { /* $Log$ -/* Revision 1.34 1998/04/28 01:21:42 curt -/* Tweaked texture parameter calculations to keep the number smaller. This -/* avoids the "swimming" problem. -/* Type-ified fgTIME and fgVIEW. +/* Revision 1.35 1998/04/28 21:43:26 curt +/* Wrapped zlib calls up so we can conditionally comment out zlib support. /* + * Revision 1.34 1998/04/28 01:21:42 curt + * Tweaked texture parameter calculations to keep the number smaller. This + * avoids the "swimming" problem. + * Type-ified fgTIME and fgVIEW. + * * Revision 1.33 1998/04/27 15:58:15 curt * Screwing around with texture coordinate generation ... still needs work. * diff --git a/Scenery/scenery.c b/Scenery/scenery.c index ffce65184..f5ce0068c 100644 --- a/Scenery/scenery.c +++ b/Scenery/scenery.c @@ -57,7 +57,7 @@ struct fgSCENERY scenery; /* Initialize the Scenery Management system */ int fgSceneryInit( void ) { fgGENERAL *g; - char path[1024]; + char path[1024], fgpath[1024]; GLubyte *texbuf; int width, height; @@ -74,9 +74,16 @@ int fgSceneryInit( void ) { strcat(path, "/Textures/"); strcat(path, "desert.rgb"); + // Try uncompressed if ( (texbuf = read_rgb_texture(path, &width, &height)) == NULL ) { - fgPrintf( FG_GENERAL, FG_EXIT, "Error in loading textures!\n" ); - return(0); + // Try compressed + strcpy(fgpath, path); + strcat(fgpath, ".gz"); + if ( (texbuf = read_rgb_texture(fgpath, &width, &height)) == NULL ) { + fgPrintf( FG_GENERAL, FG_EXIT, "Error in loading texture %s\n", + path ); + return(0); + } } xglTexImage2D(GL_TEXTURE_2D, 0, 3, height, width, 0, @@ -116,11 +123,14 @@ void fgSceneryRender( void ) { /* $Log$ -/* Revision 1.41 1998/04/24 00:51:08 curt -/* Wrapped "#include " in "#ifdef HAVE_CONFIG_H" -/* Tweaked the scenery file extentions to be "file.obj" (uncompressed) -/* or "file.obz" (compressed.) +/* Revision 1.42 1998/04/28 21:43:27 curt +/* Wrapped zlib calls up so we can conditionally comment out zlib support. /* + * Revision 1.41 1998/04/24 00:51:08 curt + * Wrapped "#include " in "#ifdef HAVE_CONFIG_H" + * Tweaked the scenery file extentions to be "file.obj" (uncompressed) + * or "file.obz" (compressed.) + * * Revision 1.40 1998/04/18 04:14:06 curt * Moved fg_debug.c to it's own library. * diff --git a/Scenery/texload.c b/Scenery/texload.c index a9b73b820..b03e9bff9 100644 --- a/Scenery/texload.c +++ b/Scenery/texload.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include "texload.h" @@ -20,7 +20,7 @@ typedef struct _ImageRec { unsigned int wasteBytes; char name[80]; unsigned long colorMap; - gzFile file; + fgFile file; unsigned char *tmp; unsigned long rleEnd; unsigned int *rowStart; @@ -88,12 +88,12 @@ static ImageRec *ImageOpen(char *fileName) fprintf(stderr, "Out of memory!\n"); exit(1); } - if ((image->file = gzopen(fileName, "rb")) == NULL) { + if ((image->file = fgopen(fileName, "rb")) == NULL) { return NULL; } // fread(image, 1, 12, image->file); - gzread(image->file, image, 12); + fgread(image->file, image, 12); if (swapFlag) { ConvertShort(&image->imagic, 6); @@ -114,11 +114,11 @@ static ImageRec *ImageOpen(char *fileName) exit(1); } image->rleEnd = 512 + (2 * x); - gzseek(image->file, 512, SEEK_SET); + fgseek(image->file, 512, SEEK_SET); // fread(image->rowStart, 1, x, image->file); - gzread(image->file, image->rowStart, x); + fgread(image->file, image->rowStart, x); // fread(image->rowSize, 1, x, image->file); - gzread(image->file, image->rowSize, x); + fgread(image->file, image->rowSize, x); if (swapFlag) { ConvertUint(image->rowStart, x/(int) sizeof(unsigned)); ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int)); @@ -129,7 +129,7 @@ static ImageRec *ImageOpen(char *fileName) static void ImageClose(ImageRec *image) { - gzclose(image->file); + fgclose(image->file); free(image->tmp); free(image); } @@ -140,10 +140,10 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { int count; if ((image->type & 0xFF00) == 0x0100) { - gzseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); + fgseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); // fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], // image->file); - gzread(image->file, image->tmp, + fgread(image->file, image->tmp, (unsigned int)image->rowSize[y+z*image->ysize]); iPtr = image->tmp; @@ -166,10 +166,10 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { } } } else { - gzseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), + fgseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), SEEK_SET); // fread(buf, 1, image->xsize, image->file); - gzread(image->file, buf, image->xsize); + fgread(image->file, buf, image->xsize); } }