本文整理汇总了C++中NetBuffer::write_string方法的典型用法代码示例。如果您正苦于以下问题:C++ NetBuffer::write_string方法的具体用法?C++ NetBuffer::write_string怎么用?C++ NetBuffer::write_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetBuffer
的用法示例。
在下文中一共展示了NetBuffer::write_string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: god
void Server::god(char *cmdline, void *p, ...) {
Client *client = reinterpret_cast<Client *>(p);
edict_t *ent = client->m_edict;
NetBuffer *msg = &client->m_msg;
ent->v.flags = (int)ent->v.flags ^ FL_GODMODE;
msg->write_byte(svc_print);
if (!((int)ent->v.flags & FL_GODMODE))
msg->write_string("godmode OFF\n");
else
msg->write_string("godmode ON\n");
}
示例2: fly
void Server::fly(char *cmdline, void *p, ...) {
Client *client = reinterpret_cast<Client *>(p);
edict_t *ent = client->m_edict;
NetBuffer *msg = &client->m_msg;
msg->write_byte(svc_print);
if (ent->v.movetype != MOVETYPE_FLY) {
ent->v.movetype = MOVETYPE_FLY;
msg->write_string("flymode ON\n");
}
else {
ent->v.movetype = MOVETYPE_WALK;
msg->write_string("flymode OFF\n");
}
}
示例3: noclip
void Server::noclip(char *cmdline, void *p, ...) {
Client *client = reinterpret_cast<Client *>(p);
edict_t *ent = client->m_edict;
NetBuffer *msg = &client->m_msg;
if (m_progs->m_global_struct->deathmatch)
return;
msg->write_byte(svc_print);
if (ent->v.movetype != MOVETYPE_NOCLIP)
{
//noclip_anglehack = true;
ent->v.movetype = MOVETYPE_NOCLIP;
msg->write_string("noclip ON\n");
}
else
{
ent->v.movetype = MOVETYPE_WALK;
msg->write_string("noclip OFF\n");
}
}
示例4: spawn
void Server::spawn(char *cmdline, void *p, ...) {
Client *client = reinterpret_cast<Client *>(p);
if (client->m_spawned) {
printf("Spawn not valid -- allready spawned\n");
return;
}
if (m_loadgame) {
m_paused = false;
} else {
edict_t *ent = client->m_edict;
memset(&ent->v, 0, m_progs->m_programs.entityfields * 4);
ent->v.colormap = m_progs->NUM_FOR_EDICT(ent);
ent->v.team = (client->m_colors & 15) + 1;
ent->v.netname = client->m_name - m_progs->m_strings;
// copy spawn parms out of the client_t
for (int i = 0; i< NUM_SPAWN_PARMS; i++)
(&m_progs->m_global_struct->parm1)[i] = client->m_spawn_parms[i];
// call the spawn function
m_progs->m_global_struct->time = m_time;
m_progs->m_global_struct->self = m_progs->edict_to_prog(ent);
m_progs->program_execute(m_progs->m_global_struct->ClientConnect);
if ((sys.seconds() - client->m_netconnection->m_connecttime) <= m_time)
printf("%s entered the game\n", client->m_name);
m_progs->program_execute(m_progs->m_global_struct->PutClientInServer);
}
NetBuffer *msg = &client->m_msg;
msg->clear();
// send time of update
msg->write_byte(svc_time);
msg->write_float(m_time);
for (int i = 0; i<m_maxclients; i++)
{
Client *client2 = &m_clients[i];
msg->write_byte(svc_updatename);
msg->write_byte(i);
msg->write_string(client2->m_name);
msg->write_byte(svc_updatefrags);
msg->write_byte(i);
msg->write_short(client2->m_old_frags);
msg->write_byte(svc_updatecolors);
msg->write_byte(i);
msg->write_byte(client2->m_colors);
}
// send all current light styles
for (int i = 0; i<MAX_LIGHTSTYLES; i++)
{
msg->write_byte(svc_lightstyle);
msg->write_byte((char)i);
msg->write_string(m_progs->m_lightstyles[i]);
}
//
// send some stats
//
msg->write_byte(svc_updatestat);
msg->write_byte(STAT_TOTALSECRETS);
msg->write_long((int)m_progs->m_global_struct->total_secrets);
msg->write_byte(svc_updatestat);
msg->write_byte(STAT_TOTALMONSTERS);
msg->write_long((int)m_progs->m_global_struct->total_monsters);
msg->write_byte(svc_updatestat);
msg->write_byte(STAT_SECRETS);
msg->write_long((int)m_progs->m_global_struct->found_secrets);
msg->write_byte(svc_updatestat);
msg->write_byte(STAT_MONSTERS);
msg->write_long((int)m_progs->m_global_struct->killed_monsters);
//
// send a fixangle
// Never send a roll angle, because savegames can catch the server
// in a state where it is expecting the client to correct the angle
// and it won't happen if the game was just loaded, so you wind up
// with a permanent head tilt
edict_t *ent = m_progs->EDICT_NUM(1 + (client - m_clients));
msg->write_byte(svc_setangle);
for (int i = 0; i < 2; i++) {
msg->write_angle(ent->v.angles[i]);
}
msg->write_angle(0);
write_client_data_to_message(ent, msg);
//SV_WriteClientdataToMessage(sv_player, &host_client->message);
msg->write_byte(svc_signonnum);
//.........这里部分代码省略.........