Exemplo n.º 1
0
TbBool load_slabdat_file(struct SlabSet *slbset, long *scount)
{
  long total;
  unsigned char *buf;
  long fsize;
  long i,k,n;
  SYNCDBG(5,"Starting");
  fsize = 2;
  buf = load_data_file_to_buffer(&fsize, FGrp_StdData, "slabs.dat");
  if (buf == NULL)
    return false;
  i = 0;
  total = lword(&buf[i]);
  i += 2;
  // Validate total amount of indices
  if ((total < 0) || (total > (fsize-2)/(9*sizeof(short))))
  {
    total = (fsize-2)/(9*sizeof(short));
    WARNMSG("Bad amount of indices in Slab Set file; corrected to %ld.",total);
  }
  if (total > *scount)
  {
    WARNMSG("Only %d slabs supported, Slab Set file has %ld.",SLABSET_COUNT,total);
    total = *scount;
  }
  for (n=0; n < total; n++)
    for (k=0; k < 9; k++)
    {
      slbset[n].col_idx[k] = lword(&buf[i]);
      i += 2;
    }
  *scount = total;
  LbMemoryFree(buf);
  return true;
}
Exemplo n.º 2
0
LLMediaImplGStreamer::
LLMediaImplGStreamer () :
	mediaData ( NULL ),
	mMediaRowbytes ( 1 ),
	mTextureFormatPrimary ( LL_MEDIA_BGRA ),
	mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ),
	mPump ( NULL ),
	mPlaybin ( NULL ),
	mVideoSink ( NULL )
#ifdef LL_GST_SOUNDSINK
	,mAudioSink ( NULL )
#endif // LL_GST_SOUNDSINK
{
	DEBUGMSG("constructing media...");

	setMediaDepth(4);

	// Create a pumpable main-loop for this media
	mPump = g_main_loop_new (NULL, FALSE);
	if (!mPump)
	{
		return; // error
	}

	// instantiate a playbin element to do the hard work
	mPlaybin = llgst_element_factory_make ("playbin", "play");
	if (!mPlaybin)
	{
		// todo: cleanup pump
		return; // error
	}

	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
		// instantiate and connect a custom video sink
		mVideoSink =
			GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
		if (!mVideoSink)
		{
			WARNMSG("Could not instantiate private-slvideo element.");
			// todo: cleanup.
			return; // error
		}

		g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);

#ifdef LL_GST_SOUNDSINK
		// instantiate and connect a custom audio sink
		mAudioSink =
			GST_SLSOUND(llgst_element_factory_make ("private-slsound", "slsound"));
		if (!mAudioSink)
		{
			WARNMSG("Could not instantiate private-slsound element.");
			// todo: cleanup.
			return; // error
		}

		g_object_set(mPlaybin, "audio-sink", mAudioSink, NULL);
#endif
	}
}
Exemplo n.º 3
0
TbBool load_slabclm_file(struct Column *cols, long *ccount)
{
  long total;
  unsigned char *buf;
  long fsize;
  long i,k;
  SYNCDBG(18,"Starting");
  fsize = 4;
  buf = load_data_file_to_buffer(&fsize, FGrp_StdData, "slabs.clm");
  if (buf == NULL)
    return false;
  i = 0;
  total = llong(&buf[i]);
  i += 4;
  // Validate total amount of columns
  if ((total < 0) || (total > (fsize-4)/sizeof(struct Column)))
  {
    total = (fsize-4)/sizeof(struct Column);
    WARNMSG("Bad amount of columns in Column Set file; corrected to %ld.",total);
  }
  if (total > *ccount)
  {
    WARNMSG("Only %d columns supported, Column Set file has %ld.",*ccount,total);
    total = *ccount;
  }
  for (k=0; k < total; k++)
  {
    LbMemoryCopy(&cols[k],&buf[i],sizeof(struct Column));
    i += sizeof(struct Column);
  }
  *ccount = total;
  LbMemoryFree(buf);
  return true;
}
Exemplo n.º 4
0
/**
 * Saves the game state file (savegame).
 * @note fill_game_catalogue_entry() should be called before to fill level information.
 *
 * @param slot_num
 * @return
 */
TbBool save_game(long slot_num)
{
    char *fname;
    TbFileHandle handle;
    if (!save_game_save_catalogue())
        return false;
/*  game.version_major = VersionMajor;
    game.version_minor = VersionMinor;
    game.load_restart_level = get_loaded_level_number();*/
    fname = prepare_file_fmtpath(FGrp_Save, saved_game_filename, slot_num);
    handle = LbFileOpen(fname,Lb_FILE_MODE_NEW);
    if (handle == -1)
    {
        WARNMSG("Cannot open file to save, \"%s\".",fname);
        return false;
    }
    if (!save_game_chunks(handle,&save_game_catalogue[slot_num]))
    {
        LbFileClose(handle);
        WARNMSG("Cannot write to save file, \"%s\".",fname);
        return false;
    }
    LbFileClose(handle);
    return true;
}
Exemplo n.º 5
0
void initwglprocs()
   {
#ifdef _WIN32

   static int done=FALSE;

   if (!done)
      {
#ifdef GL_ARB_multitexture
      if ((glActiveTextureARB=(PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB"))==NULL ||
          (glClientActiveTextureARB=(PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB"))==NULL ||
          (glMultiTexCoord3fARB=(PFNGLMULTITEXCOORD3FARBPROC)wglGetProcAddress("glMultiTexCoord3fARB"))==NULL)
         WARNMSG("unsupported multi-texturing");
#endif

#if defined(GL_ARB_vertex_program) && defined(GL_ARB_fragment_program)
      if (glext_vp && glext_fp)
         if ((glGenProgramsARB=(PFNGLGENPROGRAMSARBPROC)wglGetProcAddress("glGenProgramsARB"))==NULL ||
             (glBindProgramARB=(PFNGLBINDPROGRAMARBPROC)wglGetProcAddress("glBindProgramARB"))==NULL ||
             (glProgramStringARB=(PFNGLPROGRAMSTRINGARBPROC)wglGetProcAddress("glProgramStringARB"))==NULL ||
             (glProgramEnvParameter4fARB=(PFNGLPROGRAMENVPARAMETER4FARBPROC)wglGetProcAddress("glProgramEnvParameter4fARB"))==NULL ||
             (glDeleteProgramsARB=(PFNGLDELETEPROGRAMSARBPROC)wglGetProcAddress("glDeleteProgramsARB"))==NULL ||
             (glGetProgramivARB=(PFNGLGETPROGRAMIVARBPROC)wglGetProcAddress("glGetProgramivARB"))==NULL)
            WARNMSG("unsupported shader programs");
#endif

      done=TRUE;
      }

#endif
   }
Exemplo n.º 6
0
TbBool load_trapdoor_config_file(const char *textname, const char *fname, unsigned short flags)
{
    char *buf;
    long len;
    TbBool result;
    SYNCDBG(0,"%s %s file \"%s\".",((flags & CnfLd_ListOnly) == 0)?"Reading":"Parsing",textname,fname);
    len = LbFileLengthRnc(fname);
    if (len < MIN_CONFIG_FILE_SIZE)
    {
        if ((flags & CnfLd_IgnoreErrors) == 0)
            WARNMSG("The %s file \"%s\" doesn't exist or is too small.",textname,fname);
        return false;
    }
    if (len > MAX_CONFIG_FILE_SIZE)
    {
        if ((flags & CnfLd_IgnoreErrors) == 0)
            WARNMSG("The %s file \"%s\" is too large.",textname,fname);
        return false;
    }
    buf = (char *)LbMemoryAlloc(len+256);
    if (buf == NULL)
        return false;
    // Loading file data
    len = LbFileLoadAt(fname, buf);
    result = (len > 0);
    // Parse blocks of the config file
    if (result)
    {
        result = parse_trapdoor_common_blocks(buf, len, textname, flags);
        if ((flags & CnfLd_AcceptPartial) != 0)
            result = true;
        if (!result)
            WARNMSG("Parsing %s file \"%s\" common blocks failed.",textname,fname);
    }
    if (result)
    {
        result = parse_trapdoor_trap_blocks(buf, len, textname, flags);
        if ((flags & CnfLd_AcceptPartial) != 0)
            result = true;
        if (!result)
            WARNMSG("Parsing %s file \"%s\" trap blocks failed.",textname,fname);
    }
    if (result)
    {
        result = parse_trapdoor_door_blocks(buf, len, textname, flags);
        if ((flags & CnfLd_AcceptPartial) != 0)
            result = true;
        if (!result)
            WARNMSG("Parsing %s file \"%s\" door blocks failed.",textname,fname);
    }
    //Freeing and exiting
    LbMemoryFree(buf);
    SYNCDBG(19,"Done");
    return result;
}
Exemplo n.º 7
0
TbBool load_column_file(LevelNumber lv_num)
{
    unsigned long i;
    long k;
    unsigned short n;
    long total;
    unsigned char *buf;
    long fsize;
    if ((game.operation_flags & GOF_ColumnConvert) != 0)
    {
        convert_old_column_file(lv_num);
        game.operation_flags &= ~GOF_ColumnConvert;
    }
    fsize = 8;
    buf = load_single_map_file_to_buffer(lv_num,"clm",&fsize,LMFF_None);
    if (buf == NULL)
      return false;
    clear_columns();
    i = 0;
    total = llong(&buf[i]);
    i += 4;
    // Validate total amount of columns
    if ((total < 0) || (total > (fsize-8)/sizeof(struct Column)))
    {
      total = (fsize-8)/sizeof(struct Column);
      WARNMSG("Bad amount of columns in CLM file; corrected to %ld.",total);
    }
    if (total > COLUMNS_COUNT)
    {
      WARNMSG("Only %d columns supported, CLM file has %ld.",COLUMNS_COUNT,total);
      total = COLUMNS_COUNT;
    }
    // Read and validate second amount
    game.field_14AB3F = llong(&buf[i]);
    if (game.field_14AB3F >= COLUMNS_COUNT)
    {
      game.field_14AB3F = COLUMNS_COUNT-1;
    }
    i += 4;
    // Fill the columns
    for (k=0; k < total; k++)
    {
        struct Column *colmn;
        colmn = &game.columns_data[k];
        LbMemoryCopy(colmn, &buf[i], sizeof(struct Column));
        //Update top cube in the column
        n = find_column_height(colmn);
        set_column_floor_filled_subtiles(colmn, n);
        i += sizeof(struct Column);
    }
    LbMemoryFree(buf);
    return true;
}
Exemplo n.º 8
0
TbBool load_slab_datclm_files(void)
{
    struct Column *cols;
    long cols_tot;
    struct SlabSet *slbset;
    long slbset_tot;
    struct SlabSet *sset;
    long i;
    SYNCDBG(5,"Starting");
    // Load Column Set
    cols_tot = COLUMNS_COUNT;
    cols = (struct Column *)LbMemoryAlloc(cols_tot*sizeof(struct Column));
    if (cols == NULL)
    {
      WARNMSG("Can't allocate memory for %d column sets.",cols_tot);
      return false;
    }
    if (!load_slabclm_file(cols, &cols_tot))
    {
      LbMemoryFree(cols);
      return false;
    }
    // Load Slab Set
    slbset_tot = SLABSET_COUNT;
    slbset = (struct SlabSet *)LbMemoryAlloc(slbset_tot*sizeof(struct SlabSet));
    if (slbset == NULL)
    {
      WARNMSG("Can't allocate memory for %d slab sets.",slbset_tot);
      return false;
    }
    if (!load_slabdat_file(slbset, &slbset_tot))
    {
      LbMemoryFree(cols);
      LbMemoryFree(slbset);
      return false;
    }
    // Update the structure
    for (i=0; i < slbset_tot; i++)
    {
        sset = &game.slabset[i];
        LbMemoryCopy(sset, &slbset[i], sizeof(struct SlabSet));
    }
    game.slabset_num = slbset_tot;
    update_columns_use(cols,cols_tot,slbset,slbset_tot);
    LbMemoryFree(slbset);
    create_columns_from_list(cols,cols_tot);
    update_slabset_column_indices(cols,cols_tot);
    LbMemoryFree(cols);
    return true;
}
Exemplo n.º 9
0
/**
 * Loads map file with given level number and file extension.
 * @return Returns NULL if the file doesn't exist or is smaller than ldsize;
 * on success, returns a buffer which should be freed after use,
 * and sets ldsize into its size.
 */
unsigned char *load_single_map_file_to_buffer(LevelNumber lvnum,const char *fext,long *ldsize,unsigned short flags)
{
  unsigned char *buf;
  char *fname;
  long fsize;
  short fgroup;
  fgroup = get_level_fgroup(lvnum);
  fname = prepare_file_fmtpath(fgroup,"map%05lu.%s",lvnum,fext);
  wait_for_cd_to_be_available();
  fsize = LbFileLengthRnc(fname);
  if (fsize < *ldsize)
  {
    if ((flags & LMFF_Optional) == 0)
      WARNMSG("Map file \"map%05lu.%s\" doesn't exist or is too small.",lvnum,fext);
    else
      SYNCMSG("Optional file \"map%05lu.%s\" doesn't exist or is too small.",lvnum,fext);
    return NULL;
  }
  if (fsize > ANY_MAP_FILE_MAX_SIZE)
  {
    if ((flags & LMFF_Optional) == 0)
      WARNMSG("Map file \"map%05lu.%s\" exceeds max size of %d; loading failed.",lvnum,fext,ANY_MAP_FILE_MAX_SIZE);
    else
      SYNCMSG("Optional file \"map%05lu.%s\" exceeds max size of %d; not loading.",lvnum,fext,ANY_MAP_FILE_MAX_SIZE);
    return NULL;
  }
  buf = LbMemoryAlloc(fsize+16);
  if (buf == NULL)
  {
    if ((flags & LMFF_Optional) == 0)
      WARNMSG("Can't allocate %ld bytes to load \"map%05lu.%s\".",fsize,lvnum,fext);
    else
      SYNCMSG("Can't allocate %ld bytes to load \"map%05lu.%s\".",fsize,lvnum,fext);
    return NULL;
  }
  fsize = LbFileLoadAt(fname,buf);
  if (fsize < *ldsize)
  {
    if ((flags & LMFF_Optional) == 0)
      WARNMSG("Reading map file \"map%05lu.%s\" failed.",lvnum,fext);
    else
      SYNCMSG("Reading optional file \"map%05lu.%s\" failed.",lvnum,fext);
    LbMemoryFree(buf);
    return NULL;
  }
  *ldsize = fsize;
  SYNCDBG(7,"Map file \"map%05lu.%s\" loaded.",lvnum,fext);
  return buf;
}
int TcpConnection::connect()
{
    dp2p_assert(fdSocket > 0);

	/* Connect. */
	const int64_t tic = Utilities::getAbsTime();
	const int retVal = ::connect(fdSocket, (struct sockaddr*)&SourceManager::get(srcId).hostAddr, sizeof(SourceManager::get(srcId).hostAddr));
	char _errBuf[1024];
	char *errBuf = strerror_r(errno, _errBuf, sizeof(_errBuf)); // get the error string
	const int64_t toc = Utilities::getAbsTime();
	DBGMSG("Spent %gs in connect().", (toc - tic) / 1e6);
	if(retVal) {
		WARNMSG("Could not connect to %s. Error in connect(): %s", SourceManager::get(srcId).hostName.c_str(), errBuf);
		return 1;
	}

	/* Allocate buffer for reading from the socket */
	recvBuf = new char[recvBufSize];
	dp2p_assert(recvBuf);

	//++ numConnectEvents;
	numReqsCompleted = 0;
	if(SourceManager::get(srcId).keepAliveTimeout != -1)
		keepAliveTimeoutNext = Utilities::getAbsTime() + SourceManager::get(srcId).keepAliveTimeout;

	updateTcpInfo();
	dp2p_assert(lastTcpInfo.tcpi_state == TCP_ESTABLISHED);
	keepAliveMaxRemaining = SourceManager::get(srcId).keepAliveMax;

	const pair<int,int> socketBufferLengths = this->getSocketBufferLengths();
	DBGMSG("Socket snd buf size: %d, socket rcv buf size: %d.", socketBufferLengths.first,socketBufferLengths.second);

	return 0;
}
Exemplo n.º 11
0
/**file main.cpp
 *@brief a main function for QMC simulation. 
 *Actual works are done by QMCApps and its derived classe.
 *For other simulations, one can derive a class from QMCApps, similarly to MolecuApps.
 *
 *Only requirements are the constructor and init function to initialize.
 */
int main(int argc, char **argv) {

  OHMMS::Controller->initialize(argc,argv);

  OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext());

  ohmmsqmc::MolecuApps qmc(argc,argv);

  if(argc>1) {
    // build an XML tree from a the file;
    xmlDocPtr m_doc = xmlParseFile(argv[1]);
    if (m_doc == NULL) {
      ERRORMSG("File " << argv[1] << " is invalid")
      xmlFreeDoc(m_doc);
      return 1;
    }    
    // Check the document is of the right kind
    xmlNodePtr cur = xmlDocGetRootElement(m_doc);
    if (cur == NULL) {
      ERRORMSG("Empty document");
      xmlFreeDoc(m_doc);
      return 1;
    }
    qmc.run(cur);
  } else {
    WARNMSG("No argument is given. Assume that  does not need an input file")
    qmc.run(NULL);
  }
  LOGMSG("Bye")
  OHMMS::Controller->finalize();
  return 0;
}
Exemplo n.º 12
0
short load_map_slab_file(unsigned long lv_num)
{
    SYNCDBG(7,"Starting");
    struct SlabMap *slb;
    unsigned long x,y;
    unsigned char *buf;
    unsigned long i;
    unsigned long n;
    long fsize;
    fsize = 2*map_tiles_y*map_tiles_x;
    buf = load_single_map_file_to_buffer(lv_num,"slb",&fsize,LMFF_None);
    if (buf == NULL)
      return false;
    i = 0;
    for (y=0; y < map_tiles_y; y++)
      for (x=0; x < map_tiles_x; x++)
      {
        slb = get_slabmap_block(x,y);
        n = lword(&buf[i]);
        if (n > SLAB_TYPES_COUNT)
        {
          WARNMSG("Slab Type %d exceeds limit of %d",(int)n,SLAB_TYPES_COUNT);
          n = SlbT_ROCK;
        }
        slb->kind = n;
        i += 2;
      }
    LbMemoryFree(buf);
    initialise_map_collides();
    initialise_map_health();
    initialise_extra_slab_info(lv_num);
    return true;
}
Exemplo n.º 13
0
void MCWalkerConfiguration::resize(int numWalkers, int numPtcls) {

  WARNMSG("MCWalkerConfiguration::resize cleans up the walker list.")

  ParticleSet::resize(unsigned(numPtcls));

  int dn=numWalkers-WalkerList.size();
  if(dn>0) createWalkers(dn);

  if(dn<0) {
    int nw=-dn;
    if(nw<WalkerList.size())  {
      iterator it = WalkerList.begin();
      while(nw) {
        delete *it; ++it; --nw;
      }
      WalkerList.erase(WalkerList.begin(),WalkerList.begin()-dn);
    }
  }
  //iterator it = WalkerList.begin();
  //while(it != WalkerList.end()) {
  //  delete *it++;
  //}
  //WalkerList.erase(WalkerList.begin(),WalkerList.end());
  //R.resize(np);
  //GlobalNum = np;
  //createWalkers(nw);  
}
Exemplo n.º 14
0
bool ParticleParser::put(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur)
{
  if(xmlHasProp(cur, (const xmlChar *) "file"))
  {
    const char* fname
    =(const char*)(xmlGetProp(cur, (const xmlChar *) "file"));
    string pformat = getExtension(fname);
    if(pformat == "xml")
    {
      XMLParticleParser aHandle(ref_);
      return  aHandle.put(fname);
    }
    else
    {
      WARNMSG("Using old formats")
      ifstream fin(fname);
      if(fin)
      {
        ParticleInputFactory::createParticle(ref_,fin);
      }
      else
      {
        ERRORMSG("File " << fname << "is not found.");
      }
      return true;
    }
  }
  XMLParticleParser aHandle(ref_);
  aHandle.put(doc,ns,cur);
  return false;
}
bool
MediaPluginGStreamer010::load()
{
	if (!mDoneInit)
		return false; // error

	setStatus(STATUS_LOADING);

	DEBUGMSG("setting up media...");

	mIsLooping = false;
	mVolume = (float) 0.1234567; // minor hack to force an initial volume update

	// Create a pumpable main-loop for this media
	mPump = g_main_loop_new (NULL, FALSE);
	if (!mPump)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// instantiate a playbin element to do the hard work
	mPlaybin = gst_element_factory_make ("playbin", "play");
	if (!mPlaybin)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}

	// get playbin's bus
	GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
	if (!bus)
	{
		setStatus(STATUS_ERROR);
		return false; // error
	}
	mBusWatchID = gst_bus_add_watch (bus,
					   llmediaimplgstreamer_bus_callback,
					   this);
	gst_object_unref (bus);

	if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
		// instantiate a custom video sink
		mVideoSink =
			GST_SLVIDEO(gst_element_factory_make ("private-slvideo", "slvideo"));
		if (!mVideoSink)
		{
			WARNMSG("Could not instantiate private-slvideo element.");
			// todo: cleanup.
			setStatus(STATUS_ERROR);
			return false; // error
		}

		// connect the pieces
		g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
	}

	return true;
}
Exemplo n.º 16
0
///////////////////////////////////////////////////////////////////////////////
// (static) super-initialization - called once at application startup
bool
LLMediaImplGStreamer::
startup ( LLMediaManagerData* init_data )
{
	static bool done_init = false;
	if (!done_init)
	{
		// Init the glib type system - we need it.
		g_type_init();

		// Get symbols!
		if (! grab_gst_syms("libgstreamer-0.10.so.0",
				    "libgstvideo-0.10.so.0",
				    "libgstaudio-0.10.so.0") )
		{
			WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled.");
			return false;
		}

		if (llgst_segtrap_set_enabled)
			llgst_segtrap_set_enabled(FALSE);
		else
			WARNMSG("gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart.");

		// Protect against GStreamer resetting the locale, yuck.
		static std::string saved_locale;
		saved_locale = setlocale(LC_ALL, NULL);
		if (0 == llgst_init_check(NULL, NULL, NULL))
		{
			WARNMSG("GST init failed for unspecified reason.");
			setlocale(LC_ALL, saved_locale.c_str() );
			return false;
		}
		setlocale(LC_ALL, saved_locale.c_str() );
		
		// Init our custom plugins - only really need do this once.
		gst_slvideo_init_class();
#if 0
		gst_slsound_init_class();
#endif

		done_init = true;
	}

	return true;
}
Exemplo n.º 17
0
SOM_Scope void  SOMLINK ODDocumentSetName(ODDocument *somSelf, Environment *ev,
		ODDocumentName* name)
{
    /* ODDocumentData *somThis = ODDocumentGetData(somSelf); */
    ODDocumentMethodDebug("ODDocument","ODDocumentSetName");

	WARNMSG(WARN_INDEX(AMSG_690),"A subclass should have overridden this method!");
	ODSetSOMException(ev,kODErrSubClassResponsibility, "SubClass Responsibility");
}
Exemplo n.º 18
0
SOM_Scope ODContainer*  SOMLINK ODDocumentGetContainer(ODDocument *somSelf, Environment *ev)
{
    /* ODDocumentData *somThis = ODDocumentGetData(somSelf); */
    ODDocumentMethodDebug("ODDocument","ODDocumentGetContainer");

	WARNMSG(WARN_INDEX(AMSG_690),"A subclass should have overridden this method!");
	ODSetSOMException(ev,kODErrSubClassResponsibility, "SubClass Responsibility");
	return kODNULL;
}
Exemplo n.º 19
0
long load_static_light_file(unsigned long lv_num)
{
    unsigned long i;
    long k;
    long total;
    unsigned char *buf;
    struct InitLight ilght;
    long fsize;
    fsize = 4;
    buf = load_single_map_file_to_buffer(lv_num,"lgt",&fsize,LMFF_Optional);
    if (buf == NULL)
        return false;
    light_initialise();
    i = 0;
    total = llong(&buf[i]);
    i += 4;
    // Validate total amount of lights
    if ((total < 0) || (total > (fsize-4)/sizeof(struct InitLight)))
    {
        total = (fsize-4)/sizeof(struct InitLight);
        WARNMSG("Bad amount of static lights in LGT file; corrected to %ld.",total);
    }
    if (total >= LIGHTS_COUNT)
    {
        WARNMSG("Only %d static lights supported, LGT file has %ld.",LIGHTS_COUNT,total);
        total = LIGHTS_COUNT-1;
    } else
    if (total >= LIGHTS_COUNT/2)
    {
        WARNMSG("More than %d%% of light slots used by static lights.",100*total/LIGHTS_COUNT);
    }
    // Create the lights
    for (k=0; k < total; k++)
    {
        LbMemoryCopy(&ilght, &buf[i], sizeof(struct InitLight));
        if (light_create_light(&ilght) == 0)
        {
            WARNLOG("Couldn't allocate static light %d",(int)k);
        }
        i += sizeof(struct InitLight);
    }
    LbMemoryFree(buf);
    return true;
}
Exemplo n.º 20
0
SOM_Scope ODDocument*  SOMLINK ODDocumentReleaseDraft(ODDocument *somSelf, Environment *ev,
		ODDraft* draft)
{
    /* ODDocumentData *somThis = ODDocumentGetData(somSelf); */
    ODDocumentMethodDebug("ODDocument","ODDocumentReleaseDraft");

	WARNMSG(WARN_INDEX(AMSG_690),"A subclass should have overridden this method!");
	ODSetSOMException(ev,kODErrSubClassResponsibility, "SubClass Responsibility");
	return somSelf;
}
void TcpConnection::disconnect()
{
    if(fdSocket > 0) {
        if(shutdown(fdSocket, SHUT_RDWR)) {
            char _errBuf[1024];
            char *errBuf = strerror_r(errno, _errBuf, sizeof(_errBuf)); // get the error string
            WARNMSG("Could not propertly shutdown() socket to %s: %s.", SourceManager::get(srcId).hostName.c_str(), errBuf);
        }
        if(close(fdSocket)) {
            char _errBuf[1024];
            char *errBuf = strerror_r(errno, _errBuf, sizeof(_errBuf)); // get the error string
            WARNMSG("Could not propertly close() socket to %s: %s.", SourceManager::get(srcId).hostName.c_str(), errBuf);
        }
        fdSocket = -2;
    }

    delete [] recvBuf;
    recvBuf = nullptr;
}
Exemplo n.º 22
0
bool clsYarp::initPortRcv(char* portRcv,char *portSend, char* protocol)
{
	if(!initPort(portRcv))
	{
	        WARNMSG(("Failed to initPort %s",portRcv));
		return false;
	}
	
	return connectPort(portSend,portRcv,protocol);
}
Exemplo n.º 23
0
/**
 * Searches levels folder for LOF files and adds them to campaign levels list.
 */
TbBool find_and_load_lof_files(void)
{
    struct TbFileFind fileinfo;
    unsigned char *buf;
    char *fname;
    short result;
    int rc;
    long i;
    SYNCDBG(16,"Starting");
    buf = LbMemoryAlloc(MAX_LIF_SIZE);
    if (buf == NULL)
    {
      ERRORLOG("Can't allocate memory for .LOF files parsing.");
      return false;
    }
    result = false;
    fname = prepare_file_path(FGrp_VarLevels,"*.lof");
    rc = LbFileFindFirst(fname, &fileinfo, 0x21u);
    while (rc != -1)
    {
        fname = prepare_file_path(FGrp_VarLevels,fileinfo.Filename);
        i = LbFileLength(fname);
        if ((i < 0) || (i >= MAX_LIF_SIZE))
        {
          WARNMSG("File '%s' too long (Max size %d)", fileinfo.Filename, MAX_LIF_SIZE);

        } else
        if (LbFileLoadAt(fname, buf) != i)
        {
          WARNMSG("Unable to read .LOF file, '%s'", fileinfo.Filename);
        } else
        {
          buf[i] = '\0';
          if (level_lof_file_parse(fileinfo.Filename, (char *)buf, i))
            result = true;
        }
        rc = LbFileFindNext(&fileinfo);
    }
    LbFileFindEnd(&fileinfo);
    LbMemoryFree(buf);
    return result;
}
Exemplo n.º 24
0
int buildprog(const char *prog,bool vtxorfrg)
   {
   GLuint progid=0;

#if defined(GL_ARB_vertex_program) && defined(GL_ARB_fragment_program)
   GLint errorPos,isNative;

   glGenProgramsARB(1,&progid);

   if (vtxorfrg)
      {
      glBindProgramARB(GL_VERTEX_PROGRAM_ARB,progid);
      glProgramStringARB(GL_VERTEX_PROGRAM_ARB,GL_PROGRAM_FORMAT_ASCII_ARB,strlen(prog),prog);
      }
   else
      {
      glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,progid);
      glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,GL_PROGRAM_FORMAT_ASCII_ARB,strlen(prog),prog);
      }

   glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB,&errorPos);
   glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB,&isNative);

   if (errorPos==0)
      {
      WARNMSG("shader programs unavailable");
      WARNMSG((char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
      ERRORMSG();
      }
   else
      {
      if (errorPos!=-1)
         {
         WARNMSG((char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
         ERRORMSG();
         }
      if (isNative!=1) WARNMSG("shader program non-native");
      }
#endif

   return(progid);
   }
Exemplo n.º 25
0
SOM_Scope ODBoolean  SOMLINK ODDocumentExists(ODDocument *somSelf, Environment *ev,
		ODDraftID id,
		ODDraft* draft,
		ODPositionCode posCode)
{
    /* ODDocumentData *somThis = ODDocumentGetData(somSelf); */
    ODDocumentMethodDebug("ODDocument","ODDocumentAcquireDraft");

	WARNMSG(WARN_INDEX(AMSG_690),"A subclass should have overridden this method!");
	ODSetSOMException(ev,kODErrSubClassResponsibility, "SubClass Responsibility");
	return kODFalse;
}
Exemplo n.º 26
0
bool clsYarp::checkYarp()
{
	if(!yarpInitiated){
		usleep(100);
		#ifdef REQUIRE_YARP
		ERRMSG(("yarp failed to initialize"));
		#else
		WARNMSG(("yarp failed to initialize"));
		#endif
	}
	return yarpInitiated;
}
Exemplo n.º 27
0
bool clsYarp::connectPort(char *portIn,char *portOut, char *protocol)
{
	portIsOK = yarp::os::Network::connect(portIn,portOut,protocol);
	
	if(!portIsOK)
	{
	        WARNMSG(("failed to connect %s to %s with %s",portIn,portOut,protocol));
	        return false;
	}
	INFOMSG(("connected %s to %s with %s",portIn,portOut,protocol));
	return true;
}
Exemplo n.º 28
0
TbBool load_action_point_file(LevelNumber lv_num)
{
  struct InitActionPoint iapt;
  unsigned long i;
  long k;
  long total;
  unsigned char *buf;
  long fsize;
  SYNCDBG(5,"Starting");
  fsize = 4;
  buf = load_single_map_file_to_buffer(lv_num,"apt",&fsize,LMFF_None);
  if (buf == NULL)
    return false;
  i = 0;
  total = llong(&buf[i]);
  i += 4;
  // Validate total amount of action points
  if ((total < 0) || (total > (fsize-4)/sizeof(struct InitActionPoint)))
  {
    total = (fsize-4)/sizeof(struct InitActionPoint);
    WARNMSG("Bad amount of action points in APT file; corrected to %ld.",total);
  }
  if (total > ACTN_POINTS_COUNT-1)
  {
    WARNMSG("Only %d action points supported, APT file has %ld.",ACTN_POINTS_COUNT-1,total);
    total = ACTN_POINTS_COUNT-1;
  }
  // Create action points
  for (k=0; k < total; k++)
  {
    LbMemoryCopy(&iapt, &buf[i], sizeof(struct InitActionPoint));
    if (actnpoint_create_actnpoint(&iapt) == INVALID_ACTION_POINT)
    {
      ERRORLOG("Cannot allocate action point %d during APT load",k);
    }
    i += sizeof(struct InitActionPoint);
  }
  LbMemoryFree(buf);
  return true;
}
Exemplo n.º 29
0
SOM_Scope ODDocumentName  SOMLINK ODDocumentGetName(ODDocument *somSelf, Environment *ev)
{
    /* ODDocumentData *somThis = ODDocumentGetData(somSelf); */
    ODDocumentMethodDebug("ODDocument","ODDocumentGetName");

	WARNMSG(WARN_INDEX(AMSG_690),"A subclass should have overridden this method!");
	ODSetSOMException(ev,kODErrSubClassResponsibility, "SubClass Responsibility");
	
	// The following two lines are used to pacify the compiler.
	// They should never be executed.
	ODDocumentName	name;
	return name;
}
Exemplo n.º 30
0
bool grab_pa_syms(std::string pulse_dso_name)
{
	if (sSymsGrabbed)
	{
		// already have grabbed good syms
		return true;
	}

	bool sym_error = false;
	bool rtn = false;
	apr_status_t rv;
	apr_dso_handle_t *sSymPADSOHandle = NULL;

#define LL_PA_SYM(REQUIRED, PASYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##PASYM, sSymPADSOHandle, #PASYM); if (rv != APR_SUCCESS) {INFOMSG("Failed to grab symbol: %s", #PASYM); if (REQUIRED) sym_error = true;} else DEBUGMSG("grabbed symbol: %s from %p", #PASYM, (void*)ll##PASYM);}while(0)

	//attempt to load the shared library
	apr_pool_create(&sSymPADSOMemoryPool, NULL);
  
	if ( APR_SUCCESS == (rv = apr_dso_load(&sSymPADSOHandle,
					       pulse_dso_name.c_str(),
					       sSymPADSOMemoryPool) ))
	{
		INFOMSG("Found DSO: %s", pulse_dso_name.c_str());

#include "linux_volume_catcher_pa_syms.inc"
#include "linux_volume_catcher_paglib_syms.inc"
      
		if ( sSymPADSOHandle )
		{
			sSymPADSOHandleG = sSymPADSOHandle;
			sSymPADSOHandle = NULL;
		}
      
		rtn = !sym_error;
	}
	else
	{
		INFOMSG("Couldn't load DSO: %s", pulse_dso_name.c_str());
		rtn = false; // failure
	}

	if (sym_error)
	{
		WARNMSG("Failed to find necessary symbols in PulseAudio libraries.");
	}
#undef LL_PA_SYM

	sSymsGrabbed = rtn;
	return rtn;
}