Permalink
Browse files

ADDED: A guild member count cap, above a certain count clients within…

… the guild lock up, the added cap is the same as Blizzard had for 3.3.5a ( 500 members )
  • Loading branch information...
dfighter1985 committed Mar 17, 2012
1 parent 6ba74cf commit e2cd951742637310ae28a7f5f3a6b885b34b78cb
Showing with 33 additions and 1 deletion.
  1. +5 −1 src/arcemu-world/Guild.h
  2. +19 −0 src/arcemu-world/GuildHandler.cpp
  3. +9 −0 src/arcemu-world/Level3.cpp
View
@@ -23,7 +23,11 @@
class PlayerInfo;
#define MAX_GUILD_RANKS 10
enum{
MAX_GUILD_RANKS = 10,
MAX_GUILD_MEMBERS = 500
};
enum PETITION_TURNIN_ERRORS
{
ERR_PETITION_OK,
@@ -90,6 +90,16 @@ void WorldSession::HandleInviteToGuild(WorldPacket & recv_data)
Guild::SendGuildCommandResult(this, GUILD_INVITE_S, "", GUILD_NOT_ALLIED);
return;
}
pGuild->getLock().Acquire();
uint32 memberCount = pGuild->GetNumMembers();
pGuild->getLock().Release();
if( memberCount >= MAX_GUILD_MEMBERS ){
SystemMessage( "Your guild is full." );
return;
}
Guild::SendGuildCommandResult(this, GUILD_INVITE_S, inviteeName.c_str(), GUILD_U_HAVE_INVITED);
//41
@@ -123,6 +133,15 @@ void WorldSession::HandleGuildAccept(WorldPacket & recv_data)
{
return;
}
pGuild->getLock().Acquire();
uint32 memberCount = pGuild->GetNumMembers();
pGuild->getLock().Release();
if( memberCount >= MAX_GUILD_MEMBERS ){
plyr->UnSetGuildInvitersGuid();
SystemMessage( "That guild is full." );
return;
}
pGuild->AddGuildMember(plyr->m_playerInfo, NULL);
}
@@ -3692,6 +3692,15 @@ bool ChatHandler::HandleGuildJoinCommand(const char* args, WorldSession* m_sessi
if(pGuild)
{
pGuild->getLock().Acquire();
uint32 memberCount = pGuild->GetNumMembers();
pGuild->getLock().Release();
if( memberCount >= MAX_GUILD_MEMBERS ){
m_session->SystemMessage( "That guild is full." );
return true;
}
pGuild->AddGuildMember(ptarget->getPlayerInfo(), m_session, -2);
GreenSystemMessage(m_session, "You have joined the guild '%s'", pGuild->GetGuildName());
sGMLog.writefromsession(m_session, "Force joined guild '%s'", pGuild->GetGuildName());

7 comments on commit e2cd951

@Lillecarl

This comment has been minimized.

Show comment
Hide comment
@Lillecarl

Lillecarl Mar 25, 2012

Why are you using lock everywhere? I dont think the server will really crash if the variable would happen to change exactly as you invite another player to a group, it would just let you invite even another one?

Lillecarl replied Mar 25, 2012

Why are you using lock everywhere? I dont think the server will really crash if the variable would happen to change exactly as you invite another player to a group, it would just let you invite even another one?

@WAmadeus

This comment has been minimized.

Show comment
Hide comment
@WAmadeus

WAmadeus Mar 25, 2012

Member

Do you know what a "lock" is?

Member

WAmadeus replied Mar 25, 2012

Do you know what a "lock" is?

@Lillecarl

This comment has been minimized.

Show comment
Hide comment
@Lillecarl

Lillecarl Mar 25, 2012

Read about it, never used it. So i cannot say i am sure, no. But i have never seen any other project (i mean really no other project, not just wow servers) use this many locks. And i happened to ask why, not say that it is wrong.

Lillecarl replied Mar 25, 2012

Read about it, never used it. So i cannot say i am sure, no. But i have never seen any other project (i mean really no other project, not just wow servers) use this many locks. And i happened to ask why, not say that it is wrong.

@WAmadeus

This comment has been minimized.

Show comment
Hide comment
@Lillecarl

This comment has been minimized.

Show comment
Hide comment
@Lillecarl

Lillecarl Mar 25, 2012

In other words, this code is not thread safe and therefore you lock it and run it in a separate thread?

Lillecarl replied Mar 25, 2012

In other words, this code is not thread safe and therefore you lock it and run it in a separate thread?

@WAmadeus

This comment has been minimized.

Show comment
Hide comment
@WAmadeus

WAmadeus Mar 25, 2012

Member

You use a "lock" to make it "thread safe". It does not run in a separate thread.

A "lock" was used to ensure that only one thread can access "pGuild->GetNumMembers()" at a time.

Member

WAmadeus replied Mar 25, 2012

You use a "lock" to make it "thread safe". It does not run in a separate thread.

A "lock" was used to ensure that only one thread can access "pGuild->GetNumMembers()" at a time.

@Lillecarl

This comment has been minimized.

Show comment
Hide comment
@Lillecarl

Lillecarl Mar 25, 2012

Okay, thanks for the "lesson" =) Now i "know" how this works =)

Lillecarl replied Mar 25, 2012

Okay, thanks for the "lesson" =) Now i "know" how this works =)

Please sign in to comment.