From af4d2d62362b9b30ba4f4a3000f5c5a95e9090b0 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Tue, 19 Jul 2011 19:10:12 +0200 Subject: [PATCH] Changed: #1304: Implementation of the "guild" parameter for the "recv_money" action --HG-- branch : gsoc2011-guildmissions --- .../mission_manager/mission_action.cpp | 64 ++++++++++++++++--- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp b/code/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp index f8a762f95..c039b6b5f 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_action.cpp @@ -1695,19 +1695,63 @@ class CMissionActionRecvMoney : public IMissionAction std::vector entities; instance->getEntities(entities); - uint amount = _Amount / (uint)entities.size(); - if ( amount == 0 || _Amount % entities.size() ) - amount++; - for ( uint i = 0; i < entities.size(); i++ ) + + // If the guild parameter is not set we just divide the money and give it to each entity + if (!_Guild) { - CCharacter * user = PlayerManager.getChar( entities[i] ); - if ( user ) + + uint amount = _Amount / (uint)entities.size(); + if ( amount == 0 || _Amount % entities.size() ) + amount++; + for ( uint i = 0; i < entities.size(); i++ ) { - user->giveMoney( _Amount ); - SM_STATIC_PARAMS_1(params, STRING_MANAGER::integer); - params[0].Int = _Amount; - PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_RECV_MONEY",params); + CCharacter * user = PlayerManager.getChar( entities[i] ); + if ( user ) + { + user->giveMoney( _Amount ); + SM_STATIC_PARAMS_1(params, STRING_MANAGER::integer); + params[0].Int = _Amount; + PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_RECV_MONEY",params); + } } + + } + // Else we give the money to the guild + else + { + if (entities.size() == 0) + return; + + CCharacter * user = PlayerManager.getChar( entities[0] ); + if (!user) + { + LOGMISSIONACTION("recv_money : Invalid user"); + return; + } + + CGuild * guild = CGuildManager::getInstance()->getGuildFromId(user->getGuildId()); + if (guild) + { + guild->addMoney(_Amount); + } + else + { + LOGMISSIONACTION("recv_money : Invalid guild id '" + NLMISC::toString(user->getGuildId()) + "'"); + return; + } + + // tell everyone some money has been given to the guild + for ( uint i = 0; i < entities.size(); i++ ) + { + CCharacter * user = PlayerManager.getChar( entities[i] ); + if ( user ) + { + SM_STATIC_PARAMS_1(params, STRING_MANAGER::integer); + params[0].Int = _Amount; + PHRASE_UTILITIES::sendDynamicSystemMessage(user->getEntityRowId(),"MIS_GUILD_RECV_MONEY",params); + } + } + } }; uint _Amount;