📄 goodsinventory.cpp
字号:
//////////////////////////////////////////////////////////////////////////// Filename : GoodsInventory.cpp// Written By : bezz// Description : 权其捞瘤俊辑 备概茄 酒捞袍捞 淬败 乐绰 Inventory//////////////////////////////////////////////////////////////////////////#include "GoodsInventory.h"#include "DB.h"GoodsInventory::~GoodsInventory() throw(){ clear();}void GoodsInventory::clear() throw(){ __BEGIN_TRY ListItemItr itr = m_Goods.begin(); for ( ; itr != m_Goods.end(); itr++ ) { SAFE_DELETE( (*itr).m_pItem ); } m_Goods.clear(); __END_CATCH}void GoodsInventory::addItem( string ID, Item* pItem ) throw(){ __BEGIN_TRY BuyItem buyItem; buyItem.m_ID = ID; buyItem.m_pItem = pItem; m_Goods.push_back( buyItem ); __END_CATCH}Item* GoodsInventory::getItem( ObjectID_t oid ) throw(){ __BEGIN_TRY if ( m_Goods.empty() ) return NULL; Item* pItem = NULL; ListItemItr itr = m_Goods.begin(); for ( ; itr != m_Goods.end(); itr++ ) { if ( (*itr).m_pItem->getObjectID() == oid ) { pItem = (*itr).m_pItem; break; } } return pItem; __END_CATCH}Item* GoodsInventory::popItem( ObjectID_t oid ) throw(){ __BEGIN_TRY if ( m_Goods.empty() ) return NULL; Item* pItem = NULL; ListItemItr itr = m_Goods.begin(); for ( ; itr != m_Goods.end(); itr++ ) { if ( (*itr).m_pItem->getObjectID() == oid ) { pItem = (*itr).m_pItem; filelog( "Goods.log", "酒捞袍阑 茫酒艾嚼聪促. : [%s:%s]", (*itr).m_ID.c_str(), (*itr).m_pItem->toString().c_str() ); Statement* pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getDistConnection("PLAYER_DB")->createStatement(); Result* pResult = pStmt->executeQuery( "UPDATE GoodsListObject SET Num = Num - 1, Status = IF( NUM < 1, 'GET', 'NOT' ) WHERE ID=%s", (*itr).m_ID.c_str() ); // UPDATE牢 版快绰 Result* 措脚俊.. pStmt->getAffectedRowCount() if ( pStmt->getAffectedRowCount() == 0 ) { filelog( "Goods.log", "辟单 DB俊 诀单捞飘啊 救灯嚼聪促. : %s", (*itr).m_ID.c_str() ); } SAFE_DELETE(pStmt); } END_DB(pStmt) m_Goods.erase( itr ); break; } } return pItem; __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -