Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-12-2010, 12:01 AM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,072
Default Database Group ID Call

The lovely work of Secrets made some instancing code possible by calling Group ID. The problem with using GetGroup and then GetGroupID is that if you don't have a group in the zone to check, you arent going to get an ID to assign and link up to the stored value of Qglobal to pullt he right instance.

If we could get this committed that would be great, and it works phenominal!

Code:
Index: perlparser.cpp
===================================================================
--- perlparser.cpp	(revision 1478)
+++ perlparser.cpp	(working copy)
@@ -2973,7 +2973,20 @@
 	XSRETURN_EMPTY;
 }
 
+XS(XS_getgroupidbychar);
+XS(XS_getgroupidbychar)
+{
+   dXSARGS;
+   if (items != 1)
+      Perl_croak(aTHX_ "Usage: getgroupidbychar(charid)");
 
+   int32   charid = (int)SvIV(ST(0));
+   int32   ret_id = quest_manager.GetGroupIDByChar(charid);
+
+   XSRETURN_UV(ret_id);
+}
+
+
 /*
 This is the callback perl will look for to setup the
 quest package's XSUBs
@@ -3170,6 +3183,7 @@
 		newXS(strcpy(buf, "removetitle"), XS__removetitle, file);
 		newXS(strcpy(buf, "wearchange"), XS__wearchange, file);
 		newXS(strcpy(buf, "voicetell"), XS__voicetell, file);
+		newXS(strcpy(buf, "getgroupidbychar"), XS_getgroupidbychar, file);
 	XSRETURN_YES;
 }
 
Index: questmgr.cpp
===================================================================
--- questmgr.cpp	(revision 1478)
+++ questmgr.cpp	(working copy)
@@ -2389,3 +2389,13 @@
 	}
 }
 
+int32 QuestManager::GetGroupIDByChar(int32 charid)
+{
+	if(charid)
+	{
+	return	database.GetGroupIDByChar(charid);
+	}
+
+	return 0;
+}
+
Index: questmgr.h
===================================================================
--- questmgr.h	(revision 1478)
+++ questmgr.h	(working copy)
@@ -215,6 +215,7 @@
 	uint8 FactionValue();
 	void wearchange(int8 slot, int16 texture);
 	void voicetell(char *str, int macronum, int racenum, int gendernum);
+	int32 GetGroupIDByChar(int32 charid);
 
 	//not in here because it retains perl types
 	//thing ChooseRandom(array_of_things)
Index: zonedb.cpp
===================================================================
--- zonedb.cpp	(revision 1478)
+++ zonedb.cpp	(working copy)
@@ -1645,6 +1645,23 @@
 	return count;
 }
 
+sint32 ZoneDatabase::GetGroupIDByChar(int32 charid){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+    char *query = 0;
+    MYSQL_RES *result;
+    MYSQL_ROW row;
+	sint32 count=0;
+	if (RunQuery(query, MakeAnyLenString(&query, "SELECT groupid FROM group_id WHERE charid=%d", charid), errbuf, &result)) {
+		if((row = mysql_fetch_row(result))!=NULL)
+			count = atoi(row[0]);
+		mysql_free_result(result);
+	} else {
+		count=0;
+	}
+	safe_delete_array(query);
+	return count;
+}
+
  int8 ZoneDatabase::RaidGroupCount(int32 raidid, int32 groupid)
  {
  	char errbuf[MYSQL_ERRMSG_SIZE];
Index: zonedb.h
===================================================================
--- zonedb.h	(revision 1478)
+++ zonedb.h	(working copy)
@@ -326,6 +326,7 @@
 	 */
 	void RefreshGroupFromDB(Client *c);
 	int8 GroupCount(int32 groupid);
+	sint32 GetGroupIDByChar(int32 groupid);
 	/*
 	 * Raid
 	 */
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 12:23 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3