$char(gem,xxx) problem.

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

$char(gem,xxx) problem.

Post by grimjack » Fri Sep 19, 2003 11:49 am

Spells memed in gem 8 are always returning -2.

Code: Select all

   if (pSpellSlot->spellstate != 0) {
      strcpy(szTemp,"-2");
   } else {
Can anyone think of any reason why the spellstate of a spell in gem 8 would return != 0 always?

Thanks
GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

User avatar
pooz
a lesser mummy
a lesser mummy
Posts: 44
Joined: Fri Jun 27, 2003 1:01 pm

Post by pooz » Fri Sep 19, 2003 12:07 pm


User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri Sep 19, 2003 12:41 pm

I'm using the "Fix" from that post. Gem 1-7 works fine. It's gem 8 that is the problem now.

Thanks
GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Fri Sep 19, 2003 12:44 pm

do you have both the temporary fix [sp+1] and the real (struct) fix?
That would bust slot 8
- Plazmic

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri Sep 19, 2003 12:46 pm

Plazmic wrote:do you have both the temporary fix [sp+1] and the real (struct) fix?
That would bust slot 8
Good point. I have whatever is in the current CVS. I'll remove the [sp+1] fix and see if both are in cvs.

Thanks
Grimjack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri Sep 19, 2003 12:48 pm

It looks like both are currently in CVS.

Thanks
GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

User avatar
pooz
a lesser mummy
a lesser mummy
Posts: 44
Joined: Fri Jun 27, 2003 1:01 pm

Post by pooz » Fri Sep 19, 2003 1:08 pm

There seems to be some confusion about how to number the spell gems

in that one function there's two different numberings

MemorizedSpells uses the 0 to 7 numbering
SpellSlots uses the 1 to 8 numbering

Anyway, try this and see if it works

Code: Select all

} else if (!strncmp("char(gem,",szVar,9)) {
	if (!strstr(szVar,")")) {
		DebugSpew("PMP - Bad $char() '%s'",szVar);
		return PMP_ERROR_BADPARM;
	} else {
		PEQCASTSPELLWINDOW pCastSpellWindow = NULL;
		PEQCASTSPELLWINDOW pSpellSlot = NULL;
		pCastSpellWindow = (PEQCASTSPELLWINDOW)*EQADDR_CLASSCASTSPELLWND; 
		i += (strstr(szVar,")")-szVar);
		CHAR szTemp[MAX_STRING] = "0";
		PCHAR szArg = szVar+9;
		WORD Gem = atoi(szArg);
		if (Gem==0 && szArg[0]!='0') {
			if (szArg[0]=='"') szArg++;
			DWORD sp;
[color=RED]			for (sp=1;sp<9;sp++) {
				if (pCharInfo->MemorizedSpells[sp-1] != 0xFFFFFFFF) {
					PCHAR SpellName = GetSpellByID(pCharInfo->MemorizedSpells[sp-1]);
					if (!strnicmp(szArg,SpellName,strlen(SpellName))) {
						if (!EQADDR_CLASSCASTSPELLWND) {
							strcpy(szTemp,"0");
						} else {
							pSpellSlot = (PEQCASTSPELLWINDOW)pCastSpellWindow->SpellSlots[sp];
							if (pSpellSlot->spellstate == 0) {
								itoa(sp,szTemp,10);
							} else {
								strcpy(szTemp,"-2");
							}
						}
					}
				}
			}[/color]
		} else {
			if (Gem>0 && Gem<9) {
				if (pCharInfo->MemorizedSpells[Gem-1] != 0xFFFFFFFF) {
					strcpy(szTemp,GetSpellByID(pCharInfo->MemorizedSpells[Gem-1]));
				} else {
					strcpy(szTemp,"NULL");
				}
			} else {
				strcpy(szTemp,"NULL");
			}
		}
		strcat(szOutput,szTemp);
	}

User avatar
grimjack
Macro Author
Macro Author
Posts: 525
Joined: Thu Nov 07, 2002 6:51 am
Contact:

Post by grimjack » Fri Sep 19, 2003 1:24 pm

pooz wrote:There seems to be some confusion about how to number the spell gems

in that one function there's two different numberings

MemorizedSpells uses the 0 to 7 numbering
SpellSlots uses the 1 to 8 numbering

Anyway, try this and see if it works

Code: Select all

} else if (!strncmp("char(gem,",szVar,9)) {
	if (!strstr(szVar,")")) {
		DebugSpew("PMP - Bad $char() '%s'",szVar);
		return PMP_ERROR_BADPARM;
	} else {
		PEQCASTSPELLWINDOW pCastSpellWindow = NULL;
		PEQCASTSPELLWINDOW pSpellSlot = NULL;
		pCastSpellWindow = (PEQCASTSPELLWINDOW)*EQADDR_CLASSCASTSPELLWND; 
		i += (strstr(szVar,")")-szVar);
		CHAR szTemp[MAX_STRING] = "0";
		PCHAR szArg = szVar+9;
		WORD Gem = atoi(szArg);
		if (Gem==0 && szArg[0]!='0') {
			if (szArg[0]=='"') szArg++;
			DWORD sp;
[color=RED]			for (sp=1;sp<9;sp++) {
				if (pCharInfo->MemorizedSpells[sp-1] != 0xFFFFFFFF) {
					PCHAR SpellName = GetSpellByID(pCharInfo->MemorizedSpells[sp-1]);
					if (!strnicmp(szArg,SpellName,strlen(SpellName))) {
						if (!EQADDR_CLASSCASTSPELLWND) {
							strcpy(szTemp,"0");
						} else {
							pSpellSlot = (PEQCASTSPELLWINDOW)pCastSpellWindow->SpellSlots[sp];
							if (pSpellSlot->spellstate == 0) {
								itoa(sp,szTemp,10);
							} else {
								strcpy(szTemp,"-2");
							}
						}
					}
				}
			}[/color]
		} else {
			if (Gem>0 && Gem<9) {
				if (pCharInfo->MemorizedSpells[Gem-1] != 0xFFFFFFFF) {
					strcpy(szTemp,GetSpellByID(pCharInfo->MemorizedSpells[Gem-1]));
				} else {
					strcpy(szTemp,"NULL");
				}
			} else {
				strcpy(szTemp,"NULL");
			}
		}
		strcat(szOutput,szTemp);
	}
That would bust slot 1. All you have to do is remove the [sp+1] fix. Right now the fixed structure AND the [sp+1] fix are in CVS.


All gems test ok for me now with the original:

Code: Select all

if (pCharInfo->MemorizedSpells[sp] != 0xFFFFFFFF) {
Thanks
GrimJack
When they come to me, they're in trouble, or they want some. I bust people out of prison, hunt down vampires, fight alien gods -- All the fun jobs people are too squeamish or too polite to do themselves.

Call me a mercenary. Call me an assassin. Call me a villain. I am all that and more.

My name's John Gaunt, but out on the streets of Cynosure, I am called...
GrimJack

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Fri Sep 19, 2003 2:27 pm

Current dev CVS shows [sp], not [sp+1]. Might have to wait for the public servers to catch up.
MQ2: Think of it as Evolution in action.