Gameconfig Fixer

PC related discussion and other issues.

Gameconfig Fixer

Postby Corewarp on Sun Jul 26, 2009 1:12 am

So, i've transfered my external harddrive around from system to system A LOT the last few weeks and since those darn gameconfig doesn't update(Steam doesn't update them), i've decided to work on a program that does it for me. Currently i've only written the code for L4D. But i'll work on adding all the games to the 'Fixer' so that you can place it in the steam folder and then execute it. A DOS-Like menu pops up and you can select what game you want to update the gameconfig for.

The code for the L4D Gameconfig fixer.(You place it in the Left 4 Dead folder).

Code: Select all
#include<iostream>
#include<fstream>
#include<windows.h>


using namespace std;

int main ()
{
    //Init
    SetConsoleTitle("L4D Gameconfig Fixer - By Corewarp");
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
    //Declarations
    char Path[256];
    ofstream File;
    char Accept;
   
   
    //Code
   
    GetCurrentDirectory(256, Path);
   
    //Write gameconfig.txt
    File.open("GameConfig.txt");
    File << "\"Configs\"" << endl << "{" << endl << "\"Games\"" << endl << "{" << endl << "\"Left 4 Dead\"" << endl << "{" << endl;
    File << "\"GameDir\"  \"" << Path << "\\Left4Dead\"" << endl;
    File << "\"Hammer\"" << endl << "{" << endl;
    File << "\"GameData0\"  \"" << Path << "\\Bin\\Left4Dead.fgd\"" << endl;
    File << "\"TextureFormat\"  \"5\"" << endl << "\"MapFormat\"  \"4\"" << endl << "\"DefaultTextureScale\"  \"0.250000\"" << endl;
    File << "\"DefaultLightmapScale\"  \"16\"" << endl << "\"GameExe\" \"" << Path << "\\Left4Dead.exe\"" << endl;
    File << "\"DefaultSolidEntity\"  \"Func_detail\"" << endl << "\"DefaultPointEntity\"  \"prop_static\"" << endl;
    File << "\"BSP\"  \"" << Path << "\\Bin\\vbsp.exe\"" << endl << "\"Vis\"  \"" << Path << "\\Bin\\vvis.exe\"" << endl;
    File << "\"Light\"  \"" << Path << "\\Bin\\vrad.exe\"" << endl << "\"GameExeDir\"  \"" << Path << "\"" << endl;
    File << "\"MapDir\"  \"" << Path << "\\sdk_content\\mapsrc\"" << endl << "\"BSPDir\"  \"" << Path << "\\left4dead\\Maps\"" << endl;
    File << "\"CordonTexture\"  \"tools\\toolsskybox\"" << endl << "\"MaterialExcludeCount\"  \"0\"" << endl;
    File << "}" << endl << "}" << endl << "}" << endl << "\"SDKVersion\"  \"4\"" << endl << "}";
    File.close();
   
    //Get user acceptance
    system("more gameconfig.txt");
    cout << endl << "Acceptable?[Y/N]: ";
    cin >> Accept;
   
    if(Accept == 'Y' || Accept == 'y')
    {
              system("move gameconfig.txt bin\\gameconfig.txt");
    }
   
    fflush(stdin);
    cout << "Press Enter To Exit...";
    cin.get();


    return 0;
}


Also, if you have any ideas for suggestions for optimization of my code i would love to hear it.
User avatar
Corewarp
Been Here A While
Been Here A While
 
Joined: Thu Mar 13, 2008 6:29 pm

Re: Gameconfig Fixer

Postby zombie@computer on Sun Jul 26, 2009 7:24 am

optimization? how about fprintf?

FILE * pFile;
pFile = fopen ("myfile.txt","w");
fprintf (pFile, "Hello this is line 1\nthis is line two\nhere is a string %s\n and here is the string again %s", path, path)
fclose (pFile);

sorry, im just really fond of formatted printing.

Really not much to optimize, i dare you to find a pc where it matter with this code:p
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Return to Hardware & Software

Who is online

Users browsing this forum: No registered users

cron