Jump to content

Recommended Posts

Posted

EasyConfig C++ Class

 

Config files such as *.ini You'll see it's not hard at all to use it.

Please note that there are 2 constructors, an empty one that doesn't require any argument and another one that takes the file name.

If you declare an object without any file name, you'll have to use the SetFileName method.

 

Here's an exemple:

(cpp):

#include "stdafx.h"

 

using namespace std;

 

int main(int argc, char* argv[])

{

ConfigFile myIni;

 

myIni.SetFileName("C:\\Hax.txt");

 

cout << myIni.ReadStringValue("LOL", "value1").c_str() << endl;

 

    cout << "Writing int into value2..." << endl;

 

    myIni.WriteValue("LOL", "value2", 1337);

    cout << myIni.ReadIntValue("LOL", "value2") << endl;

 

    cout << "Writing float into value3..." << endl;

 

    myIni.WriteValue("LOL", "value3", 3.14f);

    cout << myIni.ReadFloatValue("LOL", "value3") << endl;

 

    return 0;

}

 

WriteValue is an overloaded function that works with float, int and strings which is actually what I needed.

The code launches a ConfigFileException when shit happens.

 

 

For exemple:

(cpp):

ConfigFile myIni;

 

cout << myIni.ReadStringValue("LOL", "value1").c_str() << endl;

 

 

In this code, we didn't set a file name. The code will launch an exception that contains,

The file name (In this case, it's ) And the error description To avoid unhandled...

 

 

Exceptions:

(cpp):

ConfigFile myIni;

 

try

{

cout << myIni.ReadStringValue("LOL", "value1").c_str() << endl;

}

catch( ConfigFileException e )

{

cout << "*** EXCEPTION CAUGHT ***"<< endl;

cout << e.fileName << endl;

cout << e.errMessage<< endl;

}

 

 

I  added the exceptions stuff today, so if you find anything i could add/correct, just say And now, the file you're all waiting for:

 

 

EasyCfg.cpp

(cpp):

#pragma once

 

#define FILE_NOT_EXISTING        "The file you tried to open doesn't exist"

#define FILENAME_NOT_DEFINED    "You didn't declare a file name"

#define NO_FILE_NAME            "<no File Name>"

 

class ConfigFileException

{

public:

std::string errMessage;

std::string fileName;

 

ConfigFileException( std::string tmpErrMessage, std::string tmpFileName )

{

fileName = tmpFileName;

errMessage = tmpErrMessage;

}

};

 

class ConfigFile

{

std::string FileName;

 

public:

////////////////////////////////////

ConfigFile( std::string strFile ) {

this->FileName = strFile;

 

if(!FileExists())

{

ConfigFileException e(FILE_NOT_EXISTING, this->FileName);

 

throw e;

}

}

 

ConfigFile( ) {

}

 

~ConfigFile( ) {

}

////////////////////////////////////

 

 

////////////////////////////////////

void SetFileName( std::string newFileName )

{

this->FileName = newFileName;

 

if(!FileExists())

{

ConfigFileException e(FILE_NOT_EXISTING, this->FileName);

 

throw e;

}

}

 

std::string GetFileName()

{

if(this->FileName.size() < 1 )

{

ConfigFileException e(FILENAME_NOT_DEFINED, NO_FILE_NAME);

 

throw e;   

 

return false;

}

 

return this->FileName;

}

 

bool FileExists() //If no file specified, just check if the FileName file exists

{

if(this->FileName.size() < 1 )

{

ConfigFileException e(FILENAME_NOT_DEFINED, NO_FILE_NAME);

 

throw e;   

 

return false;

}

 

bool retVal = false;

std::fstream tmpFile;

 

tmpFile.open(this->FileName.c_str(), std::ios::in);

 

if( tmpFile.is_open() )

retVal = true;

 

tmpFile.close();

 

return retVal;

}

 

bool FileExists( std::string fileName )

{

bool retVal = false;

std::fstream tmpFile;

 

tmpFile.open(fileName.c_str(), std::ios::in);

 

if( tmpFile.is_open() )

retVal = true;

 

tmpFile.close();

 

return retVal;

}

 

int ReadIntValue( std::string section, std::string option )

{

if(!FileExists())

{

ConfigFileException e(FILE_NOT_EXISTING, this->FileName);

 

throw e; //Have fun

}

 

return GetPrivateProfileIntA(section.c_str(), option.c_str(), -1, this->FileName.c_str());

}

 

float ReadFloatValue( std::string section, std::string option )

{

if(!FileExists())

{

ConfigFileException e(FILE_NOT_EXISTING, this->FileName);

 

throw e; //Have fun

}

 

char tmpStr[16] = {'\0'};

 

GetPrivateProfileStringA(section.c_str(), option.c_str(), NULL, tmpStr, 15, this->FileName.c_str());

 

return (float)atof(tmpStr);

}

 

std::string ReadStringValue( std::string section, std::string option )

{

if(!FileExists())

{

ConfigFileException e(FILE_NOT_EXISTING, this->FileName);

 

throw e;

}

 

char tmpStr[256] = {'\0'};

 

GetPrivateProfileStringA(section.c_str(), option.c_str(), NULL, tmpStr, 255, this->FileName.c_str());

 

return std::string(tmpStr);

}

 

void WriteValue( std::string section, std::string option, std::string val )

{

if(this->FileName.size() < 1 )

{

ConfigFileException e(FILENAME_NOT_DEFINED, NO_FILE_NAME);

 

throw e;

}

 

WritePrivateProfileStringA(section.c_str(), option.c_str(), val.c_str(), this->FileName.c_str());

}

 

void WriteValue( std::string section, std::string option, int val )

{

if(this->FileName.size() < 1 )

{

ConfigFileException e(FILENAME_NOT_DEFINED, NO_FILE_NAME);

 

throw e;   

}

 

char tmpResult[10] = {'\0'};

_itoa_s (val, tmpResult, 9, 10);

WritePrivateProfileStringA(section.c_str(), option.c_str(), tmpResult, this->FileName.c_str());

}

 

void WriteValue( std::string section, std::string option, float val )

{

if(this->FileName.size() < 1 )

{

ConfigFileException e(FILENAME_NOT_DEFINED, NO_FILE_NAME);

 

throw e;   

}

 

char tmpResult[16] = {'\0'};

sprintf(tmpResult, "%f", val);

WritePrivateProfileStringA(section.c_str(), option.c_str(), tmpResult, this->FileName.c_str());

}

};

 

 

Download: EasyCfg.cpp

 

 

 

Guest
This topic is now closed to further replies.


  • Posts

    • try this one instead. The one he shared affects every single NPC/player character in the game, the one I posted only affects player characters  https://drive.google.com/file/d/1UtccbD9e50x3WEnQBab2PTZnBHwpcGYM/view?usp=sharing or perhaps i misunderstood; if you could please post a full explanation of the problem you're having with the files, unfortunately i think whatever you're using to translate to english is a bit bad nevermind, i got what you mean, here's the fix   https://drive.google.com/file/d/1av7OHaGSdnVQtcBgb9MhtiIkxVXy3P2y/view?usp=sharing   CanIngnoreCollision=True CanBeIngnoredCollision=True  
    • <dailyReward days="28" autoOpen="true" minimumOnlineTimeSeconds="30" oneRewardPerIP="true" resetIfMissDay="true">   For now, I have these settings in the XML—this is the V1 version I created, though I plan to make further improvements over time. Of course, I’ll also add more protections—MAC, HWID, and perhaps others like account-based restrictions—to make it more secure. We can also implement non-tradable items to further enhance the system's security. I’ll keep posting updates and refining both the system and the interface. I might make a video tomorrow; if you look at the top, you'll see the "auto-open" feature can be toggled on or off, allowing users to rely solely on the `.daily` command. Cheers! Note: If I sell it in this state, I’ll provide support and roll out updates to users. I’m not forcing anyone to buy anything; I’d even provide the patch files so that anyone with the necessary skills can add features, modify it, or improve it further.
    • If the problem is that the target is lost, the action of aiming at another character, upon losing collision, does not allow aiming.   This one works as it should, allowing you to target characters
    • MICROTEXT AND WATERMARKS BREAK MOST RENDERINGS Microtext and watermarks aren’t just small decorative details. They are one of the most common reasons a document fails verification, even when it looks decent at first glance. The issue is that these elements are almost impossible to reproduce “by eye.” Microtext requires precise geometry and legibility at a very small size, while a watermark needs the correct density, transparency, and accurate placement relative to other security features. Any deviation becomes obvious during detailed inspection. ▪ What’s most often done wrong: - microtext is drawn too thick or blurry - the watermark is made either too visible or almost invisible - the positioning between microtext and watermark is ignored - the original printing technology isn’t taken into account when choosing density and shape - The stronger the document’s security features, the less room there is for approximation. What matters here isn’t visual similarity, but accurate reproduction of the original technical characteristics. If your document contains microtext and watermarks, this is always an area that requires extra attention. Write to us in DMs. We’ll review your case and point out exactly which details need the highest precision during rendering. › TG: @mustang_service_ms ( https:// t.me/ mustang_service_ms ) › Channel: Mustang Service ( https:// t.me/ +JPpJCETg-xM1NjNl ) #drawing #microtext #photoshop #editing #watermarks
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..