Ejemplo n.º 1
0
void OnMCFCreateError(gcException &e)
{
	Warning(gcString("Failed to create mcf: {0}", e));
	g_WaitCon.notify();
}
Ejemplo n.º 2
0
int read_test1(TEST_DATA *data, IO_BUFFER *iobuf)
{
   IO_ITEM_HEADER item_header;
   int i;
   
   item_header.type = 99;             /* test data */
   if ( get_item_begin(iobuf,&item_header) < 0 )
   {
      Warning("Missing or invalid test data block.");
      return -4;
   }

   data->lvar[0]  = get_long(iobuf);
   data->lvar[1]  = get_long(iobuf);
   data->ilvar[0] = get_long(iobuf);
   data->ilvar[1] = get_long(iobuf);
   data->isvar[0] = get_short(iobuf);
   data->isvar[1] = get_short(iobuf);
   data->svar[0]  = get_short(iobuf);
   data->svar[1]  = get_short(iobuf);
   data->svar[2]  = get_short(iobuf);
   data->fvar[0]  = get_real(iobuf);
   data->fvar[1]  = get_real(iobuf);
   data->dvar[0]  = get_double(iobuf);
   data->dvar[1]  = get_double(iobuf);
   data->hvar[0]  = get_sfloat(iobuf);
   data->hvar[1]  = get_sfloat(iobuf);
   data->i8var[0] = get_byte(iobuf);
   data->i8var[1] = get_byte(iobuf);
   data->u8var[0] = get_byte(iobuf);
   data->u8var[1] = get_byte(iobuf);
   data->i16var[0] = get_short(iobuf);
   data->i16var[1] = get_short(iobuf);
   data->u16var[0] = get_short(iobuf);
   data->u16var[1] = get_short(iobuf);
   data->i32var[0] = get_int32(iobuf);
   data->i32var[1] = get_int32(iobuf);
   data->u32var[0] = get_uint32(iobuf);
   data->u32var[1] = get_uint32(iobuf);
#ifdef HAVE_64BIT_INT
   get_vector_of_int64(&data->i64var[0],1,iobuf);
   get_vector_of_int64(&data->i64var[1],1,iobuf);
   get_vector_of_uint64(&data->u64var[0],1,iobuf);
   get_vector_of_uint64(&data->u64var[1],1,iobuf);
#endif   
   data->nbvar = get_count(iobuf);
   data->bvar[0] = get_byte(iobuf);
   data->bvar[1] = get_byte(iobuf);
   for (i=0; i<4; i++)
      data->cnt16var[i] = get_count16(iobuf);
   for (i=0; i<6; i++)
      data->cnt32var[i] = get_count32(iobuf);
   for (i=0; i<6; i++)
      data->cntzvar[i] = get_count(iobuf);
   for (i=0; i<8; i++)
      data->cntvar[i] = get_count(iobuf);
   for (i=0; i<10; i++)
      data->scnt16var[i] = get_scount16(iobuf);
   for (i=0; i<12; i++)
      data->scnt32var[i] = get_scount32(iobuf);
   for (i=0; i<12; i++)
      data->scntzvar[i] = get_scount(iobuf);
   for (i=0; i<14; i++)
      data->scntvar[i] = get_scount(iobuf);
   get_string(data->str16var,sizeof(data->str16var),iobuf);
   get_long_string(data->str32var,sizeof(data->str32var),iobuf);
   get_var_string(data->strvvar,sizeof(data->strvvar),iobuf);

   return(get_item_end(iobuf,&item_header));
}
Ejemplo n.º 3
0
bool Data_Service::Get_Event_Data (Event_File &file, Event_Data &event_rec)
{
	int hhold, lvalue, link, dir, offset, dir_index;

	hhold = file.Household ();
	if (hhold < 1) return (false);

	event_rec.Household (hhold);

	event_rec.Person (file.Person ());
	event_rec.Tour (MAX (file.Tour (), 1));
	event_rec.Trip (file.Trip ());
	event_rec.Event (file.Event ());

	if (file.Version () <= 40) {
		event_rec.Mode (Trip_Mode_Map (file.Mode ()));
	} else {
		event_rec.Mode (file.Mode ());
	}
	event_rec.Schedule (file.Schedule ());
	event_rec.Actual (file.Actual ());

	//---- check/convert the link number and direction ----

	link = file.Link ();

	if (link > 0) {
		dir = file.Dir ();
		offset = Round (file.Offset ());
	
		Link_Data *link_ptr = Set_Link_Direction (file, link, dir, offset);

		if (link_ptr == 0) return (false);

		if (dir) {
			dir_index = link_ptr->BA_Dir ();
		} else {
			dir_index = link_ptr->AB_Dir ();
		}
		if (dir_index < 0) {
			Warning (String ("Event %d Link %d Direction %s was Not Found") % Progress_Count () % 
				link_ptr->Link () % ((dir) ? "BA" : "AB"));
		}
		event_rec.Dir_Index (dir_index);
		event_rec.Offset (offset);
		event_rec.Lane (file.Lane ());
	}

	lvalue = file.Route ();

	if (lvalue > 0) {
		if (System_File_Flag (TRANSIT_ROUTE)) {
			Int_Map_Itr map_itr = line_map.find (lvalue);

			if (map_itr == line_map.end ()) {
				Warning (String ("Event %d Route %d was Not Found") % Progress_Count () % lvalue);
				return (false);
			}
			event_rec.Route (map_itr->second);
		} else {
			event_rec.Route (lvalue);
		}
	}
	return (true);
}
Ejemplo n.º 4
0
/** Create and initialize the structure of the VM abstraction */ 
vm_t *create_vm(uint32_t vm[][VMCONF_NUMCOLUNS]) {
	static uint32_t vm_id = 1;  /* vm_id is the guestid */	
	static uint32_t tlbindex = 0; 	/* unique tlb entry */

	vm_t *ret;
	ll_node_t* nd;
	uint32_t i;
	vcpu_t *vcpu;
	
	/* number of fix tlb entries */
	uint32_t ntlbent = vm[0][2];

	if(!(nd = (ll_node_t*) calloc(1, sizeof(ll_node_t) + sizeof(vm_t))))
		return NULL;
    
	ret = (vm_t*)((unsigned int)nd + sizeof(ll_node_t));
    
	//Memory map
	ret->base_addr = vm[0][0];
	ret->size = vm[0][1];
	
	ret->id = vm_id++;  
	ret->os_type = vm[0][3];
	ret->ntlbent = ntlbent;
	ret->init = 1;

	ret->tlbentries = NULL;
        
#ifdef STATICTLB	
	/* allocate a tlb entry to the VM */
	if(ret->os_type != IDLEVCPU){
		ret->tlbentries = (struct tlbentry *)calloc(1, sizeof(struct tlbentry)*(ntlbent)); 
		memset(ret->tlbentries, 0, sizeof(struct tlbentry)*ntlbent);
	}else{
		ret->tlbentries = NULL;
		ret->id = 0;
	}
	/* fill the tlb entries to the VM */
	for(i=0; i<ntlbent; i++, tlbindex++){
		ret->tlbentries[i].guestid = vm[i+1][0];
		ret->tlbentries[i].index = tlbindex;
		ret->tlbentries[i].entrylo0 = vm[i+1][1];
		if(ret->tlbentries[i].entrylo0) 
			ret->tlbentries[i].lo0flags = ENTRYLO_V | ENTRYLO_D;
		ret->tlbentries[i].entrylo1 = vm[i+1][2];
		if(ret->tlbentries[i].entrylo1)
			ret->tlbentries[i].lo1flags = ENTRYLO_V | ENTRYLO_D;
		ret->tlbentries[i].pagemask = vm[i+1][3];
		ret->tlbentries[i].entryhi = vm[i+1][4];
		ret->tlbentries[i].coherency = vm[i+1][5];
		ret->tlbentries[i].onhardware = 0;
	}
#else	
	if(ret->os_type != IDLEVCPU){
		ret->vmmap = (memVMMap_t *)calloc(1, sizeof(memVMMap_t)*(ntlbent)); 
		memset(ret->vmmap, 0, sizeof(memVMMap_t)*ntlbent);
	}else{
		ret->vmmap = NULL;
		ret->id = 0;
	}

	/* fill the tlb entries to the VM */
	for(i=0; i<ntlbent; i++, tlbindex++){
		ret->vmmap[i].phyGuestBase = vm[i+1][1];
		ret->vmmap[i].vGuestBase = vm[i+1][4];
		ret->vmmap[i].size = vm[i+1][2];
		ret->vmmap[i].coherency = vm[i+1][5];
	}
#endif	
	/* Set the VM entry Point and scheduler*/
	switch(ret->os_type){
		case BAREOS:
			vcpu = create_vcpu(ret, vm[0][5], 0 ,0, vm[0][4], BAREOS);	
			addVcpu_bestEffortList(vcpu);			
			ll_append(&virtualmachines, nd);
			break;
		case GENERIC: 	
			vcpu = create_vcpu(ret, 0x80000000, 0, 0, vm[0][4], GENERIC);
			addVcpu_bestEffortList(vcpu);
			ll_append(&virtualmachines, nd);
			break;
		case HELLFIRE:
			vcpu = create_vcpu(ret, vm[0][5], 0, 0, vm[0][4], HELLFIRE);
			addVcpu_bestEffortList(vcpu);
			ll_append(&virtualmachines, nd);
			break;
		case BAREOS_RT:
			vcpu = create_vcpu(ret, 0x801000f4, 0, 0, vm[0][4], BAREOS_RT);
			addVcpu_servicesInitList(vcpu);		
			ll_append(&virtualmachines_rt, nd);
			break;
		case LINUX:
			vcpu = create_vcpu(ret, vm[0][5], 0, 0, vm[0][4], LINUX);
			addVcpu_bestEffortList(vcpu);		
			ll_append(&virtualmachines, nd);
			break;
		case IDLEVCPU:
			vcpu = create_vcpu(ret, vm[0][5], 0, 0, vm[0][4], IDLEVCPU);
			idle_vcpu = vcpu;		
			ll_append(&virtualmachines, nd);
			break;
			
		default:
			Warning("OS type 0x%x supported!\n", ret->os_type);
			break;
	}
	
	nd->ptr = ret;
		
	return ret;
}
Ejemplo n.º 5
0
void EmulApp::killProcs(QString name)
{
    if (!name.endsWith(".exe", Qt::CaseInsensitive)) name += ".exe";
    DWORD pids[8192];
    DWORD bret = 0;
    DWORD WINAPI (*fGetProcessImageFileNameA)(HANDLE, const char *, DWORD) = 0;
    HMODULE psapi_handle = LoadLibraryA("psapi.dll");
    // first see if we are on WinXP or Windows Vista by seeing if we can open psapi.dll and then fund the GetProcessImageFileNameA function
    // if not, resort to calling the command-line program 'taskkill'
    if (psapi_handle) {
        fGetProcessImageFileNameA = (DWORD WINAPI(*)(HANDLE, const char *, DWORD))GetProcAddress(psapi_handle, "GetProcessImageFileNameA");
    } else {
        DWORD err;
        QString msg = GetLastErrorMessage(&err);
        Warning() << "LoadLibrary(\"psapi.dll\") failed, error was: (" << err << ") " << msg;
    }
    if (fGetProcessImageFileNameA) {
        Debug() << "Got handle to psapi.dll and found GetProcessImageFileNameA at address " << ((void *)fGetProcessImageFileNameA);
        int n, i;
        if (!EnumProcesses(pids, sizeof(pids), &bret)) {
            Error() << "Could not enumerate processes for killProcs(" << name << ")";
            return;
            }
        n = bret / sizeof(*pids);
        for (i = 0; i < n; ++i) {
            HANDLE h = OpenProcess(PROCESS_ALL_ACCESS, 0, pids[i]);
            if (h) {
                char strbuf[1024];
                DWORD size = sizeof strbuf;
                if (fGetProcessImageFileNameA(h, strbuf, size)) {
                    strbuf[sizeof(strbuf)-1] = 0;
                    QString exename = strbuf;
                    QStringList pathcomps = exename.split("\\");
                    if (pathcomps.size() > 1) {
                        exename = pathcomps.back();
                    }
                    Debug() << "Found process " << pids[i] << " named " << exename;
                    if (exename.toLower() == name.toLower()) {
                        TerminateProcess(h, 0);
                        Log() << "Killing process " << pids[i] << " named `" << exename << "'";
                    }
                } else {
                    Warning() << "Could not grab .exe name for PID " << pids[i];
                }
                CloseHandle(h);
            } else {
                Debug() << "Could not open process with PID " << pids[i];
            }
        }
        FreeLibrary(psapi_handle);
        psapi_handle = 0;
    } else {
        Warning() << "killProcs() failed to use PSAPI for enumerating processes, reverting to taskkill.exe method";
        QStringList args;
        args.push_back("/F");
        args.push_back("/IM");
        args.push_back("/T");
        args.push_back(name);
        QProcess::execute("taskkill", args);
    }
}
Ejemplo n.º 6
0
KVHarpeeIC::KVHarpeeIC(UInt_t number, Float_t pressure, Float_t temp, Float_t thick) : KVVAMOSDetector(number, "C4H10")
{
   // Make the ionisation chamber of Harpee composed by:
   // - one 1.5 mylar window;
   // - 3 volumes of C4H10 with thicknesses (2*dz): 2.068 cm, thick, 1.278 cm.
   //   By default thick=10.457 cm;
   //   Only the 2nd gaz volume is "active".
   //
   // The width (2*dx) of this detector is ??? and the height (2*dy) is ???.
   // The ionisation chamber is closed with the silicon wall in Harpee.
   //
   // Input: pressure - pressure of the gaz in mbar
   //        temp     - temperature of the gaz in degrees celsius.
   //                   Default temperature = 19°C
   //        thick    - the thickness in cm of the 2nd volume of gaz.
   Warning("KVHarpeeIC", "Check if the width, the height and the thickness are correct in this constructor");

   init();
   SetType("CHI");
   SetLabel("CHI");
   SetName(GetArrayName());

   // number of absorber
   Int_t Nabs = 4;

   // material of each absorber
   const Char_t* mat[] = {"Myl", "C4H10", "C4H10", "C4H10"};

   // thickness of each absorber
   Float_t th[] = {
      static_cast<Float_t>(1.5 * KVUnits::um),
      static_cast<Float_t>(2.068 * KVUnits::cm),
      static_cast<Float_t>(thick * KVUnits::cm),
      static_cast<Float_t>(1.278 * KVUnits::cm)
   };

   // active absorber flag
   Bool_t  active[] = { kFALSE, kFALSE, kTRUE, kFALSE};

   // width and height of the detector. TO BE VERIFIED
   Float_t w = 40 * KVUnits::cm;
   Float_t h = 12 * KVUnits::cm;

   // total thickness of the detector
   Float_t wtot = 0;
   for (Int_t i = 0; i < Nabs; i++) wtot += th[i];

   // pressure and temperature of the detector
   SetPressure(pressure * KVUnits::mbar);
   SetTemperature(temp);

   // Adding the absorbers
   TGeoShape* shape = NULL;
   for (Int_t i = 0; i < Nabs; i++) {

      Double_t dx = w / 2;
      Double_t dy = h / 2;
      Double_t dz = th[i] / 2;

      fTotThick += th[i];

      // box shape of the absorber
      shape  = new TGeoBBox(dx, dy, dz);

      // build and position absorber in mother volume.
      // Reference is the center of absorber
      Double_t ztrans = dz - wtot / 2;
      for (Int_t j = 0; j < Nabs - 1; j++) ztrans += (j < i) * th[j];
      TGeoTranslation* tr = new TGeoTranslation(0., 0., ztrans);
      AddAbsorber(mat[i], shape, tr, active[i]);
   }
}
Ejemplo n.º 7
0
void CCollisionProperty::ComputeSurroundingBox( Vector *pVecWorldMins, Vector *pVecWorldMaxs )
{
	if (( GetSolid() == SOLID_CUSTOM ) && (m_nSurroundType != USE_GAME_CODE ))
	{
		// NOTE: This can only happen in transition periods, say during network
		// reception on the client. We expect USE_GAME_CODE to be used with SOLID_CUSTOM
		*pVecWorldMins = GetCollisionOrigin();
		*pVecWorldMaxs = *pVecWorldMins;
		return;
	}

	switch( m_nSurroundType )
	{
	case USE_OBB_COLLISION_BOUNDS:
		Assert( GetSolid() != SOLID_CUSTOM );
		ComputeOBBBounds( pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_BEST_COLLISION_BOUNDS:
		Assert( GetSolid() != SOLID_CUSTOM );
		ComputeCollisionSurroundingBox( (GetSolid() == SOLID_VPHYSICS), pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_ROTATION_EXPANDED_SEQUENCE_BOUNDS:
		ComputeRotationExpandedSequenceBounds( pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_COLLISION_BOUNDS_NEVER_VPHYSICS:
		Assert( GetSolid() != SOLID_CUSTOM );
		ComputeCollisionSurroundingBox( false, pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_HITBOXES:
		ComputeHitboxSurroundingBox( pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_ROTATION_EXPANDED_BOUNDS:
		ComputeRotationExpandedBounds( pVecWorldMins, pVecWorldMaxs );
		break;

	case USE_SPECIFIED_BOUNDS:
		VectorAdd( GetCollisionOrigin(), m_vecSpecifiedSurroundingMins, *pVecWorldMins );
		VectorAdd( GetCollisionOrigin(), m_vecSpecifiedSurroundingMaxs, *pVecWorldMaxs );
		break;

	case USE_GAME_CODE:
		GetOuter()->ComputeWorldSpaceSurroundingBox( pVecWorldMins, pVecWorldMaxs );
		Assert( pVecWorldMins->x <= pVecWorldMaxs->x );
		Assert( pVecWorldMins->y <= pVecWorldMaxs->y );
		Assert( pVecWorldMins->z <= pVecWorldMaxs->z );
		return;
	}

//#ifdef DEBUG
#ifdef CLIENT_DLL
	if ( cl_show_bounds_errors.GetBool() && ( m_nSurroundType == USE_ROTATION_EXPANDED_SEQUENCE_BOUNDS ) )
	{ 
		// For debugging purposes, make sure the bounds actually does surround the thing.
		// Otherwise the optimization we were using isn't really all that great, is it?
		Vector vecTestMins, vecTestMaxs;
		if ( GetOuter()->GetBaseAnimating() )
		{
			GetOuter()->GetBaseAnimating()->InvalidateBoneCache();
		}
		ComputeHitboxSurroundingBox( &vecTestMins, &vecTestMaxs );
		
		Assert( vecTestMins.x >= pVecWorldMins->x && vecTestMins.y >= pVecWorldMins->y && vecTestMins.z >= pVecWorldMins->z );
		Assert( vecTestMaxs.x <= pVecWorldMaxs->x && vecTestMaxs.y <= pVecWorldMaxs->y && vecTestMaxs.z <= pVecWorldMaxs->z );

		if ( vecTestMins.x < pVecWorldMins->x || vecTestMins.y < pVecWorldMins->y || vecTestMins.z < pVecWorldMins->z ||
			 vecTestMaxs.x > pVecWorldMaxs->x || vecTestMaxs.y > pVecWorldMaxs->y || vecTestMaxs.z > pVecWorldMaxs->z )
		{
			const char *pSeqName = "<unknown seq>";
			C_BaseAnimating *pAnim = GetOuter()->GetBaseAnimating();
			if ( pAnim )
			{
				int nSequence = pAnim->GetSequence();
				pSeqName = pAnim->GetSequenceName( nSequence );
			}

			Warning( "*** Bounds problem, index %d Eng %s, Seqeuence %s ", GetOuter()->entindex(), GetOuter()->GetClassname(), pSeqName );
			Vector vecDelta = *pVecWorldMins - vecTestMins;
			Vector vecDelta2 = vecTestMaxs - *pVecWorldMaxs;
			if ( vecDelta.x > 0.0f || vecDelta2.x > 0.0f || vecDelta.y > 0.0f || vecDelta2.y > 0.0f )
			{
				Msg( "Outside X/Y by %.2f ", MAX( MAX( vecDelta.x, vecDelta2.x ), MAX( vecDelta.y, vecDelta2.y ) ) );
			}
			if ( vecDelta.z > 0.0f || vecDelta2.z > 0.0f )
			{
				Msg( "Outside Z by (below) %.2f, (above) %.2f ", MAX( vecDelta.z, 0.0f ), MAX( vecDelta2.z, 0.0f ) );
			}
			Msg( "\n" );

			char pTemp[MAX_PATH];
			Q_snprintf( pTemp, sizeof(pTemp), "%s [seq: %s]", GetOuter()->GetClassname(), pSeqName ); 

			debugoverlay->AddBoxOverlay( vec3_origin, vecTestMins, vecTestMaxs, vec3_angle, 255, 0, 0, 0, 2 );
			debugoverlay->AddBoxOverlay( vec3_origin, *pVecWorldMins, *pVecWorldMaxs, vec3_angle, 0, 0, 255, 0, 2 );
			debugoverlay->AddTextOverlay( ( vecTestMins + vecTestMaxs ) * 0.5f, 2, pTemp );
		}
	}
#endif
//#endif
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Unserialization
//-----------------------------------------------------------------------------
bool CVTFTexture::Unserialize( CUtlBuffer &buf, bool bBufferHeaderOnly, int nSkipMipLevels )
{
	// When unserializing, we can skip a certain number of mip levels,
	// and we also can just load everything but the image data

	VTFFileHeader_t header;
	memset( &header, 0, sizeof(VTFFileHeader_t) );

	buf.Get( &header, sizeof(VTFFileHeader_t) );
	if (!buf.IsValid())
	{
		Warning("*** Error unserializing VTF file... is the file empty?\n");
		return false;
	}

	// Validity check
	if ( Q_strncmp( header.fileTypeString, "VTF", 4 ) )
	{
		Warning("*** Tried to load a non-VTF file as a VTF file!\n");
		return false;
	}

	if( header.version[0] != VTF_MAJOR_VERSION )
	{
		Warning("*** Encountered VTF file with an invalid version!\n");
		return false;
	}
	if( (header.flags & TEXTUREFLAGS_ENVMAP) && (header.width != header.height) )
	{
		Warning("*** Encountered VTF non-square cubemap!\n");
		return false;
	}
	if( header.width <= 0 || header.height <= 0 )
	{
		Warning( "*** Encountered VTF invalid texture size!\n" );
		return false;
	}

	m_nWidth = header.width;
	m_nHeight = header.height;
	m_Format = header.imageFormat;

	m_nFlags = header.flags;

	m_nFrameCount = header.numFrames;

	// NOTE: We're going to store space for all mip levels, even if we don't 
	// have data on disk for them. This is for backward compatibility
	m_nMipCount = ComputeMipCount();
	m_nFaceCount = (m_nFlags & TEXTUREFLAGS_ENVMAP) ? CUBEMAP_FACE_COUNT : 1;

	m_vecReflectivity = header.reflectivity;
	m_flBumpScale = header.bumpScale;

	// FIXME: Why is this needed?
	m_iStartFrame = header.startFrame;

	// FIXME: Remove
	// This is to make sure old-format .vtf files are read properly
	m_pVersion[0] = header.version[0];
	m_pVersion[1] = header.version[1];

	if( header.lowResImageWidth == 0 || header.lowResImageHeight == 0 )
	{
		m_nLowResImageWidth = 0;
		m_nLowResImageHeight = 0;
	}
	else
	{
		m_nLowResImageWidth = header.lowResImageWidth;
		m_nLowResImageHeight = header.lowResImageHeight;
	}
	m_LowResImageFormat = header.lowResImageFormat;
	
	// Helpful for us to be able to get VTF info without reading in a ton
	if (bBufferHeaderOnly)
		return true;

	if (!LoadLowResData( buf ))
		return false;

	if (!LoadImageData( buf, header, nSkipMipLevels ))
		return false;

	return true;
}
Ejemplo n.º 9
0
static void ParsePragma (void)
/* Parse the contents of the _Pragma statement */
{
    pragma_t Pragma;
    StrBuf   Ident = AUTO_STRBUF_INITIALIZER;

    /* Create a string buffer from the string literal */
    StrBuf B = AUTO_STRBUF_INITIALIZER;
    SB_Append (&B, GetLiteralStrBuf (CurTok.SVal));

    /* Skip the string token */
    NextToken ();

    /* Get the pragma name from the string */
    SB_SkipWhite (&B);
    if (!SB_GetSym (&B, &Ident, "-")) {
        Error ("Invalid pragma");
        goto ExitPoint;
    }

    /* Search for the name */
    Pragma = FindPragma (&Ident);

    /* Do we know this pragma? */
    if (Pragma == PRAGMA_ILLEGAL) {
        /* According to the ANSI standard, we're not allowed to generate errors
         * for unknown pragmas, but warn about them if enabled (the default).
         */
        if (IS_Get (&WarnUnknownPragma)) {
            Warning ("Unknown pragma `%s'", SB_GetConstBuf (&Ident));
        }
        goto ExitPoint;
    }

    /* Check for an open paren */
    SB_SkipWhite (&B);
    if (SB_Get (&B) != '(') {
        Error ("'(' expected");
        goto ExitPoint;
    }

    /* Skip white space before the argument */
    SB_SkipWhite (&B);

    /* Switch for the different pragmas */
    switch (Pragma) {

        case PRAGMA_ALIGN:
            IntPragma (&B, &DataAlignment, 1, 4096);
            break;

        case PRAGMA_BSSSEG:
            Warning ("#pragma bssseg is obsolete, please use #pragma bss-name instead");
            /* FALLTHROUGH */
        case PRAGMA_BSS_NAME:
            SegNamePragma (&B, SEG_BSS);
            break;

        case PRAGMA_CHARMAP:
            CharMapPragma (&B);
            break;

        case PRAGMA_CHECKSTACK:
            Warning ("#pragma checkstack is obsolete, please use #pragma check-stack instead");
            /* FALLTHROUGH */
        case PRAGMA_CHECK_STACK:
            FlagPragma (&B, &CheckStack);
            break;

        case PRAGMA_CODESEG:
            Warning ("#pragma codeseg is obsolete, please use #pragma code-name instead");
            /* FALLTHROUGH */
        case PRAGMA_CODE_NAME:
            SegNamePragma (&B, SEG_CODE);
            break;

        case PRAGMA_CODESIZE:
            IntPragma (&B, &CodeSizeFactor, 10, 1000);
            break;

        case PRAGMA_DATASEG:
            Warning ("#pragma dataseg is obsolete, please use #pragma data-name instead");
            /* FALLTHROUGH */
        case PRAGMA_DATA_NAME:
            SegNamePragma (&B, SEG_DATA);
            break;

        case PRAGMA_LOCAL_STRINGS:
            FlagPragma (&B, &LocalStrings);
            break;

        case PRAGMA_OPTIMIZE:
            FlagPragma (&B, &Optimize);
            break;

        case PRAGMA_REGVARADDR:
            FlagPragma (&B, &AllowRegVarAddr);
            break;

        case PRAGMA_REGVARS:
            Warning ("#pragma regvars is obsolete, please use #pragma register-vars instead");
            /* FALLTHROUGH */
        case PRAGMA_REGISTER_VARS:
            FlagPragma (&B, &EnableRegVars);
            break;

        case PRAGMA_RODATASEG:
            Warning ("#pragma rodataseg is obsolete, please use #pragma rodata-name instead");
            /* FALLTHROUGH */
        case PRAGMA_RODATA_NAME:
            SegNamePragma (&B, SEG_RODATA);
            break;

        case PRAGMA_SIGNEDCHARS:
            Warning ("#pragma signedchars is obsolete, please use #pragma signed-chars instead");
            /* FALLTHROUGH */
        case PRAGMA_SIGNED_CHARS:
            FlagPragma (&B, &SignedChars);
            break;

        case PRAGMA_STATICLOCALS:
            Warning ("#pragma staticlocals is obsolete, please use #pragma static-locals instead");
            /* FALLTHROUGH */
        case PRAGMA_STATIC_LOCALS:
            FlagPragma (&B, &StaticLocals);
            break;

        case PRAGMA_WARN:
            WarnPragma (&B);
            break;

        case PRAGMA_WRITABLE_STRINGS:
            FlagPragma (&B, &WritableStrings);
            break;

        case PRAGMA_ZPSYM:
            StringPragma (&B, MakeZPSym);
            break;

        default:
            Internal ("Invalid pragma");
    }

    /* Closing paren expected */
    SB_SkipWhite (&B);
    if (SB_Get (&B) != ')') {
        Error ("')' expected");
        goto ExitPoint;
    }
    SB_SkipWhite (&B);

    /* Allow an optional semicolon to be compatible with the old syntax */
    if (SB_Peek (&B) == ';') {
        SB_Skip (&B);
        SB_SkipWhite (&B);
    }

    /* Make sure nothing follows */
    if (SB_Peek (&B) != '\0') {
        Error ("Unexpected input following pragma directive");
    }

ExitPoint:
    /* Release the string buffers */
    SB_Done (&B);
    SB_Done (&Ident);
}
Ejemplo n.º 10
0
void Interpolator_CurveInterpolate_NonNormalized( int interpolationType,
												 const Quaternion &vPre,
												 const Quaternion &vStart,
												 const Quaternion &vEnd,
												 const Quaternion &vNext,
												 float f,
												 Quaternion &vOut )
{
	vOut.Init();

	switch ( interpolationType )
	{
	default:
		Warning( "Unknown interpolation type %d\n",
			(int)interpolationType );
		// break; // Fall through and use catmull_rom as default
	case INTERPOLATE_CATMULL_ROM_NORMALIZEX:
	case INTERPOLATE_DEFAULT:
	case INTERPOLATE_CATMULL_ROM:
	case INTERPOLATE_CATMULL_ROM_NORMALIZE:
	case INTERPOLATE_CATMULL_ROM_TANGENT:
	case INTERPOLATE_KOCHANEK_BARTELS:
	case INTERPOLATE_KOCHANEK_BARTELS_EARLY:
	case INTERPOLATE_KOCHANEK_BARTELS_LATE:
	case INTERPOLATE_SIMPLE_CUBIC:
	case INTERPOLATE_BSPLINE:
		// FIXME, since this ignores vPre and vNext we could omit computing them aove
		QuaternionSlerp( vStart, vEnd, f, vOut );
		break;
	case INTERPOLATE_EASE_IN:
		{
			f = sin( M_PI * f * 0.5f );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			QuaternionSlerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_EASE_OUT:
		{
			f = 1.0f - sin( M_PI * f * 0.5f + 0.5f * M_PI );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			QuaternionSlerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_EASE_INOUT:
		{
			f = SimpleSpline( f );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			QuaternionSlerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_LINEAR_INTERP:
		// Fixme, since this ignores vPre and vNext we could omit computing them aove
		QuaternionSlerp( vStart, vEnd, f, vOut );
		break;
	case INTERPOLATE_EXPONENTIAL_DECAY:
		vOut.Init();
		break;
	case INTERPOLATE_HOLD:
		{
			vOut = vStart;
		}
		break;
	}
}
Ejemplo n.º 11
0
void CRagdollProp::InitRagdoll( const Vector &forceVector, int forceBone, const Vector &forcePos, matrix3x4_t *pPrevBones, matrix3x4_t *pBoneToWorld, float dt, int collisionGroup, bool activateRagdoll )
{
	SetCollisionGroup( collisionGroup );

	// Make sure it's interactive debris for at most 5 seconds
	if ( collisionGroup == COLLISION_GROUP_INTERACTIVE_DEBRIS )
	{
		SetContextThink( &CRagdollProp::SetDebrisThink, gpGlobals->curtime + 5, s_pDebrisContext );
	}

	SetMoveType( MOVETYPE_VPHYSICS );
	SetSolid( SOLID_VPHYSICS );
	AddSolidFlags( FSOLID_CUSTOMRAYTEST | FSOLID_CUSTOMBOXTEST );
	m_takedamage = DAMAGE_EVENTS_ONLY;

	ragdollparams_t params;
	params.pGameData = static_cast<void *>( static_cast<CBaseEntity *>(this) );
	params.modelIndex = GetModelIndex();
	params.pCollide = modelinfo->GetVCollide( params.modelIndex );
	params.pStudioHdr = GetModelPtr();
	params.forceVector = forceVector;
	params.forceBoneIndex = forceBone;
	params.forcePosition = forcePos;
	params.pPrevBones = pPrevBones;
	params.pCurrentBones = pBoneToWorld;
	params.boneDt = dt;
	params.jointFrictionScale = 1.0;
	RagdollCreate( m_ragdoll, params, physenv );
	if ( m_anglesOverrideString != NULL_STRING && Q_strlen(m_anglesOverrideString.ToCStr()) > 0 )
	{
		char szToken[2048];
		const char *pStr = nexttoken(szToken, STRING(m_anglesOverrideString), ',');
		// anglesOverride is index,angles,index,angles (e.g. "1, 22.5 123.0 0.0, 2, 0 0 0, 3, 0 0 180.0")
		while ( szToken[0] != 0 )
		{
			int objectIndex = atoi(szToken);
			// sanity check to make sure this token is an integer
			Assert( atof(szToken) == ((float)objectIndex) );
			pStr = nexttoken(szToken, pStr, ',');
			Assert( szToken[0] );
			if ( objectIndex >= m_ragdoll.listCount )
			{
				Warning("Bad ragdoll pose in entity %s, model (%s) at %s, model changed?\n", GetDebugName(), GetModelName().ToCStr(), VecToString(GetAbsOrigin()) );
			}
			else if ( szToken[0] != 0 )
			{
				QAngle angles;
				Assert( objectIndex >= 0 && objectIndex < RAGDOLL_MAX_ELEMENTS );
				UTIL_StringToVector( angles.Base(), szToken );
				int boneIndex = m_ragdoll.boneIndex[objectIndex];
				AngleMatrix( angles, pBoneToWorld[boneIndex] );
				const ragdollelement_t &element = m_ragdoll.list[objectIndex];
				Vector out;
				if ( element.parentIndex >= 0 )
				{
					int parentBoneIndex = m_ragdoll.boneIndex[element.parentIndex];
					VectorTransform( element.originParentSpace, pBoneToWorld[parentBoneIndex], out );
				}
				else
				{
					out = GetAbsOrigin();
				}
				MatrixSetColumn( out, 3, pBoneToWorld[boneIndex] );
				element.pObject->SetPositionMatrix( pBoneToWorld[boneIndex], true );
			}
			pStr = nexttoken(szToken, pStr, ',');
		}
	}

	if ( activateRagdoll )
	{
		MEM_ALLOC_CREDIT();
		RagdollActivate( m_ragdoll, params.pCollide, GetModelIndex() );
	}

	for ( int i = 0; i < m_ragdoll.listCount; i++ )
	{
		UpdateNetworkDataFromVPhysics( m_ragdoll.list[i].pObject, i );
		g_pPhysSaveRestoreManager->AssociateModel( m_ragdoll.list[i].pObject, GetModelIndex() );
		physcollision->CollideGetAABB( m_ragdollMins[i], m_ragdollMaxs[i], m_ragdoll.list[i].pObject->GetCollide(), vec3_origin, vec3_angle );
	}
	VPhysicsSetObject( m_ragdoll.list[0].pObject );

	CalcRagdollSize();
}
Ejemplo n.º 12
0
void Interpolator_CurveInterpolate_NonNormalized( int interpolationType,
	const Vector &vPre,
	const Vector &vStart,
	const Vector &vEnd,
	const Vector &vNext,
	float f,
	Vector &vOut )
{
	vOut.Init();

	switch ( interpolationType )
	{
	default:
		Warning( "Unknown interpolation type %d\n",
			(int)interpolationType );
		// break; // Fall through and use catmull_rom as default
	case INTERPOLATE_CATMULL_ROM_NORMALIZEX:
	case INTERPOLATE_DEFAULT:
	case INTERPOLATE_CATMULL_ROM:
	case INTERPOLATE_CATMULL_ROM_NORMALIZE:
	case INTERPOLATE_CATMULL_ROM_TANGENT:
		Catmull_Rom_Spline( 
			vPre,
			vStart,
			vEnd,
			vNext,
			f, 
			vOut );
		break;
	case INTERPOLATE_EASE_IN:
		{
			f = sin( M_PI * f * 0.5f );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			VectorLerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_EASE_OUT:
		{
			f = 1.0f - sin( M_PI * f * 0.5f + 0.5f * M_PI );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			VectorLerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_EASE_INOUT:
		{
			f = SimpleSpline( f );
			// Fixme, since this ignores vPre and vNext we could omit computing them aove
			VectorLerp( vStart, vEnd, f, vOut );
		}
		break;
	case INTERPOLATE_LINEAR_INTERP:
		// Fixme, since this ignores vPre and vNext we could omit computing them aove
		VectorLerp( vStart, vEnd, f, vOut );
		break;
	case INTERPOLATE_KOCHANEK_BARTELS:
	case INTERPOLATE_KOCHANEK_BARTELS_EARLY:
	case INTERPOLATE_KOCHANEK_BARTELS_LATE:
		{
			float t, b, c;
			Interpolator_GetKochanekBartelsParams( interpolationType, t, b, c );
			Kochanek_Bartels_Spline
			( 
				t, b, c, 
				vPre,
				vStart,
				vEnd,
				vNext,
				f, 
				vOut 
			);
		}
		break;
	case INTERPOLATE_SIMPLE_CUBIC:
		Cubic_Spline( 
			vPre,
			vStart,
			vEnd,
			vNext,
			f, 
			vOut );
		break;
	case INTERPOLATE_BSPLINE:
		BSpline( 
			vPre,
			vStart,
			vEnd,
			vNext,
			f, 
			vOut );
		break;
	case INTERPOLATE_EXPONENTIAL_DECAY:
		{
			float dt = vEnd.x - vStart.x;
			if ( dt > 0.0f )
			{
				float val = 1.0f - ExponentialDecay( 0.001, dt, f * dt ); 
				vOut.y = vStart.y + val * ( vEnd.y - vStart.y );
			}
			else
			{
				vOut.y = vStart.y;
			}
		}
		break;
	case INTERPOLATE_HOLD:
		{
			vOut.y = vStart.y;
		}
		break;
	}
}
Ejemplo n.º 13
0
void PlanPrep::Program_Control (void)
{
    int i, dump;
	char *str_ptr;

	Sort_Type input_sort;

	//---- open network files ----

	Demand_Service::Program_Control ();

	//---- open the input plans ----

	if (Get_Control_String (NODE_LIST_PATHS) != NULL) {
		type_flag = Get_Control_Flag (NODE_LIST_PATHS);
	}
	str_ptr = Get_Control_String (INPUT_PLAN_FILE);

	if (str_ptr == NULL) goto control_error;

	input_plans.File_Type ("Input Plan File");	

	str_ptr = Project_Filename (str_ptr, Extension ());

	Print_Filename (2, input_plans.File_Type (), str_ptr);

	input_plans.Filename (str_ptr);

	str_ptr = Get_Control_String (INPUT_PLAN_FORMAT);

	if (str_ptr != NULL) {
		input_plans.File_Format (str_ptr);
		Print (1, "%s Format = %s", input_plans.File_Type (), str_ptr);
	}
	input_plans.Node_Based_Flag (type_flag);

	if (!input_plans.Open (0)) {
		File_Error ("Opening Input Plan File", input_plans.Filename ());
	}
	type_flag = input_plans.Node_Based_Flag ();
	parts_flag = (input_plans.Extend () > 0);

	//---- input plan sort ----

	str_ptr = Get_Control_String (INPUT_PLAN_SORT);

	if (str_ptr != NULL) {
		Print (1, "Input Plan Sort = %s", str_ptr);

		if (str_cmp (str_ptr, "TRAVELER") == 0) {
			input_sort = TRAVELER_SORT;
		} else if (str_cmp (str_ptr, "TIME") == 0) {
			input_sort = TIME_SORT;
		} else {
			Error ("Unrecognized Input Plan Sort = %s", str_ptr);
		}
		input_plans.Plan_Sort (input_sort);
		input_sort_flag = true;
	} else {
		input_sort = input_plans.Plan_Sort ();
	}

	//---- open the merge plans ----

	str_ptr = Get_Control_String (MERGE_PLAN_FILE);

	if (str_ptr != NULL) {
		merge_plans.File_Type ("Merge Plan File");

		str_ptr = Project_Filename (str_ptr, Extension ());

		Print_Filename (2, merge_plans.File_Type (), str_ptr);

		merge_plans.Filename (str_ptr);
		merge_plans.Extend (input_plans.Extend ());

		str_ptr = Get_Control_String (MERGE_PLAN_FORMAT);

		if (str_ptr != NULL) {
			merge_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", merge_plans.File_Type (), str_ptr);
		}
		merge_plans.Node_Based_Flag (type_flag);

		if (!merge_plans.Open (0)) {
			File_Error ("Opening Merge Plan File", merge_plans.Filename ());
		}
		merge_flag = true;
		if (merge_plans.Node_Based_Flag () != type_flag) {
			Error ("Incompatible Plan Formats");
		}
	}

	//---- open the subarea plans ----

	str_ptr = Get_Control_String (SUBAREA_PLAN_FILE);

	if (str_ptr != NULL) {
		if (merge_flag) {
			Error ("Merge and Subarea Plans are Incompatible");
		}
		subarea_plans.File_Type ("Subarea Plan File");

		str_ptr = Project_Filename (str_ptr);

		subarea_plans.Filename (str_ptr);

		if (subarea_plans.Extend () > 0) {
			if (parts_flag) {
				subpart_flag = true;
			} else {
				str_ptr = subarea_plans.Pathname ();
				str_ptr = Project_Filename (str_ptr, Extension ());
				subarea_plans.Filename (str_ptr);
				subarea_plans.Extend (0);
			}
		}
		Print_Filename (2, subarea_plans.File_Type (), str_ptr);

		str_ptr = Get_Control_String (SUBAREA_PLAN_FORMAT);

		if (str_ptr != NULL) {
			subarea_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", subarea_plans.File_Type (), str_ptr);
		}
		subarea_plans.Node_Based_Flag (type_flag);

		if (!subarea_plans.Open (0)) {
			File_Error ("Opening Subarea Plan File", subarea_plans.Filename ());
		}
		subarea_flag = true;
		if (subarea_plans.Node_Based_Flag () != type_flag) {
			Error ("Incompatible Plan Formats");
		}
	}

	//---- open the output plans ----

	str_ptr = Get_Control_String (OUTPUT_PLAN_FILE);

	if (str_ptr != NULL) {
		output_plans.File_Type ("Output Plan File");

		str_ptr = Project_Filename (str_ptr, Extension ());

		Print_Filename (2, output_plans.File_Type (), str_ptr);

		output_plans.Filename (str_ptr);
		output_plans.File_Access (CREATE);

		str_cpy (output_name, sizeof (output_name), output_plans.Pathname ());
		extend = output_plans.Extend ();
		output_flag = true;

		str_ptr = Get_Control_String (OUTPUT_PLAN_FORMAT);

		if (str_ptr != NULL) {
			output_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", output_plans.File_Type (), str_ptr);

			binary_flag = (output_plans.File_Format () == BINARY);
		}
		output_plans.Node_Based_Flag (type_flag);

	} else if (merge_flag) {
		Error ("Plan Merging Requires an Output File");
	} else if (subarea_flag) {
		Error ("Subarea Merging Requires an Output File");
	}

	//---- plan sort option ----

	str_ptr = Get_Control_String (PLAN_SORT_OPTION);

	if (str_ptr != NULL && output_flag) {
		Print (2, "Plan Sort Option = %s", str_ptr);

		if (str_cmp (str_ptr, "TRAVELER") == 0) {
			sort = TRAVELER_SORT;
		} else if (str_cmp (str_ptr, "TIME") == 0) {
			if (merge_flag) {
				Error ("Plan Merging must be performed in TRAVELER Sort");
			}
			sort = TIME_SORT;
		} else {
			Error ("Unrecognized Plan Sort Option = %s", str_ptr);
		}
		if (!input_sort_flag || input_sort != sort) {
			input_plans.Plan_Memory (ALLOCATE_MEMORY);
			input_plans.Plan_Sort (sort);
			sort_flag = true;
		}
		if (sort_flag && subarea_flag) {
			Error ("Sorting and Subarea Merging are Incompatible");
		}
	}

	//---- plan combine option ----

	str_ptr = Get_Control_String (PLAN_COMBINE_OPTION);

	if (str_ptr != NULL && parts_flag && output_flag) {
		Print (2, "Plan Combine Option = %s", str_ptr);

		if (!input_sort_flag && !sort_flag) {
			Error ("The Input Sort or Sort Option are needed for Plan Combining");
		}
		if (str_cmp (str_ptr, "FILE") == 0) {
			combine = FILE_COMBINE;
		} else if (str_cmp (str_ptr, "MEMORY") == 0) {
			if (merge_flag) {
				Error ("Plan Merging and Memory Combining are Incompatible");
			} else if (subarea_flag) {
				Error ("Subarea Merging and Memory Combining are Incompatible");
			}
			if (sort_flag) {
				combine = MEMORY_COMBINE;
			} else {
				combine = FILE_COMBINE;
			}
		} else {
			Error ("Unrecognized Plan Combine Option = %s", str_ptr);
		}
		combine_flag = true;
	}

	//---- max plan size ----

	str_ptr = Get_Control_String (MAX_OUTPUT_PLAN_SIZE);

	if (str_ptr != NULL && (combine_flag || (!parts_flag && output_flag))) {
		Print (2, "Maximum Output Plan Size = %s megabytes", str_ptr);

		max_size = atol (str_ptr);

		if (max_size < 1 || max_size > 2048) {
			Error ("Maximum Output Plan Size %d is Out of Range (1-2048)", max_size);
		}
		max_size *= 1024 * 1024;
		max_size_flag = true;
	}

	//---- get the select traveler range ----
	
	str_ptr = Get_Control_String (SELECT_TRAVELER_RANGE);

	if (str_ptr != NULL) {
		Print (2, "Select Traveler Range = %s", str_ptr);

		if (!hhold_range.Add_Ranges (str_ptr)) {
			Error ("Select Traveler Range", str_ptr);
		}
		hhold_flag = true;
	}

	//---- get the select time periods ----
	
	str_ptr = Get_Control_String (SELECT_TIME_PERIODS);

	if (str_ptr != NULL) {
		Print (2, "Select Time Periods = %s", str_ptr);

		time_period.Format (Time_Step::HOURS);

		if (!time_period.Add_Ranges (str_ptr)) {
			File_Error ("Time Period Range", str_ptr);
		}
		time_flag = true;
	}

	//---- read the selection percentage ----

	str_ptr = Get_Control_String (SELECTION_PERCENTAGE);

	if (str_ptr != NULL) {
		if (input_sort != TRAVELER_SORT) {
			Error ("The Input Plans must be in Traveler order for Plan Selection");
		}
		Get_Double (str_ptr, &percent);

		if (percent < 0.1 || percent > 100.0) {
			Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent);
		}
		Print (2, "Selection Percentage = %.2lf", percent);

		percent /= 100.0;
		select_flag = (percent != 1.0);
	}

	if ((time_flag || select_flag || hhold_flag) && subarea_flag) {
		Error ("Subarea Merging and Plan Selections are Incompatible");
	}

	//---- check plan partitions ----

	str_ptr = Get_Control_String (CHECK_PLAN_PARTITIONS);

	if (str_ptr != NULL) {
		check_flag = Get_Control_Flag (CHECK_PLAN_PARTITIONS);

		Print (2, "Check Plan Partitions = %s", str_ptr);

		if (check_flag) {
			partition.Initialize (sizeof (Partition));
		}
	}

	//---- update plan partitions ----

	str_ptr = Get_Control_String (UPDATE_PLAN_PARTITIONS);

	if (str_ptr != NULL) {
		partition_flag = Get_Control_Flag (UPDATE_PLAN_PARTITIONS);

		Print (2, "Update Plan Partitions = %s", str_ptr);
	}

	//---- get the household list file ----

	str_ptr = Get_Control_String (HOUSEHOLD_LIST);

	if (str_ptr != NULL) {
		hhlist_file.File_Type ("Household List");
		hhlist_file.Filename (Project_Filename (str_ptr));

		Print_Filename (2, hhlist_file.File_Type (), str_ptr);

		if (!hhlist_file.Open (0)) {
			File_Error ("Opening Household List File", hhlist_file.Filename ());
		}
		hhlist_flag = true;
	} else if (partition_flag) {
		Error ("Household Lists are required for Partition Updates");
	}

	if (hhlist_flag) {
		combine_flag = false;

		if (sort_flag) {
			Error ("Plan Sorting and Household Lists are Incompatible");
		}
		if (merge_flag) {
			Error ("Plan Merging and Household Lists are Incompatible");
		} else if (subarea_flag) {
			Error ("Subarea Merging and Household Lists are Incompatible");
		}
		if (check_flag) {
			Error ("Checking and Updating Plan Partitions are Incompatible");
		}
		if (!output_flag) {
			Error ("Output Plans are Required for Household Lists");
		}
		partition.Initialize (sizeof (Partition));
	}

	//---- get the delete household list file ----

	str_ptr = Get_Control_String (DELETE_HOUSEHOLD_LIST);

	if (str_ptr != NULL) {
		delete_file.File_Type ("Delete Household List");
		delete_file.Filename (Project_Filename (str_ptr));

		Print_Filename (2, delete_file.File_Type (), str_ptr);

		if (!delete_file.Open (0)) {
			File_Error ("Opening Delete Household List File", delete_file.Filename ());
		}
		delete_flag = true;
	}

	//---- get the delete one leg plans flag ----

	str_ptr = Get_Control_String (DELETE_ONE_LEG_PLANS);

	if (str_ptr != NULL) {
		one_leg_flag = Get_Control_Flag (DELETE_ONE_LEG_PLANS);

		Print (1, "Delete One Leg Plans = %s", str_ptr);
	}

	//---- get the fix plan file ----

	str_ptr = Get_Control_String (FIX_PLAN_FILE);

	if (str_ptr != NULL) {
		fix_file.File_Type ("Fix Plan File");

		if (!fix_file.Open (Project_Filename (str_ptr))) {
			File_Error ("Opening Fix Plan File", fix_file.Filename ());
		}
		fix_flag = true;
	}

	//---- merge by trip ----

	str_ptr = Get_Control_String (MERGE_BY_TRIP);

	if (str_ptr != NULL) {
		trip_flag = Get_Control_Flag (MERGE_BY_TRIP);

		Print (2, "Merge by Trip = %s", str_ptr);
	}

	//---- random number seed ----

	if (select_flag || fix_flag) {
		str_ptr = Get_Control_String (RANDOM_NUMBER_SEED);

		if (str_ptr != NULL) {
			random.Seed (atoi (str_ptr));
		}
		Print (2, "Random Number Seed = %d", random.Seed ());
	}

	//---- check output file name ----

	if (output_flag) {
		output_plans.Plan_Sort (input_plans.Plan_Sort ());

		if (max_size_flag || !combine_flag) {
			extend = output_plans.Extend (input_plans.Extend ());
			if (extend == 0 && max_size_flag) {
				extend = output_plans.Extend (1);
			}
		}
		if (!hhlist_flag || !delete_flag) {
			if (!output_plans.Open (0)) {
				File_Error ("Creating Output Plan File", output_plans.Filename ());
			}
		}
		if (combine_flag && combine == FILE_COMBINE && (sort_flag || merge_flag || subarea_flag)) {

			//---- set the temporary output filename ----

			output_plans.Filename (Filename (output_name, TEMP_LABEL));
			output_plans.Extend (input_plans.Extend ());
			output_plans.File_Format (BINARY);
		}
	}
	
	//---- read report types ----

	compare_flag = path_flag = false;
	dump_path = dump_time = MAX_INTEGER;

	for (i=First_Report (); i != 0; i=Next_Report ()) {
		if (i != FIX_PLAN) compare_flag = true;

		if (i == PATH_CHANGE || i == DUMP_PATH_CHANGES) {
			path_flag = true;
			if (i == DUMP_PATH_CHANGES) {
				dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5);
				if (dump < dump_path) {
					dump_path = dump;
				}
			}
		} else if (i == DUMP_TIME_CHANGES) {
			dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5);
			if (dump < dump_time) {
				dump_time = dump;
			}
		}
	}

	if (compare_flag) {
		if (!merge_flag) {
			Write (1);
			Warning ("Change Reports require a Merge Plan File");
			compare_flag = false;
		}
		memset (time_changes, '\0', sizeof (time_changes));
		memset (path_changes, '\0', sizeof (path_changes));

		increment = MIDNIGHT / TOTAL_TIME_PERIOD;
	}
	return;

	//---- error message ----

control_error:
	Error ("Missing Control Key = %s", Current_Key ());
} 
Ejemplo n.º 14
0
void OnUploadError(gcException &e)
{
	Warning(gcString("Failed to upload of mcf: {0}", e));
	g_WaitCon.notify();
}
Ejemplo n.º 15
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDebugHistory::DumpDebugHistory( int iCategory )
{
	if ( iCategory < 0 || iCategory >= MAX_HISTORY_CATEGORIES )
	{
		Warning("Attempted to dump a history for category %d. Valid categories are %d to %d.\n", iCategory, 0, (MAX_HISTORY_CATEGORIES-1) );
		return;
	}

	// Find the start of the oldest whole debug line.
	const char *pszLine = m_DebugLineEnd[iCategory] + 1;
	if ( (pszLine - m_DebugLines[iCategory]) >= sizeof(m_DebugLines[iCategory]) )
	{
		pszLine = m_DebugLines[iCategory];
	}

	// Are we at the start of a line? If there's a null terminator before us, then we're good to go.
	while ( (!( pszLine == m_DebugLines[iCategory] && *(m_DebugLines[iCategory]+sizeof(m_DebugLines[iCategory])-1) == '\0' ) &&
			!( pszLine != m_DebugLines[iCategory] && *(pszLine-1) == '\0' )) 
			|| *pszLine == '\0' )
	{
		pszLine++;

		// Have we looped?
		if ( (pszLine - m_DebugLines[iCategory]) >= sizeof(m_DebugLines[iCategory]) )
		{
			pszLine = m_DebugLines[iCategory];
		}

		if ( pszLine == m_DebugLineEnd[iCategory] )
		{
			// We looped through the entire history, and found nothing.
			Msg( "Debug History of Category %d is EMPTY\n", iCategory );
			return;
		}
	}

	// Now print everything up till the end
	char szMsgBuffer[MAX_DEBUG_HISTORY_LINE_LENGTH];
	char *pszMsg = szMsgBuffer;
	Msg( "Starting Debug History Dump of Category %d\n", iCategory );
	while ( pszLine != m_DebugLineEnd[iCategory] )
	{
		*pszMsg = *pszLine;
		if ( *pszLine == '\0' )
		{
			if ( szMsgBuffer[0] != '\0' )
			{
				// Found a full line, so print it
				Msg( szMsgBuffer );
			}

			// Clear the buffer
			pszMsg = szMsgBuffer;
			*pszMsg = '\0';
		}
		else
		{
			pszMsg++;
		}

		pszLine++;

		// Have we looped?
		if ( (pszLine - m_DebugLines[iCategory]) >= sizeof(m_DebugLines[iCategory]) )
		{
			pszLine = m_DebugLines[iCategory];
		}
	}
	Msg("Ended Debug History Dump of Category %d\n", iCategory );
}
Ejemplo n.º 16
0
void hud_shield_show(object* objp)
{

	KeepAspectRatio keep(true);

	//	static int fod_model = -1;
	float max_shield;
	int hud_color_index, range;
	int sx, sy, i;
	ship* sp;
	ship_info* sip;
	hud_frames* sgp = NULL;

	if (objp->type != OBJ_SHIP)
		return;

	// Goober5000 - don't show if primitive sensors
	if (Ships[Player_obj->instance].flags2 & SF2_PRIMITIVE_SENSORS)
		return;

	sp = &Ships[objp->instance];
	sip = &Ship_info[sp->ship_info_index];

	//	bool digitus_improbus = (fod_model != -2 && strstr(sp->ship_name, "Sathanas") != NULL);
	if (sip->shield_icon_index == 255 && !(sip->flags2 & SIF2_GENERATE_HUD_ICON)/*&& !digitus_improbus*/)
	{
		return;
	}

	if (objp == Player_obj)
	{
		hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON);
	}
	else
	{
		hud_set_gauge_color(HUD_TARGET_SHIELD_ICON);
	}

	// load in shield frames if not already loaded
	if (sip->shield_icon_index != 255)
	{
		sgp = &Shield_gauges[sip->shield_icon_index];

		if (sgp->first_frame == -1 && sip->shield_icon_index < Hud_shield_filename_count)
		{
			sgp->first_frame = bm_load_animation(Hud_shield_filenames[sip->shield_icon_index], &sgp->num_frames);
			if (sgp->first_frame == -1)
			{
				if (!shield_ani_warning_displayed_already)
				{
					shield_ani_warning_displayed_already = true;
					Warning(LOCATION, "Could not load in the HUD shield ani: %s\n",
						Hud_shield_filenames[sip->shield_icon_index]);
				}
				return;
			}
		}
	}

	if (objp == Player_obj)
	{
		sx = current_hud->Player_shield_coords[0];
		sy = current_hud->Player_shield_coords[1];
	}
	else
	{
		sx = current_hud->Target_shield_coords[0];
		sy = current_hud->Target_shield_coords[1];
	}

	sx += fl2i(HUD_offset_x);
	sy += fl2i(HUD_offset_y);

	// draw the ship first
	if (objp == Player_obj)
	{
		hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, HULL_HIT_OFFSET);
	}
	else
	{
		hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, HULL_HIT_OFFSET);
	}

	if (sip->shield_icon_index != 255)
	{
		hud_aabitmap(sgp->first_frame, sx, sy);
	}
	else
	{
		bool g3_yourself = !g3_in_frame();
		angles rot_angles =
		{
			-1.570796327f,
			0.0f,
			0.0f
		};
		matrix object_orient;

		vm_angles_2_matrix(&object_orient, &rot_angles);

		gr_screen.clip_width = 112;
		gr_screen.clip_height = 93;

		//Fire it up
		if (g3_yourself)
			g3_start_frame(1);
		hud_save_restore_camera_data(1);
		HUD_set_clip(sx, sy, 112, 93);
		model_set_detail_level(1);

		//if(!digitus_improbus)
		g3_set_view_matrix(&sip->closeup_pos, &vmd_identity_matrix, sip->closeup_zoom * 3.25f);
		/*else
		{
			vec3d finger_vec = {0.0f, 0.0f, 176.0f};
			g3_set_view_matrix( &finger_vec, &vmd_identity_matrix, 1.0f);
		}*/

		if (!Cmdline_nohtl)
		{
			gr_set_proj_matrix(0.5f * Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
			gr_set_view_matrix(&Eye_position, &Eye_matrix);
		}

		//We're ready to show stuff
		ship_model_start(objp);
		//if(!digitus_improbus)
		{
			model_render(sip->model_num, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL |
				MR_AUTOCENTER | MR_NO_FOGGING, -1, -1, sp->ship_replacement_textures);
		}
		/*else
		{
			if(fod_model == -1)
			{
				fod_model = model_load(NOX("FoD.pof"), 0, NULL);
				if(fod_model == -1)
				{
					fod_model = -2;
					return;
				}
			}
			model_render(fod_model, &object_orient, &vmd_zero_vector, MR_NO_LIGHTING | MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, -1, -1);
		}*/
		ship_model_stop(objp);

		//We're done
		if (!Cmdline_nohtl)
		{
			gr_end_view_matrix();
			gr_end_proj_matrix();
		}
		if (g3_yourself)
			g3_end_frame();
		hud_save_restore_camera_data(0);

		HUD_reset_clip();
	}

	if (!sip->max_shield_strength)
		return;

	// draw the four quadrants
	//
	// Draw shield quadrants at one of NUM_SHIELD_LEVELS
	max_shield = get_max_shield_quad(objp);

	int j, x_val, y_val, mid_val;

	for (i = 0; i < MAX_SHIELD_SECTIONS; i++)
	{

		if (objp->flags & OF_NO_SHIELDS)
		{
			break;
		}

		if (objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f)
		{
			continue;
		}

		range = MAX(HUD_COLOR_ALPHA_MAX, HUD_color_alpha + 4);
		hud_color_index = fl2i((objp->shield_quadrant[Quadrant_xlate[i]] / max_shield) * range);
		Assert(hud_color_index >= 0 && hud_color_index <= range);

		if (hud_color_index < 0)
		{
			hud_color_index = 0;
		}
		if (hud_color_index >= HUD_NUM_COLOR_LEVELS)
		{
			hud_color_index = HUD_NUM_COLOR_LEVELS - 1;
		}

		int flash = 0;
		if (objp == Player_obj)
		{
			flash = hud_shield_maybe_flash(HUD_PLAYER_SHIELD_ICON, SHIELD_HIT_PLAYER, i);
		}
		else
		{
			flash = hud_shield_maybe_flash(HUD_TARGET_SHIELD_ICON, SHIELD_HIT_TARGET, i);
		}

		if (!flash)
		{
			// gr_set_color_fast(&HUD_color_defaults[hud_color_index]);
			if (objp == Player_obj)
			{
				hud_set_gauge_color(HUD_PLAYER_SHIELD_ICON, hud_color_index);
			}
			else
			{
				hud_set_gauge_color(HUD_TARGET_SHIELD_ICON, hud_color_index);
			}

			if (sip->shield_icon_index != 255)
			{
				hud_aabitmap(sgp->first_frame + i + 1, sx, sy);
			}
			else
			{
				//Ugh, draw four shield quadrants
				switch (i)
				{
					//Top
				case 0:
					sy += 3;
					for (j = 0; j < 6; j++)
					{
						y_val = sy + 10;
						gr_gradient(sx + j,
							sy,
							sx + j,
							y_val - j);
					}
					mid_val = sy + 5;
					for (; j < 106; j++)
					{
						gr_gradient(sx + j,
							sy,
							sx + j,
							mid_val);
					}
					for (; j < 112; j++)
					{
						gr_gradient(sx + j,
							sy,
							sx + j,
							sy + (j - 101));
					}
					y_val = sy - 1;
					sy -= 3;
					for (j = 0; j < 112; j++)
						gr_gradient(sx + j, y_val, sx + j, sy);
					break;
					//Left
				case 1:
					sx += 1;
					x_val = sx + 10;
					y_val = sy + 15;
					for (j = 0; j < 6; j++)
					{
						gr_gradient(sx,
							y_val + j,
							x_val - j,
							y_val + j);
					}
					mid_val = sx + 5;
					for (; j < 48; j++)
					{
						gr_gradient(sx,
							y_val + j,
							mid_val,
							y_val + j);
					}
					for (; j < 54; j++)
					{
						gr_gradient(sx,
							y_val + j,
							sx + (j - 43),
							y_val + j);
					}
					x_val = sx;
					sx -= 3;
					for (j = 0; j < 54; j++)
						gr_gradient(x_val, y_val + j, sx, y_val + j);
					sx += 2;
					break;
					//Right
				case 2:
					x_val = sx + 109;	//-3 for border
					y_val = sy + 15;
					for (j = 0; j < 6; j++)
					{
						gr_gradient(x_val,
							y_val + j,
							x_val - (10 - j),
							y_val + j);
					}
					mid_val = x_val - 5;
					for (; j < 48; j++)
					{
						gr_gradient(x_val,
							y_val + j,
							mid_val,
							y_val + j);
					}
					for (; j < 54; j++)
					{
						gr_gradient(x_val,
							y_val + j,
							x_val - (j - 43),
							y_val + j);
					}
					mid_val = x_val;
					x_val += 3;
					for (j = 0; j < 54; j++)
						gr_gradient(mid_val, y_val + j, x_val, y_val + j);
					break;
					//Bottom
				case 3:
					y_val = sy + 80; //-3 for border
					for (j = 0; j < 6; j++)
						gr_gradient(sx + j,
							y_val,
							sx + j,
							y_val - (10 - j));
					mid_val = y_val - 5;
					for (; j < 106; j++)
						gr_gradient(sx + j,
							y_val,
							sx + j,
							mid_val);
					for (; j < 112; j++)
						gr_gradient(sx + j,
							y_val,
							sx + j,
							y_val - (j - 101));
					mid_val = y_val + 1;
					y_val += 3;
					for (j = 0; j < 112; j++)
						gr_gradient(sx + j, mid_val, sx + j, y_val);
				}
			}
		}
	}

	// hud_set_default_color();
}
Ejemplo n.º 17
0
void            Winding::RemoveColinearPoints()
{
    unsigned int    i;
    unsigned int    nump;
    int             j;
    vec3_t          v1, v2;
    vec3_t          p[128];

    //JK: Did the optimizations...

    if (m_NumPoints>1)
    {
        VectorSubtract(m_Points[0], m_Points[m_NumPoints - 1], v2);
        VectorNormalize(v2);
    }
    nump=0;
    for (i = 0; i < m_NumPoints; i++)
    {
        j = (i + 1) % m_NumPoints;                  // i + 1

        VectorSubtract(m_Points[i], m_Points[j], v1);

        VectorNormalize(v1);

        VectorAdd(v1, v2, v2);

        if (!VectorCompare(v2, vec3_origin))
        {
            VectorCopy(m_Points[i], p[nump]);
            nump++;
        }
#if 0
        else
        {
            Log("v3 was (%4.3f %4.3f %4.3f)\n", v2[0], v2[1], v2[2]);
        }
#endif
        //Set v2 for next round
        v2[0]=-v1[0];
        v2[1]=-v1[1];
        v2[2]=-v1[2];
    }

    if (nump == m_NumPoints)
    {
        return;
    }

#if 0
    Warning("RemoveColinearPoints: Removed %u points, from %u to %u\n", m_NumPoints - nump, m_NumPoints, nump);
    Warning("Before :\n");
    Print();
#endif
    m_NumPoints = nump;
    memcpy(m_Points, p, nump * sizeof(vec3_t));

#if 0
    Warning("After :\n");
    Print();

    Warning("==========\n");
#endif
}
Ejemplo n.º 18
0
void
ETFloadGreyboxModel(model_t model, const char *name)
{
    gb_context_t ctx=(gb_context_t)RTmalloc(sizeof(struct grey_box_context));
    GBsetContext(model,ctx);
    etf_model_t etf=etf_parse_file(name);
    lts_type_t ltstype=etf_type(etf);
    int state_length=lts_type_get_state_length(ltstype);
    ctx->edge_labels=lts_type_get_edge_label_count(ltstype);
    if (ctx->edge_labels>1) {
        ctx->label_idx=SIcreate();
    } else {
        ctx->label_idx=NULL;
    }
    GBsetLTStype(model,ltstype);
    matrix_t* p_dm_info = (matrix_t*)RTmalloc(sizeof(matrix_t));
    matrix_t* p_dm_read_info = (matrix_t*)RTmalloc(sizeof(matrix_t));
    matrix_t* p_dm_write_info = (matrix_t*)RTmalloc(sizeof(matrix_t));
    dm_create(p_dm_info, etf_trans_section_count(etf), state_length);
    dm_create(p_dm_read_info, etf_trans_section_count(etf), state_length);
    dm_create(p_dm_write_info, etf_trans_section_count(etf), state_length);
    ctx->trans_key_idx=(string_index_t*)RTmalloc(dm_nrows(p_dm_info)*sizeof(string_index_t));
    ctx->trans_table=(matrix_table_t*)RTmalloc(dm_nrows(p_dm_info)*sizeof(matrix_table_t));
    for(int i=0; i < dm_nrows(p_dm_info); i++) {
        Warning(infoLong,"parsing table %d",i);
        etf_rel_t trans=etf_trans_section(etf,i);
        int used[state_length];
        int src[state_length];
        int dst[state_length];
        int lbl[ctx->edge_labels];
        int proj[state_length];
        ETFrelIterate(trans);
        if (!ETFrelNext(trans,src,dst,lbl)){
            Abort("unexpected empty transition section");
        }
        int len=0;
        for(int j=0;j<state_length;j++){
            if (src[j]) {
                proj[len]=j;
                Warning(debug,"pi[%d]=%d",len,proj[len]);
                len++;
                dm_set(p_dm_info, i, j);
                used[j]=1;
            } else {
                used[j]=0;
            }
        }
        Warning(infoLong,"length is %d",len);
        ctx->trans_key_idx[i]=SIcreate();
        ctx->trans_table[i]=MTcreate(3);
        int src_short[len];
        int dst_short[len];
        uint32_t row[3];
        do {
            /*
             * If an element is non-zero, we always consider it a read. If the
             * value is changed for at least one transition in a group then
             * we also consider it a write. Note that this could be slightly
             * optimized by omitting those elements from read where the value
             * varies over all possible inputs.
             */
            for(int k=0;k<state_length;k++) {
                if (src[k] != 0) {
                    dm_set(p_dm_read_info, i, k);
                    if (src[k] != dst[k]) dm_set(p_dm_write_info, i, k);
                }
            }
            for(int k=0;k<state_length;k++) {
                if(used[k]?(src[k]==0):(src[k]!=0)){
                    Abort("inconsistent section in src vector");
                }
            }
            for(int k=0;k<len;k++) src_short[k]=src[proj[k]]-1;
            for(int k=0;k<state_length;k++) {
                if(used[k]?(dst[k]==0):(dst[k]!=0)){
                    Abort("inconsistent section in dst vector");
                }
            }
            for(int k=0;k<len;k++) dst_short[k]=dst[proj[k]]-1;
            row[0]=(uint32_t)SIputC(ctx->trans_key_idx[i],(char*)src_short,len<<2);
            switch(ctx->edge_labels){
            case 0:
                row[2]=0;
                break;
            case 1:
                row[2]=(uint32_t)lbl[0];
                break;
            default:
                row[2]=(uint32_t)SIputC(ctx->label_idx,(char*)lbl,(ctx->edge_labels)<<2);
                break;
            }
            row[1]=(int32_t)SIputC(ctx->trans_key_idx[i],(char*)dst_short,len<<2);
            MTaddRow(ctx->trans_table[i],row);
        } while(ETFrelNext(trans,src,dst,lbl));
        Warning(infoLong,"table %d has %d states and %d transitions",
                i,SIgetCount(ctx->trans_key_idx[i]),ETFrelCount(trans));
        ETFrelDestroy(&trans);
        MTclusterBuild(ctx->trans_table[i],0,SIgetCount(ctx->trans_key_idx[i]));
    }
    GBsetDMInfo(model, p_dm_info);

    /*
     * Set these again when ETF supports read, write and copy.
       GBsetDMInfoRead(model, p_dm_read_info);
       GBsetDMInfoMustWrite(model, p_dm_write_info);
       GBsetSupportsCopy(model); // no may-write so we support copy.
     */
    GBsetNextStateShort(model,etf_short);

    matrix_t *p_sl_info = RTmalloc(sizeof *p_sl_info);
    dm_create(p_sl_info, etf_map_section_count(etf), state_length);
    ctx->label_key_idx=(string_index_t*)RTmalloc(dm_nrows(p_sl_info)*sizeof(string_index_t));
    ctx->label_data=(int**)RTmalloc(dm_nrows(p_sl_info)*sizeof(int*));
    for(int i=0;i<dm_nrows(p_sl_info);i++){
        Warning(infoLong,"parsing map %d",i);
        etf_map_t map=etf_get_map(etf,i);
        int used[state_length];
        int state[state_length];
        int value;
        ETFmapIterate(map);
        if (!ETFmapNext(map,state,&value)){
            Abort("Unexpected empty map");
        }
        int len=0;
        for(int j=0;j<state_length;j++){
            if (state[j]) {
                used[len]=j;
                len++;
                dm_set(p_sl_info, i, j);
            }
        }
        int*proj=(int*)RTmalloc(len*sizeof(int));
        for(int j=0;j<len;j++) proj[j]=used[j];
        for(int j=0;j<state_length;j++) used[j]=state[j];
        string_index_t key_idx=SIcreate();
        int *data=(int*)RTmalloc(ETFmapCount(map)*sizeof(int));
        int key[len];
        do {
            for(int k=0;k<state_length;k++) {
                if(used[k]?(state[k]==0):(state[k]!=0)){
                    Abort("inconsistent map section");
                }
            }
            for(int k=0;k<len;k++) key[k]=state[proj[k]]-1;
            data[SIputC(key_idx,(char*)key,len<<2)]=value;
        } while(ETFmapNext(map,state,&value));
        ctx->label_key_idx[i]=key_idx;
        ctx->label_data[i]=data;
    }
    GBsetStateLabelInfo(model, p_sl_info);
    GBsetStateLabelShort(model,etf_state_short);
    GBsetTransitionInGroup(model,etf_transition_in_group);

    int type_count=lts_type_get_type_count(ltstype);
    for(int i=0;i<type_count;i++){
        Warning(infoLong,"Setting values for type %d (%s)",i,lts_type_get_type(ltstype,i));
        int count=etf_get_value_count(etf,i);
        for(int j=0;j<count;j++){
            GBchunkPutAt(model,i,etf_get_value(etf,i,j),j);
        }
    }

    int state[state_length];
    etf_get_initial(etf,state);
    GBsetInitialState(model,state);
}
Ejemplo n.º 19
0
//-----------------------------------------------------------------------------
// Places Detail Objects in the level
//-----------------------------------------------------------------------------
void EmitDetailModels()
{
	StartPacifier("Placing detail props : ");

	// Place stuff on each face
	dface_t* pFace = dfaces;
	for (int j = 0; j < numfaces; ++j)
	{
		UpdatePacifier( (float)j / (float)numfaces );

		// Get at the material associated with this face
		texinfo_t* pTexInfo = &texinfo[pFace[j].texinfo];
		dtexdata_t* pTexData = GetTexData( pTexInfo->texdata );

		// Try to get at the material
		bool found;
		MaterialSystemMaterial_t handle = 
			FindOriginalMaterial( TexDataStringTable_GetString( pTexData->nameStringTableID ), 
						  &found, false );
		if (!found)
			continue;

		// See if its got any detail objects on it
		const char* pDetailType = GetMaterialVar( handle, "%detailtype" );
		if (!pDetailType)
			continue;

		// Get the detail type...
		DetailObject_t search;
		search.m_Name = pDetailType;
		int objectType = s_DetailObjectDict.Find(search);
		if (objectType < 0)
		{
			Warning("Material %s uses unknown detail object type %s!\n",	
				TexDataStringTable_GetString( pTexData->nameStringTableID ),
				pDetailType);
			continue;
		}

		// Emit objects on a particular face
		DetailObject_t& detail = s_DetailObjectDict[objectType];

		// Initialize the Random Number generators for detail prop placement based on the hammer Face num.
		int	detailpropseed = dfaceids[j].hammerfaceid;
#ifdef WARNSEEDNUMBER
		Warning( "[%d]\n",detailpropseed );
#endif
		srand( detailpropseed );
		RandomSeed( detailpropseed );

		if (pFace[j].dispinfo < 0)
		{
			EmitDetailObjectsOnFace( &pFace[j], detail );
		}
		else
		{
			// Get a CCoreDispInfo. All we need is the triangles and lightmap texture coordinates.
			mapdispinfo_t *pMapDisp = &mapdispinfo[pFace[j].dispinfo];
			CCoreDispInfo coreDispInfo;
			DispMapToCoreDispInfo( pMapDisp, &coreDispInfo, NULL, NULL );

			EmitDetailObjectsOnDisplacementFace( &pFace[j], detail, coreDispInfo );
		}
	}

	// Emit specifically specified detail props
	Vector origin;
	QAngle angles;
	Vector2D pos[2];
	Vector2D tex[2];
	for (int i = 0; i < num_entities; ++i)
	{
		char* pEntity = ValueForKey(&entities[i], "classname");
		if (!strcmp(pEntity, "detail_prop") || !strcmp(pEntity, "prop_detail"))
		{
			GetVectorForKey( &entities[i], "origin", origin );
			GetAnglesForKey( &entities[i], "angles", angles );
			char* pModelName = ValueForKey( &entities[i], "model" );
			int nOrientation = IntForKey( &entities[i], "detailOrientation" );

			AddDetailToLump( pModelName, origin, angles, nOrientation );

			// strip this ent from the .bsp file
			entities[i].epairs = 0;
			continue;
		}

		if (!strcmp(pEntity, "prop_detail_sprite"))
		{
			GetVectorForKey( &entities[i], "origin", origin );
			GetAnglesForKey( &entities[i], "angles", angles );
			int nOrientation = IntForKey( &entities[i], "detailOrientation" );
			GetVector2DForKey( &entities[i], "position_ul", pos[0] );
			GetVector2DForKey( &entities[i], "position_lr", pos[1] );
			GetVector2DForKey( &entities[i], "tex_ul", tex[0] );
			GetVector2DForKey( &entities[i], "tex_size", tex[1] );
			float flTextureSize = FloatForKey( &entities[i], "tex_total_size" );

			tex[1].x += tex[0].x - 0.5f;
			tex[1].y += tex[0].y - 0.5f;
			tex[0].x += 0.5f;
			tex[0].y += 0.5f;
			tex[0] /= flTextureSize;
			tex[1] /= flTextureSize;

			AddDetailSpriteToLump( origin, angles, nOrientation, pos, tex, 1.0f, DETAIL_PROP_TYPE_SPRITE );

			// strip this ent from the .bsp file
			entities[i].epairs = 0;
			continue;
		}
	}

	EndPacifier( true );
}
Ejemplo n.º 20
0
void Reporting::Warning(const std::wstring &text, const CWnd *parent)
//-----------------------------------------------------------
{
	Warning(text, MAINFRAME_TITLEW L" - Warning", parent);
}
Ejemplo n.º 21
0
//-----------------------------------------------------------------------------
// Purpose: Runs movement commands for the player
// Input  : *player - 
//			*ucmd - 
//			*moveHelper - 
// Output : void CPlayerMove::RunCommand
//-----------------------------------------------------------------------------
void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
{
	const float playerCurTime = player->m_nTickBase * TICK_INTERVAL; 
	const float playerFrameTime = player->m_bGamePaused ? 0 : TICK_INTERVAL;
	const float flTimeAllowedForProcessing = player->ConsumeMovementTimeForUserCmdProcessing( playerFrameTime );
	if ( !player->IsBot() && ( flTimeAllowedForProcessing < playerFrameTime ) )
	{
		// Make sure that the activity in command is erased because player cheated or dropped too many packets
		double dblWarningFrequencyThrottle = sv_maxusrcmdprocessticks_warning.GetFloat();
		if ( dblWarningFrequencyThrottle >= 0 )
		{
			static double s_dblLastWarningTime = 0;
			double dblTimeNow = Plat_FloatTime();
			if ( !s_dblLastWarningTime || ( dblTimeNow - s_dblLastWarningTime >= dblWarningFrequencyThrottle ) )
			{
				s_dblLastWarningTime = dblTimeNow;
				Warning( "sv_maxusrcmdprocessticks_warning at server tick %u: Ignored client %s usrcmd (%.6f < %.6f)!\n", gpGlobals->tickcount, player->GetPlayerName(), flTimeAllowedForProcessing, playerFrameTime );
			}
		}
		return; // Don't process this command
	}

	StartCommand( player, ucmd );

	// Set globals appropriately
	gpGlobals->curtime		=  playerCurTime;
	gpGlobals->frametime	=  playerFrameTime;

	// Prevent hacked clients from sending us invalid view angles to try to get leaf server code to crash
	if ( !ucmd->viewangles.IsValid() || !IsEntityQAngleReasonable(ucmd->viewangles) )
	{
		ucmd->viewangles = vec3_angle;
	}

	// Add and subtract buttons we're forcing on the player
	ucmd->buttons |= player->m_afButtonForced;
	ucmd->buttons &= ~player->m_afButtonDisabled;

	if ( player->m_bGamePaused )
	{
		// If no clipping and cheats enabled and noclipduring game enabled, then leave
		//  forwardmove and angles stuff in usercmd
		if ( player->GetMoveType() == MOVETYPE_NOCLIP &&
			 sv_cheats->GetBool() && 
			 sv_noclipduringpause.GetBool() )
		{
			gpGlobals->frametime = TICK_INTERVAL;
		}
	}

	/*
	// TODO:  We can check whether the player is sending more commands than elapsed real time
	cmdtimeremaining -= ucmd->msec;
	if ( cmdtimeremaining < 0 )
	{
	//	return;
	}
	*/

	g_pGameMovement->StartTrackPredictionErrors( player );

	CommentarySystem_PePlayerRunCommand( player, ucmd );

	// Do weapon selection
	if ( ucmd->weaponselect != 0 )
	{
		CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) );
		if ( weapon )
		{
			VPROF( "player->SelectItem()" );
			player->SelectItem( weapon->GetName(), ucmd->weaponsubtype );
		}
	}

	IServerVehicle *pVehicle = player->GetVehicle();

	// Latch in impulse.
	if ( ucmd->impulse )
	{
		// Discard impulse commands unless the vehicle allows them.
		// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
		if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
		{
			player->m_nImpulse = ucmd->impulse;
		}
	}

	// Update player input button states
	VPROF_SCOPE_BEGIN( "player->UpdateButtonState" );
	player->UpdateButtonState( ucmd->buttons );
	VPROF_SCOPE_END();

	CheckMovingGround( player, TICK_INTERVAL );

	g_pMoveData->m_vecOldAngles = player->pl.v_angle;

	// Copy from command to player unless game .dll has set angle using fixangle
	if ( player->pl.fixangle == FIXANGLE_NONE )
	{
		player->pl.v_angle = ucmd->viewangles;
	}
	else if( player->pl.fixangle == FIXANGLE_RELATIVE )
	{
		player->pl.v_angle = ucmd->viewangles + player->pl.anglechange;
	}

	// Call standard client pre-think
	RunPreThink( player );

	// Call Think if one is set
	RunThink( player, TICK_INTERVAL );

	// Setup input.
	SetupMove( player, ucmd, moveHelper, g_pMoveData );

	// Let the game do the movement.
	if ( !pVehicle )
	{
		VPROF( "g_pGameMovement->ProcessMovement()" );
		Assert( g_pGameMovement );
		g_pGameMovement->ProcessMovement( player, g_pMoveData );
	}
	else
	{
		VPROF( "pVehicle->ProcessMovement()" );
		pVehicle->ProcessMovement( player, g_pMoveData );
	}
			
	// Copy output
	FinishMove( player, ucmd, g_pMoveData );

	// If we have to restore the view angle then do so right now
	if ( !player->IsBot() && ( gpGlobals->tickcount - player->GetLockViewanglesTickNumber() < sv_maxusrcmdprocessticks_holdaim.GetInt() ) )
	{
		player->pl.v_angle = player->GetLockViewanglesData();
	}

	// Let server invoke any needed impact functions
	VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" );
	moveHelper->ProcessImpacts();
	VPROF_SCOPE_END();

	RunPostThink( player );

	g_pGameMovement->FinishTrackPredictionErrors( player );

	FinishCommand( player );

	// Let time pass
	if ( gpGlobals->frametime > 0 )
	{
		player->m_nTickBase++;
	}
}
Ejemplo n.º 22
0
void Reporting::Warning(const char *text, const CWnd *parent)
//-----------------------------------------------------------
{
	Warning(text, MAINFRAME_TITLE " - Warning", parent);
}
Ejemplo n.º 23
0
void IPCToolMain::warning(const char* msg)
{
	Warning(gcString("DesuraService: {0}", msg));
}
Ejemplo n.º 24
0
/*
 * Print a message listing unsupported options which were used (using the
 * opts string) and a complete list of unsupported options.
 */
void UnsupportedOptsMessage( const char *opts )
/*********************************************/
{
    Warning( "Ignoring unsupported option(s): %s", opts );
}
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------
// Purpose: Static method
// Input  : *hdr - 
//			sounds - 
//-----------------------------------------------------------------------------
void CModelSoundsCache::BuildAnimationEventSoundList( CStudioHdr *hdr, CUtlVector< unsigned short >& sounds )
{
	Assert( hdr );
	
	// force animation event resolution!!!
	VerifySequenceIndex( hdr );

	// Find all animation events which fire off sound script entries...
	for ( int iSeq=0; iSeq < hdr->GetNumSeq(); iSeq++ )
	{
		mstudioseqdesc_t *pSeq = &hdr->pSeqdesc( iSeq );
		
		// Now read out all the sound events with their timing
		for ( int iEvent=0; iEvent < (int)pSeq->numevents; iEvent++ )
		{
			mstudioevent_t *pEvent = pSeq->pEvent( iEvent );
			
			switch ( pEvent->event )
			{
			default:
				{
					if ( pEvent->type & AE_TYPE_NEWEVENTSYSTEM )
					{
						if ( pEvent->event == AE_SV_PLAYSOUND )
						{
							FindOrAddScriptSound( sounds, pEvent->pszOptions() );
						}
					}
				}
				break;
			// Old-style client .dll animation event
			case CL_EVENT_SOUND:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;
			case CL_EVENT_FOOTSTEP_LEFT:
			case CL_EVENT_FOOTSTEP_RIGHT:
				{
					char soundname[256];
					char const *options = pEvent->pszOptions();
					if ( !options || !options[0] )
					{
						options = "NPC_CombineS";
					}

					Q_snprintf( soundname, 256, "%s.RunFootstepLeft", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.RunFootstepRight", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.FootstepLeft", options );
					FindOrAddScriptSound( sounds, soundname );
					Q_snprintf( soundname, 256, "%s.FootstepRight", options );
					FindOrAddScriptSound( sounds, soundname );
				}
				break;
			case AE_CL_PLAYSOUND:
				{
					if ( !( pEvent->type & AE_TYPE_CLIENT ) )
						break;

					if ( pEvent->pszOptions()[0] )
					{
						FindOrAddScriptSound( sounds, pEvent->pszOptions() );
					}
					else
					{
						Warning( "-- Error --:  empty soundname, .qc error on AE_CL_PLAYSOUND in model %s, sequence %s, animevent # %i\n", 
							hdr->pszName(), pSeq->pszLabel(), iEvent+1 );
					}
				}
				break;
			case SCRIPT_EVENT_SOUND:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;

			case SCRIPT_EVENT_SOUND_VOICE:
				{
					FindOrAddScriptSound( sounds, pEvent->pszOptions() );
				}
				break;
			}
		}
	}
}
Ejemplo n.º 26
0
int
File_MakeTempEx2(ConstUnicode dir,                             // IN:
                 Bool createTempFile,                          // IN:
                 File_MakeTempCreateNameFunc *createNameFunc,  // IN:
                 void *createNameFuncData,                     // IN:
                 Unicode *presult)                             // OUT:
{
   uint32 i;

   int fd = -1;
   uint32 var = 0;
   Unicode path = NULL;

   if ((dir == NULL) || (createNameFunc == NULL)) {
      errno = EFAULT;

      return -1;
   }

   ASSERT(presult);

   *presult = NULL;

   for (i = 0; i < (MAX_INT32 / 2); i++) {
      Unicode fileName;

      /* construct suffixed pathname to use */
      Unicode_Free(path);
      path = NULL;

      /*
       * Files and directories are kept separate (odd and even respectfully).
       * This way the available exclusion mechanisms work properly - O_EXCL
       * on files, mkdir on directories - and races are avoided.
       *
       * Not attempting an open on a directory is a good thing...
       */

      FileTempNum(createTempFile, &var);

      fileName = (*createNameFunc)(var, createNameFuncData);
      ASSERT(fileName);

      /* construct base full pathname to use */
      path = Unicode_Join(dir, DIRSEPS, fileName, NULL);

      Unicode_Free(fileName);

      if (createTempFile) {
         fd = Posix_Open(path, O_CREAT | O_EXCL | O_BINARY | O_RDWR, 0600);
      } else {
         fd = Posix_Mkdir(path, 0700);
      }

      if (fd != -1) {
         *presult = path;
         path = NULL;
         break;
      }

      if (errno != EEXIST) {
         Log(LGPFX" Failed to create temporary %s \"%s\": %s.\n",
             createTempFile ? "file" : "directory",
             UTF8(path), strerror(errno));
         goto exit;
      }
   }

   if (fd == -1) {
      Warning(LGPFX" Failed to create temporary %s \"%s\": "
              "The name space is full.\n",
              createTempFile ? "file" : "directory", UTF8(path));

      errno = EAGAIN;
   }

  exit:
   Unicode_Free(path);

   return fd;
}
Ejemplo n.º 27
0
int read_test3(TEST_DATA *data, IO_BUFFER *iobuf)
{
   IO_ITEM_HEADER item_header1, item_header2;
   int i;
   
   item_header1.type = 990;             /* test data */
   if ( get_item_begin(iobuf,&item_header1) < 0 )
   {
      Warning("Missing or invalid test data block.");
      return -4;
   }

   item_header2.type = 991;             /* test data */
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 1.");
      return -4;
   }

   get_vector_of_long(data->lvar,2,iobuf);
   data->ilvar[0] = get_long(iobuf);
   data->ilvar[1] = get_long(iobuf);
   get_vector_of_int(data->isvar,2,iobuf);
   get_vector_of_short(data->svar,3,iobuf);
   
   get_item_end(iobuf,&item_header2);

   if ( next_subitem_type(iobuf) != 992 )
   {
      Warning("Failed to look ahead for next sub-item type.");
      return -4;
   }

   item_header2.type = 992;             /* test data */
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 2.");
      return -4;
   }

   get_vector_of_real(data->fvar,2,iobuf);
   get_vector_of_double(data->dvar,2,iobuf);
   data->hvar[0] = get_sfloat(iobuf);
   data->hvar[1] = get_sfloat(iobuf);
   get_vector_of_byte((uint8_t *)data->i8var,2,iobuf);
   get_vector_of_byte(data->u8var,2,iobuf);
   get_vector_of_short(data->i16var,2,iobuf);
   get_vector_of_short((int16_t *)data->u16var,2,iobuf);
   get_vector_of_int32(data->i32var,2,iobuf);
   get_vector_of_uint32(data->u32var,2,iobuf);
#ifdef HAVE_64BIT_INT
   get_vector_of_int64(data->i64var,2,iobuf);
   get_vector_of_uint64(data->u64var,2,iobuf);
#endif

   get_item_end(iobuf,&item_header2);
   
   /* Check that non-sequential access to sub-items also works */

   rewind_item(iobuf,&item_header1);

   item_header2.type = 994;             /* test data */
   if ( search_sub_item(iobuf,&item_header1,&item_header2) < 0 )
   {
      Warning("Cannot find test data sub-block 4.");
      return -4;
   }
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 4.");
      return -4;
   }

   get_string(data->str16var,sizeof(data->str16var),iobuf);
   get_long_string(data->str32var,sizeof(data->str32var),iobuf);
   get_var_string(data->strvvar,sizeof(data->strvvar),iobuf);

   get_item_end(iobuf,&item_header2);

   rewind_item(iobuf,&item_header1);

   item_header2.type = 993;             /* test data */
   if ( search_sub_item(iobuf,&item_header1,&item_header2) < 0 )
   {
      Warning("Cannot find test data sub-block 3.");
      return -4;
   }
   if ( get_item_begin(iobuf,&item_header2) < 0 )
   {
      Warning("Missing or invalid test data sub-block 3.");
      return -4;
   }

   data->nbvar = get_count(iobuf);
   get_vector_of_byte(data->bvar,2,iobuf);
   for (i=0; i<4; i++)
      data->cnt16var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cnt32var[i] = get_count(iobuf);
   for (i=0; i<6; i++)
      data->cntzvar[i] = get_count(iobuf);
   for (i=0; i<8; i++)
      data->cntvar[i] = get_count(iobuf);
   for (i=0; i<10; i++)
      data->scnt16var[i] = get_scount16(iobuf);
   for (i=0; i<12; i++)
      data->scnt32var[i] = get_scount32(iobuf);
   for (i=0; i<12; i++)
      data->scntzvar[i] = get_scount(iobuf);
   for (i=0; i<14; i++)
      data->scntvar[i] = get_scount(iobuf);

   get_item_end(iobuf,&item_header2);

   return(get_item_end(iobuf,&item_header1));
}
Ejemplo n.º 28
0
static void FontFind(struct font_entry * tfontptr)
{
    kpse_glyph_file_type font_ret;

    /* tfontptr->dpi = kpse_magstep_fix (tfontptr->dpi, resolution, NULL); */
    DEBUG_PRINT(DEBUG_DVI,("\n  FIND FONT:\t%s %d",tfontptr->n,tfontptr->dpi));

    tfontptr->name = kpse_find_vf (tfontptr->n);
    if (tfontptr->name!=NULL)
        InitVF(tfontptr);
#ifdef HAVE_FT2
    else if (option_flags & USE_FREETYPE) {
        tfontptr->psfontmap = FindPSFontMap(tfontptr->n);
        if (tfontptr->psfontmap!=NULL)
            tfontptr->name=kpse_find_t1_or_tt(tfontptr->psfontmap->psfile);
        else
            tfontptr->name=kpse_find_t1_or_tt(tfontptr->n);
        if (tfontptr->name!=NULL) {
            char* tfmname=kpse_find_file(tfontptr->n, kpse_tfm_format, false);
            if (tfmname!=NULL) {
                if (!ReadTFM(tfontptr,tfmname)) {
                    Warning("unable to read tfm file %s", tfmname);
                    free(tfontptr->name);
                    tfontptr->name=NULL;
                } else if ((option_flags & USE_FREETYPE)==0 || !InitFT(tfontptr)) {
                    /* if Freetype loading fails for some reason, fall back to PK font */
                    free(tfontptr->name);
                    tfontptr->name=NULL;
                }
                free(tfmname);
            }
        }
    }
#endif /* HAVE_FT2 */
    if (tfontptr->name==NULL) {
        tfontptr->name=kpse_find_pk (tfontptr->n, tfontptr->dpi, &font_ret);
        if (tfontptr->name!=NULL) {
            if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) {
                page_flags |= PAGE_GAVE_WARN;
                Warning("font %s not found, using %s at %d dpi instead",
                        tfontptr->n, font_ret.name, font_ret.dpi);
                tfontptr->c = 0; /* no checksum warning */
            } else if (!kpse_bitmap_tolerance ((double)font_ret.dpi,
                                               (double) tfontptr->dpi)) {
                page_flags |= PAGE_GAVE_WARN;
                Warning("font %s at %d dpi not found, using %d dpi instead",
                        tfontptr->n, tfontptr->dpi, font_ret.dpi);
            }
            InitPK(tfontptr);
        } else {
            page_flags |= PAGE_GAVE_WARN;
            Warning("font %s at %d dpi not found, characters will be left blank",
                    tfontptr->n, tfontptr->dpi);
#ifndef WIN32
            tfontptr->fmmap.fd = 0;
#else  /* WIN32 */
            tfontptr->fmmap.hFile = INVALID_HANDLE_VALUE;
#endif
            tfontptr->magnification = 0;
            tfontptr->designsize = 0;
        }
    }
}
Ejemplo n.º 29
0
void EventHandler::onLogConsoleMsg(const char* message, const char* source, int line)
{
	if (gc_enablebrowserconsole.getBool())
		Warning(gcString("Webkit: {0} [{1} : {2}]\n", message, source, line));
}
Ejemplo n.º 30
0
void CServerGameDLL::ApplyGameSettings( KeyValues *pKV )
{
	if ( !pKV )
		return;

	// Fix the game settings request when a generic request for
	// map launch comes in (it might be nested under reservation
	// processing)
	bool bAlreadyLoadingMap = false;
	char const *szBspName = NULL;
	const char *pGameDir = COM_GetModDirectory();
	if ( !Q_stricmp( pKV->GetName(), "::ExecGameTypeCfg" ) )
	{
		if ( !engine )
			return;

		char const *szNewMap = pKV->GetString( "map/mapname", "" );
		if ( !szNewMap || !*szNewMap )
			return;

		KeyValues *pLaunchOptions = engine->GetLaunchOptions();
		if ( !pLaunchOptions )
			return;

		if ( FindLaunchOptionByValue( pLaunchOptions, "changelevel" ) ||
			FindLaunchOptionByValue( pLaunchOptions, "changelevel2" ) )
			return;

		if ( FindLaunchOptionByValue( pLaunchOptions, "map_background" ) )
		{

			return;
		}

		bAlreadyLoadingMap = true;

		if ( FindLaunchOptionByValue( pLaunchOptions, "reserved" ) )
		{
			// We are already reserved, but we still need to let the engine
			// baseserver know how many human slots to allocate
			pKV->SetInt( "members/numSlots", g_bOfflineGame ? 1 : 8 );
			return;
		}

		pKV->SetName( pGameDir );
	}

	if ( Q_stricmp( pKV->GetName(), pGameDir ) || bAlreadyLoadingMap )
		return;

	//g_bOfflineGame = pKV->GetString( "map/offline", NULL ) != NULL;
	g_bOfflineGame = !Q_stricmp( pKV->GetString( "system/network", "LIVE" ), "offline" );

	//Msg( "GameInterface reservation payload:\n" );
	//KeyValuesDumpAsDevMsg( pKV );

	// Vitaliy: Disable cheats as part of reservation in case they were enabled (unless we are on Steam Beta)
	if ( sv_force_transmit_ents.IsFlagSet( FCVAR_DEVELOPMENTONLY ) &&	// any convar with FCVAR_DEVELOPMENTONLY flag will be sufficient here
		sv_cheats && sv_cheats->GetBool() )
	{
		sv_cheats->SetValue( 1 );
	}

	// Between here and the last part: apply settings...
	char const *szMapCommand = pKV->GetString( "map/mapcommand", "map" );

	const char *szMode = pKV->GetString( "game/mode", "sdk" );

#if 0
	char const *szGameMode = pKV->GetString( "game/mode", "" );
	if ( szGameMode && *szGameMode )
	{
		extern ConVar mp_gamemode;
		mp_gamemode.SetValue( szGameMode );
	}
#endif // 0

	// LAUNCH GAME
	if ( !Q_stricmp( szMode, "sdk" ) )
	{
		szBspName = pKV->GetString( "game/mission", NULL );
		if ( !szBspName )
			return;

		engine->ServerCommand( CFmtStr( "%s %s reserved\n",
			szMapCommand,
			szBspName ) );
	}
	else
	{
		bool bSuccess = false;
#ifndef DISABLE_PYTHON
		try {
			bSuccess = bp::extract<bool>(gamemgr.attr("_ApplyGameSettings")( PyKeyValuesToDict( pKV ) ));
		} catch( boost::python::error_already_set & ) {
			Warning("ApplyGameSettings: Error occurred while letting Python apply game settings\n");
			PyErr_Print();
		}
#endif // DISABLE_PYTHON

		if( !bSuccess )
			Warning( "ApplyGameSettings: Unknown game mode!\n" );
	}
}