Skip to content

Commit

Permalink
[10256] New auction command with subcommands for look different auc…
Browse files Browse the repository at this point in the history
…tion stores from anywhere.
  • Loading branch information
VladimirMangos committed Jul 24, 2010
1 parent 9788f46 commit 5af49be
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 40 deletions.
6 changes: 5 additions & 1 deletion sql/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`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';

--
Expand Down Expand Up @@ -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.'),
('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.'),
('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.'),
('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\".'),
Expand Down
8 changes: 8 additions & 0 deletions sql/updates/10256_01_mangos_command.sql
Original file line number Diff line number Diff line change
@@ -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.');
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pkgdata_DATA = \
10251_01_mangos_command.sql \
10252_01_mangos_reputation_reward_rate.sql \
10254_01_characters_auctionhouse.sql \
10256_01_mangos_command.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -226,4 +227,5 @@ EXTRA_DIST = \
10251_01_mangos_command.sql \
10252_01_mangos_reputation_reward_rate.sql \
10254_01_characters_auctionhouse.sql \
10256_01_mangos_command.sql \
README
34 changes: 27 additions & 7 deletions src/game/AuctionHouseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "AuctionHouseMgr.h"
#include "Mail.h"
#include "Util.h"
#include "Chat.h"

// please DO NOT use iterator++, because it is slower than ++iterator!!!
// post-incrementation is always slower than pre-incrementation !
Expand All @@ -53,10 +54,10 @@ void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
}

// this void causes that auction window is opened
void WorldSession::SendAuctionHello(Creature* unit)
void WorldSession::SendAuctionHello(Unit* unit)
{
// always return pointer
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->getFaction());
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);

WorldPacket data( MSG_AUCTION_HELLO, 12 );
data << unit->GetObjectGuid();
Expand Down Expand Up @@ -154,15 +155,34 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )

AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(ObjectGuid guid)
{
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
if (!pCreature)
Unit* auctioneer = NULL;

// GM case
if (guid == GetPlayer()->GetObjectGuid())
{
DEBUG_LOG("Auctioneeer %s accessed in cheating way.", guid.GetString().c_str());
return NULL;
// command case will return only if player have real access to command
// 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
return AuctionHouseMgr::GetAuctionHouseEntry(pCreature->getFaction());
return AuctionHouseMgr::GetAuctionHouseEntry(auctioneer);
}

// this void creates new auction and adds auction to some auctionhouse
Expand Down
74 changes: 46 additions & 28 deletions src/game/AuctionHouseMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

if(!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{
//FIXME: found way for proper auctionhouse selection by another way
// 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)
if (unit->GetTypeId() == TYPEID_UNIT)
{
case 12: houseid = 1; break; // human
case 29: houseid = 6; break; // orc, and generic for horde
case 55: houseid = 2; break; // dwarf/gnome, and generic for alliance
case 68: houseid = 4; break; // undead
case 80: houseid = 3; break; // n-elf
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
//FIXME: found way for proper auctionhouse selection by another way
// AuctionHo use.dbc have faction field with _player_ factions associated with auction house races.

This comment has been minimized.

Copy link
@SkirnirMaNGOS

SkirnirMaNGOS Jul 24, 2010

  •        // AuctionHo use.dbc have faction field with _player_ factions associated with auction house races.
    
  •        // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races.
    

Just a little something, I found it sometime ago and someone even created a patch file in "... under review" section. Hoped you push this with a version of ahbot to mangos main hint, hint :-)

Vladimir you do a hell of a job here!

This comment has been minimized.

Copy link
@VladimirMangos

VladimirMangos Jul 24, 2010

Thank you! Patch find and applied ^^

// but no easy way convert creature faction to player race faction for specific city
uint32 factionTemplateId = unit->getFaction();
switch(factionTemplateId)
{
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;
case 12: houseid = 1; break; // human
case 29: houseid = 6; break; // orc, and generic for horde
case 55: houseid = 2; break; // dwarf/gnome, and generic for alliance
case 68: houseid = 4; break; // undead
case 80: houseid = 3; break; // n-elf
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);
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;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/AuctionHouseMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AuctionHouseMgr
static uint32 GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 time, Item *pItem);

static uint32 GetAuctionHouseTeam(AuctionHouseEntry const* house);
static AuctionHouseEntry const* GetAuctionHouseEntry(uint32 factionTemplateId);
static AuctionHouseEntry const* GetAuctionHouseEntry(Unit* unit);

public:
//load first auction items, because of check if item exists, when loading
Expand Down
10 changes: 10 additions & 0 deletions src/game/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ ChatCommand * ChatHandler::getCommandTable()
{ 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[] =
{
{ "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleBanAccountCommand, "", NULL },
Expand Down Expand Up @@ -621,6 +630,7 @@ ChatCommand * ChatHandler::getCommandTable()
static ChatCommand commandTable[] =
{
{ "account", SEC_PLAYER, true, NULL, "", accountCommandTable },
{ "auction", SEC_ADMINISTRATOR, false, NULL, "", auctionCommandTable },
{ "cast", SEC_ADMINISTRATOR, false, NULL, "", castCommandTable },
{ "character", SEC_GAMEMASTER, true, NULL, "", characterCommandTable},
{ "debug", SEC_MODERATOR, true, NULL, "", debugCommandTable },
Expand Down
5 changes: 5 additions & 0 deletions src/game/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class ChatHandler
bool HandleAccountSetGmLevelCommand(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 HandleBanCharacterCommand(const char* args);
bool HandleBanIPCommand(const char* args);
Expand Down
29 changes: 29 additions & 0 deletions src/game/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4145,6 +4145,35 @@ bool ChatHandler::HandleHideAreaCommand(const char* args)
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*/)
{
m_session->SendShowBank( m_session->GetPlayer()->GetGUID() );
Expand Down
15 changes: 15 additions & 0 deletions src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ enum PlayerExtraFlags
PLAYER_EXTRA_TAXICHEAT = 0x0008,
PLAYER_EXTRA_GM_INVISIBLE = 0x0010,
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
PLAYER_EXTRA_PVP_DEATH = 0x0100 // store PvP death status until corpse creating.
Expand Down Expand Up @@ -1161,6 +1163,19 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetGMVisible(bool on);
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 GiveLevel(uint32 level);

Expand Down
2 changes: 1 addition & 1 deletion src/game/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class MANGOS_DLL_SPEC WorldSession
bool SendItemInfo( uint32 itemid, WorldPacket data );

//auction
void SendAuctionHello(Creature * unit);
void SendAuctionHello(Unit * unit);
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 SendAuctionOwnerNotification( AuctionEntry * auction );
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10255"
#define REVISION_NR "10256"
#endif // __REVISION_NR_H__
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#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"
#endif // __REVISION_SQL_H__

4 comments on commit 5af49be

@erickeir
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile error on linux (ubuntu server)

In file included from ../../../src/game/AuctionHouseMgr.cpp:26:
../../../src/game/AuctionHouseMgr.h:144: error: expected ‘;’ before ‘(’ token
../../../src/game/AuctionHouseMgr.cpp:481: error: no ‘const AuctionHouseEntry* AuctionHouseMgr::GetAuctionHouseEntry(Unit_)’ member function declared in class ‘AuctionHouseMgr’
make[3]: *_* [AuctionHouseMgr.o] Erreur 1
make[3]: quittant le répertoire « /home/eric/Sources/mangos/objdir/src/game »
make[2]: *** [all-recursive] Erreur 1
make[2]: quittant le répertoire « /home/eric/Sources/mangos/objdir/src »
make[1]: *** [all-recursive] Erreur 1
make[1]: quittant le répertoire « /home/eric/Sources/mangos/objdir »
make: *** [all] Erreur 2

@Wilibald09
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to include "Unit.h" in your "src/game/AuctionHouseMgr.h".

@erickeir
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@VladimirMangos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact not need include, but just forward class declaration.

Must be fixed in [10264]

Please sign in to comment.