From 887dbdad0d63754bdd5a5e700127cc8e21be8cc1 Mon Sep 17 00:00:00 2001 From: Ulukyn Date: Thu, 16 Jan 2020 12:28:03 +0100 Subject: [PATCH] Merge branch 'ark' --- .../src/entities_game_service/admin.cpp | 13 + .../entities_game_service.cpp | 14 + .../entities_game_service.h | 1 + .../mission_manager/missions_commands.cpp | 347 +++++++++++++++++- .../player_manager/character.cpp | 13 +- 5 files changed, 382 insertions(+), 6 deletions(-) diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index ff24dd444..4272d6807 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -196,6 +196,7 @@ AdminCommandsInit[] = "showOnline", true, "openTargetApp", true, + "openTargetUrl", true, // DEPECRATED !!! "webExecCommand", true, @@ -9050,6 +9051,18 @@ NLMISC_COMMAND(openTargetApp, "open target app", "") } } +//---------------------------------------------------------------------------- +NLMISC_COMMAND(openTargetUrl, "Open target url", " ") +{ + if (args.size() < 2) + return false; + + GET_CHARACTER + + c->sendUrl(args[1]); +} + + //---------------------------------------------------------------------------- NLMISC_COMMAND(eventSetBotURL, "changes the url of a bot", " []") { 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 0b8285d67..da4873a4f 100644 --- a/ryzom/server/src/entities_game_service/entities_game_service.cpp +++ b/ryzom/server/src/entities_game_service/entities_game_service.cpp @@ -665,6 +665,20 @@ void updateConvertFile() } } +string getServerInfos(float x, float y) +{ + CVector pos; + pos.x = x; + pos.y = y; + pos.z = 0; + CRyzomTime::EWeather weather = WeatherEverywhere.getWeather(pos, CTimeDateSeasonManager::getRyzomTimeReference()); + + return toString("%f|%d|%s|%u", + CTimeDateSeasonManager::getRyzomTimeReference().getRyzomTime(), + CTimeDateSeasonManager::getRyzomTimeReference().getRyzomDay(), + EGSPD::CSeason::toString(CTimeDateSeasonManager::getRyzomTimeReference().getRyzomSeason()).c_str(), + (uint)weather); +} //--------------------------------------------------- diff --git a/ryzom/server/src/entities_game_service/entities_game_service.h b/ryzom/server/src/entities_game_service/entities_game_service.h index 32ce8a48a..305899c18 100644 --- a/ryzom/server/src/entities_game_service/entities_game_service.h +++ b/ryzom/server/src/entities_game_service/entities_game_service.h @@ -36,6 +36,7 @@ void cbConnection( const std::string &serviceName, NLNET::TServiceId sid, void * void cbDisconnection( const std::string &serviceName, NLNET::TServiceId sid, void *arg ); void cbMirrorUp( const std::string &serviceName, NLNET::TServiceId sid, void *arg ); void cbMirrorDn( const std::string &serviceName, NLNET::TServiceId sid, void *arg ); +std::string getServerInfos(float x, float y); /** * CPlayerService 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 24fec4685..900e73e5c 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 @@ -61,6 +61,8 @@ using namespace NLMISC; using namespace NLNET; using namespace std; +extern CCharacterBotChatBeginEnd CharacterBotChatBeginEnd; + NLMISC_COMMAND(forceMissionProgress,"debug command used to trigger debug commands","") { if (args.empty() || args.size() > 3) @@ -2518,7 +2520,7 @@ NLMISC_COMMAND(getServerStats,"get server stats"," [< log.displayNL("%f", CTimeDateSeasonManager::getRyzomTimeReference().getRyzomTime ()); else if (stats[i] == "date") // Atys date log.displayNL("%d", CTimeDateSeasonManager::getRyzomTimeReference().getRyzomDay ()); - else if (stats[i] == "season") // Atys date + else if (stats[i] == "season") // Atys season log.displayNL("%s", EGSPD::CSeason::toString(CTimeDateSeasonManager::getRyzomTimeReference().getRyzomSeason()).c_str()); else if (stats[i] == "weather") // Atys weather { @@ -3612,7 +3614,7 @@ NLMISC_COMMAND(delBrick, "Specified player unlearns given brick", " ") +NLMISC_COMMAND(execAiAction, "Exec Ai Action", " ") { if (args.size() < 2) return false; @@ -3726,3 +3728,344 @@ NLMISC_COMMAND(spawnToxic, "Spawn a toxic cloud", " ") +{ + + if ( args.size() < 3 ) + return false; + + GET_ACTIVE_CHARACTER + + float x = (float)c->getX() / 1000.f; + float y = (float)c->getY() / 1000.f; + + if ( args[1] == "creature" ) + { + CSheetId creatureSheetId(args[2]); + if( creatureSheetId != CSheetId::Unknown ) + { + double minDistance = -1.; + CCreature * creature = NULL; + + TMapCreatures::const_iterator it; + const TMapCreatures& creatures = CreatureManager.getCreature(); + for( it = creatures.begin(); it != creatures.end(); ++it ) + { + CSheetId sheetId = (*it).second->getType(); + if( sheetId == creatureSheetId ) + { + double distance = PHRASE_UTILITIES::getDistance( c->getEntityRowId(), (*it).second->getEntityRowId() ); + if( !creature || (creature && distance < minDistance) ) + { + creature = (*it).second; + minDistance = distance; + } + } + } + if( creature ) + { + float fx = 0, fy = 0, fz = 0; + fx = creature->getState().X() / 1000.0f; + fy = creature->getState().Y() / 1000.0f; + fz = creature->getState().Z() / 1000.0f; + log.displayNL("%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", fx, fy, fz, minDistance, x-fx, y-fy); + return true; + } + } + else + { + log.displayNL("ERR: sheet not found"); + } + } + else if ( args[1] == "race" ) + { + EGSPD::CPeople::TPeople race; + race = EGSPD::CPeople::fromString(args[2]); + if ( race != EGSPD::CPeople::EndPeople ) + { + double minDistance = -1.; + CCreature * creature = NULL; + + TMapCreatures::const_iterator it; + const TMapCreatures& creatures = CreatureManager.getCreature(); + for( it = creatures.begin(); it != creatures.end(); ++it ) + { + if( race == (*it).second->getRace() ) + { + double distance = PHRASE_UTILITIES::getDistance( c->getEntityRowId(), (*it).second->getEntityRowId() ); + if( !creature || (creature && distance < minDistance) ) + { + creature = (*it).second; + minDistance = distance; + } + } + } + + if( creature ) + { + float fx = 0, fy = 0, fz = 0; + fx = creature->getState().X() / 1000.0f; + fy = creature->getState().Y() / 1000.0f; + fz = creature->getState().Z() / 1000.0f; + log.displayNL("%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", fx, fy, fz, minDistance, x-fx, y-fy); + return true; + } + } + else + { + log.displayNL("ERR: race not found"); + } + } + else if ( args[1] == "player" ) + { + CEntityBase *entityBase = PlayerManager.getCharacterByName(CShardNames::getInstance().makeFullNameFromRelative(c->getHomeMainlandSessionId(), args[2])); + if (entityBase != NULL) + { + double minDistance = PHRASE_UTILITIES::getDistance( c->getEntityRowId(), entityBase->getEntityRowId() ); + float fx = 0, fy = 0, fz = 0; + fx = entityBase->getState().X / 1000.0f; + fy = entityBase->getState().Y / 1000.0f; + fz = entityBase->getState().Z / 1000.0f; + log.displayNL("%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", fx, fy, fz, minDistance, x-fx, y-fy); + return true; + } + else + { + log.displayNL("ERR: player not found"); + } + } else { + // try to find the bot name + vector aliases; + CAIAliasTranslator::getInstance()->getNPCAliasesFromName( args[2], aliases ); + if ( !aliases.empty() ) + { + TAIAlias alias = aliases[0]; + const CEntityId & botId = CAIAliasTranslator::getInstance()->getEntityId(alias); + if ( botId != CEntityId::Unknown ) + { + CEntityBase *entityBase = CreatureManager.getCreature(botId); + if (entityBase != NULL) + { + double minDistance = PHRASE_UTILITIES::getDistance( c->getEntityRowId(), entityBase->getEntityRowId() ); + float fx = 0, fy = 0, fz = 0; + fx = entityBase->getState().X / 1000.0f; + fy = entityBase->getState().Y / 1000.0f; + fz = entityBase->getState().Z / 1000.0f; + log.displayNL("%.2f,%.2f,%.2f,%.2f,%.2f,%.2f", fx, fy, fz, minDistance, x-fx, y-fy); + return true; + } + } + } + else + { + log.displayNL("ERR: bot not found"); + } + } + log.displayNL("0,0,0,0,0,0"); + return true; +} + +NLMISC_COMMAND(setBehaviour," change entity behaviour"," []") +{ + if ( args.size() < 2 ) + return false; + + CEntityId id; + CEntityBase *e = NULL; + + bool isChar = false; + if (args[0] != "*") + { + CCharacter *c = NULL; + GET_ACTIVE_CHARACTER2 + + if ( args.size() > 2 && args[2] == "target") + { + id = c->getTarget(); + if( id.getType() == 0 ) + { + CCharacter *c = PlayerManager.getChar(id); + if (c && c->getEnterFlag()) + e = c; + } + else + { + e = CreatureManager.getCreature(id); + } + } + else + e = c; + } + else + { + if ( args.size() < 3 ) + return false; + + id.fromString( args[2].c_str() ); + e = CreatureManager.getCreature(id); + } + + if (e) + { + sint behav; + NLMISC::fromString(args[1], behav); + MBEHAV::EBehaviour behaviour = MBEHAV::EBehaviour(behav); + e->setBehaviour( behaviour ); + log.displayNL("%s", toString( e->getBehaviour() ).c_str() ); + } + else + { + log.displayNL("ERR: entity not found"); + } + + return true; +} + +NLMISC_COMMAND(getBehaviour," get entity behaviour"," []") +{ + if ( args.size() < 1 ) + return false; + + CEntityId id; + CEntityBase *e = NULL; + + bool isChar = false; + if (args[0] != "*") + { + CCharacter *c = NULL; + GET_ACTIVE_CHARACTER2 + + if ( args.size() > 2 && args[2] == "target") + { + id = c->getTarget(); + if( id.getType() == 0 ) + { + CCharacter *c = PlayerManager.getChar(id); + if (c && c->getEnterFlag()) + e = c; + } + else + { + e = CreatureManager.getCreature(id); + } + } + else + e = c; + } + else + { + if ( args.size() < 2 ) + return false; + + id.fromString( args[2].c_str() ); + e = CreatureManager.getCreature(id); + } + + if (e) + { + log.displayNL("%s", toString( e->getBehaviour() ).c_str() ); + } + else + { + log.displayNL("ERR: entity not found"); + } + + return true; +} + + +NLMISC_COMMAND(stopMoveBot,"stop move of a bot"," []") +{ + if ( args.size() < 1 ) + return false; + + TDataSetRow TargetRowId; + CEntityBase *e = NULL; + + bool isChar = false; + if (args[0] != "*") + { + CCharacter *c = NULL; + GET_ACTIVE_CHARACTER2 + + if (c) + CharacterBotChatBeginEnd.BotChatStart.push_back(c->getEntityRowId()); + + const CEntityId &target = c->getTarget(); + if (target == CEntityId::Unknown) + { + log.displayNL("ERR: target"); + return true; + } + + TargetRowId = TheDataset.getDataSetRow(target); + } + else + { + if ( args.size() < 2 ) + return false; + + CEntityId target; + target.fromString( args[2].c_str() ); + if (target == CEntityId::Unknown) + { + log.displayNL("ERR: target"); + return true; + } + + TargetRowId = TheDataset.getDataSetRow(target); + } + + CharacterBotChatBeginEnd.BotChatStart.push_back(TargetRowId); +} + + +NLMISC_COMMAND(startMoveBot,"start move of a bot"," []") +{ + if ( args.size() < 1 ) + return false; + + TDataSetRow TargetRowId; + CEntityBase *e = NULL; + + bool isChar = false; + if (args[0] != "*") + { + CCharacter *c = NULL; + GET_ACTIVE_CHARACTER2 + + if (c) + CharacterBotChatBeginEnd.BotChatEnd.push_back(c->getEntityRowId()); + + const CEntityId &target = c->getTarget(); + if (target == CEntityId::Unknown) + { + log.displayNL("ERR: target"); + return true; + } + + log.displayNL("%s", target.toString().c_str()); + TargetRowId = TheDataset.getDataSetRow(target); + } + else + { + if ( args.size() < 2 ) + return false; + + CEntityId target; + target.fromString( args[2].c_str() ); + if (target == CEntityId::Unknown) + { + log.displayNL("ERR: target"); + return true; + } + + TargetRowId = TheDataset.getDataSetRow(target); + } + + CharacterBotChatBeginEnd.BotChatEnd.push_back(TargetRowId); + log.displayNL("OK"); +} 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 c64d51794..12080d645 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -6117,6 +6117,9 @@ void CCharacter::respawnPet() { for (uint i = 0; i < _PlayerPets.size(); ++i) { + if (_PlayerPets[i].PetStatus == CPetAnimal::in_bag) + continue; + if (_PlayerPets[i].PetStatus != CPetAnimal::not_present && (_PlayerPets[i].PetStatus != CPetAnimal::stable || _RespawnMainLandInTown)) { @@ -6308,6 +6311,7 @@ bool CCharacter::spawnCharacterAnimal(uint index) msg.Coordinate_Y = _PlayerPets[index].Landscape_Y; msg.Coordinate_H = _PlayerPets[index].Landscape_Z; msg.Heading = 0.0f; + msg.Cell = 0; break; case CPetAnimal::stable: @@ -14796,7 +14800,7 @@ string CCharacter::getTargetInfos() string msg = target.toString()+"|"; if (target == CEntityId::Unknown) - return "0"; + return "?"; if (target.getType() == RYZOMID::creature) msg += "c|"; @@ -14838,7 +14842,7 @@ string CCharacter::getTargetInfos() CMirrorPropValueRO srcCell(TheDataset, dsr, DSPropertyCELL); sint32 cell = srcCell; - msg += toString("%.2f|%.2f|%.2f|%.2f|%.4f|%d", dist, x, y, z, h, cell); + msg += toString("%.2f|%.2f|%.2f|%.2f|%.4f|%d|", dist, x, y, z, h, cell)+cTarget->getType().toString()+"|"+EGSPD::CPeople::toString(cTarget->getRace())+"|"+toString("%d", cTarget->getGender()); } } else @@ -14871,7 +14875,7 @@ string CCharacter::getTargetInfos() CMirrorPropValueRO srcCell(TheDataset, dsr, DSPropertyCELL); sint32 cell = srcCell; - msg += toString("%.2f|%.2f|%.2f|%.2f|%.4f|%d", dist, x, y, z, h, cell); + msg += toString("%.2f|%.2f|%.2f|%.2f|%.4f|%d|", dist, x, y, z, h, cell)+cTarget->getType().toString()+"|"+EGSPD::CPeople::toString(cTarget->getRace())+"|"+toString("%d", cTarget->getGender()); } } @@ -15564,9 +15568,10 @@ void CCharacter::sendUrl(const string &url) string playerPos = getPositionInfos(); strFindReplace(playerPos, " ", "%20"); string targetInfos = getTargetInfos(); + string serverInfos = getServerInfos(getState().X / 1000., getState().Y / 1000.); strFindReplace(targetInfos, " ", "%20"); - string final_url = url + toString("&urlidx=%d", getUrlIndex())+"&player_pos="+playerPos+"&target_infos="+targetInfos; + string final_url = url + toString("&urlidx=%d", getUrlIndex())+"&player_pos="+playerPos+"&target_infos="+targetInfos+"&server_infos="+serverInfos; control = "&hmac="+ getHMacSHA1((uint8*)&final_url[0], (uint32)final_url.size(), (uint8*)&salt[0], (uint32)salt.size()).toString(); uint32 userId = PlayerManager.getPlayerId(getId());