Exemple #1
0
int IDialPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, RemoteId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, LocalId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, CallerId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, FeeNumber, 21 );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #2
0
void CargarInvent(int NpcIndex) {
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: - */
	/* ' */
	/* '*************************************************** */

	/* 'Vuelve a cargar el inventario del npc NpcIndex */
	int LoopC;
	std::string ln;
	std::string npcfile;

	npcfile = GetDatPath(DATPATH::NPCs);

	Npclist[NpcIndex].Invent.NroItems = vb6::val(
			GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "NROITEMS"));
	Npclist[NpcIndex].Invent.NroItems = vb6::Constrain(Npclist[NpcIndex].Invent.NroItems, 0, MAX_INVENTORY_SLOTS);

	for (LoopC = (1); LoopC <= (Npclist[NpcIndex].Invent.NroItems); LoopC++) {
		ln = GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "Obj" + vb6::CStr(LoopC));
		Npclist[NpcIndex].Invent.Object[LoopC].ObjIndex = vb6::val(ReadField(1, ln, 45));
		Npclist[NpcIndex].Invent.Object[LoopC].Amount = vb6::val(ReadField(2, ln, 45));

	}

}
Exemple #3
0
int IRingPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, CallerId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, PhonNumber, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, xCommandId, 10 );
	_stscanf( xCommandId, "%i", &ChNumber );
	nRead += nField; ptr += nField;
	
	if ( *( ptr ) != '\r' ) return -1;
	
	return nRead + 1;
}
Exemple #4
0
/* ' @remarks This function reads the Npc.dat file */
int EncontrarCant(int NpcIndex, int ObjIndex) {
	int retval;
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: 03/09/08 */
	/* 'Last Modification By: Marco Vanotti (Marco) */
	/* ' - 03/09/08 EncontrarCant now returns 0 if the npc doesn't have it (Marco) */
	/* '*************************************************** */

	/* 'Devuelve la cantidad original del obj de un npc */

	std::string ln;
	std::string npcfile;
	int i;

	npcfile = GetDatPath(DATPATH::NPCs);

	for (i = (1); i <= (MAX_INVENTORY_SLOTS); i++) {
		ln = GetVar(npcfile, "NPC" + vb6::CStr(Npclist[NpcIndex].Numero), "Obj" + vb6::CStr(i));
		if (ObjIndex == vb6::val(ReadField(1, ln, 45))) {
			retval = (int) vb6::val(ReadField(2, ln, 45));
			return retval;
		}
	}

	retval = 0;

	return retval;
}
Exemple #5
0
int IAchnPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR sField[10];
	
	DWORD nRead = ReadField( pBuffer, sField, 10 );
	if ( ! IsCommandId( sField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, sField, 10, ',' );
	_stscanf( sField, "%i", &ChType );
	nRead += nField; ptr += nField + 1;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, sField, 10, ',' );
	_stscanf( sField, "%i", &ChFirst );
	nRead += nField; ptr += nField + 1;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, sField, 10, ',' );
	_stscanf( sField, "%i", &ChLength );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #6
0
int IHandPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, ClientId, 8 );
	nRead += nField; ptr += nField;
	
	if ( *( ptr ) != '\r' ) return -1;
	
	return nRead + 1;
}
Exemple #7
0
int CPacketBase::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	DWORD nRead = CPacket::LoadPacket( pBuffer, nLength );
	if ( nRead == -1 ) return -1;
	
	CHAR szTemp[16];
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, szTemp, 16 );
	nRead += nField; ptr += nField;
	
	ASSERT( m_pXML == NULL );
	DWORD nXMLLength = _ttoi( szTemp );
	
	if ( nLength - nRead < 2 + nXMLLength )
	{
		return BufferSize = 0;
	}
	
	CXMLElement* pXML = CXMLElement::FromBytes( pBuffer + nRead + 2, nXMLLength, FALSE );
	m_pXML = ( pXML ) ? LoadBody( pXML ) : NULL;
	
	if ( ! m_pXML && pXML ) delete pXML;

	BufferSize = nRead + 2 + nXMLLength;
	return BufferSize;
}
Exemple #8
0
bool CDBF::Locate(bool bLoca)
{	
	unsigned int uiHave,i,j;
	unsigned long ulPrevious=m_ulCurRecLine;
	char cResult[MAX_CHAR_LENGTH+1];
	memset(cResult,0,MAX_CHAR_LENGTH+1);
	for (i=0;i<m_ulRecCount;i++)
	{
		uiHave=0;
		m_ulCurRecLine=i;
		for (j=0;j<m_uiCond;j++)
		{
			ReadField(m_pszCondition[j][0],cResult,MAX_CHAR_LENGTH);
			AllTrim(cResult);
			if (strnicmp(cResult,m_pszCondition[j][1],MAX_CHAR_LENGTH)==0)
			{
				uiHave++;
			}
		}
		if (uiHave==m_uiCond)
		{
			if (bLoca)
				m_ulCurRecLine=i;
			else
				m_ulCurRecLine=ulPrevious;
			return true;
		}
	}
	m_ulCurRecLine=ulPrevious;
	return false;
}
Exemple #9
0
int IWalkPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR sField[10];
	
	DWORD nRead = ReadField( pBuffer, sField, 10 );
	if ( ! IsCommandId( sField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, WalkId, 21 );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #10
0
/*
==============
ReadLevelLocals
 
All pointer variables(except function pointers) must be handled specially.
==============
*/
void ReadLevelLocals(FILE *f){
	field_t	*field;
	
	fread(&level, sizeof(level), 1, f);
	
	for(field = levelfields; field->name; field++){
		ReadField(f, field,(byte *)&level);
	}
}
Exemple #11
0
/*
==============
ReadClient
 
All pointer variables(except function pointers) must be handled specially.
==============
*/
void ReadClient(FILE *f, gclient_t *client){
	field_t	*field;
	
	fread(client, sizeof(*client), 1, f);
	
	for(field = clientfields; field->name; field++){
		ReadField(f, field,(byte *)client);
	}
}
Exemple #12
0
/*
==============
ReadEdict
 
All pointer variables(except function pointers) must be handled specially.
==============
*/
void ReadEdict(FILE *f, edict_t *ent){
	field_t	*field;
	
	fread(ent, sizeof(*ent), 1, f);
	
	for(field = fields; field->name; field++){
		ReadField(f, field,(byte *)ent);
	}
}
Exemple #13
0
static void ParseSub( const string & s, char & cmd, vector <string> & fields ) {

	unsigned int i = 0;
	cmd = MustGet( s, i++ );
	if ( cmd != SUB_CMD ) {
		CSVTHROW( "Invalid value for " << FLAG_EDIT << ": " << s );
	}
	char sep = MustGet( s, i++ );
	if (  sep == '\\' ) {
		CSVTHROW( "Invalid value for " << FLAG_EDIT << ": " << s );
	}

	string f = ReadField( s, i, sep );
	fields.push_back( f );
	f = ReadField( s, i, sep );
	fields.push_back( f );
	f = s.substr( i );
	fields.push_back( f );
}
Exemple #14
0
int ITalkPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;

	if ( *( pBuffer + nRead ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #15
0
int IUserPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xField[32];
	
	DWORD nRead = ReadField( pBuffer, xField, 10 );
	if ( ! IsCommandId( xField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, UserId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, MD5Hashing, 32 ); 
	nRead += nField; ptr += nField;
	
	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #16
0
int ILisnPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR sField[10];
	
	DWORD nRead = ReadField( pBuffer, sField, 10 );
	if ( ! IsCommandId( sField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, sField, 10 );
	_stscanf( sField, "%i", &Channel );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, PakParam, 16 );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
Exemple #17
0
int ISyncPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR sField[10];
	
	DWORD nRead = ReadField( pBuffer, sField, 10 );
	if ( ! IsCommandId( sField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, sField, 10 );
	_stscanf( sField, "%lf", &SyncMoney );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, sField, 10 );
	_stscanf( sField, "%i", &SyncRepeat );
	nRead += nField; ptr += nField;
	
	if ( *( ptr ) != '\r' ) return -1;
	
	return nRead + 1;
}
Exemple #18
0
int IRedPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR sField[10];
	
	DWORD nRead = ReadField( pBuffer, sField, 10 );
	if ( ! IsCommandId( sField ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, sField, 10, ',' );
	VERIFY( _tcscmp( sField, "MIN" ) == 0 );
	nRead += nField; ptr += nField + 1;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, sField, 10, ',' );
	_stscanf( sField, "%i", &Minutes );
	nRead += nField; ptr += nField;
	
	if ( *( ptr ) != '\r' ) return -1;
	
	return nRead + 1;
}
Exemple #19
0
void* ShineImpl::RequestRepeatedField(int8 index, int32 offset) {
    SendCommand('r');
    transport_->SendByte(index);
    transport_->SendUInt32(offset);

    // Read back the value.
    int8 field_index = transport_->ReadByte(); // Ignored
    FieldTypes field_type = input_->type(index);

    // TODO(jmcgill): Work out how this value survives on the stack. Might need
    // a RequestRepeatedField for each type (or size) of repeated field?
    return ReadField(field_type);
}
/*
==============
ReadClient

All pointer variables (except function pointers) must be handled specially.
==============
*/
void ReadClient (FILE *f, gclient_t *client)
{
	field_t		*field;

	fread (client, sizeof(*client), 1, f);

	client->pers.spawn_landmark = false;
	client->pers.spawn_levelchange = false;
	for (field=clientfields ; field->name ; field++)
	{		
		ReadField (f, field, (byte *)client);
	}
}
/*
==============
ReadLevelLocals

All pointer variables (except function pointers) must be handled specially.
==============
*/
void ReadLevelLocals (FILE *f)
{
	field_t		*field;

	if (fread(&level, sizeof(level), 1, f) == 0) {
        Com_Printf("ReadLevelLocals failed fread");
    }

	for (field=levelfields ; field->name ; field++)
	{
		ReadField (f, field, (byte *)&level);
	}
}
Exemple #22
0
void ShineImpl::HandleReceivedField() {
    int8 field_index = transport_->ReadByte();

    if (input_->repeated(field_index)) {
        // Only the size of repeated fields is sent in advance.
        int32 size = transport_->ReadUInt32();
        input_->set_size(field_index, size);
    } else {
        // The actual value is sent for scalar fields.
        FieldTypes field_type = input_->type(field_index);
        void* value = ReadField(field_type);
        input_->set_value(field_index, value);
    }
}
Exemple #23
0
int IRoutPacket::LoadPacket(BYTE* pBuffer, DWORD nLength)
{
	CHAR xCommandId[10];
#ifdef _DEBUG
//	pBuffer=(BYTE*)"SVR 96031222 V13867877813\r\n";
#endif
	
	DWORD nRead = ReadField( pBuffer, xCommandId, 10 );
	if ( ! IsCommandId( xCommandId ) ) return -1;
	BYTE* ptr = pBuffer + nRead;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	int nField = ReadField( ptr, RemoteId, 21 );
	nRead += nField; ptr += nField;
	
	for ( ; (*ptr) == ' ' && nRead < nLength; ptr++, nRead++ );
	nField = ReadField( ptr, PakParam, 800, '\0' );
	nRead += nField; ptr += nField;

	if ( *( ptr ) != '\r' ) return -1;

	return nRead + 1;
}
/*
==============
ReadEdict

All pointer variables (except function pointers) must be handled specially.
==============
*/
void ReadEdict (FILE *f, edict_t *ent)
{
	field_t		*field;
	int		i; // Knightmare added

	fread (ent, sizeof(*ent), 1, f);

	for (field=fields ; field->name ; field++)
	{
		ReadField (f, field, (byte *)ent);
	}
	// Knightmare- nullify reflection pointers to prevent crash
	for (i=0; i<6; i++)
		ent->reflection[i] = NULL;
}
bool
ConfigManager::ReadObjectHelper(std::istream &in, DataNode *parentNode, bool &te)
{
    bool keepReading = true;
    bool tagIsEndTag = false;
    std::string  tagName;
    NodeTypeEnum tagType = INTERNAL_NODE;
    int          tagLength = 0;

    // Read the opening tag.
    keepReading = ReadTag(in, tagName, tagType, tagLength, tagIsEndTag);

    if(tagIsEndTag && keepReading)
    {
        te = true;
        return keepReading;
    }

    if(tagType == INTERNAL_NODE)
    {
        DataNode *node = new DataNode(tagName);
        parentNode->AddNode(node);

        while(keepReading && !tagIsEndTag)
        {
            keepReading = ReadObjectHelper(in, node, tagIsEndTag);
        }

        if(tagIsEndTag)
            return keepReading;
    }
    else
        keepReading = ReadField(in, parentNode, tagName, tagType, tagLength);

    // Read the ending tag.
    stringVector sv = ReadStringVector(in,'>');
    keepReading = sv.size() > 0;

    te = false;
    return keepReading;
}
Exemple #26
0
unsigned long CDBF::Count()
{
	unsigned int i,j;
	unsigned long ulPrevious=m_ulCurRecLine;
	unsigned long ulCount=0;
	char cResult[MAX_CHAR_LENGTH+1];
	memset(cResult,0,MAX_CHAR_LENGTH+1);
	for (i=0;i<m_ulRecCount;i++)
	{
		m_ulCurRecLine=i;
		for (j=0;j<m_uiCond;j++)
		{
			ReadField(m_pszCondition[j][0],cResult,MAX_CHAR_LENGTH);
			AllTrim(cResult);
			if (strnicmp(cResult,m_pszCondition[j][1],0)==0)
			{
				ulCount++;
			}
		}
	}
	m_ulCurRecLine=ulPrevious;
	return ulCount;
}
bool FObjectReplicator::ReceivedBunch( FInBunch& Bunch, const FReplicationFlags& RepFlags, bool& bOutHasUnmapped )
{
	UObject* Object = GetObject();

	if ( Object == NULL )
	{
		UE_LOG(LogNet, Verbose, TEXT("ReceivedBunch: Object == NULL"));
		return false;
	}

	UPackageMap * PackageMap = OwningChannel->Connection->PackageMap;

	const bool bIsServer = ( OwningChannel->Connection->Driver->ServerConnection == NULL );

	const FClassNetCache * ClassCache = OwningChannel->Connection->Driver->NetCache->GetClassNetCache( ObjectClass );

	if ( ClassCache == NULL )
	{
		UE_LOG(LogNet, Error, TEXT("ReceivedBunch: ClassCache == NULL: %s"), *Object->GetFullName());
		return false;
	}

	bool bThisBunchReplicatedProperties = false;

	// Read first field
	const FFieldNetCache * FieldCache = ReadField( ClassCache, Bunch );

	if ( Bunch.IsError() )
	{
		UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Error reading field 1: %s"), *Object->GetFullName());
		return false;
	}

	if ( FieldCache == NULL )
	{
		// There are no actual replicated properties or functions in this bunch. That is ok - we may have gotten this
		// actor/sub-object because we want the client to spawn one (but we aren't actually replicating properties on it)
		return true;
	}

	while ( FieldCache )
	{
		// Receive properties from the net.
		UProperty* ReplicatedProp = NULL;

		while ( FieldCache && ( ReplicatedProp = Cast< UProperty >( FieldCache->Field ) ) != NULL )
		{
			NET_CHECKSUM( Bunch );

			// Server shouldn't receive properties.
			if ( bIsServer )
			{
				UE_LOG(LogNet, Error, TEXT("Server received unwanted property value %s in %s"), *ReplicatedProp->GetName(), *Object->GetFullName());
				return false;
			}
		
			bThisBunchReplicatedProperties = true;

			if ( !bHasReplicatedProperties )
			{
				bHasReplicatedProperties = true;		// Persistent, not reset until PostNetReceive is called
				PreNetReceive();
			}

			bool DebugProperty = false;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
			{
				static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("net.Replication.DebugProperty"));
				if (CVar && !CVar->GetString().IsEmpty() && ReplicatedProp->GetName().Contains(CVar->GetString()) )
				{
					UE_LOG(LogRep, Log, TEXT("Replicating Property[%d] %s on %s"), ReplicatedProp->RepIndex, *ReplicatedProp->GetName(), *Object->GetName());
					DebugProperty = true;
				}
			}
#endif
			if ( !Retirement[ ReplicatedProp->RepIndex ].CustomDelta )
			{
				bool bLocalHasUnmapped = false;
				// We hijack a non custom delta property to signify we are using FRepLayout to read the entire property block
				if ( !RepLayout->ReceiveProperties( ObjectClass, RepState, (void*)Object, Bunch, bLocalHasUnmapped ) )
				{
					UE_LOG(LogRep, Error, TEXT("ReceiveProperties FAILED %s in %s"), *ReplicatedProp->GetName(), *Object->GetFullName());
					return false;
				}

				if ( bLocalHasUnmapped )
				{
					bOutHasUnmapped = true;
				}
			}
			else
			{
				// Receive array index.
				uint32 Element = 0;
				if ( ReplicatedProp->ArrayDim != 1 )
				{
					check( ReplicatedProp->ArrayDim >= 2 );

					Bunch.SerializeIntPacked( Element );

					if ( Element >= (uint32)ReplicatedProp->ArrayDim )
					{
						UE_LOG(LogRep, Error, TEXT("Element index too large %s in %s"), *ReplicatedProp->GetName(), *Object->GetFullName());
						return false;
					}
				}

				// Pointer to destination.
				uint8* Data = ReplicatedProp->ContainerPtrToValuePtr<uint8>((uint8*)Object, Element);
				TArray<uint8>	MetaData;
				const PTRINT DataOffset = Data - (uint8*)Object;

				// Receive custom delta property.
				UStructProperty * StructProperty = Cast< UStructProperty >( ReplicatedProp );

				if ( StructProperty == NULL )
				{
					// This property isn't custom delta
					UE_LOG(LogRepTraffic, Error, TEXT("Property isn't custom delta %s"), *ReplicatedProp->GetName());
					return false;
				}

				UScriptStruct * InnerStruct = StructProperty->Struct;

				if ( !( InnerStruct->StructFlags & STRUCT_NetDeltaSerializeNative ) )
				{
					// This property isn't custom delta
					UE_LOG(LogRepTraffic, Error, TEXT("Property isn't custom delta %s"), *ReplicatedProp->GetName());
					return false;
				}

				UScriptStruct::ICppStructOps * CppStructOps = InnerStruct->GetCppStructOps();

				check( CppStructOps );
				check( !InnerStruct->InheritedCppStructOps() );

				FNetDeltaSerializeInfo Parms;

				FNetSerializeCB NetSerializeCB( OwningChannel->Connection->Driver );

				Parms.DebugName			= StructProperty->GetName();
				Parms.Struct			= InnerStruct;
				Parms.Map				= PackageMap;
				Parms.Reader			= &Bunch;
				Parms.NetSerializeCB	= &NetSerializeCB;

				// Call the custom delta serialize function to handle it
				CppStructOps->NetDeltaSerialize( Parms, Data );

				if ( Bunch.IsError() )
				{
					UE_LOG(LogNet, Error, TEXT("ReceivedBunch: NetDeltaSerialize - Bunch.IsError() == true: %s"), *Object->GetFullName());
					return false;
				}

				if ( Parms.bOutHasMoreUnmapped )
				{
					UnmappedCustomProperties.Add( DataOffset, StructProperty );
					bOutHasUnmapped = true;
				}

				// Successfully received it.
				UE_LOG(LogRepTraffic, Log, TEXT(" %s - %s"), *Object->GetName(), *ReplicatedProp->GetName());

				// Notify the Object if this var is RepNotify
				QueuePropertyRepNotify( Object, ReplicatedProp, Element, MetaData );
			}	
			
			// Read next field
			FieldCache = ReadField( ClassCache, Bunch );

			if ( Bunch.IsError() )
			{
				UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Error reading field 2: %s"), *Object->GetFullName());
				return false;
			}
		}

		// Handle function calls.
		if ( FieldCache && Cast< UFunction >( FieldCache->Field ) )
		{
			FName Message = FieldCache->Field->GetFName();
			UFunction * Function = Object->FindFunction( Message );

			if ( Function == NULL )
			{
				UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Function == NULL: %s"), *Object->GetFullName());
				return false;
			}

			if ( ( Function->FunctionFlags & FUNC_Net ) == 0 )
			{
				UE_LOG(LogRep, Error, TEXT("Rejected non RPC function %s in %s"), *Message.ToString(), *Object->GetFullName());
				return false;
			}

			if ( ( Function->FunctionFlags & ( bIsServer ? FUNC_NetServer : ( FUNC_NetClient | FUNC_NetMulticast ) ) ) == 0 )
			{
				UE_LOG(LogRep, Error, TEXT("Rejected RPC function due to access rights %s in %s"), *Message.ToString(), *Object->GetFullName());
				return false;
			}

			UE_LOG(LogRepTraffic, Log, TEXT("      Received RPC: %s"), *Message.ToString());

			// Get the parameters.
			FMemMark Mark(FMemStack::Get());
			uint8* Parms = new(FMemStack::Get(),MEM_Zeroed,Function->ParmsSize)uint8;

			// Use the replication layout to receive the rpc parameter values
			TSharedPtr<FRepLayout> FuncRepLayout = OwningChannel->Connection->Driver->GetFunctionRepLayout( Function );

			FuncRepLayout->ReceivePropertiesForRPC( Object, Function, OwningChannel, Bunch, Parms );

			if ( Bunch.IsError() )
			{
				UE_LOG(LogRep, Error, TEXT("ReceivedBunch: ReceivePropertiesForRPC - Bunch.IsError() == true: Function: %s, Object: %s"), *Message.ToString(), *Object->GetFullName());
				return false;
			}

			// validate that the function is callable here
			const bool bCanExecute = ( !bIsServer || RepFlags.bNetOwner );		// we are client or net owner

			if ( bCanExecute )
			{
				// Call the function.
				RPC_ResetLastFailedReason();

				Object->ProcessEvent( Function, Parms );

				if ( RPC_GetLastFailedReason() != NULL )
				{
					UE_LOG(LogRep, Error, TEXT("ReceivedBunch: RPC_GetLastFailedReason: %s"), RPC_GetLastFailedReason());
					return false;
				}
			}
			else
			{
				UE_LOG(LogRep, Verbose, TEXT("Rejected unwanted function %s in %s"), *Message.ToString(), *Object->GetFullName());

				if ( !OwningChannel->Connection->TrackLogsPerSecond() )	// This will disconnect the client if we get here too often
				{
					UE_LOG(LogRep, Error, TEXT("Rejected too many unwanted functions %s in %s"), *Message.ToString(), *Object->GetFullName());
					return false;
				}
			}

			// Destroy the parameters.
			//warning: highly dependent on UObject::ProcessEvent freeing of parms!
			for ( UProperty * Destruct=Function->DestructorLink; Destruct; Destruct=Destruct->DestructorLinkNext )
			{
				if( Destruct->IsInContainer(Function->ParmsSize) )
				{
					Destruct->DestroyValue_InContainer(Parms);
				}
			}

			Mark.Pop();

			if ( Object == NULL || Object->IsPendingKill() )
			{
				// replicated function destroyed Object
				return true;		// FIXME: Should this return false to kick connection?  Seems we'll cause a read misalignment here if we don't
			}

			// Next.
			FieldCache = ReadField( ClassCache, Bunch );

			if ( Bunch.IsError() )
			{
				UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Error reading field 3: %s"), *Object->GetFullName());
				return false;
			}
		}
		else if ( FieldCache )
		{
			UE_LOG(LogRep, Error, TEXT("ReceivedBunch: Invalid replicated field %i in %s"), FieldCache->FieldNetIndex, *Object->GetFullName());
			return false;
		}
	}

	return true;
}
void SimpleGeometryCreator::Run(const std::vector<String>& arguments)
{
	if(arguments.size() < 3)
		THROW("Must be 3 auguments for command");

	ptr<FileSystem> fileSystem = FolderFileSystem::GetNativeFileSystem();
	//открыть исходный файл
	_wfreopen(Strings::UTF82Unicode(arguments[0]).c_str(), L"rb", stdin);

	//размеры текстуры
	textureWidth = 1;
	textureHeight = 1;
	//размер вершины
	size_t vertexStride = 0;
	//считать поля
	char str[1024];
	while(gets_s(str))
	{
		Field field;
		//считать тип и размеры
		char typeStr[32];
		size_t i;
		for(i = 0; str[i] && isalpha(str[i]); ++i)
			typeStr[i] = str[i];
		typeStr[i] = 0;
		sscanf(str + i, "%dx%d", &field.size1, &field.size2);
		for(; str[i] && !isspace(str[i]); ++i);
		for(; str[i] && isspace(str[i]); ++i);
		field.divider = str[i];

		//получить тип
		size_t fieldSize;
		if(strcmp(typeStr, "float") == 0)
		{
			field.type = Field::typeFloat;
			fieldSize = sizeof(float);
		}
		else if(strcmp(typeStr, "int") == 0)
		{
			field.type = Field::typeInt;
			fieldSize = sizeof(int);
		}
		else if(strcmp(typeStr, "uint") == 0)
		{
			field.type = Field::typeUInt;
			fieldSize = sizeof(unsigned);
		}
		else if(strcmp(typeStr, "end") == 0)
			break;
		else if(strcmp(typeStr, "width") == 0)
		{
			textureWidth = field.size1;
			continue;
		}
		else if(strcmp(typeStr, "height") == 0)
		{
			textureHeight = field.size1;
			continue;
		}
		else
			THROW(String("Unknown field type: ") + typeStr);

		vertexStride += fieldSize * field.size1 * field.size2;

		//добавить поле
		fields.push_back(field);
	}

	//создать поток вывода в памяти
	stream = new MemoryStream();

	//цикл считывания вершин
	bool stop = false, indexed = false;
	while(!stop)
	{
		//проверить, может там начинается слово indexes
		char c;
		scanf(" %c", &c);
		if(c == 'i')
		{
			indexed = true;
			char s[10];
			scanf("%s", s);
			break;
		}
		else
			ungetc(c, stdin);
		//цикл считывания полей в вершине
		for(size_t i = 0; i < fields.size(); ++i)
			//если поле не считалось
			if(!ReadField(fields[i]))
				//если оно не первое в вершине, то это плохо
				if(i)
					THROW("Can't read field");
				//иначе это нормально, просто завершить цикл
				else
				{
					stop = true;
					break;
				}
	}

	//если индексы, считывать и их
	//индексы могут идти как 
	std::vector<short> indices;
	if(indexed)
	{
		for(;;)
		{
			//считать строку
			if(scanf("%s", str) != 1)
				break;
			//если это треугольник
			if(strcmp(str, "t") == 0)
			{
				//считать три индекса
				int a, b, c;
				if(scanf("%d%d%d", &a, &b, &c) != 3)
					THROW("Unexpected end of file: can't read triangle");
				indices.push_back(a);
				indices.push_back(b);
				indices.push_back(c);
			}
			//иначе если это прямоугольник
			else if(strcmp(str, "r") == 0)
			{
				//считать 4 индекса в порядке по часовой стрелке (как и треугольник)
				int a, b, c, d;
				if(scanf("%d%d%d%d", &a, &b, &c, &d) != 4)
					THROW("Unexpected end of file: can't read rectangle");
				indices.push_back(a);
				indices.push_back(b);
				indices.push_back(c);
				indices.push_back(a);
				indices.push_back(c);
				indices.push_back(d);
			}
			//иначе если это комментарий
			else if(strcmp(str, "/*") == 0)
				//найти закрывающий комментарий
				while(scanf("%s", str) == 1 && strcmp(str, "*/") != 0);
			//иначе если это однострочный комментарий
			else if(strcmp(str, "//") == 0)
				//считать все до конца строки
				gets_s(str);
			//иначе это что-то непонятное
			else
				THROW(String("Unknown type of index: ") + str);
		}
		if(indices.size() % 3)
			THROW("Number of indices must be divisible by 3");
	}

	ptr<File> indicesFile;
	if(indexed)
	{
		indicesFile = new MemoryFile(indices.size() * sizeof(short));
		memcpy(indicesFile->GetData(), &*indices.begin(), indicesFile->GetSize());
	}
	//создать геометрию
	ptr<Graphics::Geometry> geometry = NEW(Graphics::Geometry(stream->ToFile(), vertexStride, indicesFile, indexed ? sizeof(short) : 0, nullptr));
	//сохранить файл
	geometry->Serialize(fileSystem->SaveStream(arguments[1]), arguments[2]);
}
Exemple #29
0
int main (int argc, char* argv[])
{
   VString        inname;            /* name of input images      */
   VString        outname;           /* name of output images     */
   VString        fieldname;         /* name of deformation field */
   VBoolean       verbose = TRUE;    /* verbose flag              */
   VOptionDescRec options[] =        /* options of program        */
   {
      {"in",      VStringRepn,  1, &inname,    VRequiredOpt, NULL, "Input image"},
      {"out",     VStringRepn,  1, &outname,   VRequiredOpt, NULL, "Deformed output image"},
      {"field",   VStringRepn,  1, &fieldname, VRequiredOpt, NULL, "3D deformation field"},
      {"verbose", VBooleanRepn, 1, &verbose,   VOptionalOpt, NULL, "Show status messages. Optional"}
   };

   VAttrList in_history=NULL;      /* history of input images      */
   VAttrList field_history=NULL;   /* history of deformation field */

   VAttrList In;           /* input images  */
   VImage    Dx, Dy, Dz;   /* field images  */

   VAttrListPosn pos;   /* position in list */
   VImage        in;    /* image in list    */

   float  fx, fy, fz;   /* scaling factors          */
   VImage dx, dy, dz;   /* scaled deformation field */

   VAttrListPosn rider;                         /* functional data rider   */
   int           bands, rows, columns, steps;   /* size of functional data */
   VImage        data;                          /* functional data         */
   VShort        *src, *dest;                   /* functional data pointer */

   VBoolean success;   /* success flag */

   int n, t, z;   /* indices */


   /* print information */
   char prg_name[100];
	char ver[100];
	getLipsiaVersion(ver, sizeof(ver));
	sprintf(prg_name, "vdeform V%s", ver);
  
   fprintf (stderr, "%s\n", prg_name); fflush (stderr);

   /* parse command line */
   if (!VParseCommand (VNumber (options), options, &argc, argv))
   {
      if (argc > 1) VReportBadArgs (argc, argv);
      VReportUsage (argv[0], VNumber (options), options, NULL);
      exit (1);
   }

   /* read input images */
   if (verbose) {fprintf (stderr, "Reading input image '%s' ...\n", inname); fflush (stderr);}
   ReadImages (inname, In, in_history);
   if (!In) exit (2);

   /* read deformation field */
   if (verbose) {fprintf (stderr, "Reading 3D deformation field '%s' ...\n", fieldname); fflush (stderr);}
   ReadField (fieldname, Dx, Dy, Dz, field_history);
   if (!Dx || !Dy || !Dz) exit (3);


   /* deform anatomical images */
   for (VFirstAttr (In, &pos); VAttrExists (&pos); VNextAttr (&pos))
   {
      /* get image */
      VGetAttrValue (&pos, NULL, VImageRepn, &in);
      if (VPixelRepn (in) != VUByteRepn) break;

      /* compare image and field */
      if (verbose) {fprintf (stderr, "Comparing anatomical image and deformation field ...\n"); fflush (stderr);}
      if (!Compatible (in, Dx)) exit (4);
      if (!Compatible (in, Dy)) exit (4);
      if (!Compatible (in, Dz)) exit (4);

      /* deform image */
      if (verbose) {fprintf (stderr, "Deforming anatomical image ...\n"); fflush (stderr);}
      RTTI (in, TrilinearInverseDeform, (in, Dx, Dy, Dz));
      VSetAttrValue (&pos, NULL, VImageRepn, in);
   }


   /* deform map images */
   for (; VAttrExists (&pos); VNextAttr (&pos))
   {
      /* get image */
      VGetAttrValue (&pos, NULL, VImageRepn, &in);
      if (VPixelRepn (in) != VFloatRepn) break;

      /* scale field */
      if (verbose) {fprintf (stderr, "Scaling deformation field ...\n"); fflush (stderr);}
      fx = (float) VImageNColumns (in) / (float) VImageNColumns (Dx);
      fy = (float) VImageNRows    (in) / (float) VImageNRows    (Dy);
      fz = (float) VImageNBands   (in) / (float) VImageNBands   (Dz);
      TrilinearScale<VFloat> (Dx, fx, fy, fz, dx); Multiply<VFloat> (dx, fx);
      TrilinearScale<VFloat> (Dy, fx, fy, fz, dy); Multiply<VFloat> (dy, fy);
      TrilinearScale<VFloat> (Dz, fx, fy, fz, dz); Multiply<VFloat> (dz, fz);

      /* compare image and field */
      if (verbose) {fprintf (stderr, "Comparing map image and deformation field ...\n"); fflush (stderr);}
      if (!Compatible (in, dx)) exit (5);
      if (!Compatible (in, dy)) exit (5);
      if (!Compatible (in, dz)) exit (5);

      /* deform image */
      if (verbose) {fprintf (stderr, "Deforming map image ...\n"); fflush (stderr);}
      RTTI (in, TrilinearInverseDeform, (in, dx, dy, dz));
      VSetAttrValue (&pos, NULL, VImageRepn, in);

      /* clean-up */
      VDestroyImage (dx);
      VDestroyImage (dy);
      VDestroyImage (dz);
   }


   /* deform functional images */
   if (VAttrExists (&pos))
   {
      /* get data size */
      bands = rows = columns = steps = 0;
      for (rider = pos; VAttrExists (&rider); VNextAttr (&rider))
      {
         /* get image */
         VGetAttrValue (&rider, NULL, VImageRepn, &data);
         if (VPixelRepn (data) != VShortRepn) break;

         /* store image size */
         if (VImageNBands   (data) > steps)   steps   = VImageNBands   (data);
         if (VImageNRows    (data) > rows)    rows    = VImageNRows    (data);
         if (VImageNColumns (data) > columns) columns = VImageNColumns (data);
         bands++;
      }
      in = VCreateImage (bands, rows, columns, VShortRepn);

      /* scale field */
      if (verbose) {fprintf (stderr, "Scaling deformation field ...\n"); fflush (stderr);}
      fx = (float) VImageNColumns (in) / (float) VImageNColumns (Dx);
      fy = (float) VImageNRows    (in) / (float) VImageNRows    (Dy);
      fz = (float) VImageNBands   (in) / (float) VImageNBands   (Dz);
      TrilinearScale<VFloat> (Dx, fx, fy, fz, dx); Multiply<VFloat> (dx, fx);
      TrilinearScale<VFloat> (Dy, fx, fy, fz, dy); Multiply<VFloat> (dy, fy);
      TrilinearScale<VFloat> (Dz, fx, fy, fz, dz); Multiply<VFloat> (dz, fz);

      /* compare image and field */
      if (verbose) {fprintf (stderr, "Comparing functional images and deformation field ...\n"); fflush (stderr);}
      if (!Compatible (in, dx)) exit (6);
      if (!Compatible (in, dy)) exit (6);
      if (!Compatible (in, dz)) exit (6);


      /* expand zero images */
      for (rider = pos, z = 0; z < bands; z++, VNextAttr (&rider))
      {
         VGetAttrValue (&rider, NULL, VImageRepn, &data);
         if (FunctionalZero (data))
         {
            FunctionalResize (data, steps, rows, columns);
            VSetAttrValue (&rider, NULL, VImageRepn, data);
         }
      }

      /* deform images */
      if (verbose) {fprintf (stderr, "Deforming functional images ...\n"); fflush (stderr);}
      for (t = 0; t < steps; t++)
      {
         /* collect data */
         dest = (VShort*) VPixelPtr (in, 0, 0, 0);
         for (rider = pos, z = 0; z < bands; z++, VNextAttr (&rider))
         {
            VGetAttrValue (&rider, NULL, VImageRepn, &data);
            src = (VShort*) VPixelPtr (data, t, 0, 0);
            for (n = 0; n < rows * columns; ++n)
               *(dest++) = *(src++);
         }

         /* deform image */
         if (verbose) {fprintf (stderr, "Timestep %d of %d ...\r", t + 1, steps); fflush (stderr);}
         RTTI (in, TrilinearInverseDeform, (in, dx, dy, dz));

         /* spread data */
         src = (VShort*) VPixelPtr (in, 0, 0, 0);
         for (rider = pos, z = 0; z < bands; z++, VNextAttr (&rider))
         {
            VGetAttrValue (&rider, NULL, VImageRepn, &data);
            dest = (VShort*) VPixelPtr (data, t, 0, 0);
            for (n = 0; n < rows * columns; ++n)
               *(dest++) = *(src++);
         }
      }

      /* collapse zero images */
      for (rider = pos, z = 0; z < bands; z++, VNextAttr (&rider))
      {
         VGetAttrValue (&rider, NULL, VImageRepn, &data);
         if (FunctionalZero (data))
         {
            FunctionalResize (data, 1, 1, 1);
            VSetAttrValue (&rider, NULL, VImageRepn, data);
         }
      }


      /* clean-up */
      VDestroyImage (in);
      VDestroyImage (dx);
      VDestroyImage (dy);
      VDestroyImage (dz);

      /* proceed */
      pos = rider;
   }


   /* check list */
   if (VAttrExists (&pos))
   {
      VError ("Remaining image does not contain valid data");
      exit (7);
   }

   /* Prepend History */
   VPrependHistory(VNumber(options),options,prg_name,&in_history);

   /* write output images */
   if (verbose) {fprintf (stderr, "Writing output image '%s' ...\n", outname); fflush (stderr);}
   success = WriteImages (outname, In, in_history);
   if (!success) exit (8);


   /* clean-up 
      VDestroyAttrList (inhistory);
      VDestroyAttrList (fieldhistory);
      VDestroyAttrList (In);
      VDestroyImage (Dx);
      VDestroyImage (Dy);
      VDestroyImage (Dz); */

   /* exit */
   if (verbose) {fprintf (stderr, "Finished.\n"); fflush (stderr);}
   return 0;

} /* main */
Exemple #30
0
int OpenNPC(int NpcNumber, bool Respawn) {
	int retval;
	/* '*************************************************** */
	/* 'Author: Unknown */
	/* 'Last Modification: - */
	/* ' */
	/* '*************************************************** */

	int NpcIndex;
	std::shared_ptr<clsIniManager> Leer;
	int LoopC;
	std::string ln;

	Leer = (LeerNPCs);

	std::string npcSect = "NPC" + vb6::CStr(NpcNumber);

	/* 'If requested index is invalid, abort */
	if (!Leer->KeyExists(npcSect)) {
		retval = MAXNPCS + 1;
		return retval;
	}

	NpcIndex = NextOpenNPC();

	/* 'Limite de npcs */
	if (NpcIndex > MAXNPCS) {
		retval = NpcIndex;
		return retval;
	}

	Npclist[NpcIndex].Numero = NpcNumber;
	Npclist[NpcIndex].Name = Leer->GetValue(npcSect, "Name");
	Npclist[NpcIndex].desc = Leer->GetValue(npcSect, "Desc");

	Npclist[NpcIndex].Movement = static_cast<TipoAI>(vb6::CInt(Leer->GetValue(npcSect, "Movement")));
	Npclist[NpcIndex].flags.OldMovement = Npclist[NpcIndex].Movement;

	Npclist[NpcIndex].flags.AguaValida = vb6::val(Leer->GetValue(npcSect, "AguaValida"));
	Npclist[NpcIndex].flags.TierraInvalida = vb6::val(Leer->GetValue(npcSect, "TierraInValida"));
	Npclist[NpcIndex].flags.Faccion = vb6::val(Leer->GetValue(npcSect, "Faccion"));
	Npclist[NpcIndex].flags.AtacaDoble = vb6::val(Leer->GetValue(npcSect, "AtacaDoble"));

	Npclist[NpcIndex].NPCtype = static_cast<eNPCType>(vb6::CInt(Leer->GetValue(npcSect, "NpcType")));

	Npclist[NpcIndex].Char.body = vb6::val(Leer->GetValue(npcSect, "Body"));
	Npclist[NpcIndex].Char.Head = vb6::val(Leer->GetValue(npcSect, "Head"));
	Npclist[NpcIndex].Char.heading = static_cast<eHeading>(vb6::CInt(Leer->GetValue(npcSect, "Heading")));

	Npclist[NpcIndex].Attackable = vb6::val(Leer->GetValue(npcSect, "Attackable"));
	Npclist[NpcIndex].Comercia = vb6::val(Leer->GetValue(npcSect, "Comercia"));
	Npclist[NpcIndex].Hostile = vb6::val(Leer->GetValue(npcSect, "Hostile"));
	Npclist[NpcIndex].flags.OldHostil = Npclist[NpcIndex].Hostile;

	Npclist[NpcIndex].GiveEXP = vb6::val(Leer->GetValue(npcSect, "GiveEXP"));
	if (HappyHourActivated && (HappyHour != 0)) {
		Npclist[NpcIndex].GiveEXP = Npclist[NpcIndex].GiveEXP * HappyHour;
	}

	Npclist[NpcIndex].flags.ExpCount = Npclist[NpcIndex].GiveEXP;

	Npclist[NpcIndex].Veneno = vb6::val(Leer->GetValue(npcSect, "Veneno"));

	Npclist[NpcIndex].flags.Domable = vb6::val(Leer->GetValue(npcSect, "Domable"));

	Npclist[NpcIndex].GiveGLD = vb6::val(Leer->GetValue(npcSect, "GiveGLD"));

	Npclist[NpcIndex].PoderAtaque = vb6::val(Leer->GetValue(npcSect, "PoderAtaque"));
	Npclist[NpcIndex].PoderEvasion = vb6::val(Leer->GetValue(npcSect, "PoderEvasion"));

	Npclist[NpcIndex].InvReSpawn = vb6::val(Leer->GetValue(npcSect, "InvReSpawn"));

	Npclist[NpcIndex].Stats.MaxHp = vb6::val(Leer->GetValue(npcSect, "MaxHP"));
	Npclist[NpcIndex].Stats.MinHp = vb6::val(Leer->GetValue(npcSect, "MinHP"));
	Npclist[NpcIndex].Stats.MaxHIT = vb6::val(Leer->GetValue(npcSect, "MaxHIT"));
	Npclist[NpcIndex].Stats.MinHIT = vb6::val(Leer->GetValue(npcSect, "MinHIT"));
	Npclist[NpcIndex].Stats.def = vb6::val(Leer->GetValue(npcSect, "DEF"));
	Npclist[NpcIndex].Stats.defM = vb6::val(Leer->GetValue(npcSect, "DEFm"));
	Npclist[NpcIndex].Stats.Alineacion = vb6::val(Leer->GetValue(npcSect, "Alineacion"));

	Npclist[NpcIndex].Invent.NroItems = vb6::Constrain(vb6::CInt(Leer->GetValue(npcSect, "NROITEMS")), 0, MAX_DAT_ITEMS);
	for (LoopC = (1); LoopC <= (Npclist[NpcIndex].Invent.NroItems); LoopC++) {
		ln = Leer->GetValue(npcSect, "Obj" + vb6::CStr(LoopC));
		Npclist[NpcIndex].Invent.Object[LoopC].ObjIndex = vb6::val(ReadField(1, ln, 45));
		Npclist[NpcIndex].Invent.Object[LoopC].Amount = vb6::val(ReadField(2, ln, 45));
	}

	for (LoopC = (1); LoopC <= (MAX_NPC_DROPS); LoopC++) {
		ln = Leer->GetValue(npcSect, "Drop" + vb6::CStr(LoopC));
		Npclist[NpcIndex].Drop[LoopC].ObjIndex = vb6::val(ReadField(1, ln, 45));
		Npclist[NpcIndex].Drop[LoopC].Amount = vb6::val(ReadField(2, ln, 45));
	}

	Npclist[NpcIndex].flags.LanzaSpells = vb6::Constrain(vb6::CInt(Leer->GetValue(npcSect, "LanzaSpells")), 0, MAXUSERHECHIZOS);
	if (Npclist[NpcIndex].flags.LanzaSpells > 0) {
		Npclist[NpcIndex].Spells.redim(0);
		Npclist[NpcIndex].Spells.redim(1, Npclist[NpcIndex].flags.LanzaSpells);
	}
	for (LoopC = (1); LoopC <= (Npclist[NpcIndex].flags.LanzaSpells); LoopC++) {
		Npclist[NpcIndex].Spells[LoopC] = vb6::val(Leer->GetValue(npcSect, "Sp" + vb6::CStr(LoopC)));
	}

	if (Npclist[NpcIndex].NPCtype == eNPCType_Entrenador) {
		Npclist[NpcIndex].NroCriaturas = vb6::Constrain(vb6::CInt(Leer->GetValue(npcSect, "NroCriaturas")), 0, MAX_CRIATURAS_ENTRENADOR);
		Npclist[NpcIndex].Criaturas.redim(0);
		Npclist[NpcIndex].Criaturas.redim(1, Npclist[NpcIndex].NroCriaturas);
		for (LoopC = (1); LoopC <= (Npclist[NpcIndex].NroCriaturas); LoopC++) {
			Npclist[NpcIndex].Criaturas[LoopC].NpcIndex = vb6::CInt(Leer->GetValue(npcSect, "CI" + vb6::CStr(LoopC)));
			Npclist[NpcIndex].Criaturas[LoopC].NpcName = Leer->GetValue(npcSect, "CN" + vb6::CStr(LoopC));
		}
	}

	Npclist[NpcIndex].flags.NPCActive = true;

	if (Respawn) {
		Npclist[NpcIndex].flags.Respawn = vb6::val(Leer->GetValue(npcSect, "ReSpawn"));
	} else {
		Npclist[NpcIndex].flags.Respawn = 1;
	}

	Npclist[NpcIndex].flags.BackUp = vb6::val(Leer->GetValue(npcSect, "BackUp"));
	Npclist[NpcIndex].flags.RespawnOrigPos = vb6::val(Leer->GetValue(npcSect, "OrigPos"));
	Npclist[NpcIndex].flags.AfectaParalisis = vb6::val(Leer->GetValue(npcSect, "AfectaParalisis"));

	Npclist[NpcIndex].flags.Snd1 = vb6::val(Leer->GetValue(npcSect, "Snd1"));
	Npclist[NpcIndex].flags.Snd2 = vb6::val(Leer->GetValue(npcSect, "Snd2"));
	Npclist[NpcIndex].flags.Snd3 = vb6::val(Leer->GetValue(npcSect, "Snd3"));

	/* '<<<<<<<<<<<<<< Expresiones >>>>>>>>>>>>>>>> */
	Npclist[NpcIndex].NroExpresiones = vb6::val(Leer->GetValue(npcSect, "NROEXP"));
	Npclist[NpcIndex].NroExpresiones = vb6::Constrain(Npclist[NpcIndex].NroExpresiones, 0, MAX_EXPRESIONES);
	
	if (Npclist[NpcIndex].NroExpresiones > 0) {
		Npclist[NpcIndex].Expresiones.redim(0);
		Npclist[NpcIndex].Expresiones.redim(1, Npclist[NpcIndex].NroExpresiones);
	}
	for (LoopC = (1); LoopC <= (Npclist[NpcIndex].NroExpresiones); LoopC++) {
		Npclist[NpcIndex].Expresiones[LoopC] = Leer->GetValue(npcSect, "Exp" + vb6::CStr(LoopC));
	}
	/* '<<<<<<<<<<<<<< Expresiones >>>>>>>>>>>>>>>> */

	/* 'Tipo de items con los que comercia */
	Npclist[NpcIndex].TipoItems = vb6::val(Leer->GetValue(npcSect, "TipoItems"));

	Npclist[NpcIndex].Ciudad = vb6::val(Leer->GetValue(npcSect, "Ciudad"));

	/* 'Update contadores de NPCs */
	if (NpcIndex > LastNPC) {
		LastNPC = NpcIndex;
	}
	NumNPCs = NumNPCs + 1;

	/* 'Devuelve el nuevo Indice */
	retval = NpcIndex;
	return retval;
}