diff --git a/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp b/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp index c48a806e0..9146c7fa6 100644 --- a/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp +++ b/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp @@ -3292,6 +3292,26 @@ NLMISC_COMMAND(setPlayerPetName, "change the name of a player pet", " ") +{ + if (args.size() != 3) + return false; + + GET_ACTIVE_CHARACTER + uint8 index; + fromString(args[1], index); + string title; + if (args[2] != "-") + title = args[2]; + else + title = ""; + + c->setAnimalTitle(index, title); + log.displayNL("OK"); + return true; +} + //setPlayerVisual 530162 haircut fy_hof_hair_basic02.sitem //---------------------------------------------------------------------------- NLMISC_COMMAND(setPlayerVisual, "get visual of a player", "<uid> <visual_prop1>[,<visual_prop1>,...] <arg1>[,<arg2>,...]") diff --git a/ryzom/server/src/entities_game_service/player_manager/character.cpp b/ryzom/server/src/entities_game_service/player_manager/character.cpp index aa1582780..3e9172fbd 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -7796,6 +7796,32 @@ void CCharacter::setAnimalName(uint8 petIndex, ucstring customName) sendMessageViaMirror("IOS", msgout); } +void CCharacter::setAnimalTitle(uint8 petIndex, string title) +{ + if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) + { + nlwarning("<CCharacter::setAnimalName> Incorect animal index '%d'.", petIndex); + return; + } + + CPetAnimal &animal = _PlayerPets[petIndex]; + string name = animal.getCustomName().toUtf8(); + if (name.find('$') != string::npos) + { + name = name.substr(0, name.find('$')); + } + ucstring customName; + customName.fromUtf8(name+"$"+title) + animal.setCustomName(customName); + + sendPetCustomNameToClient(petIndex); + TDataSetRow row = animal.SpawnedPets; + NLNET::CMessage msgout("CHARACTER_NAME"); + msgout.serial(row); + msgout.serial(customName); + sendMessageViaMirror("IOS", msgout); +} + //----------------------------------------------------------------------------- void CCharacter::sendPetCustomNameToClient(uint8 petIndex) { diff --git a/ryzom/server/src/entities_game_service/player_manager/character.h b/ryzom/server/src/entities_game_service/player_manager/character.h index f7830c93f..87f2871ba 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.h +++ b/ryzom/server/src/entities_game_service/player_manager/character.h @@ -1111,6 +1111,7 @@ public: // Set the name of the animal void setAnimalName(uint8 petIndex, ucstring customName); + void setAnimalTitle(uint8 petIndex, string title); void sendPetCustomNameToClient(uint8 petIndex);