// **************************************************************************** ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) { ucstring formatedResult; // Apply the format for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();) { if (*it == '$') { ++it; if (it == inputString.end()) break; switch(*it) { case 't': // add text ID formatedResult += paramString; break; case 'P': case 'p': // add player name if (ClientCfg.Local) { formatedResult += ucstring("player"); } else { if(UserEntity) { ucstring name = UserEntity->getEntityName(); if (*it == 'P') setCase(name, CaseUpper); formatedResult += name; } } break; // case 's': case 'b': // add bot name { ucstring botName; bool womanTitle = false; if (ClientCfg.Local) { botName = ucstring("NPC"); } else { CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT; if(UserEntity) trader = UserEntity->trader(); if (trader != CLFECOMMON::INVALID_SLOT) { CEntityCL *entity = EntitiesMngr.entity(trader); if (entity != NULL) { uint32 nDBid = entity->getNameId(); if (nDBid != 0) { CStringManagerClient *pSMC = CStringManagerClient::instance(); pSMC->getString(nDBid, botName); } else { botName = entity->getDisplayName(); } CCharacterCL *pChar = dynamic_cast<CCharacterCL*>(entity); if (pChar != NULL) womanTitle = pChar->getGender() == GSGENDER::female; } } } // get the title translated ucstring sTitleTranslated = botName; CStringPostProcessRemoveName spprn; spprn.Woman = womanTitle; spprn.cbIDStringReceived(sTitleTranslated); botName = CEntityCL::removeTitleAndShardFromName(botName); // short name (with no title such as 'guard', 'merchant' ...) if (*it == 's') { // But if there is no name, display only the title if (botName.empty()) botName = sTitleTranslated; } else { // Else we want the title ! if (!botName.empty()) botName += " "; botName += sTitleTranslated; } formatedResult += botName; } break; default: formatedResult += (ucchar) '$'; break; } ++it; } else { formatedResult += (ucchar) *it; ++it; } } return formatedResult; }
void addWebIGParams (string &url, bool trustedDomain) { if(!UserEntity || !NetMngr.getLoginCookie().isValid()) return; uint32 cid = NetMngr.getLoginCookie().getUserId() * 16 + PlayerSelectedSlot; url += ((url.find('?') != string::npos) ? "&" : "?") + string("shardid=") + toString(CharacterHomeSessionId) + string("&name=") + UserEntity->getLoginName().toUtf8() + string("&lang=") + CI18N::getCurrentLanguageCode() + string("&datasetid=") + toString(UserEntity->dataSetId()) + string("&ig=1"); if (trustedDomain) { url += string("&cid=") + toString(cid) + string("&authkey=") + getWebAuthKey(); if (url.find('$') != string::npos) { strFindReplace(url, "$gender$", GSGENDER::toString(UserEntity->getGender())); strFindReplace(url, "$displayName$", UserEntity->getDisplayName().toString()); strFindReplace(url, "$posx$", toString(UserEntity->pos().x)); strFindReplace(url, "$posy$", toString(UserEntity->pos().y)); strFindReplace(url, "$posz$", toString(UserEntity->pos().z)); strFindReplace(url, "$post$", toString(atan2(UserEntity->front().y, UserEntity->front().x))); // Target fields const char *dbPath = "UI:VARIABLES:TARGET:SLOT"; CInterfaceManager *im = CInterfaceManager::getInstance(); CCDBNodeLeaf *node = im->getDbProp(dbPath, false); if (node && (uint8)node->getValue32() != (uint8) CLFECOMMON::INVALID_SLOT) { CEntityCL *target = EntitiesMngr.entity((uint) node->getValue32()); if (target) { strFindReplace(url, "$tdatasetid$", toString(target->dataSetId())); strFindReplace(url, "$tdisplayName$", target->getDisplayName().toString()); strFindReplace(url, "$tposx$", toString(target->pos().x)); strFindReplace(url, "$tposy$", toString(target->pos().y)); strFindReplace(url, "$tposz$", toString(target->pos().z)); strFindReplace(url, "$tpost$", toString(atan2(target->front().y, target->front().x))); strFindReplace(url, "$tsheet$", target->sheetId().toString()); string type; if (target->isFauna()) type = "fauna"; else if (target->isNPC()) type = "npc"; else if (target->isPlayer()) type = "player"; else if (target->isUser()) type = "user"; strFindReplace(url, "$ttype$", target->sheetId().toString()); } else { strFindReplace(url, "$tdatasetid$", ""); strFindReplace(url, "$tdisplayName$", ""); strFindReplace(url, "$tposx$", ""); strFindReplace(url, "$tposy$", ""); strFindReplace(url, "$tposz$", ""); strFindReplace(url, "$tpost$", ""); strFindReplace(url, "$tsheet$", ""); strFindReplace(url, "$ttype$", ""); } } } } }