本文整理汇总了C++中PacketFunctions::WriteNT方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketFunctions::WriteNT方法的具体用法?C++ PacketFunctions::WriteNT怎么用?C++ PacketFunctions::WriteNT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketFunctions
的用法示例。
在下文中一共展示了PacketFunctions::WriteNT方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteRoomListPacket
void SMOnlineRoom::WriteRoomListPacket(PacketFunctions &Packet) {
unsigned int numRooms = m_joinrooms.size();
Packet.ClearPacket();
Packet.Write1(NSSMONL + NSServerOffset);
Packet.Write1(1); //Room command
Packet.Write1(1); //Type (List Rooms)
Packet.Write1(numRooms);
for (unsigned int x = 0; x < numRooms; ++x) {
if (m_joinrooms[x] != NULL) {
Packet.WriteNT(m_joinrooms[x]->GetTitle());
Packet.WriteNT(m_joinrooms[x]->GetDescription());
}
}
//state
for (unsigned int x = 0; x < numRooms; ++x) {
if (m_joinrooms[x] != NULL)
{
//TO MAKE CHARLES HAPPY IF PASSWORDED USE 1 (UNSUSED)
if (!m_joinrooms[x]->m_passwd.empty() && (m_joinrooms[x]->m_state == RS_OPEN))
Packet.Write1(RS_UNUSED);
else
Packet.Write1(m_joinrooms[x]->m_state);
}
}
//Flags
char flags;
for (unsigned int x = 0; x < numRooms; ++x) {
if (m_joinrooms[x] != NULL)
{
flags = 0;
//bit 1 passworded
if (!m_joinrooms[x]->m_passwd.empty())
flags += 1;
Packet.Write1(flags);
}
}
}
示例2: WriteChatPacket
void SMOnlineRoom::WriteChatPacket(PacketFunctions& packet, const MString& message) {
packet.ClearPacket();
packet.Write1(NSCCM + NSServerOffset);
packet.WriteNT(message);
}
示例3: AnalizeChat
void SMOnlineRoom::AnalizeChat(unsigned int clientNum, PacketFunctions& Packet)
{
MString message = Packet.ReadNT();
ChatCommandPack ccp = ParseCommands(message, clientNum);
switch(ccp.cmd)
{
case NONE:
RelayChat(clientNum, message);
return;
case ANNOUNCE:
{
PacketFunctions reply;
reply.ClearPacket();
reply.Write1(NSCSU+NSServerOffset);
reply.WriteNT(ccp.data.front());
SERVER->SendToAll(reply);
}
return;
case KICK:
{
const MString& name = ccp.data.front();
for (unsigned int x = 0; x < m_clients.size(); ++x)
for (unsigned int y = 0; y < m_clients[x]->GetNumPlayers(); ++y)
if (m_clients[x]->GetPlayer(y)->GetName() == name)
{
LOG->Write("Kicking " + name);
m_kicked[ccp.data.front()] = KickClient(name);
ChangeRoom(1, m_joinrooms[0]->GetTitle(), x, "", true);
return;
}
}
break;
case BAN:
{
const MString& name = ccp.data.front();
for (unsigned int x = 0; x < m_clients.size(); ++x)
for (unsigned int y = 0; y < m_clients[x]->GetNumPlayers(); ++y)
if (m_clients[x]->GetPlayer(y)->GetName() == name)
{
LOG->Write("Banning " + name);
m_banned[name] = name;
ChangeRoom(1, m_joinrooms[0]->GetTitle(), x, "", true);
return;
}
}
break;
case PM:
{
MString user = ccp.data.front();
ccp.data.pop();
MString message = ccp.data.front();
MString tmp;
MString success = "PM Failed!";
if ((user.length() > 0) && (message.length() > 0))
{
tmp = "PM from ";
unsigned int numPlayers = m_clients[m_cNum]->GetNumPlayers();
for (unsigned int x = 0; x < numPlayers; ++x)
{
tmp += m_clients[m_cNum]->GetPlayerName(x);
if ((numPlayers > 1) && (x < (numPlayers - 1)))
tmp += "&";
}
tmp += ": " + message;
if (SERVER->MsgPlayer(user, tmp))
success = "PM Success!";
}
PacketFunctions result;
result.ClearPacket();
result.Write1(NSCCM + NSServerOffset);
result.WriteNT(success);
m_clients[m_cNum]->SendData(result);
}
break;
case DROP:
{
SMOnlineClient* tmp = SERVER->GetPlayerClient(ccp.data.front());
if (tmp != NULL)
tmp->connection.close();
}
break;
// case FORCESTART:
// break;
default:
break;
};
}