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

Closed Thread
 
Thread Tools Display Modes
  #1  
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);
}
  #2  
Old 09-21-2008, 04:40 PM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Actually, why not just make an option to keep all dynamic zones up for X amount of time after the last player leaves? I wouldn't mind having that for my dynamic zones as well
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
  #3  
Old 09-24-2008, 02:24 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

I'm not going to sticky this one yet, I am still getting a zone crash with the newest code regarding the raid and group types. Could you post a diff to make sure I am not merging incorrectly?
  #4  
Old 09-25-2008, 03:00 AM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default

I am fairly certainly you are merging it correctly. I just screwed up the code. Here are two I found this afternoon that need changed. Basically I had ‘%i’ when it should be %i
It is kinda hard to see but the %i is surrounded by two ‘

I will try to post a full diff by this weekend. I would do it sooner but work is killing me this week.

line 31 inside Database::setGroupInstFlagNum
Code:
// 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))

line 33 inside Database::setRaidInstFlagNum
Code:
// 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))

One side question though. Please don’t laugh to hard (this is my first time writing a quest) below is what I wrote for a quest to set these instance flags. It does not work. I know the quest::setinstflag($charid,18,0); is causing the problem since the says work. It never sets the flags in the database and just hangs at the setinstflag. I figured out it hangs there by swapping the quest::say and quest::setinstflag places. Any idea where I messed up the script? or is my code that wrong?
Code:
sub EVENT_SAY { 
$charid = 0;
$charid = $client->CharacterID(); 
if($text=~/Hail/i){ 
	quest::say("Greetings traveler, Do you want to go play in Blackburrow?"); }
if($text=~/yes/i){ 
	quest::say("Oh wonderful! Do you want to play by yourself, in a group, or in a raid?"); }
if($text=~/self/i){
	quest::say("You can now go play in your own little Blackburrow world.");
	quest::setinstflag($charid,17,0); }
if($text=~/group/i){
	quest::say("Your party can now go play in their own little Blackburrow world.");
	quest::setinstflag($charid,17,1); }
if($text=~/raid/i){
	quest::say("Your raid can now go play in their only little Blackburrow world.");
	quest::setinstflag($charid,17,2); }
if($text=~/setme/i){
	quest::say("Okay then GO PLAY!!!"); 
	quest::setinstflagmanually($charid,17,1500); } 
}
  #5  
Old 09-25-2008, 10:14 AM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

Your quest script is fine. It's your code that you use to call setinstflag that's messed up. I'd put some debug statements in there and try to figure out where it's giving you grief. I've REALLY been wanting to mess around with this but I'm so limited on time right now....
  #6  
Old 09-25-2008, 01:24 PM
joligario's Avatar
joligario
Developer
 
Join Date: Mar 2003
Posts: 1,498
Default

Just out of curiosity, why are they int32 variables instead of just int? Could that make a difference when compiling between the different machines? Does it make a difference compiling on the different machines when typecasting an int -> int32?
  #7  
Old 09-26-2008, 07:06 PM
Rocker8956
Hill Giant
 
Join Date: Sep 2007
Posts: 117
Default

Well I got it working. I will try to post a diff tonight or tomorrow. The quest functions got an overhaul.

Quote:
Originally Posted by joligario View Post
Just out of curiosity, why are they int32 variables instead of just int? Could that make a difference when compiling between the different machines? Does it make a difference compiling on the different machines when typecasting an int -> int32?

I think most programming languages view int and int32 as the same thing. However, I took your suggestion and changed most of the int32 to int. Looks better and is easier to read even if it has little to no effect on the code.
  #8  
Old 09-26-2008, 07:23 PM
AndMetal
Developer
 
Join Date: Mar 2007
Location: Ohio
Posts: 648
Default

Quote:
Originally Posted by joligario View Post
Just out of curiosity, why are they int32 variables instead of just int? Could that make a difference when compiling between the different machines? Does it make a difference compiling on the different machines when typecasting an int -> int32?
To understand int32, we need to look at common/types.h:
Code:
typedef unsigned char		int8;
typedef unsigned char		byte;
typedef unsigned short		int16;
typedef unsigned int		int32;

typedef unsigned char		uint8;
typedef  signed  char		sint8;
typedef unsigned short		uint16;
typedef  signed  short		sint16;
typedef unsigned int		uint32;
typedef  signed  int		sint32;
As I understand, int in C++ assumes signed by default on most compilers:
Quote:
By default, if we do not specify either signed or unsigned most compiler settings will assume the type to be signed
You can certainly use int for 32-bit signed integers, but by using sint32 instead, you don't have to worry about compiler-specific assumptions, plus it can be easier to understand just browsing through the source.
__________________
GM-Impossible of 'A work in progress'
A non-legit PEQ DB server
How to create your own non-legit server

My Contributions to the Wiki
Closed Thread

Thread Tools
Display Modes

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:32 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