本文整理汇总了C++中NetBuffer::read_string方法的典型用法代码示例。如果您正苦于以下问题:C++ NetBuffer::read_string方法的具体用法?C++ NetBuffer::read_string怎么用?C++ NetBuffer::read_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetBuffer
的用法示例。
在下文中一共展示了NetBuffer::read_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_client_message
bool Server::read_client_message(Client *client) {
NetBuffer *msg = client->m_netconnection->m_receiveMessage;
char *s;
int ret;
do {
if (msg->pos() == 0 || msg->read_pos() == msg->pos()) {
break;
}
int r = msg->read_byte();
if (r == -1) {
return false;
}
int len = msg->read_short();
/*int skip = */msg->read_byte();
int end = msg->read_pos() + len;
do {
if (len == 0 || !client->is_active()) {
return false;
}
int cmd = msg->read_byte();
//check end of message
if (cmd == -1) {
break;
}
switch (cmd)
{
case -1:
//goto nextmsg; // end of message
default:
printf("SV_ReadClientMessage: unknown command char\n");
return false;
case clc_nop:
printf("clc_nop\n");
break;
case clc_stringcmd:
s = msg->read_string();
ret = 0;
if (strncasecmp(s, "status", 6) == 0)
ret = 1;
else if (strncasecmp(s, "god", 3) == 0)
ret = 1;
else if (strncasecmp(s, "notarget", 8) == 0)
ret = 1;
else if (strncasecmp(s, "fly", 3) == 0)
ret = 1;
else if (strncasecmp(s, "name", 4) == 0)
ret = 1;
else if (strncasecmp(s, "noclip", 6) == 0)
ret = 1;
else if (strncasecmp(s, "create", 6) == 0)
ret = 1;
else if (strncasecmp(s, "say", 3) == 0)
ret = 1;
else if (strncasecmp(s, "say_team", 8) == 0)
ret = 1;
else if (strncasecmp(s, "tell", 4) == 0)
ret = 1;
else if (strncasecmp(s, "color", 5) == 0)
ret = 1;
else if (strncasecmp(s, "kill", 4) == 0)
ret = 1;
else if (strncasecmp(s, "pause", 5) == 0)
ret = 1;
else if (strncasecmp(s, "spawn", 5) == 0) {
ret = 1;
}
else if (strncasecmp(s, "begin", 5) == 0) {
ret = 1;
client->m_spawned = true;
break;
}
else if (strncasecmp(s, "prespawn", 8) == 0) {
ret = 1;
}
else if (strncasecmp(s, "kick", 4) == 0)
ret = 1;
else if (strncasecmp(s, "ping", 4) == 0)
ret = 1;
else if (strncasecmp(s, "give", 4) == 0)
ret = 1;
if (ret == 2)
Cbuf_InsertText(s);
else if (ret == 1) {
m_cmds.call(s, client);
Cmd_ExecuteString(s, src_client);
}
else
printf("%s tried to %s\n", client->m_name, s);
break;
case clc_disconnect:
printf("SV_ReadClientMessage: client disconnected\n");
//.........这里部分代码省略.........