mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10254] Remove dependence auction data from auctioneer guid.
* Field `auctioneerguid` replaced by `houseid` and table reanmed to `auction` (it list auctions and `id` is auction id). * Update related code. * SQL update fill `houseid` field by old `auctioneerguid` BUT: SQL update expect that you world DB named `mangos`. If this not true for your case you need modify SQL update BEFORE APPLY in 2 placed in part "mangos.creature AS c, mangos.creature_template AS ct" * Another small possitive result: now possible easy select auctions related to some auction store (1-3 is one team actions, 4-6 another team auction, and 7 is neutral auction store for both teams
This commit is contained in:
parent
6c6ce87867
commit
e3befa2072
10 changed files with 54 additions and 39 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_10160_02_characters_pet_aura` bit(1) default NULL
|
||||
`required_10254_01_characters_auctionhouse` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
|
@ -141,7 +141,7 @@ UNLOCK TABLES;
|
|||
DROP TABLE IF EXISTS `auctionhouse`;
|
||||
CREATE TABLE `auctionhouse` (
|
||||
`id` int(11) unsigned NOT NULL default '0',
|
||||
`auctioneerguid` int(11) unsigned NOT NULL default '0',
|
||||
`houseid` int(11) unsigned NOT NULL default '0',
|
||||
`itemguid` int(11) unsigned NOT NULL default '0',
|
||||
`item_template` int(11) unsigned NOT NULL default '0' COMMENT 'Item Identifier',
|
||||
`itemowner` int(11) unsigned NOT NULL default '0',
|
||||
|
|
|
|||
30
sql/updates/10254_01_characters_auctionhouse.sql
Normal file
30
sql/updates/10254_01_characters_auctionhouse.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_10160_02_characters_pet_aura required_10254_01_characters_auctionhouse bit;
|
||||
|
||||
ALTER TABLE auctionhouse
|
||||
ADD COLUMN houseid int(11) unsigned NOT NULL default '0' AFTER id;
|
||||
|
||||
UPDATE auctionhouse, mangos.creature AS c, mangos.creature_template AS ct
|
||||
SET houseid =
|
||||
CASE ct.faction_A
|
||||
WHEN 12 THEN 1 /* human */
|
||||
WHEN 29 THEN 6 /* orc, and generic for horde */
|
||||
WHEN 55 THEN 2 /* dwarf/gnome, and generic for alliance */
|
||||
WHEN 68 THEN 4 /* undead */
|
||||
WHEN 80 THEN 3 /* n-elf */
|
||||
WHEN 104 THEN 5 /* trolls */
|
||||
WHEN 120 THEN 7 /* booty bay, neutral */
|
||||
WHEN 474 THEN 7 /* gadgetzan, neutral */
|
||||
WHEN 534 THEN 2 /* Alliance Generic */
|
||||
WHEN 855 THEN 7 /* everlook, neutral */
|
||||
WHEN 1604 THEN 6 /* b-elfs, */
|
||||
WHEN 1638 THEN 2 /* exodar, alliance */
|
||||
ELSE 0 /* auction will canceled at loading */
|
||||
END
|
||||
WHERE auctionhouse.auctioneerguid = c.guid AND c.id = ct.entry;
|
||||
|
||||
|
||||
ALTER TABLE auctionhouse
|
||||
DROP COLUMN auctioneerguid;
|
||||
|
||||
DROP TABLE IF EXISTS auction;
|
||||
RENAME TABLE auctionhouse TO auction;
|
||||
|
|
@ -122,6 +122,7 @@ pkgdata_DATA = \
|
|||
10244_01_mangos_command.sql \
|
||||
10251_01_mangos_command.sql \
|
||||
10252_01_mangos_reputation_reward_rate.sql \
|
||||
10254_01_characters_auctionhouse.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -224,4 +225,5 @@ EXTRA_DIST = \
|
|||
10244_01_mangos_command.sql \
|
||||
10251_01_mangos_command.sql \
|
||||
10252_01_mangos_reputation_reward_rate.sql \
|
||||
10254_01_characters_auctionhouse.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -258,7 +258,6 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
|||
|
||||
AuctionEntry *AH = new AuctionEntry;
|
||||
AH->Id = sObjectMgr.GenerateAuctionID();
|
||||
AH->auctioneer = auctioneerGuid.GetCounter();
|
||||
AH->item_guidlow = GUID_LOPART(item);
|
||||
AH->item_template = it->GetEntry();
|
||||
AH->owner = pl->GetGUIDLow();
|
||||
|
|
@ -377,7 +376,7 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
|||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
||||
|
||||
// after this update we should save player's money ...
|
||||
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail( AuctionEntry * auction )
|
|||
void AuctionHouseMgr::LoadAuctionItems()
|
||||
{
|
||||
// data needs to be at first place for Item::LoadFromDB 0 1 2 3
|
||||
QueryResult *result = CharacterDatabase.Query( "SELECT data,text,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" );
|
||||
QueryResult *result = CharacterDatabase.Query( "SELECT data,text,itemguid,item_template FROM auction JOIN item_instance ON itemguid = guid" );
|
||||
|
||||
if( !result )
|
||||
{
|
||||
|
|
@ -336,13 +336,13 @@ void AuctionHouseMgr::LoadAuctionItems()
|
|||
|
||||
void AuctionHouseMgr::LoadAuctions()
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auctionhouse");
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(*) FROM auction");
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar(1);
|
||||
bar.step();
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -355,17 +355,17 @@ void AuctionHouseMgr::LoadAuctions()
|
|||
barGoLink bar(1);
|
||||
bar.step();
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
result = CharacterDatabase.Query( "SELECT id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auctionhouse" );
|
||||
result = CharacterDatabase.Query( "SELECT id,houseid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit FROM auction" );
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar(1);
|
||||
bar.step();
|
||||
sLog.outString();
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auctionhouse` is empty.");
|
||||
sLog.outString(">> Loaded 0 auctions. DB table `auction` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ void AuctionHouseMgr::LoadAuctions()
|
|||
|
||||
auction = new AuctionEntry;
|
||||
auction->Id = fields[0].GetUInt32();
|
||||
auction->auctioneer = fields[1].GetUInt32();
|
||||
uint32 houseid = fields[1].GetUInt32();
|
||||
auction->item_guidlow = fields[2].GetUInt32();
|
||||
auction->item_template = fields[3].GetUInt32();
|
||||
auction->owner = fields[4].GetUInt32();
|
||||
|
|
@ -404,21 +404,9 @@ void AuctionHouseMgr::LoadAuctions()
|
|||
continue;
|
||||
}
|
||||
|
||||
CreatureData const* auctioneerData = sObjectMgr.GetCreatureData(auction->auctioneer);
|
||||
if(!auctioneerData)
|
||||
{
|
||||
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u), will mail to owner (GUID: %u)",
|
||||
auction->Id, auction->auctioneer, auction->owner);
|
||||
}
|
||||
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid);
|
||||
|
||||
CreatureInfo const* auctioneerInfo = auctioneerData ? ObjectMgr::GetCreatureTemplate(auctioneerData->id) : NULL;
|
||||
if(auctioneerData && !auctioneerInfo)
|
||||
{
|
||||
sLog.outError("Auction %u has not a existing auctioneer (GUID : %u Entry: %u), will mail to owner (GUID: %u)",
|
||||
auction->Id, auction->auctioneer,auctioneerData->id, auction->owner);
|
||||
}
|
||||
|
||||
if (!auctioneerInfo)
|
||||
if (!houseid)
|
||||
{
|
||||
// need for send mail, use goblin auctionhouse
|
||||
auction->auctionHouseEntry = sAuctionHouseStore.LookupEntry(7);
|
||||
|
|
@ -439,9 +427,6 @@ void AuctionHouseMgr::LoadAuctions()
|
|||
continue;
|
||||
}
|
||||
|
||||
// always return pointer
|
||||
auction->auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(auctioneerInfo->faction_A);
|
||||
|
||||
GetAuctionsMap(auction->auctionHouseEntry)->AddAuction(auction);
|
||||
|
||||
} while (result->NextRow());
|
||||
|
|
@ -711,13 +696,13 @@ uint32 AuctionEntry::GetAuctionOutBid() const
|
|||
void AuctionEntry::DeleteFromDB() const
|
||||
{
|
||||
//No SQL injection (Id is integer)
|
||||
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE id = '%u'",Id);
|
||||
CharacterDatabase.PExecute("DELETE FROM auction WHERE id = '%u'",Id);
|
||||
}
|
||||
|
||||
void AuctionEntry::SaveToDB() const
|
||||
{
|
||||
//No SQL injection (no strings)
|
||||
CharacterDatabase.PExecute("INSERT INTO auctionhouse (id,auctioneerguid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) "
|
||||
CharacterDatabase.PExecute("INSERT INTO auction (id,houseid,itemguid,item_template,itemowner,buyoutprice,time,buyguid,lastbid,startbid,deposit) "
|
||||
"VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '" UI64FMTD "', '%u', '%u', '%u', '%u')",
|
||||
Id, auctioneer, item_guidlow, item_template, owner, buyout, (uint64)expire_time, bidder, bid, startbid, deposit);
|
||||
Id, auctionHouseEntry->houseId, item_guidlow, item_template, owner, buyout, (uint64)expire_time, bidder, bid, startbid, deposit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ enum AuctionAction
|
|||
struct AuctionEntry
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 auctioneer; // creature low guid
|
||||
uint32 item_guidlow;
|
||||
uint32 item_template;
|
||||
uint32 owner;
|
||||
|
|
|
|||
|
|
@ -2387,7 +2387,7 @@ bool ChatHandler::HandleListItemCommand(const char* args)
|
|||
|
||||
// auction case
|
||||
uint32 auc_count = 0;
|
||||
result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id);
|
||||
result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auction WHERE item_template='%u'",item_id);
|
||||
if(result)
|
||||
{
|
||||
auc_count = (*result)[0].GetUInt32();
|
||||
|
|
@ -2398,8 +2398,8 @@ bool ChatHandler::HandleListItemCommand(const char* args)
|
|||
{
|
||||
result=CharacterDatabase.PQuery(
|
||||
// 0 1 2 3
|
||||
"SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
|
||||
"FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
|
||||
"SELECT auction.itemguid, auction.itemowner, characters.account, characters.name "
|
||||
"FROM auction,characters WHERE auction.item_template='%u' AND characters.guid = auction.itemowner LIMIT %u",
|
||||
item_id,uint32(count));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -5858,7 +5858,7 @@ void ObjectMgr::SetHighestGuids()
|
|||
// Cleanup other tables from not existed guids (>=m_hiItemGuid)
|
||||
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||
CharacterDatabase.PExecute("DELETE FROM auction WHERE itemguid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed());
|
||||
|
||||
result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" );
|
||||
|
|
@ -5868,7 +5868,7 @@ void ObjectMgr::SetHighestGuids()
|
|||
delete result;
|
||||
}
|
||||
|
||||
result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse" );
|
||||
result = CharacterDatabase.Query("SELECT MAX(id) FROM auction" );
|
||||
if( result )
|
||||
{
|
||||
m_AuctionIds.Set((*result)[0].GetUInt32()+1);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10253"
|
||||
#define REVISION_NR "10254"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_10160_02_characters_pet_aura"
|
||||
#define REVISION_DB_CHARACTERS "required_10254_01_characters_auctionhouse"
|
||||
#define REVISION_DB_MANGOS "required_10252_01_mangos_reputation_reward_rate"
|
||||
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue