Page 1 of 1

CTD With latest Zip.

Posted: Sat Oct 20, 2007 7:06 am
by TMS
Crashes everytime he tries to buy an item from an vendor.

Used Macro: http://macroquest2.com/phpBB2/viewtopic ... ht=tribute

Code: Select all

[MQ2]Return - Returned to /call distCalc ${YY} ${XX} ${Me.Y} ${Me.X}
[MQ2]Return - Returned to /call amIClose ${Y} ${X}
[MQ2]Echo - [MQ2] BAZAARFIND.MAC(runToMerchant): At merchant...
[MQ2]WriteChatColor([MQ2] BAZAARFIND.MAC(runToMerchant): At merchant...)
[MQ2]Call - Calling subroutine waitTillDone with params 
[MQ2]Call - Calling subroutine Buyitem with params 
[MQ2]Call - Calling subroutine buy with params "Mushroom Cap Armguards" 1
[MQ2]GetFuncParam(1): 'item ItemToBuy'
[MQ2]GetFuncParam(2): ' int amount)'
First-chance exception at 0x03024ea7 (MQ2Main.dll) in eqgame.exe: 0xC0000005: Access violation reading location 0x00000000.



Code: Select all

--- e:\games\mq2\mq2main\mq2datatypes.h ----------------------------------------
		TypeMember(MaxPower);
		TypeMember(Purity);
		TypeMember(Accuracy);
		TypeMember(CombatEffects);
		TypeMember(DoTShielding);
	}

	~MQ2ItemType()
	{
	}

	bool GETMEMBER();
	DECLAREGETMETHOD();

	 bool ToString(MQ2VARPTR VarPtr, PCHAR Destination)
	{
		if (!VarPtr.Ptr)
03024E90  mov         eax,dword ptr [esp+4] 
03024E94  test        eax,eax 
03024E96  jne         MQ2ItemType::ToString+0Dh (3024E9Dh) 
			return false;
03024E98  xor         al,al 
		TypeMember(DoTShielding);
	}

	~MQ2ItemType()
	{
	}

	bool GETMEMBER();
	DECLAREGETMETHOD();

	 bool ToString(MQ2VARPTR VarPtr, PCHAR Destination)
	{
		if (!VarPtr.Ptr)
			return false;
		strcpy(Destination,((PCONTENTS)VarPtr.Ptr)->Item->Name);
		return true;
	}
03024E9A  ret         8    
		strcpy(Destination,((PCONTENTS)VarPtr.Ptr)->Item->Name);
03024E9D  mov         ecx,dword ptr [eax+90h] 
03024EA3  mov         edx,dword ptr [esp+8] 
[color=#FF0000]03024EA7  mov         al,byte ptr [ecx] [/color]
03024EA9  mov         byte ptr [edx],al 
03024EAB  add         ecx,1 
03024EAE  add         edx,1 
03024EB1  test        al,al 
03024EB3  jne         MQ2ItemType::ToString+17h (3024EA7h) 
		return true;
03024EB5  mov         al,1 
	}
03024EB7  ret         8   

MQ2Datatypes.h

Code: Select all

	~MQ2ItemType()
	{
	}

	bool GETMEMBER();
	DECLAREGETMETHOD();

	 bool ToString(MQ2VARPTR VarPtr, PCHAR Destination)
	{
		if (!VarPtr.Ptr)
			return false;
		[color=red]strcpy(Destination,((PCONTENTS)VarPtr.Ptr)->Item->Name);[/color]
		return true;
	}
	void InitVariable(MQ2VARPTR &VarPtr) 
	{
		VarPtr.Ptr=malloc(sizeof(CONTENTS));
		ZeroMemory(VarPtr.Ptr,sizeof(CONTENTS));
	}
	void FreeVariable(MQ2VARPTR &VarPtr) 
	{
		free(VarPtr.Ptr);
	}

Posted: Sat Oct 20, 2007 7:52 am
by Kroak
Have you tried changing "item" (the one by itself) to "Item" ?

Posted: Sat Oct 20, 2007 11:37 am
by TMS
Kroak wrote:Have you tried changing "item" (the one by itself) to "Item" ?
Nope, not yet.

Will do later ; atm i dont have the time to play.

Changing

Code: Select all

Sub Buy(item ItemToBuy, int amount
to

Code: Select all

Sub Buy([color=red]I[/color]tem ItemToBuy, int amount
Fixed it.

Posted: Sat Oct 20, 2007 2:36 pm
by dont_know_at_all
Sub Buy is not in the macro you linked...

Posted: Sat Oct 20, 2007 4:40 pm
by TMS
dont_know_at_all wrote:Sub Buy is not in the macro you linked...
It's the include buy.inc - Sorry.

Code: Select all

| 
| buy.inc 
| Buy Include File needed for macros 
| Version 1.7b 
| 
| Date: August 20, 2005 
| UPDATED BY OUNVME 
| 
| 14 MAR 2006: Armysoldier refined code to improve speed 
| 
| Please be sure to get the lastest updates at http://www.soc-music.com/mq2 
| 
| These file MUST be in the common directory in your macros directory. 
| 
| Usage: /call Buy (ItemToBuy) (Amount Needed) 
| 
| Use the Buy function for buying if you need a set total amount, like if you have 
| 20 of the item on you already and you need a total of 30, it will only buy 10 
| of the item. 
| 
| Usage: /call PCBuy (ItemToBuy) (Amount to buy off merchant) 
| 
| Use the PCBuy function if you don't need a set total amount, you just need 
| a set amount off that merchant. 
| 
| Disclaimer: 
| Code was used from other programers also from the MQ Forums. 
| 


#event Broke "#*#you cannot afford#*#" 
#event Broke "#*#you can't afford#*#" 

[color=red]Sub Buy(item ItemToBuy, int amount) [/color]
/echo Buying ${ItemToBuy}! 
/declare QTY int Inner 
/declare l2 local int 

|---SMALL delay to allow the MERCHANT Window to populate

/delay ${Math.Calc[${DelayMult}*2]}s

/varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]} 
/delay 1s 
/if (${FindItemCount[${ItemToBuy}]}>= ${amount}) { 
     /echo Done! 
     /return 
   }    
/varset l2 ${Window[MerchantWnd].Child[ItemList].List[=${ItemToBuy},2]} 
/if (!${l2}) { 
        /echo couldn't find ${ItemToBuy} 
        /endm 
    } else { 
        /notify MerchantWnd ItemList listselect ${l2} 
        /notify MerchantWnd ItemList leftmouse ${l2} 
/delay 2          

    }  

/echo Buying ${ItemToBuy} Till I get ${amount}  
:Loop 

   /if (${QTY}>19) { 
       /buyitem 20 
       /delay 1s 
       /doevents 
       /varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]} 
       /goto :Loop 
       } ELSE { 
   /if (${QTY}>0 && ${QTY}<20) { 
       /buyitem ${QTY} 
       /delay 1s 
       /varset QTY ${Math.Calc[${amount}-${FindItemCount[${ItemToBuy}]}]} 
       } 
} 
/if (${QTY}==0) { 
       /echo Done! 
       /return 
       } 
/goto :Loop 

/return 



Sub Event_Broke 
   /echo Error: You are out of money! 
   /beep 
   /endmacro 
/return

Posted: Sat Oct 20, 2007 6:39 pm
by dont_know_at_all
Yeah, well, the macro you linked doesn't call the macro anyway. It surprises me that changing it from "item" to "Item" had any effect.

Code: Select all

Sub Buy(string ItemToBuy,int amount)