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"); }
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"); } }
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"); } }
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); msg->write_byte(3); client->m_sendsignon = true; host.printf("pool : %d used: %d free: %d\n", pool.size(), pool.used(), pool.size() - pool.used()); host.printf("linear: %d used: %d free: %d\n", linear.size(), linear.used(), linear.size() - linear.used()); host.printf("LINEAR free: %dKB\n", (int)linearSpaceFree() / 1024); host.printf("REGULAR free: %dKB\n", (int)getMemFree() / 1024); host.printf("vbo_cb : %d\n", vbo_cb); host.printf("vbo_tx : %d\n", vbo_tx); host.printf("vbo_ls : %d\n", vbo_ls); host.printf("mdl_cb : %d\n", mdl_cb); host.printf("mdl_tx : %d\n", mdl_tx); }