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
*/