예제 #1
0
bool DisplayResource::load(void)
{
#ifdef ALLEGRO_IPHONE
   int flags = ALLEGRO_FULLSCREEN_WINDOW;
   al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS, ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE, ALLEGRO_REQUIRE);
#else
   int flags = useFullScreenMode ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED;
#endif
   al_set_new_display_flags(flags);
   display = al_create_display(BB_W, BB_H);
   if (!display)
       return false;

#ifndef ALLEGRO_IPHONE
   ALLEGRO_BITMAP *bmp = al_load_bitmap(getResource("gfx/icon48.png"));
   al_set_display_icon(display, bmp);
   al_destroy_bitmap(bmp);
#endif

   BB_W = al_get_display_width(display);
   BB_H = al_get_display_height(display);
   
#ifdef ALLEGRO_IPHONE
   if (BB_W < 960) {
	BB_W *= 2;
	BB_H *= 2;
	ALLEGRO_TRANSFORM t;
	al_identity_transform(&t);
	al_scale_transform(&t, 0.5, 0.5);
	al_use_transform(&t);
   }
#endif
      
   events = al_create_event_queue();
   al_register_event_source(events, al_get_display_event_source(display));

   return true;
}
예제 #2
0
FUNCTION int Q4Y7(int Q5NY, int Q4HG, list Q65O)
{
  int Q4GW = hasObjVar(this, "debugSkillInfo");
  while(numInList(Q65O))
  {
    setArrayIntElem(0x00, 0x00, Q5NY, Q65O[0x00]);
    setArrayIntElem(0x00, 0x03, Q5NY, Q4HG);
    obj Q61Z = createNoResObjectAt(Q65O[0x00], getLocation(this));
    int Q571 = 0x00;
    int Q4Q1 = getResource(Q571, Q61Z, "metal", 0x03, 0x00);
    setArrayIntElem(0x00, 0x04, Q5NY, Q571);
    int val;
    if(isReallyWeapon(Q61Z))
    {
      val = Q571 + (getWeaponSpeed(Q61Z) * getAverageDamage(Q61Z) / 0x0C);
    }
    else
    {
      val = Q571 + (getMaxArmorClass(Q61Z) * 0x02);
    }
    setArrayIntElem(0x00, 0x05, Q5NY, val);
    string description = getNameByType(Q65O[0x00]);
    toUpper(description, 0x00, 0x01);
    if(Q4GW)
    {
      description = description + ". $" + val + ", " + Q571 + " metal";
    }
    else
    {
      description = "Build " + description + ", " + Q571 + " metal.";
    }
    setArrayStrElem(0x00, 0x02, Q5NY, description);
    deleteObject(Q61Z);
    removeItem(Q65O, 0x00);
    Q5NY ++;
  }
  return(Q5NY);
}
예제 #3
0
void daRamboo_c::setupModels() {
	allocator.link(-1, GameHeaps[0], 0, 0x20);

	this->resFile.data = getResource("teresa", "g3d/teresa.brres");
	bool ret;

	nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("fog");
	this->fogModel.setup(mdl, &allocator, 0x224, 1, 0);
	SetupTextures_Enemy(&this->fogModel, 0);

	nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("fog");
	ret = this->anmFog.setup(mdl, anmChr, &this->allocator, 0);


	nw4r::g3d::ResMdl mdlB = this->resFile.GetResMdl("teresaA");
	this->bodyModel.setup(mdlB, &allocator, 0x224, 1, 0);
	SetupTextures_Enemy(&this->bodyModel, 0);

	nw4r::g3d::ResAnmChr anmChrC = this->resFile.GetResAnmChr("shay_teresaA");
	ret = this->anmA.setup(mdlB, anmChrC, &this->allocator, 0);


	nw4r::g3d::ResMdl mdlC = this->resFile.GetResMdl("teresaB");
	this->hideModel.setup(mdlC, &allocator, 0x224, 1, 0);
	SetupTextures_Enemy(&this->hideModel, 0);

	nw4r::g3d::ResAnmChr anmChrE = this->resFile.GetResAnmChr("shay_teresaB");
	ret = this->anmB.setup(mdlC, anmChrE, &this->allocator, 0);

	nw4r::g3d::ResAnmTexSrt anmSrt = this->resFile.GetResAnmTexSrt("fog");
	this->resTexSrt = anmSrt;
	//setup(ResMdl mdl, ResAnmTexSrt anmSrt, mAllocator* allocator, void* NULL, int count);
	ret = this->fogSrt.setup(mdl, anmSrt, &this->allocator, 0, 1);
	//setEntryByte34(char toSet, int which);
	this->fogSrt.setEntryByte34(0, 0);

	allocator.unlink();
}
bool EntityManager_GetProperty(const EntityManager *entityManager, const char *entityName, const char *propertyName, void **data) {
  void *entity = NULL;
  ItemsHolder *propertyData;

  if (entityManager == NULL || propertyName == NULL || entityName == NULL) {
    if (Entity_TestMode == false) {
      snprintf(errStr, sizeof(errStr), "Internal error in EntityManager_GetProperty: entityManager (isNull? %d), "
                                       "property name '%s' and entityName '%s' must not be NULL\n",
               entityManager == NULL, propertyName, entityName);
      Utils_Abort(errStr);
    } else
      return false;
  }
  if (EntityManager_IsEntityInUsersList(entityManager, entityName) == true) {
    if (getUser(entityManager, entityName, &entity) == false) {
      snprintf(errStr, sizeof(errStr), "EntityManager_GetProperty: property for user '%s' was not found", entityName);
      return false;
    }
    propertyData = ((userData *)entity)->PropertiesData;
  } else if (EntityManager_IsEntityInGroupsList(entityManager, entityName) == true) {
    if (getGroup(entityManager, entityName, &entity) == true)
      propertyData = ((groupData *)entity)->PropertiesData;
    else {
      snprintf(errStr, sizeof(errStr), "EntityManager_GetProperty: property for group '%s' was not found", entityName);
      return false;
    }
  } else if (EntityManager_IsEntityInResourcesList(entityManager, entityName) == true) {
    if (getResource(entityManager, entityName, &entity) == false) {
      snprintf(errStr, sizeof(errStr), "EntityManager_GetProperty: property for resource '%s' was not found", entityName);
      return false;
    }
    propertyData = ((resourceData *)entity)->PropertiesData;
  } else {
    snprintf(errStr, sizeof(errStr), "EntityManager_GetProperty: entityName is not in entity list");
    return false;
  }
  return getProperty(propertyData, propertyName, data);
}
예제 #5
0
void MohawkEngine_Riven::loadCard(uint16 id) {
	// NOTE: The card scripts are cleared by the RivenScriptManager automatically.

	Common::SeekableReadStream* inStream = getResource(ID_CARD, id);

	_cardData.name = inStream->readSint16BE();
	_cardData.zipModePlace = inStream->readUint16BE();
	_cardData.scripts = _scriptMan->readScripts(inStream);
	_cardData.hasData = true;

	delete inStream;

	if (_cardData.zipModePlace) {
		Common::String cardName = getName(CardNames, _cardData.name);
		if (cardName.empty())
			return;
		ZipMode zip;
		zip.name = cardName;
		zip.id = id;
		if (!(Common::find(_zipModeData.begin(), _zipModeData.end(), zip) != _zipModeData.end()))
			_zipModeData.push_back(zip);
	}
}
예제 #6
0
byte *TLib::getSubResource(int resNum, int rlbNum, int index, uint *size, bool suppressErrors) {
	// Get the specified image set
	byte *dataIn = getResource(RES_VISAGE, resNum, rlbNum);
	if (!dataIn) {
		if (suppressErrors)
			return NULL;

		error("Unknown sub resource %d/%d index %d", resNum, rlbNum, index);
	}

	int numEntries = READ_LE_UINT16(dataIn);
	uint32 entryOffset = READ_LE_UINT32(dataIn + 2 + (index - 1) * 4);
	uint32 nextOffset = (index == numEntries) ?
			_memoryManager.getSize(dataIn) : READ_LE_UINT32(dataIn + 2 + index * 4);
	*size = nextOffset - entryOffset;
	assert(*size < (1024 * 1024));

	byte *entry = _memoryManager.allocate2(*size);
	Common::copy(&dataIn[entryOffset], &dataIn[nextOffset], entry);

	_memoryManager.deallocate(dataIn);
	return entry;
}
void ArrivalPaxLandsideBehavior::ProcessGetOnVehicle( const ElapsedTime& eEventTime )
{
	WriteLogEntry(eEventTime);

	setState(StayOnVehicle);
	WriteLogEntry(eEventTime);

	//Notify vehicle that one passenger has moved into
	//
	LandsideVehicleInSim* pVehicle = getVehicle();
	if(pVehicle)
	{	
		if(LandsideResourceInSim* pRes = getResource())
		{
			pRes->PassengerMoveOut(this,eEventTime);
		}
		pVehicle->AddOnPax(this);
		pVehicle->NotifyPaxMoveInto(m_pPerson->getEngine(),this, eEventTime);
	}
	else
	{
		ASSERT(FALSE);
	}
}
예제 #8
0
void startMusic(const char* name)
{
	char resName[1000];
	strcpy(resName, getResource("music/%s", name));

	int music_size = music.size();
	int music_end = music_size-1;

	if (music_size != 0 && music[music_end] && !strcmp(music[music_end]->filename, resName)) {
		return;
	}

	LOGG_Stream* s = logg_get_stream(resName, config.getMusicVolume(), 128, 1);

	if (music_size == 0) {
		music.push_back(s);
	}
	else {
		if (music[music_end]) {
			logg_destroy_stream(music[music_end]);
		}
		music[music_end] = s;
	}
}
예제 #9
0
DECLARE_EXPORT LoadPlan::~LoadPlan()
{
  getResource()->setChanged();
  LoadPlan *prevldplan = NULL;
  if (!isStart() && oper->getOperation() == OperationSetup::setupoperation)
  {
    for (TimeLine<LoadPlan>::const_iterator i = getResource()->getLoadPlans().begin(isStart() ? getOtherLoadPlan() : this);
        i != getResource()->getLoadPlans().end(); --i)
    {
      const LoadPlan *l = dynamic_cast<const LoadPlan*>(&*i);
      if (l && l->getOperationPlan() != getOperationPlan()
          && l->getOperationPlan() != getOperationPlan()->getOwner()
          && !l->isStart())
      {
        prevldplan = const_cast<LoadPlan*>(l);
        break;
      }
    }
    if (!prevldplan)
    {
      for (TimeLine<LoadPlan>::const_iterator i = getResource()->getLoadPlans().begin(isStart() ? getOtherLoadPlan() : this);
          i != getResource()->getLoadPlans().end(); ++i)
      {
        const LoadPlan *l = dynamic_cast<const LoadPlan*>(&*i);
        if (l && l->getOperationPlan() != getOperationPlan()
            && l->getOperationPlan() != getOperationPlan()->getOwner()
            && !l->isStart())
        {
          prevldplan = const_cast<LoadPlan*>(l);
          break;
        }
      }
    }
  }
  getResource()->loadplans.erase(this);
  if (prevldplan) getResource()->updateSetups(prevldplan);
}
예제 #10
0
파일: ore.m.C 프로젝트: Grimoric/UODEMO
TRIGGER( targetobj )(obj user, obj usedon)
{
  removeObjVar(this, "inUse");
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(getDistanceInTiles(getLocation(user), getLocation(usedon)) > 0x03)
  {
    systemMessage(user, "That is too far away.");
    return(0x00);
  }
  if(getDistanceInTiles(getLocation(this), getLocation(usedon)) > 0x03)
  {
    systemMessage(user, "The ore is too far away.");
    return(0x00);
  }
  if(!canSeeObj(user, usedon))
  {
    systemMessage(user, "You can't see that.");
    return(0x00);
  }
  int Q4Q1;
  int Q4YO;
  Q4Q1 = getResource(Q4YO, this, "metal", 0x03, 0x02);
  int Q4Z5 = 0x00;
  int Q4ZU = 0x00;
  obj ore = this;
  int Q62A = getObjType(this);
  int Q66P = getObjType(usedon);
  if(Q66P == 0x0FB1)
  {
    Q4Z5 = 0x01;
  }
  if(Q66P >= 0x197A)
  {
    if(Q66P <= 0x19A9)
    {
      Q4Z5 = 0x01;
    }
  }
  if(Q66P > 0x19B6)
  {
    if(Q66P < 0x19BB)
    {
      Q4ZU = 0x01;
      if(isInContainer(this))
      {
        obj Q61O = getTopmostContainer(this);
        int Q62E = getWeight(Q61O) + getWeight(usedon);
      }
      if(isInContainer(usedon))
      {
        obj Q66Q = getTopmostContainer(usedon);
        int Q66T = getWeight(Q66Q) + getWeight(this);
      }
      if((Q62E > 0x03E8) || (Q66T > 0x03E8))
      {
        ebarkTo(user, user, "The weight is too great to combine in a container.");
        return(0x00);
      }
    }
  }
  if(Q4ZU)
  {
    ore = this;
    if(Q62A == 0x19B9)
    {
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      transferResources(usedon, ore, Q4YO, "metal");
    }
    if(Q62A == 0x19B8)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    if(Q62A == 0x19BA)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    if(Q62A == 0x19B7)
    {
      switch(Q66P)
      {
      case 0x19B9:
      case 0x19B8:
      case 0x19BA:
        Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
        transferResources(ore, usedon, Q4YO, "metal");
        break;
      case 0x19B7:
        Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
        transferResources(usedon, ore, Q4YO, "metal");
        break;
      default:
        return(0x00);
        break;
      }
    }
    Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
    if(Q4YO < 0x01)
    {
      deleteObject(ore);
    }
    Q4Q1 = getResource(Q4YO, usedon, "metal", 0x03, 0x02);
    if(Q4YO < 0x01)
    {
      deleteObject(usedon);
    }
    if(hasObjVar(this, "inUse"))
    {
      removeObjVar(this, "inUse");
    }
    return(0x00);
  }
  if(Q4Z5)
  {
    obj Q47G = getBackpack(user);
    ore = this;
    int Q5GQ = getObjType(ore);
    int Q4Y6 = 0x1BF2;
    Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
    int count = Q4YO / 0x02;
    if(count < 0x01)
    {
      systemMessage(user, "There is not enough metal-bearing ore in this pile to make an ingot.");
      if(hasObjVar(this, "inUse"))
      {
        removeObjVar(this, "inUse");
      }
      return(0x00);
    }
    if(testSkill(user, 0x2D))
    {
      obj Q5BW = createNoResObjectIn(Q4Y6, Q47G);
      transferResources(Q5BW, ore, count, "metal");
      returnResourcesToBank(ore, count, "metal");
      Q4Q1 = putObjContainer(Q5BW, Q47G);
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      if(Q4YO < 0x01)
      {
        deleteObject(ore);
      }
      systemMessage(user, "You smelt the ore removing the impurities and put the metal in your backpack.");
    }
    else
    {
      if(count == 0x01)
      {
        systemMessage(user, "You burn away the impurities but are left with no useable metal.");
        deleteObject(ore);
        return(0x01);
      }
      returnResourcesToBank(ore, count, "metal");
      systemMessage(user, "You burn away the impurities but are left with less useable metal.");
      Q4Q1 = getResource(Q4YO, ore, "metal", 0x03, 0x02);
      if(Q4YO < 0x01)
      {
        deleteObject(ore);
      }
    }
  }
  return(0x01);
}
void* ResourceManager::getData(int index)
{
   return getResource(index)->get();
}
예제 #12
0
	bool MaterialManager::initialize(std::vector<std::string> filenames) {
		for(unsigned int i=0; i<filenames.size(); i++)
			getResource(filenames[i]);
		return true;
	}
예제 #13
0
const sf::Texture& ResourceManager::getTexture(const std::string& filename) {
    return getResource(filename, this -> textures);
}
예제 #14
0
	ITexture2D* IRenderSystem::getTexture( ResID id )
	{
		ResBase* res = getResource( id );
		assert( res == NULL || res->getType() == RES_IMAGE );
		return static_cast< ITexture2D* >( res );
	}
예제 #15
0
	inline void unload(const std::string& identifier) { getResource(identifier).unload(); }
	SFObjectModel::SFObjectModel() {
		setModel(new SFModel());
		getResource()->setResource(0, getModel()->getTransformComponent().getResource());
		getResource()->setResource(1, getModel()->getMaterialComponent().getResource());
	}
예제 #17
0
	Mesh* MeshManager::getMesh(const string& name) const
	{
		return (Mesh*)getResource(name);
	}
예제 #18
0
void PreviewWorker::prepare() {
	m_scene = static_cast<Scene *>(getResource("scene"));
	m_kdtree = m_scene->getKDTree();
	m_shapes = &m_kdtree->getShapes();
}
예제 #19
0
void CaptureParticleWorker::prepare() {
	ParticleTracer::prepare();
	m_camera = static_cast<Camera *>(getResource("camera"));
	m_isPerspectiveCamera = m_camera->getClass()->derivesFrom(MTS_CLASS(PerspectiveCamera));
	m_filter = m_camera->getFilm()->getTabulatedFilter();
}
예제 #20
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(isAtHome(usedon))
  {
    systemMessage(user, "That belongs to someone else.");
    return(0x00);
  }
  int Q62A = getObjType(this);
  int Q66P = getObjType(usedon);
  loc Q66U = loc( getLocation(user) );
  loc Q61U = loc( getLocation(this) );
  loc Q66N = loc( getLocation(usedon) );
  obj Q4EZ;
  list args;
  if(testAndLearnSkill(user, 0x08, 0x00, 0x50) > 0x00)
  {
    switch(Q62A)
    {
    case 0x1BD1:
      switch(Q66P)
      {
      case 0x1BD4:
        attachScript(user, "makingarrows");
        args = list( this, usedon );
        message(user, "makearrows", args);
        break;
      default:
        systemMessage(user, "Can't use feathers on that.");
        return(0x00);
        break;
      }
      break;
    case 0x1BD4:
      switch(Q66P)
      {
      case 0x1BD1:
        attachScript(user, "makingarrows");
        args = list( usedon, this );
        message(user, "makearrows", args);
        break;
      default:
        systemMessage(user, "Can't use shafts on that.");
        return(0x00);
        break;
      }
      break;
    default:
      return(0x00);
      break;
    }
  }
  else
  {
    systemMessage(user, "Fletching failed.");
    int Q5MT;
    int Q4Q1;
    if(!random(0x00, 0x03))
    {
      debugMessage("!rand");
      debugMessage("thistype = " + Q62A);
      if(Q62A == 0x1BD1)
      {
        systemMessage(user, "A feather was destroyed.");
        returnResourcesToBank(this, 0x01, "feathers");
        Q4Q1 = getResource(Q5MT, this, "feathers", 0x03, 0x02);
      }
      if(Q62A == 0x1BD4)
      {
        systemMessage(user, "A shaft was destroyed.");
        returnResourcesToBank(this, 0x01, "wood");
        Q4Q1 = getResource(Q5MT, this, "wood", 0x03, 0x02);
      }
      if(Q5MT < 0x01)
      {
        deleteObject(this);
      }
    }
  }
  return(0x01);
}
 bool isSerialized(const char* url, const char* mimeType = 0)
 {
     return getResource(url, mimeType);
 }
예제 #22
0
void Player_SID::handleMusicBuffer() { // $33cd
	int channel = 2;
	while (channel >= 0) {
		if ((statusBits1A & BITMASK[channel]) == 0 ||
		    (busyChannelBits & BITMASK[channel]) != 0) {
			--channel;
			continue;
		}

		if (setupSongFileData() == 1)
			return;

		uint8* l_chanFileDataPtr = chanFileData[channel];

		uint16 l_freq = 0;
		bool l_keepFreq = false;

		int y = 0;
		uint8 curByte = l_chanFileDataPtr[y++];

		// freq or 0/0xFF
		if (curByte == 0) {
			func_3674(channel);
			if (!isMusicPlaying)
				return;
			continue;
		} else if (curByte == 0xFF) {
			l_keepFreq = true;
		} else {
			l_freq = FREQ_TBL[curByte];
		}

		uint8 local1 = 0;
		curByte = l_chanFileDataPtr[y++];
		bool isLastCmdByte = (curByte & 0x80) != 0;
		uint16 curStepSum = stepTbl[curByte & 0x7f];

		for (int i = 0; !isLastCmdByte && (i < 2); ++i) {
			curByte = l_chanFileDataPtr[y++];
			isLastCmdByte = (curByte & 0x80) != 0;
			if (curByte & 0x40) {
				// note: bit used in zak theme (95) only (not used/handled in MM)
				_music_timer = curByte & 0x3f;
			} else {
				local1 = curByte & 0x3f;
			}
		}

		chanFileData[channel] += y;
		chanDataOffset[channel] += y;

		uint8 *l_chanBuf = getResource(RES_ID_CHANNEL[channel]);

		if (local1 != 0) {
			// TODO: signed or unsigned?
			uint16 offset = READ_LE_UINT16(&actSongFileData[local1*2 + 12]);
			l_chanFileDataPtr = actSongFileData + offset;

			// next five bytes: freqDelta, attack, sustain and phase bit
			for (int i = 0; i < 5; ++i) {
				l_chanBuf[15 + i] = l_chanFileDataPtr[i];
			}
			phaseBit[channel] = l_chanFileDataPtr[4];

			for (int i = 0; i < 17; ++i) {
				l_chanBuf[25 + i] = l_chanFileDataPtr[5 + i];
			}
		}

		if (l_keepFreq) {
			if (!releasePhase[channel]) {
				l_chanBuf[10] &= 0xfe; // release phase
			}
			releasePhase[channel] = true;
		} else {
			if (releasePhase[channel]) {
				l_chanBuf[19] = phaseBit[channel];
				l_chanBuf[10] |= 0x01; // attack phase
			}
			l_chanBuf[11] = LOBYTE_(l_freq);
			l_chanBuf[12] = HIBYTE_(l_freq);
			releasePhase[channel] = false;
		}

		// set counter value for frequency update (freqDeltaCounter)
		l_chanBuf[13] = LOBYTE_(curStepSum);
		l_chanBuf[14] = HIBYTE_(curStepSum);

		_soundQueue[channel] = RES_ID_CHANNEL[channel];
		processSongData(channel);
		_soundQueue[channel+4] = RES_ID_CHANNEL[channel];
		processSongData(channel+4);
		--channel;
	}
}
예제 #23
0
int Player_SID::initSound(int soundResID) { // $4D0A
	initializing = true;

	if (isMusicPlaying && (statusBits1A & 0x07) == 0x07) {
		initializing = false;
		return -2;
	}

	uint8 *songFilePtr = getResource(soundResID);
	if (songFilePtr == NULL) {
		initializing = false;
		return 1;
	}

	uint8 soundPrio = songFilePtr[4];
	// for (mostly but not always looped) background sounds
	if (soundPrio == 1) {
		bgSoundResID = soundResID;
		bgSoundActive = true;
	}

	uint8 requestedChannels = 0;
	if ((songFilePtr[5] & 0x40) == 0) {
		++requestedChannels;
		if (songFilePtr[5] & 0x02)
			++requestedChannels;
		if (songFilePtr[5] & 0x08)
			++requestedChannels;
	}

	bool filterNeeded = (songFilePtr[5] & 0x20) != 0;
	bool filterBlocked = (filterUsed && filterNeeded);
	if (filterBlocked || (freeChannelCount < requestedChannels)) {
		findLessPrioChannels(soundPrio);

		if ((freeChannelCount + chansWithLowerPrioCount < requestedChannels) ||
		    (filterBlocked && !actFilterHasLowerPrio)) {
			initializing = false;
			return -1;
		}

		if (filterBlocked) {
			if (soundPrio < chanPrio[3]) {
				initializing = false;
				return -1;
			}

			uint8 l_resID = channelMap[3];
			releaseResourceBySound(l_resID);
		}

		while ((freeChannelCount < requestedChannels) || (filterNeeded && filterUsed)) {
			findLessPrioChannels(soundPrio);
			if (minChanPrio >= soundPrio) {
				initializing = false;
				return -1;
			}

			uint8 l_resID = channelMap[minChanPrioIndex];
			releaseResourceBySound(l_resID);
		}
	}

	int x;
	uint8 soundByte5 = songFilePtr[5];
	if (soundByte5 & 0x40)
		x = reserveSoundFilter(soundPrio, soundResID);
	else
		x = reserveSoundVoice(soundPrio, soundResID);

	uint8 var4CF3 = x;
	int y = 6;
	if (soundByte5 & 0x01) {
		x += 4;
		readVec6Data(x, &y, songFilePtr, soundResID);
	}
	if (soundByte5 & 0x02) {
		x = reserveSoundVoice(soundPrio, soundResID);
		readVec6Data(x, &y, songFilePtr, soundResID);
	}
	if (soundByte5 & 0x04) {
		x += 4;
		readVec6Data(x, &y, songFilePtr, soundResID);
	}
	if (soundByte5 & 0x08) {
		x = reserveSoundVoice(soundPrio, soundResID);
		readVec6Data(x, &y, songFilePtr, soundResID);
	}
	if (soundByte5 & 0x10) {
		x += 4;
		readVec6Data(x, &y, songFilePtr, soundResID);
	}
	if (soundByte5 & 0x20) {
		x = reserveSoundFilter(soundPrio, soundResID);
		readVec6Data(x, &y, songFilePtr, soundResID);
	}

	//vec5[var4CF3] = songFilePtr;
	vec6[var4CF3] = y;
	_soundQueue[var4CF3] = soundResID;

	initializing = false;
	_soundInQueue = true;

	return soundResID;
}
예제 #24
0
void CaptureParticleWorker::prepare() {
	ParticleTracer::prepare();
	m_sensor = static_cast<Sensor *>(getResource("sensor"));
	m_rfilter = m_sensor->getFilm()->getReconstructionFilter();
}
예제 #25
0
	http_result_t getResource(const char* url)
	{
		return getResource(URL(url));
	}
예제 #26
0
    LPath *getPath( const string &pathName)
    { 
	return getResource( pathName);
    }
const Drawable* BinaryResources::getDrawable (const String& name) const
{
    if (BinaryResources::BinaryResource* const res = const_cast <BinaryResources::BinaryResource*> (getResource (name)))
    {
        if (res->drawable == nullptr && res->data.getSize() > 0)
            res->drawable = Drawable::createFromImageData (res->data.getData(),
                                                           res->data.getSize());

        return res->drawable;
    }

    return nullptr;
}
예제 #28
0
void GeometryResource::downloadFinished(const QByteArray& data) {
    if (_effectiveBaseURL.fileName().toLower().endsWith(".fst")) {
        PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryResource::downloadFinished", _url.toString(), { { "url", _url.toString() } });

        // store parsed contents of FST file
        _mapping = FSTReader::readMapping(data);

        QString filename = _mapping.value("filename").toString();

        if (filename.isNull()) {
            finishedLoading(false);
        } else {
            const QString baseURL = _mapping.value("baseURL").toString();
            const QUrl base = _effectiveBaseURL.resolved(baseURL);
            QUrl url = base.resolved(filename);

            QString texdir = _mapping.value(TEXDIR_FIELD).toString();
            if (!texdir.isNull()) {
                if (!texdir.endsWith('/')) {
                    texdir += '/';
                }
                _textureBaseURL = resolveTextureBaseUrl(url, base.resolved(texdir));
            } else {
                _textureBaseURL = url.resolved(QUrl("."));
            }

            auto scripts = FSTReader::getScripts(base, _mapping);
            if (scripts.size() > 0) {
                _mapping.remove(SCRIPT_FIELD);
                for (auto &scriptPath : scripts) {
                    _mapping.insertMulti(SCRIPT_FIELD, scriptPath);
                }
            }

            auto animGraphVariant = _mapping.value("animGraphUrl");

            if (animGraphVariant.isValid()) {
                QUrl fstUrl(animGraphVariant.toString());
                if (fstUrl.isValid()) {
                    _animGraphOverrideUrl = base.resolved(fstUrl);
                } else {
                    _animGraphOverrideUrl = QUrl();
                }
            } else {
                _animGraphOverrideUrl = QUrl();
            }

            auto modelCache = DependencyManager::get<ModelCache>();
            GeometryExtra extra { GeometryMappingPair(base, _mapping), _textureBaseURL, false };

            // Get the raw GeometryResource
            _geometryResource = modelCache->getResource(url, QUrl(), &extra, std::hash<GeometryExtra>()(extra)).staticCast<GeometryResource>();
            // Avoid caching nested resources - their references will be held by the parent
            _geometryResource->_isCacheable = false;

            if (_geometryResource->isLoaded()) {
                onGeometryMappingLoaded(!_geometryResource->getURL().isEmpty());
            } else {
                if (_connection) {
                    disconnect(_connection);
                }

                _connection = connect(_geometryResource.data(), &Resource::finished, this, &GeometryResource::onGeometryMappingLoaded);
            }
        }
    } else {
        if (_url != _effectiveBaseURL) {
            _url = _effectiveBaseURL;
            _textureBaseURL = _effectiveBaseURL;
        }
        QThreadPool::globalInstance()->start(new GeometryReader(_modelLoader, _self, _effectiveBaseURL, _mappingPair, data, _combineParts, _request->getWebMediaType()));
    }
}
예제 #29
0
Font* FontsStruct::font(int style)
{
    if (!isinit) {
        fprintf(stderr, "ERROR: fonts struct not initialised\n");
        exit(1);
    }
    
    if (font_[style]) return font_[style];

    size_t len;
    FILE* fp = NULL;
    int n=0;

    while ((fp == NULL) && (n<path->get_num_paths())) {
        pstring curpath = path->get_path(n++);

        pstring fpath = curpath + mapping[style];
        fp = fopen(fpath, "rb");
        if (fp) {
            fclose(fp);
            pstring mpath;
            const char* metnam = NULL;
            if (metrics[style]) {
                mpath = curpath + metrics[style];
                fp = fopen(mpath, "rb");
                if (fp) {
                    metnam = mpath;
                    fclose(fp);
                }
            }

            font_[style] = new Font(fpath, metnam);
        }
        else {
            fpath = curpath + "fonts" + DELIMITER + mapping[style];
            fp = fopen(fpath, "rb");
            if (fp) {
                fclose(fp);
                pstring mpath;
                const char* metnam = NULL;
                if (metrics[style]) {
                    mpath = curpath + "fonts" + DELIMITER + metrics[style];
                    fp = fopen(mpath, "rb");
                    if (fp) {
                        metnam = mpath;
                        fclose(fp);
                    }
                }
                font_[style] = new Font(fpath, metnam);
            }
            else if ((len = ScriptHandler::cBR->getFileLength(mapping[style]))) {
                Uint8 *data = new Uint8[len], *mdat = NULL;
                ScriptHandler::cBR->getFile(mapping[style], data);
                size_t mlen = 0;
                if (metrics[style] &&
                    (mlen = ScriptHandler::cBR->getFileLength(metrics[style]))) {
                    mdat = new Uint8[mlen];
                    ScriptHandler::cBR->getFile(metrics[style], mdat);
                }

                font_[style] = new Font(data, len, mdat, mlen);
            }
            else {
                const InternalResource *fres, *mres = NULL;
                fres = getResource(mapping[style]);
                if (metrics[style]) mres = getResource(metrics[style]);

                if (fres) font_[style] = new Font(fres, mres);
            }
        }

        // Fall back on default.ttf if no font was specified and
        // face$STYLE.ttf was not found.
        if (!font_[style] && (fp = fopen(curpath + fallback, "rb"))) {
            fclose(fp);
            font_[style] = new Font(curpath + fallback, (const char*) NULL);
        }
    }

    if (font_[style]) {
        font_[style]->set_size(26);
        return font_[style];
    }

    fprintf(stderr, "Error: failed to open font %s\n",
            (const char*) mapping[style]);
    exit(1);
}
예제 #30
0
	ZFont* IRenderSystem::getFontRes( ResID id )
	{
		ResBase* res = getResource( id );
		assert( res == NULL || res->getType() == RES_FONT );
		return static_cast< ZFont* >( res );
	}