Exemple #1
0
FState *FStateDefinitions::ResolveGotoLabel (AActor *actor, PClassActor *mytype, char *name)
{
	PClassActor *type = mytype;
	FState *state;
	char *namestart = name;
	char *label, *offset, *pt;
	int v;

	// Check for classname
	if ((pt = strstr (name, "::")) != NULL)
	{
		const char *classname = name;
		*pt = '\0';
		name = pt + 2;

		// The classname may either be "Super" to identify this class's immediate
		// superclass, or it may be the name of any class that this one derives from.
		if (stricmp (classname, "Super") == 0)
		{
			type = dyn_cast<PClassActor>(type->ParentClass);
			actor = GetDefaultByType(type);
		}
		else
		{
			// first check whether a state of the desired name exists
			PClass *stype = PClass::FindClass (classname);
			if (stype == NULL)
			{
				I_Error ("%s is an unknown class.", classname);
			}
			if (!stype->IsDescendantOf (RUNTIME_CLASS(AActor)))
			{
				I_Error ("%s is not an actor class, so it has no states.", stype->TypeName.GetChars());
			}
			if (!stype->IsAncestorOf (type))
			{
				I_Error ("%s is not derived from %s so cannot access its states.",
					type->TypeName.GetChars(), stype->TypeName.GetChars());
			}
			if (type != stype)
			{
				type = static_cast<PClassActor *>(stype);
				actor = GetDefaultByType (type);
			}
		}
	}
	label = name;
	// Check for offset
	offset = NULL;
	if ((pt = strchr (name, '+')) != NULL)
	{
		*pt = '\0';
		offset = pt + 1;
	}
	v = offset ? strtol (offset, NULL, 0) : 0;

	// Get the state's address.
	if (type == mytype)
	{
		state = FindState (label);
	}
	else
	{
		state = type->FindStateByString(label, true);
	}

	if (state != NULL)
	{
		state += v;
	}
	else if (v != 0)
	{
		I_Error ("Attempt to get invalid state %s from actor %s.", label, type->TypeName.GetChars());
	}
	else
	{
		Printf (TEXTCOLOR_RED "Attempt to get invalid state %s from actor %s.\n", label, type->TypeName.GetChars());
	}
	delete[] namestart;		// free the allocated string buffer
	return state;
}
Exemple #2
0
bool SString::BeginsWithI(const SString& strOther) const
{
    return stricmp(Left((int)strOther.length()), strOther) == 0;
}
Exemple #3
0
static TA_RetCode findTokenId( TA_Libc *libHandle,
                               const char *str,
                               TA_TokenId *id,
                               TA_Integer *optionalParam )
{
   TA_PROLOG;
   unsigned int i;
   const char *cmp_str;
   TA_TokenId tokenId;
   unsigned int extractedParam;
   TA_RetCode retCode;

   TA_TRACE_BEGIN( libHandle, findTokenId );

   *id = TA_TOK_END;
   *optionalParam = 0;

   tokenId = TA_TOK_END;
   extractedParam = 0;

   /* First check for token directly mapping to a simple string. */
   for( i=0; (i < TA_NB_TOKEN_ID) && (tokenId == TA_TOK_END); i++ )
   {
      cmp_str = TA_TokenString( libHandle, (TA_TokenId)i );

      if( cmp_str )
      {
          #if defined( WIN32 )
          if( stricmp( str, cmp_str ) == 0 )
          #else
          if( strcasecmp( str, cmp_str ) == 0 )
          #endif
          {
             tokenId = (TA_TokenId)i;
             extractedParam = 1;
          }
      }
   }

   /* If not found, look for more advanced token taking
    * optional "=n" parameters.
    */
   if( tokenId == TA_TOK_END )
   {
      retCode = findTokenIdWithParam( libHandle, &str[0], &tokenId, &extractedParam );

      if( retCode != TA_SUCCESS )
      {
         TA_TRACE_RETURN( retCode );
      }
   }

   /* Make sure it is a valid field for a file description. */
   switch( tokenId )
   {
   case TA_TOK_YYYY:
   case TA_TOK_YY:
   case TA_TOK_Y:
   case TA_TOK_M:
   case TA_TOK_MM:
   case TA_TOK_MMM:
   case TA_TOK_D:
   case TA_TOK_DD:
   case TA_TOK_OPEN:
   case TA_TOK_HIGH:
   case TA_TOK_LOW:
   case TA_TOK_CLOSE:
   case TA_TOK_VOLUME:
   case TA_TOK_OPENINTEREST:
   case TA_TOK_HOUR:
   case TA_TOK_MIN:
   case TA_TOK_SEC:
   case TA_TOK_HH:
   case TA_TOK_MN:
   case TA_TOK_SS:
   case TA_TOK_SKIP_N_CHAR:
   case TA_TOK_SKIP_N_HEADER_LINE:
   case TA_TOK_SKIP_N_REAL:
   case TA_TOK_SKIP_N_INTEGER:
      break;
   default:
      TA_TRACE_RETURN( TA_INVALID_FIELD );
   }

   /* Everything is fine, return the information. */
   *id = tokenId;
   *optionalParam = extractedParam;

   TA_TRACE_RETURN( TA_SUCCESS );
}
Exemple #4
0
//-----------------------------------------------------------------------------
// Purpose: Handle "cd" console command
//-----------------------------------------------------------------------------
void CCDAudio::CD_f ( void )
{
	char	*command;
	int		ret;
	int		n;

	if ( Cmd_Argc() < 2 )
		return;

	command = Cmd_Argv (1);

	if (stricmp(command, "on") == 0)
	{
		m_bEnabled = true;
		return;
	}

	if (stricmp(command, "off") == 0)
	{
		if (m_bIsPlaying)
			Stop();
		m_bEnabled = false;
		return;
	}

	if (stricmp(command, "reset") == 0)
	{
		m_bEnabled = true;
		if (m_bIsPlaying)
			Stop();
		for (n = 0; n < 100; n++)
			m_rgRemapCD[n] = n;
		GetAudioDiskInfo();
		return;
	}

	if (stricmp(command, "remap") == 0)
	{
		ret = Cmd_Argc() - 2;
		if ( ret > 0)
		{
			for (n = 1; n <= ret; n++)
			{
				m_rgRemapCD[n] = atoi(Cmd_Argv (n+1));
			}
		}
		return;
	}

	if (stricmp(command, "close") == 0)
	{
		CloseDoor();
		return;
	}

	if (!m_bIsValid)
	{
		GetAudioDiskInfo();
		if (!m_bIsValid)
		{
			return;
		}
	}

	if (stricmp(command, "play") == 0)
	{
		Play( atoi(Cmd_Argv (2)), false );
		return;
	}

	if (stricmp(command, "loop") == 0)
	{
		Play( atoi(Cmd_Argv (2)), true );
		return;
	}

	if (stricmp(command, "stop") == 0)
	{
		Stop();
		return;
	}

	if (stricmp(command, "pause") == 0)
	{
		Pause();
		return;
	}

	if (stricmp(command, "resume") == 0)
	{
		Resume();
		return;
	}

	if (stricmp(command, "eject") == 0)
	{
		if (m_bIsPlaying)
			Stop();
		Eject();
		m_bIsValid = false;
		return;
	}

	if (stricmp(command, "info") == 0)
	{
		Msg("%u tracks\n", m_nMaxTrack);
		if ( m_bIsPlaying )
		{
			Msg("Currently %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack);
		}
		else if ( m_bWasPlaying )
		{
			Msg("Paused %s track %u\n", m_bIsLooping ? "looping" : "playing", m_nPlayTrack);
		}
		Msg("Volume is %f\n", m_flVolume);
		return;
	}
}
Exemple #5
0
//
// Case insensitive compate.
//
bool SString::CompareI(const SString& strOther) const
{
    return stricmp(*this, strOther) == 0;
}
int WinEDA_BasePcbFrame::ReadGeneralDescrPcb(wxDC * DC, FILE * File, int * LineNum)
/**********************************************************************************/
{
char Line[1024], *data;
BASE_SCREEN * screen = m_CurrentScreen;

	while(  GetLine(File, Line, LineNum ) != NULL )
	{
		data = strtok(Line," =\n\r");
		if(strnicmp(data,"$EndGENERAL",10) == 0) break;

		if( strncmp(data, "Ly", 2) == 0 )	// Old format for Layer count
		{
			int Masque_Layer = 1, ii;
			data = strtok(NULL," =\n\r");
			sscanf(data,"%X",&Masque_Layer);
			// Setup layer count
			m_Pcb->m_BoardSettings->m_CopperLayerCount = 0;
			for ( ii = 0; ii < NB_COPPER_LAYERS; ii++ )
			{
				if ( Masque_Layer & 1 ) m_Pcb->m_BoardSettings->m_CopperLayerCount++;
				Masque_Layer >>= 1;
			}
			continue;
		}

		if(strnicmp(data, "Links", 5) == 0)
		{
			data = strtok(NULL," =\n\r");
			m_Pcb->m_NbLinks = atoi(data);
			continue;
		}

		if(strnicmp(data, "NoConn", 6) == 0)
		{
			data = strtok(NULL," =\n\r");
			m_Pcb->m_NbNoconnect = atoi(data);
			continue;
		}

		if(strnicmp(data, "Di", 2) == 0)
		{
			int ii, jj, bestzoom;
			wxSize pcbsize, screensize;
			data = strtok(NULL," =\n\r");
			m_Pcb->m_BoundaryBox.SetX(atoi(data));
			data = strtok(NULL," =\n\r");
			m_Pcb->m_BoundaryBox.SetY(atoi(data));
			data = strtok(NULL," =\n\r");
			m_Pcb->m_BoundaryBox.SetWidth(atoi(data) - m_Pcb->m_BoundaryBox.GetX());
			data = strtok(NULL," =\n\r");
			m_Pcb->m_BoundaryBox.SetHeight(atoi(data) - m_Pcb->m_BoundaryBox.GetY());

			/* calcul du zoom optimal */
			pcbsize = m_Pcb->m_BoundaryBox.GetSize();
			screensize = DrawPanel->GetClientSize();
			ii = pcbsize.x/screensize.x;
			jj = pcbsize.y/screensize.y;
			bestzoom = max(ii, jj);
			screen->m_Curseur = m_Pcb->m_BoundaryBox.Centre();

			screen->SetZoom(bestzoom);
			// la position des tracés a changé: mise a jour dans le DC courant
			wxPoint org;
			DrawPanel->GetViewStart(&org.x, &org.y);
			DrawPanel->GetScrollPixelsPerUnit(&ii, &jj);
			org.x *= ii; org.y *= jj;
#ifdef WX_ZOOM
			DC->SetUserScale(1.0/(double)screen->GetZoom(), 1.0/screen->GetZoom());
			org.x *= screen->GetZoom(); org.y *= screen->GetZoom();
			DC->SetDeviceOrigin(-org.x, -org.y);
#endif
			DrawPanel->SetBoundaryBox();
			Recadre_Trace(TRUE);
			continue;
		}

			/* Lecture du nombre de segments type DRAW , TRACT, ZONE */
		if(stricmp(data, "Ndraw") == 0)
		{
			data = strtok(NULL," =\n\r");
			NbDraw = atoi(data);;
			continue;
		}

		if(stricmp(data, "Ntrack") == 0)
		{
			data = strtok(NULL," =\n\r");
			NbTrack = atoi(data);
			continue;
		}

		if(stricmp(data, "Nzone") == 0)
		{
			data = strtok(NULL," =\n\r");
			NbZone = atoi(data);
			continue;
		}

		if(stricmp(data, "Nmodule") == 0)
		{
			data = strtok(NULL," =\n\r");
			NbMod = atoi(data);
			continue;
		}

		if(stricmp(data, "Nnets") == 0)
		{
			data = strtok(NULL," =\n\r");
			NbNets = atoi(data);
			continue;
		}

	}
Exemple #7
0
int
PLP_scatterplot()
{
int i;
char attr[NAMEMAXLEN], val[256];
char *line, *lineval;
int nt, lvp;
int first;

int stat;
int align;
double adjx, adjy;

int xfield, yfield;
char symbol[256];
double linelen;
char linedetails[256];
double xloc, yloc;
int cluster;
double radius;
char symcode[80];
double x, y;
char text[256];
double cx, cy;
double hlinelen;
char textdetails[256];
int lblfield;
char selex[256];
int result;
double sizescale;
int sizefield;
double ox[38], oy[38];
double clusterfact;
double oldx, oldy;
int dupcount;
int subdupcount;
int clustevery;
int verttext;
int nrow;
char legendlabel[256]; /* raised (can contain urls for clickmap) scg 4/22/04 */
char xrange[80], yrange[80];
double xlo, xhi, ylo, yhi;
char rhi[40], rlo[40];
double clusterdiff;
int realrow;
int clustermeth;
int symfield;
int symfield_userange;
int dupsleg;
char mapurl[MAXPATH], expurl[MAXPATH];
char maplabel[MAXTT], explabel[MAXTT];
int irow;
double ptx, pty;
double hw, txhi;
char linedir, reqlinedir;
double rectw, recth;
int dorect, rectoutline;
int clickmap_on;
int flop2;
int maxdups;
char labelword[80], labeltxt[80];
double vennden;

TDH_errprog( "pl proc scatterplot" );


/* initialize */
xfield = -1; yfield = -1;
strcpy( symbol, "" );
linelen = -1.0;
strcpy( linedetails, "" );
xloc = 0.0;
yloc = 0.0;
/* cluster = 1; */
cluster = 0;   /* changed and added to "breakers" in docs, scg 5/29/06 */
strcpy( text, "" );
strcpy( textdetails, "" );
lblfield = -1;
strcpy( selex, "" );
sizefield = -1;
sizescale = 0.5/72.0; /* correspond roughly with pt size */
clusterfact = 0.01;
verttext = 0;
strcpy( legendlabel, "" );
strcpy( xrange, "" );
strcpy( yrange, "" );
clustevery = 0;
clusterdiff = 0.001;
clustermeth = 0;
symfield = -1;
dupsleg = 0;
symfield_userange = 0;
strcpy( mapurl, "" ); strcpy( expurl, "" );
strcpy( maplabel, "" ); strcpy( explabel, "" );
dorect = 0;
rectoutline = 0;
linedir = reqlinedir = '\0'; /* scg 3/4/03 */
clickmap_on = 0;
strcpy( labelword, "@VAL" );
vennden = 0.0;

/* get attributes.. */
first = 1;
while( 1 ) {
	line = getnextattr( first, attr, val, &lvp, &nt );
	if( line == NULL ) break;
	first = 0;
	lineval = &line[lvp];

	if( stricmp( attr, "xfield" )==0 ) xfield = fref( val ) -1;
		
	else if( stricmp( attr, "yfield" )==0 ) yfield = fref( val ) -1;
	else if( stricmp( attr, "labelfield" )==0 ) lblfield = fref( val ) -1;
		
	else if( stricmp( attr, "symbol" )==0 ) strcpy( symbol, lineval );
	else if( stricmp( attr, "text" )==0 ) strcpy( text, val );
	else if( stricmp( attr, "textdetails" )==0 ) strcpy( textdetails, lineval );

	else if( stricmp( attr, "sizefield" )==0 ) sizefield = fref( val ) -1;
	else if( stricmp( attr, "sizescale" )==0 ) sizescale = atof( val ) * 0.5/72.0;
	else if( stricmp( attr, "xrange" )==0 ) strcpy( xrange, lineval );
	else if( stricmp( attr, "yrange" )==0 ) strcpy( yrange, lineval );
	else if( stricmp( attr, "clickmapurl" )==0 ) {
		if( PLS.clickmap ) { strcpy( mapurl, val ); clickmap_on = 1; }
		}
	else if( stricmp( attr, "clickmaplabel" )==0 ) {
		if( PLS.clickmap ) { strcpy( maplabel, lineval ); clickmap_on = 1; }
		}
        else if( stricmp( attr, "clickmaplabeltext" )==0 ) {
                if( PLS.clickmap ) { getmultiline( "clickmaplabeltext", lineval, MAXTT, maplabel ); clickmap_on = 1; }
                }

	else if( stricmp( attr, "linelen" )==0 ) {
		if( val[0] == '\0' ) linelen = -1.0;
		else	{
			linelen = atof( val );
			if( PLS.usingcm ) linelen /= 2.54;
			}
		}
	else if( stricmp( attr, "linedir" )==0 ) reqlinedir = tolower( val[0] );
	else if( stricmp( attr, "linedetails" )==0 ) strcpy( linedetails, lineval );
		
	else if( stricmp( attr, "xlocation" )==0 ) {
		Eposex( lineval, X, &xloc ); /* val -> lineval scg 5/3/99 */
		if( Econv_error() ) Eerr( 2394, "invalid xlocation", val );
		}
		
	else if( stricmp( attr, "ylocation" )==0 ) {
		Eposex( lineval, Y, &yloc ); /* val -> lineval 5/3/99 */
		if( Econv_error() ) Eerr( 2395, "invalid ylocation", val );
		}
		
	else if( stricmp( attr, "select" )==0 ) strcpy( selex, lineval );
	else if( stricmp( attr, "legendlabel" )==0 ) strcpy( legendlabel, lineval );

	else if( stricmp( attr, "cluster" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) cluster = 1;
		else cluster = 0;
		}
	else if( stricmp( attr, "clusterdiff" )==0 ) {
		cluster = 1;
		clusterdiff = atof( val );
		}
	else if( stricmp( attr, "clustermethod" )==0 ) {
		cluster = 1;
		clustermeth = tolower( val[0] );  /* h, v, 2, u, r, ..  */
		}
	else if( stricmp( attr, "clusterfact" )==0 ) {
		cluster = 1;
		clusterfact = atof( val ) * .01;
		}
	else if( stricmp( attr, "clustevery" )==0 ) {
		cluster = 1;
		clustevery = atoi( val );
		if( clustevery < 1 ) clustevery = 1;
		}
	else if( stricmp( attr, "dupsleg" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) { 
			dupsleg = 1; 
			cluster = 1; 
			clustermeth = 'l';
			strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
			}
		else dupsleg = 0;
		}
	else if( stricmp( attr, "symfield" )==0 ) {
		strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
		symfield = fref( val ) -1;
		symfield_userange = 0;
		}
	else if( stricmp( attr, "symrangefield" )==0 ) {
		strcpy( symbol, "sym6a" ); /* just to get us into symbol mode */
		symfield = fref( val ) -1;
		symfield_userange = 1;
		}
	else if( stricmp( attr, "verticaltext" )==0 ) {
		if( strnicmp( val, YESANS, 1 )==0 ) verttext = 1;
		else verttext = 0;
		}
	else if( stricmp( attr, "rectangle" )==0 ) {
		nt = sscanf( lineval, "%lf %lf %s", &rectw, &recth, val );
		if( nt == 3 ) rectoutline = 1;
		rectw *= 0.5;
		recth *= 0.5;
		rectw = Eax( rectw ) - Eax( 0.0 );
		recth = Eay( recth ) - Eay( 0.0 );
		dorect = 1;
		}

	else if( stricmp( attr, "labelword" ) == 0 ) strcpy( labelword, lineval );
	else if( stricmp( attr, "vennden" ) == 0 ) vennden = atof( val );

	else Eerr( 1, "attribute not recognized", attr );
	}


/* overrides and degenerate cases */
/* -------------------------- */
if( Nrecords < 1 ) return( Eerr( 17, "No data has been read yet w/ proc getdata", "" ) );
if( !scalebeenset() )
         return( Eerr( 51, "No scaled plotting area has been defined yet w/ proc areadef", "" ) );

if( xfield < 0 && yfield < 0 ) return( Eerr( 2205, "Niether xfield nor yfield defined", "" ));

if( lblfield >= 0 ) cluster = 0;  /* added scg 12/21/00 */

if( stricmp( legendlabel, "#usexname" )==0 ) getfname( xfield+1, legendlabel );
if( stricmp( legendlabel, "#useyname" )==0 ) getfname( yfield+1, legendlabel );

if( dorect ) strcpy( symbol, "" );


/* now do the plotting work.. */
/* -------------------------- */

if( cluster ) {
	/* make offsets */
	for( i = 0; i < 38; i++ ) {
		ox[i] = xofst[i] * clusterfact;
		oy[i] = yofst[i] * clusterfact;
		}

	/* determine cluster method */
	if( clustermeth == 0 ) {
		if( yfield < 0 ) clustermeth = 'v'; 	 /* 1-d horizontal - cluster vertically (was 'h'-scg 4/21/05) */
		else if( xfield < 0 ) clustermeth = 'h'; /* 1-d vertical - cluster horizontally (was 'v'-scg 4/21/05) */
		else clustermeth = '2'; 		 /* 2-d cluster */
		}
	}

/* ranges */
xlo = EDXlo;
xhi = EDXhi;
ylo = EDYlo;
yhi = EDYhi;
if( xrange[0] != '\0' ) {
	nt = sscanf( xrange, "%s %s", rlo, rhi );
	xlo = Econv( X, rlo );
	if( Econv_error() ) { Eerr( 3958, "xrange bad format", rlo ); xlo = EDXlo; }
	if( nt == 2 ) xhi = Econv( X, rhi );
	if( Econv_error() ) { Eerr( 3958, "xrange bad format", rhi ); xhi = EDXhi; }
	}
if( yrange[0] != '\0' ) {
	nt = sscanf( yrange, "%s %s", rlo, rhi );
	ylo = Econv( Y, rlo );
	if( Econv_error() ) { Eerr( 3958, "yrange bad format", rlo ); ylo = EDYlo; }
	if( nt == 2 ) yhi = Econv( Y, rhi );
	if( Econv_error() ) { Eerr( 3958, "yrange bad format", rhi ); yhi = EDYhi; }
	}






nrow = 0;
for( i = 0; i < Nrecords; i++ ) {

	if( selex[0] != '\0' ) { /* process against selection condition if any.. */
                stat = do_select( selex, i, &result );
                if( stat != 0 ) { Eerr( stat, "Select error", selex ); continue; }
                if( result == 0 ) continue; /* reject */
                }

	/* get x value.. */
	if( xfield >= 0 ) {
		x = fda( i, xfield, 'x' );
        	if( Econv_error() ) { conv_msg( i, xfield, "xfield" ); continue; }
		if( x < xlo || x > xhi ) continue;
		}

	/* get y value.. */
	if( yfield >= 0 ) {
		y = fda( i, yfield, 'y' );
        	if( Econv_error() ) { conv_msg( i, yfield, "yfield" ); continue; }
		if( y < ylo || y > yhi ) continue;
		}

	/* go to absolute units.. */
	if( xfield < 0 ) x = xloc;
	else x = Eax(x);
	if( yfield < 0 ) y = yloc;
	else y = Eay(y);


	/* put (x,y) into PLV array so points can be sorted.. */
	if( nrow >= PLVthirdsize ) {
		fprintf( PLS.errfp, "point capacity exceeded, skipping data point (raise using -maxvector)\n" );
		continue;
		}
	dat3d( nrow, 0 ) = x;
	dat3d( nrow, 1 ) = y;
	dat3d( nrow, 2 ) = (double)i;  /* added scg 12/21/00 - went from dat2d to dat3d */
				       /* need to keep track of actual location in data array for labels, sizefield, etc.. */
	nrow++;
	}


/* if clustering and not using a label field, sort PLV array */
if( cluster && lblfield < 0 && sizefield < 0 ) {
	if( PLS.debug ) fprintf( PLS.diagfp, "sorting points for scatterplot\n" );
	qsort( PLV, nrow, sizeof(double)*3, ptcompare );
	}



if( verttext ) Etextdir( 90 );

/* these are used in clustering.. */
oldx = NEGHUGE;
oldy = NEGHUGE;
dupcount = 0;
subdupcount = 0;
maxdups = 0;

strcpy( symcode, "sym6a" );
radius = 0.04;


/* in the following, text must come before symbol.. */
if( text[0] != '\0' || lblfield >= 0 ) {
	textdet( "textdetails", textdetails, &align, &adjx, &adjy, -3, "R", 1.0 );
	}
if( symbol[0] != '\0' ) {
	symdet( "symbol", symbol, symcode, &radius );
	}
if( linelen > 0.0 || rectoutline ) {
	linedet( "linedetails", linedetails, 0.5 );
	}
cx = Ecurtextwidth * 0.3;
cy = Ecurtextheight * 0.3;
hlinelen = linelen * 0.5;
txhi = cy + cy;
if( text[0] != '\0' ) hw = strlen( text ) * Ecurtextwidth * 0.5;

/* now display points.. */
for( irow = 0; irow < nrow; irow++ ) {
	x = dat3d( irow, 0 );
	y = dat3d( irow, 1 );
	realrow = (int)dat3d( irow, 2 ); /* added scg 12/21/00 */

	/* in this loop, you MUST USE REALROW, NOT IROW for accessing ancillary data fields!! */

	if( cluster ) {
		if( GL_close_to( x, oldx, clusterdiff ) && GL_close_to( y, oldy, clusterdiff ) ) {
			subdupcount++;
			if( subdupcount >= clustevery ) {
				dupcount++;
				subdupcount = 0;
				}

			if( dupcount % 2 == 0 ) flop2 = 1;
			else flop2 = -1;

			if( clustermeth == '2' && dupcount > 37 ) {
				maxdups = 37;
				dupcount = 0; /* mod */
				}

			if( clustermeth == 'h' ) x += ((dupcount+1)/2) * clusterfact * 2.0 * flop2;
			else if( clustermeth == 'v' ) y += ((dupcount+1)/2) * clusterfact * 2.0 * flop2;
			else if( clustermeth == 'u' ) y += dupcount * clusterfact * 2.0; /* 1D upward */
			else if( clustermeth == 'r' ) x += dupcount * clusterfact * 2.0; /* 1D rightward */
			else if( clustermeth == 'l' ) ; /* legend lookup, no offset */
			else if( clustermeth == '2' ) {  x += ox[dupcount%38]; y += oy[dupcount%38]; } /* 2-D */

			if( clustermeth == 'l' ) { /* if more duplicate points coming, skip.. */
				if( irow < nrow-1 ) {
					double nextx, nexty;
					nextx = dat3d( irow+1, 0 );
					nexty = dat3d( irow+1, 1 );
					if( GL_close_to( x, nextx, clusterdiff ) && 
					    GL_close_to( y, nexty, clusterdiff ) ) continue;
					}
				}
			}
		else {
			if( dupcount > maxdups ) maxdups = dupcount;
			oldx = x;
			oldy = y;
			dupcount = 0;
			subdupcount = 0;
			}
		}

	/* allow @field substitutions into url */
        if( clickmap_on ) {
		do_subst( expurl, mapurl, realrow, URL_ENCODED );
		do_subst( explabel, maplabel, realrow, NORMAL );
		}



	/* render text, mark or line.. */
	/* text can be combined with mark if text and symbol both specified */

	/* symbol or rectangle.. */
	if( symbol[0] != '\0' || dorect || ( text[0] == '\0' && linelen <= 0.0 && lblfield < 0 ) ) {
		if( symfield >= 0 ) {  /* look it up in legend list.. */
			if( symfield_userange ) {
                		stat = PL_get_legent_rg( atof( da( realrow, symfield ) ), symbol, NULL, NULL );
				}
                	else stat = PL_get_legent( da( realrow, symfield ), symbol, NULL, NULL );
			if( stat ) Eerr( 7429, "warning: symfield: no matching legend entry tag found", da( realrow, symfield ) );
			if( !dorect ) symdet( "symfield", symbol, symcode, &radius );
			}
		if( dupsleg ) {  /* look it up in legend list.. */
                	stat = PL_get_legent_rg( (double)dupcount+1, symbol, NULL, NULL );
			if( stat ) Eerr( 7692, "warning: dupsleg: no appropriate legend entry tag\n", "" );
			if( !dorect ) symdet( "symfield", symbol, symcode, &radius );
			/* note: currently all marks will be rendered; the last one will be on "top"  */
			}
		if( sizefield >= 0 ) 
			radius = sqrt((atof( da( realrow, sizefield ) ) * sizescale)/3.1415927);
			         /* sizefield scales up the AREA of symbol, not the diameter */
		if( dorect ) {
			char color[ COLORLEN ];
			strcpy( color, "" ); /* added scg 9/1/05 - heatmap bug */
			if( symfield >=0 || dupsleg ) sscanf( symbol, "%s", color ); /* strip off any trailing space */
			Ecblock( x-rectw, y-recth, x+rectw, y+recth, color, rectoutline );
			symbol[0] = '\0';
			}
		else if( vennden > 0.0 ) {
			double urad;
			for( urad = 0.01; urad < radius; urad += vennden ) Emark( x, y, symcode, urad );
			} 
		else Emark( x, y, symcode, radius );

		if( clickmap_on ) {
			if( dorect ) clickmap_entry( 'r', expurl, 0, x-rectw, y-recth, x+rectw, y+recth, 0, 0, explabel );
			else clickmap_entry( 'r', expurl, 0, x-radius, y-radius, x+radius, y+radius, 0, 0, explabel );
			}
			
		}

	/* text */
	if( text[0] != '\0' ) {
		if( symbol[0] != '\0' )  /* set text color etc... */
			textdet( "textdetails", textdetails, &align, &adjx, &adjy, -3, "R", 1.0 );
		if( sizefield >= 0 ) Etextsize( (int) (atof( da( realrow, sizefield ) ) * sizescale) );
		if( verttext ) { ptx = (x+cy)+adjx; pty = y; } /* cy puts midheight of character on point */
		else { ptx = x+adjx; pty = (y-cy)+adjy; }

		convertnl( text );
		Emov( ptx, pty );
		if( align == '?' ) Edotext( text, 'C' );
		else Edotext( text, align );
		if( symbol[0] != '\0'  )  /* restore symbol color etc... */
			symdet( "symbol", symbol, symcode, &radius );

		if( clickmap_on ) clickmap_entry( 'r', expurl, 0, ptx-hw, pty, x+hw, y+txhi, 0, 0, explabel );
		}

	/* label from data */
	else if( lblfield  >= 0 ) {
		if( sizefield >= 0 ) Etextsize( (int) (atof( da( realrow, sizefield ) ) * sizescale) );
		if( verttext) { ptx = (x+cy)+adjx; pty = y+adjy; } /* cy puts midheight of character on point */
		else { ptx = x+adjx; pty = (y-cy)+adjy; } 

		strcpy( labeltxt, labelword );
		GL_varsub( labeltxt, "@VAL", da( realrow, lblfield ) );

		Emov( ptx, pty );
		if( align == '?' ) Edotext( labeltxt, 'C' );
		else Edotext( labeltxt, align );

		if( clickmap_on ) {
			hw = strlen( labeltxt ) * Ecurtextwidth * 0.5;
			if( GL_member( align, "C?" ))clickmap_entry( 'r', expurl, 0, ptx-hw, pty, x+hw, y+txhi, 0, 0, explabel );
			else if( align == 'L' ) clickmap_entry( 'r', expurl, 0, ptx, pty, x+(hw*2.0), y+txhi, 0, 0, explabel );
			else if( align == 'R' ) clickmap_entry( 'r', expurl, 0, ptx-(hw*2.0), pty, x, y+txhi, 0, 0, explabel );
			}
		}

	/* line */         /* (no clickmap support) */   /* no legend support either (?) */
	else if( linelen > 0.0 ) {
		if( sizefield >= 0 ) hlinelen = linelen * 0.5 * atof( da( realrow, sizefield ) ); 
					/* sizefield acts as a scale factor to linelen */

		if( reqlinedir != '\0' ) linedir = reqlinedir;
		else if( xfield >= 0 && yfield >= 0 ) linedir = 'h'; 	/* arbitrary .. scg 5/16/03 */
		else if( xfield >= 0 ) linedir = 'v';
		else linedir = 'h';			/* scg 3/5/03 */

		if( linedir == 'v' ) { Emov( x, y-hlinelen ); Elin( x, y+hlinelen ); }
		else if( linedir == 'u' ) { Emov( x, y ); Elin( x, y+(hlinelen*2.0) ); }
		else if( linedir == 'r' ) { Emov( x, y ); Elin( x+(hlinelen*2.0), y ); }
		else { Emov( x-hlinelen, y ); Elin( x+hlinelen, y ); }
		}

	}
if( verttext ) Etextdir( 0 );

if( legendlabel[0] != '\0' ) {
	char s[40];
	sprintf( s, "%d", nrow );
	GL_varsub( legendlabel, "@NVALUES", s );
	if( linelen <= 0.0 && lblfield < 0 && text[0] == '\0' )
		PL_add_legent( LEGEND_SYMBOL, legendlabel, "", symbol, "", "" );
	else if( symbol[0] != '\0' && text[0] != '\0' )
		PL_add_legent( LEGEND_SYMBOL+LEGEND_TEXT, legendlabel, "", text, textdetails, symbol );
	else if( linelen > 0.0 ) {
		char dirstr[8];
		sprintf( dirstr, "%c", linedir );
		PL_add_legent( LEGEND_LINEMARK, legendlabel, "", linedetails, dirstr, "" );
		}
	}

setintvar( "NVALUES", nrow );
maxdups++;
setintvar( "MAXDUPS", maxdups );

return( 0 );
}
void ModelPoseDebugInfo::AddInfoText( InfoText *x, ModelPoseDebugInfo *pOld )
{
	if ( x )
	{
		// Try to set the proper flags on the info text
		x->m_uiFlags &= ~F_SEEN_LAST_FRAME;
		x->m_uiFlags |= F_SEEN_THIS_FRAME;
	}

	// If we have smth to compare against
	if ( pOld )
	{
		// Search for the same activity/label in the other model pose debug info
		ModelPoseDebugInfo &o = *pOld;
		int k = o.m_iCurrentText;
		if ( x )
		{
			for ( ; k < o.m_arrTxt.Count(); ++ k )
			{
				InfoText &txt = o.m_arrTxt[k];
				if ( ( txt.m_uiFlags & F_SEEN_THIS_FRAME ) &&
					!stricmp( x->m_chActivity, txt.m_chActivity ) &&
					!stricmp( x->m_chLabel, txt.m_chLabel ) &&
					( x->m_iActivity == txt.m_iActivity ) )
				{
					x->m_flTimeAlive = txt.m_flTimeAlive;
					break;
				}
			}
		}
		else
		{
			k = o.m_arrTxt.Count();
		}

		// Range of finished activities
		int iFinishedRange[2] = { o.m_iCurrentText, k };

		// Check whether this is a new message
		if ( k == o.m_arrTxt.Count() )
		{
			if ( !x )
			{
				o.m_iCurrentText = k;
			}
			else
			{
				// Don't update the current when insertion happens and don't have finished commands
				iFinishedRange[1] = iFinishedRange[0];
			}
		}
		else
		{
			o.m_iCurrentText = k + 1;
			if ( x )
			{
				x->m_uiFlags |= F_SEEN_LAST_FRAME;
				x->m_flTimeAlive += gpGlobals->frametime;
			}
		}

		// Everything before finished
		for ( int iFinished = iFinishedRange[0]; iFinished < iFinishedRange[1]; ++ iFinished )
		{
			InfoText &txtFinished = o.m_arrTxt[ iFinished ];

			if ( txtFinished.m_uiFlags & F_SEEN_THIS_FRAME )
				txtFinished.m_uiFlags |= F_SEEN_LAST_FRAME;

			txtFinished.m_uiFlags &= ~F_SEEN_THIS_FRAME;

			txtFinished.m_flTimeToLive -= gpGlobals->frametime;
			txtFinished.m_flTimeAlive += gpGlobals->frametime;

			if ( txtFinished.m_flTimeToLive >= 0.0f )
				m_arrTxt.AddToTail( txtFinished );
		}
	}

	if ( x )
	{
		// Now add it to the array
		x->m_flTimeToLive = ui_posedebug_fade_out_time.GetFloat();
		m_arrTxt.AddToTail( *x );
	}
}
/*
==============
ChangeLevel

Server is changing to a new level, check mapcycle.txt for map name and setup info
==============
*/
void CHalfLifeMultiplay :: ChangeLevel( void )
{
	static char szPreviousMapCycleFile[ 256 ];
	static mapcycle_t mapcycle;

	char szNextMap[32];
	char szFirstMapInList[32];
	char szCommands[ 1500 ];
	char szRules[ 1500 ];
	int minplayers = 0, maxplayers = 0;
	strcpy( szFirstMapInList, "hldm1" );  // the absolute default level is hldm1

	int	curplayers;
	BOOL do_cycle = TRUE;

	// find the map to change to
	char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" );
	ASSERT( mapcfile != NULL );

	szCommands[ 0 ] = '\0';
	szRules[ 0 ] = '\0';

	curplayers = CountPlayers();

	// Has the map cycle filename changed?
	if ( stricmp( mapcfile, szPreviousMapCycleFile ) )
	{
		strcpy( szPreviousMapCycleFile, mapcfile );

		DestroyMapCycle( &mapcycle );

		if ( !ReloadMapCycleFile( mapcfile, &mapcycle ) || ( !mapcycle.items ) )
		{
			ALERT( at_console, "Unable to load map cycle file %s\n", mapcfile );
			do_cycle = FALSE;
		}
	}

	if ( do_cycle && mapcycle.items )
	{
		BOOL keeplooking = FALSE;
		BOOL found = FALSE;
		mapcycle_item_s *item;

		// Assume current map
		strcpy( szNextMap, STRING(gpGlobals->mapname) );
		strcpy( szFirstMapInList, STRING(gpGlobals->mapname) );

		// Traverse list
		for ( item = mapcycle.next_item; item->next != mapcycle.next_item; item = item->next )
		{
			keeplooking = FALSE;

			ASSERT( item != NULL );

			if ( item->minplayers != 0 )
			{
				if ( curplayers >= item->minplayers )
				{
					found = TRUE;
					minplayers = item->minplayers;
				}
				else
				{
					keeplooking = TRUE;
				}
			}

			if ( item->maxplayers != 0 )
			{
				if ( curplayers <= item->maxplayers )
				{
					found = TRUE;
					maxplayers = item->maxplayers;
				}
				else
				{
					keeplooking = TRUE;
				}
			}

			if ( keeplooking )
				continue;

			found = TRUE;
			break;
		}

		if ( !found )
		{
			item = mapcycle.next_item;
		}			
		
		// Increment next item pointer
		mapcycle.next_item = item->next;

		// Perform logic on current item
		strcpy( szNextMap, item->mapname );

		ExtractCommandString( item->rulebuffer, szCommands );
		strcpy( szRules, item->rulebuffer );
	}

	if ( !IS_MAP_VALID(szNextMap) )
	{
		strcpy( szNextMap, szFirstMapInList );
	}

	g_fGameOver = TRUE;

	ALERT( at_console, "CHANGE LEVEL: %s\n", szNextMap );
	if ( minplayers || maxplayers )
	{
		ALERT( at_console, "PLAYER COUNT:  min %i max %i current %i\n", minplayers, maxplayers, curplayers );
	}
	if ( strlen( szRules ) > 0 )
	{
		ALERT( at_console, "RULES:  %s\n", szRules );
	}
	
	CHANGE_LEVEL( szNextMap, NULL );
	if ( strlen( szCommands ) > 0 )
	{
		SERVER_COMMAND( szCommands );
	}
}
Exemple #10
0
void    main( int argc, char *argv[] ) {
//======================================

    int         rc;
    char        *wfl_env;
    char        *p;
    char        *q;
    char        *cmd;

    argc = argc;

    __InitResource();
    __ErrorInit( argv[0] );

    CmpOpts[0] = '\0';

    SwitchChars[0] = '-';
    SwitchChars[1] = _dos_switch_char();
    SwitchChars[2] = '\0';

    Word = MemAlloc( MAX_CMD );
    cmd = MemAlloc( 2*MAX_CMD ); // for "WFL" environment variable and command line

    // add "WFL" environment variable to "cmd" unless "/y" is specified
    // in "cmd" or the "WFL" environment string

    wfl_env = getenv( WFLENV );
    if( wfl_env != NULL ) {
        strcpy( cmd, wfl_env );
        strcat( cmd, " " );
        p = cmd + strlen( cmd );
        getcmd( p );
        for( q = cmd; (q = strpbrk( q, SwitchChars )) != NULL; ) {
            if( tolower( *(++q) ) == 'y' ) {
                getcmd( cmd );
                p = cmd;
                break;
            }
        }
    } else {
        getcmd( cmd );
        p = cmd;
    }
    p = SkipSpaces( p );
    if( ( *p == '\0' ) || ( strncmp( p, "? ", 2 ) == NULL ) ) {
        Usage();
        rc = 1;
    } else {
        Fp = fopen( TEMPFILE, "w" );
        if( Fp == NULL ) {
            PrintMsg( CL_ERROR_OPENING_TMP_FILE );
            rc = 1;
        } else {
            ObjName = NULL;
            rc = Parse( cmd );
            if( rc == 0 ) {
                if( !Flags.quiet ) {
                    PrtBanner();
                }
                rc = CompLink();
            }
            if( rc == 1 )
                fclose( Fp );
            if( LinkName != NULL ) {
                if( stricmp( LinkName, TEMPFILE ) != 0 ) {
                    remove( LinkName );
                    rename( TEMPFILE, LinkName );
                }
            } else {
                remove( TEMPFILE );
            }
        }
    }
    free( Word );
    free( cmd );
    wfl_exit( rc == 0 ? 0 : 1 );
}
Exemple #11
0
static  int     Parse( char *cmd ) {
//==================================

    char        opt;
    char        *end;
    int         len;
    int         cmp_option;
    char        in_quotes;

    Flags.no_link = 0;
    Flags.link_for_sys = 0;
    Flags.quiet        = 0;
#if _CPU == 8086
    Flags.windows      = 0;
    Flags.link_for_dos = 0;
    Flags.link_for_os2 = 0;
#else
    Flags.default_win  = 0;
#endif
    Flags.do_cvpack    = 0;

    DebugFlag = 0;

    // "cmd" will always begin with at least one
    // non-space character if we get this far

    do {
        opt = *cmd;
        if( ( opt == '-' ) || ( opt == SwitchChars[1] ) ) {
            cmd++;
        } else {
            opt = ' ';
        }
        in_quotes = FALSE;
        end = cmd;
        for(;;) {
            if( *end == '\0' )
                break;
            if( *end == '"' ) {
                if( in_quotes )
                    break;
                in_quotes = TRUE;
            }
            if( !in_quotes ) {
                if( *end == ' '  )
                    break;
                if( *end == '-' )
                    break;
                if( *end == SwitchChars[1] ) {
                    break;
                }
            }
            ++end;
        }
        len = end - cmd;
        if( len != 0 ) {
            if( opt == ' ' ) {  // if filename, add to list
                strncpy( Word, cmd, len );
                Word[len] = '\0';
                strlwr( Word );
                if( strstr( Word, ".lib" ) != NULL ) {
                    AddFile( &LibList, Word );
                } else {
                    AddFile( &FileList, Word );
                }
            } else {            // otherwise, do option
                --len;
                strncpy( Word, cmd + 1, len );
                Word[len] = '\0';
                cmp_option = 1; // assume its a compiler option
                switch( tolower( *cmd ) ) {
                case 'f':       // files option
                    end = ScanFName( end, len );
                    switch( tolower( Word[0] ) ) {
                    case 'd':   // name of linker directive file
                        if( Word[1] == '\0' ) {
                            LinkName = TEMPFILE;
                            cmp_option = 0;
                        } else if( (Word[1] == '=') || (Word[1] == '#') ) {
                            MakeName( Word, ".lnk" );    // add extension
                            LinkName = strdup( Word + 2 );
                            cmp_option = 0;
                        }
                        break;
                    case 'e':   // name of exe file
                        if( ( Word[1] == '=' ) || ( Word[1] == '#' ) ) {
                            fputs( "name ", Fp );
                            Fputnl( Word + 2, Fp );
                            strcpy( ExeName, Word + 2 );
                            cmp_option = 0;
                        }
                        break;
                    case 'm':   // name of map file
                        if( Word[1] == '\0' ) {
                            fputs( "option map\n", Fp );
                            cmp_option = 0;
                        } else if( (Word[1] == '=') || (Word[1] == '#') ) {
                            fputs( "option map=", Fp );
                            Fputnl( Word + 2, Fp );
                            cmp_option = 0;
                        }
                        break;
                    case 'i':
                        if( ( Word[1] == '=' ) || ( Word[1] == '#' ) ) {
                            fputs( "@", Fp );
                            Fputnl( Word + 2, Fp );
                            cmp_option = 0;
                        }
                        break;
                    case 'o':   // name of object file
                        // parse off argument, so we get right filename
                        // in linker command file
                        if( ( Word[1] == '=' ) || ( Word[1] == '#' ) ) {
                            ObjName = strdup( &Word[2] );
                        }
                        break;
                    default:
                        break;
                    }
                    break;
                case 'k':       // stack size option
                    if( ( Word[0] == '=' ) || ( Word[0] == '#' ) ) {
                        fputs( "option stack=", Fp );
                        Fputnl( Word + 1, Fp );
                        cmp_option = 0;
                    }
                    break;
                case 'c':       // compile only
                    if( Word[0] == '\0' ) {
                        Flags.no_link = 1;
                        cmp_option = 0;
                    }
                    break;
                case 'y':
                    if( Word[0] == '\0' ) {
                        cmp_option = 0;
                    }
                    break;
                case 'p':
                    // ignore the /p option - we now only
                    // have a protect-mode compiler
                    if( Word[0] == '\0' ) {
                        cmp_option = 0;
                    }
                    break;
                case 'l':
                    if( ( Word[0] == '=' ) || ( Word[0] == '#' ) ) {
                        Flags.link_for_sys = 1;
                        SystemName = strdup( &Word[1] );
                        cmp_option = 0;
#if _CPU == 8086
                    } else if( stricmp( Word, "r" ) == 0 ) {
                        Flags.link_for_dos = 1;
                        Flags.link_for_os2 = 0;
                        cmp_option = 0;
                    } else if( stricmp( Word, "p" ) == 0 ) {
                        Flags.link_for_os2 = 1;
                        Flags.link_for_dos = 0;
                        cmp_option = 0;
#endif
                    }
                    break;
                case '"':
                    Fputnl( &Word[0], Fp );
                    ++end;      // skip over closing quote
                    cmp_option = 0;
                    break;

                // compiler options that affect the linker

#if _CPU != 8086
                case 'b':
                    if( stricmp( Word, "w" ) ) {
                        Flags.default_win = 1;
                    }
                    break;
#endif

                case 'q':
                    if( IsOption( cmd, len + sizeof(char), "Quiet" ) ) {
                        Flags.quiet = 1;
                    }
                    break;
                case 'd':
                    if( DebugFlag == 0 ) { // not set by -h yet
                        if( strcmp( Word, "1" ) == 0 ) {
                            DebugFlag = 1;
                        } else if( strcmp( Word, "2" ) == 0 ) {
                            DebugFlag = 2;
                        }
                    }
                    break;
                case 'h':
                    if( strcmp( Word, "w" ) == 0 ) {
                        DebugFlag = 3;
                    } else if( strcmp( Word, "c" ) == 0 ) {
                        Flags.do_cvpack = 1;
                        DebugFlag = 4;
                    } else if( strcmp( Word, "d" ) == 0 ) {
                        DebugFlag = 5;
                    }
                    break;
                case 's':
                    if( IsOption( cmd, len + sizeof( char ), "SYntax" ) ) {
                        Flags.no_link = 1;
                    }
                    break;
#if _CPU == 8086
                case 'w':
                    if( IsOption( cmd, len + sizeof( char ), "WIndows" ) ) {
                        Flags.windows = 1;
                    }
                    break;
#endif
                default:
                    break;
                }
                // don't add linker-specific options to compiler command line
                if( cmp_option != 0 ) {
                    len = strlen( CmpOpts );
                    CmpOpts[len++] = ' ';
                    CmpOpts[len++] = opt;
                    CmpOpts[len++] = *cmd;      // keep original case
                    CmpOpts[len] = '\0';
                    strcat( CmpOpts, Word );
                }
            }
            cmd = end;
        }
        cmd = SkipSpaces( cmd );
    } while( *cmd != '\0' );
    return( 0 );
}
Exemple #12
0
int ReadSettings(ONScripterLabel *pOns, const char *file)
{
	FILE *fp;
	char key[256];
	char value[256];
	int rt;
	//FILE *fp2;

#if defined(PSP)
	int value_int;

	putenv("SDL_ASPECT_RATIO=4:3");
#endif

	fp = fopen(file,"rt");
	//fp2 = fopen("setting.log","wb");
	if (!fp) return -1;
	
	while (!feof(fp))
	{
		rt = fscanf(fp, "%[^=\n]=%[^=\n]\n", key, value);
		if (rt==0 || rt==EOF) break;
		//fprintf(fp2, "KEY=%s, VALUE=%s\n", key, value);

		if (!stricmp(key, "FONT"))
		{
			pOns->setFontFile(value);
		}
		else if (!stricmp(key, "registry"))
		{
			pOns->setRegistryFile(value);
		}
		else if (!stricmp(key, "dll"))
		{
			pOns->setDLLFile(value);
		}
		else if (!stricmp(key, "root"))
		{
			pOns->setArchivePath(value);
		}
		else if (!stricmp(key, "fullscreen"))
		{
			if (!stricmp(value, "yes"))
				pOns->setFullscreenMode();
			else if (!stricmp(value, "no"))
				pOns->setWindowMode();
		}
			
#if defined(PSP)
		if (!stricmp(key, "RESOLUTION"))
		{
			value_int = atoi(value);
			if (value_int > 0 && value_int <= 360) os_screen_width=value_int;
		}
		else if (!stricmp(key, "SCREENSIZE"))
		{
			if (!stricmp(value,"NORMAL"))
			{
				putenv("SDL_ASPECT_RATIO=4:3");
			}
			else if (!stricmp(value,"FULL"))
			{
				putenv("SDL_ASPECT_RATIO=");
			}
		}
		else if (!stricmp(key, "CPUCLOCK"))
		{
			value_int = atoi(value);
			if (value_int > 0 && value_int <= 333)
				scePowerSetCpuClockFrequency(value_int);
		}
		else if (!stricmp(key, "BUSCLOCK"))
		{
			value_int = atoi(value);
			if (value_int > 0 && value_int <= 167)
				scePowerSetBusClockFrequency(value_int);
		}
		
		else if (!stricmp(key, "LMB_ONCE"))
		{
			MapButton(SDLK_SPACE, value);
		}
		else if (!stricmp(key, "LMB"))
		{
			MapButton(SDLK_RETURN, value);
		}
		else if (!stricmp(key, "RMB"))
		{
			MapButton(SDLK_ESCAPE, value);
		}
		else if (!stricmp(key, "CURSOR_PREV"))
		{
			MapButton(SDLK_UP ,value);
		}
		else if (!stricmp(key, "CURSOR_NEXT"))
		{
			MapButton(SDLK_DOWN, value);
		}
		else if (!stricmp(key, "SKIP"))
		{
			MapButton(SDLK_s, value);
		}
		else if (!stricmp(key, "PAGEFLIP"))
		{
			MapButton(SDLK_o, value);
		}
		else if (!stricmp(key, "MEM_UP"))
		{
			MapButton(SDLK_LEFT, value);
		}
		else if (!stricmp(key, "MEM_DOWN"))
		{
			MapButton(SDLK_RIGHT, value);
		}
		else if (!stricmp(key, "SKIPMODE"))
		{
			MapButton(SDLK_s, value);
		}
		else if (!stricmp(key, "AUTOMODE"))
		{
			MapButton(SDLK_a, value);
		}
		else if (!stricmp(key, "SPEED"))
		{
			MapButton(SDLK_0, value);
		}
		else if (!stricmp(key, "NONE"))
		{
			MapButton(SDLK_UNKNOWN, value);
		}
#endif
	}
	
	fclose(fp);
	//fclose(fp2);
	return 0;
}
Exemple #13
0
Tutorial::Tutorial( int _startChapter )
:   m_currentChapter(-1),
    m_nextChapter(-1),
    m_nextChapterTimer(0.0f),
    m_objectHighlight(-1),    
    m_miscTimer(-1.0f),
    m_worldInitialised(false),
    m_startLevel(_startChapter)
{
    m_levelName[0] = '\x0';
    SetCurrentLevel(1);
    
    //
    // Parse the tutorial data file

    TextReader *reader = g_fileSystem->GetTextReader( "data/tutorial.txt" );
    AppAssert( reader && reader->IsOpen() );
    
    while( reader->ReadLine() )
    {
        if( !reader->TokenAvailable() ) continue;
        char *chapterHeading = reader->GetNextToken();
        AppAssert( stricmp( chapterHeading, "CHAPTER" ) == 0 );
        
        TutorialChapter *chapter = new TutorialChapter();
        m_chapters.PutData( chapter );

        chapter->m_name = strdup( reader->GetNextToken() );
        char temp[256];
        sprintf( temp, "tutorial_%s", chapter->m_name );
        chapter->m_message = strdup( temp );
        sprintf( temp, "tutorial_%s_obj", chapter->m_name );
        chapter->m_objective = strdup( temp );


        while( reader->ReadLine() )
        {
            if( !reader->TokenAvailable() ) continue;
            char *field = reader->GetNextToken();
            if( stricmp( field, "END" ) == 0 )      break;

            char *value = reader->GetRestOfLine();     
            if( value ) value[ strlen(value) - 1 ] = '\x0';
        
            if( stricmp( field, "MESSAGE" ) == 0 )              chapter->m_message = strdup(value);
            if( stricmp( field, "OBJECTIVE" ) == 0 )            chapter->m_objective = strdup(value);
            if( stricmp( field, "WINDOWHIGHLIGHT" ) == 0 )      chapter->m_windowHighlight = strdup(value);
            if( stricmp( field, "BUTTONHIGHLIGHT" ) == 0 )      chapter->m_buttonHighlight = strdup(value);
            
            if( stricmp( field, "NEXTCLICKABLE" ) == 0 )        
            {
                chapter->m_nextClickable = true;
                chapter->m_objective = strdup( "tutorial_clicknext" );
            }

            if( stricmp( field, "RESTARTCLICKABLE" ) == 0 )
            {
                chapter->m_restartClickable = true;
                chapter->m_objective = strdup("tutorial_restart_mission");
            }
        }
    }
}
Exemple #14
0
/*----------------------------------------------------------------------
  Parameters:

  Description:
  ----------------------------------------------------------------------*/
static int
get_option(int argc, char *argv[])
{
  int  nargs = 0 ;
  char *option ;
  
  option = argv[1] + 1 ;            /* past '-' */
  if (!stricmp(option, "dt"))
    {
    }
  else if (!stricmp(option, "debug_voxel"))
    {
      Gx = atoi(argv[2]) ; Gy = atoi(argv[3]) ; Gz = atoi(argv[4]) ;
      nargs = 3 ;
      printf("debugging voxel (%d, %d, %d)\n", Gx, Gy, Gz) ;
    }
  else if (!stricmp(option, "remove"))
    {
      lta = LTAread(argv[2]) ;
      if (lta == NULL)
	ErrorExit(ERROR_NOFILE, "%s: could not read transform from %s\n", Progname, argv[2]) ;
      printf("removing determinant of transform %s\n", argv[2]) ;
      nargs = 1 ;
    }
  else if (!stricmp(option, "tm3d"))
    {
      tm3dfile = 1;
      printf("The input morph originated from a tm3d (mri_cvs_register file).\n") ;
    }
  else switch (toupper(*option))
    {
    case 'A':
      atlas = 1 ;
      printf("outputing in atlas coords\n") ;
      break ;
    case 'W':
      write_areas = 1 ;
      printf("writing area volumes\n") ;
      break ;
    case 'L':
      use_log = 1 ;
      printf("taking log of jacobian values before saving\n") ;
      break ;
    case 'S':
      sigma = atof(argv[2]) ;
      printf("smoothing jacobian volume with sigma=%2.2f\n", sigma) ;
      nargs = 1 ;
      break ;
    case 'Z':
      zero_mean = 1 ;
      use_log = 1 ;
      printf("making log jacobian zero mean\n") ;
      break ;
    case '?':
    case 'U':
      usage_exit(0) ;
      break ;
    default:
      fprintf(stderr, "unknown option %s\n", argv[1]) ;
      exit(1) ;
      break ;
    }
  
  return(nargs) ;
}
Exemple #15
0
static void ExportImagesFromDictionary(
    rw::TexDictionary *texDict, CFileTranslator *outputRoot,
    const filePath& txdFileName, const filePath& relPathFromRoot,
    MassExportModule::eOutputType outputType,
    const std::string& imgFormat
)
{
    rw::Interface *rwEngine = texDict->GetEngine();

    for ( rw::TexDictionary::texIter_t iter( texDict->GetTextureIterator() ); !iter.IsEnd(); iter.Increment() )
    {
        rw::TextureBase *texHandle = iter.Resolve();

        if ( rw::Raster *texRaster = texHandle->GetRaster() )
        {
            // Construct the target filename.
            filePath targetFileName = relPathFromRoot;

            if ( outputType == MassExportModule::OUTPUT_PLAIN )
            {
                // We are a plain path, which is just the texture name appended.
            }
            else if ( outputType == MassExportModule::OUTPUT_TXDNAME )
            {
                // Also put the TexDictionary name before it.
                targetFileName += txdFileName;
                targetFileName += "_";
            }
            else if ( outputType == MassExportModule::OUTPUT_FOLDERS )
            {
                // Instead put it inside folders.
                targetFileName += txdFileName;
                targetFileName += "/";
            }
        
            targetFileName += texHandle->GetName();
            targetFileName += ".";
            
            std::string lower_ext = imgFormat;
            std::transform( lower_ext.begin(), lower_ext.end(), lower_ext.begin(), ::tolower );

            targetFileName += lower_ext;

            // Create the target stream.
            CFile *targetStream = outputRoot->Open( targetFileName, "wb" );

            if ( targetStream )
            {
                try
                {
                    rw::Stream *rwStream = RwStreamCreateTranslated( rwEngine, targetStream );

                    if ( rwStream )
                    {
                        try
                        {
                            // Write it!
                            try
                            {
                                if ( stricmp( imgFormat.c_str(), "RWTEX" ) == 0 )
                                {
                                    rwEngine->Serialize( texHandle, rwStream );
                                }
                                else
                                {
                                    texRaster->writeImage( rwStream, imgFormat.c_str() );
                                }
                            }
                            catch( rw::RwException& )
                            {
                                // If we failed to write it, just live with it.
                            }
                        }
                        catch( ... )
                        {
                            rwEngine->DeleteStream( rwStream );

                            throw;
                        }

                        rwEngine->DeleteStream( rwStream );
                    }
                }
                catch( ... )
                {
                    delete targetStream;

                    throw;
                }

                delete targetStream;
            }
        }
    }
}
Exemple #16
0
/*
==============
GetToken
==============
*/
qboolean GetToken (qboolean crossline)
{
    char    *token_p;

    if (tokenready)                         // is a token allready waiting?
    {
        tokenready = false;
        return true;
    }

    // printf("script_p %x (%x)\n", script->script_p, script->end_p ); fflush( stdout );

    if (script->script_p >= script->end_p)
    {
        return EndOfScript (crossline);
    }

    tokenready = false;

    // skip space, ctrl chars
skipspace:
    while (*script->script_p <= 32)
    {
        if (script->script_p >= script->end_p)
        {
            return EndOfScript (crossline);
        }
        if (*(script->script_p++) == '\n')
        {
            if (!crossline)
            {
                Error ("Line %i is incomplete\n",scriptline);
            }
            scriptline = ++script->line;
        }
    }

    if (script->script_p >= script->end_p)
    {
        return EndOfScript (crossline);
    }

    // strip single line comments
    if (*script->script_p == ';' || *script->script_p == '#' ||		 // semicolon and # is comment field
            (*script->script_p == '/' && *((script->script_p)+1) == '/')) // also make // a comment field
    {
        if (!crossline)
            Error ("Line %i is incomplete\n",scriptline);
        while (*script->script_p++ != '\n')
        {
            if (script->script_p >= script->end_p)
            {
                return EndOfScript (crossline);
            }
        }
        scriptline = ++script->line;
        goto skipspace;
    }

    //  strip out matching /* */ comments
    if (*script->script_p == '/' && *((script->script_p)+1) == '*')
    {
        script->script_p += 2;
        while (*script->script_p != '*' || *((script->script_p)+1) != '/')
        {
            if (*script->script_p++ != '\n')
            {
                if (script->script_p >= script->end_p)
                {
                    return EndOfScript (crossline);
                }

                scriptline = ++script->line;
            }
        }
        script->script_p += 2;
        goto skipspace;
    }

    // copy token to buffer
    token_p = token;

    if (*script->script_p == '"')
    {
        // quoted token
        script->script_p++;
        while (*script->script_p != '"')
        {
            *token_p++ = *script->script_p++;
            if (script->script_p == script->end_p)
                break;
            if (token_p == &token[MAXTOKEN])
                Error ("Token too large on line %i\n",scriptline);
        }
        script->script_p++;
    }
    else	// regular token
        while ( *script->script_p > 32 && *script->script_p != ';')
        {
            if ( !ExpandMacroToken( token_p ) )
            {
                if ( !ExpandVariableToken( token_p ) )
                {
                    *token_p++ = *script->script_p++;
                    if (script->script_p == script->end_p)
                        break;
                    if (token_p == &token[MAXTOKEN])
                        Error ("Token too large on line %i\n",scriptline);

                }
            }
        }

    // add null to end of token
    *token_p = 0;

    // check for other commands
    if (!stricmp (token, "$include"))
    {
        GetToken (false);
        AddScriptToStack (token);
        return GetToken (crossline);
    }
    else if (!stricmp (token, "$definemacro"))
    {
        GetToken (false);
        DefineMacro(token);
        return GetToken (crossline);
    }
    else if (!stricmp (token, "$definevariable"))
    {
        GetToken (false);
        DefineVariable(token);
        return GetToken (crossline);
    }
    else if (AddMacroToStack( token ))
    {
        return GetToken (crossline);
    }

    return true;
}
Exemple #17
0
int strcasecmp(const char* s1, const char* s2)
{
    return stricmp(s1, s2);
}
Exemple #18
0
/*
==============
GetExprToken - use C mathematical operator parsing rules to split tokens instead of whitespace
==============
*/
qboolean GetExprToken (qboolean crossline)
{
    char    *token_p;

    if (tokenready)                         // is a token allready waiting?
    {
        tokenready = false;
        return true;
    }

    if (script->script_p >= script->end_p)
        return EndOfScript (crossline);

    tokenready = false;

//
// skip space
//
skipspace:
    while (*script->script_p <= 32)
    {
        if (script->script_p >= script->end_p)
            return EndOfScript (crossline);
        if (*script->script_p++ == '\n')
        {
            if (!crossline)
                Error ("Line %i is incomplete\n",scriptline);
            scriptline = ++script->line;
        }
    }

    if (script->script_p >= script->end_p)
        return EndOfScript (crossline);

    if (*script->script_p == ';' || *script->script_p == '#' ||		 // semicolon and # is comment field
            (*script->script_p == '/' && *((script->script_p)+1) == '/')) // also make // a comment field
    {
        if (!crossline)
            Error ("Line %i is incomplete\n",scriptline);
        while (*script->script_p++ != '\n')
            if (script->script_p >= script->end_p)
                return EndOfScript (crossline);
        goto skipspace;
    }

//
// copy token
//
    token_p = token;

    if (*script->script_p == '"')
    {
        // quoted token
        script->script_p++;
        while (*script->script_p != '"')
        {
            *token_p++ = *script->script_p++;
            if (script->script_p == script->end_p)
                break;
            if (token_p == &token[MAXTOKEN])
                Error ("Token too large on line %i\n",scriptline);
        }
        script->script_p++;
    }
    else
    {
        if ( isalpha( *script->script_p ) || *script->script_p == '_' )
        {
            // regular token
            while ( isalnum( *script->script_p ) || *script->script_p == '_' )
            {
                *token_p++ = *script->script_p++;
                if (script->script_p == script->end_p)
                    break;
                if (token_p == &token[MAXTOKEN])
                    Error ("Token too large on line %i\n",scriptline);
            }
        }
        else if ( isdigit( *script->script_p ) || *script->script_p == '.' )
        {
            // regular token
            while ( isdigit( *script->script_p ) || *script->script_p == '.' )
            {
                *token_p++ = *script->script_p++;
                if (script->script_p == script->end_p)
                    break;
                if (token_p == &token[MAXTOKEN])
                    Error ("Token too large on line %i\n",scriptline);
            }
        }
        else
        {
            // single char
            *token_p++ = *script->script_p++;
        }
    }

    *token_p = 0;

    if (!stricmp (token, "$include"))
    {
        GetToken (false);
        AddScriptToStack (token);
        return GetToken (crossline);
    }

    return true;
}
Exemple #19
0
//// HOST_SAY
// String comes in as
// say blah blah blah
// or as
// blah blah blah
//
void Host_Say( edict_t *pEntity, int teamonly )
{
	CBasePlayer *client;
	int		j;
	char	*p;
	char	text[128];
	char    szTemp[256];
	const char *cpSay = "say";
	const char *cpSayTeam = "say_team";
	const char *pcmd = CMD_ARGV(0);

	// We can get a raw string now, without the "say " prepended
	if ( CMD_ARGC() == 0 )
		return;

	entvars_t *pev = &pEntity->v;
	CBasePlayer* player = GetClassPtr((CBasePlayer *)pev);

	//Not yet.
	if ( player->m_flNextChatTime > gpGlobals->time )
		 return;

	if ( !stricmp( pcmd, cpSay) || !stricmp( pcmd, cpSayTeam ) )
	{
		if ( CMD_ARGC() >= 2 )
		{
			p = (char *)CMD_ARGS();
		}
		else
		{
			// say with a blank message, nothing to do
			return;
		}
	}
	else  // Raw text, need to prepend argv[0]
	{
		if ( CMD_ARGC() >= 2 )
		{
			sprintf( szTemp, "%s %s", ( char * )pcmd, (char *)CMD_ARGS() );
		}
		else
		{
			// Just a one word command, use the first word...sigh
			sprintf( szTemp, "%s", ( char * )pcmd );
		}
		p = szTemp;
	}

// remove quotes if present
	if (*p == '"')
	{
		p++;
		p[strlen(p)-1] = 0;
	}

// make sure the text has content
	char *pc = NULL;
	for ( pc = p; pc != NULL && *pc != 0; pc++ )
	{
		if ( isprint( *pc ) && !isspace( *pc ) )
		{
			pc = NULL;	// we've found an alphanumeric character,  so text is valid
			break;
		}
	}
	if ( pc != NULL )
		return;  // no character found, so say nothing

// turn on color set 2  (color on,  no sound)
	if ( teamonly )
		sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) );
	else
		sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) );

	j = sizeof(text) - 2 - strlen(text);  // -2 for /n and null terminator
	if ( (int)strlen(p) > j )
		p[j] = 0;

	strcat( text, p );
	strcat( text, "\n" );


	player->m_flNextChatTime = gpGlobals->time + CHAT_INTERVAL;

	// loop through all players
	// Start with the first player.
	// This may return the world in single player if the client types something between levels or during spawn
	// so check it, or it will infinite loop

	client = NULL;
	while ( ((client = (CBasePlayer*)UTIL_FindEntityByClassname( client, "player" )) != NULL) && (!FNullEnt(client->edict())) ) 
	{
		if ( !client->pev )
			continue;
		
		if ( client->edict() == pEntity )
			continue;

		if ( !(client->IsNetClient()) )	// Not a client ? (should never be true)
			continue;

		// can the receiver hear the sender? or has he muted him?
		if ( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) )
			continue;

		if ( teamonly && g_pGameRules->PlayerRelationship(client, CBaseEntity::Instance(pEntity)) != GR_TEAMMATE )
			continue;

		MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev );
			WRITE_BYTE( ENTINDEX(pEntity) );
			WRITE_STRING( text );
		MESSAGE_END();

	}

	// print to the sending client
	MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, &pEntity->v );
		WRITE_BYTE( ENTINDEX(pEntity) );
		WRITE_STRING( text );
	MESSAGE_END();

	// echo to server console
	g_engfuncs.pfnServerPrint( text );

	char * temp;
	if ( teamonly )
		temp = "say_team";
	else
		temp = "say";
	
	// team match?
	if ( g_teamplay )
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%s>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( pEntity ), "model" ),
			temp,
			p );
	}
	else
	{
		UTIL_LogPrintf( "\"%s<%i><%s><%i>\" %s \"%s\"\n", 
			STRING( pEntity->v.netname ), 
			GETPLAYERUSERID( pEntity ),
			GETPLAYERAUTHID( pEntity ),
			GETPLAYERUSERID( pEntity ),
			temp,
			p );
	}
}
Exemple #20
0
//-----------------------------------------------------------------------------
// Purpose: Get list of files from current path that match pattern
//-----------------------------------------------------------------------------
int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVector< fileList_t > &fileList )
{
    char	sourcePath[MAX_PATH];
    char	fullPath[MAX_PATH];
    bool	bFindDirs;

    fileList.Purge();

    strcpy( sourcePath, pDirPath );
    int len = (int)strlen( sourcePath );
    if ( !len )
    {
        strcpy( sourcePath, ".\\" );
    }
    else if ( sourcePath[len-1] != '\\' )
    {
        sourcePath[len]   = '\\';
        sourcePath[len+1] = '\0';
    }

    strcpy( fullPath, sourcePath );
    if ( pPattern[0] == '\\' && pPattern[1] == '\0' )
    {
        // find directories only
        bFindDirs = true;
        strcat( fullPath, "*" );
    }
    else
    {
        // find files, use provided pattern
        bFindDirs = false;
        strcat( fullPath, pPattern );
    }

    struct _finddata_t findData;
    intptr_t h = _findfirst( fullPath, &findData );
    if ( h == -1 )
    {
        return 0;
    }

    do
    {
        // dos attribute complexities i.e. _A_NORMAL is 0
        if ( bFindDirs )
        {
            // skip non dirs
            if ( !( findData.attrib & _A_SUBDIR ) )
                continue;
        }
        else
        {
            // skip dirs
            if ( findData.attrib & _A_SUBDIR )
                continue;
        }

        if ( !stricmp( findData.name, "." ) )
            continue;

        if ( !stricmp( findData.name, ".." ) )
            continue;

        char fileName[MAX_PATH];
        strcpy( fileName, sourcePath );
        strcat( fileName, findData.name );

        int j = fileList.AddToTail();
        fileList[j].fileName.Set( fileName );
        fileList[j].timeWrite = findData.time_write;
    }
    while ( !_findnext( h, &findData ) );

    _findclose( h );

    return fileList.Count();
}
Exemple #21
0
void CVideoInfoTag::ParseNative(const TiXmlElement* movie, bool prioritise)
{
  std::string value;

  if (XMLUtils::GetString(movie, "title", value))
    SetTitle(value);

  if (XMLUtils::GetString(movie, "originaltitle", value))
    SetOriginalTitle(value);

  if (XMLUtils::GetString(movie, "showtitle", value))
    SetShowTitle(value);

  if (XMLUtils::GetString(movie, "sorttitle", value))
    SetSortTitle(value);

  const TiXmlElement* node = movie->FirstChildElement("ratings");
  if (node)
  {
    for (const TiXmlElement* child = node->FirstChildElement("rating"); child != nullptr; child = child->NextSiblingElement("rating"))
    {
      CRating r;
      std::string name;
      if (child->QueryStringAttribute("name", &name) != TIXML_SUCCESS)
        name = "default";
      XMLUtils::GetFloat(child, "value", r.rating);
      XMLUtils::GetInt(child, "votes", r.votes);
      int max_value = 10;
      if ((child->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
        r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10
      AddRating(r, name);
      bool isDefault = false;
      if ((child->QueryBoolAttribute("default", &isDefault) == TIXML_SUCCESS) && isDefault)
        m_strDefaultRating = name;
    }
  }
  else
  {
    CRating r;
    XMLUtils::GetFloat(movie, "rating", r.rating);
    if (XMLUtils::GetString(movie, "votes", value))
      r.votes = StringUtils::ReturnDigits(value);
    int max_value = 10;
    const TiXmlElement* rElement = movie->FirstChildElement("rating");
    if (rElement && (rElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
      r.rating = r.rating / max_value * 10; // Normalise the Movie Rating to between 1 and 10
    AddRating(r, "default");
    m_strDefaultRating = "default";
  }
  XMLUtils::GetInt(movie, "userrating", m_iUserRating);
  XMLUtils::GetFloat(movie, "epbookmark", m_fEpBookmark);
  int max_value = 10;
  const TiXmlElement* urElement = movie->FirstChildElement("userrating");
  if (urElement && (urElement->QueryIntAttribute("max", &max_value) == TIXML_SUCCESS) && max_value >= 1)
    m_iUserRating = m_iUserRating / max_value * 10; // Normalise the user Movie Rating to between 1 and 10
  XMLUtils::GetInt(movie, "year", m_iYear);
  XMLUtils::GetInt(movie, "top250", m_iTop250);
  XMLUtils::GetInt(movie, "season", m_iSeason);
  XMLUtils::GetInt(movie, "episode", m_iEpisode);
  XMLUtils::GetInt(movie, "track", m_iTrack);
  if (XMLUtils::GetString(movie, "uniqueid", value))
    SetUniqueId(value);

  XMLUtils::GetInt(movie, "displayseason", m_iSpecialSortSeason);
  XMLUtils::GetInt(movie, "displayepisode", m_iSpecialSortEpisode);
  int after=0;
  XMLUtils::GetInt(movie, "displayafterseason",after);
  if (after > 0)
  {
    m_iSpecialSortSeason = after;
    m_iSpecialSortEpisode = 0x1000; // should be more than any realistic episode number
  }

  if (XMLUtils::GetString(movie, "outline", value))
    SetPlotOutline(value);

  if (XMLUtils::GetString(movie, "plot", value))
    SetPlot(value);

  if (XMLUtils::GetString(movie, "tagline", value))
    SetTagLine(value);

  
  if (XMLUtils::GetString(movie, "runtime", value) && !value.empty())
    m_duration = GetDurationFromMinuteString(StringUtils::Trim(value));
  
  if (XMLUtils::GetString(movie, "mpaa", value))
    SetMPAARating(value);

  XMLUtils::GetInt(movie, "playcount", m_playCount);
  XMLUtils::GetDate(movie, "lastplayed", m_lastPlayed);
  
  if (XMLUtils::GetString(movie, "file", value))
    SetFile(value);

  if (XMLUtils::GetString(movie, "path", value))
    SetPath(value);

  if (XMLUtils::GetString(movie, "id", value))
    SetIMDBNumber(value);

  if (XMLUtils::GetString(movie, "filenameandpath", value))
    SetFileNameAndPath(value);

  XMLUtils::GetDate(movie, "premiered", m_premiered);
  
  if (XMLUtils::GetString(movie, "status", value))
    SetStatus(value);

  if (XMLUtils::GetString(movie, "code", value))
    SetProductionCode(value);

  XMLUtils::GetDate(movie, "aired", m_firstAired);
  
  if (XMLUtils::GetString(movie, "album", value))
    SetAlbum(value);

  if (XMLUtils::GetString(movie, "trailer", value))
    SetTrailer(value);

  if (XMLUtils::GetString(movie, "basepath", value))
    SetBasePath(value);

  size_t iThumbCount = m_strPictureURL.m_url.size();
  std::string xmlAdd = m_strPictureURL.m_xml;

  const TiXmlElement* thumb = movie->FirstChildElement("thumb");
  while (thumb)
  {
    m_strPictureURL.ParseElement(thumb);
    if (prioritise)
    {
      std::string temp;
      temp << *thumb;
      xmlAdd = temp+xmlAdd;
    }
    thumb = thumb->NextSiblingElement("thumb");
  }

  // prioritise thumbs from nfos
  if (prioritise && iThumbCount && iThumbCount != m_strPictureURL.m_url.size())
  {
    rotate(m_strPictureURL.m_url.begin(),
           m_strPictureURL.m_url.begin()+iThumbCount, 
           m_strPictureURL.m_url.end());
    m_strPictureURL.m_xml = xmlAdd;
  }

  std::vector<std::string> genres(m_genre);
  if (XMLUtils::GetStringArray(movie, "genre", genres, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetGenre(genres);

  std::vector<std::string> country(m_country);
  if (XMLUtils::GetStringArray(movie, "country", country, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetCountry(country);

  std::vector<std::string> credits(m_writingCredits);
  if (XMLUtils::GetStringArray(movie, "credits", credits, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetWritingCredits(credits);

  std::vector<std::string> director(m_director);
  if (XMLUtils::GetStringArray(movie, "director", director, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetDirector(director);

  std::vector<std::string> showLink(m_showLink);
  if (XMLUtils::GetStringArray(movie, "showlink", showLink, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetShowLink(showLink);

  const TiXmlElement* namedSeason = movie->FirstChildElement("namedseason");
  while (namedSeason != nullptr)
  {
    int seasonNumber;
    std::string seasonName = namedSeason->ValueStr();
    if (!seasonName.empty() &&
        namedSeason->Attribute("number", &seasonNumber) != nullptr)
      m_namedSeasons.insert(std::make_pair(seasonNumber, seasonName));

    namedSeason = thumb->NextSiblingElement("namedseason");
  }

  // cast
  node = movie->FirstChildElement("actor");
  if (node && node->FirstChild() && prioritise)
    m_cast.clear();
  while (node)
  {
    const TiXmlNode *actor = node->FirstChild("name");
    if (actor && actor->FirstChild())
    {
      SActorInfo info;
      info.strName = actor->FirstChild()->Value();
      
      if (XMLUtils::GetString(node, "role", value))
        info.strRole = StringUtils::Trim(value);
      
      XMLUtils::GetInt(node, "order", info.order);
      const TiXmlElement* thumb = node->FirstChildElement("thumb");
      while (thumb)
      {
        info.thumbUrl.ParseElement(thumb);
        thumb = thumb->NextSiblingElement("thumb");
      }
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true"))
        m_cast.clear();
      m_cast.push_back(info);
    }
    node = node->NextSiblingElement("actor");
  }

  // Pre-Jarvis NFO file:
  // <set>A set</set>
  if (XMLUtils::GetString(movie, "set", value))
    SetSet(value);
  // Jarvis+:
  // <set><name>A set</name><overview>A set with a number of movies...</overview></set>
  node = movie->FirstChildElement("set");
  if (node)
  {
    // No name, no set
    if (XMLUtils::GetString(node, "name", value))
    {
      SetSet(value);
      if (XMLUtils::GetString(node, "overview", value))
        SetSetOverview(value);
    }
  }

  std::vector<std::string> tags(m_tags);
  if (XMLUtils::GetStringArray(movie, "tag", tags, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetTags(tags);

  std::vector<std::string> studio(m_studio);
  if (XMLUtils::GetStringArray(movie, "studio", studio, prioritise, g_advancedSettings.m_videoItemSeparator))
    SetStudio(studio);

  // artists
  std::vector<std::string> artist(m_artist);
  node = movie->FirstChildElement("artist");
  if (node && node->FirstChild() && prioritise)
    artist.clear();
  while (node)
  {
    const TiXmlNode* pNode = node->FirstChild("name");
    const char* pValue=NULL;
    if (pNode && pNode->FirstChild())
      pValue = pNode->FirstChild()->Value();
    else if (node->FirstChild())
      pValue = node->FirstChild()->Value();
    if (pValue)
    {
      const char* clear=node->Attribute("clear");
      if (clear && stricmp(clear,"true")==0)
        artist.clear();
      std::vector<std::string> newArtists = StringUtils::Split(pValue, g_advancedSettings.m_videoItemSeparator);
      artist.insert(artist.end(), newArtists.begin(), newArtists.end());
    }
    node = node->NextSiblingElement("artist");
  }
  SetArtist(artist);

  node = movie->FirstChildElement("fileinfo");
  if (node)
  {
    // Try to pull from fileinfo/streamdetails/[video|audio|subtitle]
    const TiXmlNode *nodeStreamDetails = node->FirstChild("streamdetails");
    if (nodeStreamDetails)
    {
      const TiXmlNode *nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("audio", nodeDetail)))
      {
        CStreamDetailAudio *p = new CStreamDetailAudio();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);

        XMLUtils::GetInt(nodeDetail, "channels", p->m_iChannels);
        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("video", nodeDetail)))
      {
        CStreamDetailVideo *p = new CStreamDetailVideo();
        if (XMLUtils::GetString(nodeDetail, "codec", value))
          p->m_strCodec = StringUtils::Trim(value);

        XMLUtils::GetFloat(nodeDetail, "aspect", p->m_fAspect);
        XMLUtils::GetInt(nodeDetail, "width", p->m_iWidth);
        XMLUtils::GetInt(nodeDetail, "height", p->m_iHeight);
        XMLUtils::GetInt(nodeDetail, "durationinseconds", p->m_iDuration);
        if (XMLUtils::GetString(nodeDetail, "stereomode", value))
          p->m_strStereoMode = StringUtils::Trim(value);

        StringUtils::ToLower(p->m_strCodec);
        StringUtils::ToLower(p->m_strStereoMode);
        m_streamDetails.AddStream(p);
      }
      nodeDetail = NULL;
      while ((nodeDetail = nodeStreamDetails->IterateChildren("subtitle", nodeDetail)))
      {
        CStreamDetailSubtitle *p = new CStreamDetailSubtitle();
        if (XMLUtils::GetString(nodeDetail, "language", value))
          p->m_strLanguage = StringUtils::Trim(value);
        StringUtils::ToLower(p->m_strLanguage);
        m_streamDetails.AddStream(p);
      }
    }
    m_streamDetails.DetermineBestStreams();
  }  /* if fileinfo */

  const TiXmlElement *epguide = movie->FirstChildElement("episodeguide");
  if (epguide)
  {
    // DEPRECIATE ME - support for old XML-encoded <episodeguide> blocks.
    if (epguide->FirstChild() && strnicmp("<episodeguide", epguide->FirstChild()->Value(), 13) == 0)
      m_strEpisodeGuide = epguide->FirstChild()->Value();
    else
    {
      std::stringstream stream;
      stream << *epguide;
      m_strEpisodeGuide = stream.str();
    }
  }

  // fanart
  const TiXmlElement *fanart = movie->FirstChildElement("fanart");
  if (fanart)
  {
    // we prioritise mixed-mode nfo's with fanart set
    if (prioritise)
    {
      std::string temp;
      temp << *fanart;
      m_fanart.m_xml = temp+m_fanart.m_xml;
    }
    else
      m_fanart.m_xml << *fanart;
    m_fanart.Unpack();
  }

  // resumePoint
  const TiXmlNode *resume = movie->FirstChild("resume");
  if (resume)
  {
    XMLUtils::GetDouble(resume, "position", m_resumePoint.timeInSeconds);
    XMLUtils::GetDouble(resume, "total", m_resumePoint.totalTimeInSeconds);
  }

  XMLUtils::GetDateTime(movie, "dateadded", m_dateAdded);
}
// Note : This can't use CEditRegion::RenameTexture because that initializes the texture space.  Which we don't want.
// (It also counts the number of instances, which doesn't give nearly as much information...)
static void dcon_ReplaceTextures(int argc, char *argv[])
{
	if (argc < 2)
	{
		// Display an error.  Must have 2 arguments
		AddDebugMessage("Not enough texture arguments specified.  Please use the form:");
		AddDebugMessage("  ReplaceTex CurrentTexture NewTexture");
		return;
	}

	// Get the current region
	CRegionDoc  *pDoc = GetActiveRegionDoc();
	if (!pDoc)
	{
		AddDebugMessage("No active document available.");
		return;
	}

	CEditRegion *pRegion = pDoc->GetRegion();
	if (!pRegion)
	{
		AddDebugMessage("No active region available.");
		return;
	}

	// Tell the user what we're doing..
	AddDebugMessage("Searching %d brushes for replacement...", pRegion->m_Brushes.GetSize());

	// Keep track of the replacement count
	uint32 nReplaceCount = 0;

	// Point into the brush list
	LPOS iPos = pRegion->m_Brushes.GetHeadPosition();

	// Replace textures on all brush matching argv[0] with argv[1]
	while (iPos)
	{
		// Get the brush
		CEditBrush *pBrush = pRegion->m_Brushes.GetNext(iPos);

		// Did we find a match on this brush?
		bool bFoundMatch = false;

		// For every polygon..
		for (uint32 nPolyLoop = 0; nPolyLoop < pBrush->m_Polies; ++nPolyLoop)
		{
			CEditPoly *pPoly = pBrush->m_Polies[nPolyLoop];

			for(uint32 nCurrTex = 0; nCurrTex < CEditPoly::NUM_TEXTURES; nCurrTex++)
			{
				// Is this your texture?
				if (stricmp(pPoly->GetTexture(nCurrTex).m_pTextureName, argv[0]) == 0)
				{
					// Replace it...
					pPoly->GetTexture(nCurrTex).m_pTextureName = pRegion->m_pStringHolder->AddString(argv[1]);
					pPoly->GetTexture(nCurrTex).UpdateTextureID();

					// Found a match..
					bFoundMatch = true;
				}
			}
		}

		if (bFoundMatch)
			++nReplaceCount;
	}

	// And the results were...?
	AddDebugMessage("Done.  Replaced texture on %d brushes", nReplaceCount);

	// Redraw the region & mark it as changed if necessary
	if (nReplaceCount)
	{
		pDoc->Modify();
		pDoc->RedrawAllViews();
	}
}
Exemple #23
0
void CmdStartup(int iSignal)
{
    bool bLoop = true, bEnvUser = false;
    int cRead = 0, cCMD = 0, cOPT = 0, iEnvPos = 0, iEnvLen = 0;
    unsigned char szEnv[50];

    debug(DEBUGLEVEL_INFO, "CmdStartup entry %d\n", iSignal);

    printf("%c%c%c%c%c%c%c%c%c", IAC, WILL, TELOPT_ECHO, IAC, WILL, TELOPT_SGA, IAC, DO, TELOPT_NEW_ENVIRON);
    fflush(stdout);

    while(bLoop == true)
    {
        cRead = CmdInputGet();
        debug(DEBUGLEVEL_DEBUG, "CmdStartup read %d, length %d\n", cRead, CmdInputLen());

        if(cRead == IAC && CmdInputLen() >= 2)
        {
            debug(DEBUGLEVEL_DEBUG, "CmdStartup IAC (%d more chars)", CmdInputLen(), cRead);
            cCMD = CmdInputGet();
            cOPT = CmdInputGet();
            debug(DEBUGLEVEL_DEBUG, " [%d][%d]\n", cCMD, cOPT);

            if(cCMD == WILL && cOPT == TELOPT_NEW_ENVIRON)
            {
                iEnvLen = 0;

                szEnv[iEnvLen++] = IAC;
                szEnv[iEnvLen++] = SB;
                szEnv[iEnvLen++] = TELOPT_NEW_ENVIRON;
                szEnv[iEnvLen++] = TELQUAL_SEND;

                iEnvLen = CmdStartupEnv(szEnv, iEnvLen, NEW_ENV_VAR, "USER");
                iEnvLen = CmdStartupEnv(szEnv, iEnvLen, ENV_USERVAR, "TERM");
                // iEnvLen = CmdStartupEnv(szEnv, iEnvLen, ENV_USERVAR, "COLUMNS");
                // iEnvLen = CmdStartupEnv(szEnv, iEnvLen, ENV_USERVAR, "LINES");

                szEnv[iEnvLen++] = IAC;
                szEnv[iEnvLen++] = SE;

                debug(DEBUGLEVEL_DEBUG, "CmdStartup env request: ");
                for(iEnvPos = 0; iEnvPos < iEnvLen; iEnvPos++)
                {
                    if(isalnum(szEnv[iEnvPos]))
                    {
                        debug(DEBUGLEVEL_DEBUG, "%c", szEnv[iEnvPos]);
                    }
                    else
                    {
                        debug(DEBUGLEVEL_DEBUG, "[%d]", szEnv[iEnvPos]);
                    }
                }
                debug(DEBUGLEVEL_DEBUG, "\n");

                fwrite(szEnv, sizeof(char), iEnvLen, stdout);
                fflush(stdout);

                // sleep(2);
            }
            else if(cCMD == SB && cOPT == TELOPT_NEW_ENVIRON)
            {
                debug(DEBUGLEVEL_DEBUG, "CmdStartup env settings\n");

                cRead = CmdInputGet();
                if(cRead == TELQUAL_IS)
                {
                    iEnvPos = 0;
                    do
                    {
                        cRead = CmdInputGet();
                        if(cRead == IAC || cRead == NEW_ENV_VAR || cRead == ENV_USERVAR)
                        {
                            if(iEnvPos > 0)
                            {
                                szEnv[iEnvPos] = '\0';
                                debug(DEBUGLEVEL_DEBUG, ", value '%s'\n", szEnv);

                                if(bEnvUser == true)
                                {
                                    g_szEnvUser = strmk((char *)szEnv);
                                    bEnvUser = false;
                                }
                            }

                            // debug("CmdStartup env setting reset\n");
                            iEnvPos = 0;
                        }
                        else if(cRead == NEW_ENV_VALUE)
                        {
                            if(iEnvPos > 0)
                            {
                                szEnv[iEnvPos] = '\0';
                                debug(DEBUGLEVEL_DEBUG, "CmdStartup env '%s'", szEnv);

                                if(stricmp((char *)szEnv, "USER") == 0)
                                {
                                    bEnvUser = true;
                                }
                            }

                            iEnvPos = 0;
                        }
                        else if(cRead == IAC)
                        {
                            cRead = CmdInputGet();
                            if(cRead == SE)
                            {
                            }
                        }
                        else
                        {
                            szEnv[iEnvPos++] = cRead;
                        }
                    } while(cRead != SE && CmdInputLen() > 0);
                }
            }
        }
        else
        {
            bLoop = false;
        }
    }

    debug(DEBUGLEVEL_DEBUG, "CmdStartup %d chars in buffer\n", CmdInputLen());

    CmdWidth(80);
    CmdHeight(25);

    m_bStartup = false;

    debug(DEBUGLEVEL_INFO, "CmdStartup exit\n");
}
Exemple #24
0
static void M2TS_FlushRequested(M2TSIn *m2ts)
{
	u32 i, j, req_prog_count, count, prog_id, found;

	gf_mx_p(m2ts->mx);

	found = 0;
	count = gf_list_count(m2ts->ts->requested_pids);
	for (i=0; i<count; i++) {
		M2TSIn_Prog *req_pid = gf_list_get(m2ts->ts->requested_pids, i);
		GF_M2TS_ES *es = m2ts->ts->ess[req_pid->pid];
		if (es==NULL) continue;

		/*move to skip mode for all PES until asked for playback*/
		if (!(es->flags & GF_M2TS_ES_IS_SECTION) && !es->user)
			gf_m2ts_set_pes_framing((GF_M2TS_PES *)es, GF_M2TS_PES_FRAMING_SKIP);
		MP2TS_DeclareStream(m2ts, (GF_M2TS_PES *)es, NULL, 0);
		gf_list_rem(m2ts->ts->requested_pids, i);
		gf_free(req_pid);
		i--;
		count--;
		found++;
	}
	req_prog_count = gf_list_count(m2ts->ts->requested_progs);
	for (i = 0; i < req_prog_count; i++) {
		M2TSIn_Prog *req_prog = gf_list_get(m2ts->ts->requested_progs, i);
		prog_id = atoi(req_prog->fragment);
		count = gf_list_count(m2ts->ts->SDTs);
		for (j=0; j<count; j++) {
			GF_M2TS_SDT *sdt = gf_list_get(m2ts->ts->SDTs, j);
			if (!stricmp((const char *) sdt->service, req_prog->fragment)) req_prog->id = sdt->service_id;
			else if (sdt->service_id==prog_id)  req_prog->id = sdt->service_id;
		}
		if (req_prog->id) {
			GF_M2TS_Program *ts_prog;
			count = gf_list_count(m2ts->ts->programs);
			for (j=0; j<count; j++) {
				ts_prog = gf_list_get(m2ts->ts->programs, j);
				if (ts_prog->number==req_prog->id) {
					MP2TS_SetupProgram(m2ts, ts_prog, 0, 0);
					found++;
					gf_free(req_prog->fragment);
					gf_free(req_prog);
					gf_list_rem(m2ts->ts->requested_progs, i);
					req_prog_count--;
					i--;
					break;
				}
			}
		}
	}

	if (m2ts->epg_requested) {
		if (!m2ts->has_eit) {
			GF_ObjectDescriptor *od = M2TS_GenerateEPG_OD(m2ts);
			/*declare but don't regenerate scene*/
			gf_term_add_media(m2ts->service, (GF_Descriptor*)od, 0);
			m2ts->has_eit = 1;
		}
	} else {
		/*force scene regeneration only when EPG is not requested*/
		if (found)
			gf_term_add_media(m2ts->service, NULL, 0);
	}

	gf_mx_v(m2ts->mx);
}
Exemple #25
0
bool SString::EndsWithI(const SString& strOther) const
{
    return stricmp(Right((int)strOther.length()), strOther) == 0;
}
Exemple #26
0
LRESULT CBackEndDialog::OnActivateTask(WPARAM wParam, LPARAM lParam)
{
	//get the text
	char* pszTaskName = (char*)wParam;

	//track the old task
	CTask* pOldTask = m_pCurrTask;

	//run through the list and find the task
	CTask* pCurr = m_pHeadTask;

	while(pCurr)
	{
		if(stricmp(pszTaskName, pCurr->GetName()) == 0)
		{
			m_pCurrTask = pCurr;
			break;
		}
		pCurr = pCurr->GetNextTask();
	}

	//clean up the name now
	delete [] pszTaskName;
	pszTaskName = NULL;

	//see if we didn't find the task
	if(pCurr == NULL)
	{
		return false;
	}

	//set the active task name around the progress bar
	CStatic* pTaskName = (CStatic*)GetDlgItem(IDC_STATIC_TASK_NAME);
	CString sText;
	sText.Format("Task: %s", (m_pCurrTask) ? m_pCurrTask->GetName() : "None");
	((CStatic*)GetDlgItem(IDC_STATIC_TASK_NAME))->SetWindowText(sText);

	//also update the progress bar to reflect the change
	SetTaskProgress((m_pCurrTask) ? m_pCurrTask->GetProgress() : 0.0f);

	//if the user was viewing the previous task, then we want to start viewing the new
	//task, the same goes for if the user isn't viewing any tasks
	CTask* pViewedTask = GetViewedTask();
	if((pOldTask == pViewedTask) || (pViewedTask == NULL))
	{
		//find this new task
		for(uint32 nCurrTask = 0; nCurrTask < (uint32)GetTaskList()->GetCount(); nCurrTask++)
		{
			if((CTask*)GetTaskList()->GetItemData(nCurrTask) == m_pCurrTask)
			{
				//this is a match, select it
				GetTaskList()->SetCurSel(nCurrTask);
				ResetMessageList();
				break;
			}
		}
	}

	//save this task as our current subtask
	m_sSubTaskName = (m_pCurrTask) ? m_pCurrTask->GetName() : "";

	//update the title bar
	UpdateTitleNonIconic();	
	
	
	return 0;
}
Exemple #27
0
void CSoundMng::LoadSoundConfig( char* filename )
{
	char* token;
	char soundName[128];
	int idx, is3D, dup, resType = 0, type, eventType, soundID;
	float fraction, freq;

	Initialize();

	g_script.Load( filename );
	g_script.BeginParse();

	m_maxIdx	=	0;

	while( 1 )
	{
		token = g_script.GetNextToken( true );
		if( token[0] == 0 ) break;

		if( !stricmp( token, "RESOURCE" ) ) resType = 0;
		if( !stricmp( token, "MATCHING" ) ) resType = 1;
		else if( token[0] == '{' )
		{
			while( 1 )
			{
				token = g_script.GetNextToken( true );
				if( token[0] == '}' ) break;

				
				if( !resType )
				{
					if( !stricmp( token, "NORMAL" ) ) type = 0;
					else if( !stricmp( token, "ITEM" ) ) type = 1;
					else if( !stricmp( token, "EVENT_IDLE" ) ) { type = 2; eventType = ANIM_ITEM_IDLE; }
					else if( !stricmp( token, "EVENT_DAMAGE" ) ) { type = 2; eventType = ANIM_ITEM_DEFENSE; }
					else if( !stricmp( token, "EVENT_DIE" ) ) { type = 2; eventType = ANIM_ITEM_DYING_0; }
					else if( !stricmp( token, "EVENT_WALK" ) ) { type = 2; eventType = ANIM_ITEM_WALK; }
					else if( !stricmp( token, "EVENT_RUN" ) ) { type = 2; eventType = ANIM_ITEM_RUN; }
					else if( !stricmp( token, "EVENT_ATTACK" ) ) { type = 2; eventType = ANIM_ITEM_ATTACK_0; }
					else if( !stricmp( token, "EVENT_SHOCK" ) ) { type = 2; eventType = ANIM_ITEM_ATTACKED_0; }
					else if( token[0] == '{' )
					{
						while( 1 )
						{
							token = g_script.GetNextToken( true );
							if( token[0] == '}' ) break;

							
							idx = atoi( token );
							
							token = g_script.GetNextToken( true );
							strcpy( soundName, token );
							
							token = g_script.GetNextToken( true );
							is3D = atoi( token );
							
							token = g_script.GetNextToken( true );
							dup = atoi( token );
							if( type == 0 )
							{
								m_soundResource.normalID[idx].idx = idx;
								strcpy( m_soundResource.normalID[idx].filename, soundName );
								m_soundResource.normalID[idx].is3D = is3D;
								m_soundResource.normalID[idx].numDup = dup;
								m_soundResource.numNoramlID ++;

								m_maxIdx ++;
							}
							else if( type == 1 )
							{
								m_soundResource.itemID[idx].idx = idx;
								strcpy( m_soundResource.itemID[idx].filename, soundName );
								m_soundResource.itemID[idx].is3D = is3D;
								m_soundResource.itemID[idx].numDup = dup;
								m_soundResource.numItemID ++;

								m_maxIdx ++;
							}
							else if( type == 2 )
							{
								m_soundResource.eventID[eventType][idx].idx = idx;
								strcpy( m_soundResource.eventID[eventType][idx].filename, soundName );
								m_soundResource.eventID[eventType][idx].is3D = is3D;
								m_soundResource.eventID[eventType][idx].numDup = dup;
								m_soundResource.numEventID[eventType] ++;

								m_maxIdx ++;
							}
						}
					}
				}
				else
				{
					if( !stricmp( token, "ITEM" ) ) type = 0;
					else if( !stricmp( token, "PC" ) ) type = 1;
					else if( !stricmp( token, "MONSTER" ) ) type = 2;
					else if( token[0] == '{' )
					{
						while( 1 )
						{
							token = g_script.GetNextToken( true );
							if( token[0] == '}' ) break;
							else if( type == 0 )
							{
								idx = atoi( token );
								
								token = g_script.GetNextToken( true );
								soundID = atoi( token );
								
								token = g_script.GetNextToken( true );
								fraction = atof( token );

								m_itemSound[idx].idx = idx;
								m_itemSound[idx].soundID = soundID;
								m_itemSound[idx].playTime = fraction;
							}
							else if( type == 1 )
							{
								if( !stricmp( token, "IDX" ) ) eventType = -1;
								else if( !stricmp( token, "IDLE" ) ) eventType = ANIM_ITEM_IDLE;
								else if( !stricmp( token, "WALK" ) ) eventType = ANIM_ITEM_WALK;
								else if( !stricmp( token, "RUN" ) ) eventType = ANIM_ITEM_RUN;
								else if( !stricmp( token, "DAMAGE" ) ) eventType = ANIM_ITEM_DEFENSE;
								else if( !stricmp( token, "ATTACK" ) ) eventType = ANIM_ITEM_ATTACK_0;
								else if( !stricmp( token, "SHOCK" ) ) eventType = ANIM_ITEM_ATTACKED_0;
								else if( !stricmp( token, "DIE" ) ) eventType = ANIM_ITEM_DYING_0;
								else if( eventType == -1 )
								{
									idx = atoi( token );
								}
								else
								{
									soundID = atoi( token );
								
									token = g_script.GetNextToken( true );
									fraction = atof( token );

									token = g_script.GetNextToken( true );
									freq = atoi( token );

									m_pcSound[idx].idx = idx;
									m_pcSound[idx].soundID[eventType] = soundID;
									m_pcSound[idx].playTime[eventType] = fraction;
									m_pcSound[idx].frequency[eventType] = freq;
								}
							}
							else if( type == 2 )
							{
								if( !stricmp( token, "IDX" ) ) eventType = -1;
								else if( !stricmp( token, "IDLE" ) ) eventType = ANIM_ITEM_IDLE;
								else if( !stricmp( token, "WALK" ) ) eventType = ANIM_ITEM_WALK;
								else if( !stricmp( token, "RUN" ) ) eventType = ANIM_ITEM_RUN;
								else if( !stricmp( token, "DAMAGE" ) ) eventType = ANIM_ITEM_DEFENSE;
								else if( !stricmp( token, "ATTACK" ) ) eventType = ANIM_ITEM_ATTACK_0;
								else if( !stricmp( token, "SHOCK" ) ) eventType = ANIM_ITEM_ATTACKED_0;
								else if( !stricmp( token, "DIE" ) ) eventType = ANIM_ITEM_DYING_0;
								else if( eventType == -1 )
								{
									idx = atoi( token );
								}
								else
								{
									soundID = atoi( token );
								
									token = g_script.GetNextToken( true );
									fraction = atof( token );

									token = g_script.GetNextToken( true );
									freq = atoi( token );

									m_monSound[idx].idx = idx;
									m_monSound[idx].soundID[eventType] = soundID;
									m_monSound[idx].playTime[eventType] = fraction;
									m_monSound[idx].frequency[eventType] = freq;
								}
							}
						}
					}
				}
			}
		}
	}
}
Exemple #28
0
int
tinytest_main(int c, const char **v, struct testgroup_t *groups)
{
	int i, j, n=0;

#ifdef _WIN32
	const char *sp = strrchr(v[0], '.');
	const char *extension = "";
	if (!sp || stricmp(sp, ".exe"))
		extension = ".exe"; /* Add an exe so CreateProcess will work */
	snprintf(commandname, sizeof(commandname), "%s%s", v[0], extension);
	commandname[MAX_PATH]='\0';
#endif
	for (i=1; i<c; ++i) {
		if (v[i][0] == '-') {
			if (!strcmp(v[i], "--RUNNING-FORKED")) {
				opt_forked = 1;
			} else if (!strcmp(v[i], "--no-fork")) {
				opt_nofork = 1;
			} else if (!strcmp(v[i], "--quiet")) {
				opt_verbosity = -1;
				verbosity_flag = "--quiet";
			} else if (!strcmp(v[i], "--verbose")) {
				opt_verbosity = 2;
				verbosity_flag = "--verbose";
			} else if (!strcmp(v[i], "--terse")) {
				opt_verbosity = 0;
				verbosity_flag = "--terse";
			} else if (!strcmp(v[i], "--help")) {
				usage(groups, 0);
			} else if (!strcmp(v[i], "--list-tests")) {
				usage(groups, 1);
			} else {
				printf("Unknown option %s.  Try --help\n",v[i]);
				return -1;
			}
		} else {
			int r = process_test_option(groups, v[i]);
			if (r<0)
				return -1;
			n += r;
		}
	}
	if (!n)
		tinytest_set_flag_(groups, "..", 1, TT_ENABLED_);

#ifdef _IONBF
	setvbuf(stdout, NULL, _IONBF, 0);
#endif

	++in_tinytest_main;
	for (i=0; groups[i].prefix; ++i)
		for (j=0; groups[i].cases[j].name; ++j)
			if (groups[i].cases[j].flags & TT_ENABLED_)
				testcase_run_one(&groups[i],
						 &groups[i].cases[j]);

	--in_tinytest_main;

	if (opt_verbosity==0)
		puts("");

	if (n_bad)
		printf("%d/%d TESTS FAILED. (%d skipped)\n", n_bad,
		       n_bad+n_ok,n_skipped);
	else if (opt_verbosity >= 1)
		printf("%d tests ok.  (%d skipped)\n", n_ok, n_skipped);

	return (n_bad == 0) ? 0 : 1;
}
Exemple #29
0
int main(int argc, char *argv[]) {
	pnamestruct pn;
	FILE *fd;
	unsigned int off;
	int len;
	int count = 0;
	char pack[4], *fname = NULL, *pbor  = NULL, *p;

	setbuf(stdin,  NULL);
	setbuf(stdout, NULL);
	setbuf(stderr, NULL);

	fputs("\n"
		"BOR music player v"VER"\n"
		"v0.1 by Luigi Auriemma\n"
		"e-mail: [email protected]\n"
		"web:    aluigi.org\n"
		"v0.2-0.3 by Plombo\n"
		"e-mail: [email protected]\n"
		"web:    lavalit.com\n"
		"\n", stdout);

	if(argc < 2) {
		printf("\n"
			"Usage: %s <file.BOR/PAK> [filename]\n"
			"\n"
			"filename is a part of the bor file you want play\n"
			"use this function for playing a specific file in a PAK archive\n"
			"\n", argv[0]);
		exit(1);
	}

	if(argc > 2) pbor = slashback(argv[2]);
	fname = argv[1];

	MYFOPEN {
		fname = malloc(strlen(argv[1]) + 5);
		if(!fname) std_err();
		p = fname + sprintf(fname, "%s", argv[1]);

		strcpy(p, ".bor");
		MYFOPEN {

			strcpy(p, ".pak");
			MYFOPEN std_err();
		}
	}

	aoinit(NULL);
	printf ("- press Ctrl+Z, Ctrl+D, Ctrl+C, Esc, 'x', or 'q' to exit\n"
			"- press Space to pause or unpause\n"
			"- press Tab or Enter to go to the next song\n"
			"\n");
	if(!fread(pack, 4, 1, fd)) goto quit;
	if(memcmp(pack, "PACK", 4)) {
		if(borplay(fd, fname, 0, -1) >= 0) count = 1;
		goto quit;
	}

	if(fseek(fd, -4, SEEK_END) < 0) std_err();

	if(!fread(&off, 4, 1, fd)) goto quit;
	if(fseek(fd, off, SEEK_SET) < 0) std_err();
	
	
	if (!pbor)
		printf("- playing all music files in %s\n", argv[1]);
	while((len = fread(&pn, 1, sizeof(pn), fd)) > 12) {
		p = strrchr(pn.namebuf, '.');
		
		if((p && !stricmp(p, ".bor")) || (stristr(pn.namebuf, "music"))) {
			if(pbor && !stristr(pn.namebuf, pbor)) goto next;
			count++;
			if(borplay(fd, pn.namebuf, pn.filestart, pn.filesize) < 0) break;
		}

next:
		off += pn.pns_len;
		if(fseek(fd, off, SEEK_SET) < 0) std_err();
	}

quit:
	fclose(fd);
	if(device) {
		ao_shutdown();
	}
	if (count == 0) printf("- no matching files found\n");
	printf("- finished\n");
	return(0);
}
Exemple #30
0
int
CSQLiteDE::ProcessCSV2SQLite(int PMode,			// currently just the one mode...default is to parse from CSV and create/populate SQLite database
				  bool bSafe,					// if true then use indexing on all tables whilst inserting... much slower but perhaps safer if multiple threads ...
				  char *pszExprName,			// name by which this experiment is identified
				  char *pszExprDescr,			// describes experiment
				  char *pszCtrlConditions,		// control conditions
				  char *pszExprConditions,		// experiment conditions
				  char *pszInFile,				// parse from this input CSV file
				  char *pszDatabase)			// SQLite database file
{
int Rslt;
bool bExtdBins;			// false if CSV file does not contain bins, true if determined that CSV contains bin counts
int sqlite_error;
sqlite3_stmt *prepstatement = NULL;
int ExprID;		// experiment identifier
int TransID;
int ExpresID;
char *pszTransName;
char *pszContOrExpr;
int TransLen;
int NumExons;
int Class;
int Score;
int DECntsScore;
int PearsonScore;
int CtrlUniqueLoci;
int ExprUniqueLoci;
double CtrlExprLociRatio;
double PValueMedian;
double PValueLow95;
double PValueHi95;
int TotCtrlCnts;
int TotExprCnts;
int TotCtrlExprCnts;
double ObsFoldChange;
double FoldMedian;
double FoldLow95;
double FoldHi95;
double ObsPearson;
double PearsonMedian;
double PearsonLow95;
double PearsonHi95;
int CtrlAndExprBins;
int CtrlOnlyBins;
int ExprOnlyBins;
int TotBins;
int BinIdx;
int BinValues[100 * 2];		// sized to contain 100 bin counts for both control and experiment
int *pBinValue;
int NumFields;
int NumElsRead;
int NumBins;
int BinID;
int ExpNumBins;
int ExpNumFields;


// load CSV file and determine number of fields, from these it can be determined if the file also contains the bin counts
CCSVFile *pCSV = new CCSVFile;
if(pCSV == NULL)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Unable to instantiate CCSVfile");
	CloseDatabase(true);
	return(eBSFerrObj);
	}
pCSV->SetMaxFields(cDESummMaxBinFields + 10);	// could be upto 100 bins, add 10 in case more fields than expected!
if((Rslt=pCSV->Open(pszInFile))!=eBSFSuccess)
	{
	while(pCSV->NumErrMsgs())
		gDiagnostics.DiagOut(eDLFatal,gszProcName,pCSV->GetErrMsg());
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Unable to open file: %s",pszInFile);
	delete pCSV;
	return(Rslt);
	}
if((Rslt=pCSV->NextLine()) < 1)	// have to be able to read at least one!
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Unable to read any lines from %s",pszInFile);
	delete pCSV;
	return(Rslt);
	}
NumFields = pCSV->GetCurFields();		// expecting at least 24, if 24 then summary, if 27+ then summary plus bin counts
if(NumFields < cDESummFields)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"CSV transcipt expression file '%s' are expected to contain at least %d fields, parsed %d",pszInFile,cDESummFields,NumFields);
	delete pCSV;
	return(eBSFerrFieldCnt);
	}
if(NumFields > cDESummFields && NumFields < cDESummMinBinFields)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Expected CSV file '%s' to contain either %d (no bins) or at least %d (with bins) fields, file has %d fields",pszInFile,cDESummFields,cDESummMinBinFields,NumFields);
	delete pCSV;
	return(eBSFerrFieldCnt);
	}
if(NumFields > cDESummMaxBinFields)					// if summary plus bins then expecting at most 100 bins
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Expected CSV file '%s' to contain no more than 100 bins",pszInFile);
	delete pCSV;
	return(eBSFerrFieldCnt);
	}
if(NumFields == cDESummFields)
	{
	bExtdBins = false;
	NumBins = 0;
	}
else
	{
	bExtdBins = true;
	NumBins = NumBins = 5 + NumFields - cDESummMinBinFields; 
	}
pCSV->Close();

sqlite3_initialize();

if((CreateDatabase(bSafe,pszDatabase))==NULL)
	{
	sqlite3_shutdown();
	return(eBSFerrInternal);
	}

if((Rslt = CreateExperiment(bExtdBins ? 1 : 0,pszInFile,pszExprName,pszExprDescr,pszCtrlConditions,pszExprConditions,NumBins)) < 1)
	{
	CloseDatabase(true);
	return(Rslt);
	}
ExprID = Rslt;

char *pszBeginTransaction = (char *)"BEGIN TRANSACTION";
char *pszEndTransaction = (char *)"END TRANSACTION";
char *pszDropIndexes = (char *)"DROP INDEX IF EXISTS 'Markers_LociID'";

char *pszPragmaSyncOff = (char *)"PRAGMA synchronous = OFF";
char *pszPragmaSyncOn = (char *)"PRAGMA synchronous = ON";
char *pszPragmaJournMem = (char *)"PRAGMA journal_mode = MEMORY";

gDiagnostics.DiagOut(eDLInfo,gszProcName,"sqlite - populating tables");


// synchronous writes off
if((sqlite_error = sqlite3_exec(m_pDB,pszPragmaSyncOff,NULL,NULL,NULL))!=SQLITE_OK)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - can't turn synchronous writes off: %s", sqlite3_errmsg(m_pDB)); 
	CloseDatabase(true);
	return(eBSFerrInternal);
	}

// bracket inserts as a single transaction
if((sqlite_error = sqlite3_exec(m_pDB,pszBeginTransaction,NULL,NULL,NULL))!=SQLITE_OK)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - can't begin transactions: %s",sqlite3_errmsg(m_pDB)); 
	CloseDatabase(true);
	return(eBSFerrInternal);
	}


// load CSV file and start populating the SQLite database
if((Rslt=pCSV->Open(pszInFile))!=eBSFSuccess)
	{
	while(pCSV->NumErrMsgs())
		gDiagnostics.DiagOut(eDLFatal,gszProcName,pCSV->GetErrMsg());
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"Unable to open file: %s",pszInFile);
	delete pCSV;
	CloseDatabase(true);
	return(Rslt);
	}


bExtdBins = false;
NumElsRead = 0;
ExpNumBins = 0;
ExpNumFields = 0;
while((Rslt=pCSV->NextLine()) > 0)			// onto next line containing fields
	{
	if(!(NumElsRead % (bSafe ? 5000 : 100000)) && NumElsRead > 0)
		gDiagnostics.DiagOut(eDLInfo,gszProcName,"Parsed %d CSV lines - Transcripts: %d",NumElsRead, m_NumTrans);

	NumFields = pCSV->GetCurFields();		// expecting at least 24, if 24 then summary, if 27+ then summary plus bin counts
	if(ExpNumFields > 0 && NumFields != ExpNumFields)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"CSV transcipt expression file '%s' has varying number of fields : expected %d, parsed %d at line %d",pszInFile,ExpNumFields,NumFields,NumElsRead);
		delete pCSV;
		CloseDatabase(true);
		return(eBSFerrFieldCnt);
		}
	if(ExpNumFields == 0)
		{
		ExpNumFields = NumFields;
		if(NumFields < cDESummFields)
			{
			gDiagnostics.DiagOut(eDLFatal,gszProcName,"CSV transcipt expression file '%s' are expected to contain at least %d fields, parsed %d at line %d",pszInFile,cDESummFields,NumFields,NumElsRead);
			delete pCSV;
			CloseDatabase(true);
			return(eBSFerrFieldCnt);
			}
		if(NumFields > cDESummFields)							// summary plus bins?
			{
			if(NumFields < cDESummMinBinFields)					// if summary plus bins then expecting at least 5 bins
				{
				gDiagnostics.DiagOut(eDLFatal,gszProcName,"Expected CSV file '%s' to contain at least 5 bins at line %d",pszInFile,NumElsRead);
				delete pCSV;
				CloseDatabase(true);
				return(eBSFerrFieldCnt);
				}
			if(NumFields > cDESummMaxBinFields)					// if summary plus bins then expecting at most 100 bins
				{
				gDiagnostics.DiagOut(eDLFatal,gszProcName,"Expected CSV file '%s' to contain no more than 100 bins at line %d",pszInFile,NumElsRead);
				delete pCSV;
				CloseDatabase(true);
				return(eBSFerrFieldCnt);
				}

			NumBins = 5 + NumFields - cDESummMinBinFields;
			ExpNumBins = NumBins;
			bExtdBins = true;
			}
		}

	if(!NumElsRead && pCSV->IsLikelyHeaderLine())
		continue;
	NumElsRead += 1;

	// first 20 fields are common to both CSV file types
	pCSV->GetInt(1,&Class);
	pCSV->GetText(2,&pszTransName);
	pCSV->GetInt(3,&TransLen);
	pCSV->GetInt(4,&NumExons);

	pCSV->GetInt(5,&Score);
	pCSV->GetInt(6,&DECntsScore);
	pCSV->GetInt(7,&PearsonScore);
	pCSV->GetInt(8,&CtrlUniqueLoci);
	pCSV->GetInt(9,&ExprUniqueLoci);
	
	pCSV->GetDouble(10,&CtrlExprLociRatio);
	pCSV->GetDouble(11,&PValueMedian);
	pCSV->GetDouble(12,&PValueLow95);
	pCSV->GetDouble(13,&PValueHi95);

	pCSV->GetInt(14,&TotCtrlCnts);
	pCSV->GetInt(15,&TotExprCnts);
	pCSV->GetInt(16,&TotCtrlExprCnts);

	pCSV->GetDouble(17,&ObsFoldChange);
	pCSV->GetDouble(18,&FoldMedian);
	pCSV->GetDouble(19,&FoldLow95);
	pCSV->GetDouble(20,&FoldHi95);
	// file formats diverge dependent on if containing bin counts
	if(!bExtdBins)
		{
		pszContOrExpr = NULL;
		pCSV->GetDouble(21,&ObsPearson);
		pCSV->GetDouble(22,&PearsonMedian);
		pCSV->GetDouble(23,&PearsonLow95);
		pCSV->GetDouble(24,&PearsonHi95);
		TotBins = 0;
		CtrlAndExprBins = 0;
		CtrlOnlyBins = 0;
		ExprOnlyBins = 0;
		}
	else
		{
		pCSV->GetText(21,&pszContOrExpr);
		pCSV->GetDouble(22,&ObsPearson);
		pCSV->GetDouble(23,&PearsonMedian);
		pCSV->GetDouble(24,&PearsonLow95);
		pCSV->GetDouble(25,&PearsonHi95);
		pCSV->GetInt(26,&TotBins);
		pCSV->GetInt(27,&CtrlAndExprBins);
		pCSV->GetInt(28,&CtrlOnlyBins);
		pCSV->GetInt(29,&ExprOnlyBins);
		if(!stricmp(pszContOrExpr,"Control"))
			pBinValue = &BinValues[0];
		else
			pBinValue = &BinValues[1];
		for(BinIdx = 0; BinIdx < NumBins; BinIdx++,pBinValue += 2)
			*pBinValue = pCSV->GetInt(BinIdx + 30,pBinValue);
		}
	if(!bExtdBins || (bExtdBins && stricmp(pszContOrExpr,"Control")))
		{
		TransID = AddTrans(ExprID,pszTransName,NumExons,TransLen,(char *)"N/A");
		ExpresID = AddExpres(ExprID,TransID,Class,Score,DECntsScore,PearsonScore,CtrlUniqueLoci,ExprUniqueLoci,CtrlExprLociRatio,PValueMedian,PValueLow95,PValueHi95,
					TotCtrlCnts,TotExprCnts,TotCtrlExprCnts,ObsFoldChange,FoldMedian,FoldLow95,FoldHi95,ObsPearson,PearsonMedian,PearsonLow95,PearsonHi95,
					CtrlAndExprBins,CtrlOnlyBins,ExprOnlyBins);
		}
	if(bExtdBins && stricmp(pszContOrExpr,"Control"))
		{
		pBinValue = &BinValues[0];
		for(BinIdx = 1; BinIdx <= NumBins; BinIdx++,pBinValue += 2)
			BinID = AddBin(ExprID,TransID,ExpresID,BinIdx,*pBinValue,pBinValue[1]);
		}
	}
gDiagnostics.DiagOut(eDLInfo,gszProcName,"Parsed %d CSV lines - transcripts: %d",NumElsRead, m_NumTrans);

	// end transaction
if((sqlite_error = sqlite3_exec(m_pDB,pszEndTransaction,NULL,NULL,NULL))!=SQLITE_OK)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - can't end transactions on '%s': %s", "Markers",sqlite3_errmsg(m_pDB)); 
	CloseDatabase(true);
	return(eBSFerrInternal);
	}
gDiagnostics.DiagOut(eDLInfo,gszProcName,"Completed populating the sqlite database");

gDiagnostics.DiagOut(eDLInfo,gszProcName,"Generating indexes ...");

tsDEStmSQL *pStms;
pStms = m_StmSQL;
int TblIdx;
for(TblIdx = 0; TblIdx < 4; TblIdx++,pStms++)
	{
	if(pStms->pszCreateIndexes == NULL)
		continue;
	gDiagnostics.DiagOut(eDLInfo,gszProcName,"Creating indexes on table %s ...", pStms->pTblName);
	if((sqlite_error = sqlite3_exec(m_pDB,pStms->pszCreateIndexes,0,0,0))!=SQLITE_OK)
		{
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - can't create indexes on table %s : %s", pStms->pTblName,sqlite3_errmsg(m_pDB));
		gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - statement: %s",pStms->pszCreateIndexes);   
		CloseDatabase(true);
		return(eBSFerrInternal);
		}
	}
gDiagnostics.DiagOut(eDLInfo,gszProcName,"Indexes generated");
// synchronous writes off
if((sqlite_error = sqlite3_exec(m_pDB,pszPragmaSyncOn,NULL,NULL,NULL))!=SQLITE_OK)
	{
	gDiagnostics.DiagOut(eDLFatal,gszProcName,"sqlite - can't turn synchronous writes on: %s", sqlite3_errmsg(m_pDB)); 
	CloseDatabase(true);
	return(eBSFerrInternal);
	}

CloseDatabase();
sqlite3_shutdown();
gDiagnostics.DiagOut(eDLInfo,gszProcName,"SQLite database ready for use");
return(eBSFSuccess);
}