diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp index 9aff47c1a..93718ae79 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -7966,7 +7966,7 @@ void CCharacter::endHarvest(bool sendCloseTempImpulsion) if (sendCloseTemp && sendCloseTempImpulsion) { - sendCloseTempInventoryImpulsion(); + sendCloseTempInventoryImpulsion(true); } } // endHarvest // @@ -14477,17 +14477,35 @@ bool CCharacter::pickUpRawMaterial( uint32 indexInTempInv, bool * lastMaterial ) //----------------------------------------------- // sendCloseTempInventoryImpulsion //----------------------------------------------- -void CCharacter::sendCloseTempInventoryImpulsion() +void CCharacter::sendCloseTempInventoryImpulsion(bool onlyIfEmpty) { // Sage: May 9 2007 // The live servers are crashing due to an infinite indirect recursion loop // itemTempInventoryToBag() calls endHarvest() calls sendCloseTempInventoryImpulsion() calls getAllTempInventoryItems() calls itemTempInventoryToBag() ... // the following anti bug is a temporaray fix to prevent inifinte recursion and stack overflow - static bool isRecursing= false; // **** Temp Fix 1/4 **** // - BOMB_IF(isRecursing,"CCharacter::sendCloseTempInventoryImpulsion is recursing!",return); // **** Temp Fix 2/4 **** // - isRecursing= true; // **** Temp Fix 3/4 **** // + static bool isRecursing = false; // **** Temp Fix 1/4 **** // + + if (onlyIfEmpty) + { + CInventoryPtr tempInv = getInventory(INVENTORIES::temporary); + nlassert(tempInv != NULL); + if (tempInv->getUsedSlotCount()) + { + nldebug("Temporary inventory is not empty, do not send impulsion to close"); + return; + } + } + + if (!onlyIfEmpty) + { + BOMB_IF(isRecursing, "CCharacter::sendCloseTempInventoryImpulsion is recursing!", return); // **** Temp Fix 2/4 **** // + isRecursing = true; // **** Temp Fix 3/4 **** // - getAllTempInventoryItems(); // false); + // Take all items + getAllTempInventoryItems(); + + isRecursing= false; // **** Temp Fix 4/4 **** // + } CMessage msgout( "IMPULSION_ID" ); msgout.serial( _Id ); @@ -14500,7 +14518,6 @@ void CCharacter::sendCloseTempInventoryImpulsion() msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length()); CUnifiedNetwork::getInstance()->send( NLNET::TServiceId(_Id.getDynamicId()), msgout ); - isRecursing= false; // **** Temp Fix 4/4 **** // } // sendCloseTempInventoryImpulsion // //----------------------------------------------- diff --git a/code/ryzom/server/src/entities_game_service/player_manager/character.h b/code/ryzom/server/src/entities_game_service/player_manager/character.h index 3a3d6cd96..9631bb01a 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/character.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/character.h @@ -1860,7 +1860,7 @@ public: virtual float getActualDamageFromExplosionWithArmor( float dmg ) const; /// send temp inventory close impulsion to client - void sendCloseTempInventoryImpulsion(); + void sendCloseTempInventoryImpulsion(bool onlyIfEmpty = false); /// set a fame value for the player, send info to the client. void setFameValuePlayer(uint32 factionIndex, sint32 playerFame, sint32 fameMax, uint16 fameTrend);