home *** CD-ROM | disk | FTP | other *** search
- #include "GameCCmds.h"
-
- #include "Game.h"
- #include "log.h"
- #include "Gui.h"
- #include "ConsoleFrontEnd.h"
- #include "Network.h"
- #include <stdlib.h>
- #include "Display.h"
-
- CCmdGameRestart::CCmdGameRestart():CCmd("game.restart"){
- usageStr="game.restart";
- infoStr="restarts the game (the arena - not the whole game!)";
- }
-
- CCmdGameRestart::~CCmdGameRestart(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameRestart::exec(int argc, char* argv[]){
- if(argc==0){
- consoleFrontEnd->clearInputString();
- if(Game::wasInit()){
- Game::shutdown();
- if( !Game::init() )
- Gui::mainMenu->open();
- return false;
- }else{
- console->print("game.restart: No game running, so I'll start a new one.\n");
- return Game::init();
- }
-
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameShutdown::CCmdGameShutdown():CCmd("game.shutdown"){
- usageStr="game.shutdown";
- infoStr="shuts down the running game and returns to main menu";
- }
-
- CCmdGameShutdown::~CCmdGameShutdown(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameShutdown::exec(int argc, char* argv[]){
- if(argc==0){
- if(Game::wasInit()){
- Game::shutdown();
- Input::showMouseCursor();
- Input::freeInput();
- Gui::mainMenu->open();
- }else{
- console->print("game.shutdown: No game running.\n");
- return false;
- }
-
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
- CCmdGameStartClientGame::CCmdGameStartClientGame():CCmd("game.startClientGame"){
- usageStr="game.startClientGame [server:port]";
- infoStr="connects you to 'server'";
- }
-
- CCmdGameStartClientGame::~CCmdGameStartClientGame(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameStartClientGame::exec(int argc, char* argv[]){
- if(argc==1){
- Game::info.cvar.game_clientGame->setValStr("1");
- Network::info.cvar.network_server_hostName->setValStr(argv[0]);
- console->print("game.startClientGame: Calling game.restart...\n");
- return Game::info.ccmd.game_restart->exec(0, NULL);
- // return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameStartServer::CCmdGameStartServer():CCmd("game.startServer"){
- usageStr="game.startServer <name> <port> <dedicated>";
- infoStr="starts a server on this machine";
- }
-
- CCmdGameStartServer::~CCmdGameStartServer(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameStartServer::exec(int argc, char* argv[]){
- if(argc>=0 && argc<=3){
- Game::info.cvar.game_clientGame->setValStr("0");
- Network::info.cvar.network_server_hostName->setValStr("localhost");
- if(argc>=1)
- Network::info.cvar.network_server_name->setValStr(argv[0]);
- if(argc>=2)
- Network::info.cvar.network_server_port->setValStr(argv[1]);
- if(argc>=3)
- Network::info.cvar.network_server_dedicated->setValStr(argv[2]);
-
- console->print("game.startServer: Calling game.restart...\n");
- return Game::info.ccmd.game_restart->exec(0, NULL);
- // return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameKill::CCmdGameKill():CCmd("game.kill"){
- usageStr="game.kill <clientId>";
- infoStr="kills a client (or yourself if no id is specified)";
- }
-
- CCmdGameKill::~CCmdGameKill(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameKill::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.kill: No game running!");
- return false;
- }
-
- if( argc == 0 ){ // kill self
- if( Network::client->vehicle != NULL ){
- Network::client->sendClientKill();
- }else{
- console->print("game.kill: You are already dead!\n");
- }
-
- return true;
- }if( argc == 1 ){ // kill other client
- if( Game::info.var.clientGame ){
- console->print("game.kill: Can't kill clients on a remote server!\n");
- return false;
- }else{
- int clientId = atoi(argv[0]);
- if( clientId < 0 || clientId >= Network::server->si.maxClients ){
- console->print("game.kill: ClientId out of bounds.\n");
- return false;
- }
- Client* c = Network::server->clients[clientId];
- if( c == NULL ){
- console->print("game.kill: ClientId invalid.\n");
- return false;
- }
- if( c->vehicle == NULL ){
- console->print("game.kill: Client already dead.\n");
- return false;
- }
-
- Network::server->sendClientKill(c->clientId, c->clientId, -1);
- Game::killClient(c, c, -1);
- // log("%s was killed by server admin.\n", c->ci.name);
- }
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameChatAll::CCmdGameChatAll():CCmd("game.chatAll"){
- usageStr="game.chatAll <message>";
- infoStr="sends a chat message to all clients";
- }
-
- CCmdGameChatAll::~CCmdGameChatAll(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameChatAll::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.chatAll: No game running!\n");
- return false;
- }
-
- if( argc == 0 ){ // open chat prompt
- if( !Gui::hud->chatPrompt->isActive )
- Gui::hud->chatPrompt->activate( GAME_CHAT_MODE_ALL );
-
- return true;
- }if( argc == 1 ){ // send messsage
- Game::chatMessageAll(argv[0]);
-
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameChatTeam::CCmdGameChatTeam():CCmd("game.chatTeam"){
- usageStr="game.chatTeam <message>";
- infoStr="sends a chat message to all team members";
- }
-
- CCmdGameChatTeam::~CCmdGameChatTeam(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameChatTeam::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.chatTeam: No game running!\n");
- return false;
- }
-
- if( argc == 0 ){ // open chat prompt
- if( !Gui::hud->chatPrompt->isActive )
- Gui::hud->chatPrompt->activate( GAME_CHAT_MODE_TEAM );
-
- return true;
- }if( argc == 1 ){ // send messsage
- Game::chatMessageTeam(argv[0]);
-
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
-
- CCmdGameVoiceAll::CCmdGameVoiceAll():CCmd("game.voiceAll"){
- usageStr="game.voiceAll [voiceMessage]";
- infoStr="sends a voice message to all clients";
- }
-
- CCmdGameVoiceAll::~CCmdGameVoiceAll(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameVoiceAll::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.voiceAll: No game running!\n");
- return false;
- }
-
- if( argc == 1 ){ // send messsage
- // Game::chatMessageAll("VOICE ALL");
- char messageId = (char)Game::getVoiceMessageId(argv[0]);
- if( messageId != -1 ){
- Network::client->sendVoiceMessage( GAME_CHAT_MODE_ALL, messageId);
- }else{
- console->print("game.voiceAll: messageId invalid.\n");
- }
-
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameVoiceTeam::CCmdGameVoiceTeam():CCmd("game.voiceTeam"){
- usageStr="game.voiceTeam [voiceMessage]";
- infoStr="sends a voice message to all team members";
- }
-
- CCmdGameVoiceTeam::~CCmdGameVoiceTeam(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameVoiceTeam::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.voiceTeam: No game running!\n");
- return false;
- }
-
- if( argc == 1 ){ // send messsage
- // Game::chatMessageTeam("VOICE TEAM");
- char messageId = (char)Game::getVoiceMessageId(argv[0]);
- if( messageId != -1 ){
- Network::client->sendVoiceMessage( GAME_CHAT_MODE_TEAM, messageId);
- }else{
- console->print("game.voiceTeam: messageId invalid.\n");
- }
-
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
-
-
-
-
- CCmdGameCameraChaseNext::CCmdGameCameraChaseNext():CCmd("game.camera.chaseNext"){
- usageStr="game.camera.chaseNext";
- infoStr="chase next client with camera";
- }
-
- CCmdGameCameraChaseNext::~CCmdGameCameraChaseNext(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameCameraChaseNext::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.camera.chaseNext: No game running!");
- return false;
- }
-
- if(argc == 0){
- Game::cam.chaseNext();
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
- CCmdGameCameraChasePrevious::CCmdGameCameraChasePrevious():CCmd("game.camera.chasePrevious"){
- usageStr="game.camera.chasePrevious";
- infoStr="chase previous client with camera";
- }
-
- CCmdGameCameraChasePrevious::~CCmdGameCameraChasePrevious(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameCameraChasePrevious::exec(int argc, char* argv[]){
- if( !Game::wasInit() ){
- console->print("game.camera.chasePrevious: No game running!");
- return false;
- }
-
- if(argc == 0){
- Game::cam.chasePrevious();
- return true;
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-
-
-
-
-
-
-
-
-
- CCmdGameDebugCmd1::CCmdGameDebugCmd1():CCmd("game.debugCmd1"){
- usageStr="game.debugCmd1";
- infoStr="macht irgendwas nuetzliches...";
- }
-
- CCmdGameDebugCmd1::~CCmdGameDebugCmd1(){
- if(console!=NULL)
- console->unregisterCCmd(this);
- }
-
- bool CCmdGameDebugCmd1::exec(int argc, char* argv[]){
- if(argc == 0){
- if( Game::wasInit() ){
- // Display::takeScreenshot();
- // castRay();
-
- /*
- vec3_t col, pos;
- vectorInit3d(0.8f, 0.6f, 0.1f, col);
- //vectorInit3d(frand(1.0f), frand(1.0f), frand(1.0f), col);
- vectorAdd3d(Network::client->cs.pos, Network::client->cs.dir, pos);
- Renderer::particleSystem.linkParticleCluster(new DynamicLightParticleCluster(pos, col, 1.5f, 100));
- */
-
- return true;
- }else{
- console->print("No game running!\n");
- return false;
- }
- }else{
- console->print("usage: %s\n", usageStr);
- return false;
- }
- }
-