예제 #1
0
void JS_fwrite( flusspferd::string fileName, flusspferd::string str )
{
	std::ofstream OutFile( ( std::string("./js_files/") + fileName.to_string()).c_str() );

	if( OutFile.is_open() )
	{
		OutFile.write( str.to_string().c_str(), MIN(str.size(),1024) );
	}
	OutFile.close();
}
예제 #2
0
flusspferd::value JS_getUserIdByUserName(flusspferd::string userName)
{
	PlayerIndex *playerIndex = CharacterUtil::getPlayerIndexByUserName(userName.to_string());

	if(playerIndex == NULL)
		return flusspferd::object();
	return flusspferd::value(playerIndex->id);
}
예제 #3
0
flusspferd::value JS_loadSingleObjectFromDatabase(flusspferd::string objectId)
{
	boost::uuids::string_generator uuidGenerator;

	Object *object = Object::loadSingleItem(uuidGenerator(objectId.to_string()), true);

	return lookupValue(object);
}
예제 #4
0
void JS_saveSingleObjectToDatabase(JSObject *object, flusspferd::string holderType, flusspferd::string holderId)
{
	if(object->toReal() && object->toReal()->IsPurged() == false) {

		if(holderType.size() < 1) {

			throw flusspferd::exception("Attempting to save object to database with an empty holder type.");
		}

		Object::saveItemToTopLevelHolder(holderType.c_str()[0], holderId.to_string(), object->toReal());
	}
}
예제 #5
0
flusspferd::value JS_sendQuery( flusspferd::string qBuffer )
{
	sql::Query MyQuery;
	try {
		MyQuery = gameDatabase->sendQuery( qBuffer.to_string() );
	} catch( sql::QueryException e ) {
		MudLog(BRF, LVL_APPR, TRUE, "JavaScript : sql::Query() : %s", e.getMessage().c_str());
		return flusspferd::value();
	}
	if( MyQuery.use_count() == 0 )
		return flusspferd::value();
	JSBindable *b = new sqlJSQuery( MyQuery );
	return lookupValue( b );
}
예제 #6
0
flusspferd::string JS_fread( flusspferd::string fileName )
{
	std::string inputBuffer;
	char cBuf[1025];
	std::ifstream InFile( (std::string("./js_files/") + fileName.to_string()).c_str() );
	if( InFile.is_open() )
	{
		InFile.get(cBuf, 1024);
		cBuf[ InFile.gcount() ] = '\0';
		InFile.close();
		return flusspferd::string( cBuf );
	}
	return flusspferd::string( "" );
}
예제 #7
0
flusspferd::array JS_loadObjectsByHolderFromDatabase(flusspferd::string holderType, flusspferd::string holderId)
{
	flusspferd::array objects = flusspferd::create_array();

	if(holderType.size() == 0) {

		throw flusspferd::exception("Attempting to load objects from holder of empty type.");
	}

	std::list< Object* > objectList = Object::loadItemList(true, holderType.c_str()[0], holderId.to_string());

	while(objectList.empty() == false) {
		objects.call("push", lookupValue(objectList.front()));
//		objects.push(lookupValue(objectList.front()));

		objectList.pop_front();
	}

	return objects;
}
예제 #8
0
flusspferd::string JS_md5( flusspferd::string key )
{
	return flusspferd::string(MD5::getHashFromString( key.to_string().c_str() ));
}
예제 #9
0
flusspferd::string JS_sqlEsc( flusspferd::string qBuffer )
{
	return sql::escapeString( qBuffer.to_string() );
}
예제 #10
0
flusspferd::string JS_getWeaveAttribute( int wVnum, flusspferd::string attribute )
{
	Weave *w = WeaveManager::GetManager().GetWeave( wVnum );
	return (w ? w->getAttribute(attribute.to_string()) : "<Invalid>");
}
예제 #11
0
int JS_getSkillVnum( flusspferd::string wName )
{
	Weave *w = WeaveManager::GetManager().GetWeave( wName.to_string() );
	return (w ? w->getVnum() : 0);
}
예제 #12
0
void JS_mudLog( int type, int lvl, flusspferd::string str )
{
	MudLog(type, lvl, TRUE, StringUtil::vaEscape( str.to_string() ).c_str());
}