⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g_spawn.cpp

📁 this keik game source
💻 CPP
📖 第 1 页 / 共 3 页
字号:
//-----------------------------------------------------------------------------
//
//  $Logfile:: /Quake 2 Engine/Sin/code/game/g_spawn.cpp                      $
// $Revision:: 68                                                             $
//   $Author:: Jimdose                                                        $
//     $Date:: 1/29/99 6:14p                                                  $
//
// Copyright (C) 1998 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/g_spawn.cpp                           $
// 
// 68    1/29/99 6:14p Jimdose
// fixed savegame bug
// 
// 67    1/22/99 8:01p Jimdose
// G_SoawnEntities no longer calls G_LevelStart when loading a savegame.  This
// fixes the Darwin tubes bug in Area57.
// 
// 66    11/07/98 10:01p Jimdose
// added G_GetClassFromArgs
// 
// 65    11/05/98 8:29p Aldie
// Removed checksumming and fixed stuff for loading times
// 
// 64    10/28/98 4:46p Jimdose
// G_ArchiveEdict was accessing edict->owner->entity, which may be cleared out
// when called.
// 
// 63    10/27/98 9:46p Aldie
// Changed training cvar to level.training
// 
// 62    10/26/98 4:20p Markd
// Added game.skill variable
// 
// 61    10/25/98 11:57p Jimdose
// moved playerfrozen from game to level
// 
// 60    10/24/98 11:47p Jimdose
// made RestoreEnt call G_InitSpawnArguments
// 
// 59    10/23/98 3:43a Markd
// put in universal_script support
// 
// 58    10/19/98 11:46p Aldie
// Clear spawn arguments out after spawning things
// 
// 57    10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
// 
// 56    10/18/98 8:43p Jimdose
// Started adding check for SOLID_BSP and no model in SpawnEntities
// 
// 55    10/17/98 8:15p Jimdose
// Changed G_CallSpawn2 to G_CallSpawn
// 
// 54    10/17/98 12:21a Jimdose
// Added G_ResetEdicts
// 
// 53    10/16/98 1:50a Jimdose
// Removed G_SaveClientData from G_LevelShutdown
// 
// 52    10/15/98 7:13p Jimdose
// Overrode = for SpawnArgGroup.  Fixes crash on level change with multiplayer
// 
// 51    10/14/98 10:56p Jimdose
// More work on persistant data
// added archive functions for spawnargs classes
// 
// 50    10/14/98 1:18a Jimdose
// Got cross-level persistant info working
// 
// 49    10/11/98 8:51p Jimdose
// Added LoadingServer variable
// 
// 48    10/10/98 12:39p Markd
// Renamed team to moveteam
// 
// 47    10/10/98 1:27a Jimdose
// added G_Precache
// 
// 46    10/07/98 11:47p Jimdose
// Got savegames working
// 
// 45    9/15/98 6:46p Aldie
// Clear out the event list after deleting all the edicts
// 
// 44    9/02/98 3:47p Markd
// Put in precache ability for the main game script
// 
// 43    8/29/98 9:42p Jimdose
// Made all function names consistantly begin with G_
// Added call info to G_Trace
// 
// 42    8/29/98 2:53p Aldie
// Added status meter for loading levels.
// 
// 41    8/27/98 4:18p Jimdose
// Only start script when the world is spawned so that demomap won't start
// scripts
// 
// 40    8/24/98 1:33p Markd
// fixed null string problem with gamescript
// 
// 39    8/24/98 11:32a Markd
// Added Start method to threads, repladed all ProcessEvent(
// EV_ScriptThread_execute) with thread->Start( -1 )
// 
// 38    8/12/98 3:19p Aldie
// Created a G_CallSpawn2 that returns pointer to Entity that is created.
// Currently used with func_box.
// 
// 37    8/04/98 6:05p Aldie
// Relocated DETAIL spawnflag
// 
// 36    7/08/98 12:54p Jimdose
// Made developer c_var global
// 
// 35    7/02/98 5:24p Markd
// Added detail spawning abilities
// 
// 34    6/24/98 4:49p Aldie
// Made it so func_spawn will work.
// 
// 33    6/23/98 9:54p Jimdose
// Fixed infinite loop bug in G_RunFrame
// 
// 32    6/16/98 9:04p Markd
// made objects default to "Object" instead of "entity"
// 
// 31    5/27/98 5:02a Aldie
// Added queue for bloodsplats
// 
// 30    5/26/98 7:56p Jimdose
// added scripted cameras
// 
// 29    5/25/98 6:52a Aldie
// Added ResetBulletHoles to SpawnEntity
// 
// 28    5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
// 
// 27    5/24/98 4:48p Jimdose
// Made char *'s const
// 
// 26    5/24/98 2:47p Markd
// Made char *'s into const char *'s
// 
// 25    5/20/98 11:11a Markd
// removed char * dependency
// 
// 24    5/18/98 8:13p Jimdose
// Renamed Navigator back to PathManager
// 
// 23    5/12/98 7:07p Markd
// Put in Development spawnflag
// 
// 22    5/09/98 8:02p Jimdose
// AI nodes are saved after map changes
// 
// 21    4/30/98 5:28p Jimdose
// Removed check for null models in G_CallSpawn.  If an entity deleted itself
// in its constructor, the check would access deallocated memory
// 
// 20    4/29/98 5:04p Jimdose
// Fixed gi.error so that it doesn't crash when called from C++
// 
// 19    4/28/98 8:13p Jimdose
// Added checks to ensure that SOLID_BSP objects have models
// 
// 18    4/28/98 5:26p Jimdose
// Made spawnflags for !easy, !medium, !hard, !deathmatch and !coop work.
// 
// 17    4/27/98 3:42p Jimdose
// Navigator is initialized in SpawnEntities
// 
// 16    4/18/98 6:53p Markd
// Fixed spawning of new entity classes
// 
// 15    4/16/98 2:04p Jimdose
// Removed pathmanager
// 
// 14    4/07/98 9:18p Jimdose
// Think I found that bug where free_edicts gets put on the active_edicts list.
// 
// 13    4/07/98 8:02p Markd
// Added tons 'o SINMDL prefixed commands
// 
// 12    4/07/98 5:41p Jimdose
// Added assertions to G_Spawn and G_FreeEdict
// 
// 11    4/05/98 1:56a Jimdose
// fixed bug where edicts were being freed, but not entities when the map
// changed
// 
// 10    3/31/98 12:30a Markd
// Added models/ to spawning of model stuff
// 
// 9     3/30/98 9:44p Markd
// Added in proper spawing for classname "model"
// 
// 8     3/27/98 5:37p Jimdose
// SpawnEntities now frees up any entities for when levels change, but the game
// is the same.
// 
// 7     3/26/98 8:19p Jimdose
// G_FreeEdict no longer clears the edicts client variable
// 
// 6     3/13/98 7:24p Aldie
// Added get vector arg.
// 
// 5     3/02/98 5:46p Jimdose
// pathManager frees all cached paths on starting a map.
// 
// 4     2/19/98 5:03p Jimdose
// Moved G_Entity, G_Random, and G_CRandom to g_utils
// 
// 3     2/16/98 2:18p Jimdose
// Made G_FindTeams work
// Added active_edicts and free_edicts for faster entity processing and for
// operations that depend on the order that physics is processed on entities
// (such as binding).
// 
// 2     2/03/98 11:06a Jimdose
// Converted to work with Sin progs
// 
// 1     1/21/98 2:56p Jimdose
// 
// 3     12/30/97 6:04p Jimdose
// Added header text
//
// DESCRIPTION:
// 

#include "g_local.h"
#include "class.h"
#include "Entity.h"
#include "g_spawn.h"
#include "navigate.h"
#include <setjmp.h>
#include "player.h"
#include "gravpath.h"
#include "surface.h"
#include "console.h"
#include "object.h"

void G_ExitWithError( void );
extern jmp_buf	G_AbortGame;

SpawnArgsForEntity PersistantData;

typedef struct 
	{
	char key[ 64 ];
	char value[ 256 ];
	} spawnargs_t;

#define NUM_SPAWN_ARGS 32 

int			numSpawnArgs = 0;
spawnargs_t spawnArgs[ NUM_SPAWN_ARGS ];

/****************************************************************************

  SpawnArg Class Definition

****************************************************************************/

CLASS_DECLARATION( Class, SpawnArg, NULL );

ResponseDef SpawnArg::Responses[] =
	{
      { NULL, NULL }
   };

SpawnArg::SpawnArg()
   {
	memset( key, 0, sizeof( key ) );
	memset( value, 0, sizeof( value ) );
   }

SpawnArg::SpawnArg
   (
   SpawnArg &arg
   )

   {
   strcpy( key, arg.key );
   strcpy( value, arg.value );
   }

void SpawnArg::Archive
   (
   Archiver &arc
   )

   {
   Class::Archive( arc );

   arc.WriteRaw( key, sizeof( key ) );
   arc.WriteRaw( value, sizeof( value ) );
   }

void SpawnArg::Unarchive
   (
   Archiver &arc
   )

   {
   Class::Unarchive( arc );

   arc.ReadRaw( key, sizeof( key ) );
   arc.ReadRaw( value, sizeof( value ) );
   }

/****************************************************************************

  SpawnArgs Class Definition

****************************************************************************/

CLASS_DECLARATION( Class, SpawnArgs, NULL );

ResponseDef SpawnArgs::Responses[] =
	{
      { NULL, NULL }
   };

SpawnArgs::SpawnArgs()
   {
   }

SpawnArgs::SpawnArgs
   (
   SpawnArgs &otherlist
   )

   {
   SpawnArg arg1;
   SpawnArg *arg2;
   int num;
   int i;

   num = otherlist.NumArgs();
   for( i = 1; i <= num; i++ )
      {
      arg2 = otherlist.argList.AddressOfObjectAt( i );

      strcpy( arg1.key, arg2->key );
      strcpy( arg1.value, arg2->value );

      argList.AddObject( arg1 );
      }
   argList.Resize( num );
   }

void SpawnArgs::operator=
	(
	SpawnArgs &otherlist
	)

	{
   SpawnArg arg1;
   SpawnArg *arg2;
   int num;
   int i;

   argList.ClearObjectList();

   num = otherlist.NumArgs();
   for( i = 1; i <= num; i++ )
      {
      arg2 = otherlist.argList.AddressOfObjectAt( i );

      strcpy( arg1.key, arg2->key );
      strcpy( arg1.value, arg2->value );

      argList.AddObject( arg1 );
      }
   argList.Resize( num );
	}

int SpawnArgs::NumArgs
   (
   void
   )

   {
   return argList.NumObjects();
   }

void SpawnArgs::SetArgs
   (
   void
   )

   {
   SpawnArg arg;
   int i;

   for( i = 0; i < numSpawnArgs; i++ )
      {
      strcpy( arg.key, spawnArgs[ i ].key );
      strcpy( arg.value, spawnArgs[ i ].value );
      argList.AddObject( arg );
      }
   argList.Resize( numSpawnArgs );
   }

void SpawnArgs::RestoreArgs
   (
   void
   )

   {
   SpawnArg *arg;
   int i;

   numSpawnArgs = argList.NumObjects();
   for( i = 0; i < numSpawnArgs; i++ )
      {
      arg = &argList.ObjectAt( i + 1 );
      strcpy( spawnArgs[ i ].key, arg->key );
      strcpy( spawnArgs[ i ].value, arg->value );
      }
   }

void SpawnArgs::Archive
   (
   Archiver &arc
   )

   {
   int i;
   int num;

   Class::Archive( arc );

   num = argList.NumObjects();
   arc.WriteInteger( num );
   for( i = 1; i <= num; i++ )
      {
      arc.WriteObject( argList.AddressOfObjectAt( i ) );
      }
   }

void SpawnArgs::Unarchive
   (
   Archiver &arc
   )

   {
   int i;
   int num;

   Class::Unarchive( arc );

   argList.FreeObjectList();

   num = arc.ReadInteger();
   argList.Resize( num );
   for( i = 1; i <= num; i++ )
      {
      arc.ReadObject( argList.AddressOfObjectAt( i ) );
      }
   }

/****************************************************************************

  SpawnArgGroup Class Definition

****************************************************************************/

CLASS_DECLARATION( Class, SpawnArgGroup, NULL );

ResponseDef SpawnArgGroup::Responses[] =
	{
      { NULL, NULL }
   };

SpawnArgGroup::SpawnArgGroup()
   {
   }

SpawnArgGroup::SpawnArgGroup
   (
   SpawnArgGroup &group
   )

   {
   SpawnArgs *arg;
   int num;
   int i;

   num = group.spawnArgList.NumObjects();
   for( i = 1; i <= num; i++ )
      {
      arg = group.spawnArgList.AddressOfObjectAt( i );
      spawnArgList.AddObject( *arg );
      }
   spawnArgList.Resize( num );
   }

void SpawnArgGroup::operator=
	(
	SpawnArgGroup &group
	)

	{
   SpawnArgs *arg;
   int num;
   int i;

   num = group.spawnArgList.NumObjects();
   for( i = 1; i <= num; i++ )
      {
      arg = group.spawnArgList.AddressOfObjectAt( i );
      spawnArgList.AddObject( *arg );
      }
   spawnArgList.Resize( num );
	}

int SpawnArgGroup::NumInGroup
   (
   void
   )

   {
   return spawnArgList.NumObjects();
   }

void SpawnArgGroup::AddArgs
   (
   void
   )

   {
   SpawnArgs args;

   args.SetArgs();
   spawnArgList.AddObject( args );
   spawnArgList.Resize( NumInGroup() );
   }

void SpawnArgGroup::RestoreArgs
   (
   int i
   )

   {
   assert( ( i > 0 ) && ( i <= NumInGroup() ) );
   if ( ( i <= 0 ) || ( i > NumInGroup() ) )
      {
      G_InitSpawnArguments();
      return;
      }

   spawnArgList.ObjectAt( i ).RestoreArgs();
   }

void SpawnArgGroup::Archive
   (
   Archiver &arc
   )

   {
   int i;
   int num;

   Class::Archive( arc );

   num = spawnArgList.NumObjects();
   arc.WriteInteger( num );
   for( i = 1; i <= num; i++ )
      {
      arc.WriteObject( spawnArgList.AddressOfObjectAt( i ) );
      }
   }

void SpawnArgGroup::Unarchive
   (
   Archiver &arc
   )

   {
   int i;
   int num;

   Class::Unarchive( arc );

   spawnArgList.FreeObjectList();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -