/ini does not delete keys or sections

A forum for reporting bugs NOT related to custom plugins.

Moderator: MacroQuest Developers

sorvani
a lesser mummy
a lesser mummy
Posts: 36
Joined: Thu Aug 12, 2010 11:30 am

/ini does not delete keys or sections

Post by sorvani » Mon Sep 17, 2012 5:34 pm

Here is the fix. Replace the if block begining on line 2449 in MQ2Commands.cpp

Code: Select all

    if (!strlen(szArg4) && strlen(szArg3)) { //Deleting a key within a [section].
        if (!WritePrivateProfileString(szArg2,szArg3,NULL,szArg1)) {
            sprintf(szOutput,"IniOutput ERROR -- during WritePrivateProfileString: %s",szLine);
            DebugSpew(szOutput);
        } else {
            sprintf(szOutput,"IniOutput Write Successful!");
            DebugSpew("%s: %s",szOutput,szLine);
        }
    } else if (!strlen(szArg4) && !strlen(szArg3)) { //Deleting a [section] and all keys under it.
        if (!WritePrivateProfileString(szArg2,NULL,NULL,szArg1)) {
            sprintf(szOutput,"IniOutput ERROR -- during WritePrivateProfileString: %s",szLine);
            DebugSpew(szOutput);
        } else {
            sprintf(szOutput,"IniOutput Write Successful!");
            DebugSpew("%s: %s",szOutput,szLine);
        }
    } else {
        if (!WritePrivateProfileString(szArg2,szArg3,szArg4,szArg1)) {
            sprintf(szOutput,"IniOutput ERROR -- during WritePrivateProfileString: %s",szLine);
            DebugSpew(szOutput);
        } else {
            sprintf(szOutput,"IniOutput Write Successful!");
            DebugSpew("%s: %s",szOutput,szLine);
        }
    }

Maskoi

Re: /ini does not delete keys or sections

Post by Maskoi » Mon Sep 17, 2012 8:28 pm


sorvani
a lesser mummy
a lesser mummy
Posts: 36
Joined: Thu Aug 12, 2010 11:30 am

Re: /ini does not delete keys or sections

Post by sorvani » Mon Sep 17, 2012 8:55 pm

Aye, this just integrates it in without forcing you to pass a null.

Maskoi

Re: /ini does not delete keys or sections

Post by Maskoi » Mon Sep 17, 2012 9:14 pm

So what the commands look like to delete a section or key?

sorvani
a lesser mummy
a lesser mummy
Posts: 36
Joined: Thu Aug 12, 2010 11:30 am

Re: /ini does not delete keys or sections

Post by sorvani » Mon Sep 17, 2012 10:49 pm

Code: Select all

Delete the section BuffSpells and all it's keys
/ini test.ini BuffSpells

Delete the key "Buff1" in the section "BuffSpells"
/ini test.ini BuffSpells Buff1
here is a snippet from a macro that actively uses said code.

Code: Select all

					/if (${CurSpellLocation.NotEqual[NULL]}) {
							/if (${Me.Book[${CurSpell}]} || ${Me.CombatAbility[${CurSpell}]}) {
								| if the user wants to log scribed spells, add it to the ini
								/if (${LogInBook}) /ini HAVE_NEED_LIST "${Me.CleanName}_SCRIBED" "${CurSpell}" "LVL${CurSpellLevel} ${CurSpellLocation}"
								| always remove the spell from any other section it was listed in
								/ini HAVE_NEED_LIST "${Me.CleanName}_INVENTORY" "${CurSpell}"
								/ini HAVE_NEED_LIST "${Me.CleanName}_BANK" "${CurSpell}"
								/ini HAVE_NEED_LIST "${Me.CleanName}_NEEDED" "${CurSpell}"

sorvani
a lesser mummy
a lesser mummy
Posts: 36
Joined: Thu Aug 12, 2010 11:30 am

Re: /ini does not delete keys or sections

Post by sorvani » Sat Dec 28, 2013 9:21 pm

Any chance that either this, or the one linked by Maskoi could make it in to the main code base?

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

Re: /ini does not delete keys or sections

Post by EqMule » Sun Dec 29, 2013 9:36 am

Added in next release.

Thanks for the submission.
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.