Exemplo n.º 1
0
RivenScriptPtr RivenScriptManager::createScriptFromData(uint16 commandCount, ...) {
	va_list args;
	va_start(args, commandCount);

	// Build a script from the variadic arguments
	Common::MemoryWriteStreamDynamic writeStream = Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
	writeStream.writeUint16BE(commandCount);

	for (uint i = 0; i < commandCount; i++) {
		uint16 command = va_arg(args, int);
		writeStream.writeUint16BE(command);

		if (command == kRivenCommandSwitch) {
			// The switch command has a different format that is not implemented
			error("Cannot create a Switch command from data");
		}

		uint16 argumentCount = va_arg(args, int);
		writeStream.writeUint16BE(argumentCount);

		for (uint j = 0; j < commandCount; j++) {
			uint16 argument = va_arg(args, int);
			writeStream.writeUint16BE(argument);
		}
	}

	va_end(args);

	Common::MemoryReadStream readStream = Common::MemoryReadStream(writeStream.getData(), writeStream.size());
	return readScript(&readStream);
}
Exemplo n.º 2
0
int ScriptHandler::openScript(char *path)
{
    if (readScript(path) < 0) return -1;
    readConfiguration();
    variable_data = new VariableData[variable_range];
    return labelScript();
}
Exemplo n.º 3
0
        virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const
        {
            if (file=="ScriptEngine.V8") return new v8::V8ScriptEngine();
            if (file=="ScriptEngine.js") return new v8::V8ScriptEngine();

            return readScript(file);
        }
Exemplo n.º 4
0
/****************************
        [Animation]
         init
****************************/
void Animation :: init(char *path2, int ID2)
{
  path = (char *)malloc(strlen(path2) + 5);
  strcpy(path, path2);
  readScript(ID2);
  animation_timer.New(ID2, interval);
  frames_aux = frames_ini;
  i_sub_animations = 0;
}
Exemplo n.º 5
0
RivenScriptList RivenScriptManager::readScripts(Common::ReadStream *stream) {
	RivenScriptList scriptList;

	uint16 scriptCount = stream->readUint16BE();
	for (uint16 i = 0; i < scriptCount; i++) {
		RivenTypedScript script;
		script.type = stream->readUint16BE();
		script.script = readScript(stream);
		scriptList.push_back(script);
	}

	return scriptList;
}
Exemplo n.º 6
0
        virtual ReadResult readScript(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const
        {
            std::string ext = osgDB::getLowerCaseFileExtension(file);
            if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;

            std::string fileName = osgDB::findDataFile( file, options );
            if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;

            osgDB::ifstream istream(fileName.c_str(), std::ios::in);
            if(!istream) return ReadResult::FILE_NOT_HANDLED;

            return readScript(istream, options);
        }
Exemplo n.º 7
0
void RaceAnalyzerComm::readConfig(RaceCaptureConfig *config,RaceAnalyzerCommCallback *callback){
	try{
		wxDateTime start = wxDateTime::UNow();
		int updateCount = 0;
		CComm *serialPort = GetSerialPort();
		if (NULL==serialPort) throw CommException(CommException::OPEN_PORT_FAILED);

		updateWriteConfigPct(updateCount, callback);

		readGpsConfig(&config->gpsConfig);
		updateWriteConfigPct(++updateCount, callback);

		readGpsTargetConfig(&config->gpsConfig);
		updateWriteConfigPct(++updateCount, callback);

		readAnalogConfig(config->analogConfigs);
		updateCount += CONFIG_ANALOG_CHANNELS;
		updateWriteConfigPct(updateCount, callback);

		readTimerConfig(config->timerConfigs);
		updateCount += CONFIG_TIMER_CHANNELS;
		updateWriteConfigPct(updateCount, callback);

		readAccelConfig(config->accelConfigs);
		updateCount += CONFIG_ACCEL_CHANNELS;
		updateWriteConfigPct(updateCount, callback);

		readAnalogPulseConfig(config->pwmConfigs);
		updateCount += CONFIG_ANALOG_PULSE_CHANNELS;
		updateWriteConfigPct(updateCount, callback);

		readGpioConfig(config->gpioConfigs);
		updateCount += CONFIG_GPIO_CHANNELS;
		updateWriteConfigPct(updateCount, callback);

		readConnectivityConfig(&config->connectivityConfig);
		updateWriteConfigPct(++updateCount,callback);

		config->luaScript = readScript();
		updateWriteConfigPct(++updateCount,callback);

		wxTimeSpan dur = wxDateTime::UNow() - start;
		VERBOSE(FMT("get config in %f",dur.GetMilliseconds().ToDouble()));
		callback->ReadConfigComplete(true,"");
	}
	catch(CommException &e){
		callback->ReadConfigComplete(false, e.GetErrorMessage());
	}
	CloseSerialPort();
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void gamuzaMain::openFileDialog(){

	string URL;

	int response = ofxFileDialog::openFile(URL);
	if(response){
		loadScript(URL);
		logger.log(99, " %s", URL.c_str());
		logger.log(99, " OPEN SCRIPT:");
		liveCoding.glEditor[liveCoding.currentEditor]->ClearAllText();
		liveCoding.pasteFromLuaScript(readScript(URL,true));
	}else{
		logger.log(99, " OPEN SCRIPT Canceled.");
	}

}
Exemplo n.º 9
0
void Placeable::loadProperties(const Aurora::GFF3Struct &gff) {
	// Tag
	_tag = gff.getString("Tag", _tag);

	// Name and description
	gff.getLocString("LocName"     , _name);
	gff.getLocString("LocPopupText", _description);

	// Conversation
	_conversation = gff.getString("Conversation", _conversation);

	// Static and usable
	_static = !gff.getBool("Active" , !_static);
	_usable =  gff.getBool("Useable",  _usable);

	// Appearance
	_appearanceID = gff.getUint("Appearance", _appearanceID);

	// Position
	if (gff.hasField("XPosition")) {
		const float position[3] = {
			(float) gff.getDouble("XPosition"),
			(float) gff.getDouble("YPosition"),
			(float) gff.getDouble("ZPosition")
		};

		setPosition(position[0], position[1], position[2]);
	}

	// Orientation
	if (gff.hasField("XOrientation")) {
		const float orientation[4] = {
			(float) gff.getDouble("XOrientation"),
			(float) gff.getDouble("YOrientation"),
			(float) gff.getDouble("ZOrientation"),
			(float) Common::rad2deg(acos(gff.getDouble("WOrientation")) * 2.0)
		};

		setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]);
	}

	// Variables and script
	readVarTable(gff);
	readScript(gff);
	enableEvents(true);
}
Exemplo n.º 10
0
void Waypoint::load(const Aurora::GFF3Struct &waypoint) {
	// Tag
	_tag = waypoint.getString("Tag");

	// Group
	_group = waypoint.getSint("Group", -1);

	// Map Note
	_hasMapNote     = waypoint.getBool("HasMapNote");
	_enabledMapNote = waypoint.getBool("MapNoteEnabled");

	waypoint.getLocString("MapNote", _mapNote);

	// Type
	_type = (uint32) ((int32) waypoint.getSint("MapNoteType", -1));

	// Position
	const float position[3] = {
		(float) waypoint.getDouble("XPosition"),
		(float) waypoint.getDouble("YPosition"),
		(float) waypoint.getDouble("ZPosition")
	};

	setPosition(position[0], position[1], position[2]);

	// Orientation
	const float orientation[4] = {
		(float) waypoint.getDouble("XOrientation"),
		(float) waypoint.getDouble("YOrientation"),
		(float) waypoint.getDouble("ZOrientation"),
		(float) Common::rad2deg(acos(waypoint.getDouble("WOrientation")) * 2.0)
	};

	setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]);

	const Aurora::GDAFile &gda = getMGDA(kWorksheetWaypoints);

	// Icon
	_icon = gda.getString(_type, "Icon");

	// Variables and script
	readVarTable(waypoint);
	readScript(waypoint);
	enableEvents(true);
}
Exemplo n.º 11
0
int readAllScripts(string filePrefix) {
	dout << " loadAllScripts" << endl;	
	
	string fileName = filePrefix + "scripts.dat";
	FILE *fin = fopen(fileName.c_str(), "rb");
	if(!fin) {
		dout << "ERROR- loadScripts: Could not open " << fileName << " for reading." << endl;
		return 1;
	}

	int totalScripts = readInt(fin);
	dout << "  Total scripts: " << totalScripts << endl;
	for(int a = 0; a < totalScripts; a++) {
		Script *s = new Script;
		readScript(fin, s);
		dout << "   loaded script: " << s->id << endl;
		all_scripts.insert(make_pair<int, Script*>(s->id, s));
	}
	// Load script sound
	int playingChannels = readInt(fin);
	int channel;
	int soundId;
	SoundCollection *sound;
	map<int, SoundCollection*>::iterator soundIter;
	dout << "   loading script sounds" << endl;
	for(int b = 0; b < playingChannels; b++) {
		channel = readInt(fin);
		soundId = readInt(fin);
		soundIter = scriptSounds.find(soundId);		
		if(soundIter == scriptSounds.end()) {
			dout << "ERROR- Script sound loading out of sync, id: " << soundId << endl;
			exit(1);
		}
		dout << "    loading script sound on channel: " 
			<< channel - SOUND_CHANNEL_SCRIPT << ", with id: " << soundId << endl;
		sound = soundIter->second;
		loadSoundCollectionState(fin, sound);
		soundPlayer.loadScriptSoundChannel(fin, channel, sound);
	}
	dout << "   loading script sound complete" << endl;

	fclose(fin);
	return 0;
}
Exemplo n.º 12
0
    void GatewayDataMgr::updateGWPropCallbackExScript(redisAsyncContext *c, void *r, void *privdata) {
    
        redisReply *reply = (redisReply *)r;
        GatewayProp * gp = (GatewayProp *)privdata;
        
        if (!gp) {
            LOG(ERROR)<<"happen exception updateGWPropCallbackExScript privdata is null";
            return;
        }

        if (reply == NULL) {
            LOG(ERROR)<<"["<<gp->mGwId.c_str()<<"]"<<" updateGWPropCallback: reply null"; 
            delete gp;
            gp = NULL;
            return;
        }

        LOG(TRACE)<<gp->mGwId.c_str()<<" updateGWPropCallback: "<<reply->str;

        if (reply->type == REDIS_REPLY_ERROR) {
            if (NULL != strstr(reply->str, "NOSCRIPT No matching script")) {
                //USE EVAL
                LOG(ERROR)<<"redis-server not cache, we need eval";
                std::string scriptStream = "";
                bool ret = readScript(saveGatewayProp_script, scriptStream);

                if (!ret) {
                    delete gp;
                    gp = NULL;
                    return;
                }

                char gwPropKey[128];
                snprintf(gwPropKey, 127, "%s:%s:%s", ISCRule::iot_gw_dbtag.c_str(), gp->mGwId.c_str(), \
                        ISCRule::iot_gwprop_dbtag.c_str());
                gwPropKey[127] = 0;
                redisAsyncCommand(c, updateGWPropCallbackExScript, gp, "eval %s %d %s %s %s %s", \
                        scriptStream.c_str(), 2, ISCRule::iot_gw_dbtag.c_str(), gwPropKey, gp->mGwId.c_str(), gp->mGwProp.c_str());
                return;
            }
        }
        delete gp;
        gp = NULL;
    }
Exemplo n.º 13
0
    void GatewayDataMgr::delUpRepSubCallbackExScript(redisAsyncContext *c, void *r, void *privdata) {
    
        MemMap * ptMap = (MemMap *)privdata;
        redisReply *reply = (redisReply *)r;
        if (reply == NULL) {
            LOG(ERROR)<<(ptMap!=NULL?ptMap->mKey.c_str():NULL)<<"delUpRepSubCallbackExScript: reply null`";
            if (NULL != ptMap) {
                delete ptMap;
                ptMap = NULL;
            }
            return;
        }

        
        if (!ptMap) {
            LOG(ERROR)<<"happen exception delUpRepSubCallbackExScript privdata is null";
            return;
        }


        LOG(TRACE)<<ptMap->mKey.c_str()<<" delUpRepSubCallbackExScript:"<<reply->integer;
        if (reply->type == REDIS_REPLY_ERROR) {
            if (NULL != strstr(reply->str, "NOSCRIPT No matching script")) {
                //USE EVAL

                std::string scriptStream = "";
                bool ret = readScript(delUpRepSub_script, scriptStream);

                if (!ret) {
                    delete ptMap;
                    ptMap = NULL;
                    return;
                }

                redisAsyncCommand(c, delUpRepSubCallbackExScript, ptMap, "eval %s %d %s %s", \
                        scriptStream.c_str(), 1, ptMap->mKey.c_str(), ptMap->mValue.c_str());
                return;
            }
        }
        delete ptMap;
        ptMap = NULL;
    }
Exemplo n.º 14
0
pFace::pFace(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::pFace)
{
    ui->setupUi(this);

    QObject::connect(ui->LoadButton,SIGNAL(clicked()),this,SLOT(readScript()));
    QObject::connect(ui->RunButton,SIGNAL(clicked()),this,SLOT(tmpRunner()));
    //QObject::connect(ui->RunButton,SIGNAL(clicked()),this,SLOT(parseCommands()));
    QObject::connect(ui->ConnectButton,SIGNAL(clicked()),this,SLOT(connect2Port()));
    QObject::connect(ui->DisconnectButton,SIGNAL(clicked()),this,SLOT(closePort()));
    QObject::connect(ui->scanButton,SIGNAL(clicked()),this,SLOT(scanPorts()));

    QObject::connect(ui->homeX,SIGNAL(clicked()),this,SLOT(homeX()));
    QObject::connect(ui->homeY,SIGNAL(clicked()),this,SLOT(homeY()));
    QObject::connect(ui->homeZ,SIGNAL(clicked()),this,SLOT(homeZ()));
    QObject::connect(ui->homeAll,SIGNAL(clicked()),this,SLOT(homeAll()));

    scanPorts();
}
ScrollingTextRenderer::ScrollingTextRenderer(GameObject& owner, const std::string& relScriptPath)
	: RenderComponent(owner), timeSinceLastScroll_(0)
{
	readScript(relScriptPath);
}
Exemplo n.º 16
0
 virtual ReadResult readObject(std::istream& fin, const osgDB::ReaderWriter::Options* options =NULL) const
 {
     return readScript(fin);
 }
Exemplo n.º 17
0
        virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const
        {
            if (file=="ScriptEngine.python") return new python::PythonScriptEngine();

            return readScript(file, options);
        }
Exemplo n.º 18
0
bool ReadCell::innerRead( ifstream& fin )
{
    string line;
	lineNum_ = 0;
	
	ParseStage parseMode = DATA;
	string::size_type pos;
	
	while ( getline( fin, line ) ) {
		line = trim( line );
		lineNum_++;
		
		if ( line.length() == 0 )
			continue;
		
		pos = line.find_first_not_of( "\t " );
		if ( pos == string::npos )
			continue;
		else
			line = line.substr( pos );
		
		if ( line.substr( 0, 2 ) == "//" )
			continue;
		
		if ( ( pos = line.find( "//" ) ) != string::npos ) 
			line = line.substr( 0, pos );
		
		if ( line.substr( 0, 2 ) == "/*" ) {
			parseMode = COMMENT;
		} else if ( line.find( "*/" ) != string::npos ) {
			parseMode = DATA;
			continue;
		} else if ( line[ 0 ] == '*' ) {
			parseMode = SCRIPT;
		}
		
		if ( parseMode == COMMENT ) {
			pos = line.find( "*/" );
			if ( pos != string::npos ) {
				parseMode = DATA;
				if ( line.length() > pos + 2 )
					line = line.substr( pos + 2 );
			}
		}
		
		if ( parseMode == DATA ) {
			// For now not keeping it strict. Ignoring return status, and
			// continuing even if there was error in processing this line.
			readData( line );
		} else if ( parseMode == SCRIPT ) {
			// For now not keeping it strict. Ignoring return status, and
			// continuing even if there was error in processing this line.
			readScript( line );
			parseMode = DATA;
		}
	}
	
	cout <<
		"ReadCell: " <<
		numCompartments_ << " compartments, " << 
		numChannels_ << " channels, " << 
		numOthers_ << " others\n";
	
	return 1;
}