Exemple #1
0
///////////////////
// Load the weapons restrictions list
void CWpnRest::loadList(const std::string& szFilename, const std::string& moddir)
{
    // Shutdown the list first
    Shutdown();

    std::string fn = szFilename;
    if(!strCaseStartsWith(fn, "cfg/")) {
        if(fn.size() > 4 && !stringcaseequal(fn.substr(fn.size()-4), ".wps"))
            fn += ".wps";
        if(moddir != "" && IsFileAvailable("cfg/presets/" + moddir + "/" + fn))
            fn = "cfg/presets/" + moddir + "/" + fn;
        else
            fn = "cfg/presets/" + fn;
    }

    FILE *fp = OpenGameFile(fn, "rt");
    if( !fp )
        return;

    std::string line;

    while( !feof(fp) && !ferror(fp) ) {
        line = ReadUntil(fp, '\n');
        std::vector<std::string> exploded = explode(line,",");
        if (exploded.size() >= 2)
            addWeapon(exploded[0],from_string<int>(exploded[1]));
    }

    fclose(fp);

    // Sort the list
    sortList();
}
Exemple #2
0
/////////////////////////
// Initializes the IRC client and connects to the server (specified in options)
bool InitializeIRC()
{
	// Already initialized?
	if (globalIRC)
		return true;

	if (!tLXOptions->bEnableChat)
		return false;

	// Allocate the IRC client
	try  {
		globalIRC = new IRCClient();
	} catch (...)  {
		return false;
	}

	// Get the server
	FILE *fp = OpenGameFile("cfg/chatserver.txt", "r");
	if (fp)  {
		std::string addr = ReadUntil(fp, '/');
		std::string chann = ReadUntil(fp, '\n');
		fclose(fp);
		return globalIRC->connect(addr, chann, tLXOptions->sLastSelectedPlayer);
	} else { // Defaults
		return globalIRC->connect("irc.quakenet.org", "#LieroX", tLXOptions->sLastSelectedPlayer);
	}
}
/**
 * This function loads the savegame of the 5th version
 */
bool CSaveGameController::loadSaveGameVersion5(const std::string &fname, OldSaveGameFormatV5& old)
{
    FILE *fp;
    unsigned char episode, level, lives, numplayers;

    g_pLogFile->ftextOut("Loading game from file %s\n", fname.c_str());
    fp = OpenGameFile(fname, "rb");
    if (!fp) {
        g_pLogFile->ftextOut("unable to open %s\n",fname.c_str());
        return false;
    }

    readOldHeader(fp, &episode, &level, &lives, &numplayers);

    g_pLogFile->ftextOut("game_load: restoring structures...\n");
    /*primaryplayer =*/ fgetc(fp); // primary player doesn't exist anymore! Jump that!

    sgrle_compress(fp, (unsigned char *) &old.LevelControl, sizeof(old.LevelControl));

    // note that we don't have to load the LEVEL, because the state
    // of the map is already saved inside the save-game.
    sgrle_initdecompression();
    if (sgrle_decompressV2(fp, (unsigned char *) &old.LevelControl, sizeof(old.LevelControl))) return false;

    if (sgrle_decompressV2(fp, (unsigned char *)&old.scroll_x, sizeof(old.scroll_x))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.scrollx_buf, sizeof(old.scrollx_buf))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.scrollpix, sizeof(old.scrollpix))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.mapx, sizeof(old.mapx))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.mapxstripepos, sizeof(old.mapxstripepos))) return false;

    if (sgrle_decompressV2(fp, (unsigned char *)&old.scroll_y, sizeof(old.scroll_y))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.scrolly_buf, sizeof(old.scrolly_buf))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.scrollpixy, sizeof(old.scrollpixy))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.mapy, sizeof(old.mapy))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.mapystripepos, sizeof(old.mapystripepos))) return false;

    if (sgrle_decompressV2(fp, (unsigned char *)&old.max_scroll_x, sizeof(old.max_scroll_x))) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)&old.max_scroll_y, sizeof(old.max_scroll_y))) return false;

    if (sgrle_decompressV2(fp, (unsigned char *)&old.map, sizeof(old.map))) return false;

    unsigned char *tempbuf;

    tempbuf = new unsigned char[22624];

    /*highest_objslot = */fgetc(fp);
    fgetc(fp); // Not used anymore since objects are held in an vector.
    if (sgrle_decompressV2(fp, (unsigned char *)tempbuf, 22624)) return false;
    if (sgrle_decompressV2(fp, (unsigned char *)tempbuf, 9612)) return false;

    delete [] tempbuf;

    if (sgrle_decompressV2(fp, (unsigned char *)&old.Player, sizeof(old.Player))) return false;

    fclose(fp);

    return true;
}
Exemple #4
0
// Opens *existing* file from given directory in a case-insensitive manner
/*static*/ BE_FILE_T BEL_Cross_open_from_dir(const char *filename, bool isOverwriteRequest, const char *searchdir)
{
    std::string filePath = searchdir;

    filePath += "/";
    filePath += filename;

    return OpenGameFile(filePath, isOverwriteRequest ? "wb" : "rb");

    /*** TODO - Any reason to save (cache) DIR handles? ***/
    /*
	DIR *dir;
	struct dirent *direntry;
	dir = opendir(searchdir);
	if (!dir)
		return NULL;

	char fullpath[BE_CROSS_PATH_LEN_BOUND];

	for (direntry = readdir(dir); direntry; direntry = readdir(dir))
	{
		if (!BE_Cross_strcasecmp(direntry->d_name, filename))
		{
			// Just a little sanity check
			if (strlen(searchdir) + 1 + strlen(direntry->d_name) >= BE_CROSS_PATH_LEN_BOUND)
			{
				closedir(dir);
				return NULL;
			}
			char *fullpathEnd = fullpath + sizeof(fullpath);
			BE_Cross_safeandfastcstringcopy_3strs(fullpath, fullpathEnd, searchdir, "/", direntry->d_name);

			closedir(dir);
			return fopen(fullpath, isOverwriteRequest ? "wb" : "rb");
		}
	}
	closedir(dir);
	// If tried to open for reading, we return NULL, otherwise we attempt create new file
	if (!isOverwriteRequest)
		return NULL;
	char *fullpathEnd = fullpath + sizeof(fullpath);
	char *fullpathPtr = BE_Cross_safeandfastcstringcopy_2strs(fullpath, fullpathEnd, searchdir, "/");
	// Create actual new files with a lower case, just because that's a common pattern in Unix-like setups
	// (basically a modified BE_Cross_safeandfastcstringcopy).
	//
	// Note: fullpathPtr should initially point to an instance of '\0', so fullpathPtr < fullpathEnd.
	char ch;
	do
	{
		ch = *filename++;
		*fullpathPtr++ = BE_Cross_tolower(ch); // This includes the null terminator if there's the room
	} while ((fullpathPtr < fullpathEnd) && ch);
	// These work in case fullpathPtr == fullpathEnd, and also if not
	--fullpathPtr;
	*fullpathPtr = '\0';

    return fopen(fullpath, "wb");*/
}
Exemple #5
0
///////////////////
// Save the weapons restrictions list
void CWpnRest::saveList(const std::string& szFilename)
{
    // Save it as plain text
    FILE *fp = OpenGameFile(szFilename, "wt");
    if( !fp )
        return;

    for( std::list<wpnrest_t> :: iterator it = m_psWeaponList.begin();
            it != m_psWeaponList.end(); it++ )
        fprintf(fp, "%s,%d\n", it->szName.c_str(), it->nState);

    fclose(fp);
}
////////////////
// Loads the database, returns false on failure
bool GeoIPDatabase::load(const std::string& filename)
{
	m_file = OpenGameFile(filename, "rb");
	if (!m_file)
		return false;

	m_fileName = filename;
	if (!setupSegments())  {
		fclose(m_file);
		return false;
	}

	return true;
}
bool CSaveGameController::loadSaveGameVersion4(const std::string &fname, OldSaveGameFormatV4& old)
{
    FILE *fp;
    //unsigned char episode, level, lives;
    unsigned int numplayers;

    g_pLogFile->ftextOut("Loading game from file %s\n", fname.c_str());
    fp = OpenGameFile(fname, "rb");
    if (!fp) {
        g_pLogFile->ftextOut("unable to open %s\n",fname.c_str());
        return false;
    }

    g_pLogFile->ftextOut("game_load: restoring structures...\n");
    if (fgetc(fp) != 'S') {
        fclose(fp);
        return false;
    }
    if (fgetc(fp) != OLDSAVEGAMEVERSION4) {
        fclose(fp);
        return false;
    }
    fgetc(fp);

    // load all structures from the file
    sgrle_initdecompression();
    sgrle_decompressV1(fp, (unsigned char *)&numplayers, sizeof(numplayers));
    sgrle_decompressV1(fp, (unsigned char *)&old.LevelControl, sizeof(old.LevelControl));
    sgrle_decompressV1(fp, (unsigned char *)&old.scroll_x, sizeof(old.scroll_x));
    sgrle_decompressV1(fp, (unsigned char *)&old.scroll_y, sizeof(old.scroll_y));
    sgrle_decompressV1(fp, (unsigned char *)&old.max_scroll_x, sizeof(old.max_scroll_x));
    sgrle_decompressV1(fp, (unsigned char *)&old.max_scroll_y, sizeof(old.max_scroll_y));
    sgrle_decompressV1(fp, (unsigned char *)&old.map, sizeof(old.map));

    //initgame( &(pCKP->Control.levelcontrol) ); // reset scroll
    //drawmap();
    //for(i=0;i<scrx;i++) map_scroll_right();
    //for(i=0;i<scry;i++) map_scroll_down();

    sgrle_decompressV1(fp, (unsigned char *)&old.Player, sizeof(old.Player));

    //sgrle_decompress(fp, (unsigned char *)&objects[0], sizeof(objects));
    //sgrle_decompress(fp, (unsigned char *)&tiles[0], sizeof(tiles));

    fclose(fp);

    return true;
}
Exemple #8
0
void LoadCDTrackList()
{
	//clear out the old list first
	EmptyCDTrackList();

	FILE *file = OpenGameFile(CDTrackFileName, FILEMODE_READONLY, FILETYPE_OPTIONAL);
	
	if(file==NULL)
	{
		LOGDXFMT(("Failed to open %s",CDTrackFileName));
		return;
	}

	char* buffer;
	int file_size;

	fseek(file, 0, SEEK_END);
	file_size = ftell(file);
	rewind(file);
	
	//copy the file contents into a buffer
	buffer=new char[file_size+1];
	fread(buffer, 1, file_size, file);
	fclose(file);

	// NULL terminate buffer.
	buffer[file_size] = '\0';
	
	char* bufferptr=buffer;


	//first extract the multiplayer tracks
	for(int i=0;i<3;i++)
	{
		ExtractTracksForLevel(bufferptr,MultiplayerCDTracks[i]);
	}
	
	//now the level tracks
	for(int i=0 ;i<AVP_ENVIRONMENT_END_OF_LIST;i++)
	{
		ExtractTracksForLevel(bufferptr,LevelCDTracks[i]);
	}
	

	delete [] buffer;
}
bool CSaveGameController::IsOldSGVersion4(const std::string& fname)
{
    FILE* fp = OpenGameFile(fname, "rb");
    if (!fp) return false;

    if (fgetc(fp) != 'S') {
        fclose(fp);
        return false;
    }
    if (fgetc(fp) != OLDSAVEGAMEVERSION4) {
        fclose(fp);
        return false;
    }

    fclose(fp);
    return true;
}
bool CSaveGameController::IsOldSGVersion5(const std::string& fname)
{
    const char *verify = "CKSAVE";
    FILE* fp = OpenGameFile(fname, "rb");
    if (!fp) return false;

    for(size_t i=0; i < strlen(verify); i++)
    {
        char c = fgetc(fp);
        if (c != verify[i])
        {
            fclose(fp);
            return false;
        }
        printf("%c", c);
    }
    if (fgetc(fp) != OLDSAVEGAMEVERSION5)
    {
        fclose(fp);
        return false;
    }
    fclose(fp);
    return true;
}
Exemple #11
0
void ScreenShot()
{
	int i;
	char Name[40];
	
	int width, height;
	unsigned char *buf = GetScreenShot24(&width, &height);
	if (buf == NULL)
		return;
	
	strcpy(Name,"avp");
	int length=strlen(Name);
	strncpy(&Name[length],"00.bmp",8);
	for(i=0;i<100;i++)
	{
		Name[length]=i/10+'0';
		Name[length+1]=(i%10)+'0';
		FILE* tempfp = OpenGameFile(Name, FILEMODE_READONLY, FILETYPE_CONFIG);
		if(!tempfp)break;
		else
 		{
			fclose(tempfp);
		}
	}
	if(i==100) return;
	
	FILE *fp = OpenGameFile(Name, FILEMODE_WRITEONLY, FILETYPE_CONFIG);
	if (!fp)
	{
		return;
	}
	
	BMPHEADER2 h;

	// fill out header
	
	h.Header.Type      = 'B'+'M'*256;
	h.Header.Reserved1 = 0;
	h.Header.Reserved2 = 0;
	h.Header.Offset    = 14+40+0;

	/*
	** The type of information found in a BMP structure is indicated by
	** the Size (Information Headere Size) field with a non-zero value.
	*/
	h.PmInfo.Size   = 0;
	h.Pm2Info.Size  = 0;

	h.WinInfo.Size          = 40;
	h.WinInfo.Width         = width;
	h.WinInfo.Height        = height;
	h.WinInfo.Planes        = 1;
	h.WinInfo.BitCount      = 24;
	h.WinInfo.Compression   = 0;
	h.WinInfo.SizeImage     = h.WinInfo.Width*h.WinInfo.Height*3;
	h.WinInfo.XPelsPerMeter = h.WinInfo.Width;
	h.WinInfo.YPelsPerMeter = h.WinInfo.Height;
	h.WinInfo.ClrUsed       = 0;
	h.WinInfo.ClrImportant  = 0;

	h.Header.FileSize  = h.WinInfo.SizeImage + h.Header.Offset + 8;

	// write header

	PutWord_F PutWord = PutLittleWord;
	PutDword_F PutDword = PutLittleDword;

    PutWord(h.Header.Type, fp);
    PutDword(h.Header.FileSize, fp);
    PutWord(h.Header.Reserved1, fp);
    PutWord(h.Header.Reserved2, fp);
    PutDword(h.Header.Offset, fp);

	PutDword(h.WinInfo.Size, fp);

    PutDword(h.WinInfo.Width, fp);
    PutDword(h.WinInfo.Height, fp);
    PutWord(h.WinInfo.Planes, fp);
    PutWord(h.WinInfo.BitCount, fp);
    PutDword(h.WinInfo.Compression, fp);
    PutDword(h.WinInfo.SizeImage, fp);
    PutDword(h.WinInfo.XPelsPerMeter, fp);
    PutDword(h.WinInfo.YPelsPerMeter, fp);
    PutDword(h.WinInfo.ClrUsed, fp);
    PutDword(h.WinInfo.ClrImportant, fp);

	// write 24 bit image

//	unsigned char *BufferPtr = &buf[(width * 3) * (height - 1)];
	unsigned char *BufferPtr = &buf[0];
	for (i=h.WinInfo.Height-1; i>=0; --i)
	{
		unsigned int j;
		for (j=0; j<h.WinInfo.Width; ++j)
		{
			PutByte((BYTE)BufferPtr[j*3+2],fp);  //b
			PutByte((BYTE)BufferPtr[j*3+1],fp);  //g
			PutByte((BYTE)BufferPtr[j*3],fp);  //r
		}
			
		// pad to 4 byte boundary
		for (j=~(h.WinInfo.Width*3-1) & 3; j; --j) PutByte(0,fp);
//		BufferPtr -= width * 3;
		BufferPtr += width * 3;
	}

	free(buf);
	fclose(fp);	
}
Exemple #12
0
bool CEGASprit::loadData(const std::string& filename, bool compresseddata)
{
	byte *RawData;
    SDL_Surface *sfc;
    Uint8* pixel;
    Uint32 percent = 0;
	
	FILE* latchfile = OpenGameFile(filename.c_str(),"rb");
	
	if(!latchfile)
		return false;
	
	gResourceLoader.setPermilage(10);

	RawData = new byte[m_planesize * 5];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, RawData))
			return 1;
    }
    else
    {
    	for(int i=0 ; i<(m_planesize*5) ; i++)
    		RawData[i] = fgetc(latchfile);
    }
	
    fclose(latchfile);

	gResourceLoader.setPermilage(50);
	
    // TODO: Try to blit the Font map here!
	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4, plane5;
	
	plane1 = 0;
	plane2 = (m_planesize * 1);
	plane3 = (m_planesize * 2);
	plane4 = (m_planesize * 3);
	plane5 = (m_planesize * 4);
	
	CPlanes Planes(RawData + m_spriteloc);
	Planes.setOffsets(plane1, plane2, plane3, plane4, plane5);
	
	// load the image data
    gGraphics.createEmptySprites(4,MAX_SPRITES+1);
	for(int i=0 ; i<m_numsprites ; i++)
	{
        GsSprite &Sprite = gGraphics.getSprite(0,i);
		Sprite.setSize( EGASpriteModell[i].width, EGASpriteModell[i].height );
		Sprite.setBoundingBoxCoordinates( (EGASpriteModell[i].hitbox_l << STC),
				(EGASpriteModell[i].hitbox_u << STC),
				(EGASpriteModell[i].hitbox_r << STC),
				(EGASpriteModell[i].hitbox_b << STC) );
		Sprite.createSurface( gVideoDriver.mpVideoEngine->getBlitSurface()->flags,
				gGraphics.Palette.m_Palette );

		percent = (i*50)/m_numsprites;
		gResourceLoader.setPermilage(50+percent);
	}

	gResourceLoader.setPermilage(100);

	for(int p=0 ; p<4 ; p++)
	{
		for(int s=0 ; s<m_numsprites ; s++)
		{
            sfc = gGraphics.getSprite(0,s).getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			pixel = (Uint8*) sfc->pixels;

			Planes.readPlane(p, pixel, sfc->w, sfc->h);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

			percent = (s*100)/m_numsprites;
			gResourceLoader.setPermilage(100+percent);
		}
	}

	gResourceLoader.setPermilage(200);

	// now load the 5th plane, which contains the sprite masks.
	// note that we invert the mask because our graphics functions
	// use white on black masks whereas keen uses black on white.
	for(int s=0 ; s<m_numsprites ; s++)
	{
        GsSprite &Sprite = gGraphics.getSprite(0,s);
		SDL_Surface *pixsfc = Sprite.getSDLSurface();
		SDL_Surface *masksfc = Sprite.getSDLMaskSurface();

		if(SDL_MUSTLOCK(pixsfc)) SDL_LockSurface(pixsfc);
		if(SDL_MUSTLOCK(masksfc)) SDL_LockSurface(masksfc);

		pixel = (Uint8*) masksfc->pixels;

		for(int y=0 ; y<masksfc->h ; y++)
		{
			for(int x=0 ; x<masksfc->w ; x++)
			{
				if(Planes.getbit(4))
                    pixel[y*masksfc->w + x] = ((Uint8*)pixsfc->pixels)[y*pixsfc->w + x];
				else
					pixel[y*masksfc->w + x] = 15;
			}
		}
		if(SDL_MUSTLOCK(masksfc)) SDL_UnlockSurface(masksfc);
		if(SDL_MUSTLOCK(pixsfc)) SDL_UnlockSurface(pixsfc);

		percent = (s*100)/m_numsprites;
		gResourceLoader.setPermilage(200+percent);
	}

	gResourceLoader.setPermilage(300);
	
	if(RawData){ delete[] RawData; RawData = NULL;}
	
    LoadSpecialSprites( gGraphics.getSpriteVec(0) );


    for(unsigned int i=1 ; i<4 ; i++)
    {
        gGraphics.getSpriteVec(i) = gGraphics.getSpriteVec(0);
    }


    // For the other variant let's exchange some colors
    auto &SpriteVecPlayer2 = gGraphics.getSpriteVec(1);
    for( unsigned int i = 0 ; i < SpriteVecPlayer2.size() ; i++)
    {
        auto &sprite = SpriteVecPlayer2[i];
        // Red against Purple
        sprite.exchangeSpriteColor( 5, 4, 0 );
        sprite.exchangeSpriteColor( 13, 12, 0 );

        // Yellow against Green
        sprite.exchangeSpriteColor( 2, 6, 0 );
        sprite.exchangeSpriteColor( 10, 14, 0 );
    }


    auto &SpriteVecPlayer3 = gGraphics.getSpriteVec(2);
    for( auto &sprite : SpriteVecPlayer3)
    {
        // Red against Green
        sprite.exchangeSpriteColor( 2, 4, 0 );
        sprite.exchangeSpriteColor( 10, 12, 0 );

        // Yellow against Purple
        sprite.exchangeSpriteColor( 5, 6, 0 );
        sprite.exchangeSpriteColor( 13, 14, 0 );
    }

    auto &SpriteVecPlayer4 = gGraphics.getSpriteVec(3);
    for( auto &sprite : SpriteVecPlayer4)
    {
        // Red against Yellow
        sprite.exchangeSpriteColor( 6, 4, 0 );
        sprite.exchangeSpriteColor( 14, 12, 0 );

        // Green against Purple
        sprite.exchangeSpriteColor( 2, 5, 0 );
        sprite.exchangeSpriteColor( 10, 13, 0 );
    }


    for(unsigned int i=0 ; i<4 ; i++)
    {
        for(Uint16 s=0 ; s<gGraphics.getSpriteVec(i).size() ; s++)
        {
            GsSprite &Sprite = gGraphics.getSprite(i,s);
            Sprite.optimizeSurface();

            percent = (s*50)/m_numsprites;
            gResourceLoader.setPermilage(300+percent);
        }
    }


    gResourceLoader.setPermilage(350);

    std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(m_gamepath, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "sprite");


	std::set<std::string>::iterator it = filelist.begin();
	int listsize = filelist.size();
    for( int c=0 ; it != filelist.end() ; it++, c++ )
	{
		std::string name=*it;

        if(name.find("_") != name.npos)
            continue;

		int num = getRessourceID(name, "sprite");
		if(num < m_numsprites )
		{
            GsSprite &Sprite = gGraphics.getSprite(0, num);
			std::string filename = getResourceFilename("gfx/"+name, m_gamepath, false, true);
			Sprite.loadHQSprite(filename);
		}

		percent = (c*150)/listsize;
		gResourceLoader.setPermilage(350+percent);
    }



	gResourceLoader.setPermilage(500);

    for(unsigned int i=0 ; i<4 ; i++)
    {
        const int NoSprites = gGraphics.getSpriteVec(i).size();
        for(Uint16 s=0 ; s<NoSprites ; s++)
        {
            gGraphics.getSprite(i,s).applyTransparency();

            percent = (s*250)/NoSprites;
            gResourceLoader.setPermilage(500+percent);
        }
    }

    gResourceLoader.setPermilage(750);

	// Now create special sprites, like those for effects and the doors!
    DeriveSpecialSprites( gGraphics.getTileMap(1), gGraphics.getSpriteVec(0) );
    gResourceLoader.setPermilage(800);

	// Here special Effects are applied, only when the option is enabled for it
	if(gVideoDriver.getSpecialFXConfig())
		ApplySpecialFX();

    gResourceLoader.setPermilage(900);

    // Apply the sprites for player 2,3 and 4
    DerivePlayerSprites( 1,gGraphics.getSpriteVec(1) );
    DerivePlayerSprites( 2,gGraphics.getSpriteVec(2) );
    DerivePlayerSprites( 3,gGraphics.getSpriteVec(3) );
    gResourceLoader.setPermilage(1000);


	return true;
}
Exemple #13
0
FILE* gusOpenGameFile(const std::string& path, const char *mode) {
	return OpenGameFile(path, mode);
}
bool CEGALatch::loadData( const std::string &path,
                          const short episode,
                          const int version,
                          const unsigned char *data,
                          const bool compresseddata )
{
	std::string filename;
	byte *RawData;
    Uint16 width, height;
    SDL_Surface *sfc;


	filename = getResourceFilename("egalatch.ck" + itoa(episode), path);

	FILE* latchfile = OpenGameFile(filename,"rb");

	if(!latchfile)
		return false;

	RawData = new byte[m_latchplanesize * 4];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, (unsigned char*) RawData))
		{
			return 1;
		}
    }
    else
    {
    	for(int i=0 ; i<(m_latchplanesize*4) ; i++)
    		RawData[i] = fgetc(latchfile);
    }

    fclose(latchfile);

	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4;

	plane1 = 0;
	plane2 = (m_latchplanesize * 1);
	plane3 = (m_latchplanesize * 2);
	plane4 = (m_latchplanesize * 3);

	// ** read the 8x8 tiles **
	// set up the getbit() function of CPlanes class
	CPlanes Planes(RawData);
	Planes.setOffsets(plane1 + m_fontlocation, plane2 + m_fontlocation,
					  plane3 + m_fontlocation, plane4 + m_fontlocation, 0);
	// Load these graphics into the GsFont Class of GsGraphics
	// The original vorticon engine only uses one fontmap, but we use another for
	// extra icons. For example sliders are in that map

	gGraphics.freeFonts();
	gGraphics.createEmptyFontmaps(3);

	gGraphics.getFont(0).loadinternalFont();

	GsFont &Font = gGraphics.getFont(1);
	Font.CreateSurface( gGraphics.Palette.m_Palette, SDL_SWSURFACE );
	sfc = Font.getSDLSurface();

	gGraphics.getFont(2).loadAlternateFont();


	if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);

	Uint8 *pixel = (Uint8*) sfc->pixels;
	SDL_FillRect(sfc, NULL, 0);

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, pixel, 16, 8, m_fonttiles);

	if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

	// prepare to ** read the 16x16 tiles **
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);

	gGraphics.freeTilemap();
	gGraphics.createEmptyTilemaps(2);
	
	loadTilemap(gGraphics.getTileMap(0), Planes, episode, path);
	
	// prepare to ** read the 16x16 tiles **, this is for the second plane.
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);	
	
	loadTilemap(gGraphics.getTileMap(1), Planes, episode, path);

    gGraphics.getTileMap(0).optimizeSurface();
    gGraphics.getTileMap(1).optimizeSurface();

	// make masked tiles according to it's surfaces
	applyMasks();

	////////////////////
	/// Load Bitmaps ///
	////////////////////

	Planes.setOffsets(plane1 + m_bitmaplocation,
					plane2 + m_bitmaplocation,
					plane3 + m_bitmaplocation,
					plane4 + m_bitmaplocation,
					0);

	// decode bitmaps into the BitmapData structure. The bitmaps are
	// loaded into one continuous stream of image data, with the bitmaps[]
	// array giving pointers to where each bitmap starts within the stream.

	for(int p=0 ; p<4 ; p++)
	{
		for(int b=0 ; b<m_bitmaps ; b++)
		{
            GsBitmap &bitmap = gGraphics.getBitmapFromId(b);
			// this points to the location that we're currently
			// decoding bitmap data to

			sfc= bitmap.getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			Uint8* pixel = (Uint8*) sfc->pixels;
			if(p==0)
				SDL_FillRect(sfc, NULL, 0);
			width = bitmap.getWidth(); height = bitmap.getHeight();
			// Now read the raw data

			Planes.readPlane(p, pixel, width, height);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
		}
	}

	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(path, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "bitmap");

	std::set<std::string>::iterator it = filelist.begin();

	for( ; it != filelist.end() ; it++ )
	{
		std::string filename=*it;
		int num = getRessourceID(filename, "bitmap");
        GsBitmap &bitmap = gGraphics.getBitmapFromId(num);
		filename = getResourceFilename("gfx/" + filename, path, false);
		bitmap.loadHQBitmap(filename);
	}

	if(RawData){ delete[] RawData; RawData = NULL;}

    // Create an intro in case it does not exist yet
    std::string fullpath = getResourceFilename("preview.bmp", path, false);
    if( fullpath == "" )
    {   // Not found create it
        fullpath = path + "/preview.bmp";
        fullpath = GetWriteFullFileName(fullpath, true);
        GsBitmap *pBitmap = gGraphics.getBitmapFromStr("TITLE");
        SDL_SaveBMP( pBitmap->getSDLSurface(), fullpath.c_str());
    }

	return true;
}
Exemple #15
0
bool CEGALatch::loadData( std::string &path, short episode, int version, unsigned char *data, bool compresseddata )
{
	std::string filename;
	byte *RawData;
    Uint16 width, height;
    SDL_Surface *sfc;


	filename = getResourceFilename("egalatch.ck" + itoa(episode), path);

	FILE* latchfile = OpenGameFile(filename,"rb");

	if(!latchfile)
		return false;

	RawData = new byte[m_latchplanesize * 4];
    // get the data out of the file into the memory, decompressing it if necessary.
    if (compresseddata)
    {
		if (lz_decompress(latchfile, (unsigned char*) RawData))
		{
			return 1;
		}
    }
    else
    {
    	for(int i=0 ; i<(m_latchplanesize*4) ; i++)
    		RawData[i] = fgetc(latchfile);
    }

    fclose(latchfile);

	// these are the offsets of the different video planes as
	// relative to each other--that is if a pixel in plane1
	// is at N, the byte for that same pixel in plane3 will be
	// at (N + plane3).
	unsigned long plane1, plane2, plane3, plane4;

	plane1 = 0;
	plane2 = (m_latchplanesize * 1);
	plane3 = (m_latchplanesize * 2);
	plane4 = (m_latchplanesize * 3);

	// ** read the 8x8 tiles **
	// set up the getbit() function of CPlanes class
	CPlanes Planes(RawData);
	Planes.setOffsets(plane1 + m_fontlocation, plane2 + m_fontlocation,
					  plane3 + m_fontlocation, plane4 + m_fontlocation, 0);
	// Load these graphics into the CFont Class of CGfxEngine
	// The original vorticon engine only uses one fontmap, but we use another for
	// extra icons. For example sliders are in that map

	g_pGfxEngine->freeFonts();
	g_pGfxEngine->createEmptyFontmaps(3);

	g_pGfxEngine->getFont(0).loadinternalFont();

	CFont &Font = g_pGfxEngine->getFont(1);
	Font.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE );
	sfc = Font.getSDLSurface();

	g_pGfxEngine->getFont(2).loadAlternateFont();


	if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);

	Uint8 *pixel = (Uint8*) sfc->pixels;
	SDL_FillRect(sfc, NULL, 0);

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, pixel, 16, 8, m_fonttiles);

	if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);

	// ** read the 16x16 tiles **
	Planes.setOffsets(plane1 + m_tiles16location,
					 plane2 + m_tiles16location,
					 plane3 + m_tiles16location,
					 plane4 + m_tiles16location,
					 0);

	g_pGfxEngine->freeTilemap();
	g_pGfxEngine->createEmptyTilemap(2);
	CTilemap &Tilemap = g_pGfxEngine->getTileMap(1);
	Tilemap.CreateSurface( g_pGfxEngine->Palette.m_Palette, SDL_SWSURFACE, m_num16tiles, 4, 13 );
	sfc = Tilemap.getSDLSurface();
	SDL_FillRect(sfc,NULL, 0);
	if(SDL_MUSTLOCK(sfc))	SDL_LockSurface(sfc);
	Uint8 *u_pixel = (Uint8*) sfc->pixels;

	for(int p=0;p<4;p++)
		Planes.readPlaneofTiles(p, u_pixel, 13, 16, m_num16tiles);

	if(SDL_MUSTLOCK(sfc))	SDL_UnlockSurface(sfc);

	// Load Hi-Colour, VGA, SVGA Tiles into the tilemap
	filename = getResourceFilename("gfx/ck" + itoa(episode) + "tiles.bmp", path, false);
	if(Tilemap.loadHiresTile(filename))
		g_pLogFile->textOut(GREEN, "VGA Bitmap for Tileset has been loaded successfully!");

	// Adapt the tilemap to the display, so they are faster blit
	Tilemap.optimizeSurface();

	// make masked tiles according to it's surfaces
	applyMasks();

	////////////////////
	/// Load Bitmaps ///
	////////////////////

	Planes.setOffsets(plane1 + m_bitmaplocation,
					plane2 + m_bitmaplocation,
					plane3 + m_bitmaplocation,
					plane4 + m_bitmaplocation,
					0);

	// decode bitmaps into the BitmapData structure. The bitmaps are
	// loaded into one continuous stream of image data, with the bitmaps[]
	// array giving pointers to where each bitmap starts within the stream.

	for(int p=0 ; p<4 ; p++)
	{
		for(int b=0 ; b<m_bitmaps ; b++)
		{
		    CBitmap &bitmap = g_pGfxEngine->getBitmap(b);
			// this points to the location that we're currently
			// decoding bitmap data to

			sfc= bitmap.getSDLSurface();
			if(SDL_MUSTLOCK(sfc)) SDL_LockSurface(sfc);
			Uint8* pixel = (Uint8*) sfc->pixels;
			if(p==0)
				SDL_FillRect(sfc, NULL, 0);
			width = bitmap.getWidth(); height = bitmap.getHeight();
			// Now read the raw data

			Planes.readPlane(p, pixel, width, height);

			if(SDL_MUSTLOCK(sfc)) SDL_UnlockSurface(sfc);
		}
	}

	// optimize the bitmaps and load hq bitmaps if there are some.
	for(int b=0 ; b<m_bitmaps ; b++)
	{
		CBitmap &bitmap = g_pGfxEngine->getBitmap(b);
		bitmap.optimizeSurface();
	}

	std::set<std::string> filelist;
	FileListAdder fileListAdder;
	std::string gfxpath = JoinPaths(path, "gfx");
	GetFileList(filelist, fileListAdder, gfxpath, false, FM_REG);
	FilterFilelist(filelist, "bitmap");

	std::set<std::string>::iterator it = filelist.begin();

	for( ; it != filelist.end() ; it++ )
	{
		std::string filename=*it;
		int num = getRessourceID(filename, "bitmap");
		CBitmap &bitmap = g_pGfxEngine->getBitmap(num);
		filename = getResourceFilename("gfx/" + filename, path, false);
		bitmap.loadHQBitmap(filename);
	}

	if(RawData){ delete[] RawData; RawData = NULL;}

	return true;
}
Exemple #16
0
FFError FFHeaderI::Read(char const *_filename)
{
	if (_filename)
	{
		if (filename) delete[] filename;
		filename = new char [strlen(_filename)+1];
		strcpy(filename,_filename);
	}
	
	FILE *h = OpenGameFile(filename, FILEMODE_READONLY, FILETYPE_PERM);
	
	if (h == NULL)
	{
		ReportError(filename);
		return FF_COULDNOTOPENFILE;
	}
	
	// reset vars
	Clear();
	
	char magic[4];
	unsigned long rffl_version;
	size_t num_files;
	size_t total_headsize;
	
	DWORD bytes_read;
	
	READ_FILE(filename,(void)0,fclose(h),h,magic,4,bytes_read,0)
	READ_FILE(filename,(void)0,fclose(h),h,&rffl_version,4,bytes_read,0)
	READ_FILE(filename,(void)0,fclose(h),h,&num_files,4,bytes_read,0)
	READ_FILE(filename,(void)0,fclose(h),h,&total_headsize,4,bytes_read,0)
	READ_FILE(filename,(void)0,fclose(h),h,&length,4,bytes_read,0)
	
	if (strncmp(magic,"RFFL",4))
	{
		ReportError(filename,"Incorrect file type");
		fclose(h);
		return FF_COULDNOTREADFILE;
	}
	if (rffl_version>0)
	{
		ReportError(filename,"Version not supported");
		fclose(h);
		return FF_COULDNOTREADFILE;
	}
	
	void * header = malloc(total_headsize);
	
	READ_FILE(filename,(void)0,fclose(h),h,header,total_headsize,bytes_read,0)
	
	data = malloc(length);
	
	READ_FILE(filename,(void)0,fclose(h),h,data,length,bytes_read,0)
	
	fclose(h);
	
	// now parse the header
	
	void * headerP = header;
	
	for (unsigned int i=0; i<num_files; ++i)
	{
		char const * fnameP = (char *)((size_t)headerP + 8);
		size_t leng = *(size_t *)((size_t)headerP + 4);
		void * dataP = (void *)((size_t)data + *(size_t *)headerP);
		
		files[HashFunction(fnameP)].add_entry(FFDataI(fnameP,dataP,leng));
		
		// increment pointer
		headerP = (void *)((size_t)headerP + 8 + strlen(fnameP) +4&~3);
	}
	
	free(header);
	
	return FF_OK;
}
Exemple #17
0
/** 
 *  \brief loads a 32-bit uncompressed RGBA targa file, and return a pointer to
 *         the raw image data. The width and height of the image are returned as well.
 *  \param filename Name to the file that will used to read the picture
 *  \param image    Pointer to an array that will contain the image data. This array will be allocated
 *  \param width    Width of the picture that will be set after the picture was read
 *  \param height   Same here for the height
 */
bool LoadTGA(const std::string& filename, Uint8 **image, Uint16 &width, Uint16 &height)
{
	TGA_HEADER header;
	FILE *fp;
	uint bytes_per_pixel;
	unsigned long img_data_size;

	// First check if the files exists
	if ((fp=OpenGameFile(filename, "rb")) == NULL)
		return false;
	
	// read the header
	header.identsize = fgetc(fp);
	fgetc(fp);
	header.imagetype = fgetc(fp);
	fgeti(fp); fgeti(fp); fgetc(fp);
	
	header.xstart = fgeti(fp);
	header.ystart = fgeti(fp);
	header.width = fgeti(fp);
	header.height = fgeti(fp);
	header.bpp = fgetc(fp);
	fgetc(fp);
	
	// Check if the header meet our requirements
	if (header.imagetype != TGA_RGB)
	{
		g_pLogFile->textOut(PURPLE,"<br>LoadTGA: " + filename + ": imagetype must be RGBA uncompressed!<br>");
		fclose(fp);
		return false;
	}

	if (header.bpp != 32)
	{
		g_pLogFile->textOut(PURPLE,"<br>LoadTGA: " + filename + ": image bpp must be 32 (RGB w/ alpha channel)<br>");
		fclose(fp);
		return false;
	}
	
	// Set some variables values so the pictures can be used outside this code
	width = header.width;
	height = header.height;
	
	bytes_per_pixel = (header.bpp / 8);
	img_data_size = header.width * header.height * bytes_per_pixel;

	// allocate memory for the image buffer
	*image = new byte [img_data_size];
	if (*image == NULL)
	{
		fclose(fp);
		return false;
	}
	
	// Read the picture data
	const uint elem_read = fread(*image, img_data_size, 1, fp);
	fclose(fp);

	// Check if the picture was read correctly
	if(elem_read != 1)
	{
		delete [] *image;
		*image  = NULL;
		return false;
	}
	else
		return true;
}
Exemple #18
0
Sprite_Header_Chunk::Sprite_Header_Chunk(const char * file_name, Chunk_With_Children * parent)
: Chunk_With_Children(parent,"SPRIHEAD")
{
// Load in whole chunk and traverse
	FILE *rif_file;
	DWORD file_size;
	DWORD file_size_from_file;
	char * buffer;
	char * buffer_ptr;
	char id_buffer[9];

	Parent_File = this;

	error_code = 0;


	rif_file = OpenGameFile(file_name, FILEMODE_READONLY, FILETYPE_PERM);	
	if (rif_file == NULL) {
		return;
	}

	fseek(rif_file, 0, SEEK_END);
	file_size = ftell(rif_file);
	rewind(rif_file);
	
	if (fread(id_buffer, 1, 8, rif_file) != 8) {
		error_code = CHUNK_FAILED_ON_LOAD;
		fclose(rif_file);
		return;
	}	

	if (strncmp(id_buffer, "SPRIHEAD", 8) != 0) {
		error_code = CHUNK_FAILED_ON_LOAD_NOT_RECOGNISED;
		fclose(rif_file);
		return;
	}	

	if (fread(&file_size_from_file, 1, 4, rif_file) != 4) {
		error_code = CHUNK_FAILED_ON_LOAD;
		fclose(rif_file);
		return;
	}	

	if (file_size != file_size_from_file) {
		error_code = CHUNK_FAILED_ON_LOAD_NOT_RECOGNISED;
		fclose(rif_file);
		return;
	}	

	buffer = new char [file_size];

	if (fread(buffer, 1, (file_size-12), rif_file) != (file_size-12)) {
		error_code = CHUNK_FAILED_ON_LOAD;
		delete [] buffer;
		
		fclose(rif_file);
		return;
	}

	fclose(rif_file);
	
	// Process the file

	buffer_ptr = buffer;

	
	// The start of the first chunk

	while ((buffer_ptr-buffer)< ((signed) file_size-12) && !error_code) {
		if ((*(int *)(buffer_ptr + 8)) + (buffer_ptr-buffer) > ((signed) file_size-12)) {
			error_code = CHUNK_FAILED_ON_LOAD_NOT_RECOGNISED;
			break;
		}

		DynCreate(buffer_ptr);
		buffer_ptr += *(int *)(buffer_ptr + 8);
	}

	delete [] buffer;
}
bool IniReader::Parse() {
	FILE* f = OpenGameFile(m_filename, "r");
	if(f == NULL)
		return false;

	bool res = true;
	enum ParseState {
		S_DEFAULT, S_IGNORERESTLINE, S_PROPNAME, S_PROPVALUE, S_SECTION };
	ParseState state = S_DEFAULT;
	std::string propname;
	std::string section;
	std::string value;

	while(!feof(f) && !ferror(f)) {
		unsigned char c = 0;
		if(fread(&c, 1, 1, f) == 0) break;

		if(c == '\r') continue; // ignore this

		switch(state) {
		case S_DEFAULT:
			if(c >= 128) break; // just ignore unicode-stuff when we are in this state (UTF8 bytes at beginning are also handled by this)
			else if(isspace(c)) break; // ignore spaces and newlines
			else if(c == '#') { state = S_IGNORERESTLINE; /* this is a comment */ break; }
			else if(c == '[') { state = S_SECTION; section = ""; break; }
			else if(c == '=') {
				warnings << "WARNING: \"=\" is not allowed as the first character in a line of " << m_filename << endl;
				break; /* ignore */ }
			else { state = S_PROPNAME; propname = c; break; }

		case S_SECTION:
			if(c == ']') {
				if( ! OnNewSection(section) )  { res = false; goto parseCleanup; }
				state = S_DEFAULT; NewSection(section); break; }
			else if(c == '\n') {
				warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " is not closed correctly" << endl;
				state = S_DEFAULT; break; }
			else if(isspace(c)) {
				warnings << "WARNING: section-name \"" << section << "\" of " << m_filename << " contains a space" << endl;
				break; /* ignore */ }
			else { section += c; break; }

		case S_PROPNAME:
			if(c == '\n') {
				warnings << "WARNING: property \"" << propname << "\" of " << m_filename << " incomplete" << endl;
				state = S_DEFAULT; break; }
			else if(isspace(c)) break; // just ignore spaces
			else if(c == '=') { state = S_PROPVALUE; value = ""; break; }
			else { propname += c; break; }

		case S_PROPVALUE:
			if(c == '\n' || c == '#') {
				if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; }
				NewEntryInSection(propname, value);
				if(c == '#') state = S_IGNORERESTLINE; else state = S_DEFAULT;
				break; }
			else if(isspace(c) && value == "") break; // ignore heading spaces
			else { value += c; break; }

		case S_IGNORERESTLINE:
			if(c == '\n') state = S_DEFAULT;
			break; // ignore everything
		}
	}

	// In case the endline is missing at the end of file, finish the parsing of the last line
	if (state == S_PROPVALUE)  {
		if( ! OnEntry(section, propname, value) ) { res = false; goto parseCleanup; }
		NewEntryInSection(propname, value);
	}

	// DEBUG: dump the file
	/*notes << "Dump of " << m_filename << endl;
	for (SectionMap::iterator it = m_sections.begin(); it != m_sections.end(); ++it)  {
		notes << "[" << it->first << "]" << endl;
		for (Section::iterator k = it->second.begin(); k != it->second.end(); ++k)
			notes << k->first << "=" << k->second << endl;
		notes << endl;
	}
	notes << endl;*/

parseCleanup:
	fclose(f);

	return res;
}
///////////////////
// Read a string
static bool GetString(const std::string& filename, const std::string& section, const std::string& key, std::string& string, bool abs_fn)
{
	FILE	*config = NULL;
	std::string	Line;
	std::string	tmpLine;
	std::string	curSection;
	std::string	temp;
	std::string	curKey;
	size_t	chardest = 0;
	int		Position;
	bool	found = false;
	
	if(filename == "")
		return false;
	
	if(abs_fn) {
		config = OpenGameFile(filename.c_str(), "rt");
	} else
		config = OpenGameFile(filename,"rt");
	if(!config)
		return false;
	
	//string="";
	curSection="";
	temp="";
	curKey="";
	
	// Check for UTF-8 encoded file and skip the UTF-8 mark if it is
	unsigned char utf8mark[3] = {0,0,0};
	if(fread(utf8mark, sizeof(utf8mark), 1, config) == 0) {
		fclose(config);
		return false;
	}
	if (utf8mark[0] != 0xEF || utf8mark[1] != 0xBB || utf8mark[2] != 0xBF)
		fseek(config, 0, SEEK_SET); // Not a UTF-8 file, jump back to the beginning
	
	
	while(!feof(config) && !ferror(config))
	{
		// Parse the lines
		Line = ReadUntil(config, '\n');
		TrimSpaces(Line);
		
		///////////////////
		// Comment, Ignore
		if(Line.size() == 0 || Line[0] == '#')
			continue;
		
		////////////
		// Sections
		if(Line[0] == '[' && Line[Line.size()-1] == ']')
		{
			curSection = Line.substr(1);
			curSection.erase(curSection.size()-1);
			continue;
		}
		
		////////
		// Keys
		chardest = Line.find('=');
		if(chardest != std::string::npos)
		{
			// Key
			Position = (int)chardest;
			tmpLine = Line;
			tmpLine.erase(Position);
			TrimSpaces(tmpLine);
			curKey = tmpLine;
			
			// Check if this is the key were looking for under the section were looking for
			if(stringcasecmp(curKey,key) == 0 && stringcasecmp(curSection,section) == 0)
			{
				// Get the value
				tmpLine = Line.substr(Position+1);
				TrimSpaces(tmpLine);
				string = tmpLine;
				found = true;
				break;
			}
			continue;
		}
	}
	
	fclose(config);
	
	return found;
}