From 41e4f6800fde001b479b5d3c2e7b5b4198e5608a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 24 Jun 2021 15:18:18 +0800 Subject: [PATCH] Merge fixes from core branch --- .../src/entities_game_service/admin.cpp | 25 +++++++++-------- .../entities_game_service/client_messages.cpp | 2 +- .../common_shard_callbacks.cpp | 2 +- .../src/entities_game_service/deposit.cpp | 2 +- .../egs_static_continent.h | 2 +- .../entities_game_service.cpp | 7 ++++- .../inventory_updater.cpp | 2 +- .../pvp_faction_reward_manager.cpp | 10 +++++++ .../pvp_manager/pvp_manager_2.cpp | 28 +++++++++++++++++-- .../shop_type/character_shopping_list.cpp | 8 ++++-- .../shop_type/dynamic_items.cpp | 1 + .../shop_type/items_for_sale.cpp | 1 + .../shop_type/shop_type_manager.cpp | 8 +++--- .../shop_type/shop_type_manager.h | 2 +- .../team_manager/reward_sharing.cpp | 4 +-- 15 files changed, 74 insertions(+), 30 deletions(-) diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index 8f53de3a4..af5d93107 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -4520,24 +4520,25 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " getUserDynChannel(name); + string name = args[1]; + string nameLwr = toCaseInsensitive(args[1]); + TChanID channel = inst->getUserDynChannel(nameLwr); if (args.size() < 3) - pass = toLower(name); + pass = nameLwr; else pass = args[2]; - if ( (channel == DYN_CHAT_INVALID_CHAN) && (pass != string("*")) && (pass != string("***")) ) - channel = inst->createUserChannel(name, pass); + if ( (channel == DYN_CHAT_INVALID_CHAN) && (pass != nlstr("*")) && (pass != nlstr("***")) ) + channel = inst->createUserChannel(nameLwr, pass); if (channel != DYN_CHAT_INVALID_CHAN) { string channelPass = inst->getPassUserChannel(channel); - if ( pass == string("***") && (c->havePriv(":DEV:") || c->havePriv(":SGM:") || c->havePriv(":GM:") || c->havePriv(":EM:"))) + if ( pass == nlstr("***") && (c->havePriv(":DEV:") || c->havePriv(":SGM:") || c->havePriv(":GM:") || c->havePriv(":EM:"))) { - inst->deleteUserChannel(name); + inst->deleteUserChannel(nameLwr); } else if (channelPass == pass) { @@ -4548,7 +4549,7 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " addFactionChannelToCharacter(channel, c, true, true); } - else if (pass == string("*")) + else if (pass == nlstr("*")) { inst->removeFactionChannelForCharacter(channel, c, true); } @@ -4556,7 +4557,7 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " setFullPVP(true); - else if (value=="0" || value=="off" || toLower(value)=="false" ) + else if (value=="0" || value=="off" || toLowerAscii(value)=="false" ) c->setFullPVP(false); // c->setPVPRecentActionFlag(); CPVPManager2::getInstance()->setPVPModeInMirror(c); diff --git a/ryzom/server/src/entities_game_service/client_messages.cpp b/ryzom/server/src/entities_game_service/client_messages.cpp index ebbf53bed..918b399c1 100644 --- a/ryzom/server/src/entities_game_service/client_messages.cpp +++ b/ryzom/server/src/entities_game_service/client_messages.cpp @@ -1980,7 +1980,7 @@ void cbClientSendCustomEmote( NLNET::CMessage& msgin, const std::string &service return; } - if(behaviour >= 140 && behaviour <= 169) + if (behaviour >= (MBEHAV::EMOTE_BEGIN + 80) && behaviour <= (MBEHAV::EMOTE_BEGIN + 109)) { string name = CEntityIdTranslator::getInstance()->getByEntity(id).toString(); nlwarning("HACK: %s %s tries to launch a firework %d", id.toString().c_str(), name.c_str(), behaviour); diff --git a/ryzom/server/src/entities_game_service/common_shard_callbacks.cpp b/ryzom/server/src/entities_game_service/common_shard_callbacks.cpp index 4febd07d0..bdac3f1a6 100644 --- a/ryzom/server/src/entities_game_service/common_shard_callbacks.cpp +++ b/ryzom/server/src/entities_game_service/common_shard_callbacks.cpp @@ -53,7 +53,7 @@ void cbStallShard( NLNET::CMessage& msgin, const std::string &serviceName, NLNET msgin.serial( filename ); nlwarning("Backup service send Stall order when trying write %s file", filename.c_str() ); - PlayerManager.broadcastMessage( 2, 0, 5, "Technical problem occured on the server,"); + PlayerManager.broadcastMessage( 2, 0, 5, "Technical problem occurred on the server,"); PlayerManager.broadcastMessage( 2, 0, 5, "All non administrator accounts are disconnected immediately."); PlayerManager.broadcastMessage( 2, 0, 5, "Customer Support is already working on it."); PlayerManager.broadcastMessage( 2, 0, 5, "Sorry for any inconveniences."); diff --git a/ryzom/server/src/entities_game_service/deposit.cpp b/ryzom/server/src/entities_game_service/deposit.cpp index 7d8000f4d..a234e177f 100644 --- a/ryzom/server/src/entities_game_service/deposit.cpp +++ b/ryzom/server/src/entities_game_service/deposit.cpp @@ -586,7 +586,7 @@ void CDeposit::selectRMsByFilters( std::vector& exactRMCodesS, cons if ( ! depositReportCreated ) { depositReportCreated = true; - depositReportFile = fopen( "deposit_contents.csv", "wt" ); // fclose() auto? + depositReportFile = nlfopen( "deposit_contents.csv", "wt" ); // fclose() auto? if ( depositReportFile ) { fprintf( depositReportFile, "Deposit;RM;When in year;When in day;Weather;\n" ); diff --git a/ryzom/server/src/entities_game_service/egs_static_continent.h b/ryzom/server/src/entities_game_service/egs_static_continent.h index 85db06c8e..3427a0b98 100644 --- a/ryzom/server/src/entities_game_service/egs_static_continent.h +++ b/ryzom/server/src/entities_game_service/egs_static_continent.h @@ -27,7 +27,7 @@ class CStaticWorld { public: /// Serialisation - void serial(class NLMISC::IStream &f); + void serial(NLMISC::IStream &f); /// read georges sheet void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &sheetId); diff --git a/ryzom/server/src/entities_game_service/entities_game_service.cpp b/ryzom/server/src/entities_game_service/entities_game_service.cpp index ad36aef56..f2d2b1cee 100644 --- a/ryzom/server/src/entities_game_service/entities_game_service.cpp +++ b/ryzom/server/src/entities_game_service/entities_game_service.cpp @@ -1004,6 +1004,10 @@ void CPlayerService::egsAddMonkeyPlayer() } idx++; } + else + { + return; + } } if( PlayerManager.getPlayer( userId ) != 0 ) @@ -3938,7 +3942,8 @@ NLMISC_COMMAND( db, "Display or set the value of a property in the database", "< { // Set sint64 value; - sscanf( args[2].c_str(), "%" NL_I64 "d", &value ); + fromString(args[2], value); + if ( (args.size() > 3) && (args[3]!="0") ) { res = e->_PropertyDatabase.x_setPropButDontSend( entry, value ); diff --git a/ryzom/server/src/entities_game_service/inventory_updater.cpp b/ryzom/server/src/entities_game_service/inventory_updater.cpp index a09923dcd..507032131 100644 --- a/ryzom/server/src/entities_game_service/inventory_updater.cpp +++ b/ryzom/server/src/entities_game_service/inventory_updater.cpp @@ -194,7 +194,7 @@ void CInventoryUpdaterForCharacter::resetItemIntoClassicDatabase( INVENTORIES:: arrayItem.setSHEET(*_PropertyDatabasePt, CSheetId::Unknown); arrayItem.setQUALITY(*_PropertyDatabasePt, 0); arrayItem.setQUANTITY(*_PropertyDatabasePt, 0); - arrayItem.setUSER_COLOR(*_PropertyDatabasePt, 0); + arrayItem.setUSER_COLOR(*_PropertyDatabasePt, 1); // arrayItem.setLOCKED(_PropertyDatabasePt, 0); arrayItem.setWEIGHT(*_PropertyDatabasePt, 0); arrayItem.setNAMEID(*_PropertyDatabasePt, 0); diff --git a/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp b/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp index 63d366856..91dbbb605 100644 --- a/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp +++ b/ryzom/server/src/entities_game_service/pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.cpp @@ -971,6 +971,11 @@ NLMISC_COMMAND(buildSpire, "build a spire"," ") x = 11105.0f; y = -4400.0f; } + else + { + log.displayNL( "buildSpire : Invalid region '%s'", args[1].c_str() ); + return true; + } NLMISC::CVector vec( x, y, 0.0f ); @@ -1035,6 +1040,11 @@ NLMISC_COMMAND(destroySpire, "destroy a spire","") x = 11105.0f; y = -4400.0f; } + else + { + log.displayNL( "destroySpire : Invalid region '%s'", args[1].c_str() ); + return true; + } NLMISC::CVector vec( x, y, 0.0f ); diff --git a/ryzom/server/src/entities_game_service/pvp_manager/pvp_manager_2.cpp b/ryzom/server/src/entities_game_service/pvp_manager/pvp_manager_2.cpp index eb8a2350f..8314d8f07 100644 --- a/ryzom/server/src/entities_game_service/pvp_manager/pvp_manager_2.cpp +++ b/ryzom/server/src/entities_game_service/pvp_manager/pvp_manager_2.cpp @@ -471,10 +471,12 @@ void CPVPManager2::addFactionChannelToCharacter(TChanID channel, CCharacter * us { if (DynChatEGS.addSession(channel, user->getEntityRowId(), writeRight)) { +#ifdef HAVE_MONGO string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); string::size_type pos = playerName.find('('); if (pos != string::npos) playerName = playerName.substr(0, pos); +#endif std::vector currentChannels = getCharacterRegisteredChannels(user); currentChannels.push_back(channel); _CharacterChannels.erase(user->getId()); @@ -502,7 +504,11 @@ void CPVPManager2::addFactionChannelToCharacter(TChanID channel, CCharacter * us (*it).second.push_back(user->getId()); } +#ifndef HAVE_MONGO + const string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); +#endif broadcastMessage(channel, string(""), "<-- "+playerName); + sendChannelUsers(channel, user); } } @@ -512,23 +518,35 @@ void CPVPManager2::addFactionChannelToCharacter(TChanID channel, CCharacter * us //---------------------------------------------------------------------------- void CPVPManager2::removeFactionChannelForCharacter(TChanID channel, CCharacter * user, bool userChannel) { - const string channelName = DynChatEGS.getChanNameFromID(channel); std::vector currentChannels; +#ifdef HAVE_MONGO + const string channelName = DynChatEGS.getChanNameFromID(channel); string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); string::size_type pos = playerName.find('('); if (pos != string::npos) playerName = playerName.substr(0, pos); +#endif if (channel == DYN_CHAT_INVALID_CHAN) // Send leaves message to all user channels { currentChannels = getCharacterUserChannels(user); for (uint i = 0; i < currentChannels.size(); i++) + { +#ifndef HAVE_MONGO + const string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); +#endif broadcastMessage(currentChannels[i], string(""), playerName+" -->[]"); + } } if (userChannel) + { +#ifndef HAVE_MONGO + const string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); +#endif broadcastMessage(channel, string(""), playerName+" -->[]"); + } currentChannels = getCharacterRegisteredChannels(user); for (uint i = 0; i < currentChannels.size(); i++) @@ -613,19 +631,23 @@ void CPVPManager2::addRemoveFactionChannelToUserWithPriviledge(TChanID channel, //---------------------------------------------------------------------------- void CPVPManager2::playerConnects(CCharacter * user) { +#ifdef HAVE_MONGO string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); string::size_type pos = playerName.find('('); if (pos != string::npos) playerName = playerName.substr(0, pos); -#ifdef HAVE_MONGO CMongo::update("ryzom_users", toString("{'name': '%s'}", playerName.c_str()), toString("{$set: {'cid': %" NL_I64 "u, 'guildId': %d, 'online': true} }", user->getId().getShortId(), user->getGuildId()), true); #endif std::vector currentChannels = getCharacterUserChannels(user); for (uint i = 0; i < currentChannels.size(); i++) + { +#ifndef HAVE_MONGO + const string playerName = CEntityIdTranslator::getInstance()->getByEntity(user->getId()).toString(); +#endif broadcastMessage(currentChannels[i], string(""), "<-- "+playerName); - + } } //---------------------------------------------------------------------------- diff --git a/ryzom/server/src/entities_game_service/shop_type/character_shopping_list.cpp b/ryzom/server/src/entities_game_service/shop_type/character_shopping_list.cpp index 73370d834..4cb68ddbc 100644 --- a/ryzom/server/src/entities_game_service/shop_type/character_shopping_list.cpp +++ b/ryzom/server/src/entities_game_service/shop_type/character_shopping_list.cpp @@ -61,6 +61,7 @@ CCharacterShoppingList::CCharacterShoppingList( CSmartPtr& merchant, //----------------------------------------------------------------------------- CCharacterShoppingList::~CCharacterShoppingList() { + TLogNoContext_Item noLog; _CurrentTradeListNpc.clear(); _CurrentTradeListPlayer.clear(); _CurrentTradeListYours.clear(); @@ -196,8 +197,11 @@ bool CCharacterShoppingList::passThruFilter(TItemTradePtr itemTrade, bool dynnam { const CStaticItem * form = CSheets::getForm( itemTrade->getSheetId() ); + if (!_Character) + return false; + // No filter on Faction trade - if(_Character && _Character->getBotChatType() == BOTCHATTYPE::TradeFactionFlag) + if(_Character->getBotChatType() == BOTCHATTYPE::TradeFactionFlag) return true; if( form != 0 ) @@ -650,7 +654,7 @@ void CCharacterShoppingList::fillTradePage( uint16 session ) tradeElem.setSERIAL(_Character->_PropertyDatabase, 0); tradeElem.setCREATE_TIME(_Character->_PropertyDatabase, 0); // _Character->_PropertyDatabase.setProp( NLMISC::toString("TRADING:%u:USER_COLOR",index ), 1); - tradeElem.setUSER_COLOR(_Character->_PropertyDatabase, 0); + tradeElem.setUSER_COLOR(_Character->_PropertyDatabase, 1); // _Character->_PropertyDatabase.setProp( NLMISC::toString("TRADING:%u:WEIGHT",index ), 0 ); tradeElem.setWEIGHT(_Character->_PropertyDatabase, 0); // _Character->_PropertyDatabase.setProp( NLMISC::toString("TRADING:%u:NAMEID",index ), 0 ); diff --git a/ryzom/server/src/entities_game_service/shop_type/dynamic_items.cpp b/ryzom/server/src/entities_game_service/shop_type/dynamic_items.cpp index 7a42f46f6..ee1b65a39 100644 --- a/ryzom/server/src/entities_game_service/shop_type/dynamic_items.cpp +++ b/ryzom/server/src/entities_game_service/shop_type/dynamic_items.cpp @@ -425,6 +425,7 @@ void CDynamicItems::tickUpdate() COfflineCharacterCommand::getInstance()->addOfflineCommand( command ); } + TLogNoContext_Item noLog; subVec[_NextItemToCheck] = subVec.back(); subVec.pop_back(); TotalNbItemsForSale = --_TotalNbItemsForSale; diff --git a/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp b/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp index 950eb1d6b..6ca842556 100644 --- a/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp +++ b/ryzom/server/src/entities_game_service/shop_type/items_for_sale.cpp @@ -110,6 +110,7 @@ void CItemsForSale::serial(NLMISC::IStream &f) //----------------------------------------------------------------------------- void CItemsForSale::checkSellStore( CEntityId charId ) { + TLogContext_Item_CheckSaleStore itemStoreContext(charId); std::vector< TItemTradePtr > itemsForSaleOfCharacter; std::vector< TItemTradePtr > itemsOfCharacterMustBeRemoved; CDynamicItems::getInstance()->getItemsOfCharacter( charId, itemsForSaleOfCharacter ); diff --git a/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp b/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp index 4f684981c..6c13bc9ed 100644 --- a/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp +++ b/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.cpp @@ -1046,7 +1046,7 @@ void CShopTypeManager::addTpShopBase( uint32 shopCategoryNumber, uint32 ecosyste //---------------------------------------------------------------------------- void CShopTypeManager::addShopBase( uint32 shopCategoryNumber, CMerchant& merchant, std::vector< uint32 >& rmSelector, std::vector< uint32 >& originSelector, std::vector< uint32 >& qualitySelector, std::vector< uint32 >& levelSelector, std::vector< uint32 >& shopTypeSelector ) { - TShopTypeSelected shopTypeSelected; + TShopTypeSelected shopTypeSelected = InvalidShopSelected; if( shopTypeSelector.size() == 0 ) { shopTypeSelected = AllShopSelected; @@ -1055,15 +1055,15 @@ void CShopTypeManager::addShopBase( uint32 shopCategoryNumber, CMerchant& mercha { for( uint32 i = 0; i < shopTypeSelector.size(); ++i ) { - if( _CategoryName[ shopTypeSelector[ i ] ] == string("STATIC_SHOP") ) + if( _CategoryName[ shopTypeSelector[ i ] ] == "STATIC_SHOP" ) { shopTypeSelected = StaticShopSelected; } - else if( _CategoryName[ shopTypeSelector[ i ] ] == string("DYNAMIC_SHOP") ) + else if( _CategoryName[ shopTypeSelector[ i ] ] == "DYNAMIC_SHOP" ) { shopTypeSelected = DynamicShopSelected; } - else if( _CategoryName[ shopTypeSelector[ i ] ] == string("STATIC_DYNAMIC_SHOP") ) + else if( _CategoryName[ shopTypeSelector[ i ] ] == "STATIC_DYNAMIC_SHOP" ) { shopTypeSelected = AllShopSelected; } diff --git a/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.h b/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.h index ceed8b43f..01a837627 100644 --- a/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.h +++ b/ryzom/server/src/entities_game_service/shop_type/shop_type_manager.h @@ -54,7 +54,7 @@ class CShopTypeManager : public NLMISC::CEvalNumExpr { public: - enum TShopTypeSelected { StaticShopSelected = 0, DynamicShopSelected, AllShopSelected }; + enum TShopTypeSelected { StaticShopSelected = 0, DynamicShopSelected, AllShopSelected, InvalidShopSelected }; /// init / release class static void initShopBase(); diff --git a/ryzom/server/src/entities_game_service/team_manager/reward_sharing.cpp b/ryzom/server/src/entities_game_service/team_manager/reward_sharing.cpp index 28a35c266..78f9dc109 100644 --- a/ryzom/server/src/entities_game_service/team_manager/reward_sharing.cpp +++ b/ryzom/server/src/entities_game_service/team_manager/reward_sharing.cpp @@ -264,7 +264,7 @@ bool CRewardSharing::userValidSelect(const TDataSetRow & userRow, uint8 state) shareItem.setSERIAL(user->_PropertyDatabase, 0); shareItem.setCREATE_TIME(user->_PropertyDatabase, 0); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:USER_COLOR",j), 0 ); - shareItem.setUSER_COLOR(user->_PropertyDatabase, 0); + shareItem.setUSER_COLOR(user->_PropertyDatabase, 1); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:WEIGHT",j), 0 ); shareItem.setWEIGHT(user->_PropertyDatabase, 0); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:NAMEID",j), 0 ); @@ -422,7 +422,7 @@ void CRewardSharing::setUsersDb() shareItem.setSERIAL(user->_PropertyDatabase, 0); shareItem.setCREATE_TIME(user->_PropertyDatabase, 0); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:USER_COLOR",j), 0 ); - shareItem.setUSER_COLOR(user->_PropertyDatabase, 0); + shareItem.setUSER_COLOR(user->_PropertyDatabase, 1); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:WEIGHT",j), 0 ); shareItem.setWEIGHT(user->_PropertyDatabase, 0); // user->_PropertyDatabase.setProp( NLMISC::toString("INVENTORY:SHARE:%u:NAMEID",j), 0 );