Thread: Zone instancing
View Single Post
  #8  
Old 09-21-2008, 04:04 PM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default

I think I figured out where I messed up the group and raid instance flags. Database::setGroupInstFlagNum and Database::setRaidInstFlagNum will need replaced with the ones below.

Can you post, or send me, the quest script you are using to set these? I suck at quest writing so using yours would help me test them.

I like the idea of holding the zone open for a set amount of time. Also, I agree there needs to be ways to check if someone is already flagged, remove the flag, and inherit the flag of the group/raid leader. I also want to add a way to shutdown the zone after a certain amount of time (like ldons).

The only issue I could see with making the type 2 flag raids or groups is some server admins may want to limit how many people can be in the instance. Though I could make a type 3 that flags both.

It might take me a while to figure out why goto is not working in instances. But I will see.

Code:
void Database::setGroupInstFlagNum(int32 charID, int32 orgZoneID)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;
	int32 groupid = 0;
	int instFlag = getCurInstFlagNum();
	int numCharsInGroup = 0; // Used to count number of characters in group
	
	// Find out what group the character is in
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT groupid from group_id where charid=%i", charID), errbuf, &result)) {
		if (mysql_num_rows(result) == 1) {
				row = mysql_fetch_row(result);
				groupid=atoi(row[0]);
		}
		else
			printf("Unable to get group id, char not found!\n");
		mysql_free_result(result);
	}
	else
			printf("Unable to get group id: %s\n",errbuf);
	safe_delete_array(query);
	// Find out how many other characters are in the group
	if (RunQuery(query, ("SELECT COUNT(charid) FROM group_id WHERE groupid=%i", groupid), errbuf, &result)) {
		safe_delete_array(query);
		row = mysql_fetch_row(result);
		numCharsInGroup = atoi(row[0]);
		mysql_free_result(result);
	}
	// Select the character IDs of the characters in the group
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid from group_id where groupid='%i'", groupid), errbuf, &result))
	{
		row = mysql_fetch_row(result);
		
		int i = 0;
		// Set each group members instflag
		while ((i <= numCharsInGroup)) 
		{
			charID = atoi(row[i]);
			setCharInstFlag(charID, orgZoneID, instFlag);
			i++;
		}
			safe_delete_array(query);
			mysql_free_result(result);
	}
	// Increment the curInstFlagNum
	incrCurInstFlagNum(instFlag);
}
Code:
void Database::setRaidInstFlagNum(int32 charID, int32 orgZoneID)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;
    MYSQL_RES *result;
    MYSQL_ROW row;
	int32 raidid = 0;
	int instFlag = getCurInstFlagNum();
	int numCharsInRaid = 0; // Used to count number of characters in raid

	// Find out what raid the character is in
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT raidid from raid_members where charid=%i", charID), errbuf, &result)) {
		safe_delete_array(query);
		if (mysql_num_rows(result) == 1) {
			row = mysql_fetch_row(result);
			raidid=atoi(row[0]);
			mysql_free_result(result);
		}
		else
			printf("Unable to get raidid, char not found!\n");
		mysql_free_result(result);
	}
	else
			printf("Unable to get raid id: %s\n",errbuf);
	safe_delete_array(query);
	// Find out how many other characters are in the raid
	if (RunQuery(query, ("SELECT COUNT(charid) FROM raid_members WHERE raidid=%i", raidid), errbuf, &result)) {
		row = mysql_fetch_row(result);
		numCharsInRaid = atoi(row[0]);
		mysql_free_result(result);
		safe_delete_array(query);
	}
	// Select the character IDs of the characters in the raid
	if (RunQuery(query, MakeAnyLenString(&query, "SELECT charid from raid_members where raidid='%i'", raidid), errbuf, &result))
	{
		int i = 0;
		row = mysql_fetch_row(result);
		// Set each group members instflag
		while ((i <= numCharsInRaid)) 
		{
			charID = atoi(row[i]);
			setCharInstFlag(charID, orgZoneID, instFlag);
			i++;
		}
			safe_delete_array(query);
			mysql_free_result(result);
	}
	// Increment the curInstFlagNum
	incrCurInstFlagNum(instFlag);
}