bool MgServerFeatureTransactionPool::RollbackTransaction(CREFSTRING transactionId)
{
    Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
    if (NULL != tran.p)
    {
        tran->Rollback();
    }

    return RemoveTransaction(transactionId);
}
bool MgServerFeatureTransactionPool::CommitTransaction(CREFSTRING transactionId)
{
    ValidateTimeout(transactionId);

    Ptr<MgServerFeatureTransaction> tran = GetTransaction(transactionId);
    if (NULL != tran.p)
    {
        tran->Commit();
    }

    return RemoveTransaction(transactionId);
}
Exemple #3
0
int TradeManager :: CancelTransaction(int playerID, int tradeID, char *buffer)
{
	//Removes a transaction from the list.  Prepares and sends a close message
	//to the players involved.

	//The return value needs to be a generic error, so the calling function can
	//easily exit by do something like "return CancelTransaction()";

	TradeTransaction *tradeData = GetExistingTransaction(tradeID);
	if(tradeData == NULL)
		return -1;

	if(playerID == tradeData->player[1].selfPlayerID)
		playerID = tradeData->player[0].selfPlayerID;

	int wpos = 0;
	wpos += PutByte(&buffer[wpos], 51);     //_handleTradeMsg
	wpos += PutShort(&buffer[wpos], 0);    //Placeholder for size
	wpos += PutInteger(&buffer[wpos], playerID);   //traderID
	wpos += PutByte(&buffer[wpos], TradeEventTypes::REQUEST_CLOSED);     //eventType
	wpos += PutByte(&buffer[wpos], CloseReasons::CANCELED);     //eventType
	PutShort(&buffer[1], wpos - 3);       //Set message size

	//Send to both players.
	SendToOneSimulator(buffer, wpos, tradeData->player[0].cInst->simulatorPtr);
	SendToOneSimulator(buffer, wpos, tradeData->player[1].cInst->simulatorPtr);

	//tradeData->player[0].cInst->actInst->LSendToOneSimulator(buffer, wpos, tradeData->player[0].cInst->SimulatorIndex);
	//tradeData->player[1].cInst->actInst->LSendToOneSimulator(buffer, wpos, tradeData->player[1].cInst->SimulatorIndex);

	//Remove trade data
	tradeData->player[0].cInst->activeLootID = 0;
	tradeData->player[1].cInst->activeLootID = 0;

	//Remove this trade object entirely.
	RemoveTransaction(tradeID);
	return -1;
}