void nasolver<nr_type_t>::solve_pre (void)
{
    // create node list, enumerate nodes and voltage sources
#if DEBUG
    logprint (LOG_STATUS, "NOTIFY: %s: creating node list for %s analysis\n",
              getName (), desc.c_str());
#endif
    nlist = new nodelist (subnet);
    nlist->assignNodes ();
    assignVoltageSources ();
#if DEBUG && 0
    nlist->print ();
#endif

    // create matrix, solution vector and right hand side vector
    int M = countVoltageSources ();
    int N = countNodes ();
    if (A != NULL) delete A;
    A = new tmatrix<nr_type_t> (M + N);
    if (z != NULL) delete z;
    z = new tvector<nr_type_t> (N + M);
    if (x != NULL) delete x;
    x = new tvector<nr_type_t> (N + M);

#if DEBUG
    logprint (LOG_STATUS, "NOTIFY: %s: solving %s netlist\n", getName (), desc.c_str());
#endif
}
Exemple #2
0
/*
=============
main
=============
*/
int main (int argc, char **argv)
{
	if (argc == 1)
	{
		logprint ("qfiles -pak <0 / 1 / 2 / 3> : build a .pak file\n");
		logprint ("qfiles -bspmodels : regenerates all brush models\n");
		exit (1);
	}

	SetQdirFromPath ("");

	ReadFiles ();

	if (!strcmp (argv[1], "-pak"))
	{
		CopyQFiles (atoi(argv[2]));
	}
	else if (!strcmp (argv[1], "-bspmodels"))
	{
		BspModels ();
	}
	else
		Error ("unknown command: %s", argv[1]);

	return 0;
}
Exemple #3
0
/* starts the parsing of  pattern files as called in parse_squirm_conf
   creates a pattern_file, which includes a list of all patterns in conf_filename */
struct pattern_file *create_pattern_list (char *conf_filename)
{
    struct pattern_file *tmp;

    tmp = (struct pattern_file *)malloc(sizeof(struct pattern_file));
    if (tmp == NULL) {
        logprint(LOG_ERROR, "unable to allocate memory in create_pattern_list()\n");
        dodo_mode = 1;
        return NULL;
    }

    tmp->head = NULL;
    tmp->filename = safe_strdup(conf_filename);
    if (tmp->filename == NULL) {
        logprint(LOG_ERROR, "unable to allocate memory in create_pattern_list()\n");
        dodo_mode = 1;
        free(tmp);
        return NULL;
    }
    tmp->next = NULL;

    if (load_patterns(&(tmp->head), conf_filename) == -1) {
        return NULL;
    }

    return tmp;
}
Exemple #4
0
int load_patterns(struct pattern_item **list, char *conf_filename)
{
    char buff[MAX_BUFF];
    FILE *fp;

    fp = fopen(conf_filename, "rt");

    if(fp == NULL) {
        logprint(LOG_ERROR, "unable to open patterns file [%s]\n", conf_filename);
        dodo_mode = 1;
        return -1;
    }

    logprint(LOG_INFO, "Reading patterns from file %s\n", conf_filename);

    while(!dodo_mode && (fgets(buff, MAX_BUFF, fp) != NULL)) {

        /* skip blank lines and comments */
        if((strncmp(buff, "#", 1) == 0) || (strncmp(buff, "\n", 1) == 0))
            continue;

        if(strlen(buff) != 1) {
            /* chop newline */
            buff[strlen(buff) - 1] = '\0';
            add_to_patterns(buff, list);
        }
    }

    fclose(fp);
    return 1;
}
Exemple #5
0
/*
=============
ReadFiles
=============
*/
int ReadFiles (void)
{
	FILE	*f;
	int		i;

	f = SafeOpenRead ("files.dat");

	fscanf (f, "%i\n", &numsounds);
	for (i=0 ; i<numsounds ; i++)
		fscanf (f, "%i %s\n", &precache_sounds_block[i],
			precache_sounds[i]);

	fscanf (f, "%i\n", &nummodels);
	for (i=0 ; i<nummodels ; i++)
		fscanf (f, "%i %s\n", &precache_models_block[i],
			precache_models[i]);

	fscanf (f, "%i\n", &numfiles);
	for (i=0 ; i<numfiles ; i++)
		fscanf (f, "%i %s\n", &precache_files_block[i],
			precache_files[i]);

	fclose (f);

	logprint ("%3i sounds\n", numsounds);
	logprint ("%3i models\n", nummodels);
	logprint ("%3i files\n", numfiles);
}
Exemple #6
0
int BotGetConfig(char* param)
{

	cout<<"Загрузка: ";
	cout<<param;
	cout<<"...";

	char *myparam = (char*)malloc(strlen(param) + 1);
	sprintf(myparam, "%s", param);

	char *Configdatahttpquery = (char*)malloc(strlen("http://178.132.203.196/D3Bot/getconfig.php?param=config_") + strlen(param) + strlen("&authkey=") + strlen(TestKey) + 1);
	sprintf(Configdatahttpquery, "%s%s%s%s", "http://178.132.203.196/D3Bot/getconfig.php?param=config_", param, "&authkey=", TestKey);
	string Configurls = Configdatahttpquery;
	CURLcode Configresult;
	string Configbuffer;

	curl_easy_setopt(curl, CURLOPT_URL, Configurls.c_str());
	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
	curl_easy_setopt(curl, CURLOPT_WRITEDATA, &Configbuffer);
	Configresult = curl_easy_perform(curl);

	cout<<" - ";
	cout<<atoi((char*)Configbuffer.c_str());
	cout<<"\n";

	logprint(param, -1);
	logprint((char*)Configbuffer.c_str(), -1);

	return atoi((char*)Configbuffer.c_str());

}
/*
 * =============
 *  LightWorld
 * =============
 */
static void
LightWorld(void)
{
    if (dlightdata)
	free(dlightdata);

    if (colored)
	lightdatasize = MAX_MAP_LIGHTING;
    else
	lightdatasize = MAX_MAP_LIGHTING / 4;
    dlightdata = malloc(lightdatasize + 16); /* for alignment */
    if (!dlightdata)
	Error("%s: allocation of %i bytes failed.", __func__, lightdatasize);
    memset(dlightdata, 0, lightdatasize + 16);

    if (litfile)
	lightdatasize /= 4;

    /* align filebase to a 4 byte boundary */
    filebase = file_p = (byte *)(((unsigned long)dlightdata + 3) & ~3);
    file_end = filebase + lightdatasize;

    if (colored && litfile) {
	/* litfile data stored in dlightdata, after the white light */
	lit_filebase = file_end + 12 - ((unsigned long)file_end % 12);
	lit_file_p = lit_filebase;
	lit_file_end = lit_filebase + 3 * (MAX_MAP_LIGHTING / 4);
    }

    RunThreadsOn(0, numfaces, LightThread);
    logprint("Lighting Completed.\n\n");

    lightdatasize = file_p - filebase;
    logprint("lightdatasize: %i\n", lightdatasize);
}
Exemple #8
0
void reload(int signum)
{
	PMList *lp;
	opendoor_t *door;

	vprint("Re-reading config file: %s\n", o_cfg);
	logprint("Re-reading config file: %s\n", o_cfg);

	for(lp = doors; lp; lp = lp->next) {
		door = (opendoor_t*)lp->data;
		close_door(door);
	}
	list_free(doors);

	parseconfig(o_cfg);

	vprint("Closing and re-opening log file: %s\n", o_logfile);
	logprint("Closing and re-opening log file: %s\n", o_logfile);

	/* close and re-open the log file */
	if(logfd) {
		fclose(logfd);
	}
	logfd = fopen(o_logfile, "a");
	if(logfd == NULL) {
		perror("warning: cannot open logfile");
	}

	return;
}
Exemple #9
0
void BotUpdateSession()
{
	while(1)
	{
		char *Dropdatahttpquery = (char*)malloc(strlen("http://178.132.203.196/D3Bot/session.php?version=") + strlen(BotVersion) + strlen("&type=") + strlen(BotType) + strlen("&authkey=") + strlen(TestKey) + 1);
		sprintf(Dropdatahttpquery, "%s%s%s%s%s%s", "http://178.132.203.196/D3Bot/session.php?version=", BotVersion, "&type=", BotType, "&authkey=", TestKey);
		string Dropurls = Dropdatahttpquery;

		CURLcode Dropresult;
		string Dropbuffer;

		curl_easy_setopt(curl, CURLOPT_URL, Dropurls.c_str());
		curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2);
		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &Dropbuffer);
		Dropresult = curl_easy_perform(curl);

		if(Dropbuffer == md5(mymd5))
		{
			noauthupdate = 0;
			noauth = 0;
			break;
		}
		else
		{
			noauth = 1;
			noauthupdate = 1;
			BotSleep(0,0,0,0,0,0,0,0,0,0,0,0,300);
			logprint("Ошибка соединения с сервером:", 0);
			logprint(Dropbuffer, 0);
		}
	}
}
Exemple #10
0
/* Signal handlers */
void cleanup(int signum)
{
	ip_literal_t *myip = myips;
	int status;

	vprint("waiting for child processes...\n");
	logprint("waiting for child processes...");
	wait(&status);

	vprint("closing...\n");
	logprint("shutting down");
	pcap_close(cap);
	if(o_daemon) {
		unlink(o_pidfile);
	}

	if(myips) {
		while(myips) {
			if(myip->value)
				free(myip->value);
			myips = myip->next;
			free(myip);
		}
	}

	exit(signum);
}
Exemple #11
0
/*
  ==================
  CalcPortalVis
  ==================
*/
void
CalcPortalVis(const bsp2_t *bsp)
{
    int i, startcount;
    portal_t *p;

// fastvis just uses mightsee for a very loose bound
    if (fastvis) {
        for (i = 0; i < numportals * 2; i++) {
            portals[i].visbits = portals[i].mightsee;
            portals[i].status = pstat_done;
        }
        return;
    }

    /*
     * Count the already completed portals in case we loaded previous state
     */
    startcount = 0;
    for (i = 0, p = portals; i < numportals * 2; i++, p++) {
        if (p->status == pstat_done)
            startcount++;
    }
    RunThreadsOn(startcount, numportals * 2, LeafThread, NULL);

    if (verbose) {
        logprint("portalcheck: %i  portaltest: %i  portalpass: %i\n",
                 c_portalcheck, c_portaltest, c_portalpass);
        logprint("c_vistest: %i  c_mighttest: %i  c_mightseeupdate %i\n",
                 c_vistest, c_mighttest, c_mightseeupdate);
    }
}
/* This function scans, parses and checks a netlist from the input
   file (specified by the constructor call) or stdin if there is no
   such file.  Afterwards the function builds the netlist
   representation and stores it into the given netlist object.  The
   function returns zero on success and non-zero otherwise. */
int input::netlist (net * netlist) {

  // tell the scanner to use the specified file
  netlist_in = getFile ();

  // save the netlist object
  subnet = netlist;

  logprint (LOG_STATUS, "parsing netlist...\n");
  if (netlist_parse () != 0)
    return -1;

  logprint (LOG_STATUS, "checking netlist...\n");
  if (netlist_checker (env) != 0)
    return -1;

  if (netlist_checker_variables (env) != 0)
    return -1;

#if DEBUG
  netlist_list ();
#endif /* DEBUG */
  netlist_status ();

  logprint (LOG_STATUS, "creating netlist...\n");
  factory ();

  netlist_destroy ();
  return 0;
}
Exemple #13
0
/* Parse a port:protocol sequence. Returns a positive integer on error.
 */
int parse_port_sequence(char *sequence, opendoor_t *door)
{
	char *num;
	char *protocol;
	char *port;

	door->seqcount = 0;	/* reset seqcount */
	while((num = strsep(&sequence, ","))) {
		if(door->seqcount >= SEQ_MAX) {
			fprintf(stderr, "config: section %s: too many ports in knock sequence\n", door->name);
			logprint("error: section %s: too many ports in knock sequence\n", door->name);
			return(1);
		}
		port = strsep(&num, ":");
		door->sequence[door->seqcount++] = (unsigned short)atoi(port);
		if((protocol = strsep(&num, ":"))){
			protocol = strtoupper(trim(protocol));
			if(!strcmp(protocol, "TCP")){
				door->protocol[door->seqcount-1] = IPPROTO_TCP;
			} else if(!strcmp(protocol, "UDP")) {
				door->protocol[door->seqcount-1] = IPPROTO_UDP;
			} else {
				fprintf(stderr,"config: section %s: unknown protocol in knock sequence\n", door->name);
				logprint("error: section %s: unknown protocol in knock sequence\n", door->name);
				return(1);
			}
		} else {
			door->protocol[door->seqcount-1] = IPPROTO_TCP; /* default protocol */
		}
	}
	return(0);
}
Exemple #14
0
static void
LeafFlow(int leafnum, bsp2_dleaf_t *dleaf)
{
    leaf_t *leaf;
    byte *outbuffer;
    byte *compressed;
    int i, j, shift, len;
    int numvis;
    byte *dest;
    const portal_t *p;

    /*
     * flow through all portals, collecting visible bits
     */
    outbuffer = uncompressed + leafnum * leafbytes;
    leaf = &leafs[leafnum];
    for (i = 0; i < leaf->numportals; i++) {
        p = leaf->portals[i];
        if (p->status != pstat_done)
            Error("portal not done");
        for (j = 0; j < leafbytes; j++) {
            shift = (j << 3) & LEAFMASK;
            outbuffer[j] |= (p->visbits->bits[j >> (LEAFSHIFT - 3)] >> shift) & 0xff;
        }
    }

    if (outbuffer[leafnum >> 3] & (1 << (leafnum & 7)))
        logprint("WARNING: Leaf portals saw into leaf (%i)\n", leafnum);
    outbuffer[leafnum >> 3] |= (1 << (leafnum & 7));

    numvis = 0;
    for (i = 0; i < portalleafs; i++)
        if (outbuffer[i >> 3] & (1 << (i & 3)))
            numvis++;

    /*
     * compress the bit string
     */
    if (verbose > 1)
        logprint("leaf %4i : %4i visible\n", leafnum, numvis);
    totalvis += numvis;

    /* Allocate for worst case where RLE might grow the data (unlikely) */
    compressed = malloc(portalleafs * 2 / 8);
    len = CompressRow(outbuffer, (portalleafs + 7) >> 3, compressed);

    dest = vismap_p;
    vismap_p += len;

    if (vismap_p > vismap_end)
        Error("Vismap expansion overflow");

    /* leaf 0 is a common solid */
    dleaf->visofs = dest - vismap;

    memcpy(dest, compressed, len);
    free(compressed);
}
Exemple #15
0
// DEBUG function:  Prints the S parameters of this circuit object.
void circuit::print (void) {
  for (int i = 0; i < getSize (); i++) {
    for (int j = 0; j < getSize (); j++) {
      logprint (LOG_STATUS, "%s S%d%d(%+.3e,%+.3e) ", getName (), i, j,
		(double) real (getS (i, j)), (double) imag (getS (i, j)));
    }
    logprint (LOG_STATUS, "\n");
  }
}
// Debug function: Prints the entire nodelist.
void nodelist::print (void) {
  for (struct nodelist_t * n = root; n != NULL; n = n->next) {
    logprint (LOG_STATUS, "DEBUG: node %s-%d [", n->name, n->n);
    for (int i = 0; i < n->nNodes; i++) {
      logprint (LOG_STATUS, "%s", n->nodes[i]->getCircuit()->getName ());
      if (i != n->nNodes - 1) logprint (LOG_STATUS, ",");
    }
    logprint (LOG_STATUS, "]\n");
  }
}
Exemple #17
0
/*------------------------------------------------------------------*/
void count_qs_matrix_nonzero(fact_obj_t *obj,
			uint32 nrows, uint32 num_dense_rows,
			uint32 ncols, qs_la_col_t *cols) {

	uint32 i, j;
	uint32 total_weight;
	uint32 sparse_weight;
	size_t mem_use;
	
	mem_use = ncols * (sizeof(qs_la_col_t) +
		sizeof(uint32) * ((num_dense_rows + 31) / 32));

	for (i = total_weight = sparse_weight = 0; i < ncols; i++) {
		uint32 w = cols[i].weight;
		total_weight += w;
		sparse_weight += w;
		mem_use += w * sizeof(uint32);
	}

	if (num_dense_rows > 0) {
		for (i = 0; i < ncols; i++) {
			uint32 *dense_rows = cols[i].data + cols[i].weight;
			for (j = 0; j < num_dense_rows; j++) {
				if (dense_rows[j / 32] & (1 << (j % 32)))
					total_weight++;
			}
		}
	}

	if (VFLAG > 0)
		printf("matrix is %u x %u (%.1f MB) with "
			"weight %u (%5.2f/col)\n", 
				nrows, ncols, 
				(double)mem_use / 1048576,
				total_weight, 
				(double)total_weight / ncols);
	if (VFLAG > 0)
		printf("sparse part has weight %u (%5.2f/col)\n", 
				sparse_weight, 
				(double)sparse_weight / ncols);

	if (obj->logfile != NULL)
		logprint(obj->logfile, "matrix is %u x %u (%.1f MB) with "
			"weight %u (%5.2f/col)\n", 
				nrows, ncols, 
				(double)mem_use / 1048576,
				total_weight, 
				(double)total_weight / ncols);

	if (obj->logfile != NULL)
		logprint(obj->logfile, "sparse part has weight %u (%5.2f/col)\n", 
				sparse_weight, 
				(double)sparse_weight / ncols);
}
bool AUserDefinedMapList::query(QSqlQuery* q)
{
	_lasterror = QString("");
	int count = 0;
#ifndef QT_NO_DEBUG
	logprint(QString("%1 query start").arg("User Defined Map"));
#endif

	QString prevMap = QString("");
	QString prevLayer = QString("");
	QSqlError sqlerror;
	QString sql = QString (
			"SELECT                                              "
			"       USER_LAYER_ID, LAYER_ID, ELEMENT_ID          "
			"  FROM TB_USERLAYERCONF                             "
			" ORDER BY USER_LAYER_ID, LAYER_ID, ELEMENT_ID       "
			);
	q->exec(sql);
	if (q->lastError().type() != QSqlError::NoError) {
		_lasterror = q->lastError().text();
		logprint(QString("AUserDefinedMapList query error : %1 (%2)").arg(q->lastError().text()).arg(sql));
		return false;
	}
	mapList.clear();
	AUserDefinedMap* nowmap;
	while(q->next()) {
		QString mapid = q->value(0).toString();
		QString layerid = q->value(1).toString();
		QString id = q->value(2).toString();

		QString keyMap = mapid;
		QString keyLayer = layerid;

		if (keyMap != prevMap) {
			AUserDefinedMap* newmap = new AUserDefinedMap(mapid);
			mapList.append(newmap);
			newmap->addLayer(layerid);
			newmap->addId(layerid, id);
			nowmap = newmap;
		}else {		// map이 같으면
			if (keyLayer != prevLayer) {
				nowmap->addLayer(layerid);
				nowmap->addId(layerid, id);
			}else {
				nowmap->addId(layerid, id);
			}
		}
		prevLayer = keyLayer;
		prevMap = keyMap;
		count++;
	}
	return true;
}
Exemple #19
0
static void
Pread(int fd, void *buf, size_t size, offset_t off)
{
	ssize_t sz = pread64(fd, buf, size, off);

	if (sz < 0)
		logprint(SC_SL_ERR | SC_EXIT_ERR,
		    "pread: %s", strerror(errno));
	else if (sz != size)
		logprint(SC_SL_ERR | SC_EXIT_ERR,
		    "pread: size %ld != %ld", sz, size);
}
Exemple #20
0
/*
  ============
  CalcPassages
  ============
*/
void
CalcPassages(void)
{
    int i, j, k;
    int count, count2;
    leaf_t *l;
    portal_t *p1, *p2;
    sep_t *sep;
    passage_t *passages;

    logprint("building passages...\n");

    count = count2 = 0;
    for (i = 0; i < portalleafs; i++) {
        l = &leafs[i];

        for (j = 0; j < l->numportals; j++) {
            p1 = l->portals[j];
            for (k = 0; k < l->numportals; k++) {
                if (k == j)
                    continue;

                count++;
                p2 = l->portals[k];

                // definately can't see into a coplanar portal
                if (PlaneCompare(&p1->plane, &p2->plane))
                    continue;

                count2++;

                sep = Findpassages(p1->winding, p2->winding);
                if (!sep) {
//                    Error ("No seperating planes found in portal pair");
                    count_sep++;
                    sep = malloc(sizeof(*sep));
                    sep->next = NULL;
                    sep->plane = p1->plane;
                }
                passages = malloc(sizeof(*passages));
                passages->planes = sep;
                passages->from = p1->leaf;
                passages->to = p2->leaf;
                passages->next = l->passages;
                l->passages = passages;
            }
        }
    }

    logprint("numpassages: %i (%i)\n", count2, count);
    logprint("total passages: %i\n", count_sep);
}
Exemple #21
0
// Prints the environment.
void environment::print (bool all) {
  ptrlistiterator<environment> it;
  logprint (LOG_STATUS, "environment %s\n", getName () ? getName () : "?env?");
  for (variable * var = root; var != NULL; var = var->getNext ()) {
    logprint (LOG_STATUS, "  %s [%s]\n", var->getName (), var->toString ());
  }
  for (it = ptrlistiterator<environment> (*children); *it; ++it) {
    logprint (LOG_STATUS, "  %s\n", (*it)->getName ());
  }
  if (all) {
    for (it = ptrlistiterator<environment> (*children); *it; ++it)
      (*it)->print ();
  }
}
Exemple #22
0
/* This function is the checker routine for a parsed dataset.  It
   returns zero on success or non-zero if the parsed dataset contained
   errors. */
int dataset_check (dataset * data) {

  int errors = 0;
  vector * v, * d;

  /* check actual size and requested size of independent vectors */
  for (v = data->getDependencies (); v != NULL; v = (vector *) v->getNext ()) {
    if (v->getSize () != v->getRequested ()) {
      logprint (LOG_ERROR, "checker error, vector `%s' contains %d values, "
		"%d have been stated\n", v->getName (), v->getSize (),
		v->getRequested ());
      errors++;
    }
  }

  /* check dependencies of dependent vectors */
  for (v = data->getVariables (); v != NULL; v = (vector *) v->getNext ()) {
    strlist * s = v->getDependencies ();
    /* any dependencies at all ? */
    if (s == NULL || s->length () == 0) {
      logprint (LOG_ERROR, "checker error, vector `%s' contains no "
		"dependencies\n", v->getName ());
      errors++;
    }
    /* yes */
    else {
      int n = 1;
      /* go through each dependency and check it */
      for (strlistiterator it (s); *it; ++it) {
	if ((d = data->findDependency (*it)) == NULL) {
	  logprint (LOG_ERROR, "checker error, no such dependency `%s' as "
		    "stated in `%s'\n", *it, v->getName ());
	  errors++;
	}
	else {
	  n *= d->getSize ();
	}
      }
      if (n != 0) {
	if (v->getSize () % n != 0) {
	  logprint (LOG_ERROR, "checker error, size of vector `%s' %d should "
		    "be dividable by %d\n", v->getName (), v->getSize (), n);
	  errors++;
	}
      }
    }
  }

  return errors ? -1 : 0;
}
Exemple #23
0
/* Execute a command through the system shell and wait for return
 */
int exec_cmd(char* command, char* name){
	int ret;

	logprint("%s: running command: %s\n", name, command);
	vprint("%s: running command: %s\n", name, command);
	ret = system(command);
	if(ret == -1) {
		fprintf(stderr, "error: command fork failed!\n");
		logprint("error: command fork failed!");
	} else if(ret != 0) {
		fprintf(stderr, "%s: command returned non-zero status code (%d)\n", name, WEXITSTATUS(ret));
		logprint("%s: command returned non-zero status code (%d)", name, WEXITSTATUS(ret));
	}
	return ret;
}
Exemple #24
0
/*
=================
Cmd_Environment
=================
*/
void Cmd_Environment (void)
{
	char	name[1024];
	int		i, x, y;
	byte	image[256*256];
	byte	*tga;

	GetToken (false);

	if (g_release)
	{
		for (i=0 ; i<6 ; i++)
		{
			sprintf (name, "env/%s%s.pcx", token, suf[i]);
			ReleaseFile (name);
			sprintf (name, "env/%s%s.tga", token, suf[i]);
			ReleaseFile (name);
		}
		return;
	}
	// get the palette
	BuildPalmap ();

	sprintf (name, "%senv/", gamedir);
	CreatePath (name);

	// convert the images
	for (i=0 ; i<6 ; i++)
	{
		sprintf (name, "%senv/%s%s.tga", gamedir, token, suf[i]);
		logprint ("loading %s...\n", name);
		LoadTGA (name, &tga, NULL, NULL);

		for (y=0 ; y<256 ; y++)
		{
			for (x=0 ; x<256 ; x++)
			{
				image[y*256+x] = FindColor (tga[(y*256+x)*4+0],tga[(y*256+x)*4+1],tga[(y*256+x)*4+2]);
			}
		}
		free (tga);
		sprintf (name, "%senv/%s%s.pcx", gamedir, token, suf[i]);
		if (FileTime (name) != -1)
			logprint ("%s already exists, not overwriting.\n", name);
		else
			WritePCXfile (name, image, 256, 256, colormap_palette);
	}
}
Exemple #25
0
/* This function prints the current dataset representation either to
   the specified file name (given by the function setFile()) or to
   stdout if there is no such file name given. */
void dataset::print (void) {

  FILE * f = stdout;

  // open file for writing
  if (file) {
    if ((f = fopen (file, "w")) == NULL) {
      logprint (LOG_ERROR, "cannot create file `%s': %s\n",
		file, strerror (errno));
      return;
    }
  }

  // print header
  fprintf (f, "<Qucs Dataset " PACKAGE_VERSION ">\n");

  // print dependencies
  for (vector * d = dependencies; d != NULL; d = (vector *) d->getNext ()) {
    printDependency (d, f);
  }

  // print variables
  for (vector * v = variables; v != NULL; v = (vector *) v->getNext ()) {
    if (v->getDependencies () != NULL)
      printVariable (v, f);
    else
      printDependency (v, f);
  }

  // close file if necessary
  if (file) fclose (f);
}
Exemple #26
0
void coaxline::calcPropagation (nr_double_t frequency) {
  nr_double_t er   = getPropertyDouble ("er");
  nr_double_t mur  = getPropertyDouble ("mur");
  nr_double_t rho  = getPropertyDouble ("rho");
  nr_double_t tand = getPropertyDouble ("tand");
  nr_double_t d    = getPropertyDouble ("d");
  nr_double_t D    = getPropertyDouble ("D");
  nr_double_t ad, ac, rs;

  // check cutoff frequency
  if (frequency > fc) {
    logprint (LOG_ERROR, "WARNING: Operating frequency (%g) beyond "
	      "cutoff frequency (%g).\n", frequency, fc);
  }

  // calculate losses
  ad = M_PI / C0 * frequency * sqrt (er) * tand;
  rs = sqrt (M_PI * frequency * mur * MU0 * rho);
  ac = sqrt (er) * (1 / d + 1 / D) / log (D / d) * rs / Z0;

  // calculate propagation constants and reference impedance
  alpha = ac + ad;
  beta  = sqrt (er * mur) * 2 * M_PI * frequency / C0;
  zl = Z0 / 2 / M_PI / sqrt (er) * log (D / d);
}
Exemple #27
0
void WriteCodeW(S32 code) {
	if(!PRECOMPILING) {  
    	code = ConfirmWord(code);
		BankPutW((S16)code);
    	logprint(" %d",code);
    }
}
Exemple #28
0
void WriteCodeB(S32 code) {
	if(!PRECOMPILING) {
    	code = ConfirmChar(code);
		BankPutB((S8)code);
    	logprint(" %d",code);
    }
}
Exemple #29
0
/*
==================
MatchTargets
==================
*/
void MatchTargets (void)
{
	int		i,j;
	
	for (i=0 ; i<num_entities ; i++)
	{
		if (!entities[i].target[0])
			continue;
			
		for (j=0 ; j<num_entities ; j++)
			if (!strcmp(entities[j].targetname, entities[i].target))
			{
				entities[i].targetent = &entities[j];
				break;
			}
		if (j==num_entities)
		{
			logprint ("WARNING: entity at (%i,%i,%i) (%s) has unmatched target\n", (int)entities[i].origin[0], (int)entities[i].origin[1], (int)entities[i].origin[2], entities[i].classname);
			continue;
		}
		
// set the style on the source ent for switchable lights
		if (entities[j].style)
		{
			char	s[16];
			
			entities[i].style = entities[j].style;
			sprintf (s,"%i", entities[i].style);
			SetKeyValue (&entities[i], "style", s);
		}
	}	
}
Exemple #30
0
static void
Pwrite(int fd, void *buf, size_t size, off64_t off)
{
	if (pwrite64(fd, buf, size, off) != size)
		logprint(SC_SL_ERR | SC_EXIT_ERR, "pwrite: %s",
		    strerror(errno));
}