mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-31 00:15:55 -04:00
Added the CommoditiesServer project
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
add_subdirectory(CentralServer)
|
||||
add_subdirectory(ChatServer)
|
||||
add_subdirectory(CommoditiesServer)
|
||||
add_subdirectory(ConnectionServer)
|
||||
add_subdirectory(LogServer)
|
||||
add_subdirectory(LoginPing)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(CommoditiesServer)
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
set(SHARED_SOURCES
|
||||
shared/AuctionBid.cpp
|
||||
shared/AuctionBid.h
|
||||
shared/Auction.cpp
|
||||
shared/Auction.h
|
||||
shared/AuctionItem.cpp
|
||||
shared/AuctionItem.h
|
||||
shared/AuctionLocation.cpp
|
||||
shared/AuctionLocation.h
|
||||
shared/AuctionMarket.cpp
|
||||
shared/AuctionMarket.h
|
||||
shared/CentralServerConnection.cpp
|
||||
shared/CentralServerConnection.h
|
||||
shared/CommodityServer.cpp
|
||||
shared/CommodityServer.h
|
||||
shared/CommodityServerMetricsData.cpp
|
||||
shared/CommodityServerMetricsData.h
|
||||
shared/ConfigCommodityServer.cpp
|
||||
shared/ConfigCommodityServer.h
|
||||
shared/DatabaseServerConnection.cpp
|
||||
shared/DatabaseServerConnection.h
|
||||
shared/FirstCommodityServer.h
|
||||
shared/GameServerConnection.cpp
|
||||
shared/GameServerConnection.h
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_SOURCES "")
|
||||
else()
|
||||
set(PLATFORM_SOURCES
|
||||
linux/main.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/shared
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedCompression/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedDebug/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFile/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundation/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedFoundationTypes/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedGame/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedLog/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMemoryManager/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedMessageDispatch/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetwork/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedObject/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedRandom/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedUtility/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverMetrics/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverNetworkMessages/include/public
|
||||
${SWG_ENGINE_SOURCE_DIR}/server/library/serverUtility/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/fileInterface/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localization/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/localizationArchive/include/public
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include
|
||||
${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public
|
||||
)
|
||||
|
||||
link_directories(${STLPORT_LIBDIR})
|
||||
|
||||
add_executable(CommoditiesServer
|
||||
${SHARED_SOURCES}
|
||||
${PLATFORM_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(CommoditiesServer
|
||||
sharedCompression
|
||||
sharedDebug
|
||||
sharedFile
|
||||
sharedFoundation
|
||||
sharedGame
|
||||
sharedMemoryManager
|
||||
sharedLog
|
||||
sharedMessageDispatch
|
||||
sharedNetwork
|
||||
sharedNetworkMessages
|
||||
sharedObject
|
||||
sharedRandom
|
||||
sharedThread
|
||||
sharedUtility
|
||||
serverMetrics
|
||||
serverNetworkMessages
|
||||
serverUtility
|
||||
${STLPORT_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
@@ -0,0 +1,80 @@
|
||||
// main.cpp
|
||||
// Copyright 2000-02, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Justin Randall
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "sharedCompression/SetupSharedCompression.h"
|
||||
#include "sharedDebug/SetupSharedDebug.h"
|
||||
#include "sharedFile/TreeFile.h"
|
||||
#include "sharedFile/SetupSharedFile.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/ExitChain.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedFoundation/SetupSharedFoundation.h"
|
||||
#include "sharedGame/CommoditiesAdvancedSearchAttribute.h"
|
||||
#include "sharedGame/ConfigSharedGame.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "sharedNetwork/NetworkHandler.h"
|
||||
#include "sharedNetworkMessages/SetupSharedNetworkMessages.h"
|
||||
#include "sharedThread/SetupSharedThread.h"
|
||||
#include "sharedUtility/DataTableManager.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "LocalizationManager.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
SetupSharedThread::install();
|
||||
SetupSharedDebug::install(1024);
|
||||
|
||||
//-- setup foundation
|
||||
SetupSharedFoundation::Data setupFoundationData(SetupSharedFoundation::Data::D_game);
|
||||
|
||||
setupFoundationData.argc = argc;
|
||||
setupFoundationData.argv = argv;
|
||||
setupFoundationData.runInBackground = true;
|
||||
SetupSharedFoundation::install (setupFoundationData);
|
||||
|
||||
ConfigSharedGame::install();
|
||||
SetupSharedCompression::install();
|
||||
SetupSharedFile::install(false);
|
||||
SetupSharedNetworkMessages::install();
|
||||
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
SetupSharedNetwork::install(networkSetupData);
|
||||
NetworkHandler::install();
|
||||
|
||||
Os::setProgramName("CommodityServer");
|
||||
ConfigCommodityServer::install();
|
||||
|
||||
const bool displayBadStringIds = ConfigSharedGame::getDisplayBadStringIds ();
|
||||
const bool debugStringIds = ConfigSharedGame::getDebugStringIds ();
|
||||
Unicode::NarrowString defaultLocale(ConfigSharedGame::getDefaultLocale ());
|
||||
Unicode::UnicodeNarrowStringVector localeVector;
|
||||
localeVector.push_back(defaultLocale);
|
||||
|
||||
LocalizationManager::install (new TreeFile::TreeFileFactory, localeVector, debugStringIds, NULL, displayBadStringIds);
|
||||
ExitChain::add(LocalizationManager::remove, "LocalizationManager::remove");
|
||||
|
||||
DataTableManager::install();
|
||||
CommoditiesAdvancedSearchAttribute::install();
|
||||
|
||||
//-- run server
|
||||
SetupSharedFoundation::callbackWithExceptionHandling(CommodityServer::run);
|
||||
|
||||
NetworkHandler::remove();
|
||||
SetupSharedFoundation::remove();
|
||||
SetupSharedThread::remove();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// Auction.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
#ifndef Auction_h
|
||||
#define Auction_h
|
||||
|
||||
#include "serverNetworkMessages/AuctionBase.h"
|
||||
#include "AuctionItem.h"
|
||||
#include "AuctionBid.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Unicode.h"
|
||||
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "sharedNetworkMessages/AuctionQueryHeadersMessage.h"
|
||||
|
||||
class AuctionLocation;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class Auction
|
||||
{
|
||||
private:
|
||||
Auction();
|
||||
Auction(const Auction&);
|
||||
Auction& operator= (const Auction&);
|
||||
|
||||
protected:
|
||||
const NetworkId m_creatorId;
|
||||
const int m_minBid;
|
||||
int m_auctionTimer;
|
||||
const int m_buyNowPrice;
|
||||
const int m_userDescriptionLength;
|
||||
const Unicode::String m_userDescription;
|
||||
const int m_oobLength;
|
||||
const Unicode::String m_oobData;
|
||||
std::vector<std::pair<std::string, Unicode::String> > m_attributes;
|
||||
std::map<uint32, int> * m_searchableAttributeInt;
|
||||
std::map<uint32, double> * m_searchableAttributeFloat;
|
||||
std::map<uint32, std::string> * m_searchableAttributeString;
|
||||
AuctionBid * m_highBid;
|
||||
AuctionItem * const m_item;
|
||||
|
||||
bool m_sold;
|
||||
bool m_active;
|
||||
std::vector<AuctionBid *> m_bids;
|
||||
AuctionLocation & m_location;
|
||||
const int m_flags;
|
||||
|
||||
int m_trackId;
|
||||
|
||||
int GetActualBid(AuctionBid *bid);
|
||||
|
||||
public:
|
||||
Auction(
|
||||
const NetworkId & creatorId,
|
||||
int minBid,
|
||||
int auctionTimer,
|
||||
const NetworkId & itemId,
|
||||
int itemNameLength,
|
||||
const Unicode::String & itemName,
|
||||
int itemType,
|
||||
int itemTemplateId,
|
||||
int itemTimer,
|
||||
int itemSize,
|
||||
const AuctionLocation & location,
|
||||
int flags,
|
||||
int buyNowPrice,
|
||||
int userDescriptionLength,
|
||||
const Unicode::String & userDescription,
|
||||
int oobLength,
|
||||
const Unicode::String & oobData,
|
||||
std::vector<std::pair<std::string, Unicode::String> > const & attributes
|
||||
);
|
||||
|
||||
Auction(
|
||||
const NetworkId & creatorId,
|
||||
int minBid,
|
||||
int auctionTimer,
|
||||
const NetworkId & itemId,
|
||||
int itemNameLength,
|
||||
const Unicode::String & itemName,
|
||||
int itemType,
|
||||
int itemTemplateId,
|
||||
int itemTimer,
|
||||
int itemSize,
|
||||
const AuctionLocation & location,
|
||||
int flags,
|
||||
int buyNowPrice,
|
||||
int userDescriptionLength,
|
||||
const Unicode::String & userDescription,
|
||||
int oobLength,
|
||||
const Unicode::String & oobData,
|
||||
std::vector<std::pair<std::string, Unicode::String> > const & attributes,
|
||||
bool isActive,
|
||||
bool isSold
|
||||
);
|
||||
|
||||
~Auction();
|
||||
|
||||
static void Initialization();
|
||||
|
||||
const NetworkId & GetCreatorId() const {return m_creatorId;}
|
||||
int GetMinBid() const {return m_minBid;}
|
||||
int GetAuctionTimer() const {return m_auctionTimer;}
|
||||
int GetBuyNowPrice() const {return m_buyNowPrice;}
|
||||
int GetBuyNowPriceWithSalesTax() const;
|
||||
int GetUserDescriptionLength() const {return m_userDescriptionLength;}
|
||||
const Unicode::String & GetUserDescription() const {return m_userDescription;}
|
||||
int GetOobLength() const {return m_oobLength;}
|
||||
const Unicode::String & GetOobData() const {return m_oobData;}
|
||||
std::vector<std::pair<std::string, Unicode::String> > const & GetAttributes() const {return m_attributes;}
|
||||
void GetAttributes(std::string & output) const;
|
||||
void AddAttributes(const std::string & attributeName, const Unicode::String & attributeValue);
|
||||
const AuctionBid * GetHighBid() const {return m_highBid;}
|
||||
int GetHighBidAmount() const;
|
||||
const AuctionBid * GetPreviousBid() const;
|
||||
const AuctionBid * GetPlayerBid(const NetworkId & playerId) const;
|
||||
AuctionItem & GetItem() const {return *m_item;}
|
||||
bool IsSold() const {return m_sold;}
|
||||
bool IsActive() const {return m_active;}
|
||||
bool IsImmediate() const {return m_buyNowPrice > 0;}
|
||||
int GetFlags() const {return m_flags;}
|
||||
|
||||
AuctionResultCode AddBid(const NetworkId & bidderId, int bid, int maxProxyBid);
|
||||
void AddLoadedBid(const NetworkId & bidderId, int bid, int maxProxyBid);
|
||||
|
||||
bool Update(int gameTime);
|
||||
void Expire(bool sold, bool expiredBasedOnTimer, int track_id = -1);
|
||||
|
||||
AuctionLocation & GetLocation() const {return m_location;}
|
||||
|
||||
void SetTrackId(int trackId) {m_trackId = trackId;}
|
||||
|
||||
void BuildSearchableAttributeList();
|
||||
|
||||
bool IsAdvancedFilterMatch(std::list<AuctionQueryHeadersMessage::SearchCondition> const & advancedSearch, int matchAllAny) const;
|
||||
|
||||
private:
|
||||
void SetItemResourceContainerClassCrc();
|
||||
void SetItemResourceContainerClassCrc(const std::string & attributeName, const Unicode::String & attributeValue);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,73 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionBid.cpp
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
#include "AuctionBid.h"
|
||||
#include <algorithm>
|
||||
|
||||
// ======================================================================
|
||||
|
||||
AuctionBid::AuctionBid(
|
||||
const NetworkId & bidderId,
|
||||
int bid,
|
||||
int maxProxyBid
|
||||
) :
|
||||
m_bidderId(bidderId),
|
||||
m_bid(bid),
|
||||
m_maxProxyBid(maxProxyBid)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AuctionBid::~AuctionBid()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const bool AuctionBid::operator > (const AuctionBid & rhs) const
|
||||
{
|
||||
return (max(m_bid, m_maxProxyBid) > max(rhs.m_bid, rhs.m_maxProxyBid));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const bool AuctionBid::operator >= (const AuctionBid & rhs) const
|
||||
{
|
||||
return (max(m_bid, m_maxProxyBid) >= max(rhs.m_bid, rhs.m_maxProxyBid));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const bool AuctionBid::operator == (const AuctionBid & rhs) const
|
||||
{
|
||||
return (max(m_bid, m_maxProxyBid) == max(rhs.m_bid, rhs.m_maxProxyBid));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const bool AuctionBid::operator < (const AuctionBid & rhs) const
|
||||
{
|
||||
return (max(m_bid, m_maxProxyBid) < max(rhs.m_bid, rhs.m_maxProxyBid));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
const bool AuctionBid::operator <= (const AuctionBid & rhs) const
|
||||
{
|
||||
return (max(m_bid, m_maxProxyBid) <= max(rhs.m_bid, rhs.m_maxProxyBid));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,53 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionBid.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef AuctionBid_h
|
||||
#define AuctionBid_h
|
||||
|
||||
#include <string>
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "serverNetworkMessages/AuctionBase.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class AuctionBid
|
||||
{
|
||||
private:
|
||||
AuctionBid();
|
||||
AuctionBid(const AuctionBid&);
|
||||
AuctionBid& operator= (const AuctionBid&);
|
||||
|
||||
protected:
|
||||
const NetworkId m_bidderId;
|
||||
int m_bid;
|
||||
const int m_maxProxyBid;
|
||||
|
||||
public:
|
||||
AuctionBid(const NetworkId & bidderId, int bid, int maxProxyBid);
|
||||
~AuctionBid();
|
||||
|
||||
const NetworkId & GetBidderId() const {return m_bidderId;}
|
||||
int GetBid() const {return m_bid;}
|
||||
int GetMaxProxyBid() const {return m_maxProxyBid;}
|
||||
|
||||
void SetBid(int bid) {m_bid = bid;}
|
||||
const bool operator>(const AuctionBid &rhs) const;
|
||||
const bool operator>=(const AuctionBid &rhs) const;
|
||||
const bool operator==(const AuctionBid &rhs) const;
|
||||
const bool operator<(const AuctionBid &rhs) const;
|
||||
const bool operator<=(const AuctionBid &rhs) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,56 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionItem.cpp
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "AuctionItem.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
AuctionItem::AuctionItem(
|
||||
const NetworkId & itemId,
|
||||
const int category,
|
||||
const int itemTemplateId,
|
||||
const int itemTimer,
|
||||
const int nameLength,
|
||||
const Unicode::String & name,
|
||||
const NetworkId & ownerId,
|
||||
const int size
|
||||
) :
|
||||
m_itemId(itemId),
|
||||
m_category(category),
|
||||
m_itemTemplateId(itemTemplateId),
|
||||
m_resourceContainerClassCrc(0),
|
||||
m_resourceName(),
|
||||
m_resourceNameCrc(0),
|
||||
m_itemTimer(itemTimer),
|
||||
m_nameLength(nameLength),
|
||||
m_name(name),
|
||||
m_ownerId(ownerId),
|
||||
m_size(size)
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AuctionItem::~AuctionItem()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionItem::IsExpired(int gameTime) const
|
||||
{
|
||||
return (gameTime > m_itemTimer);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,70 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionItem.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef AuctionItem_h
|
||||
#define AuctionItem_h
|
||||
|
||||
#include "Unicode.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class AuctionItem
|
||||
{
|
||||
private:
|
||||
AuctionItem();
|
||||
AuctionItem(const AuctionItem&);
|
||||
AuctionItem& operator= (const AuctionItem&);
|
||||
|
||||
protected:
|
||||
const NetworkId m_itemId;
|
||||
const int m_category;
|
||||
const int m_itemTemplateId;
|
||||
int m_resourceContainerClassCrc; // for resource container, this contains the crc of the resource class
|
||||
std::string m_resourceName; // for resource container, this is the name of the resource (like Iblovris)
|
||||
int m_resourceNameCrc; // crc for m_resourceName
|
||||
const int m_itemTimer;
|
||||
const int m_nameLength;
|
||||
const Unicode::String m_name;
|
||||
NetworkId m_ownerId;
|
||||
const int m_size;
|
||||
|
||||
public:
|
||||
AuctionItem(const NetworkId & itemId, int category, int itemTemplateId, int itemTimer, int nameLength, const Unicode::String & name, const NetworkId & ownerId, int size);
|
||||
~AuctionItem();
|
||||
|
||||
const NetworkId & GetItemId() const {return m_itemId;}
|
||||
int GetCategory() const {return m_category;}
|
||||
int GetItemTemplateId() const {return m_itemTemplateId;}
|
||||
int GetResourceContainerClassCrc() const {return m_resourceContainerClassCrc;}
|
||||
const std::string & GetResourceName() const {return m_resourceName;}
|
||||
int GetResourceNameCrc() const {return m_resourceNameCrc;}
|
||||
void SetResourceContainerClassCrc(int resourceContainerClassCrc) {m_resourceContainerClassCrc = resourceContainerClassCrc;}
|
||||
void SetResourceName(const std::string & resourceName) {m_resourceName = resourceName;}
|
||||
void SetResourceNameCrc(int resourceNameCrc) {m_resourceNameCrc = resourceNameCrc;}
|
||||
int GetItemTimer() const {return m_itemTimer;}
|
||||
int GetNameLength() const {return m_nameLength;}
|
||||
const Unicode::String & GetName() const {return m_name;}
|
||||
const NetworkId & GetOwnerId() const {return m_ownerId;}
|
||||
int GetSize() const {return m_size;}
|
||||
|
||||
void SetOwnerId(const NetworkId & ownerId) {m_ownerId = ownerId;}
|
||||
|
||||
bool IsExpired(int gameTime) const;
|
||||
|
||||
static bool IsCategoryResourceContainer(int category) {return ((category & 0xffffff00) == 0x00400000);} // SharedObjectTemplate::GOT_resource_container is 0x00400000
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,524 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionLocation.cpp
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "AuctionLocation.h"
|
||||
#include "AuctionMarket.h"
|
||||
#include "DatabaseServerConnection.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "serverNetworkMessages/CMUpdateLocationMessage.h"
|
||||
#include "serverNetworkMessages/AuctionBase.h"
|
||||
#include "sharedGame/GameObjectTypes.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace AuctionMarketNameSpace
|
||||
{
|
||||
int const cs_statusMask = 0x00FFFFFF;
|
||||
int const cs_packedFlag = 0x01000000;
|
||||
|
||||
std::map<NetworkId, Auction *> emptyAuctionList;
|
||||
}
|
||||
|
||||
using namespace AuctionMarketNameSpace;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
static AuctionMarket::VendorStatusCode nextStatus[AuctionMarket::REMOVED + 1][AuctionMarket::REMOVED + 1];
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::Initialization()
|
||||
{
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::ACTIVE] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::EMPTY] = AuctionMarket::EMPTY;
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::UNACCESSED] = AuctionMarket::UNACCESSED;
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::ENDANGERED] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::ACTIVE][AuctionMarket::REMOVED] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::ACTIVE] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::EMPTY] = AuctionMarket::EMPTY;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::ENDANGERED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::EMPTY][AuctionMarket::REMOVED] = AuctionMarket::EMPTY;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::ACTIVE] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::EMPTY] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::UNACCESSED] = AuctionMarket::UNACCESSED;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::ENDANGERED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::UNACCESSED][AuctionMarket::REMOVED] = AuctionMarket::UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::ACTIVE] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::EMPTY] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::ENDANGERED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::EMPTY_AND_UNACCESSED][AuctionMarket::REMOVED] = AuctionMarket::EMPTY_AND_UNACCESSED;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::ACTIVE] = AuctionMarket::ACTIVE;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::EMPTY] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::UNACCESSED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::ENDANGERED] = AuctionMarket::ENDANGERED;
|
||||
nextStatus[AuctionMarket::ENDANGERED][AuctionMarket::REMOVED] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::ACTIVE] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::EMPTY] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::UNACCESSED] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::EMPTY_AND_UNACCESSED] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::ENDANGERED] = AuctionMarket::REMOVED;
|
||||
nextStatus[AuctionMarket::REMOVED][AuctionMarket::REMOVED] = AuctionMarket::REMOVED;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AuctionLocation::AuctionLocation(
|
||||
const NetworkId & locationId,
|
||||
const std::string & location,
|
||||
const NetworkId & ownerId,
|
||||
int salesTax,
|
||||
const NetworkId & salesTaxBankId,
|
||||
int emptyDate,
|
||||
int lastAccessDate,
|
||||
int inactiveDate,
|
||||
int status,
|
||||
bool searchEnabled,
|
||||
int entranceCharge
|
||||
) :
|
||||
m_locationId(locationId),
|
||||
m_ownerId(ownerId),
|
||||
m_location(location),
|
||||
m_locationPlanet(),
|
||||
m_locationRegion(),
|
||||
m_salesTax(salesTax),
|
||||
m_salesTaxBankId(salesTaxBankId),
|
||||
m_emptyDate(emptyDate),
|
||||
m_lastAccessDate(lastAccessDate),
|
||||
m_vendorFirstTimerExpiredAuctionDate(0),
|
||||
m_inactiveDate(inactiveDate),
|
||||
m_nextUpdateTime(0), // force an immediate update on the auction location
|
||||
m_status(status),
|
||||
m_searchEnabled(searchEnabled),
|
||||
m_entranceCharge(entranceCharge),
|
||||
m_auctionItemCount(0),
|
||||
m_auctions(),
|
||||
m_auctionsIndexedByType(),
|
||||
m_auctionsIndexedByParentTypeExactMatch(),
|
||||
m_auctionsIndexedByTemplate(),
|
||||
m_auctionsResourceContainer(),
|
||||
m_vendorOffers()
|
||||
{
|
||||
assert(location != "");
|
||||
assert(GetStatus() >= AuctionMarket::ACTIVE && GetStatus() <= AuctionMarket::REMOVED);
|
||||
|
||||
AuctionMarket::getPlanetAndRegionFromLocationString(m_location, m_locationPlanet, m_locationRegion);
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
|
||||
AuctionMarket::getInstance().AddAuctionLocationToPriorityQueue(*this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
AuctionLocation::~AuctionLocation()
|
||||
{
|
||||
AuctionMarket::getInstance().sanityCheckAuctionLocationBeingDestroyed(this);
|
||||
AuctionMarket::getInstance().RemoveAuctionLocationFromPriorityQueue(*this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionLocation::AddAuction(Auction *auction)
|
||||
{
|
||||
assert(auction != NULL);
|
||||
if (IsVendorMarket() &&
|
||||
(!auction->IsActive() || !IsOwner(auction->GetCreatorId())))
|
||||
{
|
||||
// printf("!!!Offering item to vendor\n");
|
||||
m_vendorOffers.insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_auctionItemCount += auction->GetItem().GetSize();
|
||||
m_auctions.insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
|
||||
if (AuctionItem::IsCategoryResourceContainer(auction->GetItem().GetCategory()))
|
||||
{
|
||||
m_auctionsResourceContainer.insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
}
|
||||
else if (auction->GetItem().GetCategory() != 0)
|
||||
{
|
||||
m_auctionsIndexedByType[auction->GetItem().GetCategory()].insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
|
||||
if (GameObjectTypes::isSubType(auction->GetItem().GetCategory()))
|
||||
{
|
||||
m_auctionsIndexedByType[GameObjectTypes::getMaskedType(auction->GetItem().GetCategory())].insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_auctionsIndexedByParentTypeExactMatch[auction->GetItem().GetCategory()].insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
}
|
||||
|
||||
if (auction->GetItem().GetItemTemplateId() != 0)
|
||||
{
|
||||
m_auctionsIndexedByTemplate[std::make_pair(auction->GetItem().GetCategory(), auction->GetItem().GetItemTemplateId())].insert(std::make_pair(auction->GetItem().GetItemId(), auction));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
//All vendor available items must be in the vendor offers list to be retrieved
|
||||
void AuctionLocation::CancelVendorSale(Auction *auction)
|
||||
{
|
||||
RemoveAuction(auction);
|
||||
m_vendorOffers.insert(std::make_pair(auction->GetItem().GetItemId(),
|
||||
auction));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionLocation::RemoveAuction(Auction *auction)
|
||||
{
|
||||
assert(auction != NULL);
|
||||
return RemoveAuction(auction->GetItem().GetItemId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionLocation::RemoveAuction(const NetworkId & itemId)
|
||||
{
|
||||
std::map<NetworkId, Auction *>::iterator i = m_auctions.find(itemId);
|
||||
if (i != m_auctions.end())
|
||||
{
|
||||
m_auctionItemCount -= (*i).second->GetItem().GetSize();
|
||||
if (m_auctionItemCount < 0)
|
||||
{
|
||||
m_auctionItemCount = 0;
|
||||
}
|
||||
|
||||
if (m_auctionItemCount == 0)
|
||||
{
|
||||
// vendor has reached 0 item, so force an immediate update on the auction location
|
||||
SetNextUpdateTime(0);
|
||||
}
|
||||
|
||||
if (AuctionItem::IsCategoryResourceContainer((*i).second->GetItem().GetCategory()))
|
||||
{
|
||||
m_auctionsResourceContainer.erase((*i).second->GetItem().GetItemId());
|
||||
}
|
||||
else if ((*i).second->GetItem().GetCategory() != 0)
|
||||
{
|
||||
m_auctionsIndexedByType[(*i).second->GetItem().GetCategory()].erase((*i).second->GetItem().GetItemId());
|
||||
|
||||
if (GameObjectTypes::isSubType((*i).second->GetItem().GetCategory()))
|
||||
{
|
||||
m_auctionsIndexedByType[GameObjectTypes::getMaskedType((*i).second->GetItem().GetCategory())].erase((*i).second->GetItem().GetItemId());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_auctionsIndexedByParentTypeExactMatch[(*i).second->GetItem().GetCategory()].erase((*i).second->GetItem().GetItemId());
|
||||
}
|
||||
|
||||
if ((*i).second->GetItem().GetItemTemplateId() != 0)
|
||||
{
|
||||
m_auctionsIndexedByTemplate[std::make_pair((*i).second->GetItem().GetCategory(), (*i).second->GetItem().GetItemTemplateId())].erase((*i).second->GetItem().GetItemId());
|
||||
}
|
||||
}
|
||||
|
||||
m_auctions.erase(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = m_vendorOffers.find(itemId);
|
||||
if (i != m_vendorOffers.end())
|
||||
{
|
||||
m_vendorOffers.erase(i);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
Auction *AuctionLocation::GetAuction(const NetworkId & itemId)
|
||||
{
|
||||
std::map<NetworkId, Auction *>::iterator i = m_auctions.find(itemId);
|
||||
if (i != m_auctions.end())
|
||||
{
|
||||
return((*i).second);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = m_vendorOffers.find(itemId);
|
||||
if (i != m_vendorOffers.end())
|
||||
{
|
||||
return((*i).second);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int AuctionLocation::GetValue() const
|
||||
{
|
||||
int value = 0;
|
||||
std::map<NetworkId, Auction *>::const_iterator i = m_auctions.begin();
|
||||
while (i != m_auctions.end())
|
||||
{
|
||||
Auction *auction = (*i).second;
|
||||
if (auction->IsActive())
|
||||
{
|
||||
int auctionValue = auction->GetBuyNowPrice();
|
||||
if (auctionValue > 0)
|
||||
{
|
||||
value += auctionValue;
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionLocation::MatchLocation(const std::string & planet, const std::string & region, const NetworkId & locationId, bool checkLocationInfo, bool searchMyVendorsOnly, bool overrideVendorSearchFlag, const NetworkId & playerId, bool allowSearchVendors, const NetworkId & vendorId, const int searchType) const
|
||||
{
|
||||
if (IsPacked())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!allowSearchVendors && IsVendorMarket())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (searchMyVendorsOnly && playerId != m_ownerId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_searchEnabled && !overrideVendorSearchFlag && !searchMyVendorsOnly && IsVendorMarket())
|
||||
{
|
||||
// Search is disabled on this vendor. However search of this vendor should still be allowed
|
||||
// if player comes to the vendor to search.
|
||||
return (vendorId == m_locationId);
|
||||
}
|
||||
|
||||
// do not show bazaar items while searching vendor items
|
||||
if (searchType == AST_ByVendorSelling && (! IsVendorMarket()))
|
||||
return false;
|
||||
|
||||
if (checkLocationInfo)
|
||||
{
|
||||
if (locationId.isValid())
|
||||
return (locationId == m_locationId);
|
||||
|
||||
if (!planet.empty() && (planet != m_locationPlanet))
|
||||
return false;
|
||||
|
||||
if (!region.empty() && (region != m_locationRegion))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetOwnerId(const NetworkId & ownerId)
|
||||
{
|
||||
AuctionMarket::getInstance().removeAuctionLocationFromLocationIndex(this);
|
||||
|
||||
m_ownerId = ownerId;
|
||||
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetLocationString( const std::string & newstr )
|
||||
{
|
||||
AuctionMarket::getInstance().removeAuctionLocationFromLocationIndex(this);
|
||||
|
||||
m_location = newstr;
|
||||
|
||||
AuctionMarket::getPlanetAndRegionFromLocationString(m_location, m_locationPlanet, m_locationRegion);
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetSearchedEnabled(bool enabled)
|
||||
{
|
||||
AuctionMarket::getInstance().removeAuctionLocationFromLocationIndex(this);
|
||||
|
||||
m_searchEnabled = enabled;
|
||||
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetSalesTax( int salesTax, const NetworkId & bankId )
|
||||
{
|
||||
m_salesTax = salesTax;
|
||||
m_salesTaxBankId = bankId;
|
||||
|
||||
//printf( "AuctionLocation::SetSalesTax() setting sales tax to %ld for bankId %Ld.\n", m_salesTax, m_salesTaxBankId.getValue());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetNextUpdateTime(int nextUpdateTime)
|
||||
{
|
||||
if (nextUpdateTime != m_nextUpdateTime)
|
||||
{
|
||||
AuctionMarket::getInstance().RemoveAuctionLocationFromPriorityQueue(*this);
|
||||
}
|
||||
|
||||
m_nextUpdateTime = nextUpdateTime;
|
||||
AuctionMarket::getInstance().AddAuctionLocationToPriorityQueue(*this);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::Update(int emptyDate, int lastAccessDate, int inactiveDate, int status)
|
||||
{
|
||||
int oldStatus = GetStatus();
|
||||
if (emptyDate >= 0)
|
||||
{
|
||||
m_emptyDate = emptyDate;
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
if (lastAccessDate >= 0)
|
||||
{
|
||||
m_lastAccessDate = lastAccessDate;
|
||||
m_vendorFirstTimerExpiredAuctionDate = 0;
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
if (inactiveDate >= 0)
|
||||
{
|
||||
m_inactiveDate = inactiveDate;
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
if (status >= AuctionMarket::ACTIVE && status <= AuctionMarket::REMOVED)
|
||||
{
|
||||
WARNING((status != nextStatus[GetStatus()][status]), ("Location status inconsistency, old status = %d, new status = %d, expected status = %d", GetStatus(), status, nextStatus[GetStatus()][status]));
|
||||
SetStatus(status);
|
||||
}
|
||||
|
||||
CMUpdateLocationMessage msg(
|
||||
m_locationId,
|
||||
m_ownerId,
|
||||
m_location,
|
||||
m_salesTax,
|
||||
m_salesTaxBankId,
|
||||
m_emptyDate,
|
||||
m_lastAccessDate,
|
||||
m_inactiveDate,
|
||||
m_status,
|
||||
m_searchEnabled,
|
||||
m_entranceCharge);
|
||||
|
||||
DatabaseServerConnection* dbServer = CommodityServer::getInstance().getDatabaseServer();
|
||||
if (dbServer)
|
||||
dbServer->send(msg, true);
|
||||
if (oldStatus == AuctionMarket::EMPTY && GetStatus() == AuctionMarket::ACTIVE)
|
||||
AuctionMarket::getInstance().OnVendorStatusChange(-1, m_locationId, ARC_VendorStatusNotEmpty);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int AuctionLocation::GetStatus() const
|
||||
{
|
||||
return m_status & cs_statusMask;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int AuctionLocation::GetFullStatus() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetStatus(int const status)
|
||||
{
|
||||
AuctionMarket::getInstance().removeAuctionLocationFromLocationIndex(this);
|
||||
|
||||
m_status = (m_status & ~cs_statusMask) | (status & cs_statusMask);
|
||||
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void AuctionLocation::SetFullStatus(int const status, bool const upperBitsOnly)
|
||||
{
|
||||
AuctionMarket::getInstance().removeAuctionLocationFromLocationIndex(this);
|
||||
|
||||
if (upperBitsOnly)
|
||||
m_status = (m_status & cs_statusMask) | (status & ~cs_statusMask);
|
||||
else
|
||||
m_status = status;
|
||||
|
||||
AuctionMarket::getInstance().addAuctionLocationToLocationIndex(this);
|
||||
SetNextUpdateTime(0); // force an immediate update on the auction location
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool AuctionLocation::IsPacked() const
|
||||
{
|
||||
return m_status & cs_packedFlag;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::map<NetworkId, Auction *> & AuctionLocation::GetAuctionsByType(int type)
|
||||
{
|
||||
std::map<int, std::map<NetworkId, Auction *> >::iterator const iterFind = m_auctionsIndexedByType.find(type);
|
||||
if (iterFind != m_auctionsIndexedByType.end())
|
||||
return iterFind->second;
|
||||
|
||||
return emptyAuctionList;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::map<NetworkId, Auction *> & AuctionLocation::GetAuctionsByParentTypeExactMatch(int type)
|
||||
{
|
||||
std::map<int, std::map<NetworkId, Auction *> >::iterator const iterFind = m_auctionsIndexedByParentTypeExactMatch.find(type);
|
||||
if (iterFind != m_auctionsIndexedByParentTypeExactMatch.end())
|
||||
return iterFind->second;
|
||||
|
||||
return emptyAuctionList;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
std::map<NetworkId, Auction *> & AuctionLocation::GetAuctionsByTemplate(int type, int templateId)
|
||||
{
|
||||
std::map<std::pair<int, int>, std::map<NetworkId, Auction *> >::iterator const iterFind = m_auctionsIndexedByTemplate.find(std::make_pair(type, templateId));
|
||||
if (iterFind != m_auctionsIndexedByTemplate.end())
|
||||
return iterFind->second;
|
||||
|
||||
return emptyAuctionList;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,120 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionLocation.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// (refactorof original code only to the degree to make it work with new)
|
||||
// (server & database framework ... i.e. none of the logic has changed)
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef AuctionLocation_h
|
||||
#define AuctionLocation_h
|
||||
|
||||
#include "serverNetworkMessages/AuctionBase.h"
|
||||
#include "Auction.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
#define PUBLIC_OWNER 0
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class AuctionLocation
|
||||
{
|
||||
private:
|
||||
AuctionLocation();
|
||||
AuctionLocation(const AuctionLocation&);
|
||||
AuctionLocation& operator= (const AuctionLocation&);
|
||||
|
||||
protected:
|
||||
const NetworkId m_locationId;
|
||||
NetworkId m_ownerId;
|
||||
std::string m_location;
|
||||
std::string m_locationPlanet;
|
||||
std::string m_locationRegion;
|
||||
int m_salesTax;
|
||||
NetworkId m_salesTaxBankId;
|
||||
int m_emptyDate;
|
||||
int m_lastAccessDate;
|
||||
int m_vendorFirstTimerExpiredAuctionDate; // time that first unsold auction expired by timer since vendor was last accessed
|
||||
int m_inactiveDate;
|
||||
int m_nextUpdateTime;
|
||||
int m_status;
|
||||
bool m_searchEnabled;
|
||||
int m_entranceCharge;
|
||||
int m_auctionItemCount;
|
||||
std::map<NetworkId, Auction *> m_auctions;
|
||||
std::map<int, std::map<NetworkId, Auction *> > m_auctionsIndexedByType;
|
||||
std::map<int, std::map<NetworkId, Auction *> > m_auctionsIndexedByParentTypeExactMatch;
|
||||
std::map<std::pair<int, int>, std::map<NetworkId, Auction *> > m_auctionsIndexedByTemplate;
|
||||
std::map<NetworkId, Auction *> m_auctionsResourceContainer;
|
||||
std::map<NetworkId, Auction *> m_vendorOffers;
|
||||
|
||||
public:
|
||||
AuctionLocation(const NetworkId & locationId, const std::string & location, const NetworkId & ownerId, int salesTax, const NetworkId & salesTaxBankId, int emptyDate, int lastAccessDate, int inactiveDate, int status, bool searchEnabled, int entranceCharge);
|
||||
~AuctionLocation();
|
||||
|
||||
void CancelVendorSale(Auction *auction);
|
||||
|
||||
bool AddAuction(Auction *auction);
|
||||
bool RemoveAuction(const NetworkId & itemId);
|
||||
bool RemoveAuction(Auction *auction);
|
||||
Auction * GetAuction(const NetworkId & itemId);
|
||||
bool MatchLocation(const std::string & planet, const std::string & region, const NetworkId & locationId, bool checkLocationInfo, bool searchMyVendorsOnly, bool overrideVendorSearchFlag, const NetworkId & playerId, bool allowSearchVendors, const NetworkId & vendorId, const int searchType) const;
|
||||
|
||||
bool IsVendorMarket() const {return m_ownerId.getValue() != PUBLIC_OWNER;}
|
||||
bool IsOwner(const NetworkId & ownerId) const {return (ownerId == m_ownerId);}
|
||||
int GetAuctionItemCount() const {return m_auctionItemCount;}
|
||||
|
||||
const NetworkId & GetLocationId() const {return m_locationId;}
|
||||
const NetworkId & GetOwnerId() const {return m_ownerId;}
|
||||
int GetEmptyDate() const {return m_emptyDate;}
|
||||
int GetLastAccessDate() const {return m_lastAccessDate;}
|
||||
int GetVendorFirstTimerExpiredAuctionDate() const {return m_vendorFirstTimerExpiredAuctionDate;}
|
||||
void SetVendorFirstTimerExpiredAuctionDate(int vendorFirstTimerExpiredAuctionDate) {m_vendorFirstTimerExpiredAuctionDate = vendorFirstTimerExpiredAuctionDate;}
|
||||
int GetInactiveDate() const {return m_inactiveDate;}
|
||||
int GetNextUpdateTime() const {return m_nextUpdateTime;}
|
||||
void SetNextUpdateTime(int nextUpdateTime);
|
||||
bool GetSearchEnabled() const {return m_searchEnabled;}
|
||||
int GetEntranceCharge() const {return m_entranceCharge;}
|
||||
void Update(int emptyDate, int lastAccessDate, int inactiveDate, int status);
|
||||
|
||||
int GetValue() const;
|
||||
|
||||
void SetOwnerId(const NetworkId & ownerId);
|
||||
void SetLocationString( const std::string & newstr );
|
||||
void SetSalesTax(int salesTax, const NetworkId & bankId);
|
||||
void SetSearchedEnabled(bool enabled);
|
||||
void SetEntranceCharge(int entranceCharge) {m_entranceCharge = entranceCharge;}
|
||||
int GetSalesTax() const {return m_salesTax;};
|
||||
const NetworkId & GetSalesTaxBankId() const {return m_salesTaxBankId;};
|
||||
const std::string & GetLocationString() const {return m_location;}
|
||||
const std::string & GetLocationPlanet() const {return m_locationPlanet;}
|
||||
const std::string & GetLocationRegion() const {return m_locationRegion;}
|
||||
|
||||
std::map<NetworkId, Auction *> & GetAuctions() {return m_auctions;}
|
||||
std::map<NetworkId, Auction *> & GetAuctionsByType(int type);
|
||||
std::map<NetworkId, Auction *> & GetAuctionsByParentTypeExactMatch(int type);
|
||||
std::map<NetworkId, Auction *> & GetAuctionsByTemplate(int type, int templateId);
|
||||
std::map<NetworkId, Auction *> & GetAuctionsResourceContainer() {return m_auctionsResourceContainer;}
|
||||
std::map<NetworkId, Auction *> & GetVendorOffers() {return m_vendorOffers;}
|
||||
static void Initialization();
|
||||
|
||||
int GetStatus() const;
|
||||
int GetFullStatus() const;
|
||||
|
||||
void SetStatus(int const status);
|
||||
void SetFullStatus(int const status, bool const upperBitsOnly);
|
||||
|
||||
bool IsPacked() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ======================================================================
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,235 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// AuctionMarket.h (refactor of original Commodities Market code)
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// Original Author: Matt Severenson
|
||||
// Refactored by : Doug Mellencamp
|
||||
//
|
||||
// All the Commodities Market logic is part of this class. Changes were
|
||||
// made to this class only to the degree necessary to make it work with
|
||||
// the new server infrastructure. In other words ... the logic is
|
||||
// estentially unchanged and there are still many issues with the logic
|
||||
// code itself.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef AuctionMarket_h
|
||||
#define AuctionMarket_h
|
||||
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "Singleton/Singleton.h"
|
||||
|
||||
#include "serverNetworkMessages/AcceptHighBidMessage.h"
|
||||
#include "serverNetworkMessages/AddAuctionMessage.h"
|
||||
#include "serverNetworkMessages/AddBidMessage.h"
|
||||
#include "serverNetworkMessages/AddImmediateAuctionMessage.h"
|
||||
#include "serverNetworkMessages/AuctionBase.h"
|
||||
#include "serverNetworkMessages/CancelAuctionMessage.h"
|
||||
#include "serverNetworkMessages/CleanupInvalidItemRetrievalMessage.h"
|
||||
#include "serverNetworkMessages/CreateVendorMarketMessage.h"
|
||||
#include "serverNetworkMessages/DeleteAuctionLocationMessage.h"
|
||||
#include "serverNetworkMessages/DestroyVendorMarketMessage.h"
|
||||
#include "serverNetworkMessages/GetItemDetailsMessage.h"
|
||||
#include "serverNetworkMessages/GetItemMessage.h"
|
||||
#include "serverNetworkMessages/GetPlayerVendorCountMessage.h"
|
||||
#include "serverNetworkMessages/SetSalesTaxMessage.h"
|
||||
#include "serverNetworkMessages/GetVendorOwnerMessage.h"
|
||||
#include "serverNetworkMessages/GetVendorValueMessage.h"
|
||||
#include "serverNetworkMessages/QueryAuctionHeadersMessage.h"
|
||||
#include "sharedNetworkMessages/DeleteCharacterMessage.h"
|
||||
#include "serverNetworkMessages/SetEntranceChargeMessage.h"
|
||||
#include "serverNetworkMessages/SetGameTimeMessage.h"
|
||||
#include "serverNetworkMessages/QueryVendorItemCountMessage.h"
|
||||
#include "serverNetworkMessages/UpdateVendorSearchOptionMessage.h"
|
||||
#include "serverNetworkMessages/UpdateVendorStatusMessage.h"
|
||||
|
||||
#include "Auction.h"
|
||||
#include "AuctionItem.h"
|
||||
#include "AuctionLocation.h"
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Unicode.h"
|
||||
|
||||
class GameServerConnection;
|
||||
|
||||
class AuctionMarket : public Singleton<AuctionMarket>
|
||||
{
|
||||
private:
|
||||
|
||||
protected:
|
||||
std::map<NetworkId, AuctionLocation *> m_locationIdMap;
|
||||
std::map<NetworkId, std::map<NetworkId, AuctionLocation *> > m_playerVendorListMap;
|
||||
|
||||
std::map<NetworkId, AuctionLocation *> m_allBazaar;
|
||||
std::map<std::string, std::map<NetworkId, AuctionLocation *> > m_bazaarByPlanet;
|
||||
std::map<std::pair<std::string, std::string>, std::map<NetworkId, AuctionLocation *> > m_bazaarByRegion;
|
||||
|
||||
std::map<NetworkId, AuctionLocation *> m_allSearchableVendor;
|
||||
std::map<std::string, std::map<NetworkId, AuctionLocation *> > m_searchableVendorByPlanet;
|
||||
std::map<std::pair<std::string, std::string>, std::map<NetworkId, AuctionLocation *> > m_searchableVendorByRegion;
|
||||
|
||||
std::map<NetworkId, Auction *> m_auctions;
|
||||
std::map<std::string, int> m_auctionsCountByGameObjectType;
|
||||
std::set<std::string> m_auctionsCountByGameObjectTypeChanged; // clear() by CommodityServerMetricsData
|
||||
std::map<NetworkId, int> m_auctionCountMap;
|
||||
|
||||
std::map<int, std::set<int> > m_resourceTreeHierarchy;
|
||||
std::map<int, std::set<int> > m_itemTypeMap;
|
||||
int m_itemTypeMapVersionNumber;
|
||||
std::map<int, std::set<std::string> > m_resourceTypeMap;
|
||||
int m_resourceTypeMapVersionNumber;
|
||||
int m_gameTime;
|
||||
bool m_showAllDebugInfo;
|
||||
|
||||
// auctions that are completed during this frame
|
||||
// and needs to be processes at the start of the next frame
|
||||
// (typically buy now auctions bought during this frame)
|
||||
std::vector<NetworkId> m_completedAuctions;
|
||||
|
||||
// priority queue of auctions ordered by
|
||||
// the auction expiration time
|
||||
std::set<std::pair<int, NetworkId> > m_priorityQueueAuctionTimer;
|
||||
|
||||
// priority queue of auctions ordered by
|
||||
// the item's expiration time
|
||||
std::set<std::pair<int, NetworkId> > m_priorityQueueItemTimer;
|
||||
|
||||
// priority queue of auction locations ordered by the time
|
||||
// the auction location needs to be checked for status change
|
||||
std::set<std::pair<int, NetworkId> > m_priorityQueueAuctionLocation;
|
||||
|
||||
void AddAuction(Auction *auction);
|
||||
void DestroyAuction(std::map<NetworkId, Auction *>::iterator & iter);
|
||||
void UpdateLiveAuctions(int gameTime);
|
||||
void DestroyExpiredItems(int gameTime);
|
||||
AuctionLocation * CreateLocation(const NetworkId & ownerId, const std::string & locationString, int entranceCharge);
|
||||
void InitializeFromDB();
|
||||
bool FixVendorLocation( const std::string& );
|
||||
bool GetContainerIdString( const std::string&, std::string& );
|
||||
NetworkId GetLocationId(const std::string&);
|
||||
void ModifyAuctionCount (const NetworkId & playerId, int delta);
|
||||
bool HasOpenAuctionSlots (const NetworkId & playerId);
|
||||
void AddPlayerVendor(const NetworkId & playerId, const NetworkId & vendorId, AuctionLocation * auctionLocation);
|
||||
void RemovePlayerVendor(const NetworkId & playerId, const NetworkId & vendorId);
|
||||
int GetVendorCount(const NetworkId & playerId);
|
||||
int GetItemCount(const NetworkId & playerId);
|
||||
void AddAuctionToPriorityQueue(const Auction & auction);
|
||||
|
||||
void SingletonInialize();
|
||||
|
||||
public:
|
||||
AuctionMarket();
|
||||
~AuctionMarket();
|
||||
|
||||
enum VendorStatusCode
|
||||
{
|
||||
ACTIVE,
|
||||
EMPTY,
|
||||
UNACCESSED,
|
||||
EMPTY_AND_UNACCESSED,
|
||||
ENDANGERED,
|
||||
REMOVED
|
||||
};
|
||||
|
||||
void Update (int gameTime);
|
||||
void AddAuction (const AddAuctionMessage &message);
|
||||
void AddImmediateAuction (const AddImmediateAuctionMessage &message);
|
||||
void AddBid (const AddBidMessage &message);
|
||||
void CancelAuction (const CancelAuctionMessage &message);
|
||||
void AcceptHighBid (const AcceptHighBidMessage &message);
|
||||
void QueryAuctionHeaders (const QueryAuctionHeadersMessage &message);
|
||||
void SetGameTime (const SetGameTimeMessage &message);
|
||||
void GetItemDetails (const GetItemDetailsMessage &message);
|
||||
void GetItem (const GetItemMessage &message);
|
||||
void CreateVendorMarket (const CreateVendorMarketMessage &message);
|
||||
void DestroyVendorMarket (const DestroyVendorMarketMessage &message);
|
||||
void DeleteAuctionLocation (const DeleteAuctionLocationMessage &message);
|
||||
void GetVendorOwner (const GetVendorOwnerMessage &message);
|
||||
void GetVendorValue (const GetVendorValueMessage &message);
|
||||
void CleanupInvalidItemRetrieval (const CleanupInvalidItemRetrievalMessage &message);
|
||||
void SetSalesTax (const SetSalesTaxMessage &message);
|
||||
void QueryVendorItemCount (const QueryVendorItemCountMessage &message);
|
||||
void GetPlayerVendorCount (const GetPlayerVendorCountMessage &message);
|
||||
void UpdateVendorSearchOption (const UpdateVendorSearchOptionMessage &message);
|
||||
void SetEntranceCharge (const SetEntranceChargeMessage &message);
|
||||
void DeleteCharacter (const DeleteCharacterMessage &message);
|
||||
void UpdateVendorStatus (const UpdateVendorStatusMessage &message);
|
||||
void UpdateVendorLocation (const NetworkId &locationId, const std::string &locationString);
|
||||
|
||||
void SendItemTypeMap (GameServerConnection &gameServerConnection);
|
||||
|
||||
void AddResourceType (int resourceClassCrc, const std::string & resourceName);
|
||||
void SendResourceTypeMap (GameServerConnection &gameServerConnection);
|
||||
|
||||
void RemoveFromAuctionTimerPriorityQueue(int timer, const NetworkId & item);
|
||||
void AddAuctionToCompletedAuctionsList(const Auction & auction);
|
||||
|
||||
void onReceiveAuctionLocations (const NetworkId &locationId, const std::string &locationName, const NetworkId &ownerId, const int salesTax, const NetworkId &salesTaxBankId, const int emptyDate, const int lastAccessDate, const int inactiveDate, const int status, const bool searchEnabled, const int entranceCharge);
|
||||
void onReceiveMarketAuctions (const NetworkId &itemId, const NetworkId &ownerId, const NetworkId &creatorId, const NetworkId &locationId, const int minBid, const int buyNowPrice, const int auctionTimer, const std::string &oob, const Unicode::String &userDescription, const int category, const int itemTemplateId, const Unicode::String &itemName, const int itemTimer, const int active, const int itemSize);
|
||||
void onReceiveMarketAuctionAttributes(const NetworkId &itemId, const std::string &attributeName, const Unicode::String &attributeValue);
|
||||
void onReceiveMarketAuctionBids (const NetworkId &itemId, const NetworkId &bidderId, const int bid, const int maxProxyBid);
|
||||
void printAuctionTables();
|
||||
|
||||
int getAuctionCount () const { return m_auctions.size(); }
|
||||
int getLocationCount () const { return m_locationIdMap.size(); }
|
||||
|
||||
void OnAddAuction (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & ownerId, const std::string & ownerName, const NetworkId & vendorId, const std::string & location);
|
||||
void OnAddBid (int trackId, int result, int responseId, const NetworkId & ownerId, const NetworkId & itemId, const NetworkId & bidderId, const NetworkId & previousBidderId, int bidAmount, int previousBidAmount, int maxProxyBid, const std::string & location, int itemNameLength, const Unicode::String & itemName, int salesTaxAmount, const NetworkId & salesTaxBankId);
|
||||
void OnCancelAuction (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & playerId, const NetworkId & highBidderId, int highBid, const std::string & location);
|
||||
void OnAcceptHighBid (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & playerId);
|
||||
void OnQueryAuctionHeaders (int trackId, int result, int responseId, const NetworkId & playerId, int queryType, std::vector<AuctionDataHeader> &auctions, unsigned int queryOffset, bool hasMorePages);
|
||||
void OnGetItemDetails (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & playerId, int userDescriptionLength, const Unicode::String & userDescription, int oobDataLength, const Unicode::String & oobData, std::vector<std::pair<std::string, Unicode::String> > const & attributes);
|
||||
void OnAuctionExpired (const NetworkId & ownerId, bool sold, int flags, const NetworkId & buyerId, int highBidAmount, const NetworkId & itemId, int highBidMaxProxy, const std::string & location, bool immediate, int itemNameLength, const Unicode::String & itemName, const NetworkId & itemOwnerId, int track_id, bool sendSellerMail);
|
||||
void OnItemExpired (const NetworkId & ownerId, const NetworkId & itemId, int itemNameLength, const Unicode::String & itemName, const std::string & locationName, const NetworkId & locationId);
|
||||
void OnGetItem (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & playerId, const std::string & location);
|
||||
void OnCreateVendorMarket (int trackId, int result, int responseId, const NetworkId & ownerId, const std::string & location);
|
||||
void OnVendorRefuseItem (int trackId, int result, int responseId, const NetworkId & itemId, const NetworkId & vendorId, const NetworkId & itemOwnerId);
|
||||
void OnGetVendorOwner (int trackId, int result, int responseId, const NetworkId & ownerId, const NetworkId & requesterId, const std::string & location);
|
||||
void OnGetVendorValue (int trackId, int responseId, const std::string & location, int value);
|
||||
void OnPermanentAuctionPurchased (int trackId, const NetworkId & ownerId, const NetworkId & buyerId, int price, const NetworkId & itemId, const std::string & location, int itemNameLength, const Unicode::String & itemName, std::vector<std::pair<std::string, Unicode::String> > const & attributes);
|
||||
void OnCleanupInvalidItemRetrieval (int trackId, int responseId, const NetworkId & itemId, const NetworkId & playerId, const NetworkId & creatorId, int reimburseAmt);
|
||||
void OnQueryVendorItemCount (const int responseId, const int trackId, const NetworkId &vendorId, const int itemCount, const bool searchEnabled);
|
||||
void OnGetPlayerVendorCount (const int responseId, const int trackId, const NetworkId &playerId, const int vendorCount, std::vector<NetworkId> vendorList);
|
||||
void OnVendorStatusChange (int trackId, const NetworkId &vendorId, int newStatus);
|
||||
|
||||
AuctionLocation & GetLocation (const std::string & location);
|
||||
AuctionLocation & GetLocation (const NetworkId & location);
|
||||
|
||||
void VerifyExcludedGotTypes (stdmap<int, std::string>::fwd const & excludedGotTypes);
|
||||
void VerifyExcludedResourceClasses (stdset<std::string>::fwd const & excludedResourceClasses);
|
||||
void SetResourceTreeHierarchy (stdmap<int, stdset<int>::fwd>::fwd const & resourceTreeHierarchy);
|
||||
bool HasReceivedResourceTreeHierarchy() const {return !m_resourceTreeHierarchy.empty();}
|
||||
|
||||
std::map<std::string, int> const & getAuctionsCountByGameObjectType() const { return m_auctionsCountByGameObjectType; }
|
||||
std::set<std::string> & getAuctionsCountByGameObjectTypeChanged() { return m_auctionsCountByGameObjectTypeChanged; }
|
||||
|
||||
void getItemAttributeData (int requestingGameServerId, const NetworkId & requester, const std::string & outputFileName, int gameObjectType, bool exactGameObjectTypeMatch, bool ignoreSearchableAttribute, int throttle) const;
|
||||
void getItemAttributeDataValues (int requestingGameServerId, const NetworkId & requester, int gameObjectType, bool exactGameObjectTypeMatch, const std::string & attributeName, int throttle) const;
|
||||
void getItemAttribute (int requestingGameServerId, const NetworkId & requester, const NetworkId & item) const;
|
||||
void getVendorInfoForPlayer (int requestingGameServerId, const NetworkId & requester, const NetworkId & player, bool godMode);
|
||||
void getAuctionLocationPriorityQueue(int requestingGameServerId, const NetworkId & requester, int count) const;
|
||||
|
||||
void addAuctionLocationToLocationIndex(const AuctionLocation * auctionLocation);
|
||||
void removeAuctionLocationFromLocationIndex(const AuctionLocation * auctionLocation);
|
||||
|
||||
void sanityCheckAuctionLocationBeingDestroyed(const AuctionLocation * auctionLocation);
|
||||
|
||||
void BuildAuctionsSearchableAttributeList();
|
||||
|
||||
void AddAuctionLocationToPriorityQueue(const AuctionLocation & auctionLocation);
|
||||
void RemoveAuctionLocationFromPriorityQueue(const AuctionLocation & auctionLocation);
|
||||
|
||||
static void getPlanetAndRegionFromLocationString(const std::string &locationName, std::string &planet, std::string ®ion);
|
||||
|
||||
friend class CommodityServer;
|
||||
|
||||
private:
|
||||
bool IsResourceClassDerivedFrom (int resourceClassCrc, int parentResourceClassCrc);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
// CentralServerConnection.cpp
|
||||
// copyright 2001 Verant Interactive
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
CentralServerConnection::CentralServerConnection(const std::string & address, const unsigned short port) :
|
||||
ServerConnection(address, port, NetworkSetupData())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
CentralServerConnection::CentralServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t)
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CentralServerConnection::~CentralServerConnection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
void CentralServerConnection::onConnectionClosed()
|
||||
{
|
||||
ServerConnection::onConnectionClosed();
|
||||
static MessageConnectionCallback m("CentralServerConnectionClosed");
|
||||
emitMessage(m);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onConnectionOpened()
|
||||
{
|
||||
ServerConnection::onConnectionOpened();
|
||||
static const MessageConnectionCallback m("CentralServerConnectionOpened");
|
||||
emitMessage(m);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CentralServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
ServerConnection::onReceive(message);
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,33 @@
|
||||
// CentralServerConnection.h
|
||||
// copyright 2004 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _CentralServerConnection_H
|
||||
#define _CentralServerConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CentralServerConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
CentralServerConnection (const std::string & address, const unsigned short port);
|
||||
CentralServerConnection(UdpConnectionMT *, TcpClient *);
|
||||
~CentralServerConnection();
|
||||
void onConnectionClosed();
|
||||
void onConnectionOpened();
|
||||
void onReceive(const Archive::ByteStream & message);
|
||||
|
||||
private:
|
||||
CentralServerConnection();
|
||||
CentralServerConnection(const CentralServerConnection&);
|
||||
CentralServerConnection& operator=(const CentralServerConnection&);
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _CentralServerConnection_H
|
||||
@@ -0,0 +1,296 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.cpp
|
||||
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
// Server Infrastructure by: Justin Randall
|
||||
//
|
||||
// This is the primary entry point to the commodities service. This class
|
||||
// is called from main.cpp. The main server loop is encapsulated here
|
||||
// in the run method
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
|
||||
#include "AuctionMarket.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "CommodityServerMetricsData.h"
|
||||
#include "CentralServerConnection.h"
|
||||
#include "DatabaseServerConnection.h"
|
||||
#include "GameServerConnection.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "serverMetrics/MetricsManager.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedFoundation/Os.h"
|
||||
#include "sharedNetwork/Connection.h"
|
||||
#include "sharedNetwork/Service.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "sharedLog/SetupSharedLog.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace CommodityServerNamespace
|
||||
{
|
||||
Service * s_gameServerService = 0; // the listening service waiting for game server connections
|
||||
AuctionMarket * s_auctionMarketManager = 0; // the Auction Market singleton containg all the logic
|
||||
CentralServerConnection * s_centralServerConnection = 0; // connection to central
|
||||
DatabaseServerConnection * s_databaseServerConnection = 0;
|
||||
CommodityServerMetricsData * s_commodityServerMetricsData = 0;
|
||||
}
|
||||
|
||||
using namespace CommodityServerNamespace;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CommodityServer::CommodityServer() :
|
||||
Singleton<CommodityServer>(),
|
||||
MessageDispatch::Receiver(),
|
||||
m_gameserverMap(),
|
||||
m_commoditiesServerLoadDone(0),
|
||||
m_timeCommoditiesServerStarted(time(0)),
|
||||
m_commoditiesServerLoadTime(-1)
|
||||
{
|
||||
connectToMessage("CommoditiesLoadDone");
|
||||
connectToMessage("DatabaseServerConnectionClosed");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CommodityServer::~CommodityServer()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CommodityServer::receiveMessage(const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message)
|
||||
{
|
||||
if(message.isType("CommoditiesLoadDone"))
|
||||
{
|
||||
m_commoditiesServerLoadDone = 1;
|
||||
|
||||
// record how long it took the commodities server to load
|
||||
if (m_commoditiesServerLoadTime == -1)
|
||||
m_commoditiesServerLoadTime = (time(0) - m_timeCommoditiesServerStarted) / 60;
|
||||
}
|
||||
else if (message.isType("DatabaseServerConnectionClosed"))
|
||||
{
|
||||
WARNING(true, ("[Commodities Server] : No connection to the database server. Shutting down.\n"));
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int CommodityServer::addGameServer (GameServerConnection & gameserver)
|
||||
{
|
||||
static int nextGameServerId = 0;
|
||||
int tmp = ++nextGameServerId;
|
||||
m_gameserverMap[tmp] = &gameserver;
|
||||
AuctionMarket::getInstance().SendItemTypeMap(gameserver);
|
||||
AuctionMarket::getInstance().SendResourceTypeMap(gameserver);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CommodityServer::removeGameServer (int gameServerId)
|
||||
{
|
||||
WARNING_STRICT_FATAL(gameServerId == 0, ("Tried to remove a gameserver with id == 0"));
|
||||
std::map<int, GameServerConnection*>::iterator i = m_gameserverMap.find(gameServerId);
|
||||
if (i != m_gameserverMap.end())
|
||||
{
|
||||
IGNORE_RETURN(m_gameserverMap.erase(gameServerId));
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
GameServerConnection* CommodityServer::getGameServer (int gameServerId)
|
||||
{
|
||||
WARNING_STRICT_FATAL(gameServerId == 0, ("Tried to get a gameserver with id == 0"));
|
||||
if (gameServerId == -1)
|
||||
{
|
||||
// if requested game server id is -1 we don't know what game server
|
||||
// to send to so use the first known good one
|
||||
std::map<int, GameServerConnection*>::iterator i = m_gameserverMap.begin();
|
||||
while (i != m_gameserverMap.end())
|
||||
{
|
||||
if ((*i).second)
|
||||
{
|
||||
return (*i).second;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<int, GameServerConnection*>::iterator i = m_gameserverMap.find(gameServerId);
|
||||
if (i == m_gameserverMap.end())
|
||||
return 0;
|
||||
else
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CommodityServer::sendToAllGameServers(const GameNetworkMessage & message)
|
||||
{
|
||||
for (std::map<int, GameServerConnection*>::const_iterator i = m_gameserverMap.begin(); i != m_gameserverMap.end(); ++i)
|
||||
i->second->send(message, true);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
DatabaseServerConnection* CommodityServer::getDatabaseServer ()
|
||||
{
|
||||
return s_databaseServerConnection;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
int CommodityServer::getCommoditiesServerLoadTime() const
|
||||
{
|
||||
if (m_commoditiesServerLoadTime != -1)
|
||||
return m_commoditiesServerLoadTime;
|
||||
else
|
||||
// return how long the commodities server has been loading
|
||||
return ((time(0) - m_timeCommoditiesServerStarted) / 60);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CommodityServer::run()
|
||||
{
|
||||
|
||||
// setup log for CommoditiesServer
|
||||
SetupSharedLog::install("CommoditiesServer");
|
||||
|
||||
int const sleepTimePerFrameMs = ConfigCommodityServer::getSleepTimePerFrameMs();
|
||||
|
||||
NetworkSetupData setup;
|
||||
setup.port = ConfigCommodityServer::getCMServerServiceBindPort();
|
||||
setup.bindInterface = ConfigCommodityServer::getCMServerServiceBindInterface();
|
||||
setup.maxConnections=500;
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Starting Commodities Auction Market Manager.\n"));
|
||||
AuctionMarket::getInstance().SingletonInialize();
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Initiating connection to SWG Database Server.\n"));
|
||||
s_databaseServerConnection = new DatabaseServerConnection(ConfigCommodityServer::getDatabaseServerAddress(), ConfigCommodityServer::getDatabaseServerPort());
|
||||
|
||||
Auction::Initialization();
|
||||
AuctionLocation::Initialization();
|
||||
AuctionMarket::getInstance().InitializeFromDB();
|
||||
|
||||
s_commodityServerMetricsData = new CommodityServerMetricsData;
|
||||
MetricsManager::install(s_commodityServerMetricsData, false, "CommoditiesServer", "", 0);
|
||||
|
||||
time_t timePrevious = ::time(NULL);
|
||||
time_t timeCurrent = timePrevious;
|
||||
|
||||
while (true)
|
||||
{
|
||||
volatile int i;
|
||||
i = CommodityServer::getInstance().m_commoditiesServerLoadDone;
|
||||
if (i == 1)
|
||||
break;
|
||||
NetworkHandler::update();
|
||||
|
||||
timeCurrent = ::time(NULL);
|
||||
MetricsManager::update(static_cast<float>((timeCurrent - timePrevious) * 1000));
|
||||
timePrevious = timeCurrent;
|
||||
|
||||
NetworkHandler::dispatch();
|
||||
NetworkHandler::clearBytesThisFrame();
|
||||
Os::sleep(sleepTimePerFrameMs);
|
||||
}
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Auction Market loaded and initialized.\n"));
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Starting Commodities Game Server Listening Service.\n"));
|
||||
s_gameServerService = new Service(ConnectionAllocator<GameServerConnection>(), setup);
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Initiating connection to central server.\n"));
|
||||
s_centralServerConnection = new CentralServerConnection(ConfigCommodityServer::getCentralServerAddress(), ConfigCommodityServer::getCentralServerPort());
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Entering Commodities Server main message processing loop (sleep time %dms).\n", sleepTimePerFrameMs));
|
||||
|
||||
// one time operation to request from the game server
|
||||
// (any game server) the list of GOT types and resource
|
||||
// classes that are excluded from the vendor/bazaar
|
||||
// Object Type Filter tree so that we can check to see
|
||||
// if we have any item that belongs in an excluded GOT type
|
||||
// or resource class so that we can remove that GOT type
|
||||
// or resource class from the excluded list;
|
||||
// this is not a high priority thing, so wait until
|
||||
// the cluster has started and "stabilized" before
|
||||
// doing this; 3 hours should be adequate
|
||||
time_t timeToRequestExcludedType = ::time(NULL) + 10800;
|
||||
|
||||
// one time request from the game server (any game server)
|
||||
// to receive the resource tree hierarchy to support
|
||||
// searching for resource container
|
||||
time_t timeToRequestResourceTree = ::time(NULL);
|
||||
|
||||
while(true)
|
||||
{
|
||||
NetworkHandler::update();
|
||||
|
||||
timeCurrent = ::time(NULL);
|
||||
MetricsManager::update(static_cast<float>((timeCurrent - timePrevious) * 1000));
|
||||
timePrevious = timeCurrent;
|
||||
|
||||
NetworkHandler::dispatch();
|
||||
if (! CommodityServer::getInstance().m_gameserverMap.empty())
|
||||
{
|
||||
// one time request for a game server to send us the resource
|
||||
// tree hierarchy to support searching resource containers
|
||||
if (!AuctionMarket::getInstance().HasReceivedResourceTreeHierarchy())
|
||||
{
|
||||
// keep asking every 10 seconds until we receive the resource tree
|
||||
if (timeToRequestResourceTree <= timeCurrent)
|
||||
{
|
||||
GameServerConnection * gsConn = CommodityServer::getInstance().getGameServer(-1);
|
||||
if (gsConn)
|
||||
{
|
||||
GenericValueTypeMessage<int> const msg("RequestResourceTreeHierarchy", 1);
|
||||
gsConn->send(msg, true);
|
||||
}
|
||||
|
||||
timeToRequestResourceTree = timeCurrent + 10;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeToRequestExcludedType && (timeToRequestExcludedType <= timeCurrent))
|
||||
{
|
||||
GameServerConnection * gsConn = CommodityServer::getInstance().getGameServer(-1);
|
||||
if (gsConn)
|
||||
{
|
||||
GenericValueTypeMessage<int> const msg("RequestCommoditiesExcludedGotTypes", 1);
|
||||
gsConn->send(msg, true);
|
||||
|
||||
GenericValueTypeMessage<int> const msg2("RequestCommoditiesExcludedResourceClasses", 1);
|
||||
gsConn->send(msg2, true);
|
||||
|
||||
timeToRequestExcludedType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
AuctionMarket::getInstance().Update(time(0));
|
||||
}
|
||||
NetworkHandler::clearBytesThisFrame();
|
||||
Os::sleep(sleepTimePerFrameMs);
|
||||
}
|
||||
s_centralServerConnection = 0;
|
||||
s_gameServerService = 0;
|
||||
s_databaseServerConnection = 0;
|
||||
|
||||
MetricsManager::remove();
|
||||
delete s_commodityServerMetricsData;
|
||||
s_commodityServerMetricsData = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,58 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.h
|
||||
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
// Server Infrastructure by: Justin Randall
|
||||
//
|
||||
// This is the primary entry point to the commodities service. This class
|
||||
// is called from main.cpp. The main server loop is encapsulated here.
|
||||
//
|
||||
// ======================================================================
|
||||
#ifndef _INCLUDED_CommodityServer_H
|
||||
#define _INCLUDED_CommodityServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "Singleton/Singleton.h"
|
||||
#include "Archive/ByteStream.h"
|
||||
#include "sharedMessageDispatch/Receiver.h"
|
||||
#include <map>
|
||||
|
||||
class GameNetworkMessage;
|
||||
class GameServerConnection;
|
||||
class DatabaseServerConnection;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CommodityServer : public Singleton<CommodityServer>, public MessageDispatch::Receiver
|
||||
{
|
||||
public:
|
||||
CommodityServer();
|
||||
~CommodityServer();
|
||||
|
||||
void receiveMessage (const MessageDispatch::Emitter & source, const MessageDispatch::MessageBase & message);
|
||||
|
||||
int addGameServer (GameServerConnection & gameserver);
|
||||
void removeGameServer (int gameServerId);
|
||||
GameServerConnection* getGameServer (int gameServerId);
|
||||
void sendToAllGameServers(const GameNetworkMessage & message);
|
||||
DatabaseServerConnection* getDatabaseServer ();
|
||||
int getCommoditiesServerLoadTime() const;
|
||||
|
||||
static void run();
|
||||
|
||||
private:
|
||||
|
||||
std::map<int, GameServerConnection *> m_gameserverMap;
|
||||
int m_commoditiesServerLoadDone;
|
||||
time_t m_timeCommoditiesServerStarted;
|
||||
int m_commoditiesServerLoadTime;
|
||||
|
||||
CommodityServer & operator = (const CommodityServer & rhs);
|
||||
CommodityServer(const CommodityServer & source);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_CommodityServer_H
|
||||
@@ -0,0 +1,99 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// CommodityServerMetricsData.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "CommodityServerMetricsData.h"
|
||||
|
||||
#include "AuctionMarket.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "sharedGame/GameObjectTypes.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
CommodityServerMetricsData::CommodityServerMetricsData() :
|
||||
MetricsData(),
|
||||
m_numItems(0),
|
||||
m_numLocations(0),
|
||||
m_loadTime(0),
|
||||
m_mapAuctionsCountByGameObjectTypeIndex()
|
||||
{
|
||||
MetricsPair p;
|
||||
|
||||
ADD_METRICS_DATA(numItems, 0, true);
|
||||
ADD_METRICS_DATA(numLocations, 0, true);
|
||||
ADD_METRICS_DATA(loadTime, 0, true);
|
||||
|
||||
m_data[m_loadTime].m_description = "minutes";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
CommodityServerMetricsData::~CommodityServerMetricsData()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void CommodityServerMetricsData::updateData()
|
||||
{
|
||||
MetricsData::updateData();
|
||||
m_data[m_numItems].m_value = AuctionMarket::getInstance().getAuctionCount();
|
||||
m_data[m_numLocations].m_value = AuctionMarket::getInstance().getLocationCount();
|
||||
m_data[m_loadTime].m_value = CommodityServer::getInstance().getCommoditiesServerLoadTime();
|
||||
|
||||
// handle auctions count by game object type statistics
|
||||
std::map<std::string, int> const & auctionsCountByGameObjectType = AuctionMarket::getInstance().getAuctionsCountByGameObjectType();
|
||||
std::set<std::string> & auctionsCountByGameObjectTypeChanged = AuctionMarket::getInstance().getAuctionsCountByGameObjectTypeChanged();
|
||||
if (!auctionsCountByGameObjectTypeChanged.empty() && !auctionsCountByGameObjectType.empty())
|
||||
{
|
||||
if (m_mapAuctionsCountByGameObjectTypeIndex.empty())
|
||||
{
|
||||
int gameObjectType;
|
||||
int baseGameObjectType;
|
||||
char buffer[1024];
|
||||
for (std::map<std::string, int>::const_iterator iterGameObjectType = auctionsCountByGameObjectType.begin(); iterGameObjectType != auctionsCountByGameObjectType.end(); ++iterGameObjectType)
|
||||
{
|
||||
if (!iterGameObjectType->first.empty() && (iterGameObjectType->second >= 0) && (m_mapAuctionsCountByGameObjectTypeIndex.count(iterGameObjectType->first) < 1))
|
||||
{
|
||||
gameObjectType = GameObjectTypes::getGameObjectType(iterGameObjectType->first);
|
||||
if (GameObjectTypes::isSubType(gameObjectType))
|
||||
{
|
||||
baseGameObjectType = GameObjectTypes::getMaskedType(gameObjectType);
|
||||
|
||||
snprintf(buffer, sizeof(buffer)-1, "numItems.0x%08X_%s.0x%08X_%s", baseGameObjectType, GameObjectTypes::getCanonicalName(baseGameObjectType).c_str(), gameObjectType, iterGameObjectType->first.c_str());
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer)-1, "numItems.0x%08X_%s", gameObjectType, iterGameObjectType->first.c_str());
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
}
|
||||
|
||||
m_mapAuctionsCountByGameObjectTypeIndex[iterGameObjectType->first] = addMetric(buffer, 0, NULL, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (std::set<std::string>::const_iterator iterChanged = auctionsCountByGameObjectTypeChanged.begin(); iterChanged != auctionsCountByGameObjectTypeChanged.end(); ++iterChanged)
|
||||
{
|
||||
std::map<std::string, int>::const_iterator const iterFindIndex = m_mapAuctionsCountByGameObjectTypeIndex.find(*iterChanged);
|
||||
if (iterFindIndex != m_mapAuctionsCountByGameObjectTypeIndex.end())
|
||||
{
|
||||
std::map<std::string, int>::const_iterator const iterFindGameObjectType = auctionsCountByGameObjectType.find(*iterChanged);
|
||||
if (iterFindGameObjectType != auctionsCountByGameObjectType.end())
|
||||
{
|
||||
updateMetric(iterFindIndex->second, iterFindGameObjectType->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auctionsCountByGameObjectTypeChanged.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,38 @@
|
||||
//CommodityServerMetricsData.h
|
||||
//Copyright 2002 Sony Online Entertainment
|
||||
|
||||
|
||||
#ifndef _CommodityServerMetricsData_H
|
||||
#define _CommodityServerMetricsData_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverMetrics/MetricsData.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class CommodityServerMetricsData : public MetricsData
|
||||
{
|
||||
public:
|
||||
CommodityServerMetricsData();
|
||||
~CommodityServerMetricsData();
|
||||
|
||||
virtual void updateData();
|
||||
|
||||
private:
|
||||
unsigned long m_numItems;
|
||||
unsigned long m_numLocations;
|
||||
unsigned long m_loadTime;
|
||||
|
||||
std::map<std::string, int> m_mapAuctionsCountByGameObjectTypeIndex;
|
||||
|
||||
private:
|
||||
|
||||
// Disabled.
|
||||
CommodityServerMetricsData(const CommodityServerMetricsData&);
|
||||
CommodityServerMetricsData &operator =(const CommodityServerMetricsData&);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.cpp
|
||||
// Copyright 2000-01, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "sharedFoundation/ConfigFile.h"
|
||||
#include "sharedNetwork/SetupSharedNetwork.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
ConfigCommodityServer::Data * ConfigCommodityServer::data = 0;
|
||||
|
||||
#define KEY_INT(a,b) (data->a = ConfigFile::getKeyInt("CommodityServer", #a, b))
|
||||
#define KEY_BOOL(a,b) (data->a = ConfigFile::getKeyBool("CommodityServer", #a, b))
|
||||
#define KEY_FLOAT(a,b) (data->a = ConfigFile::getKeyFloat("CommodityServer", #a, b))
|
||||
#define KEY_STRING(a,b) (data->a = ConfigFile::getKeyString("CommodityServer", #a, b))
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConfigCommodityServer::install(void)
|
||||
{
|
||||
SetupSharedNetwork::SetupData networkSetupData;
|
||||
SetupSharedNetwork::getDefaultServerSetupData(networkSetupData);
|
||||
|
||||
data = new ConfigCommodityServer::Data;
|
||||
|
||||
KEY_INT (cmServerServiceBindPort, 4069);
|
||||
KEY_STRING (cmServerServiceBindInterface, "localhost");
|
||||
KEY_INT (databaseServerPort, 44457); //TODO: confirm port
|
||||
KEY_STRING (databaseServerAddress, "localhost");
|
||||
KEY_STRING (dsn,"swodb");
|
||||
KEY_STRING (databaseUID,"dmellencamp");
|
||||
KEY_STRING (databasePWD, "compts6m");
|
||||
KEY_STRING (databaseSchema, "dmellencamp");
|
||||
KEY_INT (secondsBetweenDBReconnect, 45);
|
||||
KEY_STRING (databaseProtocol, "OCI");
|
||||
KEY_BOOL (enableQueryProfile,false);
|
||||
KEY_BOOL (verboseQueryMode,false);
|
||||
KEY_BOOL (developmentMode, true);
|
||||
KEY_INT (databaseThreads, 1);
|
||||
KEY_INT (databaseCharacterNameSizeLimit, 64);
|
||||
KEY_INT (databaseItemNameSizeLimit, 256);
|
||||
KEY_INT (databaseUserDescriptionSizeLimit, 1024);
|
||||
KEY_INT (databaseOOBDataSizeLimit, 4000);
|
||||
KEY_BOOL (snapshotDBWrite, true);
|
||||
KEY_BOOL (showAllDebugInfo, true);
|
||||
KEY_INT (centralServerPort, 44456);
|
||||
KEY_STRING (centralServerAddress, "localhost");
|
||||
KEY_INT (sleepTimePerFrameMs, 1);
|
||||
KEY_INT (minutesActiveToUnaccessed, 7 * 24 * 60);
|
||||
KEY_INT (minutesEmptyToEndangered, 7 * 24 * 60);
|
||||
KEY_INT (minutesUnaccessedToEndangered, 7 * 24 * 60);
|
||||
KEY_INT (minutesEndangeredToRemoved, 7 * 24 * 60);
|
||||
KEY_INT (minutesVendorAuctionTimer, 30 * 24 * 60);
|
||||
KEY_INT (minutesVendorItemTimer, 30 * 24 * 60);
|
||||
KEY_INT (maxAuctionsPerPage, 100);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void ConfigCommodityServer::remove(void)
|
||||
{
|
||||
delete data;
|
||||
data = 0;
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.h
|
||||
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _ConfigCommodityServer_H
|
||||
#define _ConfigCommodityServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class ConfigCommodityServer
|
||||
{
|
||||
public:
|
||||
struct Data
|
||||
{
|
||||
int cmServerServiceBindPort;
|
||||
const char * cmServerServiceBindInterface;
|
||||
int databaseServerPort;
|
||||
const char * databaseServerAddress;
|
||||
const char * dsn;
|
||||
const char * databaseUID;
|
||||
const char * databasePWD;
|
||||
const char * databaseSchema;
|
||||
int secondsBetweenDBReconnect;
|
||||
const char * databaseProtocol;
|
||||
bool enableQueryProfile;
|
||||
bool verboseQueryMode;
|
||||
bool developmentMode;
|
||||
int databaseThreads; // db task q threads
|
||||
int databaseCharacterNameSizeLimit; // max character name db column size
|
||||
int databaseItemNameSizeLimit; // max item name db column size
|
||||
int databaseUserDescriptionSizeLimit; // max user desc db column size
|
||||
int databaseOOBDataSizeLimit; // max out of band data db column size
|
||||
bool snapshotDBWrite; // save db writes delayed or immediate
|
||||
bool showAllDebugInfo; // show detailed debugging logging info
|
||||
int centralServerPort;
|
||||
const char * centralServerAddress;
|
||||
int sleepTimePerFrameMs;
|
||||
int minutesActiveToUnaccessed;
|
||||
int minutesEmptyToEndangered;
|
||||
int minutesUnaccessedToEndangered;
|
||||
int minutesEndangeredToRemoved;
|
||||
int minutesVendorAuctionTimer;
|
||||
int minutesVendorItemTimer;
|
||||
int maxAuctionsPerPage;
|
||||
};
|
||||
|
||||
static uint16 getCMServerServiceBindPort ();
|
||||
static const char * getCMServerServiceBindInterface ();
|
||||
static uint16 getDatabaseServerPort ();
|
||||
static const char * getDatabaseServerAddress ();
|
||||
static const char * getDSN ();
|
||||
static const char * getDatabaseUID ();
|
||||
static const char * getDatabasePWD ();
|
||||
static const char * getDatabaseSchema ();
|
||||
static uint16 getSecondsBetweenDBReconnect ();
|
||||
static const char * getDatabaseProtocol ();
|
||||
static bool getEnableQueryProfile ();
|
||||
static bool getVerboseQueryMode ();
|
||||
static bool getDevelopmentMode ();
|
||||
static int getDatabaseThreads ();
|
||||
static unsigned int getDatabaseCharacterNameSizeLimit ();
|
||||
static unsigned int getDatabaseItemNameSizeLimit ();
|
||||
static unsigned int getDatabaseUserDescriptionSizeLimit ();
|
||||
static unsigned int getDatabaseOOBDataSizeLimit ();
|
||||
static bool getSnapshotDBWrite ();
|
||||
static bool getShowAllDebugInfo ();
|
||||
static uint16 getCentralServerPort ();
|
||||
static const char * getCentralServerAddress ();
|
||||
static int getSleepTimePerFrameMs ();
|
||||
static int getMinutesActiveToUnaccessed ();
|
||||
static int getMinutesEmptyToEndangered ();
|
||||
static int getMinutesUnaccessedToEndangered ();
|
||||
static int getMinutesEndangeredToRemoved ();
|
||||
static int getMinutesVendorAuctionTimer ();
|
||||
static int getMinutesVendorItemTimer ();
|
||||
static int getMaxAuctionsPerPage ();
|
||||
|
||||
static void install ();
|
||||
static void remove ();
|
||||
|
||||
private:
|
||||
static Data * data;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline unsigned short ConfigCommodityServer::getCMServerServiceBindPort()
|
||||
{
|
||||
return data->cmServerServiceBindPort;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline unsigned short ConfigCommodityServer::getDatabaseServerPort()
|
||||
{
|
||||
return data->databaseServerPort;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getCMServerServiceBindInterface()
|
||||
{
|
||||
return data->cmServerServiceBindInterface;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDatabaseServerAddress()
|
||||
{
|
||||
return data->databaseServerAddress;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDSN()
|
||||
{
|
||||
return data->dsn;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDatabaseUID()
|
||||
{
|
||||
return data->databaseUID;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDatabasePWD()
|
||||
{
|
||||
return data->databasePWD;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDatabaseSchema()
|
||||
{
|
||||
return data->databaseSchema;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline unsigned short ConfigCommodityServer::getSecondsBetweenDBReconnect()
|
||||
{
|
||||
return data->secondsBetweenDBReconnect;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getDatabaseProtocol()
|
||||
{
|
||||
return (data->databaseProtocol);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigCommodityServer::getEnableQueryProfile()
|
||||
{
|
||||
return (data->enableQueryProfile);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigCommodityServer::getVerboseQueryMode()
|
||||
{
|
||||
return (data->verboseQueryMode);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigCommodityServer::getDevelopmentMode()
|
||||
{
|
||||
return (data->developmentMode);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getDatabaseThreads()
|
||||
{
|
||||
return (data->databaseThreads);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline unsigned int ConfigCommodityServer::getDatabaseCharacterNameSizeLimit()
|
||||
{
|
||||
return (data->databaseCharacterNameSizeLimit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline unsigned int ConfigCommodityServer::getDatabaseItemNameSizeLimit()
|
||||
{
|
||||
return (data->databaseItemNameSizeLimit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline unsigned int ConfigCommodityServer::getDatabaseUserDescriptionSizeLimit()
|
||||
{
|
||||
return (data->databaseUserDescriptionSizeLimit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline unsigned int ConfigCommodityServer::getDatabaseOOBDataSizeLimit()
|
||||
{
|
||||
return (data->databaseOOBDataSizeLimit);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigCommodityServer::getSnapshotDBWrite()
|
||||
{
|
||||
return (data->snapshotDBWrite);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline bool ConfigCommodityServer::getShowAllDebugInfo()
|
||||
{
|
||||
return (data->showAllDebugInfo);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline unsigned short ConfigCommodityServer::getCentralServerPort()
|
||||
{
|
||||
return data->centralServerPort;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline const char * ConfigCommodityServer::getCentralServerAddress()
|
||||
{
|
||||
return data->centralServerAddress;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getSleepTimePerFrameMs()
|
||||
{
|
||||
return data->sleepTimePerFrameMs;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesActiveToUnaccessed()
|
||||
{
|
||||
return data->minutesActiveToUnaccessed;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesEmptyToEndangered()
|
||||
{
|
||||
return data->minutesEmptyToEndangered;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesUnaccessedToEndangered()
|
||||
{
|
||||
return data->minutesUnaccessedToEndangered;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesEndangeredToRemoved()
|
||||
{
|
||||
return data->minutesEndangeredToRemoved;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesVendorAuctionTimer()
|
||||
{
|
||||
return data->minutesVendorAuctionTimer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMinutesVendorItemTimer()
|
||||
{
|
||||
return data->minutesVendorItemTimer;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
inline int ConfigCommodityServer::getMaxAuctionsPerPage()
|
||||
{
|
||||
return data->maxAuctionsPerPage;
|
||||
}
|
||||
|
||||
#endif // _ConfigCommodityServer_H
|
||||
@@ -0,0 +1,218 @@
|
||||
// DatabaseServerConnection.cpp
|
||||
// copyright 2000 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "DatabaseServerConnection.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "AuctionMarket.h"
|
||||
#include "sharedLog/Log.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "sharedNetwork/NetworkSetupData.h"
|
||||
#include "sharedNetworkMessages/GameNetworkMessage.h"
|
||||
#include "sharedNetworkMessages/DeleteCharacterMessage.h"
|
||||
#include "serverNetworkMessages/CommoditiesLoadDoneMessage.h"
|
||||
#include "serverNetworkMessages/GetAuctionLocationsMessage.h"
|
||||
#include "serverNetworkMessages/GetMarketAuctionsMessage.h"
|
||||
#include "serverNetworkMessages/GetMarketAuctionAttributesMessage.h"
|
||||
#include "serverNetworkMessages/GetMarketAuctionBidsMessage.h"
|
||||
#include "UnicodeUtils.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
DatabaseServerConnection::DatabaseServerConnection(const std::string & a, const unsigned short p) :
|
||||
ServerConnection(a, p, NetworkSetupData())
|
||||
{
|
||||
LOG("DatabaseServerConnection", ("Connection with the database server created"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
DatabaseServerConnection::~DatabaseServerConnection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void DatabaseServerConnection::onConnectionClosed()
|
||||
{
|
||||
LOG("DatabaseServerConnection", ("Connection with the database server is closed"));
|
||||
static MessageConnectionCallback m("DatabaseServerConnectionClosed");
|
||||
emitMessage(m);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void DatabaseServerConnection::onConnectionOpened()
|
||||
{
|
||||
LOG("DatabaseServerConnection", ("Connection with the database server is open"));
|
||||
static MessageConnectionCallback m("DatabaseServerConnectionOpened");
|
||||
emitMessage(m);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void DatabaseServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
static int lastLocationCount = 0, currentLocationCount = 0;
|
||||
static int lastAuctionCount = 0, currentAuctionCount = 0;
|
||||
static int lastAuctionAttributeCount = 0, currentAuctionAttributeCount = 0;
|
||||
static int lastBidCount = 0, currentBidCount = 0;
|
||||
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if (msg.isType("CommoditiesLoadDone"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
if (currentBidCount != lastBidCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received", currentBidCount));
|
||||
lastBidCount = currentBidCount;
|
||||
}
|
||||
REPORT_LOG("DatabaseServerConnection", ("CommoditiesLoadDone Message received on connection with the database server\n"));
|
||||
CommoditiesLoadDoneMessage m(ri);
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Auction_Locations\n", m.getAuctionLocationsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auctions\n", m.getMarketAuctionsCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Attributes\n", m.getMarketAuctionAttributesCount()));
|
||||
REPORT_LOG("DatabaseServerConnection", ("%d rows received on Market_Auction_Bids\n", m.getMarketAuctionBidsCount()));
|
||||
LOG("CommoditiesServer", ("CommoditiesLoadDone Message received, %d rows Auction_Locations, %d rows Market_Auctions, %d rows Market_Auction_Attributes, %d rows Market_Auction_Bids", m.getAuctionLocationsCount(), m.getMarketAuctionsCount(), m.getMarketAuctionAttributesCount(), m.getMarketAuctionBidsCount()));
|
||||
|
||||
LOG("CommoditiesServer", ("Start build index for attribute search"));
|
||||
AuctionMarket::getInstance().BuildAuctionsSearchableAttributeList();
|
||||
LOG("CommoditiesServer", ("End build index for attribute search"));
|
||||
|
||||
emitMessage(m);
|
||||
}
|
||||
else if (msg.isType("GetAuctionLocationsMessage"))
|
||||
{
|
||||
GetAuctionLocationsMessage m(ri);
|
||||
const std::list<GetAuctionLocationsMessage::AuctionLocation> & auctionLocations = m.getAuctionLocations();
|
||||
for (std::list<GetAuctionLocationsMessage::AuctionLocation>::const_iterator iter = auctionLocations.begin(); iter != auctionLocations.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveAuctionLocations(iter->locationId, iter->locationName, iter->ownerId, iter->salesTax, iter->salesTaxBankId, iter->emptyDate, iter->lastAccessDate, iter->inactiveDate, iter->status, iter->searchEnabled, iter->entranceCharge);
|
||||
currentLocationCount++;
|
||||
if (currentLocationCount - lastLocationCount >= 1000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionsMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
GetMarketAuctionsMessage m(ri);
|
||||
const std::list<GetMarketAuctionsMessage::MarketAuction> & auctions = m.getAuctions();
|
||||
for (std::list<GetMarketAuctionsMessage::MarketAuction>::const_iterator iter = auctions.begin(); iter != auctions.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctions(iter->itemId, iter->ownerId, iter->creatorId, iter->locationId, iter->minBid, iter->buyNowPrice, iter->auctionTimer, iter->oob, iter->userDescription, iter->category, iter->itemTemplateId, iter->itemName, iter->itemTimer, iter->active, iter->itemSize);
|
||||
currentAuctionCount++;
|
||||
if (currentAuctionCount - lastAuctionCount >= 10000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionAttributesMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
GetMarketAuctionAttributesMessage m(ri);
|
||||
const std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute> & attributes = m.getAttributes();
|
||||
for (std::list<GetMarketAuctionAttributesMessage::MarketAuctionAttribute>::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionAttributes(iter->itemId, iter->attributeName, iter->attributeValue);
|
||||
currentAuctionAttributeCount++;
|
||||
if (currentAuctionAttributeCount - lastAuctionAttributeCount >= 10000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg.isType("GetMarketAuctionBidsMessage"))
|
||||
{
|
||||
if (currentLocationCount != lastLocationCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d AuctionLocations record received\n", currentLocationCount));
|
||||
LOG("CommoditiesServer", ("%d AuctionLocations record received\n", currentLocationCount));
|
||||
lastLocationCount = currentLocationCount;
|
||||
}
|
||||
if (currentAuctionCount != lastAuctionCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctions record received\n", currentAuctionCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctions record received\n", currentAuctionCount));
|
||||
lastAuctionCount = currentAuctionCount;
|
||||
}
|
||||
if (currentAuctionAttributeCount != lastAuctionAttributeCount)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionAttributes record received\n", currentAuctionAttributeCount));
|
||||
lastAuctionAttributeCount = currentAuctionAttributeCount;
|
||||
}
|
||||
GetMarketAuctionBidsMessage m(ri);
|
||||
const std::list<GetMarketAuctionBidsMessage::MarketAuctionBid> & bids = m.getMarketAuctionBids();
|
||||
for (std::list<GetMarketAuctionBidsMessage::MarketAuctionBid>::const_iterator iter = bids.begin(); iter != bids.end(); ++iter)
|
||||
{
|
||||
AuctionMarket::getInstance().onReceiveMarketAuctionBids(iter->itemId, iter->bidderId, iter->bid, iter->maxProxyBid);
|
||||
currentBidCount++;
|
||||
if (currentBidCount - lastBidCount >= 1000)
|
||||
{
|
||||
DEBUG_REPORT_LOG(true, (" -- %d MarketAuctionBids record received\n", currentBidCount));
|
||||
LOG("CommoditiesServer", ("%d MarketAuctionBids record received\n", currentBidCount));
|
||||
lastBidCount = currentBidCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(msg.isType("DeleteCharacterMessage"))
|
||||
{
|
||||
DeleteCharacterMessage message(ri);
|
||||
AuctionMarket::getInstance().DeleteCharacter(message);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// DatabaseServerConnection.h
|
||||
// copyright 2001 Verant Interactive
|
||||
// Author: Justin Randall
|
||||
|
||||
#ifndef _DatabaseServerConnection_H
|
||||
#define _DatabaseServerConnection_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
class DatabaseServerConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
DatabaseServerConnection(const std::string & remoteAddress, const unsigned short remotePort);
|
||||
~DatabaseServerConnection();
|
||||
|
||||
void onConnectionClosed();
|
||||
void onConnectionOpened();
|
||||
void onReceive(const Archive::ByteStream & message);
|
||||
|
||||
private:
|
||||
DatabaseServerConnection(const DatabaseServerConnection&);
|
||||
DatabaseServerConnection& operator= (const DatabaseServerConnection&);
|
||||
|
||||
}; //lint !e1712 default constructor not defined
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _DatabaseServerConnection_H
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// FirstCommodityServer.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
//
|
||||
// This is file contains the requires include to use any of the shared foundation
|
||||
// libs in the Commodities server
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _INCLUDED_FirstCommodityServer_H
|
||||
#define _INCLUDED_FirstCommodityServer_H
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#include "sharedFoundation/FirstSharedFoundation.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_FirstCommodityServer_H
|
||||
@@ -0,0 +1,289 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.h
|
||||
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
// Server Infrastructure by: Justin Randall
|
||||
//
|
||||
// This is message handler for incoming gameserver messages.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "FirstCommodityServer.h"
|
||||
#include "CommodityServer.h"
|
||||
#include "GameServerConnection.h"
|
||||
#include "AuctionMarket.h"
|
||||
#include "ConfigCommodityServer.h"
|
||||
#include "sharedNetworkMessages/GameNetworkMessage.h"
|
||||
#include "serverNetworkMessages/AcceptHighBidMessage.h"
|
||||
#include "serverNetworkMessages/AddAuctionMessage.h"
|
||||
#include "serverNetworkMessages/AddBidMessage.h"
|
||||
#include "serverNetworkMessages/AddImmediateAuctionMessage.h"
|
||||
#include "serverNetworkMessages/CancelAuctionMessage.h"
|
||||
#include "serverNetworkMessages/CreateVendorMarketMessage.h"
|
||||
#include "serverNetworkMessages/DeleteAuctionLocationMessage.h"
|
||||
#include "serverNetworkMessages/DestroyVendorMarketMessage.h"
|
||||
#include "serverNetworkMessages/GetItemDetailsMessage.h"
|
||||
#include "serverNetworkMessages/GetItemMessage.h"
|
||||
#include "serverNetworkMessages/SetSalesTaxMessage.h"
|
||||
#include "sharedNetworkMessages/GenericValueTypeMessage.h"
|
||||
#include "serverNetworkMessages/GetPlayerVendorCountMessage.h"
|
||||
#include "serverNetworkMessages/GetVendorOwnerMessage.h"
|
||||
#include "serverNetworkMessages/GetVendorValueMessage.h"
|
||||
#include "serverNetworkMessages/QueryAuctionHeadersMessage.h"
|
||||
#include "serverNetworkMessages/SetGameTimeMessage.h"
|
||||
#include "serverNetworkMessages/CleanupInvalidItemRetrievalMessage.h"
|
||||
#include "serverNetworkMessages/QueryVendorItemCountMessage.h"
|
||||
#include "serverNetworkMessages/UpdateVendorStatusMessage.h"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace GameServerConnectionNamespace
|
||||
{
|
||||
}
|
||||
|
||||
using namespace GameServerConnectionNamespace;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
GameServerConnection::GameServerConnection(UdpConnectionMT * u, TcpClient * t) :
|
||||
ServerConnection(u, t),
|
||||
m_gameServerId(0),
|
||||
m_showAllDebugInfo(ConfigCommodityServer::getShowAllDebugInfo())
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
GameServerConnection::~GameServerConnection()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void GameServerConnection::onConnectionClosed()
|
||||
{
|
||||
//REPORT_LOG("GameServerConnection", ("Connection with GameServer has closed\n"));
|
||||
|
||||
CommodityServer::getInstance().removeGameServer(m_gameServerId);
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Game Server %d disconnected\n", m_gameServerId));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void GameServerConnection::onConnectionOpened()
|
||||
{
|
||||
m_gameServerId = CommodityServer::getInstance().addGameServer(*this);
|
||||
//setOverflowLimit(ConfigLoginServer::getClientOverflowLimit());
|
||||
|
||||
DEBUG_REPORT_LOG(true, ("[Commodities Server] : Game Server %d opened connection.\n", m_gameServerId));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void GameServerConnection::onReceive(const Archive::ByteStream & message)
|
||||
{
|
||||
|
||||
Archive::ReadIterator ri = message.begin();
|
||||
GameNetworkMessage msg(ri);
|
||||
ri = message.begin();
|
||||
|
||||
if(msg.isType("AcceptHighBidMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AcceptHighBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AcceptHighBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AcceptHighBid(message);
|
||||
}
|
||||
else if(msg.isType("AddAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddAuction(message);
|
||||
}
|
||||
else if(msg.isType("AddBidMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddBidMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddBidMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddBid(message);
|
||||
}
|
||||
else if(msg.isType("AddImmediateAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message AddImmediateAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
AddImmediateAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().AddImmediateAuction(message);
|
||||
}
|
||||
else if(msg.isType("CancelAuctionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CancelAuctionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CancelAuctionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CancelAuction(message);
|
||||
}
|
||||
else if(msg.isType("CreateVendorMarketMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CreateVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CreateVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CreateVendorMarket(message);
|
||||
}
|
||||
else if(msg.isType("DestroyVendorMarketMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DestroyVendorMarketMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DestroyVendorMarketMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DestroyVendorMarket(message);
|
||||
}
|
||||
else if(msg.isType("DeleteAuctionLocationMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message DeleteAuctionLocationMessage from game server id: %d.\n", m_gameServerId ));
|
||||
DeleteAuctionLocationMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().DeleteAuctionLocation(message);
|
||||
}
|
||||
else if(msg.isType("GetItemDetailsMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemDetailsMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemDetailsMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItemDetails(message);
|
||||
}
|
||||
else if(msg.isType("GetItemMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetItemMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetItemMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetItem(message);
|
||||
}
|
||||
else if(msg.isType("SetSalesTaxMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetSalesTaxMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetSalesTaxMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetSalesTax(message);
|
||||
}
|
||||
else if(msg.isType("GetVendorOwnerMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorOwnerMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorOwnerMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorOwner(message);
|
||||
}
|
||||
else if(msg.isType("GetVendorValueMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetVendorValueMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetVendorValueMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetVendorValue(message);
|
||||
}
|
||||
else if(msg.isType("QueryAuctionHeadersMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryAuctionHeadersMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryAuctionHeadersMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryAuctionHeaders(message);
|
||||
}
|
||||
else if(msg.isType("SetGameTimeMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message SetGameTimeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetGameTimeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetGameTime(message);
|
||||
}
|
||||
else if(msg.isType("CleanupInvalidItemRetrievalMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message CleanupInvalidItemRetrievalMessage from game server id: %d.\n", m_gameServerId ));
|
||||
CleanupInvalidItemRetrievalMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().CleanupInvalidItemRetrieval(message);
|
||||
}
|
||||
else if(msg.isType("QueryVendorItemCountMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message QueryVendorItemCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
QueryVendorItemCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().QueryVendorItemCount(message);
|
||||
}
|
||||
else if(msg.isType("GetPlayerVendorCountMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message GetPlayerVendorCountMessage from game server id: %d.\n", m_gameServerId ));
|
||||
GetPlayerVendorCountMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().GetPlayerVendorCount(message);
|
||||
}
|
||||
else if(msg.isType("UpdateVendorSearchOptionMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorSearchOptionMessage from game server id: %d.\n", m_gameServerId ));
|
||||
UpdateVendorSearchOptionMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().UpdateVendorSearchOption(message);
|
||||
}
|
||||
else if(msg.isType("SetEntranceChargeMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(/*m_showAllDebugInfo*/ true, ("[Commodities Server] : Received message SetEntranceChargeMessage from game server id: %d.\n", m_gameServerId ));
|
||||
SetEntranceChargeMessage message(ri);
|
||||
message.SetTrackId(m_gameServerId);
|
||||
AuctionMarket::getInstance().SetEntranceCharge(message);
|
||||
}
|
||||
else if(msg.isType("ResponseCommoditiesExcludedGotTypes"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedGotTypes from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedGotTypes(message.getValue());
|
||||
}
|
||||
else if(msg.isType("ResponseCommoditiesExcludedResourceClasses"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseCommoditiesExcludedResourceClasses from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::set<std::string> > message(ri);
|
||||
AuctionMarket::getInstance().VerifyExcludedResourceClasses(message.getValue());
|
||||
}
|
||||
else if(msg.isType("ResponseResourceTreeHierarchy"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message ResponseResourceTreeHierarchy from game server id: %d.\n", m_gameServerId ));
|
||||
GenericValueTypeMessage<std::map<int, std::set<int> > > message(ri);
|
||||
AuctionMarket::getInstance().SetResourceTreeHierarchy(message.getValue());
|
||||
}
|
||||
else if(msg.isType("UpdateVendorStatusMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorStatusMessage from game server id: %d.\n", m_gameServerId));
|
||||
UpdateVendorStatusMessage message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorStatus(message);
|
||||
}
|
||||
else if(msg.isType("UpdateVendorLocationMessage"))
|
||||
{
|
||||
DEBUG_REPORT_LOG(m_showAllDebugInfo, ("[Commodities Server] : Received message UpdateVendorLocationMessage from game server id: %d.\n", m_gameServerId));
|
||||
GenericValueTypeMessage<std::pair<NetworkId, std::string> > const message(ri);
|
||||
AuctionMarket::getInstance().UpdateVendorLocation(message.getValue().first, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttributeData"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::string>, std::pair<std::pair<int, bool>, std::pair<bool, int> > > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeData(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second.first.first, message.getValue().second.first.second, message.getValue().second.second.first, message.getValue().second.second.second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttributeDataValues"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, std::pair<int, bool> >, std::pair<std::string, int> > > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttributeDataValues(m_gameServerId, message.getValue().first.first, message.getValue().first.second.first, message.getValue().first.second.second, message.getValue().second.first, message.getValue().second.second);
|
||||
}
|
||||
else if(msg.isType("GetItemAttribute"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, NetworkId> > const message(ri);
|
||||
AuctionMarket::getInstance().getItemAttribute(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetVendorInfoForPlayer"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<std::pair<NetworkId, NetworkId>, bool> > const message(ri);
|
||||
AuctionMarket::getInstance().getVendorInfoForPlayer(m_gameServerId, message.getValue().first.first, message.getValue().first.second, message.getValue().second);
|
||||
}
|
||||
else if(msg.isType("GetALPQ"))
|
||||
{
|
||||
GenericValueTypeMessage<std::pair<NetworkId, int> > const message(ri);
|
||||
AuctionMarket::getInstance().getAuctionLocationPriorityQueue(m_gameServerId, message.getValue().first, message.getValue().second);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -0,0 +1,41 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// ConfigCommodityServer.h
|
||||
// Copyright 2004, Sony Online Entertainment Inc., all rights reserved.
|
||||
// Author: Doug Mellencamp
|
||||
// Server Infrastructure by: Justin Randall
|
||||
//
|
||||
// This is message handler for incoming gameserver messages.
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _INCLUDED_GameServerConnection_H
|
||||
#define _INCLUDED_GameServerConnection_H
|
||||
|
||||
|
||||
#include "serverUtility/ServerConnection.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class GameServerConnection : public ServerConnection
|
||||
{
|
||||
public:
|
||||
GameServerConnection(UdpConnectionMT *, TcpClient * t);
|
||||
~GameServerConnection();
|
||||
|
||||
virtual void onConnectionClosed ();
|
||||
virtual void onConnectionOpened ();
|
||||
virtual void onReceive (const Archive::ByteStream & message);
|
||||
|
||||
private:
|
||||
int m_gameServerId;
|
||||
bool m_showAllDebugInfo;
|
||||
|
||||
GameServerConnection();
|
||||
GameServerConnection & operator = (const GameServerConnection & rhs);
|
||||
GameServerConnection(const GameServerConnection & source);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
#endif // _INCLUDED_GameServerConnection_H
|
||||
@@ -0,0 +1,42 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// dBAuctionRecord.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
// Author: Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
|
||||
#ifndef INCLUDED_dBAuctionRecord_H
|
||||
#define INCLUDED_dBAuctionRecord_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "Unicode.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Data structures for querying auctions.
|
||||
*/
|
||||
struct AuctionRecord
|
||||
{
|
||||
NetworkId m_creatorId;
|
||||
int m_minBid;
|
||||
int m_auctionTimer;
|
||||
int m_buyNowPrice;
|
||||
Unicode::String m_userDescription;
|
||||
std::string m_oob;
|
||||
NetworkId m_locationId;
|
||||
NetworkId m_itemId;
|
||||
int m_category;
|
||||
int m_itemTimer;
|
||||
Unicode::String m_itemName;
|
||||
NetworkId m_ownerId;
|
||||
int m_active;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// dBBidRecord.h
|
||||
// copyright (c) 2004 Sony Online Entertainment
|
||||
// Author: Doug Mellencamp
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef INCLUDED_dBBidRecord_H
|
||||
#define INCLUDED_dBBidRecord_H
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "Unicode.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
/**
|
||||
* Data structures for querying bids.
|
||||
*/
|
||||
struct BidRecord
|
||||
{
|
||||
NetworkId m_bidId;
|
||||
NetworkId m_itemId;
|
||||
NetworkId m_bidderId;
|
||||
int m_bid;
|
||||
int m_maxProxyBid;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
typedef stdvector<BidRecord>::fwd BidList;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
create table auction_characters
|
||||
(
|
||||
character_id number(20),
|
||||
character_name varchar2(64),
|
||||
constraint pk_auction_characters primary key (character_id) using index tablespace indexes
|
||||
);
|
||||
grant select on auction_characters to public;
|
||||
@@ -0,0 +1,9 @@
|
||||
create table auction_locations
|
||||
(
|
||||
owner_id number(20), -- BIND_AS(DB::BindableNetworkId)
|
||||
location_name varchar2(256),
|
||||
constraint pk_auction_locations primary key (location_name) using index tablespace indexes,
|
||||
sales_tax number(20),
|
||||
sales_tax_bank_id number(20)
|
||||
);
|
||||
grant select on auction_locations to public;
|
||||
@@ -0,0 +1,18 @@
|
||||
create table auctions
|
||||
(
|
||||
creator_id number(20),
|
||||
creator_name varchar2(64),
|
||||
min_bid number(20),
|
||||
auction_timer number(20),
|
||||
buy_now_price number(20),
|
||||
user_description varchar2(4000),
|
||||
oob varchar2(4000),
|
||||
location varchar2(256),
|
||||
item_id number(20),
|
||||
category number(20),
|
||||
item_timer number(20),
|
||||
item_name varchar2(4000),
|
||||
owner_id number(20),
|
||||
constraint pk_auctions primary key (item_id) using index tablespace indexes
|
||||
);
|
||||
grant select on auctions to public;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
create table market_auction_bids
|
||||
(
|
||||
bid_id number(20),
|
||||
item_id number(20),
|
||||
bidder_id number(20),
|
||||
bid number(20),
|
||||
max_proxy_bid number(20),
|
||||
constraint pk_market_auction_bids primary key (bid_id) using index tablespace indexes
|
||||
);
|
||||
grant select on market_auction_bids to public;
|
||||
create index market_item_index on market_auction_bids (item_id) tablespace indexes;
|
||||
@@ -0,0 +1,18 @@
|
||||
create table market_auctions
|
||||
(
|
||||
creator_id number(20),
|
||||
min_bid number(20),
|
||||
auction_timer number(20),
|
||||
buy_now_price number(20),
|
||||
user_description varchar2(4000),
|
||||
oob varchar2(4000),
|
||||
location varchar2(256),
|
||||
item_id number(20),
|
||||
category number(20),
|
||||
item_timer number(20),
|
||||
item_name varchar2(4000),
|
||||
owner_id number(20),
|
||||
active number(20),
|
||||
constraint pk_market_auctions primary key (item_id) using index tablespace indexes
|
||||
);
|
||||
grant select on market_auctions to public;
|
||||
@@ -0,0 +1,460 @@
|
||||
-------------------------------------------------
|
||||
-- Export file for user AVALDES --
|
||||
-- Created by avaldes on 09-Jun-03, 2:15:33 PM --
|
||||
-------------------------------------------------
|
||||
|
||||
spool sp_swg_auctions.log
|
||||
|
||||
prompt
|
||||
prompt Creating package SWG_COMMODITIES
|
||||
prompt ================================
|
||||
prompt
|
||||
create or replace package swg_commodities is
|
||||
|
||||
-- Author : AVALDES
|
||||
-- Created : 05-Jun-03 4:28:39 PM
|
||||
-- Purpose : Stored Procedures for Star Wars Galaxies Commodities
|
||||
|
||||
TYPE swg_cur IS REF CURSOR;
|
||||
|
||||
FUNCTION create_auction
|
||||
(creator_id_in IN market_auctions.creator_id%TYPE,
|
||||
min_bid_in IN market_auctions.min_bid%TYPE,
|
||||
auction_timer_in IN market_auctions.auction_timer%TYPE,
|
||||
buy_now_price_in IN market_auctions.buy_now_price%TYPE,
|
||||
location_in IN market_auctions.location%TYPE,
|
||||
item_id_in IN market_auctions.item_id%TYPE,
|
||||
category_in IN market_auctions.category%TYPE,
|
||||
item_timer_in IN market_auctions.item_timer%TYPE,
|
||||
owner_id_in IN market_auctions.owner_id%TYPE,
|
||||
active_in IN market_auctions.active%TYPE,
|
||||
auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_character
|
||||
(character_id_in IN auction_characters.character_id%TYPE,
|
||||
character_name_in IN auction_characters.character_name%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION delete_auction
|
||||
(item_id_in IN market_auctions.item_id%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION delete_location
|
||||
(location_in IN auction_locations.location_name%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_bid
|
||||
(bid_id_in IN market_auction_bids.bid_id%TYPE,
|
||||
item_id_in IN market_auction_bids.item_id%TYPE,
|
||||
bidder_id_in IN market_auction_bids.bidder_id%TYPE,
|
||||
bid_in IN market_auction_bids.bid%TYPE,
|
||||
max_proxy_bid_in IN market_auction_bids.max_proxy_bid%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_location
|
||||
(owner_id_in IN auction_locations.owner_id%TYPE,
|
||||
location_name_in IN auction_locations.location_name%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_auction
|
||||
(item_id_in IN market_auctions.item_id%TYPE,
|
||||
active_in IN market_auctions.active%TYPE,
|
||||
owner_id_in IN market_auctions.owner_id%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_location
|
||||
(oldloc_in IN auction_locations.location_name%TYPE,
|
||||
newloc_in IN auction_locations.location_name%TYPE,
|
||||
sales_tax_in IN auction_locations.sales_tax%TYPE,
|
||||
sales_tax_bank_id_in IN auction_locations.sales_tax_bank_id%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_item_location
|
||||
(oldloc_in IN market_auctions.location%TYPE,
|
||||
newloc_in IN market_auctions.location%TYPE)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_characters
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_locations
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_bids
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_market_auctions
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER;
|
||||
|
||||
end swg_commodities;
|
||||
/
|
||||
|
||||
prompt
|
||||
prompt Creating package body SWG_COMMODITIES
|
||||
prompt =====================================
|
||||
prompt
|
||||
create or replace package body swg_commodities is
|
||||
|
||||
FUNCTION create_auction
|
||||
(creator_id_in IN market_auctions.creator_id%TYPE,
|
||||
min_bid_in IN market_auctions.min_bid%TYPE,
|
||||
auction_timer_in IN market_auctions.auction_timer%TYPE,
|
||||
buy_now_price_in IN market_auctions.buy_now_price%TYPE,
|
||||
location_in IN market_auctions.location%TYPE,
|
||||
item_id_in IN market_auctions.item_id%TYPE,
|
||||
category_in IN market_auctions.category%TYPE,
|
||||
item_timer_in IN market_auctions.item_timer%TYPE,
|
||||
owner_id_in IN market_auctions.owner_id%TYPE,
|
||||
active_in IN market_auctions.active%TYPE,
|
||||
auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
INSERT INTO market_auctions
|
||||
(creator_id,
|
||||
min_bid,
|
||||
auction_timer,
|
||||
buy_now_price,
|
||||
user_description,
|
||||
oob,
|
||||
location,
|
||||
item_id,
|
||||
category,
|
||||
item_timer,
|
||||
item_name,
|
||||
owner_id,
|
||||
active)
|
||||
VALUES
|
||||
(creator_id_in,
|
||||
min_bid_in,
|
||||
auction_timer_in,
|
||||
buy_now_price_in,
|
||||
empty_blob(),
|
||||
empty_blob(),
|
||||
location_in,
|
||||
item_id_in,
|
||||
category_in,
|
||||
item_timer_in,
|
||||
empty_blob(),
|
||||
owner_id_in,
|
||||
active_in);
|
||||
|
||||
|
||||
OPEN auction_cur_out FOR
|
||||
SELECT user_description, oob, item_name
|
||||
FROM market_auctions
|
||||
WHERE item_id = item_id_in
|
||||
FOR UPDATE;
|
||||
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END create_auction;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_character
|
||||
(character_id_in IN auction_characters.character_id%TYPE,
|
||||
character_name_in IN auction_characters.character_name%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
INSERT INTO auction_characters
|
||||
(character_id,
|
||||
character_name)
|
||||
VALUES
|
||||
(character_id_in,
|
||||
character_name_in);
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
|
||||
END create_character;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION delete_auction
|
||||
(item_id_in IN market_auctions.item_id%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
DELETE FROM market_auctions
|
||||
WHERE item_id = item_id_in;
|
||||
|
||||
DELETE FROM market_auction_bids
|
||||
WHERE item_id = item_id_in;
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END delete_auction;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION delete_location
|
||||
(location_in IN auction_locations.location_name%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
DELETE FROM auction_locations
|
||||
WHERE location_name = location_in;
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END delete_location;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_bid
|
||||
(bid_id_in IN market_auction_bids.bid_id%TYPE,
|
||||
item_id_in IN market_auction_bids.item_id%TYPE,
|
||||
bidder_id_in IN market_auction_bids.bidder_id%TYPE,
|
||||
bid_in IN market_auction_bids.bid%TYPE,
|
||||
max_proxy_bid_in IN market_auction_bids.max_proxy_bid%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
INSERT INTO market_auction_bids
|
||||
(bid_id,
|
||||
item_id,
|
||||
bidder_id,
|
||||
bid,
|
||||
max_proxy_bid)
|
||||
VALUES
|
||||
(bid_id_in,
|
||||
item_id_in,
|
||||
bidder_id_in,
|
||||
bid_in,
|
||||
max_proxy_bid_in);
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END create_bid;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION create_location
|
||||
(owner_id_in IN auction_locations.owner_id%TYPE,
|
||||
location_name_in IN auction_locations.location_name%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
INSERT INTO auction_locations
|
||||
(owner_id,
|
||||
location_name)
|
||||
VALUES
|
||||
(owner_id_in,
|
||||
location_name_in);
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END create_location;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_auction
|
||||
(item_id_in IN market_auctions.item_id%TYPE,
|
||||
active_in IN market_auctions.active%TYPE,
|
||||
owner_id_in IN market_auctions.owner_id%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
UPDATE market_auctions
|
||||
SET active = active_in,
|
||||
owner_id = owner_id_in
|
||||
WHERE item_id = item_id_in;
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END update_auction;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_location
|
||||
(oldloc_in IN auction_locations.location_name%TYPE,
|
||||
newloc_in IN auction_locations.location_name%TYPE,
|
||||
sales_tax_in IN auction_locations.sales_tax%TYPE,
|
||||
sales_tax_bank_id_in IN auction_locations.sales_tax_bank_id%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
UPDATE auction_locations
|
||||
SET location_name = newloc_in, sales_tax = sales_tax_in, sales_tax_bank_id = sales_tax_bank_id_in
|
||||
WHERE location_name = oldloc_in;
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END update_location;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION update_item_location
|
||||
(oldloc_in IN market_auctions.location%TYPE,
|
||||
newloc_in IN market_auctions.location%TYPE)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
UPDATE market_auctions
|
||||
SET location = newloc_in
|
||||
WHERE location = oldloc_in;
|
||||
|
||||
COMMIT;
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
ROLLBACK;
|
||||
RETURN SQLCODE;
|
||||
END update_item_location;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_characters
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
OPEN auction_cur_out FOR
|
||||
SELECT character_id,
|
||||
character_name
|
||||
FROM auction_characters;
|
||||
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN SQLCODE;
|
||||
END get_auction_characters;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_locations
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
OPEN auction_cur_out FOR
|
||||
SELECT owner_id,
|
||||
location_name,
|
||||
sales_tax,
|
||||
sales_tax_bank_id
|
||||
FROM auction_locations;
|
||||
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN SQLCODE;
|
||||
END get_auction_locations;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_auction_bids
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
OPEN auction_cur_out FOR
|
||||
SELECT bid_id,
|
||||
item_id,
|
||||
bidder_id,
|
||||
bid,
|
||||
max_proxy_bid
|
||||
FROM market_auction_bids;
|
||||
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN SQLCODE;
|
||||
END get_auction_bids;
|
||||
--
|
||||
--
|
||||
--
|
||||
FUNCTION get_market_auctions
|
||||
(auction_cur_out OUT swg_cur)
|
||||
RETURN INTEGER IS
|
||||
BEGIN
|
||||
OPEN auction_cur_out FOR
|
||||
SELECT creator_id,
|
||||
min_bid,
|
||||
auction_timer,
|
||||
buy_now_price,
|
||||
user_description,
|
||||
oob,
|
||||
location,
|
||||
item_id,
|
||||
category,
|
||||
item_timer,
|
||||
item_name,
|
||||
owner_id,
|
||||
active
|
||||
FROM market_auctions
|
||||
FOR UPDATE;
|
||||
|
||||
RETURN 0;
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN SQLCODE;
|
||||
END get_market_auctions;
|
||||
|
||||
end swg_commodities;
|
||||
/
|
||||
|
||||
|
||||
spool off
|
||||
@@ -98,3 +98,7 @@ target_link_libraries(sharedNetwork
|
||||
sharedMessageDispatch
|
||||
udplibrary
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(sharedNetwork mswsock ws2_32)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user