From 6a79a5bf0ff4be9deaf0a6d5d0b3815b456891c5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 24 Jun 2021 15:17:43 +0800 Subject: [PATCH 1/3] Include fixes from atys branch --- .../src/entities_game_service/admin.cpp | 265 ++++++++++-------- .../entities_game_service/client_messages.cpp | 2 +- .../pvp_manager/pvp_manager_2.cpp | 49 ++-- .../shop_type/named_items.cpp | 4 + .../server/src/entities_game_service/stdpch.h | 2 +- 5 files changed, 179 insertions(+), 143 deletions(-) diff --git a/ryzom/server/src/entities_game_service/admin.cpp b/ryzom/server/src/entities_game_service/admin.cpp index 9d7243f89..2cbce98be 100644 --- a/ryzom/server/src/entities_game_service/admin.cpp +++ b/ryzom/server/src/entities_game_service/admin.cpp @@ -4514,7 +4514,7 @@ NLMISC_COMMAND (connectUserChannel, "Connect to user channels", " getPassUserChannel(channel); - if ( (channel != DYN_CHAT_INVALID_CHAN) && (pass == nlstr("***")) && (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(nameLwr); } @@ -4667,8 +4667,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " infos; CGameItemPtr item; @@ -4680,28 +4679,29 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_index", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_index"); return false; } if (next_step && (iindex != saved_index+1)) { // Next step commands wants an index who follow the last used index. if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_next_index", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_next_index"); return false; } - string salt = getSalt(); string checksumEid = web_app_url + toString(c->getLastConnectedDate()) + index + command + c->getId().toString(); string checksumRowId = web_app_url + toString(c->getLastConnectedDate()) + index + command + toString(c->getEntityRowId().getIndex()); - NLMISC::CHashKey realhmacEid = NLMISC::getHMacSHA1((uint8*)&checksumEid[0], checksumEid.size(), (uint8*)&salt[0], salt.size()); - NLMISC::CHashKey realhmacRowId = NLMISC::getHMacSHA1((uint8*)&checksumRowId[0], checksumRowId.size(), (uint8*)&salt[0], salt.size()); - if (realhmacEid != hmacBin && realhmacRowId != hmacBin && command != "is_valid_index") + string salt = ArkSalt.get(); + + string realhmacEid = getHMacSHA1((uint8*)&checksumEid[0], checksumEid.size(), (uint8*)&salt[0], salt.size()).toString(); + string realhmacRowId = getHMacSHA1((uint8*)&checksumRowId[0], checksumRowId.size(), (uint8*)&salt[0], salt.size()).toString(); + if (realhmacEid != hmac && realhmacRowId != hmac && command != "is_valid_index") { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_auth", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_auth"); return false; } } @@ -4711,7 +4711,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getInventory(INVENTORIES::bag); if (!c->havePriv(":DEV:") || (web_app_url != "debug")) { - uint item_idx = c->checkWebCommand(web_app_url, index+command, hmac, getSalt()); + uint item_idx = c->checkWebCommand(web_app_url, index+command, hmac, ""); if (item_idx == INVENTORIES::NbBagSlots) { nlwarning("Bad web command check"); @@ -4736,11 +4736,11 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " isValidWebCommandIndex(iindex)) { - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=unvalid_index", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=unvalid_index"); } else { - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished&desc=valid_index", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished&desc=valid_index"); } return true; } @@ -4782,7 +4782,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_inventory", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_inventory"); return false; } @@ -4799,7 +4799,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getSheetId() == sheetId) ) { - if (itemPtr->quality() == quality) + if (itemPtr->quality() == quality) numberEqualItem += itemPtr->getStackSize(); if (itemPtr->quality() >= quality) numberItem += itemPtr->getStackSize(); @@ -4810,7 +4810,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_items", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_items"); return false; } @@ -4905,7 +4905,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getSheetId() == sheetId && itemPtr->quality() == quality ) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=allready_have_item", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=allready_have_item"); return false; } } @@ -4922,20 +4922,24 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=cant_add_item", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=cant_add_item"); return false; } if (new_item != NULL) // When the item is stacked, it's deleted by addItemToInventory. Need be checked again to prevent crash of egs { + ucstring customValue; + if (command_args.size() >= 6 && command_args[5] != "*") { - new_item->setPhraseId(command_args[5], true); + customValue.fromUtf8(command_args[5]); + new_item->setCustomName(customValue); } if (command_args.size() >= 7 && command_args[6] != "*") { - new_item->setPhraseId(command_args[6], true); + customValue.fromUtf8(command_args[6]); + new_item->setCustomText(customValue); } if (command_args.size() >= 8) @@ -4976,7 +4980,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " max_x || y > max_y)) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_position", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_position"); return false; } } @@ -5005,12 +5009,12 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " value) || (command_args[2] == "above" && fame < value)) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_fame", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_fame"); return false; } } - + //************************************************* //***************** set_fame (need x6000 to change 1 point) //************************************************* @@ -5034,7 +5038,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getId(), factionIndex, fame-value, false); - nlinfo("fame : %d => %d", fame, fame-value); + nlinfo("fame : %d => %d", fame, fame-value); } else if (command_args[2] == "set") { @@ -5045,20 +5049,20 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getId(), c->getAllegiance()); + CFameManager::getInstance().enforceFameCaps(c->getId(), c->getOrganization(), c->getAllegiance()); // set tribe fame threshold and clamp fame if necessary - CFameManager::getInstance().setAndEnforceTribeFameCap(c->getId(), c->getAllegiance()); + CFameManager::getInstance().setAndEnforceTribeFameCap(c->getId(), c->getOrganization(), c->getAllegiance()); } } //************************************************* - //***************** check_target + //***************** check_target //************************************************* else if (command_args[0] == "check_target") { const CEntityId &target = c->getTarget(); - + if (command_args.size () < 2) return false; if (command_args[1] == "leaguemate") @@ -5066,14 +5070,14 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type"); return false; } CCharacter * targetTarget = dynamic_cast(CEntityBaseManager::getEntityBasePtr(target)); if (targetTarget->getLeagueId() == DYN_CHAT_INVALID_CHAN || c->getLeagueId() != targetTarget->getLeagueId()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_league", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_league"); return false; } } @@ -5082,14 +5086,14 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type"); return false; } CCharacter * targetTarget = dynamic_cast(CEntityBaseManager::getEntityBasePtr(target)); if (targetTarget->getGuildId() == 0 || c->getGuildId() != targetTarget->getGuildId()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_guild", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_guild"); return false; } } @@ -5098,18 +5102,18 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type"); return false; } CCharacter * targetTarget = dynamic_cast(CEntityBaseManager::getEntityBasePtr(target)); if (targetTarget->getTeamId() == CTEAM::InvalidTeamId || c->getTeamId() != targetTarget->getTeamId()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_team", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_team"); return false; } } - + if (command_args.size () < 3) return false; if (command_args[1] == "sheet") @@ -5120,7 +5124,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getType()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_sheet", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_sheet"); return false; } } @@ -5129,7 +5133,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type"); return false; } vector aliases; @@ -5147,7 +5151,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_bot", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_bot"); return false; } } @@ -5156,14 +5160,14 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_type"); return false; } CEntityBase *entityBase = PlayerManager.getCharacterByName(CShardNames::getInstance().makeFullNameFromRelative(c->getHomeMainlandSessionId(), command_args[2])); if (entityBase == NULL) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_player", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_player"); return false; } } else @@ -5171,7 +5175,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " haveBrick(CSheetId(command_args[1]))) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_brick", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_brick"); return false; } } //************************************************* - //***************** set_brick + //***************** set_brick //************************************************* else if (command_args[0] == "set_brick") { @@ -5203,7 +5207,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_brick_action", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_brick_action"); return false; } } @@ -5234,7 +5238,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_inventory", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=bad_inventory"); return false; } @@ -5270,7 +5274,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_items", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_items"); return false; } } @@ -5279,7 +5283,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=have_items", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=have_items"); return false; } } @@ -5301,12 +5305,12 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getState() != OUTPOSTENUMS::DefenseRound)) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc="+command_args[2], getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc="+command_args[2]); return false; } } @@ -5379,7 +5383,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " 7) { - + if (command_args[6] != "*") { float userX; NLMISC::fromString(command_args[6], userX); @@ -5411,7 +5415,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " 10) { @@ -5422,7 +5426,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " isSpawnValid(inVillage, inOutpost, inStable, inAtys)) return false; } @@ -5463,14 +5467,14 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getInstanceNumber(); + uint32 instanceNumber = c->getInstanceNumber(); uint32 nbString = (uint32)command_args.size(); - + // See if it needs another AI instance string botsName = command_args[1]; if ( ! getAIInstanceFromGroupName(botsName, instanceNumber)) @@ -5565,15 +5569,15 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getHomeMainlandSessionId(), command_args[1])); string name = command_args[2]; - + uint32 value; fromString(command_args[3], value); @@ -5703,7 +5707,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_vpx_def", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_vpx_def"); } } //************************************************* @@ -5774,12 +5778,12 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " 3) { - bool pvpFlagValid = (c->getPvPRecentActionFlag() == false || c->getPVPFlag() == false); + bool pvpFlagValid = (c->getPvPRecentActionFlag() == false || c->getPVPFlag() == false); if (command_args[3][0] == '1' && !pvpFlagValid) { CCharacter::sendDynamicSystemMessage(c->getEntityRowId(), "PVP_TP_FORBIDEN"); return true; } - + bool pvpTagValid = c->getPVPFlag() == false; if (command_args[3].length() > 1 && command_args[3][1] == '1' && !pvpTagValid) { @@ -5804,7 +5808,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " res; sint32 x = 0, y = 0, z = 0; float h = 0; @@ -5923,7 +5927,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " allowNearPetTp(); else - c->forbidNearPetTp(); + c->forbidNearPetTp(); // Respawn player if dead if (c->isDead()) @@ -5990,7 +5994,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " allowNearPetTp(); else - c->forbidNearPetTp(); + c->forbidNearPetTp(); IBuildingPhysical * building = CBuildingManager::getInstance()->getBuildingPhysicalsByName(command_args[2]); if ( building ) @@ -6012,7 +6016,12 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " removePlayerFromRoom( c ); uint16 ownerId = buildingPlayer->getOwnerIdx( entityBase->getId() ); + nlinfo("Gettting ownerId : %d", ownerId); + buildingPlayer->addUser(c, 0, ownerId, cell); + + //CBuildingManager::getInstance()->setRoomLifeTime(cell, TGameCycle(NLMISC::TGameTime(4*60*60) / CTickEventHandler::getGameTimeStep())); + nlinfo("Gettting cell : %d", cell); c->teleportCharacter(x,y,z,allowPetTp,true,h,0xFF,cell); } //} @@ -6031,7 +6040,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " setAnimalName(petIndex, customName); } - + //************************************************* //***************** organization //************************************************* @@ -6042,7 +6051,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " = 0) c->setOrganization((uint32)value); else if (action == "add_points") @@ -6052,7 +6061,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " changeOrganizationStatus(value); } - + //************************************************* //***************** buildings // /a webExecCommand debug 1 building!set_player_room!building_instance_ARCC_player_320 hmac 0 @@ -6062,16 +6071,16 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " addTriggerRequest(c->getEntityRowId(), liftId); } else if (action == "trigger_out") { CBuildingManager::getInstance()->removeTriggerRequest(c->getEntityRowId()); - + } else if (action == "add_guild_room" && command_args.size () == 3) { @@ -6125,27 +6134,27 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " addRoomAccessToPlayer(c->getId()); } - } - + } + //************************************************* //***************** Skill //************************************************* - + else if (command_args[0] == "skill") { if (command_args.size() < 4) return false; - + string action = command_args[1]; // check, best, add_xp - + if (action == "check") { SKILLS::ESkills skillEnum = SKILLS::toSkill( command_args[2] ); uint32 wantedValue; fromString(command_args[3], wantedValue); - + if (c->getSkillValue(skillEnum) < wantedValue) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_skill", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_skill"); return true; } } @@ -6154,10 +6163,10 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getBestChildSkillValue(skillEnum) < wantedValue) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_best_skill", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_best_skill"); return true; } } @@ -6168,22 +6177,22 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " addXpToSkill(xp, command_args[2]); } } - + //************************************************* //***************** Dead //************************************************* - + else if (command_args[0] == "check_state") { if (command_args.size() < 3) return false; - + string action = command_args[1]; // dead, alive, tag, flag - + if (action == "dead") { if (!c->isDead()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_dead", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_dead"); return true; } } @@ -6191,7 +6200,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " isDead()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_alive", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_alive"); return true; } } @@ -6199,7 +6208,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getPVPFlag()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_tag", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_tag"); return true; } } @@ -6207,29 +6216,29 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getPvPRecentActionFlag()) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_flag", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=not_flag"); return true; } } } - + //************************************************* //***************** Money //************************************************* - + else if (command_args[0] == "money") { if (command_args.size() < 3) return false; - + string action = command_args[1]; // check, give, spend - + if (action == "check") { uint64 wantedMoney; fromString(command_args[2], wantedMoney); if (c->getMoney() < wantedMoney) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_money", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_money"); return true; } } @@ -6254,24 +6263,24 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getGuildFromId(c->getGuildId()); if (guild == NULL) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_guild", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_guild"); return true; } - + string action = command_args[1]; // check, give, spend - + if (action == "check_money") { uint64 wantedMoney; fromString(command_args[2], wantedMoney); if (guild->getMoney() < wantedMoney) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_money", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_money"); return true; } } @@ -6303,11 +6312,11 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " wanted_grade) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_rank", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_rank"); return true; } } - + } //************************************************* @@ -6317,9 +6326,9 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " resetPVPTimers(); @@ -6337,10 +6346,10 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " PVP_CLAN::EndClans)) { @@ -6349,13 +6358,13 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getFactionPoint(clan) < value) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_faction_points", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_faction_points"); return true; } } @@ -6373,7 +6382,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " setFactionPoint(clan, 0, true); else c->setFactionPoint(clan, c->getFactionPoint(clan)-value, true); - } + } } //************************************************* @@ -6394,7 +6403,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getPvpPoint() < value) { if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_pvp_points", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=failed&desc=no_enough_pvp_points"); return true; } } @@ -6415,15 +6424,15 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " getHomeMainlandSessionId(), player)); destPlayer = dynamic_cast(CEntityBaseManager::getEntityBasePtr(entityBase->getId())); @@ -6480,7 +6489,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " (CEntityBaseManager::getEntityBasePtr(target)); } if (destPlayer) - destPlayer->sendUrl(app+" "+params, ""); + destPlayer->sendUrl(app+" "+params); } @@ -6488,10 +6497,10 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " removeMission(missionAlias, 0); c->removeMissionFromHistories(missionAlias); } + else if (action == "finish") + { + TAIAlias missionAlias = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName(command_args[2]); + c->removeMission(missionAlias, 0, true); + c->removeMissionFromHistories(missionAlias); + } else if (action == "add_compass" && command_args.size() == 4) { TVectorParamCheck params(1); @@ -6618,7 +6633,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " setCustomMissionParams(command_args[2], text); @@ -6648,7 +6663,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished"); } } else @@ -6658,7 +6673,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " validateWebCommandIndex(iindex); } if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished"); } } else @@ -6667,7 +6682,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", " validateWebCommandIndex(iindex); if (send_url) - c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished", getSalt()); + c->sendUrl(web_app_url+"&player_eid="+c->getId().toString()+"&event=finished"); } return true; @@ -8118,6 +8133,8 @@ NLMISC_COMMAND(eScript, "executes a script on an event npc group", " pos = arg.find("(eid:"); } + strFindReplace(arg, "#item:", ""); + strFindReplace(arg, "#rrp:", ""); msgout.serial(arg); } CWorldInstances::instance().msgToAIInstance2(instanceNumber, msgout); diff --git a/ryzom/server/src/entities_game_service/client_messages.cpp b/ryzom/server/src/entities_game_service/client_messages.cpp index 79e08107d..3124ef6ea 100644 --- a/ryzom/server/src/entities_game_service/client_messages.cpp +++ b/ryzom/server/src/entities_game_service/client_messages.cpp @@ -3710,7 +3710,7 @@ TUnifiedCallbackItem CbClientArray[]= { "CLIENT:MISSION:WAKE", cbClientMissionWake }, { "CLIENT:MISSION:GROUP_WAKE", cbClientMissionGroupWake }, - // { "CLIENT:EVENT:SET_ITEM_CUSTOM_TEXT", cbClientEventSetItemCustomText }, + // { "CLIENT:EVENT:SET_ITEM_CUSTOM_TEXT", cbClientEventSetItemCustomText }, // Moved to ITEM:WRITE { "CLIENT:TOTEM:BUILD", cbTotemBuild }, 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 6b2e8b7a5..95e6c3ba1 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 @@ -228,34 +228,30 @@ std::vector CPVPManager2::getCharacterChannels(CCharacter * user) NLMISC::splitString(user->getLangChannel(), " ", langChannels); for ( uint i = 0; i < langChannels.size(); i++ ) { - TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(langChannels[i]); - if (it != _ExtraFactionChannel.end()) + if (langChannels[i] != "rf") { - result.push_back((*it).second); + TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("usr_"+langChannels[i]); + if (it != _ExtraFactionChannel.end()) + { + result.push_back((*it).second); + } } } } - else + + TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("rf"); + if (it != _ExtraFactionChannel.end()) { - TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("en"); - if (it != _ExtraFactionChannel.end()) - { - result.push_back((*it).second); - } + result.push_back((*it).second); } -#endif -#ifdef RYZOM_FORGE PVP_CLAN::TPVPClan faction = user->getAllegiance().first; if( faction != PVP_CLAN::Neutral ) { - if (isFactionInWar(faction)) + TMAPFactionChannel::iterator it = _FactionChannel.find(faction); + if( it != _FactionChannel.end() ) { - TMAPFactionChannel::iterator it = _FactionChannel.find(faction); - if (it != _FactionChannel.end()) - { - result.push_back((*it).second); - } + result.push_back((*it).second); } } @@ -268,6 +264,25 @@ std::vector CPVPManager2::getCharacterChannels(CCharacter * user) result.push_back((*it).second); } } + + // Organizations + if (user->getOrganization() == 5) // marauder + { + TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("marauders"); + if (it != _ExtraFactionChannel.end()) + { + result.push_back((*it).second); + } + } + + if (user->getOrganization() == 7) // ranger + { + TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("ranger"); + if (it != _ExtraFactionChannel.end()) + { + result.push_back((*it).second); + } + } #endif /* diff --git a/ryzom/server/src/entities_game_service/shop_type/named_items.cpp b/ryzom/server/src/entities_game_service/shop_type/named_items.cpp index ba29e78ad..f4734a90b 100644 --- a/ryzom/server/src/entities_game_service/shop_type/named_items.cpp +++ b/ryzom/server/src/entities_game_service/shop_type/named_items.cpp @@ -124,6 +124,10 @@ CGameItemPtr CNamedItems::createNamedItem(const std::string & name, uint32 quant if( itemSrc == NULL ) return NULL; CGameItemPtr item = itemSrc->getItemCopy(); + + quantity = min(quantity, item->getMaxStackSize()); + item->setStackSize(quantity); + return item; } diff --git a/ryzom/server/src/entities_game_service/stdpch.h b/ryzom/server/src/entities_game_service/stdpch.h index a40fb9b59..d4c626261 100644 --- a/ryzom/server/src/entities_game_service/stdpch.h +++ b/ryzom/server/src/entities_game_service/stdpch.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,6 @@ #include #include #include -#include // NeL georges #include "nel/georges/load_form.h" From 678d888b5cfbb1d6785ff3a23c32d19a8fd60ccb Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 24 Jun 2021 15:05:40 +0800 Subject: [PATCH 2/3] Merge stuff from atys branch --- .../player_manager/character.cpp | 505 +++++++++++++++--- 1 file changed, 426 insertions(+), 79 deletions(-) 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 6da0a1b9d..bc483dc7a 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -429,6 +429,9 @@ CCharacter::CCharacter(): CEntityBase(false), #ifdef RYZOM_FORGE _PvpPoint = 0; + _GuildPoints = 0; + _TodayGuildPoints = 0; + _NextTodayGuildPointsReset = 0; #endif _PVPFlagLastTimeChange = 0; @@ -441,6 +444,8 @@ CCharacter::CCharacter(): CEntityBase(false), _Organization = 0; _OrganizationStatus = 0; _OrganizationPoints = 0; + // refill pact automatically + _doPact = false; #endif // do not start berserk @@ -1272,6 +1277,24 @@ uint32 CCharacter::tickUpdate() // _PropertyDatabase.setProp( _DataIndexReminder->TARGET.PLAYER_LEVEL, skillBaseValue ); CBankAccessor_PLR::getTARGET().getBARS().setPLAYER_LEVEL(_PropertyDatabase, checkedCast(skillBaseValue) ); } +#ifdef RYZOM_FORGE + else + { + CCreature *creature = dynamic_cast(target); + if (creature) + { + if (creature->getLockLoot() != CTEAM::InvalidTeamId) + { + if (creature->getLockLoot() == _TeamId) + CBankAccessor_PLR::getTARGET().getBARS().setPLAYER_LEVEL(_PropertyDatabase, 2); + else + CBankAccessor_PLR::getTARGET().getBARS().setPLAYER_LEVEL(_PropertyDatabase, 1); + } + else + CBankAccessor_PLR::getTARGET().getBARS().setPLAYER_LEVEL(_PropertyDatabase, 0); + } + } +#endif if( !checkCharacterStillValide(" Character corrupted : after update target HP/STA/SAP !!!") ) return (uint32)-1; @@ -1386,7 +1409,8 @@ uint32 CCharacter::tickUpdate() if ( _LastTickNpcControlUpdated + TickFrequencyNpcControlUpdate.get() <= CTickEventHandler::getGameCycle() ) { // _LastTickNpcControlUpdated = CTickEventHandler::getGameCycle(); is done in setNpcControl - { // Update npc control + { + // Update npc control setNpcControl(_NpcControlEid); } } @@ -1544,10 +1568,10 @@ uint32 CCharacter::tickUpdate() } uint32 nextUpdate = 16; - if( oldHp != _PhysScores._PhysicalScores[ SCORES::hit_points ].Current || - oldSta != _PhysScores._PhysicalScores[ SCORES::stamina].Current || - oldSap != _PhysScores._PhysicalScores[ SCORES::sap ].Current || - oldFocus != _PhysScores._PhysicalScores[ SCORES::focus].Current ) + if (oldHp != _PhysScores._PhysicalScores[SCORES::hit_points].Current + || oldSta != _PhysScores._PhysicalScores[SCORES::stamina].Current + || oldSap != _PhysScores._PhysicalScores[SCORES::sap].Current + || oldFocus != _PhysScores._PhysicalScores[SCORES::focus].Current) { nextUpdate = 8; } @@ -3741,17 +3765,10 @@ void CCharacter::setTargetBotchatProgramm( CEntityBase * target, const CEntityId // send the web page url SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal); - string url = c->getWebPage(); - #ifdef RYZOM_FORGE - // add ? or & with - if ( url.find('?') == string::npos ) - url += NLMISC::toString("?urlidx=%d", getUrlIndex()); - else - url += NLMISC::toString("&urlidx=%d", getUrlIndex()); - - setUrlIndex(getUrlIndex()+1); -#endif + params[0].Literal = c->getWebPage(); +#else + string url = c->getWebPage(); url += "&player_eid="+getId().toString(); @@ -3763,7 +3780,8 @@ void CCharacter::setTargetBotchatProgramm( CEntityBase * target, const CEntityId nlinfo(url.c_str()); string control = "&hmac="+NLMISC::getHMacSHA1((uint8*)&url[0], (uint32)url.size(), (uint8*)&defaultSalt[0], (uint32)defaultSalt.size()).toString(); - params[0].Literal= url+control; + params[0].Literal = url + control; +#endif text = STRING_MANAGER::sendStringToClient(_EntityRowId, "LITERAL", params ); // _PropertyDatabase.setProp( "TARGET:CONTEXT_MENU:WEB_PAGE_URL" , text ); @@ -6891,7 +6909,43 @@ void CCharacter::sendAnimalCommand( uint8 petIndexCode, uint8 command ) } #ifdef RYZOM_FORGE_PET_NAME -void CCharacter::setAnimalName( uint8 petIndex, ucstring customName ) +void CCharacter::setAnimalSheetId(uint8 petIndex, CSheetId sheetId) +{ + if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) + { + nlwarning(" Incorect animal index '%d'.", petIndex); + return; + } + + CPetAnimal &animal = _PlayerPets[petIndex]; + animal.setSheetId(sheetId); +} + +void CCharacter::setAnimalSize(uint8 petIndex, uint8 size) +{ + if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) + { + nlwarning(" Incorect animal index '%d'.", petIndex); + return; + } + + CPetAnimal &animal = _PlayerPets[petIndex]; + animal.setSize(size); +} + +void CCharacter::setAnimalPosition(uint8 petIndex, sint32 x, sint32 y) +{ + if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) + { + nlwarning(" Incorect animal index '%d'.", petIndex); + return; + } + + CPetAnimal &animal = _PlayerPets[petIndex]; + animal.setPosition(x, y); +} + +void CCharacter::setAnimalName(uint8 petIndex, ucstring customName) { if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) { @@ -6903,14 +6957,37 @@ void CCharacter::setAnimalName( uint8 petIndex, ucstring customName ) animal.setCustomName(customName); sendPetCustomNameToClient(petIndex); - if ( ! customName.empty()) + TDataSetRow row = animal.SpawnedPets; + NLNET::CMessage msgout("CHARACTER_NAME"); + msgout.serial(row); + msgout.serial(customName); + sendMessageViaMirror("IOS", msgout); +} + +void CCharacter::setAnimalTitle(uint8 petIndex, string title) +{ + if (petIndex < 0 || petIndex >= MAX_INVENTORY_ANIMAL) + { + nlwarning(" Incorect animal index '%d'.", petIndex); + return; + } + + CPetAnimal &animal = _PlayerPets[petIndex]; + string name = animal.getCustomName().toUtf8(); + if (name.find('$') != string::npos) { - TDataSetRow row = animal.SpawnedPets; - NLNET::CMessage msgout("CHARACTER_NAME"); - msgout.serial(row); - msgout.serial(customName); - sendMessageViaMirror("IOS", msgout); + 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); } //----------------------------------------------------------------------------- @@ -6924,6 +7001,7 @@ void CCharacter::sendPetCustomNameToClient(uint8 petIndex) uint32 userId = PlayerManager.getPlayerId(_Id); textId = STRING_MANAGER::sendStringToUser(userId, "LITERAL", params); } + CBankAccessor_PLR::getPACK_ANIMAL().getBEAST(petIndex).setNAME(_PropertyDatabase, textId); } #endif @@ -10257,7 +10335,8 @@ void CCharacter::spendMoney( const uint64 & price ) setMoney(0); else setMoney(_Money - price); -// _PropertyDatabase.setProp( "INVENTORY:MONEY", _Money ); + + // _PropertyDatabase.setProp( "INVENTORY:MONEY", _Money ); } // spend // @@ -10390,7 +10469,20 @@ void CCharacter::setNewTitle(const string &title) { } //----------------------------------------------------------------------------- -void CCharacter::setTagPvPA(const string &tag) { +void CCharacter::setTagA(const string &tag) +{ + _TagA = tag; +} + +//----------------------------------------------------------------------------- +void CCharacter::setTagB(const string &tag) +{ + _TagB = tag; +} + +//----------------------------------------------------------------------------- +void CCharacter::setTagPvPA(const string &tag) +{ _TagPvPA = tag; } @@ -10400,13 +10492,170 @@ void CCharacter::setTagPvPB(const string &tag) { } //----------------------------------------------------------------------------- -void CCharacter::setTagA(const string &tag) { - _TagA = tag; +void CCharacter::setDontTranslate(const string &langs) +{ + _DontTranslate = langs; } //----------------------------------------------------------------------------- -void CCharacter::setTagB(const string &tag) { - _TagB = tag; +CSBrickParamJewelAttrs CCharacter::getJewelAttrs(const string &attribute, SLOT_EQUIPMENT::TSlotEquipment slot, CSheetId &usedSheet) +{ + + string contName; + string regionName; + const CRegion *region = NULL; + const CContinent *cont = NULL; + CZoneManager::getInstance().getRegion(getState().X, getState().Y, ®ion, &cont); + if (region) + regionName = region->getName(); + if (cont) + contName = cont->getName(); + + CSBrickParamJewelAttrs returnSBrickParam; + CSBrickParamJewelAttrs *boostSBrickParam = NULL; + + CInventoryPtr inv = getInventory(INVENTORIES::equipment); + if (inv) + { + if (slot == SLOT_EQUIPMENT::UNDEFINED) + { + for (uint8 s = 0; s < SLOT_EQUIPMENT::NB_SLOT_EQUIPMENT; ++s) + { + const CGameItemPtr item = inv->getItem(s); + if (item != NULL) + { + vector enchant = item->getEnchantment(); + for (uint i = 0; i < enchant.size(); i++) + { + const CStaticBrick *brick = CSheets::getSBrickForm(enchant[i]); + + if (brick && brick->Family == BRICK_FAMILIES::BSGMCB) + { + if (brick->Params.size() > 0) + { + const TBrickParam::IId *param = brick->Params[0]; + boostSBrickParam = (CSBrickParamJewelAttrs *)param; + } + } + else if (brick && brick->Family == BRICK_FAMILIES::BSGMC) + { + if (brick->Params.size() > 0) + { + const TBrickParam::IId *param = brick->Params[0]; + CSBrickParamJewelAttrs *sbrickParam = (CSBrickParamJewelAttrs *)param; + + if (param->id() == TBrickParam::JEWEL_ATTRS && sbrickParam->Attribute == attribute) + { + bool valid = true; + // Check required fame (if no required faction, check are ok) + if (!checkRequiredFame(sbrickParam->RequiredFaction, sbrickParam->RequiredFame)) + valid = false; + // Require a faction/nation/org only for fame up to 30 + else if (sbrickParam->RequiredFame >= 30 && !checkRequiredFaction(sbrickParam->RequiredFaction)) + valid = false; + + if (!sbrickParam->RequiredZones.empty()) + { + bool zoneValid = false; + vector zones; + NLMISC::splitString(sbrickParam->RequiredZones, ",", zones); + for (uint z = 0; z < zones.size(); z++) + { + if (zones[z] == contName || zones[z] == regionName) + zoneValid = true; + } + + if (!zoneValid) + valid = false; + } + + if (valid) + { + usedSheet = enchant[i]; + returnSBrickParam.copy(*sbrickParam); + } + } + } + } + } + } + } + } + else + { + const CGameItemPtr item = inv->getItem(slot); + if (item != NULL) + { + vector enchant = item->getEnchantment(); + for (uint i = 0; i < enchant.size(); i++) + { + + const CStaticBrick *brick = CSheets::getSBrickForm(enchant[i]); + + if (brick && brick->Family == BRICK_FAMILIES::BSGMCB) + { + if (brick->Params.size() > 0) + { + const TBrickParam::IId *param = brick->Params[0]; + boostSBrickParam = (CSBrickParamJewelAttrs *)param; + } + } + else if (brick && brick->Family == BRICK_FAMILIES::BSGMC) + { + if (brick->Params.size() > 0) + { + const TBrickParam::IId *param = brick->Params[0]; + CSBrickParamJewelAttrs *sbrickParam = (CSBrickParamJewelAttrs *)param; + + if (param->id() == TBrickParam::JEWEL_ATTRS && sbrickParam->Attribute == attribute) + { + bool valid = true; + // Check required fame (if no required faction, check are ok) + if (!checkRequiredFame(sbrickParam->RequiredFaction, sbrickParam->RequiredFame)) + { + valid = false; + } + else if (sbrickParam->RequiredFame >= 30 && !checkRequiredFaction(sbrickParam->RequiredFaction)) + { + valid = false; + } + + if (!sbrickParam->RequiredZones.empty()) + { + bool zoneValid = false; + vector zones; + NLMISC::splitString(sbrickParam->RequiredZones, ",", zones); + for (uint z = 0; z < zones.size(); z++) + { + if (zones[z] == contName || zones[z] == regionName) + { + zoneValid = true; + } + } + + if (!zoneValid) + { + valid = false; + } + } + + if (valid) + { + usedSheet = enchant[i]; + returnSBrickParam.copy(*sbrickParam); + } + } + } + } + } + } + } + } + + if (boostSBrickParam) + returnSBrickParam.Modifier *= boostSBrickParam->Modifier; + + return returnSBrickParam; } //----------------------------------------------------------------------------- @@ -10414,12 +10663,28 @@ void CCharacter::setOrganization(uint32 org) { if (org == _Organization) return; + _Organization = org; _OrganizationStatus = 0; _OrganizationPoints = 0; - CBankAccessor_PLR::getUSER().getRRPS_LEVELS(1).setVALUE(_PropertyDatabase, _Organization ); - CBankAccessor_PLR::getUSER().getRRPS_LEVELS(2).setVALUE(_PropertyDatabase, _OrganizationStatus ); - CBankAccessor_PLR::getUSER().getRRPS_LEVELS(3).setVALUE(_PropertyDatabase, _OrganizationPoints ); + CBankAccessor_PLR::getUSER().getRRPS_LEVELS(1).setVALUE(_PropertyDatabase, _Organization); + CBankAccessor_PLR::getUSER().getRRPS_LEVELS(2).setVALUE(_PropertyDatabase, _OrganizationStatus); + CBankAccessor_PLR::getUSER().getRRPS_LEVELS(3).setVALUE(_PropertyDatabase, _OrganizationPoints); + + if (org != 0) + { + setDeclaredCult(PVP_CLAN::Neutral); + setDeclaredCiv(PVP_CLAN::Neutral); + } + + CPVPManager2::getInstance()->updateFactionChannel(this); + updateJewelsTags(false); + + // Make sure fame values are properly capped. + CFameManager::getInstance().enforceFameCaps(getId(), org, getAllegiance()); + + // set tribe fame threshold and clamp fame if necessary + CFameManager::getInstance().setAndEnforceTribeFameCap(getId(), org, getAllegiance()); } //----------------------------------------------------------------------------- @@ -10436,7 +10701,8 @@ void CCharacter::changeOrganizationStatus(sint32 status) _OrganizationStatus = 0; else _OrganizationStatus += status; - CBankAccessor_PLR::getUSER().getRRPS_LEVELS(2).setVALUE(_PropertyDatabase, _OrganizationStatus ); + + CBankAccessor_PLR::getUSER().getRRPS_LEVELS(2).setVALUE(_PropertyDatabase, _OrganizationStatus); } //----------------------------------------------------------------------------- @@ -10446,7 +10712,8 @@ void CCharacter::changeOrganizationPoints(sint32 points) _OrganizationPoints = 0; else _OrganizationPoints += points; - CBankAccessor_PLR::getUSER().getRRPS_LEVELS(3).setVALUE(_PropertyDatabase, _OrganizationPoints ); + + CBankAccessor_PLR::getUSER().getRRPS_LEVELS(3).setVALUE(_PropertyDatabase, _OrganizationPoints); } @@ -12077,8 +12344,8 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis bool processed = false; bool firstEvent = true; - CGuild *guild = NULL; - while ( !eventList.empty() ) + CGuild *guild = CGuildManager::getInstance()->getGuildFromId(_GuildId); + while (!eventList.empty()) { bool eventProcessed = false; CMissionEvent & event = *(*eventList.begin()); @@ -12101,7 +12368,6 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis else { // We find the guild and each guild members and we instanciate the mission for them - guild = CGuildManager::getInstance()->getGuildFromId(_GuildId); if (guild) { for ( std::map::iterator it = guild->getMembersBegin(); @@ -13322,23 +13588,16 @@ void CCharacter::setPlaces(const std::vector & places) //----------------------------------------------- bool CCharacter::isSpawnValid(bool inVillage, bool inOutpost, bool inStable, bool inAtys) { - if (inVillage) - nlinfo("inVillage"); - if (inOutpost) - nlinfo("inOutpost"); - if (inStable) - nlinfo("inStable"); - if (inAtys) - nlinfo("inAtys"); - const uint size = (uint)_Places.size(); - for ( uint i = 0; i < size; i++ ) + + for (uint i = 0; i < size; i++) { - CPlace * p = CZoneManager::getInstance().getPlaceFromId( _Places[i] ); + CPlace *p = CZoneManager::getInstance().getPlaceFromId(_Places[i]); + if (p) { PLACE_TYPE::TPlaceType place_type = p->getPlaceType(); - nlinfo("Place type = %s", PLACE_TYPE::toString(p->getPlaceType()).c_str()); + if (!inVillage && (place_type == PLACE_TYPE::Village || place_type == PLACE_TYPE::Capital)) { CCharacter::sendDynamicSystemMessage( _EntityRowId, "NO_ACTION_IN_VILLAGE" ); @@ -13346,6 +13605,7 @@ bool CCharacter::isSpawnValid(bool inVillage, bool inOutpost, bool inStable, boo } TAIAlias outpostAlias = getOutpostAlias(); + if (!inOutpost && outpostAlias != 0) { CSmartPtr outpost = COutpostManager::getInstance().getOutpostFromAlias( outpostAlias ); @@ -13921,27 +14181,45 @@ void CCharacter::sendDynamicMessage(const string &phrase, const string &message) PHRASE_UTILITIES::sendDynamicSystemMessage( _EntityRowId, phrase, messageParams ); } - -void CCharacter::sendUrl(const string &url, const string &salt) +void CCharacter::sendUrl(const string &url) { string control; - if (!salt.empty()) - { - control = "&hmac="+NLMISC::getHMacSHA1((uint8*)&url[0], (uint32)url.size(), (uint8*)&salt[0], (uint32)salt.size()).toString(); + string salt = toString(getLastConnectedDate()) + ArkSalt.get(); + string playerPos = getPositionInfos(); + while (strFindReplace(playerPos, " ", "%20")) + ; + string targetInfos = getTargetInfos(); + string serverInfos = getServerInfos(getState().X / 1000., getState().Y / 1000.); + while (strFindReplace(targetInfos, " ", "%20")) + ; + string final_url; + + if (url.find("$(") != string::npos) + { + final_url = url; + strFindReplace(final_url, "$(pos)", playerPos); + strFindReplace(final_url, "$(target)", targetInfos); + strFindReplace(final_url, "$(server)", serverInfos); + strFindReplace(final_url, "$(hands)", getEquipementInfos(INVENTORIES::handling)); + strFindReplace(final_url, "$(equiped)", getEquipementInfos(INVENTORIES::equipment)); + final_url += toString("&urlidx=%d", getUrlIndex()); } else { - string defaultSalt = toString(getLastConnectedDate()); - control = "&hmac="+NLMISC::getHMacSHA1((uint8*)&url[0], (uint32)url.size(), (uint8*)&defaultSalt[0], (uint32)defaultSalt.size()).toString(); + final_url = url + toString("&urlidx=%d", getUrlIndex()) + "&player_pos=" + playerPos + "&target_infos=" + targetInfos + "&server_infos=" + serverInfos; } - nlinfo(url.c_str()); - - uint32 userId = PlayerManager.getPlayerId(getId()); + while (strFindReplace(final_url, "#", "%23")) + ; + while (strFindReplace(final_url, "$", "%24")) + ; - SM_STATIC_PARAMS_1(textParams, STRING_MANAGER::literal); - textParams[0].Literal= "WEB : "+url+control; + control = "&hmac=" + getHMacSHA1((uint8 *)&final_url[0], (uint32)final_url.size(), (uint8 *)&salt[0], (uint32)salt.size()).toString(); + uint32 userId = PlayerManager.getPlayerId(getId()); + SM_STATIC_PARAMS_1(textParams, STRING_MANAGER::literal); + textParams[0].Literal = "WEB : " + final_url + control; + nlinfo("URL: %s", final_url.c_str()); TVectorParamCheck titleParams; uint32 titleId = STRING_MANAGER::sendStringToUser(userId, "web_transactions", titleParams); uint32 textId = STRING_MANAGER::sendStringToClient(_EntityRowId, "LITERAL", textParams ); @@ -13950,7 +14228,7 @@ void CCharacter::sendUrl(const string &url, const string &salt) void CCharacter::validateDynamicMissionStep(const string &url) { - sendUrl(url+"&player_eid="+getId().toString()+"&event=mission_step_finished", getSalt()); + sendUrl(url + "&player_eid=" + getId().toString() + "&event=mission_step_finished"); } /// set custom mission param @@ -13975,11 +14253,6 @@ void CCharacter::addCustomMissionParam(const string &missionName, const string & vector CCharacter::getCustomMissionParams(const string &missionName) { vector params; - if (_CustomMissionsParams.empty()) - { - return params; - } - if (!_CustomMissionsParams.empty() && _CustomMissionsParams.find(missionName) != _CustomMissionsParams.end()) { if (!_CustomMissionsParams[missionName].empty()) @@ -14003,9 +14276,53 @@ string CCharacter::getCustomMissionText(const string &missionName) return ""; } -#endif +/// add Ark position check +void CCharacter::addPositionCheck(sint32 x, sint32 y, uint32 r, const std::string &name, bool use_compass) +{ + if (x == 0 && y == 0) + { + for (vector::iterator it = _CheckPos.begin(); it != _CheckPos.end();) + { + if ((*it).Name == name) + it = _CheckPos.erase(it); + else + ++it; + } -#ifdef RYZOM_FORGE + return; + } + + SCheckPosCoordinate poscheck; + poscheck.X = x; + poscheck.Y = y; + poscheck.Radius = r; + poscheck.Name = name; + _CheckPos.push_back(poscheck); +} + +/// get Ark position check +void CCharacter::getPositionCheck(const string &name, sint32 &x, sint32 &y, string &textName) +{ + x = 0; + y = 0; + textName = "EMPTY"; + + for (vector::iterator it = _CheckPos.begin(); it != _CheckPos.end();) + { + if ((*it).Name == name) + { + textName = getCustomMissionText((*it).Name + "_COMPASS_TEXT"); + + if (!textName.empty()) + { + x = (*it).X; + y = (*it).Y; + } + } + + ++it; + } +} // !!! Deprecated !!! void CCharacter::addWebCommandCheck(const string &url, const string &data, const string &salt) { @@ -14028,7 +14345,7 @@ void CCharacter::addWebCommandCheck(const string &url, const string &data, const item->setCustomText(ucstring(url)); vector infos; NLMISC::splitString(url, "\n", infos); - sendUrl(infos[0]+"&player_eid="+getId().toString()+"&event=command_added", salt); + sendUrl(infos[0] + "&player_eid=" + getId().toString() + "&event=command_added"); } else { @@ -14039,8 +14356,8 @@ void CCharacter::addWebCommandCheck(const string &url, const string &data, const { finalData += ","+randomString+infos[i]; } - item->setCustomText(ucstring(url+"\n"+finalData)); - sendUrl(url+"&player_eid="+getId().toString()+"&event=command_added&transaction_id="+randomString, salt); + item->setCustomText(ucstring(url + "\n" + finalData)); + sendUrl(url + "&player_eid=" + getId().toString() + "&event=command_added&transaction_id=" + randomString); } } } @@ -14062,7 +14379,7 @@ void CCharacter::addWebCommandCheck(const string &url, const string &data, const NLMISC::splitString(cText, "\n", infos); vector datas; NLMISC::splitString(infos[1], ",", datas); - sendUrl(infos[0]+"&player_eid="+getId().toString()+"&event=command_added&transaction_id="+datas[0].substr(0, 8), salt); + sendUrl(infos[0] + "&player_eid=" + getId().toString() + "&event=command_added&transaction_id=" + datas[0].substr(0, 8)); } } } @@ -15294,6 +15611,26 @@ const NLMISC::CEntityId& CCharacter::getInRoomOfPlayer() return _inRoomOfPlayer; } +void CCharacter::setPowoCell(sint32 cell) +{ + _PowoCell = cell; +} + +void CCharacter::setPowoScope(const string &scope) +{ + _PowoScope = scope; +} + +sint32 CCharacter::getPowoCell() const +{ + return _PowoCell; +} + +const string &CCharacter::getPowoScope() const +{ + return _PowoScope; +} + //-------------------------------------------------------------- // CCharacter::havePlayerRoomAccess //-------------------------------------------------------------- @@ -15649,16 +15986,26 @@ void CCharacter::removeRoomAccesToPlayer(const NLMISC::CEntityId &id, bool kick) if (kick & (target->getInRoomOfPlayer().getShortId() == getId().getShortId())) { target->setInRoomOfPlayer(CEntityId::Unknown); + if (!TheDataset.isAccessible(getEntityRowId())) return; - const CTpSpawnZone * zone = CZoneManager::getInstance().getTpSpawnZone(target->getBuildingExitZone()); - if (zone) + CVector buildingExitPos = target->getBuildingExitPos(); + if (buildingExitPos.x != 0 && buildingExitPos.y != 0) { - sint32 x,y,z; - float heading; - zone->getRandomPoint(x,y,z,heading); - target->tpWanted(x,y,z,true,heading); + target->tpWanted(buildingExitPos.x, buildingExitPos.y, 0); + target->setBuildingExitPos(0, 0, 0); + } + else + { + const CTpSpawnZone *zone = CZoneManager::getInstance().getTpSpawnZone(target->getBuildingExitZone()); + if (zone) + { + sint32 x, y, z; + float heading; + zone->getRandomPoint(x, y, z, heading); + target->tpWanted(x, y, z, true, heading); + } } } } From 2889e81d63f3f5400cfe87d59ad6d1517ec30323 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 24 Jun 2021 16:01:22 +0800 Subject: [PATCH 3/3] Typo --- .../src/entities_game_service/player_manager/character.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bc483dc7a..580fcab25 100644 --- a/ryzom/server/src/entities_game_service/player_manager/character.cpp +++ b/ryzom/server/src/entities_game_service/player_manager/character.cpp @@ -2981,7 +2981,7 @@ void CCharacter::postLoadTreatment() if ( animal.Satiety == SatietyNotInit ) { const CStaticItem* ticketPetForm = CSheets::getForm( animal.TicketPetSheetId ); - animal.MaxSatiety = ticketPetForm ? ticketPetForm->PetHungerCount : 0;\ + animal.MaxSatiety = ticketPetForm ? ticketPetForm->PetHungerCount : 0; animal.Satiety = animal.MaxSatiety; } }