Esempio n. 1
0
void
pvt_base::check_oil_common (const vector_t &pressure, const vector_t &fvf, const vector_t &visc)
{
    for (t_long i = 0, cnt = (t_long)pressure.size (); i < cnt; ++i)
    {
        if (pressure[i] < 0)
        {
            // TODO: LOG
            BS_ASSERT (false) (pressure[i]);
            throw bs_exception ("", "pressure should be greater than 0");
        }
        if (fvf[i] < 0)
        {
            // TODO:LOG
            BS_ASSERT (false) (fvf[i]);
            throw bs_exception ("", "fvf should be greater than 0");
        }
        if (visc[i] < 0)
        {
            // TODO: LOG
            BS_ASSERT (false) (visc[i]);
            throw bs_exception ("", "viscosity should be greater than 0");
        }
    }
}
Esempio n. 2
0
static int getSoundPanning(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	lua_pushnumber(L, pSfx->getSoundPanning(static_cast<uint>(luaL_checknumber(L, 1))));

	return 1;
}
Esempio n. 3
0
static int stopSound(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	pSfx->stopSound(static_cast<uint>(luaL_checknumber(L, 1)));

	return 0;
}
Esempio n. 4
0
static int isSoundPaused(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	lua_pushbooleancpp(L, pSfx->isSoundPaused(static_cast<uint>(luaL_checknumber(L, 1))));

	return 1;
}
Esempio n. 5
0
static int setSoundPanning(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	pSfx->setSoundPanning(static_cast<uint>(luaL_checknumber(L, 1)), static_cast<float>(luaL_checknumber(L, 2)));

	return 0;
}
Esempio n. 6
0
static int getVolume(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	lua_pushnumber(L, pSfx->getVolume(static_cast<SoundEngine::SOUND_TYPES>(static_cast<uint>(luaL_checknumber(L, 1)))));

	return 1;
}
Esempio n. 7
0
static int pauseAll(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	pSfx->pauseAll();

	return 0;
}
Esempio n. 8
0
pvt_base::pvt_base ( )
{
    p_step = 0;
    surface_density = 0;
    init_dependent = true;
    pvt_input_props = BS_KERNEL.create_object ("table");
    pvt_props_table = BS_KERNEL.create_object ("table");

    BS_ASSERT (pvt_input_props);
    BS_ASSERT (pvt_props_table);
}
  void
  data_serializer::save (const sp_storage_t &storage, const sp_obj &obj) const
    {
      BS_ASSERT (storage);
      BS_ASSERT (obj);

      const sp_storage_t &locked_storage (storage);
      data_storage &st = *locked_storage;

      BS_ASSERT (false && "BASE METHOD CALL") (storage->bs_resolve_type ().stype_) (obj->bs_resolve_type ().stype_);
      st.save ("base method call", "---");
    }
Esempio n. 10
0
bool SoundEngine::registerScriptBindings() {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	ScriptEngine *pScript = pKernel->getScript();
	BS_ASSERT(pScript);
	lua_State *L = static_cast<lua_State *>(pScript->getScriptObject());
	BS_ASSERT(L);

	if (!LuaBindhelper::addFunctionsToLib(L, SFX_LIBRARY_NAME, SFX_FUNCTIONS)) return false;
	if (!LuaBindhelper::addConstantsToLib(L, SFX_LIBRARY_NAME, SFX_CONSTANTS)) return false;

	return true;
}
Esempio n. 11
0
static int init(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	if (lua_gettop(L) == 0)
		lua_pushbooleancpp(L, pSfx->init(44100, 32));
	else if (lua_gettop(L) == 1)
		lua_pushbooleancpp(L, pSfx->init(static_cast<uint>(luaL_checknumber(L, 1)), 32));
	else
		lua_pushbooleancpp(L, pSfx->init(static_cast<uint>(luaL_checknumber(L, 1)), static_cast<uint>(luaL_checknumber(L, 2))));

	return 1;
}
Esempio n. 12
0
  well_factory::sp_well_t
  well_factory::create_well (const std::string & /*group_name*/, const std::string &well_name) const
    {
      BS_ASSERT (well_name.size ());

      sp_well_t w = BS_KERNEL.create_object (wells::default_well::bs_type (), true);
      BS_ASSERT (w) (well_name);

      w->set_name (well_name);

      //sp_well_t w = BS_KERNEL.create_object_v2 <wells::default_well > (well_name, true);
      //BS_ERROR (w, "well_factory::create_well: Can't create well");

      return w;
    }
	ScriptManagedResource::ScriptManagedResource(MonoObject* instance, const HManagedResource& resource)
		:ScriptObject(instance), mResource(resource)
	{
		BS_ASSERT(instance != nullptr);

		MonoUtil::getClassName(instance, mNamespace, mType);
	}
Esempio n. 14
0
bool AnimationResource::computeFeatures() {
	BS_ASSERT(_frames.size());

	// Alle Features werden als vorhanden angenommen
	_scalingAllowed = true;
	_alphaAllowed = true;
	_colorModulationAllowed = true;

	// Alle Frame durchgehen und alle Features deaktivieren, die auch nur von einem Frame nicht unterstützt werden.
	Common::Array<Frame>::const_iterator iter = _frames.begin();
	for (; iter != _frames.end(); ++iter) {
		BitmapResource *pBitmap;
		if (!(pBitmap = static_cast<BitmapResource *>(Kernel::getInstance()->getResourceManager()->requestResource((*iter).fileName)))) {
			BS_LOG_ERRORLN("Could not request \"%s\".", (*iter).fileName.c_str());
			return false;
		}

		if (!pBitmap->isScalingAllowed())
			_scalingAllowed = false;
		if (!pBitmap->isAlphaAllowed())
			_alphaAllowed = false;
		if (!pBitmap->isColorModulationAllowed())
			_colorModulationAllowed = false;

		pBitmap->release();
	}

	return true;
}
Esempio n. 15
0
bool Text::doRender() {
	// Font-Resource locken.
	FontResource *fontPtr = lockFontResource();
	if (!fontPtr)
		return false;

	// Charactermap-Resource locken.
	ResourceManager *rmPtr = getResourceManager();
	BitmapResource *charMapPtr;
	{
		Resource *pResource = rmPtr->requestResource(fontPtr->getCharactermapFileName());
		if (!pResource) {
			BS_LOG_ERRORLN("Could not request resource \"%s\".", fontPtr->getCharactermapFileName().c_str());
			return false;
		}
		if (pResource->getType() != Resource::TYPE_BITMAP) {
			BS_LOG_ERRORLN("Requested resource \"%s\" is not a bitmap.", fontPtr->getCharactermapFileName().c_str());
			return false;
		}

		charMapPtr = static_cast<BitmapResource *>(pResource);
	}

	// Framebufferobjekt holen.
	GraphicEngine *gfxPtr = Kernel::getInstance()->getGfx();
	BS_ASSERT(gfxPtr);

	bool result = true;
	Common::Array<Line>::iterator iter = _lines.begin();
	for (; iter != _lines.end(); ++iter) {
		// Feststellen, ob überhaupt Buchstaben der aktuellen Zeile vom Update betroffen sind.
		Common::Rect checkRect = (*iter).bbox;
		checkRect.translate(_absoluteX, _absoluteY);

		// Jeden Buchstaben einzeln Rendern.
		int curX = _absoluteX + (*iter).bbox.left;
		int curY = _absoluteY + (*iter).bbox.top;
		for (uint i = 0; i < (*iter).text.size(); ++i) {
			Common::Rect curRect = fontPtr->getCharacterRect((byte)(*iter).text[i]);

			Common::Rect renderRect(curX, curY, curX + curRect.width(), curY + curRect.height());
			int renderX = curX + (renderRect.left - renderRect.left);
			int renderY = curY + (renderRect.top - renderRect.top);
			renderRect.translate(curRect.left - curX, curRect.top - curY);
			result = charMapPtr->blit(renderX, renderY, Image::FLIP_NONE, &renderRect, _modulationColor);
			if (!result)
				break;

			curX += curRect.width() + fontPtr->getGapWidth();
		}
	}

	// Charactermap-Resource freigeben.
	charMapPtr->release();

	// Font-Resource freigeben.
	fontPtr->release();

	return result;
}
Esempio n. 16
0
  void
  data_storage_interface::save (const sp_obj &obj) const
    {
      // FIXME: Implement storage_
      if (!storage_)
        return ;

      BS_ASSERT (obj);
      const type_descriptor &td = obj->bs_resolve_type ();

      serializer_list_t::const_iterator it = serializer_list_->find (td.stype_);
      BS_ASSERT (it != serializer_list_->end ()) (td.stype_);

      if (it != serializer_list_->end ())
        it->second->save (storage_, obj);
    }
Esempio n. 17
0
void LuaCallback::unregisterCallbackFunction(lua_State *L, uint objectHandle) {
	BS_ASSERT(lua_isfunction(L, -1));
	ensureObjectCallbackTableExists(L, objectHandle);

	// Iterate over all elements of the object callback table and remove the function from it
	lua_pushnil(L);
	while (lua_next(L, -2) != 0) {
		// The value of the current element is the top of the stack, including the index

		// If the value is identical to the function parameters, it is removed from the table
		if (lua_equal(L, -1, -4)) {
			lua_pushvalue(L, -2);
			lua_pushnil(L);
			lua_settable(L, -5);

			// The function was found, iteration can be stopped
			lua_pop(L, 2);
			break;
		} else {
			// Pop value from the stack. The index is then ready for the next call to lua_next()
			lua_pop(L, 1);
		}
	}

	// Function and object table are popped from the stack
	lua_pop(L, 2);
}
Esempio n. 18
0
  void
  data_storage_interface::set_storage (const sp_storage_t &storage)
  {
    storage_ = storage;

    BS_ASSERT (storage_);
  }
Esempio n. 19
0
  jacobian::get_matrix (std::string const &name) const
  {
    BS_ASSERT (matrix);
    if (name == "trns") 
      return flux_conn->get_conn_trans ();

    return matrix->get_matrix (name);
  }
Esempio n. 20
0
  data_storage_interface::data_storage_interface (const data_storage_interface& dsi)
        : bs_refcounter (), objbase ()
  {
    storage_ = dsi.storage_;
    serializer_list_ = dsi.serializer_list_;

    BS_ASSERT (serializer_list_);
  }
Esempio n. 21
0
  well_factory::sp_connection_t
  well_factory::create_connection () const
    {
      sp_connection_t con = BS_KERNEL.create_object (wells::default_connection::bs_type (), true);
      BS_ASSERT (con);

      return con;
    }
Esempio n. 22
0
void Text::setAlpha(int alpha) {
	BS_ASSERT(alpha >= 0 && alpha < 256);
	uint newModulationColor = (_modulationColor & 0x00ffffff) | alpha << 24;
	if (newModulationColor != _modulationColor) {
		_modulationColor = newModulationColor;
		forceRefresh();
	}
}
Esempio n. 23
0
bool LuaScriptEngine::registerStandardLibExtensions() {
	lua_State *L = _state;
	BS_ASSERT(_state);

	if (!LuaBindhelper::addFunctionsToLib(L, "", GLOBAL_FUNCTIONS))
		return false;

	return true;
}
Esempio n. 24
0
void pvt_base::check_pressure_interval (t_double min_p, t_double max_p)
{
    if (max_p - min_p < 1.0e-12)
    {
        // TODO: LOG
        BS_ASSERT (false) (max_p) (min_p);
        throw bs_exception ("", "invalid pressure interval");
    }
}
Esempio n. 25
0
  void
  data_storage_interface::register_serializer (const sp_serializer_t &serializer)
  {
    BS_ASSERT (serializer);
    BS_ASSERT (serializer->bs_resolve_type ().stype_.length ());

    const type_descriptor &td = serializer->handled_type ();
    BS_ASSERT (td.stype_.length ()) (serializer->bs_resolve_type ().stype_);

    const sp_serializer_list_t &locked_list (serializer_list_);
    serializer_list_t::iterator it = locked_list->find (td.stype_);
    BS_ASSERT (it == locked_list->end ());

    if (it == locked_list->end ())
      locked_list->insert (make_pair (td.stype_, serializer));
    else
      it->second = serializer;
  }
Esempio n. 26
0
void pvt_base::check_common ()
{
    if (surface_density < 0)
    {
        // TODO: LOG
        BS_ASSERT (false) (surface_density);
        throw bs_exception ("", "surface density lower than 0");
    }
}
Esempio n. 27
0
  bool
  data_serializer_register_type (const plugin_descriptor &pd)
  {
    bool res = true;

    res &= BS_KERNEL.register_type (pd, data_serializer::bs_type ());
    BS_ASSERT (res);

    return res;
  }
Esempio n. 28
0
  bool
  data_storage_interface_register_type (const plugin_descriptor &pd)
  {
    bool res = true;

    res &= BS_KERNEL.register_type (pd, data_storage_interface::bs_type ());
    BS_ASSERT (res);

    return res;
  }
Esempio n. 29
0
  bool
  well_factory_register_type (const blue_sky::plugin_descriptor &pd)
  {
    bool res = true;

    res &= BS_KERNEL.register_type (pd, well_factory::bs_type ());
    BS_ASSERT (res);

    return res;
  }
Esempio n. 30
0
static int playSoundEx(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	Common::String fileName;
	SoundEngine::SOUND_TYPES type;
	float volume;
	float pan;
	bool loop;
	int loopStart;
	int loopEnd;
	uint layer;
	processPlayParams(L, fileName, type, volume, pan, loop, loopStart, loopEnd, layer);

	lua_pushnumber(L, pSfx->playSoundEx(fileName, type, volume, pan, loop, loopStart, loopEnd, layer));

	return 1;
}