Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
Fix % character in in config files causing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Impact123 committed Aug 27, 2023
1 parent 8a06973 commit af6604e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 9 additions & 9 deletions autoexecconfig.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <sourcemod>

#define AUTOEXECCONFIG_VERSION "0.1.5"
#define AUTOEXECCONFIG_VERSION "0.1.6"
#define AUTOEXECCONFIG_URL "https://forums.alliedmods.net/showthread.php?t=204254"

// Append
Expand Down Expand Up @@ -401,7 +401,7 @@ stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValu

GetPluginFilename(g_hPluginHandle, writebuffer, sizeof(writebuffer));
Format(writebuffer, sizeof(writebuffer), "// ConVars for plugin \"%s\"", writebuffer);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);
}

// Spacer
Expand All @@ -414,7 +414,7 @@ stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValu
{
// We have no newlines, we can write the description to the file as is
Format(writebuffer, sizeof(writebuffer), "// %s", description);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);
}
else
{
Expand All @@ -438,28 +438,28 @@ stock int AutoExecConfig_AppendValue(const char[] name, const char[] defaultValu

// Default
Format(writebuffer, sizeof(writebuffer), "// Default: \"%s\"", defaultValue);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);


// Minimum
if (hasMin)
{
Format(writebuffer, sizeof(writebuffer), "// Minimum: \"%f\"", min);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);
}


// Maximum
if (hasMax)
{
Format(writebuffer, sizeof(writebuffer), "// Maximum: \"%f\"", max);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);
}


// Write end and defaultvalue
Format(writebuffer, sizeof(writebuffer), "%s \"%s\"", name, defaultValue);
fFile.WriteLine(writebuffer);
fFile.WriteLine("%s", writebuffer);


fFile.Close();
Expand Down Expand Up @@ -520,7 +520,7 @@ stock int AutoExecConfig_FindValue(const char[] cvar, char[] value, int size, bo
int valueend;
int cvarend;

// Just an reminder to self, leave the values that high
// Just a reminder to self, leave the values that high
char sConvar[64];
char sValue[64];
char readbuffer[2048];
Expand Down Expand Up @@ -703,7 +703,7 @@ stock int AutoExecConfig_CleanFile()
if (count < 2 || !firstreached)
{
ReplaceString(readbuffer, sizeof(readbuffer), "\n", "");
fFile2.WriteLine(readbuffer);
fFile2.WriteLine("%s", readbuffer);
}


Expand Down
5 changes: 5 additions & 0 deletions autoexecconfig.sp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public void OnPluginStart()
AutoExecConfig_CreateConVar("321isgreaterthan123", "Anothervalue", "Convar with numbers");
SetAppend(appended);
SetError(error);

AutoExecConfig_CreateConVar("somespecialconvar", "%%%somevalue%%%", "Convar with percent signs");
SetAppend(appended);
SetError(error);



// Execute the given config
Expand Down

0 comments on commit af6604e

Please sign in to comment.