Esempio n. 1
0
//-----------------------------------------------------------------------------
//	Shader - Generic Shader File Loading
//-----------------------------------------------------------------------------
bool shader::load( const char* shaderFilePath, int shaderType ) {
    //check to see if the fragment shader file exists
    if ( !resource::fileExists( shaderFilePath ) ) {
        std::cerr << "WARNING: Attempted to load a nonexistent shader file:\n";
        std::cerr << "\t" << shaderFilePath << std::endl;
        return false;
    }

    int fileLength( 0 );
    char* shaderData( nullptr );
    bool ret = false;

    fileLength = (int)resource::fileSize( shaderFilePath );
    shaderData = new char[ fileLength ];
    resource::readFile( shaderFilePath, shaderData, fileLength );
    
    ret = loadBuffer( shaderData, fileLength, shaderType );
    delete [] shaderData;

    return ret;
}
Esempio n. 2
0
void LuaInterface::loadFunction(const std::string& buffer, const std::string& source)
{
    if(buffer.empty()) {
        pushNil();
        return;
    }

    std::string buf;
    if(stdext::starts_with(buffer, "function"))
        buf = stdext::format("__func = %s", buffer);
    else
        buf = stdext::format("__func = function(self)\n%s\nend", buffer);

    loadBuffer(buf, source);
    safeCall();

    // get the function
    getGlobal("__func");

    // reset the global __func
    pushNil();
    setGlobal("__func");
}
Esempio n. 3
0
bool ScriptEvent::configureRaidEvent(xmlNodePtr eventNode)
{
	if(!RaidEvent::configureRaidEvent(eventNode))
		return false;

	std::string scriptsName = Raids::getInstance()->getScriptBaseName();
	if(!m_interface.loadDirectory(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/"))))
		std::clog << "[Warning - ScriptEvent::configureRaidEvent] Cannot load " << scriptsName << "/lib/" << std::endl;

	std::string strValue;
	if(readXMLString(eventNode, "file", strValue))
	{
		if(!loadScript(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/" + strValue)), true))
		{
			std::clog << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script file (" << strValue << ")." << std::endl;
			return false;
		}
	}
	else if(parseXMLContentString(eventNode->children, strValue) && loadBuffer(strValue))
		return true;

	std::clog << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script buffer." << std::endl;
	return false;
}
Esempio n. 4
0
 /**
  * Loads a map's data into a buffer
  */
 char* File::loadMapBuffer(const std::string &name, size_t *size)
 {
   return loadBuffer("maps/" + name + ".lua",size);
 }
Esempio n. 5
0
 /**
  * Loads some sprite data into a buffer
  * (the buffer will have to be freeded of course)
  */
 char* File::loadSpriteDataBuffer(const std::string &name, size_t *size)
 {
   return loadBuffer("sprites/" + name + ".lua",size);
 }
Esempio n. 6
0
void LuaInterface::runBuffer(const std::string& buffer, const std::string& source)
{
    loadBuffer(buffer, source);
    safeCall(0, 0);
}
Esempio n. 7
0
/*STATUS tcpServer (int SERVER_PORT_NM)
{
  if (taskSpawn("tcpRecvTask", SERVER_WORK_PRIORITY, 0, SERVER_STACK_SIZE,(FUNCPTR) tcpRecvTask, 0, 0, 0,0,0, 0, 0, 0, 0, 0) == ERROR)
    {
      perror ("taskSpawn");
    }
}

STATUS tcpClient (int SERVER_PORT_NM)
{
  if (taskSpawn("tcpSendTask", CLIENT_WORK_PRIORITY, 0, SERVER_STACK_SIZE,(FUNCPTR) tcpSendTask, 0, 0, 0,0,0, 0, 0, 0, 0, 0) == ERROR)
    {
      perror ("taskSpawn");
    }
}*/
void playSound(char c) {
	/*dat = buf;*/
	sn = c;
	loadBuffer(c);
	
}