[10256] New auction command with subcommands for look different auction stores from anywhere.

This commit is contained in:
VladimirMangos 2010-07-24 13:46:45 +04:00
parent dbf2d02762
commit 9a6535963c
13 changed files with 151 additions and 40 deletions

View file

@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL, `version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0', `cache_id` int(10) default '0',
`required_10252_01_mangos_reputation_reward_rate` bit(1) default NULL `required_10256_01_mangos_command` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
-- --
@ -520,6 +520,10 @@ INSERT INTO `command` VALUES
('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'), ('additem',3,'Syntax: .additem #itemid/[#itemname]/#shift-click-item-link #itemcount\r\n\r\nAdds the specified number of items of id #itemid (or exact (!) name $itemname in brackets, or link created by shift-click at item in inventory or recipe) to your or selected character inventory. If #itemcount is omitted, only one item will be added.\r\n.'),
('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'), ('additemset',3,'Syntax: .additemset #itemsetid\r\n\r\nAdd items from itemset of id #itemsetid to your or selected character inventory. Will add by one example each item from itemset.'),
('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'), ('announce',1,'Syntax: .announce $MessageToBroadcast\r\n\r\nSend a global message to all players online in chat log.'),
('auction',3,'Syntax: .auction\r\n\r\nShow your team auction store.'),
('auction aliance',3,'Syntax: .auction aliance\r\n\r\nShow aliance auction store independent from your team.'),
('auction goblin',3,'Syntax: .auction goblin\r\n\r\nShow goblin auction store common for all teams.'),
('auction horde',3,'Syntax: .auction horde\r\n\r\nShow horde auction store independent from your team.'),
('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'), ('aura',3,'Syntax: .aura #spellid\r\n\r\nAdd the aura from spell #spellid to the selected Unit.'),
('ban account',3,'Syntax: .ban account $Name $bantime $reason\r\nBan account kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'), ('ban account',3,'Syntax: .ban account $Name $bantime $reason\r\nBan account kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
('ban character',3,'Syntax: .ban character $Name $bantime $reason\r\nBan account and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'), ('ban character',3,'Syntax: .ban character $Name $bantime $reason\r\nBan account and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),

View file

@ -0,0 +1,8 @@
ALTER TABLE db_version CHANGE COLUMN required_10252_01_mangos_reputation_reward_rate required_10256_01_mangos_command bit;
DELETE FROM command WHERE name IN ('auction','auction aliance','auction goblin','auction horde');
INSERT INTO command (name, security, help) VALUES
('auction',3,'Syntax: .auction\r\n\r\nShow your team auction store.'),
('auction aliance',3,'Syntax: .auction aliance\r\n\r\nShow aliance auction store independent from your team.'),
('auction goblin',3,'Syntax: .auction goblin\r\n\r\nShow goblin auction store common for all teams.'),
('auction horde',3,'Syntax: .auction horde\r\n\r\nShow horde auction store independent from your team.');

View file

@ -123,6 +123,7 @@ pkgdata_DATA = \
10251_01_mangos_command.sql \ 10251_01_mangos_command.sql \
10252_01_mangos_reputation_reward_rate.sql \ 10252_01_mangos_reputation_reward_rate.sql \
10254_01_characters_auctionhouse.sql \ 10254_01_characters_auctionhouse.sql \
10256_01_mangos_command.sql \
README README
## Additional files to include when running 'make dist' ## Additional files to include when running 'make dist'
@ -226,4 +227,5 @@ EXTRA_DIST = \
10251_01_mangos_command.sql \ 10251_01_mangos_command.sql \
10252_01_mangos_reputation_reward_rate.sql \ 10252_01_mangos_reputation_reward_rate.sql \
10254_01_characters_auctionhouse.sql \ 10254_01_characters_auctionhouse.sql \
10256_01_mangos_command.sql \
README README

View file

@ -28,6 +28,7 @@
#include "AuctionHouseMgr.h" #include "AuctionHouseMgr.h"
#include "Mail.h" #include "Mail.h"
#include "Util.h" #include "Util.h"
#include "Chat.h"
// please DO NOT use iterator++, because it is slower than ++iterator!!! // please DO NOT use iterator++, because it is slower than ++iterator!!!
// post-incrementation is always slower than pre-incrementation ! // post-incrementation is always slower than pre-incrementation !
@ -53,10 +54,10 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
} }
// this void causes that auction window is opened // this void causes that auction window is opened
void WorldSession::SendAuctionHello(Creature* unit) void WorldSession::SendAuctionHello(Unit* unit)
{ {
// always return pointer // always return pointer
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction()); AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
WorldPacket data( MSG_AUCTION_HELLO, 12 ); WorldPacket data( MSG_AUCTION_HELLO, 12 );
data << unit->GetObjectGuid(); data << unit->GetObjectGuid();
@ -154,15 +155,34 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid) AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid)
{ {
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER); Unit* auctioneer = NULL;
if (!pCreature)
// GM case
if (guid == GetPlayer()->GetObjectGuid())
{ {
DEBUG_LOG("Auctioneeer %s accessed in cheating way.", guid.GetString().c_str()); // command case will return only if player have real access to command
return NULL; // using special access modes (1,-1) done at mode set in command, so not need recheck
if (GetPlayer()->GetAuctionAccessMode()==0 && !ChatHandler(GetPlayer()).FindCommand("auction"))
{
DEBUG_LOG("%s attempt open auction in cheating way.", guid.GetString().c_str());
return NULL;
}
auctioneer = GetPlayer();
}
// auctioneer case
else
{
auctioneer = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
if (!auctioneer)
{
DEBUG_LOG("Auctioneeer %s accessed in cheating way.", guid.GetString().c_str());
return NULL;
}
} }
// always return pointer // always return pointer
return AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction()); return AuctionHouseMgr::GetAuctionHouseEntry(auctioneer);
} }
// this void creates new auction and adds auction to some auctionhouse // this void creates new auction and adds auction to some auctionhouse

View file

@ -478,41 +478,59 @@ uint32 AuctionHouseMgr::GetAuctionHouseTeam(AuctionHouseEntry const* house)
} }
} }
AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTemplateId) AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit)
{ {
uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents) uint32 houseid = 1; // dwarf auction house (used for normal cut/etc percents)
if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{ {
//FIXME: found way for proper auctionhouse selection by another way if (unit->GetTypeId() == TYPEID_UNIT)
// AuctionHo use.dbc have faction field with _player_ factions associated with auction house races.
// but no easy way convert creature faction to player race faction for specific city
switch(factionTemplateId)
{ {
case 12: houseid = 1; break; // human //FIXME: found way for proper auctionhouse selection by another way
case 29: houseid = 6; break; // orc, and generic for horde // AuctionHo use.dbc have faction field with _player_ factions associated with auction house races.
case 55: houseid = 2; break; // dwarf/gnome, and generic for alliance // but no easy way convert creature faction to player race faction for specific city
case 68: houseid = 4; break; // undead uint32 factionTemplateId = unit->getFaction();
case 80: houseid = 3; break; // n-elf switch(factionTemplateId)
case 104: houseid = 5; break; // trolls
case 120: houseid = 7; break; // booty bay, neutral
case 474: houseid = 7; break; // gadgetzan, neutral
case 534: houseid = 2; break; // Alliance Generic
case 855: houseid = 7; break; // everlook, neutral
case 1604: houseid = 6; break; // b-elfs,
case 1638: houseid = 2; break; // exodar, alliance
default: // for unknown case
{ {
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); case 12: houseid = 1; break; // human
if(!u_entry) case 29: houseid = 6; break; // orc, and generic for horde
houseid = 7; // goblin auction house case 55: houseid = 2; break; // dwarf/gnome, and generic for alliance
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE) case 68: houseid = 4; break; // undead
houseid = 1; // human auction house case 80: houseid = 3; break; // n-elf
else if(u_entry->ourMask & FACTION_MASK_HORDE) case 104: houseid = 5; break; // trolls
houseid = 6; // orc auction house case 120: houseid = 7; break; // booty bay, neutral
else case 474: houseid = 7; break; // gadgetzan, neutral
houseid = 7; // goblin auction house case 534: houseid = 2; break; // Alliance Generic
break; case 855: houseid = 7; break; // everlook, neutral
case 1604: houseid = 6; break; // b-elfs,
case 1638: houseid = 2; break; // exodar, alliance
default: // for unknown case
{
FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId);
if(!u_entry)
houseid = 7; // goblin auction house
else if(u_entry->ourMask & FACTION_MASK_ALLIANCE)
houseid = 1; // human auction house
else if(u_entry->ourMask & FACTION_MASK_HORDE)
houseid = 6; // orc auction house
else
houseid = 7; // goblin auction house
break;
}
}
}
else
{
Player* player = (Player*)unit;
if (player->GetAuctionAccessMode() > 0)
houseid = 7;
else
{
switch (((Player*)unit)->GetTeam())
{
case ALLIANCE: houseid = player->GetAuctionAccessMode() == 0 ? 1 : 6; break;
case HORDE: houseid = player->GetAuctionAccessMode() == 0 ? 6 : 1; break;
}
} }
} }
} }

View file

@ -141,7 +141,7 @@ class AuctionHouseMgr
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem); static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);
static uint32 GetAuctionHouseTeam(AuctionHouseEntry const* house); static uint32 GetAuctionHouseTeam(AuctionHouseEntry const* house);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId); static AuctionHouseEntry const* GetAuctionHouseEntry(Unit* unit);
public: public:
//load first auction items, because of check if item exists, when loading //load first auction items, because of check if item exists, when loading

View file

@ -85,6 +85,15 @@ ChatCommand * ChatHandler::getCommandTable()
{ NULL, 0, false, NULL, "", NULL } { NULL, 0, false, NULL, "", NULL }
}; };
static ChatCommand auctionCommandTable[] =
{
{ "aliance", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuctionAlianceCommand, "", NULL },
{ "goblin", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuctionGoblinCommand, "", NULL },
{ "horde", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuctionHordeCommand, "", NULL },
{ "", SEC_ADMINISTRATOR, false, &ChatHandler::HandleAuctionCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand banCommandTable[] = static ChatCommand banCommandTable[] =
{ {
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanAccountCommand, "", NULL }, { "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanAccountCommand, "", NULL },
@ -621,6 +630,7 @@ ChatCommand * ChatHandler::getCommandTable()
static ChatCommand commandTable[] = static ChatCommand commandTable[] =
{ {
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable }, { "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
{ "auction", SEC_ADMINISTRATOR, false, NULL, "", auctionCommandTable },
{ "cast", SEC_ADMINISTRATOR, false, NULL, "", castCommandTable }, { "cast", SEC_ADMINISTRATOR, false, NULL, "", castCommandTable },
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable}, { "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
{ "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable }, { "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable },

View file

@ -119,6 +119,11 @@ class ChatHandler
bool HandleAccountSetGmLevelCommand(const char* args); bool HandleAccountSetGmLevelCommand(const char* args);
bool HandleAccountSetPasswordCommand(const char* args); bool HandleAccountSetPasswordCommand(const char* args);
bool HandleAuctionAlianceCommand(const char* args);
bool HandleAuctionGoblinCommand(const char* args);
bool HandleAuctionHordeCommand(const char* args);
bool HandleAuctionCommand(const char* args);
bool HandleBanAccountCommand(const char* args); bool HandleBanAccountCommand(const char* args);
bool HandleBanCharacterCommand(const char* args); bool HandleBanCharacterCommand(const char* args);
bool HandleBanIPCommand(const char* args); bool HandleBanIPCommand(const char* args);

View file

@ -4145,6 +4145,35 @@ bool ChatHandler::HandleHideAreaCommand(const char* args)
return true; return true;
} }
bool ChatHandler::HandleAuctionAlianceCommand(const char* /*args*/)
{
m_session->GetPlayer()->SetAuctionAccessMode(m_session->GetPlayer()->GetTeam() != ALLIANCE ? -1 : 0);
m_session->SendAuctionHello(m_session->GetPlayer());
return true;
}
bool ChatHandler::HandleAuctionHordeCommand(const char* /*args*/)
{
m_session->GetPlayer()->SetAuctionAccessMode(m_session->GetPlayer()->GetTeam() != HORDE ? -1 : 0);
m_session->SendAuctionHello(m_session->GetPlayer());
return true;
}
bool ChatHandler::HandleAuctionGoblinCommand(const char* /*args*/)
{
m_session->GetPlayer()->SetAuctionAccessMode(1);
m_session->SendAuctionHello(m_session->GetPlayer());
return true;
}
bool ChatHandler::HandleAuctionCommand(const char* /*args*/)
{
m_session->GetPlayer()->SetAuctionAccessMode(0);
m_session->SendAuctionHello(m_session->GetPlayer());
return true;
}
bool ChatHandler::HandleBankCommand(const char* /*args*/) bool ChatHandler::HandleBankCommand(const char* /*args*/)
{ {
m_session->SendShowBank( m_session->GetPlayer()->GetGUID() ); m_session->SendShowBank( m_session->GetPlayer()->GetGUID() );

View file

@ -620,6 +620,8 @@ enum PlayerExtraFlags
PLAYER_EXTRA_TAXICHEAT = 0x0008, PLAYER_EXTRA_TAXICHEAT = 0x0008,
PLAYER_EXTRA_GM_INVISIBLE = 0x0010, PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages PLAYER_EXTRA_GM_CHAT = 0x0020, // Show GM badge in chat messages
PLAYER_EXTRA_AUCTION_NEUTRAL = 0x0040,
PLAYER_EXTRA_AUCTION_ENEMY = 0x0080, // overwrite PLAYER_EXTRA_AUCTION_NEUTRAL
// other states // other states
PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating. PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
@ -1161,6 +1163,19 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetGMVisible(bool on); void SetGMVisible(bool on);
void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
// 0 = own auction, -1 = enemy auction, 1 = goblin auction
int GetAuctionAccessMode() const { return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0); }
void SetAuctionAccessMode(int state)
{
m_ExtraFlags &= ~ (PLAYER_EXTRA_AUCTION_ENEMY|PLAYER_EXTRA_AUCTION_NEUTRAL);
if(state < 0)
m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY;
else if( state > 0)
m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL;
}
void GiveXP(uint32 xp, Unit* victim); void GiveXP(uint32 xp, Unit* victim);
void GiveLevel(uint32 level); void GiveLevel(uint32 level);

View file

@ -264,7 +264,7 @@ class MANGOS_DLL_SPEC WorldSession
bool SendItemInfo( uint32 itemid, WorldPacket data ); bool SendItemInfo( uint32 itemid, WorldPacket data );
//auction //auction
void SendAuctionHello(Creature * unit); void SendAuctionHello(Unit * unit);
void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0); void SendAuctionCommandResult( uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
void SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template); void SendAuctionBidderNotification( uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
void SendAuctionOwnerNotification( AuctionEntry * auction ); void SendAuctionOwnerNotification( AuctionEntry * auction );

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 "10255" #define REVISION_NR "10256"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__

View file

@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__ #ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__ #define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10254_01_characters_auctionhouse" #define REVISION_DB_CHARACTERS "required_10254_01_characters_auctionhouse"
#define REVISION_DB_MANGOS "required_10252_01_mangos_reputation_reward_rate" #define REVISION_DB_MANGOS "required_10256_01_mangos_command"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__ #endif // __REVISION_SQL_H__