engine/EngineServerEntity.c
/*	Parses an edict out of the given string, returning the new position
	ed should be a properly initialized empty edict.
	Used for initial level load and for savegames.
	[19/11/2012]
	Revised to work for our needs. ~hogsy
*/
Parses an edict out of the given string, returning the new position
ed should be a properly initialized empty edict.
Used for initial level load and for savegames.
[19/11/2012]
Revised to work for our needs. ~hogsy
Parses an edict out of the given string returning the new position ed should be a properly initialized empty edict . Used for initial level load and for savegames . [ 19 / 11 / 2012 ] Revised to work for our needs . ~hogsy
char *ED_ParseEdict(char *data, ServerEntity_t *ent)
{
	bool	bInit = false;
	char	keyname[256];
	int		n;
	if(ent != sv.edicts)	
		Edict_Clear(ent,false);
	for(;;)
	{
		data = COM_Parse(data);
		if(com_token[0] == '}')
			break;
		if(!data)
			Sys_Error("ED_ParseEntity: EOF without closing brace");
		strncpy(keyname, com_token, sizeof(keyname) - 1);
#ifdef _MSC_VER
#pragma warning(suppress: 6053)	// This is intended.
#endif
		n = strlen(keyname);
		if(n > 0)
			while(n && keyname[n-1] == ' ')
			{
				keyname[n-1] = 0;
				n--;
			}
		data = COM_Parse(data);
		if(!data)
			Sys_Error("ED_ParseEntity: EOF without closing brace");
		else if(com_token[0] == '}')
			Sys_Error("ED_ParseEntity: closing brace without data");
		bInit = true;
		if(keyname[0] == '_')
			continue;
		Game->Server_ParseEntityField(keyname, com_token, ent);
	}
	if(!bInit)
		ent->free = true;
	return data;
}
char * ED_ParseEdict ( char * data , ServerEntity_t * ent ) { bool bInit = false ; char keyname [ 256 ] ; int n ; if ( ent != sv . edicts ) Edict_Clear ( ent , false ) ; for ( ; ; ) { data = COM_Parse ( data ) ; if ( com_token [ 0 ] == ' ' ) break ; if ( ! data ) Sys_Error ( " " ) ; strncpy ( keyname , com_token , sizeof ( keyname ) - 1 ) ; #ifdef _MSC_VER #pragma  warning(suppress: 6053)	// This is intended. #endif n = strlen ( keyname ) ; if ( n > 0 ) while ( n && keyname [ n - 1 ] == ' ' ) { keyname [ n - 1 ] = 0 ; n -- ; } data = COM_Parse ( data ) ; if ( ! data ) Sys_Error ( " " ) ; else if ( com_token [ 0 ] == ' ' ) Sys_Error ( " " ) ; bInit = true ; if ( keyname [ 0 ] == ' ' ) continue ; Game -> Server_ParseEntityField ( keyname , com_token , ent ) ; } if ( ! bInit ) ent -> free = true ; return data ; }
Parses an edict out of the given string, returning the new position
ed should be a properly initialized empty edict.
Parses an edict out of the given string returning the new position ed should be a properly initialized empty edict .
// hack // Go through all the dictionary pairs // Parse key // Hack to fix keynames with trailing spaces // Parse value // keynames with a leading underscore are used for utility comments, // and are immediately discarded by quake