home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / gamesys / SysCmds.cpp < prev    next >
C/C++ Source or Header  |  2005-11-14  |  82KB  |  3,107 lines

  1.  
  2. #include "../../idlib/precompiled.h"
  3. #pragma hdrstop
  4.  
  5. #include "../Game_local.h"
  6. // RAVEN BEGIN
  7. #include "../ai/AI.h"
  8. #if !defined(__GAME_PROJECTILE_H__)
  9.     #include "../Projectile.h"
  10. #endif
  11. #if !defined(__GAME_WEAPON_H__)
  12.     #include "../Weapon.h"
  13. #endif
  14. #if !defined(__GAME_SPAWNER_H__)
  15.     #include "../spawner.h"
  16. #endif
  17. #if !defined(__GAME_VEHICLE_H__)
  18.     #include "../Vehicle/Vehicle.h"
  19. #endif
  20. #if !defined(__AI_MANAGER_H__)
  21.     #include "../ai/AI_Manager.h"
  22. #endif
  23. #if !defined(__INSTANCE_H__)
  24.     #include "../Instance.h"
  25. #endif
  26. // RAVEN END
  27.  
  28. #ifdef _WIN32
  29. #include "TypeInfo.h"
  30. #else
  31. #include "NoGameTypeInfo.h"
  32. #endif
  33.  
  34. /*
  35. ==================
  36. Cmd_GetFloatArg
  37. ==================
  38. */
  39. float Cmd_GetFloatArg( const idCmdArgs &args, int &argNum ) {
  40.     const char *value;
  41.  
  42.     value = args.Argv( argNum++ );
  43.     return atof( value );
  44. }
  45.  
  46. /*
  47. ===================
  48. Cmd_EntityList_f
  49. ===================
  50. */
  51. void Cmd_EntityList_f( const idCmdArgs &args ) {
  52.     int            e;
  53.     idEntity    *check;
  54.     int            count;
  55.     size_t        size;
  56.     idStr        match;
  57.  
  58.     if ( args.Argc() > 1 ) {
  59.         match = args.Args();
  60.         match.Replace( " ", "" );
  61.     } else {
  62.         match = "";
  63.     }
  64.  
  65.     count = 0;
  66.     size = 0;
  67.  
  68.     gameLocal.Printf( "%-4s  %-20s %-20s %s\n", " Num", "EntityDef", "Class", "Name" );
  69.     gameLocal.Printf( "--------------------------------------------------------------------\n" );
  70.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  71.         check = gameLocal.entities[ e ];
  72.  
  73.         if ( !check ) {
  74.             continue;
  75.         }
  76.  
  77.         if ( !check->name.Filter( match ) ) {
  78.             continue;
  79.         }
  80.  
  81.         gameLocal.Printf( "%4i: %-20s %-20s %s\n", e,
  82.             check->GetEntityDefName(), check->GetClassname(), check->name.c_str() );
  83.  
  84.         count++;
  85.         size += check->spawnArgs.Allocated();
  86.     }
  87.  
  88.     gameLocal.Printf( "...%d entities\n...%d bytes of spawnargs\n", count, size );
  89. }
  90.  
  91. /*
  92. ===================
  93. Cmd_ActiveEntityList_f
  94. ===================
  95. */
  96. void Cmd_ActiveEntityList_f( const idCmdArgs &args ) {
  97.     idEntity    *check;
  98.     int            count;
  99.  
  100.     count = 0;
  101.  
  102.     gameLocal.Printf( "%-4s  %-20s %-20s %s\n", " Num", "EntityDef", "Class", "Name" );
  103.     gameLocal.Printf( "--------------------------------------------------------------------\n" );
  104.     for( check = gameLocal.activeEntities.Next(); check != NULL; check = check->activeNode.Next() ) {
  105.         char    dormant = check->fl.isDormant ? '-' : ' ';
  106.         gameLocal.Printf( "%4i:%c%-20s %-20s %s\n", check->entityNumber, dormant, check->GetEntityDefName(), check->GetClassname(), check->name.c_str() );
  107.         count++;
  108.     }
  109.  
  110.     gameLocal.Printf( "...%d active entities\n", count );
  111. }
  112.  
  113. /*
  114. ===================
  115. Cmd_ListSpawnArgs_f
  116. ===================
  117. */
  118. void Cmd_ListSpawnArgs_f( const idCmdArgs &args ) {
  119.     int i;
  120.     idEntity *ent;
  121.  
  122.     ent = gameLocal.FindEntity( args.Argv( 1 ) );
  123.     if ( !ent ) {
  124.         gameLocal.Printf( "entity not found\n" );
  125.         return;
  126.     }
  127.  
  128.     for ( i = 0; i < ent->spawnArgs.GetNumKeyVals(); i++ ) {
  129.         const idKeyValue *kv = ent->spawnArgs.GetKeyVal( i );
  130.         gameLocal.Printf( "\"%s\"  "S_COLOR_WHITE"\"%s\"\n", kv->GetKey().c_str(), kv->GetValue().c_str() );
  131.     }
  132. }
  133.  
  134. /*
  135. ===================
  136. Cmd_ReloadScript_f
  137. ===================
  138. */
  139. void Cmd_ReloadScript_f( const idCmdArgs &args ) {
  140.     // shutdown the map because entities may point to script objects
  141.     gameLocal.MapShutdown();
  142.  
  143.     // recompile the scripts
  144.     gameLocal.program.Startup( SCRIPT_DEFAULT );
  145.  
  146.     // error out so that the user can rerun the scripts
  147.     gameLocal.Error( "Exiting map to reload scripts" );
  148. }
  149.  
  150. /*
  151. ===================
  152. Cmd_Script_f
  153. ===================
  154. */
  155. void Cmd_Script_f( const idCmdArgs &args ) {
  156.     const char *    script;
  157.     idStr            text;
  158.     idStr            funcname;
  159.     static int        funccount = 0;
  160.     idThread *        thread;
  161.     const function_t *func;
  162.     idEntity        *ent;
  163.  
  164.     if ( !gameLocal.CheatsOk() ) {
  165.         return;
  166.     }
  167.  
  168.     sprintf( funcname, "ConsoleFunction_%d", funccount++ );
  169.  
  170.     script = args.Args();
  171. // RAVEN BEGIN
  172. // jscott: fixed sprintf to idStr
  173.     text = va( "void %s() {%s;}\n", funcname.c_str(), script );
  174. // RAVEN END
  175.     if ( gameLocal.program.CompileText( "console", text, true ) ) {
  176.         func = gameLocal.program.FindFunction( funcname );
  177.         if ( func ) {
  178.             // set all the entity names in case the user named one in the script that wasn't referenced in the default script
  179.             for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  180.                 gameLocal.program.SetEntity( ent->name, ent );
  181.             }
  182.  
  183.             thread = new idThread( func );
  184.             thread->Start();
  185.         }
  186.     }
  187. }
  188.  
  189. // RAVEN BEGIN
  190. // jscott: exports for tracking memory
  191. /*
  192. ==================
  193. idGameEdit::ScriptSummary
  194. ==================
  195. */
  196. size_t idGameEdit::ScriptSummary( const idCmdArgs &args ) const {
  197.  
  198.     return( gameLocal.program.ScriptSummary( args ) );
  199. }
  200.  
  201. /*
  202. ==================
  203. idGameEdit::ClassSummary
  204. ==================
  205. */
  206. size_t idGameEdit::ClassSummary( const idCmdArgs &args ) const {
  207.  
  208.     common->Printf( "Classes         - %dK\n", idClass::GetUsedMemory() / 1024 );
  209.  
  210.     return( idClass::GetUsedMemory() / 1024 );
  211. }
  212.  
  213. /*
  214. ==================
  215. idGameEdit::EntitySummary
  216. ==================
  217. */
  218.  
  219. size_t idGameEdit::EntitySummary( const idCmdArgs &args ) const {
  220.  
  221.     common->Printf( "CL & SV ents    - %dK\n", gameLocal.GetEntityMemoryUsage () / 1024);
  222.  
  223.     return gameLocal.GetEntityMemoryUsage() / 1024;
  224. }
  225. // RAVEN END
  226.  
  227. /*
  228. ==================
  229. KillEntities
  230.  
  231. Kills all the entities of the given class in a level.
  232. ==================
  233. */
  234. void KillEntities( const idCmdArgs &args, const idTypeInfo &superClass ) {
  235.     idEntity    *ent;
  236.     idStrList    ignore;
  237.     const char *name;
  238.     int            i;
  239.  
  240.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  241.         return;
  242.     }
  243.  
  244.     for( i = 1; i < args.Argc(); i++ ) {
  245.         name = args.Argv( i );
  246.         ignore.Append( name );
  247.     }
  248.  
  249.     for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  250.         if ( ent->IsType( superClass ) ) {
  251.             for( i = 0; i < ignore.Num(); i++ ) {
  252.                 if ( ignore[ i ] == ent->name ) {
  253.                     break;
  254.                 }
  255.             }
  256.  
  257.             if ( i >= ignore.Num() ) {
  258.                 ent->PostEventMS( &EV_Remove, 0 );
  259.             }
  260.         }
  261.     }
  262. }
  263.  
  264. /*
  265. ==================
  266. Cmd_KillMonsters_f
  267.  
  268. Kills all the monsters in a level.
  269. ==================
  270. */
  271. void Cmd_KillMonsters_f( const idCmdArgs &args ) {
  272. // RAVEN BEGIN
  273. // jnewquist: Use accessor for static class type 
  274.     KillEntities( args, idAI::GetClassType() );
  275. // nmckenzie: rvSpawners
  276.     KillEntities( args, rvSpawner::GetClassType() );
  277.  
  278.     // kill any projectiles as well since they have pointers to the monster that created them
  279.     KillEntities( args, idProjectile::GetClassType() );
  280. // RAVEN END
  281. }
  282.  
  283. /*
  284. ==================
  285. Cmd_KillMovables_f
  286.  
  287. Kills all the moveables in a level.
  288. ==================
  289. */
  290. void Cmd_KillMovables_f( const idCmdArgs &args ) {
  291.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  292.         return;
  293.     }
  294. // RAVEN BEGIN
  295. // jnewquist: Use accessor for static class type 
  296.     KillEntities( args, idMoveable::GetClassType() );
  297. // RAVEN END
  298. }
  299.  
  300. // RAVEN BEGIN
  301. // bdube: vehicle code
  302. /*
  303. ==================
  304. Cmd_KillVehicles_f
  305. ==================
  306. */
  307. void Cmd_KillVehicles_f( const idCmdArgs &args ) {
  308.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  309.         return;
  310.     }
  311.     
  312.     rvVehicleController::KillVehicles ( );
  313. }
  314.  
  315. void Cmd_KillMessage_f( const idCmdArgs &args ) {
  316.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  317.         return;
  318.     }
  319.     
  320.     gameLocal.mpGame.SendDeathMessage( gameLocal.GetLocalPlayer(), gameLocal.GetLocalPlayer(), 2 );
  321. }
  322.  
  323. void Cmd_APState_f( const idCmdArgs &args ) {
  324.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  325.         return;
  326.     }
  327.     
  328.     for ( int i = 0; i < gameLocal.mpGame.assaultPoints.Num(); i++ ) {
  329.         gameLocal.Printf ( "Assault point #%d: owner: %d\n", gameLocal.mpGame.assaultPoints[i]->GetIndex(), gameLocal.mpGame.assaultPoints[i]->GetOwner() );
  330.     }
  331. }
  332. // RAVEN END
  333.  
  334. /*
  335. ==================
  336. Cmd_KillRagdolls_f
  337.  
  338. Kills all the ragdolls in a level.
  339. ==================
  340. */
  341. void Cmd_KillRagdolls_f( const idCmdArgs &args ) {
  342.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  343.         return;
  344.     }
  345. // RAVEN BEGIN
  346. // jnewquist: Use accessor for static class type 
  347.     KillEntities( args, idAFEntity_Generic::GetClassType() );
  348.     KillEntities( args, idAFEntity_WithAttachedHead::GetClassType() );
  349. // RAVEN END
  350. }
  351.  
  352. /*
  353. ==================
  354. Cmd_Give_f
  355.  
  356. Give items to a client
  357. ==================
  358. */
  359. void Cmd_Give_f( const idCmdArgs &args ) {
  360.     const char *name;
  361.     int            i;
  362.     bool        give_all;
  363.     idPlayer    *player;
  364.  
  365.     player = gameLocal.GetLocalPlayer();
  366.     if ( !player || !gameLocal.CheatsOk() ) {
  367.         return;
  368.     }
  369.  
  370.     name = args.Argv( 1 );
  371.  
  372.     if ( idStr::Icmp( name, "all" ) == 0 ) {
  373.         give_all = true;
  374.     } else {
  375.         give_all = false;
  376.     }
  377.  
  378.     if ( give_all || ( idStr::Cmpn( name, "weapon", 6 ) == 0 ) ) {
  379.         if ( gameLocal.world->spawnArgs.GetBool( "no_Weapons" ) ) {
  380.             gameLocal.world->spawnArgs.SetBool( "no_Weapons", false );
  381.             for( i = 0; i < gameLocal.numClients; i++ ) {
  382.                 if ( gameLocal.entities[ i ] ) {
  383.                     gameLocal.entities[ i ]->PostEventSec( &EV_Player_SelectWeapon, 0.5f, gameLocal.entities[ i ]->spawnArgs.GetString( "def_weapon1" ) );
  384.                 }
  385.             }
  386.         }
  387.     }
  388.  
  389.     if ( ( idStr::Cmpn( name, "weapon_", 7 ) == 0 ) || ( idStr::Cmpn( name, "item_", 5 ) == 0 ) || ( idStr::Cmpn( name, "ammo_", 5 ) == 0 ) ) {
  390.         player->GiveItem( name );
  391.         return;
  392.     }
  393.  
  394.     if ( give_all || idStr::Icmp( name, "health" ) == 0 )    {
  395.         player->health = player->inventory.maxHealth;
  396.         if ( player->IsInVehicle() ) {
  397.             player->GetVehicleController().Give ( "health", "9999" );
  398.         }
  399.         if ( !give_all ) {
  400.             return;
  401.         }
  402.     }
  403.  
  404.     if ( give_all || idStr::Icmp( name, "weapons" ) == 0 ) {
  405.         player->inventory.weapons = BIT( MAX_WEAPONS ) - 1;
  406.         player->CacheWeapons();
  407.  
  408.         if ( !give_all ) {
  409.             return;
  410.         }
  411.     }
  412.  
  413.     if ( give_all || idStr::Icmp( name, "ammo" ) == 0 ) {
  414. // RAVEN BEGIN
  415. // bdube: define changed
  416.         for ( i = 0 ; i < MAX_AMMOTYPES; i++ ) {
  417.             player->inventory.ammo[ i ] = player->inventory.MaxAmmoForAmmoClass( player, rvWeapon::GetAmmoNameForIndex( i ) );
  418. // RAVEN END        
  419.         }
  420.         if ( !give_all ) {
  421.             return;
  422.         }
  423.     }
  424.  
  425.     if ( give_all || idStr::Icmp( name, "armor" ) == 0 ) {
  426.         player->inventory.armor = player->inventory.maxarmor;
  427.         if ( !give_all ) {
  428.             return;
  429.         }
  430.     }
  431. // RAVEN BEGIN
  432.     if (idStr::Icmp(name, "quad") == 0) {
  433.         player->GivePowerUp( POWERUP_QUADDAMAGE, SEC2MS( 30.0f ) );
  434.         return;
  435.     }
  436.  
  437.     if ( idStr::Icmp( name, "invis" ) == 0 ) {
  438.         player->GivePowerUp( POWERUP_INVISIBILITY, SEC2MS( 30.0f ) );
  439.         return;
  440.     }
  441.  
  442.     if ( idStr::Icmp( name, "regen" ) == 0 ) {
  443.         player->GivePowerUp( POWERUP_REGENERATION, SEC2MS( 30.0f ) );
  444.         return;
  445.     }
  446.  
  447.     if ( idStr::Icmp( name, "haste" ) == 0 ) {
  448.         player->GivePowerUp( POWERUP_HASTE, SEC2MS( 30.0f ) );
  449.         return;
  450.     }
  451.  
  452.     if (idStr::Icmp(name, "ammoregen") == 0) {
  453.         player->GivePowerUp( POWERUP_AMMOREGEN, -1 );
  454.         return;
  455.     }
  456.     
  457.     if (idStr::Icmp(name, "scout") == 0) {
  458.         player->GivePowerUp( POWERUP_SCOUT, -1 );
  459.         return;
  460.     }
  461.  
  462.     if (idStr::Icmp(name, "doubler") == 0) {
  463.         player->GivePowerUp( POWERUP_DOUBLER, -1 );
  464.         return;
  465.     }
  466.  
  467.     if (idStr::Icmp(name, "guard") == 0) {
  468.         player->GivePowerUp( POWERUP_GUARD, -1 );
  469.         return;
  470.     }
  471. // RAVEN END
  472.  
  473.     if ( !idStr::Icmp ( name, "wpmod_all" ) ) {
  474.         player->GiveWeaponMods ( 0xFFFFFFFF );
  475.         return;
  476.     } else if ( !idStr::Cmpn( name, "wpmod_", 6 ) ) {
  477.         player->GiveWeaponMods ( (1<<(atoi(name+6)-1)) );
  478.         return;
  479.     }
  480.  
  481.     if ( !idStr::Cmpn( name, "stroggmod_", 10 ) ) {
  482.         player->Give ( name, "" );
  483.         return;
  484.     }
  485.  
  486.     if ( !give_all && !player->Give( args.Argv(1), args.Argv(2) ) ) {
  487.         gameLocal.Printf( "unknown item\n" );
  488.     }
  489. }
  490.  
  491. /*
  492. ==================
  493. Cmd_CenterView_f
  494.  
  495. Centers the players pitch
  496. ==================
  497. */
  498. void Cmd_CenterView_f( const idCmdArgs &args ) {
  499.     idPlayer    *player;
  500.     idAngles    ang;
  501.  
  502.     player = gameLocal.GetLocalPlayer();
  503.     if ( !player ) {
  504.         return;
  505.     }
  506.  
  507.     ang = player->viewAngles;
  508.     ang.pitch = 0.0f;
  509.     player->SetViewAngles( ang );
  510. }
  511.  
  512. /*
  513. ==================
  514. Cmd_God_f
  515.  
  516. Sets client to godmode
  517.  
  518. argv(0) god
  519. ==================
  520. */
  521. void Cmd_God_f( const idCmdArgs &args ) {
  522.     char        *msg;
  523.     idPlayer    *player;
  524.  
  525.     player = gameLocal.GetLocalPlayer();
  526.     if ( !player || !gameLocal.CheatsOk() ) {
  527.         return;
  528.     }
  529.  
  530.     if ( player->godmode ) {
  531.         player->godmode = false;
  532.         msg = "godmode OFF\n";
  533.     } else {
  534.         player->godmode = true;
  535.         msg = "godmode ON\n";
  536.     }
  537.  
  538.     gameLocal.Printf( "%s", msg );
  539. }
  540.  
  541. /*
  542. ==================
  543. Cmd_Undying_f
  544.  
  545. Sets client to undying
  546.  
  547. argv(0) undying
  548. ==================
  549. */
  550. void Cmd_Undying_f( const idCmdArgs &args ) {
  551.     char        *msg;
  552.     idPlayer    *player;
  553.  
  554.     player = gameLocal.GetLocalPlayer();
  555.     if ( !player || !gameLocal.CheatsOk() ) {
  556.         return;
  557.     }
  558.  
  559.     if ( player->undying ) {
  560.         player->undying = false;
  561.         msg = "undying OFF\n";
  562.     } else {
  563.         player->undying = true;
  564.         msg = "undying ON\n";
  565.     }
  566.  
  567.     gameLocal.Printf( "%s", msg );
  568. }
  569.  
  570. /*
  571. ==================
  572. Cmd_Notarget_f
  573.  
  574. Sets client to notarget
  575.  
  576. argv(0) notarget
  577. ==================
  578. */
  579. void Cmd_Notarget_f( const idCmdArgs &args ) {
  580.     char        *msg;
  581.     idPlayer    *player;
  582.  
  583.     player = gameLocal.GetLocalPlayer();
  584.     if ( !player || !gameLocal.CheatsOk() ) {
  585.         return;
  586.     }
  587.  
  588.     if ( player->fl.notarget ) {
  589.         player->fl.notarget = false;
  590.         msg = "notarget OFF\n";
  591.     } else {
  592.         player->fl.notarget = true;
  593.         msg = "notarget ON\n";
  594.     }
  595.  
  596.     gameLocal.Printf( "%s", msg );
  597. }
  598.  
  599. /*
  600. ==================
  601. Cmd_Noclip_f
  602.  
  603. argv(0) noclip
  604. ==================
  605. */
  606. void Cmd_Noclip_f( const idCmdArgs &args ) {
  607.     char        *msg;
  608.     idPlayer    *player;
  609.  
  610.     player = gameLocal.GetLocalPlayer();
  611.     if ( !player || !gameLocal.CheatsOk() ) {
  612.         return;
  613.     }
  614.  
  615.     if ( player->noclip ) {
  616.         msg = "noclip OFF\n";
  617.     } else {
  618.         msg = "noclip ON\n";
  619.     }
  620.     player->noclip = !player->noclip;
  621.  
  622.     gameLocal.Printf( "%s", msg );
  623. }
  624.  
  625. /*
  626. =================
  627. Cmd_Kill_f
  628. =================
  629. */
  630. void Cmd_Kill_f( const idCmdArgs &args ) {
  631.     idPlayer    *player;
  632.  
  633.     if ( gameLocal.isMultiplayer ) {
  634.         if ( gameLocal.isClient ) {
  635.             idBitMsg    outMsg;
  636.             byte        msgBuf[ MAX_GAME_MESSAGE_SIZE ];
  637.             outMsg.Init( msgBuf, sizeof( msgBuf ) );
  638.             outMsg.WriteByte( GAME_RELIABLE_MESSAGE_KILL );
  639.             networkSystem->ClientSendReliableMessage( outMsg );
  640.         } else {
  641.             player = gameLocal.GetClientByCmdArgs( args );
  642.             if ( !player ) {
  643.                 gameLocal.Printf( "kill <client nickname> or kill <client index>\n" );
  644.                 return;
  645.             }
  646.             player->Kill( false, false );
  647. // RAVEN BEGIN
  648. // rhummer: localized this string.. (killed client)
  649.             cmdSystem->BufferCommandText( CMD_EXEC_NOW, va( "say %s %d '%s^0'\n", common->GetLocalizedString( "#str_108022" ), player->entityNumber, gameLocal.userInfo[ player->entityNumber ].GetString( "ui_name" ) ) );
  650. // RAVEN END
  651.         }
  652.     } else {
  653.         player = gameLocal.GetLocalPlayer();
  654.         if ( !player ) {
  655.             return;
  656.         }
  657.         player->Kill( false, false );
  658.     }
  659. }
  660.  
  661. // RAVEN BEGIN
  662. // bdube: jump points
  663. /*
  664. =================
  665. Cmd_DebugJump_f
  666. =================
  667. */
  668. void Cmd_DebugJump_f( const idCmdArgs &args ) {
  669.     if (args.Argc() > 1) {
  670.         // going to a specific jump point as specified by second argument
  671.         gameDebug.JumpTo ( args.Argv( 1 ) );
  672.     } else {
  673.         // just go to next jump point as specified
  674.         gameDebug.JumpNext ( );
  675.     }
  676. }
  677.  
  678. /*
  679. =================
  680. Cmd_DebugNextJumpPoint_f
  681. =================
  682. */
  683. void Cmd_DebugNextJumpPoint_f( const idCmdArgs &args ) {     
  684.     // just go to next jump point as specified
  685.     gameDebug.JumpNext ( );
  686. }
  687.  
  688. /*
  689. =================
  690. Cmd_DebugPrevJumpPoint_f
  691. =================
  692. */
  693. void Cmd_DebugPrevJumpPoint_f( const idCmdArgs &args ) {
  694.     // just go to previous jump point as specified
  695.     gameDebug.JumpPrev ( );
  696. }
  697.  
  698. /*
  699. =================
  700. Cmd_AASExtractTactical_f
  701. =================
  702. */
  703. void Cmd_AASExtractTactical_f( const idCmdArgs &args ) {
  704.     if (gameLocal.GetLocalPlayer())
  705.     {
  706.         gameLocal.GetLocalPlayer()->aasSensor->SearchDebug();
  707.     }
  708. }
  709.  
  710. /*
  711. =================
  712. Cmd_CallScriptFunc_f
  713. =================
  714. */
  715. void Cmd_CallScriptFunc_f( const idCmdArgs& args ) {
  716.     if( args.Argc() <= 1 ) {
  717.         gameLocal.Printf( "usage: call <retKey> FuncName <parm1> <Parm2>...\n" );
  718.         return;
  719.     }
  720.  
  721.     idDict returnDict;
  722.     rvScriptFuncUtility util;
  723.  
  724.     if( !util.Init(args) ) {
  725.         return;
  726.     }
  727.  
  728.     util.CallFunc( &returnDict );
  729.  
  730.     if( util.ReturnsAVal() && util.GetReturnKey() && util.GetReturnKey()[0] ) {
  731.         gameLocal.Printf( "%s: %s\n", util.GetReturnKey(), returnDict.GetString(util.GetReturnKey()) );
  732.     }
  733. }
  734.  
  735. void Cmd_SetPlayerGravity_f( const idCmdArgs& args ) {
  736.     if( args.Argc() <= 1 ) {
  737.         gameLocal.Printf( "usage: setPlayerGravity 'x_magnitude y_magnitude z_magnitude\n" );
  738.         return;
  739.     }
  740.  
  741.     idPlayer* player = gameLocal.GetLocalPlayer();
  742.     if( !player ) {
  743.         return;
  744.     }
  745.  
  746.     idVec3 gravity;
  747.     sscanf( args.Argv(1), "%f %f %f", &gravity.x, &gravity.y, &gravity.z );
  748.     player->GetPhysics()->SetGravity( gravity );
  749. }
  750. // RAVEN END
  751.  
  752. /*
  753. =================
  754. Cmd_PlayerModel_f
  755. =================
  756. */
  757. void Cmd_PlayerModel_f( const idCmdArgs &args ) {
  758.     idPlayer    *player;
  759.     const char *name;
  760.     idVec3        pos;
  761.     idAngles    ang;
  762.  
  763.     player = gameLocal.GetLocalPlayer();
  764.     if ( !player || !gameLocal.CheatsOk() ) {
  765.         return;
  766.     }
  767.  
  768.     if ( args.Argc() < 2 ) {
  769.         gameLocal.Printf( "usage: playerModel <modelname>\n" );
  770.         return;
  771.     }
  772.  
  773.     name = args.Argv( 1 );
  774.     player->spawnArgs.Set( "model", name );
  775.  
  776.     pos = player->GetPhysics()->GetOrigin();
  777.     ang = player->viewAngles;
  778.     player->SpawnToPoint( pos, ang );
  779. }
  780.  
  781. /*
  782. ==================
  783. Cmd_Say
  784. ==================
  785. */
  786. static void Cmd_Say( bool team, const idCmdArgs &args ) {
  787.     const char *name;
  788.     idStr text;
  789.     const char *cmd = team ? "sayTeam" : "say" ;
  790.  
  791.     if ( !gameLocal.isMultiplayer ) {
  792.         gameLocal.Printf( "%s can only be used in a multiplayer game\n", cmd );
  793.         return;
  794.     }
  795.  
  796.     if ( args.Argc() < 2 ) {
  797.         gameLocal.Printf( "usage: %s <text>\n", cmd );
  798.         return;
  799.     }
  800.  
  801.     text = args.Args();
  802. // RAVEN BEGIN
  803. // bdube: make sure text was specified
  804.     if ( text.Length() == 0 ) {
  805.         gameLocal.Printf( "usage: %s <text>\n", cmd );
  806.         return;
  807.     }
  808.  
  809. // asalmon: check to see if the text passes the live decency standard
  810. #ifdef _XENON
  811.     if(!Sys_VerifyString(text.c_str()))
  812.     {
  813.         gameLocal.Printf( "Your message did not pass Xbox decency standards\n");
  814.         return;
  815.     }
  816. #endif
  817.  
  818.  
  819. // ddynerman: team speak only in team games
  820.     if ( team && !gameLocal.IsTeamGame() ) {
  821.         team = false;
  822.     }
  823. // RAVEN END
  824.     if ( text[ text.Length() - 1 ] == '\n' ) {
  825.         text[ text.Length() - 1 ] = '\0';
  826.     }
  827.     name = "player";
  828.  
  829.     idPlayer *    player;
  830.  
  831.     // here we need to special case a listen server to use the real client name instead of "server"
  832.     // "server" will only appear on a dedicated server
  833.     if ( gameLocal.isClient || cvarSystem->GetCVarInteger( "net_serverDedicated" ) == 0 ) {
  834.         player = gameLocal.localClientNum >= 0 ? static_cast<idPlayer *>( gameLocal.entities[ gameLocal.localClientNum ] ) : NULL;
  835.         if ( player ) {
  836.             name = player->GetUserInfo()->GetString( "ui_name", "player" );
  837.  
  838. // RAVEN BEGIN
  839. // mekberg: activate the mphud gui so the time is right before receiving the chat message
  840.             if ( player->mphud ) {
  841.                 player->mphud->Activate( true, gameLocal.time );
  842.             }
  843.         }
  844. // RAVEN END
  845.     } else {
  846.         name = "server";
  847.     }
  848.  
  849.     if ( gameLocal.isClient ) {
  850.         idBitMsg    outMsg;
  851.         byte        msgBuf[ 256 ];
  852.         outMsg.Init( msgBuf, sizeof( msgBuf ) );
  853.         outMsg.WriteByte( team ? GAME_RELIABLE_MESSAGE_TCHAT : GAME_RELIABLE_MESSAGE_CHAT );
  854.         outMsg.WriteString( name );
  855.         outMsg.WriteString( text );
  856.         outMsg.WriteString( "" );
  857.         networkSystem->ClientSendReliableMessage( outMsg );
  858.     } else {
  859.         gameLocal.mpGame.ProcessChatMessage( gameLocal.localClientNum, team, name, text, NULL );
  860.     }
  861. }
  862.  
  863. /*
  864. ==================
  865. Cmd_Say_f
  866. ==================
  867. */
  868. static void Cmd_Say_f( const idCmdArgs &args ) {
  869.     Cmd_Say( false, args );
  870. }
  871.  
  872. /*
  873. ==================
  874. Cmd_SayTeam_f
  875. ==================
  876. */
  877. static void Cmd_SayTeam_f( const idCmdArgs &args ) {
  878.     Cmd_Say( true, args );
  879. }
  880.  
  881. /*
  882. ==================
  883. Cmd_AddChatLine_f
  884. ==================
  885. */
  886. static void Cmd_AddChatLine_f( const idCmdArgs &args ) {
  887.     gameLocal.mpGame.AddChatLine( args.Argv( 1 ) );
  888. }
  889.  
  890. /*
  891. ==================
  892. Cmd_Kick_f
  893. ==================
  894. */
  895. static void Cmd_Kick_f( const idCmdArgs &args ) {
  896.     idPlayer *player;
  897.  
  898.     if ( !gameLocal.isMultiplayer ) {
  899.         gameLocal.Printf( "kick can only be used in a multiplayer game\n" );
  900.         return;
  901.     }
  902.  
  903.     if ( gameLocal.isClient ) {
  904.         gameLocal.Printf( "You have no such power. This is a server command\n" );
  905.         return;
  906.     }
  907.  
  908.     player = gameLocal.GetClientByCmdArgs( args );
  909.     if ( !player ) {
  910.         gameLocal.Printf( "usage: kick <client nickname> or kick <client index>\n" );
  911.         return;
  912.     }
  913.     cmdSystem->BufferCommandText( CMD_EXEC_NOW, va( "say kicking out client %d '%s^0'\n", player->entityNumber, gameLocal.userInfo[ player->entityNumber ].GetString( "ui_name" ) ) );
  914.     cmdSystem->BufferCommandText( CMD_EXEC_NOW, va( "kick %d\n", player->entityNumber ) );
  915. }
  916.  
  917. /*
  918. ==================
  919. Cmd_GetViewpos_f
  920. ==================
  921. */
  922. void Cmd_GetViewpos_f( const idCmdArgs &args ) {
  923.     idPlayer    *player;
  924.     idVec3        origin;
  925.     idMat3        axis;
  926.  
  927.     player = gameLocal.GetLocalPlayer();
  928.     if ( !player ) {
  929.         return;
  930.     }
  931.  
  932.     const renderView_t *view = player->GetRenderView();
  933.     if ( view ) {
  934.         gameLocal.Printf( "(%s) %.1f\n", view->vieworg.ToString(), view->viewaxis[0].ToYaw() );
  935.     } else {
  936.         player->GetViewPos( origin, axis );
  937.         gameLocal.Printf( "(%s) %.1f\n", origin.ToString(), axis[0].ToYaw() );
  938.     }
  939. }
  940.  
  941. /*
  942. =================
  943. Cmd_SetViewpos_f
  944. =================
  945. */
  946. void Cmd_SetViewpos_f( const idCmdArgs &args ) {
  947.     idVec3        origin;
  948.     idAngles    angles;
  949.     int            i;
  950.     idPlayer    *player;
  951.  
  952.     player = gameLocal.GetLocalPlayer();
  953.     if ( !player || !gameLocal.CheatsOk() ) {
  954.         return;
  955.     }
  956.  
  957.     if ( ( args.Argc() != 4 ) && ( args.Argc() != 5 ) ) {
  958.         gameLocal.Printf( "usage: setviewpos <x> <y> <z> <yaw>\n" );
  959.         return;
  960.     }
  961.  
  962.     angles.Zero();
  963.     if ( args.Argc() == 5 ) {
  964.         angles.yaw = atof( args.Argv( 4 ) );
  965.     }
  966.  
  967.     for ( i = 0 ; i < 3 ; i++ ) {
  968.         origin[i] = atof( args.Argv( i + 1 ) );
  969.     }
  970.     origin.z -= pm_normalviewheight.GetFloat() - 0.25f;
  971.  
  972.     player->Teleport( origin, angles, NULL );
  973. }
  974.  
  975. /*
  976. =================
  977. Cmd_Teleport_f
  978. =================
  979. */
  980. void Cmd_Teleport_f( const idCmdArgs &args ) {
  981.     idVec3        origin;
  982.     idAngles    angles;
  983.     idPlayer    *player;
  984.     idEntity    *ent;
  985.  
  986.     player = gameLocal.GetLocalPlayer();
  987.     if ( !player || !gameLocal.CheatsOk() ) {
  988.         return;
  989.     }
  990.  
  991.     if ( args.Argc() != 2 ) {
  992.         gameLocal.Printf( "usage: teleport <name of entity to teleport to>\n" );
  993.         return;
  994.     }
  995.  
  996.     ent = gameLocal.FindEntity( args.Argv( 1 ) );
  997.     if ( !ent ) {
  998.         gameLocal.Printf( "entity not found\n" );
  999.         return;
  1000.     }
  1001.  
  1002.     angles.Zero();
  1003.     angles.yaw = ent->GetPhysics()->GetAxis()[ 0 ].ToYaw();
  1004.     origin = ent->GetPhysics()->GetOrigin();
  1005.  
  1006.     player->Teleport( origin, angles, ent );
  1007. }
  1008.  
  1009. /*
  1010. =================
  1011. Cmd_Trigger_f
  1012. =================
  1013. */
  1014. void Cmd_Trigger_f( const idCmdArgs &args ) {
  1015.     idVec3        origin;
  1016.     idAngles    angles;
  1017.     idPlayer    *player;
  1018.     idEntity    *ent;
  1019.  
  1020.     player = gameLocal.GetLocalPlayer();
  1021.     if ( !player || !gameLocal.CheatsOk() ) {
  1022.         return;
  1023.     }
  1024.  
  1025.     if ( args.Argc() != 2 ) {
  1026.         gameLocal.Printf( "usage: trigger <name of entity to trigger>\n" );
  1027.         return;
  1028.     }
  1029.  
  1030.     ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1031.     if ( !ent ) {
  1032.         gameLocal.Printf( "entity not found\n" );
  1033.         return;
  1034.     }
  1035.  
  1036.     ent->Signal( SIG_TRIGGER );
  1037.     ent->ProcessEvent( &EV_Activate, player );
  1038.     ent->TriggerGuis();
  1039. }
  1040.  
  1041. /*
  1042. ===================
  1043. Cmd_Spawn_f
  1044. ===================
  1045. */
  1046. void Cmd_Spawn_f( const idCmdArgs &args ) {
  1047. #ifndef _MPBETA
  1048.     const char *key, *value;
  1049.     int            i;
  1050.     float        yaw;
  1051.     idVec3        org;
  1052.     idPlayer    *player;
  1053.     idDict        dict;
  1054.  
  1055.     player = gameLocal.GetLocalPlayer();
  1056.     if ( !player || !gameLocal.CheatsOk( false ) ) {
  1057.         return;
  1058.     }
  1059.  
  1060.     if ( args.Argc() & 1 ) {    // must always have an even number of arguments
  1061.         gameLocal.Printf( "usage: spawn classname [key/value pairs]\n" );
  1062.         return;
  1063.     }
  1064.  
  1065.     yaw = player->viewAngles.yaw;
  1066.  
  1067.     value = args.Argv( 1 );
  1068.     dict.Set( "classname", value );
  1069.     dict.Set( "angle", va( "%f", yaw + 180 ) );
  1070.  
  1071.     org = player->GetPhysics()->GetOrigin() + idAngles( 0, yaw, 0 ).ToForward() * 80 + idVec3( 0, 0, 1 );
  1072.     dict.Set( "origin", org.ToString() );
  1073.  
  1074.     for( i = 2; i < args.Argc() - 1; i += 2 ) {
  1075.  
  1076.         key = args.Argv( i );
  1077.         value = args.Argv( i + 1 );
  1078.  
  1079.         dict.Set( key, value );
  1080.     }
  1081.  
  1082. // RAVEN BEGIN
  1083. // kfuller: want to know the name of the entity I spawned
  1084.     idEntity *newEnt = NULL;
  1085.     gameLocal.SpawnEntityDef( dict, &newEnt );
  1086.  
  1087.     if (newEnt)    {
  1088.         gameLocal.Printf("spawned entity '%s'\n", newEnt->name.c_str());
  1089.     }
  1090. // RAVEN END
  1091. #endif // !_MPBETA
  1092. }
  1093.  
  1094. // RAVEN BEGIN
  1095. // ddynerman: MP spawning command for performance testing
  1096. /*
  1097. ===================
  1098. Cmd_EvaluateMPPerformance_f
  1099. ===================
  1100. */
  1101. void Cmd_EvaluateMPPerformance_f( const idCmdArgs &args ) {
  1102.     float        yaw;
  1103.     idVec3        org;
  1104.     idPlayer    *player;
  1105.     idDict        dict;
  1106.  
  1107.     player = gameLocal.GetLocalPlayer();
  1108.     if ( !player || !gameLocal.CheatsOk( false ) ) {
  1109.         return;
  1110.     }
  1111.  
  1112.     int num = 15;
  1113.  
  1114.     if ( args.Argc() > 1 ) {
  1115.         num = atoi( args.Argv( 1 ) );
  1116.     }
  1117.  
  1118.     float angleStep = 360.0f / num;
  1119.  
  1120.     const char* className = "char_marine";
  1121.     
  1122.     yaw = player->viewAngles.yaw;
  1123.  
  1124.     for( int i = 0; i < num; i++ ) {
  1125.         dict.Set( "classname", className );
  1126.         dict.Set( "angle", va( "%f", yaw + 180 ) );
  1127.  
  1128.         org = player->GetPhysics()->GetOrigin() + idAngles( 0, yaw + (i * angleStep), 0 ).ToForward() * 120 + idVec3( 0, 0, 1 );
  1129.         dict.Set( "origin", org.ToString() );
  1130.  
  1131.         idEntity *newEnt = NULL;
  1132.         gameLocal.SpawnEntityDef( dict, &newEnt );
  1133.  
  1134.         if (newEnt)    {
  1135.             gameLocal.Printf("spawned entity '%s'\n", newEnt->name.c_str());
  1136.         }
  1137.     }
  1138. }
  1139. // RAVEN END
  1140.  
  1141.  
  1142. /*
  1143. ==================
  1144. Cmd_Damage_f
  1145.  
  1146. Damages the specified entity
  1147. ==================
  1148. */
  1149. void Cmd_Damage_f( const idCmdArgs &args ) {
  1150.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  1151.         return;
  1152.     }
  1153.     if ( args.Argc() != 3 ) {
  1154.         gameLocal.Printf( "usage: damage <name of entity to damage> <damage>\n" );
  1155.         return;
  1156.     }
  1157.  
  1158.     idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1159.     if ( !ent ) {
  1160.         gameLocal.Printf( "entity not found\n" );
  1161.         return;
  1162.     }
  1163.  
  1164.     ent->Damage( gameLocal.world, gameLocal.world, idVec3( 0, 0, 1 ), "damage_moverCrush", atoi( args.Argv( 2 ) ), INVALID_JOINT );
  1165. }
  1166.  
  1167.  
  1168. /*
  1169. ==================
  1170. Cmd_Flashlight_f
  1171.  
  1172. Toggles flashlight on specified entity
  1173. ==================
  1174. */
  1175. void Cmd_Flashlight_f( const idCmdArgs &args ) {
  1176.     if ( gameLocal.IsMultiplayer() || !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  1177.         return;
  1178.     }
  1179.     if ( args.Argc() != 3 ) {
  1180.         gameLocal.Printf( "usage: flashight <name of entity to damage> <0 = off, 1 = on>\n" );
  1181.         return;
  1182.     }
  1183.  
  1184.     idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1185.     if ( !ent || !ent->IsType( idActor::GetClassType() ) ) {
  1186.         gameLocal.Printf( "entity not found or not an actor\n" );
  1187.         return;
  1188.     }
  1189.     ent->ProcessEvent( &AI_Flashlight, atoi( args.Argv( 2 ) ) );
  1190. }
  1191.  
  1192. /*
  1193. ==================
  1194. Cmd_Remove_f
  1195.  
  1196. Removes the specified entity
  1197. ==================
  1198. */
  1199. void Cmd_Remove_f( const idCmdArgs &args ) {
  1200.     if ( !gameLocal.GetLocalPlayer() || !gameLocal.CheatsOk( false ) ) {
  1201.         return;
  1202.     }
  1203.     if ( args.Argc() != 2 ) {
  1204.         gameLocal.Printf( "usage: remove <name of entity to remove>\n" );
  1205.         return;
  1206.     }
  1207.  
  1208.     idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1209.     if ( !ent ) {
  1210.         gameLocal.Printf( "entity not found\n" );
  1211.         return;
  1212.     }
  1213.  
  1214.     delete ent;
  1215. }
  1216.  
  1217. /*
  1218. ==================
  1219. Cmd_AI_DebugFilter_f
  1220.  
  1221. Makes the targeted entity the only one ai_debugMove & ai_debugTactical cares about
  1222. ==================
  1223. */
  1224. void Cmd_AI_DebugFilter_f( const idCmdArgs &args ) {
  1225.     idPlayer* player = gameLocal.GetLocalPlayer();
  1226.     if ( !player ) {
  1227.         return;
  1228.     }
  1229.     idEntity *ent = NULL;
  1230.     if ( args.Argc() != 2 ) 
  1231.     {
  1232.         //trace ahead
  1233.         trace_t    trace;
  1234.         idVec3 start = player->GetEyePosition();
  1235.         idVec3 end = start + player->viewAngles.ToForward() * 2048.0f;
  1236.         gameLocal.TracePoint( player, trace, start, end, MASK_SHOT_RENDERMODEL, player );
  1237.         ent = gameLocal.GetTraceEntity( trace );
  1238.     }
  1239.     else
  1240.     {    
  1241.         idEntity *ent = gameLocal.FindEntity( args.Argv( 1 ) );
  1242.         if ( !ent ) {
  1243.             gameLocal.Printf( "entity not found\n" );
  1244.             return;
  1245.         }
  1246.     }
  1247.  
  1248.     if ( !ent || !ent->IsType( idAI::GetClassType() ) ) {
  1249.         ai_debugFilterString.SetString( "" );
  1250.     } else {
  1251.         ai_debugFilterString.SetString( ent->GetName() );
  1252.     }
  1253. }
  1254.  
  1255. /*
  1256. ===================
  1257. Cmd_TestLight_f
  1258. ===================
  1259. */
  1260. void Cmd_TestLight_f( const idCmdArgs &args ) {
  1261.     int            i;
  1262.     idStr        filename;
  1263.     const char *key, *value, *name = NULL;
  1264.     idPlayer *    player;
  1265.     idDict        dict;
  1266.  
  1267.     player = gameLocal.GetLocalPlayer();
  1268.     if ( !player || !gameLocal.CheatsOk( false ) ) {
  1269.         return;
  1270.     }
  1271.  
  1272.     renderView_t    *rv = player->GetRenderView();
  1273.  
  1274.     float fov = idMath::Tan( idMath::M_DEG2RAD * rv->fov_x / 2 );
  1275.  
  1276.     dict.SetMatrix( "rotation", mat3_default );
  1277.     dict.SetVector( "origin", rv->vieworg );
  1278.     dict.SetVector( "light_target", rv->viewaxis[0] );
  1279.     dict.SetVector( "light_right", rv->viewaxis[1] * -fov );
  1280.     dict.SetVector( "light_up", rv->viewaxis[2] * fov );
  1281.     dict.SetVector( "light_start", rv->viewaxis[0] * 16 );
  1282.     dict.SetVector( "light_end", rv->viewaxis[0] * 1000 );
  1283.  
  1284.     if ( args.Argc() >= 2 ) {
  1285.         value = args.Argv( 1 );
  1286.         filename = args.Argv(1);
  1287.         filename.DefaultFileExtension( ".tga" );
  1288.         dict.Set( "texture", filename );
  1289.     }
  1290.  
  1291.     dict.Set( "classname", "light" );
  1292.     for( i = 2; i < args.Argc() - 1; i += 2 ) {
  1293.  
  1294.         key = args.Argv( i );
  1295.         value = args.Argv( i + 1 );
  1296.  
  1297.         dict.Set( key, value );
  1298.     }
  1299.  
  1300.     for ( i = 0; i < MAX_GENTITIES; i++ ) {
  1301.         name = va( "spawned_light_%d", i );        // not just light_, or it might pick up a prelight shadow
  1302.         if ( !gameLocal.FindEntity( name ) ) {
  1303.             break;
  1304.         }
  1305.     }
  1306.     dict.Set( "name", name );
  1307.  
  1308.     gameLocal.SpawnEntityDef( dict );
  1309.  
  1310.     gameLocal.Printf( "Created new light\n");
  1311. }
  1312.  
  1313. /*
  1314. ===================
  1315. Cmd_TestPointLight_f
  1316. ===================
  1317. */
  1318. void Cmd_TestPointLight_f( const idCmdArgs &args ) {
  1319.     const char *key, *value, *name = NULL;
  1320.     int            i;
  1321.     idPlayer    *player;
  1322.     idDict        dict;
  1323.  
  1324.     player = gameLocal.GetLocalPlayer();
  1325.     if ( !player || !gameLocal.CheatsOk( false ) ) {
  1326.         return;
  1327.     }
  1328.  
  1329.     dict.SetVector("origin", player->GetRenderView()->vieworg);
  1330.  
  1331.     if ( args.Argc() >= 2 ) {
  1332.         value = args.Argv( 1 );
  1333.         dict.Set("light", value);
  1334.     } else {
  1335.         dict.Set("light", "300");
  1336.     }
  1337.  
  1338.     dict.Set( "classname", "light" );
  1339.     for( i = 2; i < args.Argc() - 1; i += 2 ) {
  1340.  
  1341.         key = args.Argv( i );
  1342.         value = args.Argv( i + 1 );
  1343.  
  1344.         dict.Set( key, value );
  1345.     }
  1346.  
  1347.     for ( i = 0; i < MAX_GENTITIES; i++ ) {
  1348.         name = va( "light_%d", i );
  1349.         if ( !gameLocal.FindEntity( name ) ) {
  1350.             break;
  1351.         }
  1352.     }
  1353.     dict.Set( "name", name );
  1354.  
  1355.     gameLocal.SpawnEntityDef( dict );
  1356.  
  1357.     gameLocal.Printf( "Created new point light\n");
  1358. }
  1359.  
  1360. /*
  1361. ==================
  1362. Cmd_PopLight_f
  1363. ==================
  1364. */
  1365. void Cmd_PopLight_f( const idCmdArgs &args ) {
  1366.     idEntity    *ent;
  1367.     idMapEntity *mapEnt;
  1368.     idMapFile    *mapFile = gameLocal.GetLevelMap();
  1369.     idLight        *lastLight;
  1370.     int            last;
  1371.  
  1372.     if ( !gameLocal.CheatsOk() ) {
  1373.         return;
  1374.     }
  1375.  
  1376.     bool removeFromMap = ( args.Argc() > 1 );
  1377.  
  1378.     lastLight = NULL;
  1379.     last = -1;
  1380.     for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  1381. // RAVEN BEGIN
  1382. // jnewquist: Use accessor for static class type 
  1383.         if ( !ent->IsType( idLight::GetClassType() ) ) {
  1384. // RAVEN END
  1385.             continue;
  1386.         }
  1387.  
  1388.         if ( gameLocal.spawnIds[ ent->entityNumber ] > last ) {
  1389.             last = gameLocal.spawnIds[ ent->entityNumber ];
  1390.             lastLight = static_cast<idLight*>( ent );
  1391.         }
  1392.     }
  1393.  
  1394.     if ( lastLight ) {
  1395.         // find map file entity
  1396.         mapEnt = mapFile->FindEntity( lastLight->name );
  1397.  
  1398.         if ( removeFromMap && mapEnt ) {
  1399.             mapFile->RemoveEntity( mapEnt );
  1400.         }
  1401.         gameLocal.Printf( "Removing light %i\n", lastLight->GetLightDefHandle() );
  1402.         delete lastLight;
  1403.     } else {
  1404.         gameLocal.Printf( "No lights to clear.\n" );
  1405.     }
  1406.  
  1407. }
  1408.  
  1409. /*
  1410. ====================
  1411. Cmd_ClearLights_f
  1412. ====================
  1413. */
  1414. void Cmd_ClearLights_f( const idCmdArgs &args ) {
  1415.     idEntity *ent;
  1416.     idEntity *next;
  1417.     idLight *light;
  1418.     idMapEntity *mapEnt;
  1419.     idMapFile *mapFile = gameLocal.GetLevelMap();
  1420.  
  1421.     bool removeFromMap = ( args.Argc() > 1 );
  1422.  
  1423.     gameLocal.Printf( "Clearing all lights.\n" );
  1424.     for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = next ) {
  1425.         next = ent->spawnNode.Next();
  1426. // RAVEN BEGIN
  1427. // jnewquist: Use accessor for static class type 
  1428.         if ( !ent->IsType( idLight::GetClassType() ) ) {
  1429. // RAVEN END
  1430.             continue;
  1431.         }
  1432.  
  1433.         light = static_cast<idLight*>( ent );
  1434.         mapEnt = mapFile->FindEntity( light->name );
  1435.  
  1436.         if ( removeFromMap && mapEnt ) {
  1437.             mapFile->RemoveEntity( mapEnt );
  1438.         }
  1439.  
  1440.         delete light;
  1441.     }
  1442. }
  1443.  
  1444. // RAVEN BEGIN
  1445. // bdube: not using id effects
  1446. /*
  1447. ==================
  1448. Cmd_TestFx_f
  1449. ==================
  1450. void Cmd_TestFx_f( const idCmdArgs &args ) {
  1451.     idVec3        offset;
  1452.     const char *name;
  1453.     idPlayer *    player;
  1454.     idDict        dict;
  1455.  
  1456.     player = gameLocal.GetLocalPlayer();
  1457.     if ( !player || !gameLocal.CheatsOk() ) {
  1458.         return;
  1459.     }
  1460.  
  1461.     // delete the testModel if active
  1462.     if ( gameLocal.testFx ) {
  1463.         delete gameLocal.testFx;
  1464.         gameLocal.testFx = NULL;
  1465.     }
  1466.  
  1467.     if ( args.Argc() < 2 ) {
  1468.         return;
  1469.     }
  1470.  
  1471.     name = args.Argv( 1 );
  1472.  
  1473.     offset = player->GetPhysics()->GetOrigin() + player->viewAngles.ToForward() * 100.0f;
  1474.  
  1475.     dict.Set( "origin", offset.ToString() );
  1476.     dict.Set( "test", "1");
  1477.     dict.Set( "fx", name );
  1478.     gameLocal.testFx = ( idEntityFx * )gameLocal.SpawnEntityType( idEntityFx::Type, &dict );
  1479. }
  1480. */
  1481. // RAVEN END
  1482.  
  1483. #define MAX_DEBUGLINES    128
  1484.  
  1485. typedef struct {
  1486.     bool used;
  1487.     idVec3 start, end;
  1488.     int color;
  1489.     bool blink;
  1490.     bool arrow;
  1491. } gameDebugLine_t;
  1492.  
  1493. gameDebugLine_t debugLines[MAX_DEBUGLINES];
  1494.  
  1495. /*
  1496. ==================
  1497. Cmd_AddDebugLine_f
  1498. ==================
  1499. */
  1500. static void Cmd_AddDebugLine_f( const idCmdArgs &args ) {
  1501.     int i, argNum;
  1502.     const char *value;
  1503.  
  1504.     if ( !gameLocal.CheatsOk() ) {
  1505.         return;
  1506.     }
  1507.  
  1508.     if ( args.Argc () < 7 ) {
  1509.         gameLocal.Printf( "usage: addline <x y z> <x y z> <color>\n" );
  1510.         return;
  1511.     }
  1512.     for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1513.         if ( !debugLines[i].used ) {
  1514.             break;
  1515.         }
  1516.     }
  1517.     if ( i >= MAX_DEBUGLINES ) {
  1518.         gameLocal.Printf( "no free debug lines\n" );
  1519.         return;
  1520.     }
  1521.     value = args.Argv( 0 );
  1522.     if ( !idStr::Icmp( value, "addarrow" ) ) {
  1523.         debugLines[i].arrow = true;
  1524.     } else {
  1525.         debugLines[i].arrow = false;
  1526.     }
  1527.     debugLines[i].used = true;
  1528.     debugLines[i].blink = false;
  1529.     argNum = 1;
  1530.     debugLines[i].start.x = Cmd_GetFloatArg( args, argNum );
  1531.     debugLines[i].start.y = Cmd_GetFloatArg( args, argNum );
  1532.     debugLines[i].start.z = Cmd_GetFloatArg( args, argNum );
  1533.     debugLines[i].end.x = Cmd_GetFloatArg( args, argNum );
  1534.     debugLines[i].end.y = Cmd_GetFloatArg( args, argNum );
  1535.     debugLines[i].end.z = Cmd_GetFloatArg( args, argNum );
  1536.     debugLines[i].color = Cmd_GetFloatArg( args, argNum );
  1537. }
  1538.  
  1539. /*
  1540. ==================
  1541. Cmd_RemoveDebugLine_f
  1542. ==================
  1543. */
  1544. static void Cmd_RemoveDebugLine_f( const idCmdArgs &args ) {
  1545.     int i, num;
  1546.     const char *value;
  1547.  
  1548.     if ( !gameLocal.CheatsOk() ) {
  1549.         return;
  1550.     }
  1551.  
  1552.     if ( args.Argc () < 2 ) {
  1553.         gameLocal.Printf( "usage: removeline <num>\n" );
  1554.         return;
  1555.     }
  1556.     value = args.Argv( 1 );
  1557.     num = atoi(value);
  1558.     for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1559.         if ( debugLines[i].used ) {
  1560.             if ( --num < 0 ) {
  1561.                 break;
  1562.             }
  1563.         }
  1564.     }
  1565.     if ( i >= MAX_DEBUGLINES ) {
  1566.         gameLocal.Printf( "line not found\n" );
  1567.         return;
  1568.     }
  1569.     debugLines[i].used = false;
  1570. }
  1571.  
  1572. /*
  1573. ==================
  1574. Cmd_BlinkDebugLine_f
  1575. ==================
  1576. */
  1577. static void Cmd_BlinkDebugLine_f( const idCmdArgs &args ) {
  1578.     int i, num;
  1579.     const char *value;
  1580.  
  1581.     if ( !gameLocal.CheatsOk() ) {
  1582.         return;
  1583.     }
  1584.  
  1585.     if ( args.Argc () < 2 ) {
  1586.         gameLocal.Printf( "usage: blinkline <num>\n" );
  1587.         return;
  1588.     }
  1589.     value = args.Argv( 1 );
  1590.     num = atoi( value );
  1591.     for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1592.         if ( debugLines[i].used ) {
  1593.             if ( --num < 0 ) {
  1594.                 break;
  1595.             }
  1596.         }
  1597.     }
  1598.     if ( i >= MAX_DEBUGLINES ) {
  1599.         gameLocal.Printf( "line not found\n" );
  1600.         return;
  1601.     }
  1602.     debugLines[i].blink = !debugLines[i].blink;
  1603. }
  1604.  
  1605. /*
  1606. ==================
  1607. PrintFloat
  1608. ==================
  1609. */
  1610. static void PrintFloat( float f ) {
  1611.     char buf[128], i;
  1612.  
  1613.     for ( i = sprintf( buf, "%3.2f", f ); i < 7; i++ ) {
  1614.         buf[i] = ' ';
  1615.     }
  1616.     buf[i] = '\0';
  1617.     gameLocal.Printf( buf );
  1618. }
  1619.  
  1620. /*
  1621. ==================
  1622. Cmd_ListDebugLines_f
  1623. ==================
  1624. */
  1625. static void Cmd_ListDebugLines_f( const idCmdArgs &args ) {
  1626.     int i, num;
  1627.  
  1628.     if ( !gameLocal.CheatsOk() ) {
  1629.         return;
  1630.     }
  1631.  
  1632.     num = 0;
  1633.     gameLocal.Printf( "line num: x1     y1     z1     x2     y2     z2     c  b  a\n" );
  1634.     for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1635.         if ( debugLines[i].used ) {
  1636.             gameLocal.Printf( "line %3d: ", num );
  1637.             PrintFloat( debugLines[i].start.x );
  1638.             PrintFloat( debugLines[i].start.y );
  1639.             PrintFloat( debugLines[i].start.z );
  1640.             PrintFloat( debugLines[i].end.x );
  1641.             PrintFloat( debugLines[i].end.y );
  1642.             PrintFloat( debugLines[i].end.z );
  1643.             gameLocal.Printf( "%d  %d  %d\n", debugLines[i].color, debugLines[i].blink, debugLines[i].arrow );
  1644.             num++;
  1645.         }
  1646.     }
  1647.     if ( !num ) {
  1648.         gameLocal.Printf( "no debug lines\n" );
  1649.     }
  1650. }
  1651.  
  1652. /*
  1653. ==================
  1654. D_DrawDebugLines
  1655. ==================
  1656. */
  1657. void D_DrawDebugLines( void ) {
  1658. // RAVEN BEGIN
  1659. // ddynerman: this eats about 5k us in release
  1660. #ifdef _DEBUG
  1661.     int i;
  1662.     idVec3 forward, right, up, p1, p2;
  1663.     idVec4 color;
  1664.     float l;
  1665.  
  1666.     for ( i = 0; i < MAX_DEBUGLINES; i++ ) {
  1667.         if ( debugLines[i].used ) {
  1668.             if ( !debugLines[i].blink || (gameLocal.time & (1<<9)) ) {
  1669.                 color = idVec4( debugLines[i].color&1, (debugLines[i].color>>1)&1, (debugLines[i].color>>2)&1, 1 );
  1670.                 gameRenderWorld->DebugLine( color, debugLines[i].start, debugLines[i].end );
  1671.                 //
  1672.                 if ( debugLines[i].arrow ) {
  1673.                     // draw a nice arrow
  1674.                     forward = debugLines[i].end - debugLines[i].start;
  1675.                     l = forward.Normalize() * 0.2f;
  1676.                     forward.NormalVectors( right, up);
  1677.  
  1678.                     if ( l > 3.0f ) {
  1679.                         l = 3.0f;
  1680.                     }
  1681.                     p1 = debugLines[i].end - l * forward + (l * 0.4f) * right;
  1682.                     p2 = debugLines[i].end - l * forward - (l * 0.4f) * right;
  1683.                     gameRenderWorld->DebugLine( color, debugLines[i].end, p1 );
  1684.                     gameRenderWorld->DebugLine( color, debugLines[i].end, p2 );
  1685.                     gameRenderWorld->DebugLine( color, p1, p2 );
  1686.                 }
  1687.             }
  1688.         }
  1689.     }
  1690. #else
  1691.     return;
  1692. #endif
  1693. // RAVEN END
  1694. }
  1695.  
  1696. /*
  1697. ==================
  1698. Cmd_ListCollisionModels_f
  1699. ==================
  1700. */
  1701. static void Cmd_ListCollisionModels_f( const idCmdArgs &args ) {
  1702.     if ( !gameLocal.CheatsOk() ) {
  1703.         return;
  1704.     }
  1705.  
  1706.     collisionModelManager->ListModels();
  1707. }
  1708.  
  1709. /*
  1710. ==================
  1711. Cmd_CollisionModelInfo_f
  1712. ==================
  1713. */
  1714. static void Cmd_CollisionModelInfo_f( const idCmdArgs &args ) {
  1715.     const char *value;
  1716.  
  1717.     if ( !gameLocal.CheatsOk() ) {
  1718.         return;
  1719.     }
  1720.  
  1721.     if ( args.Argc () < 2 ) {
  1722.         gameLocal.Printf( "usage: collisionModelInfo <modelNum>\n"
  1723.                     "use 'all' instead of the model number for accumulated info\n" );
  1724.         return;
  1725.     }
  1726.  
  1727.     value = args.Argv( 1 );
  1728.     if ( !idStr::Icmp( value, "all" ) ) {
  1729.         collisionModelManager->ModelInfo( -1 );
  1730.     } else {
  1731.         collisionModelManager->ModelInfo( atoi(value) );
  1732.     }
  1733. }
  1734.  
  1735. /*
  1736. ==================
  1737. Cmd_ExportModels_f
  1738. ==================
  1739. */
  1740. static void Cmd_ExportModels_f( const idCmdArgs &args ) {
  1741.     idModelExport    exporter;
  1742.     idStr            name;
  1743.  
  1744.     // don't allow exporting models when cheats are disabled,
  1745.     // but if we're not in the game, it's ok
  1746.     if ( gameLocal.GetLocalPlayer() && !gameLocal.CheatsOk( false ) ) {
  1747.         return;
  1748.     }
  1749.  
  1750.     if ( args.Argc() < 2 ) {
  1751.         exporter.ExportModels( "def", ".def" );
  1752.     } else {
  1753.         name = args.Argv( 1 );
  1754.         name = "def/" + name;
  1755.         name.DefaultFileExtension( ".def" );
  1756.         exporter.ExportDefFile( name );
  1757.     }
  1758. }
  1759.  
  1760. /*
  1761. ==================
  1762. Cmd_ReexportModels_f
  1763. ==================
  1764. */
  1765. static void Cmd_ReexportModels_f( const idCmdArgs &args ) {
  1766.     idModelExport    exporter;
  1767.     idStr            name;
  1768.  
  1769.     // don't allow exporting models when cheats are disabled,
  1770.     // but if we're not in the game, it's ok
  1771.     if ( gameLocal.GetLocalPlayer() && !gameLocal.CheatsOk( false ) ) {
  1772.         return;
  1773.     }
  1774.  
  1775.     idAnimManager::forceExport = true;
  1776.     if ( args.Argc() < 2 ) {
  1777.         exporter.ExportModels( "def", ".def" );
  1778.     } else {
  1779.         name = args.Argv( 1 );
  1780.         name = "def/" + name;
  1781.         name.DefaultFileExtension( ".def" );
  1782.         exporter.ExportDefFile( name );
  1783.     }
  1784.     idAnimManager::forceExport = false;
  1785. }
  1786.  
  1787. /*
  1788. ==================
  1789. Cmd_ReloadAnims_f
  1790. ==================
  1791. */
  1792. static void Cmd_ReloadAnims_f( const idCmdArgs &args ) {
  1793.  
  1794.     // don't allow reloading anims when cheats are disabled,
  1795.     // but if we're not in the game, it's ok
  1796.     if ( gameLocal.GetLocalPlayer() && !gameLocal.CheatsOk( false ) ) {
  1797.         return;
  1798.     }
  1799.  
  1800. // RAVEN BEGIN
  1801. // mekberg: disable non pre-cached warnings
  1802.     fileSystem->SetIsFileLoadingAllowed( true );
  1803.  
  1804. // jsinger: animationLib changed to a pointer
  1805.     animationLib->ReloadAnims();
  1806.  
  1807. // mekberg: enable non pre-cached warnings
  1808.     fileSystem->SetIsFileLoadingAllowed( false );
  1809. // RAVEN END
  1810. }
  1811.  
  1812. /*
  1813. ==================
  1814. Cmd_ListAnims_f
  1815. ==================
  1816. */
  1817. static void Cmd_ListAnims_f( const idCmdArgs &args ) {
  1818.     idEntity *        ent;
  1819.     int                num;
  1820.     size_t            size;
  1821.     size_t            alloced;
  1822.     idAnimator *    animator;
  1823.     const char *    classname;
  1824.     const idDict *    dict;
  1825.     int                i;
  1826.  
  1827.     if ( args.Argc() > 1 ) {
  1828.         idAnimator animator;
  1829.  
  1830.         classname = args.Argv( 1 );
  1831.  
  1832.         dict = gameLocal.FindEntityDefDict( classname, false );
  1833.         if ( !dict ) {
  1834.             gameLocal.Printf( "Entitydef '%s' not found\n", classname );
  1835.             return;
  1836.         }
  1837.         animator.SetModel( dict->GetString( "model" ) );
  1838.  
  1839.         gameLocal.Printf( "----------------\n" );
  1840.         num = animator.NumAnims();
  1841. // RAVEN BEGIN
  1842. // rjohnson: more output for animators
  1843.         idFile *FH = fileSystem->OpenFileAppend( "animations.txt" );
  1844.         for( i = 0; i < num; i++ ) {
  1845.             for( int j = 0; ; j++ ) {
  1846.                 const char *fileName = animator.AnimMD5Name( i, j );
  1847.  
  1848.                 if ( !fileName[0] ) {
  1849.                     break;
  1850.                 }
  1851.                 gameLocal.Printf( "%s\t%s\n", animator.AnimFullName( i ), animator.AnimMD5Name( i, 0 ) );
  1852.                 if ( FH ) {
  1853.                     FH->Printf( "%s\t%s\n", animator.AnimFullName( i ), animator.AnimMD5Name( i, 0 ) );
  1854.                 }
  1855.             }
  1856.         }
  1857.         gameLocal.Printf( "%d anims\n", num );
  1858.         fileSystem->CloseFile( FH );
  1859. // RAVEN END
  1860.     } else {
  1861. // RAVEN BEGIN
  1862. // jsinger: animationLib changed to a pointer
  1863.         animationLib->ListAnims();
  1864. // RAVEN END
  1865.  
  1866.         size = 0;
  1867.         num = 0;
  1868.         for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
  1869.             animator = ent->GetAnimator();
  1870.             if ( animator ) {
  1871.                 alloced = animator->Allocated();
  1872.                 size += alloced;
  1873.                 num++;
  1874.             }
  1875.         }
  1876.  
  1877.         gameLocal.Printf( "%d memory used in %d entity animators\n", size, num );
  1878.     }
  1879. }
  1880.  
  1881. // RAVEN BEGIN
  1882. // jscott: export for memory tracking
  1883. /*
  1884. ================
  1885. idGameEdit::ListAnims
  1886. ================
  1887. */
  1888. void idGameEdit::PrintMemInfo( MemInfo *mi ) {
  1889.  
  1890.     int        i, count, totalSize;
  1891.     idAAS    *aas;
  1892.  
  1893.     totalSize = 0;
  1894.     count = 0;
  1895.     for( i = 0; i < gameLocal.GetNumAAS(); i++ ) {
  1896.  
  1897.         aas = gameLocal.GetAAS( i );
  1898.         if( aas ) {
  1899.  
  1900.             totalSize += aas->StatsSummary();
  1901.             count++;
  1902.         }
  1903.     }
  1904.  
  1905.     mi->aasAssetsTotal = totalSize;
  1906.     mi->aasAssetsCount = count;
  1907.  
  1908.     // jsinger: animationLib changed to a pointer
  1909.     animationLib->PrintMemInfo( mi );
  1910. }
  1911. // RAVEN END
  1912.  
  1913. /*
  1914. ==================
  1915. Cmd_AASStats_f
  1916. ==================
  1917. */
  1918. static void Cmd_AASStats_f( const idCmdArgs &args ) {
  1919.     int aasNum;
  1920.  
  1921.     if ( !gameLocal.CheatsOk() ) {
  1922.         return;
  1923.     }
  1924.  
  1925.     aasNum = aas_test.GetInteger();
  1926.     idAAS *aas = gameLocal.GetAAS( aasNum );
  1927.     if ( !aas ) {
  1928.         gameLocal.Printf( "No aas #%d loaded\n", aasNum );
  1929.     } else {
  1930.         aas->Stats();
  1931.     }
  1932. }
  1933.  
  1934. /*
  1935. ==================
  1936. Cmd_TestDamage_f
  1937. ==================
  1938. */
  1939. static void Cmd_TestDamage_f( const idCmdArgs &args ) {
  1940.     idPlayer *player;
  1941.     const char *damageDefName;
  1942.  
  1943.     player = gameLocal.GetLocalPlayer();
  1944.     if ( !player || !gameLocal.CheatsOk() ) {
  1945.         return;
  1946.     }
  1947.  
  1948.     if ( args.Argc() < 2 || args.Argc() > 3 ) {
  1949.         gameLocal.Printf( "usage: testDamage <damageDefName> [angle]\n" );
  1950.         return;
  1951.     }
  1952.  
  1953.     damageDefName = args.Argv( 1 );
  1954.  
  1955.     idVec3    dir;
  1956.     if ( args.Argc() == 3 ) {
  1957.         float angle = atof( args.Argv( 2 ) );
  1958.  
  1959.         idMath::SinCos( DEG2RAD( angle ), dir[1], dir[0] );
  1960.         dir[2] = 0;
  1961.     } else {
  1962.         dir.Zero();
  1963.     }
  1964.  
  1965.     // give the player full health before and after
  1966.     // running the damage
  1967.     player->health = player->inventory.maxHealth;
  1968.     player->Damage( NULL, NULL, dir, damageDefName, 1.0f, INVALID_JOINT );
  1969.     player->health = player->inventory.maxHealth;
  1970. }
  1971.  
  1972. /*
  1973. ==================
  1974. Cmd_TestBoneFx_f
  1975. ==================
  1976. */
  1977. // RAVEN BEGIN
  1978. // bdube: not using
  1979. /*
  1980. static void Cmd_TestBoneFx_f( const idCmdArgs &args ) {
  1981.     idPlayer *player;
  1982.     const char *bone, *fx;
  1983.  
  1984.     player = gameLocal.GetLocalPlayer();
  1985.     if ( !player || !gameLocal.CheatsOk() ) {
  1986.         return;
  1987.     }
  1988.  
  1989.     if ( args.Argc() < 3 || args.Argc() > 4 ) {
  1990.         gameLocal.Printf( "usage: testBoneFx <fxName> <boneName>\n" );
  1991.         return;
  1992.     }
  1993.  
  1994.     fx = args.Argv( 1 );
  1995.     bone = args.Argv( 2 );
  1996.  
  1997.     player->StartFxOnBone( fx, bone );
  1998. }
  1999. */
  2000. // RAVEN END
  2001.  
  2002. /*
  2003. ==================
  2004. Cmd_TestDamage_f
  2005. ==================
  2006. */
  2007. static void Cmd_TestDeath_f( const idCmdArgs &args ) {
  2008.     idPlayer *player;
  2009.  
  2010.     player = gameLocal.GetLocalPlayer();
  2011.     if ( !player || !gameLocal.CheatsOk() ) {
  2012.         return;
  2013.     }
  2014.  
  2015.     idVec3 dir;
  2016.     idMath::SinCos( DEG2RAD( 45.0f ), dir[1], dir[0] );
  2017.     dir[2] = 0;
  2018.  
  2019.     g_testDeath.SetBool( 1 );
  2020.     player->Damage( NULL, NULL, dir, "damage_triggerhurt_1000", 1.0f, INVALID_JOINT );
  2021.     if ( args.Argc() >= 2) {
  2022.         player->SpawnGibs( dir, "damage_triggerhurt_1000" );
  2023.     }
  2024.  
  2025. }
  2026.  
  2027. /*
  2028. ==================
  2029. Cmd_WeaponSplat_f
  2030. ==================
  2031. */
  2032. static void Cmd_WeaponSplat_f( const idCmdArgs &args ) {
  2033.     idPlayer *player;
  2034.  
  2035.     player = gameLocal.GetLocalPlayer();
  2036.     if ( !player || !gameLocal.CheatsOk() ) {
  2037.         return;
  2038.     }
  2039.  
  2040.     player->weapon->BloodSplat( 2.0f );
  2041. }
  2042.  
  2043. /*
  2044. ==================
  2045. Cmd_SaveSelected_f
  2046. ==================
  2047. */
  2048. static void Cmd_SaveSelected_f( const idCmdArgs &args ) {
  2049.     int i;
  2050.     idPlayer *player;
  2051.     idEntity *s;
  2052.     idMapEntity *mapEnt;
  2053.     idMapFile *mapFile = gameLocal.GetLevelMap();
  2054.     idDict dict;
  2055.     idStr mapName;
  2056.     const char *name = NULL;
  2057.  
  2058.     player = gameLocal.GetLocalPlayer();
  2059.     if ( !player || !gameLocal.CheatsOk() ) {
  2060.         return;
  2061.     }
  2062.  
  2063.     s = player->dragEntity.GetSelected();
  2064.     if ( !s ) {
  2065.         gameLocal.Printf( "no entity selected, set g_dragShowSelection 1 to show the current selection\n" );
  2066.         return;
  2067.     }
  2068.  
  2069.     if ( args.Argc() > 1 ) {
  2070.         mapName = args.Argv( 1 );
  2071.         mapName = "maps/" + mapName;
  2072.     }
  2073.     else {
  2074.         mapName = mapFile->GetName();
  2075.     }
  2076.  
  2077.     // find map file entity
  2078.     mapEnt = mapFile->FindEntity( s->name );
  2079.     // create new map file entity if there isn't one for this articulated figure
  2080.     if ( !mapEnt ) {
  2081.         mapEnt = new idMapEntity();
  2082.         mapFile->AddEntity( mapEnt );
  2083.         for ( i = 0; i < 9999; i++ ) {
  2084.             name = va( "%s_%d", s->GetEntityDefName(), i );
  2085.             if ( !gameLocal.FindEntity( name ) ) {
  2086.                 break;
  2087.             }
  2088.         }
  2089.         s->name = name;
  2090.         mapEnt->epairs.Set( "classname", s->GetEntityDefName() );
  2091.         mapEnt->epairs.Set( "name", s->name );
  2092.     }
  2093.  
  2094. // RAVEN BEGIN
  2095. // jnewquist: Use accessor for static class type 
  2096.     if ( s->IsType( idMoveable::GetClassType() ) ) {
  2097. // RAVEN END
  2098.         // save the moveable state
  2099.         mapEnt->epairs.Set( "origin", s->GetPhysics()->GetOrigin().ToString( 8 ) );
  2100.         mapEnt->epairs.Set( "rotation", s->GetPhysics()->GetAxis().ToString( 8 ) );
  2101.     }
  2102. // RAVEN BEGIN
  2103. // jnewquist: Use accessor for static class type 
  2104.     else if ( s->IsType( idAFEntity_Generic::GetClassType() ) || s->IsType( idAFEntity_WithAttachedHead::GetClassType() ) ) {
  2105. // RAVEN END
  2106.         // save the articulated figure state
  2107.         dict.Clear();
  2108.         static_cast<idAFEntity_Base *>(s)->SaveState( dict );
  2109.         mapEnt->epairs.Copy( dict );
  2110.     }
  2111.  
  2112.     // write out the map file
  2113.     mapFile->Write( mapName, ".map" );
  2114. }
  2115.  
  2116. /*
  2117. ==================
  2118. Cmd_DeleteSelected_f
  2119. ==================
  2120. */
  2121. static void Cmd_DeleteSelected_f( const idCmdArgs &args ) {
  2122.     idPlayer *player;
  2123.  
  2124.     player = gameLocal.GetLocalPlayer();
  2125.     if ( !player || !gameLocal.CheatsOk() ) {
  2126.         return;
  2127.     }
  2128.  
  2129.     if ( player ) {
  2130.         player->dragEntity.DeleteSelected();
  2131.     }
  2132. }
  2133.  
  2134. /*
  2135. ==================
  2136. Cmd_SaveMoveables_f
  2137. ==================
  2138. */
  2139. static void Cmd_SaveMoveables_f( const idCmdArgs &args ) {
  2140.     int e, i;
  2141.     idMoveable *m;
  2142.     idMapEntity *mapEnt;
  2143.     idMapFile *mapFile = gameLocal.GetLevelMap();
  2144.     idStr mapName;
  2145.     const char *name = NULL;
  2146.  
  2147.     if ( !gameLocal.CheatsOk() ) {
  2148.         return;
  2149.     }
  2150.  
  2151.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  2152.         m = static_cast<idMoveable *>(gameLocal.entities[ e ]);
  2153.  
  2154. // RAVEN BEGIN
  2155. // jnewquist: Use accessor for static class type 
  2156.         if ( !m || !m->IsType( idMoveable::GetClassType() ) ) {
  2157. // RAVEN END
  2158.             continue;
  2159.         }
  2160.  
  2161.         if ( m->IsBound() ) {
  2162.             continue;
  2163.         }
  2164.  
  2165.         if ( !m->IsAtRest() ) {
  2166.             break;
  2167.         }
  2168.     }
  2169.  
  2170.     if ( e < MAX_GENTITIES ) {
  2171.         gameLocal.Warning( "map not saved because the moveable entity %s is not at rest", gameLocal.entities[ e ]->name.c_str() );
  2172.         return;
  2173.     }
  2174.  
  2175.     if ( args.Argc() > 1 ) {
  2176.         mapName = args.Argv( 1 );
  2177.         mapName = "maps/" + mapName;
  2178.     }
  2179.     else {
  2180.         mapName = mapFile->GetName();
  2181.     }
  2182.  
  2183.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  2184.         m = static_cast<idMoveable *>(gameLocal.entities[ e ]);
  2185.  
  2186. // RAVEN BEGIN
  2187. // jnewquist: Use accessor for static class type 
  2188.         if ( !m )
  2189.         {
  2190.             continue;
  2191.         }
  2192. // jdischler: need to check for idMoveableItem as well
  2193.         if ( !m->IsType( idMoveable::GetClassType()) && !m->IsType( idMoveableItem::GetClassType()) )
  2194.         {
  2195. // RAVEN END
  2196.             continue;
  2197.         }
  2198.  
  2199.         if ( m->IsBound() ) {
  2200.             continue;
  2201.         }
  2202.  
  2203.         // find map file entity
  2204.         mapEnt = mapFile->FindEntity( m->name );
  2205.         // create new map file entity if there isn't one for this articulated figure
  2206.         if ( !mapEnt ) {
  2207.             mapEnt = new idMapEntity();
  2208.             mapFile->AddEntity( mapEnt );
  2209.             for ( i = 0; i < 9999; i++ ) {
  2210.                 name = va( "%s_%d", m->GetEntityDefName(), i );
  2211.                 if ( !gameLocal.FindEntity( name ) ) {
  2212.                     break;
  2213.                 }
  2214.             }
  2215.             m->name = name;
  2216.             mapEnt->epairs.Set( "classname", m->GetEntityDefName() );
  2217.             mapEnt->epairs.Set( "name", m->name );
  2218.         }
  2219.         // save the moveable state
  2220.         mapEnt->epairs.Set( "origin", m->GetPhysics()->GetOrigin().ToString( 8 ) );
  2221.         mapEnt->epairs.Set( "rotation", m->GetPhysics()->GetAxis().ToString( 8 ) );
  2222.     }
  2223.  
  2224.     // write out the map file
  2225.     mapFile->Write( mapName, ".map" );
  2226. }
  2227.  
  2228. /*
  2229. ==================
  2230. Cmd_SaveRagdolls_f
  2231. ==================
  2232. */
  2233. static void Cmd_SaveRagdolls_f( const idCmdArgs &args ) {
  2234.     int e, i;
  2235.     idAFEntity_Base *af;
  2236.     idMapEntity *mapEnt;
  2237.     idMapFile *mapFile = gameLocal.GetLevelMap();
  2238.     idDict dict;
  2239.     idStr mapName;
  2240.     const char *name = NULL;
  2241.  
  2242.     if ( !gameLocal.CheatsOk() ) {
  2243.         return;
  2244.     }
  2245.  
  2246.     if ( args.Argc() > 1 ) {
  2247.         mapName = args.Argv( 1 );
  2248.         mapName = "maps/" + mapName;
  2249.     }
  2250.     else {
  2251.         mapName = mapFile->GetName();
  2252.     }
  2253.  
  2254.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  2255.         af = static_cast<idAFEntity_Base *>(gameLocal.entities[ e ]);
  2256.  
  2257.         if ( !af ) {
  2258.             continue;
  2259.         }
  2260.  
  2261. // RAVEN BEGIN
  2262. // jnewquist: Use accessor for static class type 
  2263.         if ( !af->IsType( idAFEntity_WithAttachedHead::GetClassType() ) && !af->IsType( idAFEntity_Generic::GetClassType() ) ) {
  2264. // RAVEN END
  2265.             continue;
  2266.         }
  2267.  
  2268.         if ( af->IsBound() ) {
  2269.             continue;
  2270.         }
  2271.  
  2272.         if ( !af->IsAtRest() ) {
  2273.             gameLocal.Warning( "the articulated figure for entity %s is not at rest", gameLocal.entities[ e ]->name.c_str() );
  2274.         }
  2275.  
  2276.         dict.Clear();
  2277.         af->SaveState( dict );
  2278.  
  2279.         // find map file entity
  2280.         mapEnt = mapFile->FindEntity( af->name );
  2281.         // create new map file entity if there isn't one for this articulated figure
  2282.         if ( !mapEnt ) {
  2283.             mapEnt = new idMapEntity();
  2284.             mapFile->AddEntity( mapEnt );
  2285.             for ( i = 0; i < 9999; i++ ) {
  2286.                 name = va( "%s_%d", af->GetEntityDefName(), i );
  2287.                 if ( !gameLocal.FindEntity( name ) ) {
  2288.                     break;
  2289.                 }
  2290.             }
  2291.             af->name = name;
  2292.             mapEnt->epairs.Set( "classname", af->GetEntityDefName() );
  2293.             mapEnt->epairs.Set( "name", af->name );
  2294.         }
  2295.         // save the articulated figure state
  2296.         mapEnt->epairs.Copy( dict );
  2297.     }
  2298.  
  2299.     // write out the map file
  2300.     mapFile->Write( mapName, ".map" );
  2301. }
  2302.  
  2303. /*
  2304. ==================
  2305. Cmd_BindRagdoll_f
  2306. ==================
  2307. */
  2308. static void Cmd_BindRagdoll_f( const idCmdArgs &args ) {
  2309.     idPlayer *player;
  2310.  
  2311.     player = gameLocal.GetLocalPlayer();
  2312.     if ( !player || !gameLocal.CheatsOk() ) {
  2313.         return;
  2314.     }
  2315.  
  2316.     if ( player ) {
  2317.         player->dragEntity.BindSelected();
  2318.     }
  2319. }
  2320.  
  2321. /*
  2322. ==================
  2323. Cmd_UnbindRagdoll_f
  2324. ==================
  2325. */
  2326. static void Cmd_UnbindRagdoll_f( const idCmdArgs &args ) {
  2327.     idPlayer *player;
  2328.  
  2329.     player = gameLocal.GetLocalPlayer();
  2330.     if ( !player || !gameLocal.CheatsOk() ) {
  2331.         return;
  2332.     }
  2333.  
  2334.     if ( player ) {
  2335.         player->dragEntity.UnbindSelected();
  2336.     }
  2337. }
  2338.  
  2339. /*
  2340. ==================
  2341. Cmd_GameError_f
  2342. ==================
  2343. */
  2344. static void Cmd_GameError_f( const idCmdArgs &args ) {
  2345.     gameLocal.Error( "game error" );
  2346. }
  2347.  
  2348. // RAVEN BEGIN
  2349. // rjohnson: entity usage stats
  2350. /*
  2351. ==================
  2352. Cmd_ListEntityStats_f
  2353. ==================
  2354. */
  2355. static void Cmd_ListEntityStats_f( const idCmdArgs &args ) {
  2356.     gameLocal.ListEntityStats( args );
  2357. }
  2358. // RAVEN END
  2359.  
  2360. /*
  2361. ==================
  2362. Cmd_SaveLights_f
  2363. ==================
  2364. */
  2365. static void Cmd_SaveLights_f( const idCmdArgs &args ) {
  2366.     int e, i;
  2367.     idLight *light;
  2368.     idMapEntity *mapEnt;
  2369.     idMapFile *mapFile = gameLocal.GetLevelMap();
  2370.     idDict dict;
  2371.     idStr mapName;
  2372.     const char *name = NULL;
  2373.  
  2374.     if ( !gameLocal.CheatsOk() ) {
  2375.         return;
  2376.     }
  2377.  
  2378.     if ( args.Argc() > 1 ) {
  2379.         mapName = args.Argv( 1 );
  2380.         mapName = "maps/" + mapName;
  2381.     }
  2382.     else {
  2383.         mapName = mapFile->GetName();
  2384.     }
  2385.  
  2386.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  2387.         light = static_cast<idLight*>(gameLocal.entities[ e ]);
  2388.  
  2389. // RAVEN BEGIN
  2390. // jnewquist: Use accessor for static class type 
  2391.         if ( !light || !light->IsType( idLight::GetClassType() ) ) {
  2392. // RAVEN END
  2393.             continue;
  2394.         }
  2395.  
  2396.         dict.Clear();
  2397.         light->SaveState( &dict );
  2398.  
  2399.         // find map file entity
  2400.         mapEnt = mapFile->FindEntity( light->name );
  2401.         // create new map file entity if there isn't one for this light
  2402.         if ( !mapEnt ) {
  2403.             mapEnt = new idMapEntity();
  2404.             mapFile->AddEntity( mapEnt );
  2405.             for ( i = 0; i < 9999; i++ ) {
  2406.                 name = va( "%s_%d", light->GetEntityDefName(), i );
  2407.                 if ( !gameLocal.FindEntity( name ) ) {
  2408.                     break;
  2409.                 }
  2410.             }
  2411.             light->name = name;
  2412.             mapEnt->epairs.Set( "classname", light->GetEntityDefName() );
  2413.             mapEnt->epairs.Set( "name", light->name );
  2414.         }
  2415.         // save the light state
  2416.         mapEnt->epairs.Copy( dict );
  2417.     }
  2418.  
  2419.     // write out the map file
  2420.     mapFile->Write( mapName, ".map" );
  2421. }
  2422.  
  2423.  
  2424. /*
  2425. ==================
  2426. Cmd_SaveParticles_f
  2427. ==================
  2428. */
  2429. static void Cmd_SaveParticles_f( const idCmdArgs &args ) {
  2430.     int e;
  2431.     idEntity *ent;
  2432.     idMapEntity *mapEnt;
  2433.     idMapFile *mapFile = gameLocal.GetLevelMap();
  2434.     idDict dict;
  2435.     idStr mapName, strModel;
  2436.  
  2437.     if ( !gameLocal.CheatsOk() ) {
  2438.         return;
  2439.     }
  2440.  
  2441.     if ( args.Argc() > 1 ) {
  2442.         mapName = args.Argv( 1 );
  2443.         mapName = "maps/" + mapName;
  2444.     }
  2445.     else {
  2446.         mapName = mapFile->GetName();
  2447.     }
  2448.  
  2449.     for( e = 0; e < MAX_GENTITIES; e++ ) {
  2450.  
  2451.         ent = static_cast<idStaticEntity*> ( gameLocal.entities[ e ] );
  2452.  
  2453.         if ( !ent ) {
  2454.             continue;
  2455.         }
  2456.  
  2457.         strModel = ent->spawnArgs.GetString( "model" );
  2458.         if ( strModel.Length() && strModel.Find( ".prt") > 0 ) {
  2459.             dict.Clear();
  2460.             dict.Set( "model", ent->spawnArgs.GetString( "model" ) );
  2461.             dict.SetVector( "origin", ent->GetPhysics()->GetOrigin() );
  2462.  
  2463.             // find map file entity
  2464.             mapEnt = mapFile->FindEntity( ent->name );
  2465.             // create new map file entity if there isn't one for this entity
  2466.             if ( !mapEnt ) {
  2467.                 continue;
  2468.             }
  2469.             // save the particle state
  2470.             mapEnt->epairs.Copy( dict );
  2471.         }
  2472.     }
  2473.  
  2474.     // write out the map file
  2475.     mapFile->Write( mapName, ".map" );
  2476. }
  2477.  
  2478.  
  2479. /*
  2480. ==================
  2481. Cmd_DisasmScript_f
  2482. ==================
  2483. */
  2484. static void Cmd_DisasmScript_f( const idCmdArgs &args ) {
  2485.     gameLocal.program.Disassemble();
  2486. }
  2487.  
  2488. /*
  2489. ==================
  2490. Cmd_TestSave_f
  2491. ==================
  2492. */
  2493. static void Cmd_TestSave_f( const idCmdArgs &args ) {
  2494.     idFile *f;
  2495.  
  2496.     f = fileSystem->OpenFileWrite( "test.sav" );
  2497.     gameLocal.SaveGame( f );
  2498.     fileSystem->CloseFile( f );
  2499. }
  2500.  
  2501. // RAVEN BEGIN
  2502. #if 0
  2503. /*
  2504. ==================
  2505. Cmd_RecordViewNotes_f
  2506. ==================
  2507. */
  2508. static void Cmd_RecordViewNotes_f( const idCmdArgs &args ) {
  2509.     idPlayer *player;
  2510.     idVec3 origin;
  2511.     idMat3 axis;
  2512.  
  2513.     if ( args.Argc() <= 3 ) {
  2514.         return;
  2515.     }
  2516.  
  2517.     player = gameLocal.GetLocalPlayer();
  2518.     if ( !player ) {
  2519.         return;
  2520.     }
  2521.  
  2522.     player->GetViewPos( origin, axis );
  2523.  
  2524.     // Argv(1) = filename for map (viewnotes/mapname/person)
  2525.     // Argv(2) = note number (person0001)
  2526.     // Argv(3) = comments
  2527.  
  2528.     idStr str = args.Argv(1);
  2529.     str.SetFileExtension( ".txt" );
  2530.     idFile *file = fileSystem->OpenFileAppend( str );
  2531.     if ( file ) {
  2532.         file->WriteFloatString( "\"view\"\t( %s )\t( %s )\r\n", origin.ToString(), axis.ToString() );
  2533.         file->WriteFloatString( "\"comments\"\t\"%s: %s\"\r\n\r\n", args.Argv(2), args.Argv(3) );
  2534.         fileSystem->CloseFile( file );
  2535.     }
  2536.  
  2537.     idStr viewComments = args.Argv(1);
  2538.     viewComments.StripLeading("viewnotes/");
  2539.     viewComments += " -- Loc: ";
  2540.     viewComments += origin.ToString();
  2541.     viewComments += "\n";
  2542.     viewComments += args.Argv(3);
  2543.     player->hud->SetStateString( "viewcomments", viewComments );
  2544.     player->hud->HandleNamedEvent( "showViewComments" );
  2545. }
  2546.  
  2547. /*
  2548. ==================
  2549. Cmd_CloseViewNotes_f
  2550. ==================
  2551. */
  2552. static void Cmd_CloseViewNotes_f( const idCmdArgs &args ) {
  2553.     idPlayer *player = gameLocal.GetLocalPlayer();
  2554.  
  2555.     if ( !player ) {
  2556.         return;
  2557.     }
  2558.     
  2559.     player->hud->SetStateString( "viewcomments", "" );
  2560.     player->hud->HandleNamedEvent( "hideViewComments" );
  2561. }
  2562.  
  2563. /*
  2564. ==================
  2565. Cmd_ShowViewNotes_f
  2566. ==================
  2567. */
  2568. static void Cmd_ShowViewNotes_f( const idCmdArgs &args ) {
  2569.     static idLexer parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS | LEXFL_NOSTRINGCONCAT | LEXFL_NOFATALERRORS );
  2570.     idToken    token;
  2571.     idPlayer *player;
  2572.     idVec3 origin;
  2573.     idMat3 axis;
  2574.  
  2575.     player = gameLocal.GetLocalPlayer();
  2576.  
  2577.     if ( !player ) {
  2578.         return;
  2579.     }
  2580.  
  2581.     if ( !parser.IsLoaded() ) {
  2582.         idStr str = "viewnotes/";
  2583.         str += gameLocal.GetMapName();
  2584.         str.StripFileExtension();
  2585.         str += "/";
  2586.         if ( args.Argc() > 1 ) {
  2587.             str += args.Argv( 1 );
  2588.         } else {
  2589.             str += "comments";
  2590.         }
  2591.         str.SetFileExtension( ".txt" );
  2592.         if ( !parser.LoadFile( str ) ) {
  2593.             gameLocal.Printf( "No view notes for %s\n", gameLocal.GetMapName() );
  2594.             return;
  2595.         }
  2596.     }
  2597.  
  2598.     if ( parser.ExpectTokenString( "view" ) && parser.Parse1DMatrix( 3, origin.ToFloatPtr() ) && 
  2599.         parser.Parse1DMatrix( 9, axis.ToFloatPtr() ) && parser.ExpectTokenString( "comments" ) && parser.ReadToken( &token ) ) {
  2600.         player->hud->SetStateString( "viewcomments", token );
  2601.         player->hud->HandleNamedEvent( "showViewComments" );
  2602.         player->Teleport( origin, axis.ToAngles(), NULL );
  2603.     } else {
  2604.         parser.FreeSource();
  2605.         player->hud->HandleNamedEvent( "hideViewComments" );
  2606.         return;
  2607.     }
  2608. }
  2609. #endif
  2610. // RAVEN END
  2611.  
  2612. /*
  2613. =================
  2614. FindEntityGUIs
  2615.  
  2616. helper function for Cmd_NextGUI_f.  Checks the passed entity to determine if it
  2617. has any valid gui surfaces.
  2618. =================
  2619. */
  2620. bool FindEntityGUIs( idEntity *ent, const modelSurface_t ** surfaces,  int maxSurfs, int &guiSurfaces ) {
  2621.     renderEntity_t            *renderEnt;
  2622.     idRenderModel            *renderModel;
  2623.     const modelSurface_t    *surf;
  2624.     const idMaterial        *shader;
  2625.     int                        i;
  2626.  
  2627.     assert( surfaces != NULL );
  2628.     assert( ent != NULL );
  2629.  
  2630.     memset( surfaces, 0x00, sizeof( modelSurface_t *) * maxSurfs );
  2631.     guiSurfaces = 0;
  2632.  
  2633.     renderEnt  = ent->GetRenderEntity();
  2634.     renderModel = renderEnt->hModel;
  2635.     if ( renderModel == NULL ) {
  2636.         return false;
  2637.     }
  2638.  
  2639.     for( i = 0; i < renderModel->NumSurfaces(); i++ ) {
  2640.         surf = renderModel->Surface( i );
  2641.         if ( surf == NULL ) {
  2642.             continue;
  2643.         }
  2644.         shader = surf->shader;
  2645.         if ( shader == NULL ) {
  2646.             continue;
  2647.         }
  2648.         if ( shader->GetEntityGui() > 0 ) {
  2649.             surfaces[ guiSurfaces++ ] = surf;
  2650.         }
  2651.     }
  2652.  
  2653.     return ( guiSurfaces != 0 );
  2654. }
  2655.  
  2656. /*
  2657. =================
  2658. Cmd_NextGUI_f
  2659. =================
  2660. */
  2661. void Cmd_NextGUI_f( const idCmdArgs &args ) {
  2662.     idVec3                    origin;
  2663.     idAngles                angles;
  2664.     idPlayer                *player;
  2665.     idEntity                *ent;
  2666.     int                        guiSurfaces;
  2667.     bool                    newEnt;
  2668.     renderEntity_t            *renderEnt;
  2669.     int                        surfIndex;
  2670.     srfTriangles_t            *geom;
  2671.     idMat4                    modelMatrix;
  2672.     idVec3                    normal;
  2673.     idVec3                    center;
  2674.     const modelSurface_t    *surfaces[ MAX_RENDERENTITY_GUI ];
  2675.  
  2676.     player = gameLocal.GetLocalPlayer();
  2677.     if ( !player || !gameLocal.CheatsOk() ) {
  2678.         return;
  2679.     }
  2680.  
  2681.     if ( args.Argc() != 1 ) {
  2682.         gameLocal.Printf( "usage: nextgui\n" );
  2683.         return;
  2684.     }
  2685.  
  2686.     // start at the last entity
  2687.     ent = gameLocal.lastGUIEnt.GetEntity();
  2688.  
  2689.     // see if we have any gui surfaces left to go to on the current entity.
  2690.     guiSurfaces = 0;
  2691.     newEnt = false;
  2692.     if ( ent == NULL ) {
  2693.         newEnt = true;
  2694.     } else if ( FindEntityGUIs( ent, surfaces, MAX_RENDERENTITY_GUI, guiSurfaces ) == true ) {
  2695.         if ( gameLocal.lastGUI >= guiSurfaces ) {
  2696.             newEnt = true;
  2697.         }
  2698.     } else {
  2699.         // no actual gui surfaces on this ent, so skip it
  2700.         newEnt = true;
  2701.     }
  2702.  
  2703.     if ( newEnt == true ) {
  2704.         // go ahead and skip to the next entity with a gui...
  2705.         if ( ent == NULL ) {
  2706.             ent = gameLocal.spawnedEntities.Next();
  2707.         } else {
  2708.             ent = ent->spawnNode.Next();
  2709.         }
  2710.  
  2711.         for ( ; ent != NULL; ent = ent->spawnNode.Next() ) {
  2712.             if ( ent->spawnArgs.GetString( "gui", NULL ) != NULL ) {
  2713.                 break;
  2714.             }
  2715.             
  2716.             if ( ent->spawnArgs.GetString( "gui2", NULL ) != NULL ) {
  2717.                 break;
  2718.             }
  2719.  
  2720.             if ( ent->spawnArgs.GetString( "gui3", NULL ) != NULL ) {
  2721.                 break;
  2722.             }
  2723.             
  2724.             // try the next entity
  2725.             gameLocal.lastGUIEnt = ent;
  2726.         }
  2727.  
  2728.         gameLocal.lastGUIEnt = ent;
  2729.         gameLocal.lastGUI = 0;
  2730.  
  2731.         if ( !ent ) {
  2732.             gameLocal.Printf( "No more gui entities. Starting over...\n" );
  2733.             return;
  2734.         }
  2735.     }
  2736.  
  2737.     if ( FindEntityGUIs( ent, surfaces, MAX_RENDERENTITY_GUI, guiSurfaces ) == false ) {
  2738.         gameLocal.Printf( "Entity \"%s\" has gui properties but no gui surfaces.\n", ent->name.c_str() );
  2739.     }
  2740.  
  2741.     if ( guiSurfaces == 0 ) {
  2742.         gameLocal.Printf( "Entity \"%s\" has gui properties but no gui surfaces!\n", ent->name.c_str() );
  2743.         return;
  2744.     }
  2745.  
  2746.     gameLocal.Printf( "Teleporting to gui entity \"%s\", gui #%d.\n" , ent->name.c_str (), gameLocal.lastGUI );
  2747.  
  2748.     renderEnt = ent->GetRenderEntity();
  2749.     surfIndex = gameLocal.lastGUI++;
  2750.     geom = surfaces[ surfIndex ]->geometry;
  2751.     if ( geom == NULL ) {
  2752.         gameLocal.Printf( "Entity \"%s\" has gui surface %d without geometry!\n", ent->name.c_str(), surfIndex );
  2753.         return;
  2754.     }
  2755.  
  2756.     assert( geom->facePlanes != NULL );
  2757.  
  2758.     modelMatrix = idMat4( renderEnt->axis, renderEnt->origin );    
  2759.     normal = geom->facePlanes[ 0 ].Normal() * renderEnt->axis;
  2760.     center = geom->bounds.GetCenter() * modelMatrix;
  2761.  
  2762.     origin = center + (normal * 32.0f);
  2763.     origin.z -= player->EyeHeight();
  2764.     normal *= -1.0f;
  2765.     angles = normal.ToAngles ();
  2766.  
  2767.     //    make sure the player is in noclip
  2768.     player->noclip = true;
  2769.     player->Teleport( origin, angles, NULL );
  2770. }
  2771.  
  2772. static void ArgCompletion_DefFile( const idCmdArgs &args, void(*callback)( const char *s ) ) {
  2773.     cmdSystem->ArgCompletion_FolderExtension( args, callback, "def/", true, ".def", NULL );
  2774. }
  2775.  
  2776. /*
  2777. ===============
  2778. Cmd_TestId_f
  2779. outputs a string from the string table for the specified id
  2780. ===============
  2781. */
  2782. void Cmd_TestId_f( const idCmdArgs &args ) {
  2783.     idStr    id;
  2784.     int        i;
  2785.     if ( args.Argc() == 1 ) {
  2786.         common->Printf( "usage: testid <string id>\n" );
  2787.         return;
  2788.     }
  2789.  
  2790.     for ( i = 1; i < args.Argc(); i++ ) {
  2791.         id += args.Argv( i );
  2792.     }
  2793.     if ( idStr::Cmpn( id, STRTABLE_ID, STRTABLE_ID_LENGTH ) != 0 ) {
  2794.         id = STRTABLE_ID + id;
  2795.     }
  2796.     gameLocal.mpGame.AddChatLine( common->GetLocalizedString( id ), "<nothing>", "<nothing>", "<nothing>" );    
  2797. }
  2798.  
  2799. // RAVEN BEGIN
  2800. // ddynerman: instance testing commands
  2801. void Cmd_SetInstance_f( const idCmdArgs& args ) {
  2802.     if( !gameLocal.isServer ) {
  2803.         gameLocal.Warning( "Cmd_SetInstance_f(): setInstance can only be run on a server\n" );
  2804.         return;
  2805.     }
  2806.  
  2807.     if ( args.Argc() <= 2 ) {
  2808.         common->Printf( "usage: setInstance <client> <instance id>\n" );
  2809.         return;
  2810.     }
  2811.  
  2812.     int client = atoi( args.Argv( 1 ) );
  2813.     int instanceID = atoi( args.Argv( 2 ) );
  2814.  
  2815.     if( client < 0 || client >= MAX_CLIENTS || !gameLocal.entities[ client ] ) {
  2816.         gameLocal.Warning( "Cmd_SetInstance_f(): Invalid clientnum %d\n", client );
  2817.         return;
  2818.     }
  2819.  
  2820.     idPlayer* player = (idPlayer*)gameLocal.entities[ client ];
  2821.  
  2822.     gameLocal.Printf( "Cmd_SetInstance_f(): Switching %d: %s to instance %d\n", client, gameLocal.userInfo[ client ].GetString( "ui_name", "unknown" ), instanceID );
  2823.  
  2824.     player->JoinInstance( instanceID );
  2825. }
  2826.  
  2827. void Cmd_ListInstances_f( const idCmdArgs& args ) {
  2828.     if( !gameLocal.isServer ) {
  2829.         gameLocal.Warning( "Cmd_ListInstances_f(): listInstances can only be run on a server\n" );
  2830.         return;
  2831.     }
  2832.  
  2833.     for( int i = 0; i < gameLocal.GetNumInstances(); i++ ) {
  2834.         gameLocal.Printf("Instance %d:\n", i );
  2835.         for( int j = 0; j < MAX_CLIENTS; j++ ) {
  2836.             idPlayer* player = (idPlayer*)gameLocal.entities[ j ];
  2837.             if( player && player->GetInstance() == i ) {
  2838.                 gameLocal.Printf( "\t%d: %s\n", j, player->GetUserInfo()->GetString( "ui_name" ) );
  2839.             }
  2840.         }
  2841.     }
  2842. }
  2843.  
  2844. void Cmd_AddIcon_f( const idCmdArgs& args ) {
  2845.     if ( args.Argc() <= 1 ) {
  2846.         common->Printf( "usage: addIcon <client>\n" );
  2847.         return;
  2848.     }
  2849.     
  2850.     int client = atoi( args.Argv( 1 ) );
  2851.     
  2852.     iconManager->AddIcon( client, "textures/mp/awards/capture" );
  2853. }
  2854.  
  2855. void Cmd_PlayerEmote_f( const idCmdArgs& args ) {
  2856.     if( gameLocal.GetLocalPlayer() == NULL ) {
  2857.         gameLocal.Warning( "Cmd_Emote_f() - local player is NULL" );
  2858.         return;
  2859.     }
  2860.  
  2861.     if ( args.Argc() <= 1 ) {
  2862.         gameLocal.Printf( "usage: emote <emote>\n" );
  2863.         gameLocal.Printf( "\ttry 'taunt', 'salute', 'grab_a'\n" );
  2864.         return;
  2865.     }
  2866.  
  2867.     if( !idStr::Icmp( args.Argv( 1 ), "taunt" ) ) {
  2868.         gameLocal.GetLocalPlayer()->SetEmote( PE_TAUNT );
  2869.     } else if( !idStr::Icmp( args.Argv( 1 ), "grab_a" ) ) {
  2870.         gameLocal.GetLocalPlayer()->SetEmote( PE_GRAB_A );
  2871.     } else if( !idStr::Icmp( args.Argv( 1 ), "grab_b" ) ) {
  2872.         gameLocal.GetLocalPlayer()->SetEmote( PE_GRAB_B );
  2873.     } else if( !idStr::Icmp( args.Argv( 1), "salute" ) ) {
  2874.         gameLocal.GetLocalPlayer()->SetEmote( PE_SALUTE );
  2875.     } else if( !idStr::Icmp( args.Argv( 1), "cheer" ) ) {
  2876.         gameLocal.GetLocalPlayer()->SetEmote( PE_CHEER );
  2877.     } else {
  2878.         gameLocal.Printf( "Invalid emote '%s'\n", args.Argv( 1 ) );
  2879.         gameLocal.Printf( "\ttry 'taunt', 'salute', 'grab'\n" );
  2880.     }
  2881.     
  2882. }
  2883.  
  2884. // mekberg: added
  2885. void Cmd_SetPMCVars_f ( const idCmdArgs &args ) {
  2886.     if ( gameLocal.isMultiplayer ) {
  2887.         return;
  2888.     }
  2889.  
  2890.     if ( gameLocal.GetLocalPlayer( ) ) {
  2891.         gameLocal.GetLocalPlayer( )->SetPMCVars( );
  2892.     }
  2893. }
  2894.  
  2895. void Cmd_FadeSound_f( const idCmdArgs &args )    {
  2896.  
  2897.     if( args.Argc() < 2)    {
  2898.         return;
  2899.     }
  2900.  
  2901.     float fadeDB = 0.0f;
  2902.     float fadeTime = 0.0f;
  2903.  
  2904.     idStr _fadeDB = args.Argv( 1);
  2905.     fadeDB = atof( _fadeDB );
  2906.  
  2907.     idStr _fadeTime = args.Argv( 2);
  2908.     fadeTime = atof( _fadeTime );
  2909.  
  2910.     soundSystem->FadeSoundClasses( SOUNDWORLD_GAME, SOUND_CLASS_MUSICAL, 0.0f - fadeDB, fadeTime );
  2911.  
  2912. }
  2913.  
  2914. // RAVEN END
  2915.  
  2916. void Cmd_CheckSave_f( const idCmdArgs &args );
  2917.  
  2918. /*
  2919. =================
  2920. idGameLocal::InitConsoleCommands
  2921.  
  2922. Let the system know about all of our commands
  2923. so it can perform tab completion
  2924. =================
  2925. */
  2926. void idGameLocal::InitConsoleCommands( void ) {
  2927. // RAVEN BEGIN
  2928. // jscott: typeinfo gone - didn't work, it was unfinished
  2929. //    cmdSystem->AddCommand( "listTypeInfo",            ListTypeInfo_f,                CMD_FL_GAME,                "list type info" );
  2930. //    cmdSystem->AddCommand( "writeGameState",        WriteGameState_f,            CMD_FL_GAME,                "write game state" );
  2931. //    cmdSystem->AddCommand( "testSaveGame",            TestSaveGame_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "test a save game for a level" );
  2932. // RAVEN END
  2933.     cmdSystem->AddCommand( "game_memory",            idClass::DisplayInfo_f,        CMD_FL_GAME,                "displays game class info" );
  2934.     cmdSystem->AddCommand( "listClasses",            idClass::ListClasses_f,        CMD_FL_GAME,                "lists game classes" );
  2935.     cmdSystem->AddCommand( "listThreads",            idThread::ListThreads_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "lists script threads" );
  2936.     cmdSystem->AddCommand( "listEntities",            Cmd_EntityList_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "lists game entities" );
  2937.     cmdSystem->AddCommand( "listActiveEntities",    Cmd_ActiveEntityList_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "lists active game entities" );
  2938.     cmdSystem->AddCommand( "listMonsters",            idAI::List_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "lists monsters" );
  2939.     cmdSystem->AddCommand( "listSpawnArgs",            Cmd_ListSpawnArgs_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "list the spawn args of an entity", idGameLocal::ArgCompletion_EntityName );
  2940.     cmdSystem->AddCommand( "say",                    Cmd_Say_f,                    CMD_FL_GAME,                "text chat" );
  2941.     cmdSystem->AddCommand( "sayTeam",                Cmd_SayTeam_f,                CMD_FL_GAME,                "team text chat" );
  2942.     cmdSystem->AddCommand( "addChatLine",            Cmd_AddChatLine_f,            CMD_FL_GAME,                "internal use - core to game chat lines" );
  2943.     cmdSystem->AddCommand( "gameKick",                Cmd_Kick_f,                    CMD_FL_GAME,                "same as kick, but recognizes player names" );
  2944.     cmdSystem->AddCommand( "give",                    Cmd_Give_f,                    CMD_FL_GAME|CMD_FL_CHEAT,    "gives one or more items" );
  2945.     cmdSystem->AddCommand( "centerview",            Cmd_CenterView_f,            CMD_FL_GAME,                "centers the view" );
  2946.     cmdSystem->AddCommand( "god",                    Cmd_God_f,                    CMD_FL_GAME|CMD_FL_CHEAT,    "enables god mode" );
  2947.     cmdSystem->AddCommand( "undying",                Cmd_Undying_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "enables undying mode (take damage down to 1 health, but do not die)" );
  2948.     cmdSystem->AddCommand( "notarget",                Cmd_Notarget_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "disables the player as a target" );
  2949.     cmdSystem->AddCommand( "noclip",                Cmd_Noclip_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "disables collision detection for the player" );
  2950.     cmdSystem->AddCommand( "kill",                    Cmd_Kill_f,                    CMD_FL_GAME,                "kills the player" );
  2951.     cmdSystem->AddCommand( "where",                    Cmd_GetViewpos_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "prints the current view position" );
  2952.     cmdSystem->AddCommand( "getviewpos",            Cmd_GetViewpos_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "prints the current view position" );
  2953.     cmdSystem->AddCommand( "setviewpos",            Cmd_SetViewpos_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "sets the current view position" );
  2954.     cmdSystem->AddCommand( "teleport",                Cmd_Teleport_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "teleports the player to an entity location", idGameLocal::ArgCompletion_EntityName );
  2955.     cmdSystem->AddCommand( "trigger",                Cmd_Trigger_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "triggers an entity", idGameLocal::ArgCompletion_EntityName );
  2956.     cmdSystem->AddCommand( "spawn",                    Cmd_Spawn_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "spawns a game entity", idCmdSystem::ArgCompletion_Decl<DECL_ENTITYDEF> );
  2957.     cmdSystem->AddCommand( "damage",                Cmd_Damage_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "apply damage to an entity", idGameLocal::ArgCompletion_EntityName );
  2958.     cmdSystem->AddCommand( "remove",                Cmd_Remove_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "removes an entity", idGameLocal::ArgCompletion_EntityName );
  2959.     cmdSystem->AddCommand( "killMonsters",            Cmd_KillMonsters_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "removes all monsters" );
  2960.     cmdSystem->AddCommand( "killMoveables",            Cmd_KillMovables_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "removes all moveables" );
  2961.     cmdSystem->AddCommand( "killRagdolls",            Cmd_KillRagdolls_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "removes all ragdolls" );
  2962.     cmdSystem->AddCommand( "addline",                Cmd_AddDebugLine_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "adds a debug line" );
  2963.     cmdSystem->AddCommand( "addarrow",                Cmd_AddDebugLine_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "adds a debug arrow" );
  2964.     cmdSystem->AddCommand( "removeline",            Cmd_RemoveDebugLine_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "removes a debug line" );
  2965.     cmdSystem->AddCommand( "blinkline",                Cmd_BlinkDebugLine_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "blinks a debug line" );
  2966.     cmdSystem->AddCommand( "listLines",                Cmd_ListDebugLines_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "lists all debug lines" );
  2967.     cmdSystem->AddCommand( "playerModel",            Cmd_PlayerModel_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "sets the given model on the player", idCmdSystem::ArgCompletion_Decl<DECL_MODELDEF> );
  2968.     cmdSystem->AddCommand( "flashlight",            Cmd_Flashlight_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "toggle actor's flashlight", idGameLocal::ArgCompletion_AIName );
  2969. // RAVEN BEGIN
  2970. // bdube: not using id effect system
  2971. //    cmdSystem->AddCommand( "testFx",                Cmd_TestFx_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "tests an FX system", idCmdSystem::ArgCompletion_Decl<DECL_FX> );
  2972. //    cmdSystem->AddCommand( "testBoneFx",            Cmd_TestBoneFx_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests an FX system bound to a joint", idCmdSystem::ArgCompletion_Decl<DECL_FX> );
  2973. // RAVEN END
  2974.     cmdSystem->AddCommand( "testLight",                Cmd_TestLight_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests a light" );
  2975.     cmdSystem->AddCommand( "testPointLight",        Cmd_TestPointLight_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "tests a point light" );
  2976.     cmdSystem->AddCommand( "popLight",                Cmd_PopLight_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "removes the last created light" );
  2977.     cmdSystem->AddCommand( "testDeath",                Cmd_TestDeath_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests death" );
  2978.     cmdSystem->AddCommand( "testSave",                Cmd_TestSave_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "writes out a test savegame" );
  2979.     cmdSystem->AddCommand( "testModel",                idTestModel::TestModel_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests a model", idTestModel::ArgCompletion_TestModel );
  2980.     cmdSystem->AddCommand( "testSkin",                idTestModel::TestSkin_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests a skin on an existing testModel", idCmdSystem::ArgCompletion_Decl<DECL_SKIN> );
  2981.     cmdSystem->AddCommand( "testShaderParm",        idTestModel::TestShaderParm_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "sets a shaderParm on an existing testModel" );
  2982.     cmdSystem->AddCommand( "keepTestModel",            idTestModel::KeepTestModel_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "keeps the last test model in the game" );
  2983.     cmdSystem->AddCommand( "testAnim",                idTestModel::TestAnim_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests an animation", idTestModel::ArgCompletion_TestAnim );
  2984.     cmdSystem->AddCommand( "testParticleStopTime",    idTestModel::TestParticleStopTime_f,CMD_FL_GAME|CMD_FL_CHEAT,    "tests particle stop time on a test model" );
  2985.     cmdSystem->AddCommand( "nextAnim",                idTestModel::TestModelNextAnim_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "shows next animation on test model" );
  2986.     cmdSystem->AddCommand( "prevAnim",                idTestModel::TestModelPrevAnim_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "shows previous animation on test model" );
  2987.     cmdSystem->AddCommand( "nextFrame",                idTestModel::TestModelNextFrame_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "shows next animation frame on test model" );
  2988.     cmdSystem->AddCommand( "prevFrame",                idTestModel::TestModelPrevFrame_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "shows previous animation frame on test model" );
  2989.     cmdSystem->AddCommand( "testBlend",                idTestModel::TestBlend_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests animation blending" );
  2990.     cmdSystem->AddCommand( "reloadScript",            Cmd_ReloadScript_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "reloads scripts" );
  2991.     cmdSystem->AddCommand( "script",                Cmd_Script_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "executes a line of script" );
  2992.     cmdSystem->AddCommand( "listCollisionModels",    Cmd_ListCollisionModels_f,    CMD_FL_GAME,                "lists collision models" );
  2993.     cmdSystem->AddCommand( "collisionModelInfo",    Cmd_CollisionModelInfo_f,    CMD_FL_GAME,                "shows collision model info" );
  2994.     cmdSystem->AddCommand( "reexportmodels",        Cmd_ReexportModels_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "reexports models", ArgCompletion_DefFile );
  2995.     cmdSystem->AddCommand( "reloadanims",            Cmd_ReloadAnims_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "reloads animations" );
  2996.     cmdSystem->AddCommand( "listAnims",                Cmd_ListAnims_f,            CMD_FL_GAME,                "lists all animations" );
  2997.     cmdSystem->AddCommand( "aasStats",                Cmd_AASStats_f,                CMD_FL_GAME,                "shows AAS stats" );
  2998.     cmdSystem->AddCommand( "testDamage",            Cmd_TestDamage_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "tests a damage def", idCmdSystem::ArgCompletion_Decl<DECL_ENTITYDEF> );
  2999.     cmdSystem->AddCommand( "weaponSplat",            Cmd_WeaponSplat_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "projects a blood splat on the player weapon" );
  3000.     cmdSystem->AddCommand( "saveSelected",            Cmd_SaveSelected_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "saves the selected entity to the .map file" );
  3001.     cmdSystem->AddCommand( "deleteSelected",        Cmd_DeleteSelected_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "deletes selected entity" );
  3002.     cmdSystem->AddCommand( "saveMoveables",            Cmd_SaveMoveables_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "save all moveables to the .map file" );
  3003.     cmdSystem->AddCommand( "saveRagdolls",            Cmd_SaveRagdolls_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "save all ragdoll poses to the .map file" );
  3004.     cmdSystem->AddCommand( "bindRagdoll",            Cmd_BindRagdoll_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "binds ragdoll at the current drag position" );
  3005.     cmdSystem->AddCommand( "unbindRagdoll",            Cmd_UnbindRagdoll_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "unbinds the selected ragdoll" );
  3006.     cmdSystem->AddCommand( "saveLights",            Cmd_SaveLights_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "saves all lights to the .map file" );
  3007.     cmdSystem->AddCommand( "saveParticles",            Cmd_SaveParticles_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "saves all lights to the .map file" );
  3008.     cmdSystem->AddCommand( "clearLights",            Cmd_ClearLights_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "clears all lights" );
  3009.     cmdSystem->AddCommand( "gameError",                Cmd_GameError_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "causes a game error" );
  3010.  
  3011. // RAVEN BEGIN
  3012. // rjohnson: entity usage stats
  3013.     cmdSystem->AddCommand( "listEntityStats",        Cmd_ListEntityStats_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "lists global entity stats" );
  3014. // ddynerman: mp spawning test command
  3015.     cmdSystem->AddCommand( "evaluateMPPerformance",    Cmd_EvaluateMPPerformance_f,CMD_FL_GAME|CMD_FL_CHEAT,    "spawns serveral player models", idCmdSystem::ArgCompletion_Decl<DECL_ENTITYDEF> );
  3016.     cmdSystem->AddCommand( "listMapEntities",        idGameLocal::Cmd_PrintMapEntityNumbers_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "lists map entity numbers" );
  3017.     cmdSystem->AddCommand( "listSpawnIds",            idGameLocal::Cmd_PrintSpawnIds_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "lists map entity numbers" );
  3018. // RAVEN END
  3019.  
  3020. #ifndef    ID_DEMO_BUILD
  3021.     cmdSystem->AddCommand( "disasmScript",            Cmd_DisasmScript_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "disassembles script" );
  3022. // RAVEN BEGIN
  3023. // rjohnson: removed old not taking system
  3024. /*
  3025.     cmdSystem->AddCommand( "recordViewNotes",        Cmd_RecordViewNotes_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "record the current view position with notes" );
  3026.     cmdSystem->AddCommand( "showViewNotes",            Cmd_ShowViewNotes_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "show any view notes for the current map, successive calls will cycle to the next note" );
  3027.     cmdSystem->AddCommand( "closeViewNotes",        Cmd_CloseViewNotes_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "close the view showing any notes for this map" );
  3028. */
  3029. // RAVEN END
  3030.     cmdSystem->AddCommand( "exportmodels",            Cmd_ExportModels_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "exports models", ArgCompletion_DefFile );
  3031.  
  3032.     // multiplayer client commands ( replaces old impulses stuff )
  3033.     //cmdSystem->AddCommand( "clientDropWeapon",        idMultiplayerGame::DropWeapon_f, CMD_FL_GAME,            "drop current weapon" );
  3034.     cmdSystem->AddCommand( "clientMessageMode",        idMultiplayerGame::MessageMode_f, CMD_FL_GAME,            "ingame gui message mode" );
  3035.     // FIXME: implement
  3036.     cmdSystem->AddCommand( "clientVote",            idMultiplayerGame::Vote_f,    CMD_FL_GAME,                "cast your vote: clientVote yes | no" );
  3037.     cmdSystem->AddCommand( "clientCallVote",        idMultiplayerGame::CallVote_f,    CMD_FL_GAME,            "call a vote: clientCallVote si_.. proposed_value" );
  3038.     cmdSystem->AddCommand( "clientVoiceChat",        idMultiplayerGame::VoiceChat_f,    CMD_FL_GAME,            "voice chats: clientVoiceChat <sound shader>" );
  3039.     cmdSystem->AddCommand( "clientVoiceChatTeam",    idMultiplayerGame::VoiceChatTeam_f,    CMD_FL_GAME,        "team voice chats: clientVoiceChat <sound shader>" );
  3040. // RAVEN BEGIN
  3041.     // jshepard
  3042.     cmdSystem->AddCommand( "forceTeamChange",                idMultiplayerGame::ForceTeamChange_f,            CMD_FL_GAME,        "force team change: forceTeamChange <id>" );
  3043.     cmdSystem->AddCommand( "removeClientFromBanList",        idMultiplayerGame::RemoveClientFromBanList_f,    CMD_FL_GAME,        "removes a client id from the ban list: removeClientFromBanList <client id>" );
  3044.  
  3045. #ifndef _XBOX
  3046. // shouchard:  more voice chat stuff (non-XBOX)
  3047.     cmdSystem->AddCommand( "clientvoicemute",        idMultiplayerGame::VoiceMute_f, CMD_FL_GAME,            "mute the specified player's incoming voicechat" );
  3048.     cmdSystem->AddCommand( "clientvoiceunmute",        idMultiplayerGame::VoiceUnmute_f, CMD_FL_GAME,            "unmute the specified player's incoming voicechat" );
  3049. #endif // _XBOX
  3050. // RAVEN END
  3051.  
  3052.     // multiplayer server commands
  3053.     cmdSystem->AddCommand( "verifyServerSettings",    idGameLocal::VerifyServerSettings_f,    CMD_FL_GAME,    "verifies the game type can be played on the map" );
  3054.     cmdSystem->AddCommand( "serverMapRestart",        idGameLocal::MapRestart_f,    CMD_FL_GAME,                "restart the current game" );
  3055.     cmdSystem->AddCommand( "serverForceReady",        idMultiplayerGame::ForceReady_f,CMD_FL_GAME,                "force all players ready" );
  3056.     cmdSystem->AddCommand( "serverNextMap",            idGameLocal::NextMap_f,        CMD_FL_GAME,                "change to the next map" );
  3057. #endif
  3058.  
  3059.     // localization help commands
  3060.     cmdSystem->AddCommand( "nextGUI",                Cmd_NextGUI_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "teleport the player to the next func_static with a gui" );
  3061.     cmdSystem->AddCommand( "testid",                Cmd_TestId_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "output the string for the specified id." );
  3062.  
  3063. // RAVEN BEGIN
  3064. // bdube: vehicle code
  3065.     cmdSystem->AddCommand( "killVehicles",            Cmd_KillVehicles_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "kills all vehicles" );
  3066.     cmdSystem->AddCommand( "killMessage",            Cmd_KillMessage_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "prints a fake death message" );
  3067.     cmdSystem->AddCommand( "apState",                Cmd_APState_f,                CMD_FL_GAME|CMD_FL_CHEAT,    "prints AP state" );
  3068. // bdube: jump points
  3069.     cmdSystem->AddCommand( "jump",                    Cmd_DebugJump_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "jumps to a specific debug jump point" );
  3070.     cmdSystem->AddCommand( "nextjumppoint",            Cmd_DebugNextJumpPoint_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "jumps to the next debug jump point " );
  3071.     cmdSystem->AddCommand( "prevjumppoint",            Cmd_DebugPrevJumpPoint_f,    CMD_FL_GAME|CMD_FL_CHEAT,    "jumps to the previous debug jump point" );
  3072. // cdr: Added Extract Tactical
  3073.     cmdSystem->AddCommand( "extract_tactical",        Cmd_AASExtractTactical_f,    CMD_FL_GAME,                "pulls tactical information for the current position." );
  3074. // RAVEN END
  3075.  
  3076. // RAVEN BEGIN
  3077. // abahr
  3078.     cmdSystem->AddCommand( "call",                    Cmd_CallScriptFunc_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "calls script function and prints out return val" );
  3079.     cmdSystem->AddCommand( "setPlayerGravity",        Cmd_SetPlayerGravity_f,        CMD_FL_GAME|CMD_FL_CHEAT,    "sets players local gravity" );
  3080. // cdr
  3081.     cmdSystem->AddCommand( "ai_debugFilter",        Cmd_AI_DebugFilter_f,        CMD_FL_GAME,                "ai_debugMove and ai_debugTactical only work on the specified entity (if none, does one you're looking at)", idGameLocal::ArgCompletion_AIName );
  3082. // ddynerman: multiple arena/CW stuff
  3083.     cmdSystem->AddCommand( "setInstance",            Cmd_SetInstance_f,            CMD_FL_GAME,                "sets a player's world instance" );
  3084.     cmdSystem->AddCommand( "addIcon",                Cmd_AddIcon_f,                CMD_FL_GAME,                "adds a test icon" );
  3085.     cmdSystem->AddCommand( "listInstances",            Cmd_ListInstances_f,        CMD_FL_GAME,                "lists instances" );
  3086. // ddynerman: emote anims
  3087.     cmdSystem->AddCommand( "emote",                    Cmd_PlayerEmote_f,            CMD_FL_GAME,                "plays an emote" );
  3088.  
  3089.     cmdSystem->AddCommand( "checkSave",                Cmd_CheckSave_f,            CMD_FL_GAME,                "tests save system" );
  3090.  
  3091. // jshepard: fade music in / out
  3092.     cmdSystem->AddCommand( "fadeSound",                Cmd_FadeSound_f,            CMD_FL_GAME|CMD_FL_CHEAT,    "fades all sound by X decibles over Y seconds" );
  3093.  
  3094. // mekberg: added.
  3095.     cmdSystem->AddCommand( "setPMCVars",            Cmd_SetPMCVars_f,            CMD_FL_GAME,                "Resets player movement cvars" );
  3096. // RAVEN END
  3097. }
  3098.  
  3099. /*
  3100. =================
  3101. idGameLocal::ShutdownConsoleCommands
  3102. =================
  3103. */
  3104. void idGameLocal::ShutdownConsoleCommands( void ) {
  3105.     cmdSystem->RemoveFlaggedCommands( CMD_FL_GAME );
  3106. }
  3107.