Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Development

Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 06-12-2004, 07:20 AM
monalin crusader
Hill Giant
 
Join Date: May 2004
Posts: 238
Default /guildwar /guildpeace added

Ok i was looking for someting i could fix/add with my knowledge of eqemu source code. I figured /guildwar would be easy. So i added some code to make /guildwar work. It works just fine except for if there are more than 2 sets of guilds warring it doesnt work. I think i've fixed it i'll include what i think will fix that problem but i havent been on yet to check it because it requires 2 people to get on and check its a little harder than jsut logging on.

database.h Line 179 right after #endif

Code:
	bool	SetGuildWar(int32 guildid, int32 gildid2);
	bool	CheckGuildWar(int32 guildid, int32 guildid2);
client_process.cpp around Line 1845
insert this code into "case OP_GuildWar: { break; }"

Code:
	GuildCommand_Struct* gc = (GuildCommand_Struct*) app->pBuffer;
					Client* client=entity_list.GetClientByName(gc->othername);

					if ((GuildRank() == 2) && (client->GuildRank() == 2)) // If both clients are guild leaders
					{

						if(!database.SetGuildWar(GuildDBID(), client->GuildDBID()))
							Message(0, "And error occured while writing to Database");

					}
					else if (client->GuildRank() != 2)
						Message(0, "Error: Your target is not a guild leader!");
					else if (client->GuildDBID == 0)
						Message(0, "Error: Your target is not in a guild!");
					else if (GuildRank() !=2)
						Message(0, "Error: You arent the guild leader!");
					else if (!worldserver.Connected())
						Message(0, "Error: World server disconnected");
					else if (client->GuildDBID() == GuildDBID())
						Message(0,"You are in the same guild, what do you think you are doing?");
					else if (guilddbid == 0)
						Message(0, "Error: You arent in a guild!");

					break;

database.cpp line 740
after bool Database::SetGMSpeed(int32 account_id, int8 gmspeed) function

Code:
bool Database::SetGuildWar(int32 guildid, int32 guildid2)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;

	if (!RunQuery(query, MakeAnyLenString(&query, "INSERT INTO guildwar SET guildid1=%i, guildid2=%i;", guildid, guildid2), errbuf)) 
	{
		cerr << "Error in SetGuildWar Query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);

		return false;
	}
	else 
	{
	safe_delete_array(query);
	return true;
	}
}

bool Database::CheckGuildWar(int32 guildid1, int32 guildid2)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;
	int x;

	if (!RunQuery(query, MakeAnyLenString(&query, "SELECT guildid2 FROM guildwar WHERE guildid1='%i';", guildid1), errbuf, &result)) 
	{
		cerr << "Error in CheckGuildWar Query '" << query << "' " << errbuf << endl;
		safe_delete_array(query);

		return false;
	}
	else
	{

//********************************************************
//Possible Fix for having more than one set of guilds warring at same time	
//		for(x = 0; x <= result; x++)
//		{
//				row = mysql_fetch_row(x);
//				int32 guildid2_match = atoi(row[x]);
//
//				mysql_free_result(x);
//
//				if(guildid2_match == guildid2)
//					return true;
//		}
//********************************************************

		if (mysql_num_rows(result) == 1) 
		{
			row = mysql_fetch_row(result);
			int32 guildid2_match = atoi(row[0]);

			mysql_free_result(result);

			if(guildid2_match == guildid2)
				return true;
		}
	}
	
	return false;

}
mob.cpp Line 2080
inside the if(_CLIENT(mob2)) statment should read.

Code:
				c1 = mob1->CastToClient();
				c2 = mob2->CastToClient();

				if	// if both are pvp they can fight
				(
					c1->GetPVP() &&
					c2->GetPVP()
				)
					return true;
				else if	// if they're dueling they can go at it
				(
					c1->IsDueling() &&
					c2->IsDueling() &&
					c1->GetDuelTarget() == c2->GetID() &&
					c2->GetDuelTarget() == c1->GetID()
				)
					return true;
				// If the two guilds are at war and not in same guild
				else if ((c1->GuildDBID() != 0) && (c2->GuildDBID() != 0) || (c1->GuildDBID() == c2->GuildDBID())) 
				{
					if(!database.CheckGuildWar(c1->GuildDBID(), c2->GuildDBID()) || !database.CheckGuildWar(c2->GuildDBID(), c1->GuildDBID())) 
					{
						Message(0, "You do not have permission to attack that player");
						return false;
					}
					else
						return true;
				}
				else
					return false;
I think that is all of it however if it doesnt complile i didnt get all of it i didnt get any errors compiling and it worked fine in game in alot of testing.
__________________
Ascending Dawn Server Op
Coder/Quester/Mysql
Reply With Quote
  #2  
Old 06-12-2004, 10:07 AM
monalin crusader
Hill Giant
 
Join Date: May 2004
Posts: 238
Default

Oh yes forgot this important part. Add this to your db

CREATE TABLE guildwar (
guildwarid int(11) unsigned NOT NULL auto_increment,
guildid1 int(11) unsigned NOT NULL default '0',
guildid2 int(11) unsigned NOT NULL default '0',
PRIMARY KEY (guildwarid)
) TYPE=MyISAM;

=P
__________________
Ascending Dawn Server Op
Coder/Quester/Mysql
Reply With Quote
  #3  
Old 06-14-2004, 02:18 PM
Dspirit
Fire Beetle
 
Join Date: May 2004
Posts: 28
Default

thanks your work is appreciated lets hope this bumps till its added to cvs by a dev
__________________
Server Owner Midnight Rayne.
Reply With Quote
  #4  
Old 06-14-2004, 02:25 PM
Xabob's Avatar
Xabob
Discordant
 
Join Date: Feb 2004
Location: On your desktop
Posts: 387
Default

Noice work there man i bet yea will get Jr dev now
__________________
[12:38] <RangerDown> I watched Napoleon Dynamite the other day
[12:39] <Xabob> omg
[12:39] <Xabob> want me to shoot you now?
[12:39] <RangerDown> and the first words out of my mouth at the start were:
[12:39] <RangerDown> Hey I bet Rog looks like that

Reply With Quote
  #5  
Old 06-14-2004, 02:28 PM
monalin crusader
Hill Giant
 
Join Date: May 2004
Posts: 238
Default

heres /guildpeace

not sure if this works yet i'll have to test it. Doing so soon.

line 808 in database.cpp

Code:
bool Database::SetGuildPeace(int32 guildid, int32 guildid2)
{
	char errbuf[MYSQL_ERRMSG_SIZE];
    char *query = 0;

	if (!RunQuery(query, MakeAnyLenString(&amp;query, "DELETE FROM guildwar WHERE guildid1=%i, guildid2=%i;", guildid, guildid2), errbuf)) 
	{
		cerr &lt;&lt; "Error in SetGuildPeace Query '" &lt;&lt; query &lt;&lt; "' " &lt;&lt; errbuf &lt;&lt; endl;
		safe_delete_array(query);

		return false;
	}
	else 
	{
	safe_delete_array(query);
	return true;
	}
}
Line 181 in database.h

Code:
	bool	SetGuildPeace(int32 guildid, int32 guildid2);
around line 1857 in client_process.cpp

change

Code:
		case OP_GuildPeace: { break; }
to

Code:
		case OP_GuildPeace: {

					GuildCommand_Struct* gc = (GuildCommand_Struct*) app->pBuffer;
					Client* client=entity_list.GetClientByName(gc->othername);

					if ((GuildRank() == 2) &amp;&amp; (client->GuildRank() == 2)) // If both clients are guild leaders
					{

						if(!database.CheckGuildWar(GuildDBID(), client->GuildDBID()))
							Message(0, "Error: You are not at war with this guild!");
						else if(!database.SetGuildPeace(GuildDBID(), client->GuildDBID()))
							Message(0, "There was an error writing to db!");
						else
							Message(0, "You are now at peace.");

					}	else if (client->GuildRank() != 2)
						Message(0, "Error: Your target is not a guild leader!");
					else if (client->GuildDBID == 0)
						Message(0, "Error: Your target is not in a guild!");
					else if (GuildRank() !=2)
						Message(0, "Error: You arent the guild leader!");
					else if (!worldserver.Connected())
						Message(0, "Error: World server disconnected");
					else if (client->GuildDBID() == GuildDBID())
						Message(0,"You are in the same guild, what do you think you are doing?");
					else if (guilddbid == 0)
						Message(0, "Error: You arent in a guild!");
					break;
				}
__________________
Ascending Dawn Server Op
Coder/Quester/Mysql
Reply With Quote
Reply


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 11:00 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3