本文整理汇总了C++中OutputMessage_ptr::AddByte方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessage_ptr::AddByte方法的具体用法?C++ OutputMessage_ptr::AddByte怎么用?C++ OutputMessage_ptr::AddByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessage_ptr
的用法示例。
在下文中一共展示了OutputMessage_ptr::AddByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adminCommandKickPlayer
void ProtocolAdmin::adminCommandKickPlayer(const std::string& name)
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output)
{
TRACK_MESSAGE(output);
Player* player = g_game.getPlayerByName(name);
if(player)
{
player->kickPlayer(false);
addLogLine(this, LOGTYPE_EVENT, 1, "kicked player " + name);
output->AddByte(AP_MSG_COMMAND_OK);
}
else
{
addLogLine(this, LOGTYPE_WARNING, 1, "Could not kick player (not online): " + name);
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString("player is not online");
}
OutputMessagePool::getInstance()->send(output);
}
}
示例2: adminCommandSendMail
void ProtocolAdmin::adminCommandSendMail(const std::string& xmlData)
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
std::string name;
uint32_t depotId;
Item* mailItem = createMail(xmlData, name, depotId);
if(mailItem){
if(Mailbox::sendItemTo(name, depotId, mailItem)){
output->AddByte(AP_MSG_COMMAND_OK);
}
else{
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString("Could not mail item");
}
}
else{
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString("Could not mail item");
}
OutputMessagePool::getInstance()->send(output);
}
}
示例3: adminCommandSetOwner
void ProtocolAdmin::adminCommandSetOwner(const std::string& param)
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
boost::char_separator<char> sep(", ");
tokenizer cmdtokens(param, sep);
tokenizer::iterator cmdit = cmdtokens.begin();
std::string _house, name;
_house = parseParams(cmdit, cmdtokens.end());
name = parseParams(cmdit, cmdtokens.end());
trimString(_house);
trimString(name);
if (House* house = Houses::getInstance().getHouse(atoi(_house.c_str()))) {
uint32_t _guid;
if (IOLoginData::getInstance()->getGuidByName(_guid, name)) {
house->setHouseOwner(_guid);
addLogLine(this, LOGTYPE_EVENT, 1, "set " + name + " as new owner of house with id " + _house);
output->AddByte(AP_MSG_COMMAND_OK);
} else {
addLogLine(this, LOGTYPE_WARNING, 1, "Could not find player with name: " + name);
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString("such player does not exists");
}
} else {
addLogLine(this, LOGTYPE_WARNING, 1, "Could not find house with id: " + _house);
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString("such house does not exists");
}
OutputMessagePool::getInstance()->send(output);
}
}
示例4: adminCommandPayHouses
void ProtocolAdmin::adminCommandPayHouses()
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
if (Houses::getInstance().payHouses()) {
addLogLine(this, LOGTYPE_EVENT, 1, "pay houses ok");
output->AddByte(AP_MSG_COMMAND_OK);
} else {
addLogLine(this, LOGTYPE_WARNING, 1, "pay houses fail");
output->AddByte(AP_MSG_COMMAND_FAILED);
output->AddString(" ");
}
OutputMessagePool::getInstance()->send(output);
}
}
示例5: disconnectClient
void ProtocolLogin::disconnectClient(uint8_t error, const char* message)
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
output->AddByte(error);
output->AddString(message);
OutputMessagePool::getInstance()->send(output);
}
getConnection()->closeConnection();
}
示例6: disconnectClient
void ProtocolLogin::disconnectClient(const std::string& message)
{
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
output->AddByte(0x0A);
output->AddString(message);
OutputMessagePool::getInstance()->send(output);
}
getConnection()->closeConnection();
}
示例7: adminCommandSaveServer
void ProtocolAdmin::adminCommandSaveServer(bool shallow)
{
g_game.saveServer(false, shallow);
addLogLine(this, LOGTYPE_EVENT, 1, "save server ok");
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例8: adminCommandPayHouses
void ProtocolAdmin::adminCommandPayHouses()
{
Houses::getInstance().payHouses();
addLogLine(this, LOGTYPE_EVENT, 1, "pay houses ok");
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例9: adminCommandShutdownServer
void ProtocolAdmin::adminCommandShutdownServer()
{
g_game.setGameState(GAME_STATE_SHUTDOWN);
addLogLine(this, LOGTYPE_EVENT, 1, "start server shutdown");
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例10: adminCommandOpenServer
void ProtocolAdmin::adminCommandOpenServer()
{
g_game.setGameState(GAME_STATE_NORMAL);
addLogLine(this, LOGTYPE_EVENT, 1, "open server ok");
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例11: adminCommandRelationalSaveServer
void ProtocolAdmin::adminCommandRelationalSaveServer()
{
std::string old_type = g_config.getString(ConfigManager::MAP_STORAGE_TYPE);
g_config.setString(ConfigManager::MAP_STORAGE_TYPE, "relational");
g_game.saveServer(false);
g_config.setString(ConfigManager::MAP_STORAGE_TYPE, old_type);
addLogLine(this, LOGTYPE_EVENT, 1, "relational save server ok");
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例12: getCharacterList
void ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password)
{
Account account;
if (!IOLoginData::loginserverAuthentication(accountName, password, account)) {
disconnectClient("Account name or password is not correct.");
return;
}
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
//Update premium days
Game::updatePremium(account);
//Add MOTD
output->AddByte(0x14);
std::ostringstream ss;
ss << g_game.getMotdNum() << "\n" << g_config.getString(ConfigManager::MOTD);
output->AddString(ss.str());
//Add char list
output->AddByte(0x64);
output->AddByte(1); // number of worlds
output->AddByte(0); // world id
output->AddString(g_config.getString(ConfigManager::SERVER_NAME));
output->AddString(g_config.getString(ConfigManager::IP));
output->add<uint16_t>(g_config.getNumber(ConfigManager::GAME_PORT));
output->AddByte(0);
output->AddByte(static_cast<uint8_t>(account.charList.size()));
for (const std::string& characterName : account.charList) {
output->AddByte(0);
output->AddString(characterName);
}
//Add premium days
if (g_config.getBoolean(ConfigManager::FREE_PREMIUM)) {
output->add<uint16_t>(0xFFFF); //client displays free premium
} else {
output->add<uint16_t>(account.premiumDays);
}
OutputMessagePool::getInstance()->send(output);
}
getConnection()->closeConnection();
}
示例13: onRecvFirstMessage
void ProtocolAdmin::onRecvFirstMessage(NetworkMessage& msg)
{
//is the remote admin protocol enabled?
if(!g_adminConfig->isEnabled())
{
getConnection()->closeConnection();
return;
}
m_state = NO_CONNECTED;
//is allowed this ip?
if(!g_adminConfig->allowIP(getIP()))
{
addLogLine(this, LOGTYPE_EVENT, 1, "ip not allowed");
getConnection()->closeConnection();
return;
}
//max connections limit
if(!g_adminConfig->addConnection())
{
addLogLine(this, LOGTYPE_EVENT, 1, "cannot add new connection");
getConnection()->closeConnection();
return;
}
addLogLine(this, LOGTYPE_EVENT, 1, "sending HELLO");
//send hello
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output)
{
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_HELLO);
output->AddU32(1); //version
output->AddString("OTADMIN");
output->AddU16(g_adminConfig->getProtocolPolicy()); //security policy
output->AddU32(g_adminConfig->getProtocolOptions()); //protocol options(encryption, ...)
OutputMessagePool::getInstance()->send(output);
}
m_lastCommand = time(NULL);
m_state = ENCRYPTION_NO_SET;
}
示例14: adminCommandCloseServer
void ProtocolAdmin::adminCommandCloseServer()
{
g_game.setGameState(GAME_STATE_CLOSED);
addLogLine(this, LOGTYPE_EVENT, 1, "close server ok");
AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
while(it != Player::listPlayer.list.end()){
if(!(*it).second->hasFlag(PlayerFlag_CanAlwaysLogin)){
(*it).second->kickPlayer();
it = Player::listPlayer.list.begin();
}
else{
++it;
}
}
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if(output){
TRACK_MESSAGE(output);
output->AddByte(AP_MSG_COMMAND_OK);
OutputMessagePool::getInstance()->send(output);
}
}
示例15: parseFirstPacket
//.........这里部分代码省略.........
if (IOBan::isIpBanned(clientip, banInfo)) {
if (banInfo.reason.empty()) {
banInfo.reason = "(none)";
}
std::ostringstream ss;
ss << "Your IP has been banned until " << formatDateShort(banInfo.expiresAt) << " by " << banInfo.bannedBy << ".\n\nReason specified:\n" << banInfo.reason;
disconnectClient(0x0B, ss.str().c_str());
return false;
}
//IF THE PASSWORD FIELDS AND ACCOUNT FIELD ARE EMPTY THEN THE USER WAN'T TO USE CAST SYSTEM
bool cast_login = false;
if ((accountName.empty() && password.empty()) || (accountName.empty() && !password.empty()))
{
cast_login = true;
}
if (!cast_login && accountName.empty()) {
disconnectClient(0x0B, "Invalid account name.");
return false;
}
Account account;
if (!cast_login && !IOLoginData::loginserverAuthentication(accountName, password, account)) {
disconnectClient(0x0B, "Account name or password is not correct.");
return false;
}
OutputMessage_ptr output = OutputMessagePool::getInstance()->getOutputMessage(this, false);
if (output) {
//Update premium days
g_game.updatePremium(account);
//Add MOTD
output->AddByte(0x14);
std::ostringstream ss;
ss << g_game.getMotdNum() << "\n" << g_config.getString(ConfigManager::MOTD);
output->AddString(ss.str());
//SessionKey
if (!cast_login) {
output->AddByte(0x28);
output->AddString(accountName + "\n" + password);
}
//Add char list
output->AddByte(0x64);
if (cast_login)
{
int cz = 0;
std::vector<std::string> names;
std::vector<uint32_t> counts;
cast_login = false;
uint8_t size = 0;
g_game.lockPlayers();
for (const auto& it : g_game.getPlayers())
{
if (it.second->cast.isCasting && (it.second->cast.password == "" || it.second->cast.password == password))
{
names.push_back(it.second->getName());
counts.push_back(it.second->getCastViewerCount());
it.second->getCastViewerCount();
cast_login = true;