[6913] Fixed guild creation after adding stronger checks.

Fixed _return_ typo in guild charter sign code.
Merged some sql queries into one.

Signed-off-by: ApoC <apoc@nymfe.net>
This commit is contained in:
ApoC 2008-12-16 05:15:39 +01:00
parent d43bd7efe9
commit 98281cc389
2 changed files with 26 additions and 36 deletions

View file

@ -250,15 +250,16 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
// solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?) // solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
uint32 petitionguid_low = GUID_LOPART(petitionguid); uint32 petitionguid_low = GUID_LOPART(petitionguid);
QueryResult *result = CharacterDatabase.PQuery("SELECT petitionguid, type FROM petition WHERE petitionguid = '%u'", petitionguid_low); QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", petitionguid_low);
if(!result) if(!result)
{ {
sLog.outError("any petition on server..."); sLog.outError("any petition on server...");
return; return;
} }
Field *fields = result->Fetch(); Field *fields = result->Fetch();
uint32 type = fields[1].GetUInt32(); uint32 type = fields[0].GetUInt32();
delete result; delete result;
// if guild petition and has guild => error, return; // if guild petition and has guild => error, return;
if(type==9 && _player->GetGuildId()) if(type==9 && _player->GetGuildId())
return; return;
@ -317,6 +318,7 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
QueryResult *result = CharacterDatabase.PQuery( QueryResult *result = CharacterDatabase.PQuery(
"SELECT ownerguid, name, " "SELECT ownerguid, name, "
" (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs " " (SELECT COUNT(playerguid) FROM petition_sign WHERE petition_sign.petitionguid = '%u') AS signs "
"type "
"FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid)); "FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid), GUID_LOPART(petitionguid));
if(result) if(result)
@ -325,6 +327,7 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER);
name = fields[1].GetCppString(); name = fields[1].GetCppString();
signs = fields[2].GetUInt8(); signs = fields[2].GetUInt8();
type = fields[3].GetUInt32();
delete result; delete result;
} }
else else
@ -333,20 +336,6 @@ void WorldSession::SendPetitionQueryOpcode(uint64 petitionguid)
return; return;
} }
QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if(result2)
{
Field* fields = result2->Fetch();
type = fields[0].GetUInt32();
delete result2;
}
else
{
sLog.outDebug("CMSG_PETITION_QUERY failed for petition (GUID: %u)", GUID_LOPART(petitionguid));
return;
}
WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*13)); WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*13));
data << GUID_LOPART(petitionguid); // guild/team guid (in mangos always same as GUID_LOPART(petition guid) data << GUID_LOPART(petitionguid); // guild/team guid (in mangos always same as GUID_LOPART(petition guid)
data << ownerguid; // charter owner guid data << ownerguid; // charter owner guid
@ -398,13 +387,13 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
if(!item) if(!item)
return; return;
QueryResult *result2 = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid)); QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if(result2) if(result)
{ {
Field* fields = result2->Fetch(); Field* fields = result->Fetch();
type = fields[0].GetUInt32(); type = fields[0].GetUInt32();
delete result2; delete result;
} }
else else
{ {
@ -549,11 +538,9 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket & recv_data)
SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ALREADY_INVITED_TO_GUILD); SendGuildCommandResult(GUILD_INVITE_S, _player->GetName(), ALREADY_INVITED_TO_GUILD);
return; return;
} }
return;
} }
signs += 1; if(++signs > type) // client signs maximum
if(signs > type) // client signs maximum
return; return;
//client doesn't allow to sign petition two times by one character, but not check sign by another character from same account //client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
@ -637,14 +624,26 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
uint8 signs = 0; uint8 signs = 0;
uint64 petitionguid, plguid; uint64 petitionguid, plguid;
uint32 type; uint32 type, junk;
Player *player; Player *player;
recv_data >> type; recv_data >> junk; // this is not petition type!
recv_data >> petitionguid; // petition guid recv_data >> petitionguid; // petition guid
recv_data >> plguid; // player guid recv_data >> plguid; // player guid
sLog.outDebug("OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, GUID_LOPART(petitionguid), GUID_LOPART(plguid));
player = ObjectAccessor::FindPlayer(plguid); player = ObjectAccessor::FindPlayer(plguid);
if (!player)
return;
QueryResult *result = CharacterDatabase.PQuery("SELECT type FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if (!result)
return;
Field *fields = result->Fetch();
type = fields[0].GetUInt32();
delete result;
sLog.outDebug("OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, GUID_LOPART(petitionguid), GUID_LOPART(plguid));
if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam() ) if (!sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam() )
{ {
if(type != 9) if(type != 9)
@ -695,15 +694,6 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data)
} }
} }
QueryResult *result = CharacterDatabase.PQuery("SELECT petitionguid FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
if(!result)
{
sLog.outError("any petition on server...");
return;
}
delete result;
result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid)); result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
// result==NULL also correct charter without signs // result==NULL also correct charter without signs
if(result) if(result)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "6912" #define REVISION_NR "6913"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__