Can I use this function to read a percent Value from an ini?
For example it would be something like this
if (Life drops below X percent)
(cDrinkaPotion)
The code I have so far only reads key values and such, I dont know how to read a number value..
bool readConfig ()
{
char pFile[65535];
strncpy_s(pFile, sizeof(pFile), szPath, sizeof(pFile));
strcat_s(pFile, "\\mMap.ini");
char nRet[65535];
for (int i = 0; i < ArraySize(pEntries); i++)
{
GetPrivateProfileString(pEntries[i].pSection, pEntries[i].pKey, pEntries[i].pDefault, nRet, sizeof(nRet), pFile);
if (pEntries[i].nType == CONFIG_BOOL)
*(PBOOL)pEntries[i].nVar = getBool(nRet);
else if (pEntries[i].nType == CONFIG_INT)
*(PINT)pEntries[i].nVar = atoi(nRet);
else if (pEntries[i].nType == CONFIG_STRING)
strncpy_s((PCHAR)pEntries[i].nVar, sizeof((PCHAR)pEntries[i].nVar), nRet, sizeof(nRet));
}
return true;
}
#ifndef _CONFIG_H
#define _CONFIG_H
#define CONFIG_BOOL 1
#define CONFIG_INT 2
#define CONFIG_STRING 3
struct ConfigEntry {
char* pSection;
char* pKey;
char* pDefault;
int nType;
LPVOID nVar;
};
bool readConfig ();
bool getBool(char* pRet);
VOID setConfig(char* pKey, char* pValue);
#endif