View Single Post
  #9  
Old 02-03-2013, 12:42 AM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

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;
Reply With Quote