本文整理汇总了C++中GetMainPartOfName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMainPartOfName函数的具体用法?C++ GetMainPartOfName怎么用?C++ GetMainPartOfName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetMainPartOfName函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: data
void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
{
uint64 guid;
recv_data >> guid;
// not accept declined names for unsupported languages
std::string name;
if(!objmgr.GetPlayerNameByGUID(guid, name))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
std::wstring wname;
if(!Utf8toWStr(name, wname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
if(!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
std::string name2;
DeclinedName declinedname;
recv_data >> name2;
if(name2 != name) // character have different name
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
recv_data >> declinedname.name[i];
if(!normalizePlayerName(declinedname.name[i]))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
}
if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')",
GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
CharacterDatabase.CommitTransaction();
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(0); // OK
data << uint64(guid);
SendPacket(&data);
}
开发者ID:Golgotha29,项目名称:mangos,代码行数:86,代码来源:CharacterHandler.cpp
示例2: CHECK_PACKET_SIZE
void WorldSession::HandlePetRename( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+1);
sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME\n" );
uint64 petguid;
uint8 isdeclined;
std::string name;
DeclinedName declinedname;
recv_data >> petguid;
recv_data >> name;
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
recv_data >> isdeclined;
Pet* pet = ObjectAccessor::GetPet(petguid);
// check it!
if( !pet || !pet->isPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
pet->GetByteValue(UNIT_FIELD_BYTES_2, 2) != UNIT_RENAME_ALLOWED ||
pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo() )
return;
if(!ObjectMgr::IsValidPetName(name))
{
SendPetNameInvalid(PET_NAME_INVALID, name, NULL);
return;
}
if(objmgr.IsReservedName(name))
{
SendPetNameInvalid(PET_NAME_RESERVED, name, NULL);
return;
}
pet->SetName(name);
Unit *owner = pet->GetOwner();
if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
pet->SetByteValue(UNIT_FIELD_BYTES_2, 2, UNIT_RENAME_NOT_ALLOWED);
if(isdeclined)
{
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
recv_data >> declinedname.name[i];
}
std::wstring wname;
Utf8toWStr(name, wname);
if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
{
SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname);
return;
}
}
CharacterDatabase.BeginTransaction();
if(isdeclined)
{
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
}
CharacterDatabase.escape_string(name);
CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.CommitTransaction();
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
}
开发者ID:de-dima,项目名称:243,代码行数:77,代码来源:PetHandler.cpp
示例3: DETAIL_LOG
void WorldSession::HandlePetRename( WorldPacket & recv_data )
{
DETAIL_LOG( "HandlePetRename. CMSG_PET_RENAME" );
uint64 petguid;
uint8 isdeclined;
std::string name;
DeclinedName declinedname;
recv_data >> petguid;
recv_data >> name;
recv_data >> isdeclined;
Pet* pet = _player->GetMap()->GetPet(petguid);
// check it!
if( !pet || pet->getPetType() != HUNTER_PET ||
!pet->HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ||
pet->GetOwnerGuid() != _player->GetObjectGuid() || !pet->GetCharmInfo() )
return;
PetNameInvalidReason res = ObjectMgr::CheckPetName(name);
if(res != PET_NAME_SUCCESS)
{
SendPetNameInvalid(res, name, NULL);
return;
}
if(sObjectMgr.IsReservedName(name))
{
SendPetNameInvalid(PET_NAME_RESERVED, name, NULL);
return;
}
pet->SetName(name);
if(_player->GetGroup())
_player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_NAME);
pet->RemoveByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED);
if(isdeclined)
{
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
recv_data >> declinedname.name[i];
}
std::wstring wname;
Utf8toWStr(name, wname);
if(!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname,0),declinedname))
{
SendPetNameInvalid(PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME, name, &declinedname);
return;
}
}
CharacterDatabase.BeginTransaction();
if(isdeclined)
{
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
CharacterDatabase.escape_string(declinedname.name[i]);
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
}
CharacterDatabase.escape_string(name);
CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
CharacterDatabase.CommitTransaction();
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL)));
}
开发者ID:Wisznu,项目名称:mangos,代码行数:73,代码来源:PetHandler.cpp
示例4: CHECK_PACKET_SIZE
void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data)
{
uint64 guid;
CHECK_PACKET_SIZE(recv_data, 8);
recv_data >> guid;
// not accept declined names for unsupported languages
std::string name;
if (!sObjectMgr.GetPlayerNameByGUID(guid, name))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
std::wstring wname;
if (!Utf8toWStr(name, wname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
std::string name2;
DeclinedName declinedname;
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
recv_data >> name2;
if (name2 != name) // character have different name
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
{
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
recv_data >> declinedname.name[i];
if (!normalizePlayerName(declinedname.name[i]))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
}
if (!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname))
{
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(1);
data << uint64(guid);
SendPacket(&data);
return;
}
static SqlStatementID deleteDeclinedName;
static SqlStatementID insertDeclinedName;
RealmDataDatabase.BeginTransaction();
SqlStatement stmt = RealmDataDatabase.CreateStatement(deleteDeclinedName, "DELETE FROM character_declinedname WHERE guid = ?");
stmt.PExecute(GUID_LOPART(guid));
stmt = RealmDataDatabase.CreateStatement(insertDeclinedName, "INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES (?, ?, ?, ?, ?, ?)");
stmt.addUInt32(GUID_LOPART(guid));
stmt.addString(declinedname.name[0]);
stmt.addString(declinedname.name[1]);
stmt.addString(declinedname.name[2]);
stmt.addString(declinedname.name[3]);
stmt.addString(declinedname.name[4]);
stmt.Execute();
RealmDataDatabase.CommitTransaction();
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
data << uint32(0); // OK
data << uint64(guid);
SendPacket(&data);
}
开发者ID:Dolmero,项目名称:L4G_Core,代码行数:99,代码来源:CharacterHandler.cpp
注:本文中的GetMainPartOfName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论