| 
   | 
   | 
  
 
    | 
    | 
    | 
  
 
    | 
   | 
    | 
  
 
    | 
   | 
    | 
  
 
    | 
   | 
    | 
  
 
   | 
  
	
	
		
	
	
	
		
		
		
			
			 
			
				01-29-2013, 09:20 PM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2009 
					
					
					
						Posts: 719
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
				 
				quest::varlink() patch
			 
			 
			
		
		
		
		this will keep improper use of quest::varlink() from crashing the zone. 
	Code: 
	@@ -2293,6 +2293,8 @@
 	const ItemInst* inst = database.CreateItem(item_id);
 	if (!inst)
 		return "INVALID ITEM ID IN VARLINK";
+    if ( !initiator || !initiator->IsClient() )
+        return "INVALID INITIATOR IN VARLINK";
 	char* link = 0;
 	char* tempstr = 0;
 	if (initiator->MakeItemLink(link, inst)) {	// make a link to the item
  
		
	
		
		
		
		
		
		
			
				__________________ 
				I muck about @  The Forge.
 say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-29-2013, 09:31 PM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2009 
					
					
					
						Posts: 719
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		i should lay off the coffee so i can see i missed copying a few lines... 
	Code: 
	Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 2468)
+++ questmgr.cpp	(working copy)
@@ -2293,6 +2293,8 @@
 	const ItemInst* inst = database.CreateItem(item_id);
 	if (!inst)
 		return "INVALID ITEM ID IN VARLINK";
+    if ( !initiator || !initiator->IsClient() )
+        return "INVALID INITIATOR IN VARLINK";
 	char* link = 0;
 	char* tempstr = 0;
 	if (initiator->MakeItemLink(link, inst)) {	// make a link to the item
  
		
	
		
		
		
		
		
		
			
				__________________ 
				I muck about @  The Forge.
 say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-29-2013, 09:49 PM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Developer 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Nov 2012 
					Location: Halas 
					
					
						Posts: 355
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		Increase coffee!    Nice work.  
		
	
		
		
		
		
		
		
			
				__________________ 
				Drajor regards you indifferently -- what would you like your tombstone to say?
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-30-2013, 12:05 AM
			
			
			
		  
	 | 
 
	
		
		
		
			
			| 
			
				
				
				 Discordant 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2005 
					
					
					
						Posts: 435
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		Hey I think you need more coffee ! 
		
	
		
		
		
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-30-2013, 03:11 AM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Developer 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Aug 2006 
					Location: USA 
					
					
						Posts: 5,946
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		That patch should prevent the crash, but it might be best to just move MakeItemLink() to Mob:: instead of Client::, so they can be generated by NPCs as well without requiring a client.  We would still probably want to check for initiator to be safe, but it would allow for more flexibility. 
		
	
		
		
		
		
		
		
			
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-30-2013, 08:49 AM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2009 
					
					
					
						Posts: 719
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		i wasn't familiar with how that function worked, but that does indeed sound like a much better solution. 
		
	
		
		
		
		
		
		
			
				__________________ 
				I muck about @  The Forge.
 say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
 
    | 
   | 
    | 
  
 
	
		
		
		
			
			 
			
				01-31-2013, 12:39 AM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2009 
					
					
					
						Posts: 719
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
				 
				
			 
			 
			
		
		
		
		compiled and tested. won't crash the zone if there is no client initiator, but the results won't print out correctly in all cases, because it doesn't know what client version is being used (falls through to version < SoF). 
	Code: 
	Index: client.h
===================================================================
--- client.h	(revision 2472)
+++ client.h	(working copy)
@@ -773,7 +773,6 @@
 	void	SetStats(uint8 type,int16 set_val);
 	void	IncStats(uint8 type,int16 increase_val);
 	void	DropItem(int16 slot_id);
-	bool	MakeItemLink(char* &ret_link, const ItemInst* inst);
 	int		GetItemLinkHash(const ItemInst* inst);
 	void	SendItemLink(const ItemInst* inst, bool sendtoall=false);
 	void	SendLootItemInPacket(const ItemInst* inst, int16 slot_id);
Index: inventory.cpp
===================================================================
--- inventory.cpp	(revision 2472)
+++ inventory.cpp	(working copy)
@@ -719,7 +719,7 @@
 	}
 }
 
-bool Client::MakeItemLink(char* &ret_link, const ItemInst *inst) {
+bool Mob::MakeItemLink(char* &ret_link, const ItemInst *inst) {
 	//we're sending back the entire "link", minus the null characters & item name
 	//that way, we can use it for regular links & Task links
 	//note: initiator needs to pass us ret_link
@@ -747,7 +747,8 @@
 	uint8 evolvedlevel = 0;
 	int hash = 0;
 	//int hash = GetItemLinkHash(inst);	//eventually this will work (currently crashes zone), but for now we'll skip the extra overhead
-	if (GetClientVersion() >= EQClientRoF)
+    
+	if (IsClient() && CastToClient()->GetClientVersion() >= EQClientRoF)
 	{
 		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", 
 			0,
@@ -765,7 +766,7 @@
 			hash
 		);
 	}
-	else if (GetClientVersion() >= EQClientSoF)
+	else if (IsClient() && CastToClient()->GetClientVersion() >= EQClientSoF)
 	{
 		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", 
 			0,
Index: mob.h
===================================================================
--- mob.h	(revision 2472)
+++ mob.h	(working copy)
@@ -869,6 +869,7 @@
 	void Emote(const char *format, ...);
 	void QuestJournalledSay(Client *QuestInitiator, const char *str);
 	uint32 GetItemStat(uint32 itemid, const char *identifier);
+    bool MakeItemLink(char* &ret_link, const ItemInst* inst);
 
 	//Casting related
  	void SendSpellBarDisable();
Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 2472)
+++ questmgr.cpp	(working copy)
@@ -1099,7 +1099,7 @@
 void QuestManager::itemlink(int item_id) {
 	const ItemInst* inst = database.CreateItem(item_id);
 	char* link = 0;
-	if (initiator->MakeItemLink(link, inst))
+	if (owner->MakeItemLink(link, inst))
 		initiator->Message(0, "%s tells you, %c%s%s%c", owner->GetCleanName(), 0x12, link, inst->GetItem()->Name, 0x12);
 	safe_delete_array(link);
 	safe_delete(inst);
@@ -2295,7 +2295,7 @@
 		return "INVALID ITEM ID IN VARLINK";
 	char* link = 0;
 	char* tempstr = 0;
-	if (initiator->MakeItemLink(link, inst)) {	// make a link to the item
+	if (owner->MakeItemLink(link, inst)) {	// make a link to the item
 		MakeAnyLenString(&tempstr, "%c%s%s%c", 0x12, link, inst->GetItem()->Name, 0x12);
 		strn0cpy(perltext, tempstr,250);	// the perl string is only 250 chars, so make sure the link isn't too large
 		safe_delete_array(tempstr);	// MakeAnyLenString() uses new, so clean up after it
  
		
	
		
		
		
		
		
		
			
				__________________ 
				I muck about @  The Forge.
 say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
 
    | 
   | 
    | 
  
 
	 
	
		 
	 
 
	
	
		
	
	
	
		
		
		
			
			 
			
				01-31-2013, 11:36 AM
			
			
			
		  
	 | 
 
	
		
		
		
			
			| 
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: May 2010 
					
					
					
						Posts: 965
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
			 
			
		
		
		
		I would fail it to SoF+  
Titanium needs to die in a fire. 
		
	
		
		
		
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
	 
	
		 
	 
 
	
	
		
	
	
 
    | 
   | 
    | 
  
 
	
		
		
		
			
			 
			
				02-03-2013, 12:42 AM
			
			
			
		  
	 | 
 
	
		
		
		
			  | 
			
			
				
				
				 Dragon 
				
				
				
			 | 
			  | 
			
				
				
					Join Date: Dec 2009 
					
					
					
						Posts: 719
					 
					
					
					
					     
				 
				
			 | 
		 
		 
		
	 | 
 
	
	
	
		
		
		
			
			
				 
				
			 
			 
			
		
		
		
		this one defaults to SoF instead of titanium. 
it also isn't quite as ignorant as my last one. i was calling MakeItemLink via the quest's owner instead of the initiator, so it'd obviously rarely see a client and instead fall through to the default format (derp). now it prefers to use the quest's initiator, but will fall back to the owner. if neither is found, it produces an error.
 
	Code: 
	Index: client.h
===================================================================
--- client.h	(revision 2479)
+++ client.h	(working copy)
@@ -773,7 +773,6 @@
 	void	SetStats(uint8 type,int16 set_val);
 	void	IncStats(uint8 type,int16 increase_val);
 	void	DropItem(int16 slot_id);
-	bool	MakeItemLink(char* &ret_link, const ItemInst* inst);
 	int		GetItemLinkHash(const ItemInst* inst);
 	void	SendItemLink(const ItemInst* inst, bool sendtoall=false);
 	void	SendLootItemInPacket(const ItemInst* inst, int16 slot_id);
Index: inventory.cpp
===================================================================
--- inventory.cpp	(revision 2479)
+++ inventory.cpp	(working copy)
@@ -719,7 +719,7 @@
 	}
 }
 
-bool Client::MakeItemLink(char* &ret_link, const ItemInst *inst) {
+bool Mob::MakeItemLink(char* &ret_link, const ItemInst *inst) {
 	//we're sending back the entire "link", minus the null characters & item name
 	//that way, we can use it for regular links & Task links
 	//note: initiator needs to pass us ret_link
@@ -747,7 +747,9 @@
 	uint8 evolvedlevel = 0;
 	int hash = 0;
 	//int hash = GetItemLinkHash(inst);	//eventually this will work (currently crashes zone), but for now we'll skip the extra overhead
-	if (GetClientVersion() >= EQClientRoF)
+    
+	// client with RoF or greater
+	if (IsClient() && CastToClient()->GetClientVersion() >= EQClientRoF)
 	{
 		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", 
 			0,
@@ -765,9 +767,10 @@
 			hash
 		);
 	}
-	else if (GetClientVersion() >= EQClientSoF)
+	// client with less than SoF
+	else if (IsClient() && CastToClient()->GetClientVersion() < EQClientSoF)
 	{
-		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", 
+		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X", 
 			0,
 			item->ID, 
 			inst->GetAugmentItemID(0), 
@@ -777,14 +780,14 @@
 			inst->GetAugmentItemID(4), 
 			evolving, 
 			loregroup, 
-			evolvedlevel,
-			0,
+			evolvedlevel, 
 			hash
 		);
 	}
+	// default to SoF format (client or npc)
 	else
 	{
-		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X", 
+		MakeAnyLenString(&ret_link, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", 
 			0,
 			item->ID, 
 			inst->GetAugmentItemID(0), 
@@ -794,7 +797,8 @@
 			inst->GetAugmentItemID(4), 
 			evolving, 
 			loregroup, 
-			evolvedlevel, 
+			evolvedlevel,
+			0,
 			hash
 		);
 	}
Index: mob.h
===================================================================
--- mob.h	(revision 2479)
+++ mob.h	(working copy)
@@ -869,6 +869,7 @@
 	void Emote(const char *format, ...);
 	void QuestJournalledSay(Client *QuestInitiator, const char *str);
 	uint32 GetItemStat(uint32 itemid, const char *identifier);
+    bool MakeItemLink(char* &ret_link, const ItemInst* inst);
 
 	//Casting related
  	void SendSpellBarDisable();
Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 2479)
+++ questmgr.cpp	(working copy)
@@ -2292,10 +2292,13 @@
 const char* QuestManager::varlink(char* perltext, int item_id) {
 	const ItemInst* inst = database.CreateItem(item_id);
 	if (!inst)
-		return "INVALID ITEM ID IN VARLINK";
+		return "ERROR: Invalid item ID in QuestManager::varlink";
+	if ( !(initiator||owner) )
+		return "ERROR: No valid Mob object in QuestManager::varlink";
 	char* link = 0;
 	char* tempstr = 0;
-	if (initiator->MakeItemLink(link, inst)) {	// make a link to the item
+	Mob* caller = initiator ? initiator->CastToMob() : owner->CastToMob();
+	if ( caller->MakeItemLink(link, inst) ) {	// make a link to the item
 		MakeAnyLenString(&tempstr, "%c%s%s%c", 0x12, link, inst->GetItem()->Name, 0x12);
 		strn0cpy(perltext, tempstr,250);	// the perl string is only 250 chars, so make sure the link isn't too large
 		safe_delete_array(tempstr);	// MakeAnyLenString() uses new, so clean up after it
@@ -2736,3 +2739,4 @@
 	worldserver.SendPacket(pack);
 	safe_delete(pack);
 }
+
  
		
	
		
		
		
		
		
		
			
				__________________ 
				I muck about @  The Forge.
 say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
			 
		
		
		
		
		
		
	
		
		
	
	
	 | 
 
 
 
    | 
   | 
    | 
  
 
	 
	
		 
	 
 
 
	
		
	
	
	
	
	
		
	
		 
		Posting Rules
	 | 
 
	
		
		You may not post new threads 
		You may not post replies 
		You may not post attachments 
		You may not edit your posts 
		 
		
		
		
		
		HTML code is Off 
		 
		
	  | 
 
 
	 | 
	
		
	 | 
 
 
All times are GMT -4. The time now is 10:23 PM. 
 
		 
	 
 
 
     | 
     | 
    
   
      | 
     | 
      | 
    
   
     | 
      | 
     | 
    
   
       | 
      | 
       | 
     
    
    
  | 
   |