$merchant(has,xxx) fixed!

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

Moderator: MacroQuest Developers

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

$merchant(has,xxx) fixed!

Post by EqMule » Mon Jul 28, 2003 7:47 pm

if you wanna get the $merchant commands to work again, here is something you can use...

oh I use a _tcsinc to advance a stringpointer, so you need to have a

Code: Select all

#include <tchar.h>
in your EQLib_MacroParser.cpp as well. Use this until Plazmic releases his fixes which will superseed my bubblegum code...

Code: Select all

					// $merchant(name)
					} else if (!strncmp("merchant(name)",szVar,15)) {
						CHAR szTemp[MAX_STRING] = {0};
						CHAR* szOut;
						i += 14;
						if (!EQADDR_ACTIVEMERCHANT) return FALSE;
						sprintf(szTemp,"%s",*EQADDR_ACTIVEMERCHANT);
						szOut = _tcsinc(szTemp);
						strncpy(szTemp,szOut,(strlen(szOut)-2));
						strcat(szOutput,szTemp);
						j+=strlen(szTemp);
					// $merchant(xxx)
					} else if (!strncmp("merchant(",szVar,9)) {
						CHAR szTemp[MAX_STRING] = {0};
						CHAR* szOut;
						if (!strncmp("merchant()",szVar,10)) {
							if (!EQADDR_ACTIVEMERCHANT) return FALSE;
							sprintf(szTemp,"%s",*EQADDR_ACTIVEMERCHANT);
							szOut = _tcsinc(szTemp);
							strncpy(szTemp,szOut,(strlen(szOut)-2));
							DebugSpew("%s",szTemp);
							i += 9;
							if (!strstr(szTemp, szVar)) {
								strcat(szOutput,"TRUE");
								j+=4;
							} else {
								strcat(szOutput,"FALSE");
								j+=5;
							}
					// $merchant(has,xxx)
					} else if (!strncmp("merchant(has,",szVar,13)) {
						if (!EQADDR_CLASSMERCHWND) return FALSE;
						PEQWINDOW pMerchWindow = NULL;
						pMerchWindow = (PEQWINDOW)*EQADDR_CLASSMERCHWND;
						if (!strstr(szVar,")")) {
							DebugSpew("PMP - Bad $merchant() '%s'",szVar);
							i--;
							szOutput[j] = '@';
							j++;
						} else {
							i += (strstr(szVar,")")-szVar);
							if (pMerchWindow->Open == 1) {
								PCHAR szArg = szVar+13;
								if (szArg[0]=='"') szArg++;
								CHAR szTemp[MAX_STRING] = {0};
								DebugSpew("$merchant(has) -- looking for '%s'", szArg);
								DWORD i;
								BOOL Found = FALSE;
								for (i=0;i<79;i++) {
									if (pMerchWindow->ItemDesc[i]) {
										if (!strnicmp(szArg,pMerchWindow->ItemDesc[i]->Name,strlen(pMerchWindow->ItemDesc[i]->Name))) {
											Found=TRUE;
											DebugSpew("Merchant does have: %s",pMerchWindow->ItemDesc[i]->Name);
											break;
										}
									}
								}
								if (Found) {
									strcat(szOutput,"TRUE");
									j+=4;
								} else {
									strcat(szOutput,"FALSE");
									j+=5;
								}
							} else {
								strcat(szOutput,"FALSE");
								j+=5;
							}
						}

						// $merchant(Unknown)
						} else {
							DebugSpew("PMP - Bad $merchant() '%s'",szVar);
							i--;
							szOutput[j] = '@';
							j++;
						}

					// $merchant
					} else if (!strncmp("merchant",szVar,8)) {
						if (!EQADDR_CLASSMERCHWND) return FALSE;
						PEQWINDOW pMerchWindow = NULL;
						pMerchWindow = (PEQWINDOW)*EQADDR_CLASSMERCHWND;
						i += 7;
						if (pMerchWindow->Open == 1) {
							strcat(szOutput,"TRUE");
							j+=4;
						} else {
							strcat(szOutput,"FALSE");
							j+=5;
						}
eqlib.h needs this

Code: Select all

extern PCHAR *EQADDR_ACTIVEMERCHANT;
eqlib_main.cpp needs this in the right places...

Code: Select all

PCHAR *EQADDR_ACTIVEMERCHANT=0;
and

Code: Select all

	GetPrivateProfileString("Memory Locations","ActiveMerchant","0",szBuffer,MAX_STRING,ClientINI);            EQADDR_ACTIVEMERCHANT = (PCHAR*)strtoul(szBuffer,NULL,16); 
eqgame.ini needs this

Code: Select all

ActiveMerchant=00714970
code not bugtested, I need feedback.
Last edited by EqMule on Tue Aug 05, 2003 8:52 pm, edited 1 time in total.
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.

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

Post by EqMule » Tue Aug 05, 2003 8:52 pm

can I get this tested and cvsed? 8)
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.