コード例 #1
0
ファイル: mysql_wrapper.cpp プロジェクト: Kiddinglife/ryzom
	bool CConnection::query(const std::string &queryString)
	{
		H_AUTO(CConnection_query);
		nlassert(_Connected);

		nldebug("Executing query : [%s%s", queryString.substr(0, 100).c_str(), 100<queryString.size() ? "]" : "");
		for (uint i=100; i<queryString.size(); i+=100)
			nldebug("\t%s%s", queryString.substr(i, 100).c_str(), i+100>queryString.size() ? "]" : "");

		TTime startDate = CTime::getLocalTime();

		int result = mysql_real_query(_MysqlContext, queryString.c_str(), (unsigned long)queryString.size());
		if (result != 0)
		{
			// in all case, we try to reconnect
			int merrno = mysql_errno(_MysqlContext);
			//if (result == CR_SERVER_GONE_ERROR)
			{
				// reconnect and retry the request
				nlinfo("%p Mysql error errno:%d result:%d : %s, try to reconnect...", _MysqlContext, merrno, result, mysql_error(_MysqlContext));
				if (_connect())
					result = mysql_real_query(_MysqlContext, queryString.c_str(), (unsigned long)queryString.size());
				else
				{
					nlwarning("Failed to reopen closed connection to send query '%s'", queryString.c_str());
					if (MSWStrictMode)
					{
						nlstopex(("SQL Strict mode, the above error is fatal"));
					}
					TTime endDate = CTime::getLocalTime();
					MSWRequestDuration = uint32(endDate - startDate);
					return false;
				}
			}

			if (result != 0)
			{
				nlwarning("Mysql error errno:%d result:%d : %s", merrno, result, mysql_error(_MysqlContext));
				nlwarning("   in query '%s':", queryString.c_str());
				if (MSWStrictMode)
				{
					nlstopex(("SQL Strict mode, the above error is fatal"));
				}
				TTime endDate = CTime::getLocalTime();
				MSWRequestDuration = uint32(endDate - startDate);
				return false;
			}
		}

		TTime endDate = CTime::getLocalTime();
		MSWRequestDuration = uint32(endDate - startDate);

		return true;
	}
コード例 #2
0
void CStateManager::display() const
{
	if (_States.empty())
	{
		nldebug("SS No active states");
		return;
	}

	nldebug("SS Active states:");

	for (uint32 i=0;i<_States.size();++i)
	{
		nldebug("SS \t%s",_States[i].c_str());
	}
}
コード例 #3
0
	void CObjectViewer::release()
	{
		//H_AUTO2
		nldebug("CObjectViewer::release");

		Modules::config().dropCallback("BackgroundColor");
		Modules::config().dropCallback("GraphicsDriver");

		_Driver->delete3dMouseListener(_MouseListener);

		// delete all entities
		deleteEntities();

		_Scene->deletePlayListManager(_PlayListManager);

		// delete the scene
		_Driver->deleteScene(_Scene);

		// delete the light
		delete _Light;

		// release driver
		nlassert(_Driver);
		_Driver->release();
		delete _Driver;
		_Driver = NULL;
	}
コード例 #4
0
ファイル: main.cpp プロジェクト: junhuac/ryzomcore
int main(int /* argc */, char ** /* argv */)
{
	// all debug functions have different behaviors in debug and in release mode.
	// in general, in debug mode, all debug functions are active, they display
	// what happens and some break the program to debug it. In release mode, they often
	// do nothing to increase the execution speed.


	// this function initializes debug functions. it adds displayers into the debug
	// logger.
	// in debug mode, all debug functions display on the std output.
	// in release mode, this function does nothing by default. you have to add a displayer
	// manually, or put true in the parameter to say to the function that you want it to
	// add the default displayers
	NLMISC::createDebug();

	// enable the crash report tool
	NLMISC::INelContext::getInstance().setWindowedApplication(true);
	NLMISC::setReportPostUrl("http://ryzomcore.org/crash_report/");

	// display debug information, that will be skipped in release mode.
	nldebug("nldebug() %d", 1);

	// display the string
	nlinfo("nlinfo() %d", 2);

	// when something not normal, but that the program can manage, occurs, call nlwarning()
	nlwarning("nlwarning() %d", 3);

	// nlassert() is like assert but do more powerful things. in release mode, the test is
	// not executed and nothing will happen. (Press F5 in Visual C++ to continue the execution)
	nlassert(true == false);

	// in a switch case or when you want that the program never executes a part of code, use stop.
	// in release, nlstop does nothing. in debug mode,
	// if the code reaches the nlstop, a breakpoint will be set. (In Visual C++ press F5 to continue)
	nlstop;

	// when the program failed, call nlerror(), it displays the message and throws a EFatalError to
	// exit the program. don't forget to put a try/catch block everywhere an nlerror could
	// occurs. (In Visual C++ press F5 to continue)
	try
	{
		nlerror("nlerror() %d", 4);
	}
	catch (const NLMISC::EFatalError &)
	{
		// just continue...
		nlinfo("nlerror() generated an EFatalError exception, just ignore it");
	}

	// keep repeating the same error
	for (int i = 0; i < 32; ++i)
		repeatederror();

	printf("\nPress <return> to exit\n");
	getchar();

	return EXIT_SUCCESS;
}
コード例 #5
0
	void CObjectViewer::reinit(nlWindow wnd, uint16 w, uint16 h)
	{
		nldebug("CObjectViewert::reinit");

		//release();
		//init(wnd, w, h);
		_Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32));
	}
コード例 #6
0
ファイル: dynloadlib.cpp プロジェクト: sythaeryn/pndrpg
bool CLibrary::loadLibrary(const std::string &libName, bool addNelDecoration, bool tryLibPath, bool ownership)
{
	_Ownership = ownership;
	string libPath = libName;

	if (addNelDecoration)
		libPath = makeLibName(libPath);

	if (tryLibPath)
	{
		// remove any directory spec
		string filename = CFile::getFilename(libPath);

		for (uint i=0; i<_LibPaths.size(); ++i)
		{
			string pathname = _LibPaths[i]+filename;
			if (CFile::isExists(pathname))
			{
				// we found it, replace libPath
				libPath = pathname;
				break;
			}
		}
	}

	nldebug("Loading dynamic library '%s'", libPath.c_str());
	// load the lib now
	_LibHandle = nlLoadLibrary(libPath);
	_LibFileName = libPath;
	// MTR: some new error handling. Just logs if it couldn't load the handle.
	if(_LibHandle == NULL)
	{
#ifdef NL_OS_UNIX
		const char *errormsg = dlerror();
#else
		const char *errormsg = "Verify DLL existence";
#endif
		nlwarning("Loading library %s failed: %s", libPath.c_str(), errormsg);
	}
	else
	{
		// check for 'pure' NeL library
		void *entryPoint = getSymbolAddress(NL_MACRO_TO_STR(NLMISC_PURE_LIB_ENTRY_POINT));
		if (entryPoint != NULL)
		{
			// rebuild the interface pointer
			_PureNelLibrary = *(reinterpret_cast<INelLibrary**>(entryPoint));
			// call the private initialization method.
			_PureNelLibrary->_onLibraryLoaded(INelContext::getInstance());
		}
	}

	return _LibHandle != NULL;
}
コード例 #7
0
ファイル: vegetable_editor.cpp プロジェクト: AzyxWare/ryzom
void CVegetableEditor::init()
{
	//H_AUTO2
	nldebug("CVegetableEditor::init");

	NL3D::CDriverUser *driver = dynamic_cast<NL3D::CDriverUser *>(Modules::objView().getDriver());
	_Driver = driver->getDriver();

	NL3D::CSceneUser *scene = dynamic_cast<NL3D::CSceneUser *>(Modules::objView().getScene());
	_Scene = &scene->getScene();
}
コード例 #8
0
/*
 * Remove a change (slow) (assumes isAllocated())
 */
void		CChangeTrackerBase::cancelChange( TDataSetIndex entityIndex )
{
#ifdef NL_DEBUG
	nlassertex( (entityIndex != INVALID_DATASET_INDEX) && (entityIndex != LAST_CHANGED), ("E%d", entityIndex) );
#endif

	trackerMutex().enter();

	// Find the change before the specified one, to make the link skip it
	TDataSetIndex row = _Header->First;
	if ( row != LAST_CHANGED )
	{
		if ( row == entityIndex )
		{
			// It was the first one
			_Header->First = _Array[entityIndex].NextChanged;
			_Array[entityIndex].NextChanged = INVALID_DATASET_INDEX;
			if ( _Header->First == LAST_CHANGED ) // and it was the only one
				_Header->Last = INVALID_DATASET_INDEX;
			nldebug( "Cancelling change of E%u", entityIndex );
		}
		else
		{
			// It wasn't the first one
			while ( (_Array[row].NextChanged != entityIndex) && (_Array[row].NextChanged != LAST_CHANGED) )
			{
				row = _Array[row].NextChanged;
			}
			if ( _Array[row].NextChanged == entityIndex )
			{
				_Array[row].NextChanged = _Array[entityIndex].NextChanged;
				_Array[entityIndex].NextChanged = INVALID_DATASET_INDEX;
				if ( _Header->Last == entityIndex ) // it was the last one
					_Header->Last = row;
				nldebug( "Cancelling change of E%u", entityIndex );
			}
		}
	}
	trackerMutex().leave();
}
コード例 #9
0
ファイル: fxaa.cpp プロジェクト: junhuac/ryzomcore
CFXAA::~CFXAA()
{
	nldebug("3D: Destroy FXAA");

	if (!m_Mat.empty())
	{
		m_Driver->deleteMaterial(m_Mat);
	}

	delete m_VP;
	m_VP = NULL;
	delete m_PP;
	m_PP = NULL;

	m_Driver = NULL;
}
コード例 #10
0
BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
{
	// initialize nel context
	if (!NLMISC::INelContext::isContextInitialised())
	{
		new NLMISC::CLibraryContext(GetSharedNelContext());
		nldebug("NeL Vertex Tree Paint: DllMain");
	}

	hInstance = hinstDLL;				// Hang on to this DLL's instance handle.

	switch (fdwReason) {
		case DLL_PROCESS_ATTACH:
			InitCustomControls(hInstance);	// Initialize MAX's custom controls
			InitCommonControls();			// Initialize Win95 controls
			break;
		}
			
	return (TRUE);
}
コード例 #11
0
ファイル: dynloadlib.cpp プロジェクト: sythaeryn/pndrpg
void CLibrary::freeLibrary()
{
	if (_LibHandle)
	{
		nlassert(_Ownership);

		if (_PureNelLibrary)
		{
			// call the private finalization method.
			_PureNelLibrary->_onLibraryUnloaded();
		}

		nldebug("Freeing dynamic library '%s'", _LibFileName.c_str());
		nlFreeLibrary(_LibHandle);

		_PureNelLibrary = NULL;
		_LibHandle = NULL;
		_Ownership = false;
		_LibFileName = "";
	}
}
コード例 #12
0
ファイル: ms_automaton.cpp プロジェクト: mixxit/solinia
void CMirrorService::receiveMessageToForwardFromClient( CMessage& msgin, TServiceId senderId )
{
	H_AUTO(receiveMessageToForwardFromClient);

	uint8 counter;
	msgin.serial( counter ); // there are no multiple messages, but there can be multiple destinations
	if ( counter == MSG_BROADCAST )
	{
		CMemStream ms = msgin.extractStreamFromPos( msgin.getHeaderSize() + sizeof(counter) );
#ifdef NL_DEBUG
		string name = msgin.readTypeAtCurrentPos(); // warning: the pos is updated in msgin
		nldebug( "MSG: Broadcasting message from %s (msg %s, %u b)", servStr(senderId).c_str(), name.c_str(), ms.length() );
#endif
		pushMessageToLocalQueue( _MessagesToBroadcastLocally, senderId, ms );
		_RemoteMSList.pushMessageToRemoteQueue( DEST_MSG_BROADCAST, senderId, ms );
	}
	else
	{
		for ( uint i=0; i!=(uint)counter; ++i )
		{
			TServiceId destId;
			msgin.serial( destId );
			TClientServices::iterator ics = _ClientServices.find( destId );
			if ( ics != _ClientServices.end() )
			{
				// Destination service is local => buffer the message (which is found in the stream after the list of destinations)
				CMemStream m = msgin.extractStreamFromPos( msgin.getHeaderSize() + sizeof(counter) + counter*sizeof(destId) );
				pushMessageToLocalQueue( GET_CLIENT_SERVICE_INFO(ics).Messages, senderId, m );
			}
			else
			{
				// Destination service is remote => find the corresponding remote MS and buffer the message
				CMemStream m = msgin.extractStreamFromPos( msgin.getHeaderSize() + sizeof(counter) + counter*sizeof(destId) );
				_RemoteMSList.pushMessageToRemoteQueue( (TServiceId)destId, (TServiceId)senderId, m );
			}
		}
	}
}
コード例 #13
0
void CSampleBank::onUpdate()
{
	if (_SplitLoadDone)
	{
		nldebug("Some samples have been loaded");
		if (_LoadList.empty())
		{
			// all the samples are loaded, we can compute the bank size.
			TSampleTable::iterator	first(_Samples.begin()), last(_Samples.end());
			for (; first != last; ++first)
			{
				_ByteSize += first->second->getSize();
			}

			_SampleBankManager->m_LoadedSize += _ByteSize;

			// stop the update.
			_SampleBankManager->m_AudioMixer->unregisterUpdate(this);
			_LoadingDone = true;

			// Force an update in the background manager (can restar stopped sound).
			_SampleBankManager->m_AudioMixer->getBackgroundSoundManager()->updateBackgroundStatus();

			nlinfo("Sample bank %s loaded.", CStringMapper::unmap(_Name).c_str());
		}
		else
		{
			_SplitLoadDone = false;
			for (uint i=0; i<ASYNC_LOADING_SPLIT && !_LoadList.empty(); ++i)
			{
				CAsyncFileManagerSound::getInstance().loadWavFile(_LoadList.front().first, CStringMapper::unmap(_LoadList.front().second)+".wav");
				_LoadList.pop_front();
			}
			// add a end loading event...
			CAsyncFileManagerSound::getInstance().signal(&_SplitLoadDone);
		}
	}
}
コード例 #14
0
ファイル: vegetable_editor.cpp プロジェクト: AzyxWare/ryzom
void CVegetableEditor::release()
{
	//H_AUTO2
	nldebug("CVegetableEditor::release");

	if(_VegetableCollisionEntity)
	{
		_VegetableCollisionManager->deleteEntity(_VegetableCollisionEntity);
		_VegetableCollisionEntity= NULL;
	}
	if(_VegetableCollisionManager)
	{
		delete _VegetableCollisionManager;
		_VegetableCollisionManager= NULL;
	}

	// delete Landscape
	if(_VegetableLandscape)
	{
		Modules::veget().getScene()->deleteModel(_VegetableLandscape);
		_VegetableLandscape= NULL;
	}
}
コード例 #15
0
ファイル: mysql_wrapper.cpp プロジェクト: Kiddinglife/ryzom
	std::string encodeDate(NLMISC::TTime date)
	{
		time_t baseTime = time_t(date);
		// convert UTC time_t into local time, including daillight adjustment
		struct tm *converted = localtime(&baseTime);

		if (converted == NULL)
		{
			nldebug("Failed to convert %dl into a time structure", date);
			return "0000-00-00 00:00:00";
		}

		std::string str;
		str = NLMISC::toString("%4u-%02u-%02u %u:%02u:%02u", 
			converted->tm_year+1900, 
			converted->tm_mon+1, 
			converted->tm_mday,
			converted->tm_hour,
			converted->tm_min,
			converted->tm_sec);

		return str;
	}
コード例 #16
0
ファイル: words_dictionary.cpp プロジェクト: mixxit/solinia
/* Load the config file and the related words files. Return false in case of failure.
 * Config file variables:
 * - WordsPath: where to find <filter>_words_<languageCode>.txt
 * - LanguageCode: language code (ex: en for English)
 * - Utf8: results are in UTF8, otherwise in ANSI string
 * - Filter: "*" for all files (default) or a name (ex: "item").
 * - AdditionalFiles/AdditionalFileColumnTitles
 */
bool CWordsDictionary::init( const string& configFileName )
{
	// Read config file
	bool cfFound = false;
	CConfigFile cf;
	try
	{
		cf.load( configFileName );
		cfFound = true;
	}
	catch ( EConfigFile& e )
	{
		nlwarning( "WD: %s", e.what() );
	}
	string wordsPath, languageCode, filter = "*";
	vector<string> additionalFiles, additionalFileColumnTitles;
	bool filterAll = true, utf8 = false;
	if ( cfFound )
	{
		CConfigFile::CVar *v = cf.getVarPtr( "WordsPath" );
		if ( v )
		{
			wordsPath = v->asString();
			/*if ( (!wordsPath.empty()) && (wordsPath[wordsPath.size()-1]!='/') )
				wordsPath += '/';*/
		}
		v = cf.getVarPtr( "LanguageCode" );
		if ( v )
			languageCode = v->asString();
		v = cf.getVarPtr( "Utf8" );
		if ( v )
			utf8 = (v->asInt() == 1);
		v = cf.getVarPtr( "Filter" );
		if ( v )
		{
			filter = v->asString();
			filterAll = (filter == "*");
		}
		v = cf.getVarPtr( "AdditionalFiles" );
		if ( v )
		{
			for ( uint i=0; i!=v->size(); ++i )
				additionalFiles.push_back( v->asString( i ) );
			v = cf.getVarPtr( "AdditionalFileColumnTitles" );
			if ( v->size() != additionalFiles.size() )
			{
				nlwarning( "AdditionalFiles and AdditionalFileColumnTitles have different size, ignoring second one" );
				additionalFileColumnTitles.resize( v->size(), DefaultColTitle );
			}
			else
			{
				for ( uint i=0; i!=v->size(); ++i )
					additionalFileColumnTitles.push_back( v->asString( i ) );
			}
		}

	}
	if ( languageCode.empty() )
		languageCode = "en";

	// Load all found words files
	const string ext = ".txt";
	vector<string> fileList;
	CPath::getPathContent( wordsPath, false, false, true, fileList );
	for ( vector<string>::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl )
	{
		const string& filename = (*ifl);
		string::size_type p = string::npos;
		bool isAdditionalFile = false;

		// Test if filename is in additional file list
		uint iAdditionalFile;
		for ( iAdditionalFile=0; iAdditionalFile!=additionalFiles.size(); ++iAdditionalFile )
		{
			if ( (p = filename.find( additionalFiles[iAdditionalFile] )) != string::npos )
			{
				isAdditionalFile = true;
				break;
			}
		}

		// Or test if filename is a words_*.txt file
		string pattern = string("_words_") + languageCode + ext;
		if ( isAdditionalFile ||
			 ((p = filename.find( pattern )) != string::npos) )
		{
			// Skip if a filter is specified and does not match the current file
			if ( (!filterAll) && (filename.find( filter+pattern ) == string::npos) )
				continue;

			// Load file
			nldebug( "WD: Loading %s", filename.c_str() );
			_FileList.push_back( filename );
			string::size_type origSize = filename.size() - ext.size();
			const string truncFilename = CFile::getFilenameWithoutExtension( filename );
			const string wordType = isAdditionalFile ? "" : truncFilename.substr( 0, p - (origSize - truncFilename.size()) );
			const string colTitle = isAdditionalFile ? additionalFileColumnTitles[iAdditionalFile] : DefaultColTitle;

			// Load Unicode Excel words file
			STRING_MANAGER::TWorksheet worksheet;
			STRING_MANAGER::loadExcelSheet( filename, worksheet );
			uint ck, cw = 0;
			if ( worksheet.findId( ck ) && worksheet.findCol( ucstring(colTitle), cw ) ) // =>
			{
				for ( std::vector<STRING_MANAGER::TWorksheet::TRow>::iterator ip = worksheet.begin(); ip!=worksheet.end(); ++ip )
				{
					if ( ip == worksheet.begin() ) // skip first row
						continue;
					STRING_MANAGER::TWorksheet::TRow& row = *ip;
					_Keys.push_back( row[ck].toString() );
					string word = utf8 ? row[cw].toUtf8() : row[cw].toString();
					_Words.push_back( word );
				}
			}
			else
				nlwarning( "WD: %s ID or %s not found in %s", wordType.c_str(), colTitle.c_str(), filename.c_str() );
		}
	}

	if ( _Keys.empty() )
	{
		if ( wordsPath.empty() )
			nlwarning( "WD: WordsPath missing in config file %s", configFileName.c_str() );
		nlwarning( "WD: %s_words_%s.txt not found", filter.c_str(), languageCode.c_str() );
		return false;
	}
	else
		return true;
}
コード例 #17
0
	void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
	{
		//H_AUTO2
		nldebug("CObjectViewer::init");

		// load and set remap extensions from config
		//Modules::config().configRemapExtensions();

		// load and set search paths from config
		//Modules::config().configSearchPaths();

		// set background color from config
		Modules::config().setAndCallback("BackgroundColor", CConfigCallback(this, &CObjectViewer::cfcbBackgroundColor));	

		// set graphics driver from config
		Modules::config().setAndCallback("GraphicsDriver",CConfigCallback(this,&CObjectViewer::cfcbGraphicsDriver));

		// create the driver
		nlassert(!_Driver);

		_Driver = UDriver::createDriver(NULL, _Direct3D, NULL);
		nlassert(_Driver);

		// initialize the window with config file values
		_Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32));

		_Light = ULight::createLight();

		// set mode of the light
		_Light->setMode(ULight::DirectionalLight);

		// set position of the light
		_Light->setPosition(CVector(-20.f, 30.f, 10.f));

		// white light
		_Light->setAmbiant(CRGBA(255, 255, 255));

		// set and enable the light
		_Driver->setLight(0, *_Light);
		_Driver->enableLight(0);

		// Create a scene
		_Scene = _Driver->createScene(true);

		_PlayListManager = _Scene->createPlayListManager();

		_Scene->enableLightingSystem(true);

		// create the camera
		UCamera camera = _Scene->getCam();

		camera.setTransformMode (UTransformable::DirectMatrix);

		setSizeViewport(w, h);

		// camera will look at entities
		updateCamera(0,0,0);

		NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0);

		_MouseListener = _Driver->create3dMouseListener();
		_MouseListener->setMatrix(Modules::objView().getScene()->getCam().getMatrix());
		_MouseListener->setFrustrum(Modules::objView().getScene()->getCam().getFrustum());
		_MouseListener->setHotSpot(hotSpot);
		_MouseListener->setMouseMode(U3dMouseListener::edit3d);
	}
コード例 #18
0
ファイル: fxaa.cpp プロジェクト: junhuac/ryzomcore
CFXAA::CFXAA(NL3D::UDriver *driver) : m_Driver(driver), m_PP(NULL), m_VP(NULL), m_Width(~0), m_Height(~0)
{
	nldebug("3D: Create FXAA");

	CDriverUser *dru = static_cast<CDriverUser *>(driver);
	NL3D::IDriver *drv = (dru)->getDriver();

	if (drv->supportBloomEffect() && drv->supportNonPowerOfTwoTextures())
	{
		m_PP = new CPixelProgram();
		// arbfp1
		{
			IProgram::CSource *source = new IProgram::CSource();
			source->Features.MaterialFlags = CProgramFeatures::TextureStages;
			source->Profile = IProgram::arbfp1;
			source->setSourcePtr(a_arbfp1);
			m_PP->addSource(source);
		}
		// ps_2_0
		{
			IProgram::CSource *source = new IProgram::CSource();
			source->Features.MaterialFlags = CProgramFeatures::TextureStages;
			source->Profile = IProgram::ps_2_0;
			source->setSourcePtr(a_ps_2_0);
			m_PP->addSource(source);
		}
		if (!drv->compilePixelProgram(m_PP))
		{
			nlwarning("3D: No supported pixel program for FXAA effect");

			delete m_PP;
			m_PP = NULL;
		}
		else
		{
			nldebug("3D: FXAA pixel program available");
		}
	}

	if (!m_PP)
	{
		return;
	}

	// create vp
	{
		m_VP = new CVertexProgram();
		// nelvp
		{
			IProgram::CSource *source = new IProgram::CSource();
			source->Features.MaterialFlags = CProgramFeatures::TextureStages;
			source->Profile = IProgram::nelvp;
			source->setSourcePtr(a_nelvp);
			m_VP->addSource(source);
		}
		if (!drv->compileVertexProgram(m_VP))
		{
			nlwarning("3D: No supported vertex program for FXAA effect");

			delete m_VP;
			m_VP = NULL;
			delete m_PP;
			m_PP = NULL;
		}
		else
		{
			nldebug("3D: FXAA vertex program available");
		}
	}

	if (!m_VP)
	{
		return;
	}
	
	// create material and vb
	{
		m_Mat = m_Driver->createMaterial();
		m_Mat.initUnlit();
		m_Mat.setColor(CRGBA::White);
		m_Mat.setBlend (false);
		m_Mat.setAlphaTest (false);
		NL3D::CMaterial *mat = m_Mat.getObjectPtr();
		mat->setShader(NL3D::CMaterial::Normal);
		mat->setBlendFunc(CMaterial::one, CMaterial::zero);
		mat->setZWrite(false);
		mat->setZFunc(CMaterial::always);
		mat->setDoubleSided(true);

		m_QuadUV.V0 = CVector(0.f, 0.f, 0.5f);
		m_QuadUV.V1 = CVector(1.f, 0.f, 0.5f);
		m_QuadUV.V2 = CVector(1.f, 1.f, 0.5f);
		m_QuadUV.V3 = CVector(0.f, 1.f, 0.5f);

		/*if (drv->textureCoordinateAlternativeMode())
		{
			m_QuadUV.Uv0 = CUV(0.f,  1.f);
			m_QuadUV.Uv1 = CUV(1.f, 1.f);
			m_QuadUV.Uv2 = CUV(1.f, 0.f);
			m_QuadUV.Uv3 = CUV(0.f,  0.f);
		}
		else
		{*/
			m_QuadUV.Uv0 = CUV(0.f,  0.f);
			m_QuadUV.Uv1 = CUV(1.f, 0.f);
			m_QuadUV.Uv2 = CUV(1.f, 1.f);
			m_QuadUV.Uv3 = CUV(0.f,  1.f);
		/*}*/

		/*CVertexBuffer &vb = m_VB;
		vb.clearValueEx();
		vb.addValueEx(CVertexBuffer::Position, CVertexBuffer::Float3);
		vb.addValueEx(CVertexBuffer::TexCoord0, CVertexBuffer::Float2);
		vb.addValueEx(CVertexBuffer::TexCoord1, CVertexBuffer::Float4);
		vb.initEx();
		vb.setPreferredMemory(CVertexBuffer::RAMVolatile, false);
		vb.setNumVertices(4);*/
	}
}
コード例 #19
0
ファイル: visual_config.cpp プロジェクト: nimetu/rrs_server
void CVisualConfig::serial(NLMISC::IStream & f) throw (NLMISC::EStream) {
    if (!f.isReading()) {
        throw "This is only for reading";
    }

    uint8 ver;
    f.serial(ver);
    nldebug("CVisualConfig::serial version %d", ver);

    if (ver < 2) {
        pktFormat = (EPacketFormat) ver;
    } else {
        f.serialShortEnum(pktFormat);
    }

    f.serialShortEnum(Race);

    if (ver >= 2) {
        f.serial(Age);
        if (Age > 2) {
            Age = 2;
        }
    } else {
        Age = 0;
    }

    if (pktFormat == PKT_SHORT) {
        nldebug(">> short packet");
        vpa.serial(f);
        vpb.serial(f);
        vpc.serial(f);
        nlinfo("1");
    } else {
        nldebug(">> long packet");
        // they say bitfields are compiler and platform specific - this is mainly for php
        uint32 b;
        f.serial(b);
        vpa.PropertySubData.Sex = b;
        f.serial(b);
        vpa.PropertySubData.JacketModel = b;
        f.serial(b);
        vpa.PropertySubData.JacketColor = b;
        f.serial(b);
        vpa.PropertySubData.TrouserModel = b;
        f.serial(b);
        vpa.PropertySubData.TrouserColor = b;
        f.serial(b);
        vpa.PropertySubData.WeaponRightHand = b;
        f.serial(b);
        vpa.PropertySubData.WeaponLeftHand = b;
        f.serial(b);
        vpa.PropertySubData.ArmModel = b;
        f.serial(b);
        vpa.PropertySubData.ArmColor = b;
        f.serial(b);
        vpa.PropertySubData.HatModel = b;
        f.serial(b);
        vpa.PropertySubData.HatColor = b;

        f.serial(b);
        vpb.PropertySubData.Name = b;
        f.serial(b);
        vpb.PropertySubData.HandsModel = b;
        f.serial(b);
        vpb.PropertySubData.HandsColor = b;
        f.serial(b);
        vpb.PropertySubData.FeetModel = b;
        f.serial(b);
        vpb.PropertySubData.FeetColor = b;
        f.serial(b);
        vpb.PropertySubData.RTrail = b;
        f.serial(b);
        vpb.PropertySubData.LTrail = b;

        f.serial(b);
        vpc.PropertySubData.MorphTarget1 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget2 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget3 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget4 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget5 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget6 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget7 = b;
        f.serial(b);
        vpc.PropertySubData.MorphTarget8 = b;
        f.serial(b);
        vpc.PropertySubData.EyesColor = b;
        f.serial(b);
        vpc.PropertySubData.Tattoo = b;
        f.serial(b);
        vpc.PropertySubData.CharacterHeight = b;
        f.serial(b);
        vpc.PropertySubData.TorsoWidth = b;
        f.serial(b);
        vpc.PropertySubData.ArmsWidth = b;
        f.serial(b);
        vpc.PropertySubData.LegsWidth = b;
        f.serial(b);
        vpc.PropertySubData.BreastSize = b;
    }

    // hair color can only come from HEAD_SLOT, so use it and clamp it
    HairColor = vpa.PropertySubData.HatColor;
    NLMISC::clamp(HairColor, (uint) 1, (uint) 6); // H1..H6

    sint32 angle;
    f.serial(angle);
    // convert angle from CCW to CW (clockwise)
    angle = (270 - angle);
    if (angle < 0) {
        angle += 360;
    }
    Theta = angle * 3.14 / 180;
    nlinfo("2");
    f.serial(angle);
    Phi = angle * 3.14 / 180;
    nlinfo("3");
    f.serial(FaceShot);
    nlinfo("4");
    Background.serial(f);
    nlinfo("5");
    if (ver >= 2) {
        f.serial(useFx);
        nlinfo("6");
    } else {
        useFx = Background.A == 255;
    }

    nldebug(">> serial in");
    nldebug(">> race: %s", EGSPD::CPeople::toString(Race).c_str());
    nldebug(">> age: %d", Age);
    nldebug("VPA: %"NL_I64"u : Chest(%d,%d) Legs(%d,%d) Arms(%d,%d) Hat(%d,%d) RH(%d) LH(%d)", vpa.PropertyA,
            (uint) vpa.PropertySubData.JacketModel, (uint) vpa.PropertySubData.JacketColor,
            (uint) vpa.PropertySubData.TrouserModel, (uint) vpa.PropertySubData.TrouserColor,
            (uint) vpa.PropertySubData.ArmModel, (uint) vpa.PropertySubData.ArmColor,
            (uint) vpa.PropertySubData.HatModel, (uint) vpa.PropertySubData.HatColor,
            (uint) vpa.PropertySubData.WeaponRightHand,
            (uint) vpa.PropertySubData.WeaponLeftHand);
    nldebug("VPB: %"NL_I64"u : Hands(%d,%d) Feet(%d,%d).", vpb.PropertyB,
            (uint) vpb.PropertySubData.HandsModel, (uint) vpb.PropertySubData.HandsColor,
            (uint) vpb.PropertySubData.FeetModel, (uint) vpb.PropertySubData.FeetColor);
    nldebug("VPC: %"NL_I64"u : EyesColor(%d) Tattoo(%d).", vpc.PropertyC,
            (uint) vpc.PropertySubData.EyesColor, (uint) vpc.PropertySubData.Tattoo);
    nldebug("VPC: morph(%d,%d,%d,%d,%d,%d,%d,%d), gabarit(%d,%d,%d,%d,%d)",
            (uint) vpc.PropertySubData.MorphTarget1,
            (uint) vpc.PropertySubData.MorphTarget2,
            (uint) vpc.PropertySubData.MorphTarget3,
            (uint) vpc.PropertySubData.MorphTarget4,
            (uint) vpc.PropertySubData.MorphTarget5,
            (uint) vpc.PropertySubData.MorphTarget6,
            (uint) vpc.PropertySubData.MorphTarget7,
            (uint) vpc.PropertySubData.MorphTarget8,
            (uint) vpc.PropertySubData.CharacterHeight,
            (uint) vpc.PropertySubData.TorsoWidth,
            (uint) vpc.PropertySubData.ArmsWidth,
            (uint) vpc.PropertySubData.LegsWidth,
            (uint) vpc.PropertySubData.BreastSize);
    nldebug(">> angle = %f, %f", Theta, Phi);
    nldebug(">> face shot: %s", FaceShot ? "yes" : "no");
    nldebug(">> use fx: %s", useFx ? "yes" : "no");
}
コード例 #20
0
void CSheetId::loadSheetId ()
{
	H_AUTO(CSheetIdInit);
	//nldebug("Loading sheet_id.bin");

	// Open the sheet id to sheet file name association
	CIFile file;
	std::string path = CPath::lookup("sheet_id.bin", false, false);
	if(!path.empty() && file.open(path))
	{
		// clear entries
		_FileExtensions.clear ();
		_SheetIdToName.clear ();
		_SheetNameToId.clear ();

		// reserve space for the vector of file extensions
		_FileExtensions.resize(1 << (NL_SHEET_ID_TYPE_BITS));

		// Get the map from the file
		map<uint32,string> tempMap;
		contReset(tempMap);
		file.serialCont(tempMap);
		file.close();

		if (_RemoveUnknownSheet)
		{
			uint32 removednbfiles = 0;
			uint32 nbfiles = (uint32)tempMap.size();

			// now we remove all files that not available
			map<uint32,string>::iterator itStr2;
			for( itStr2 = tempMap.begin(); itStr2 != tempMap.end(); )
			{
				if (CPath::exists ((*itStr2).second))
				{
					++itStr2;
				}
				else
				{
					map<uint32,string>::iterator olditStr = itStr2;
					//nldebug ("Removing file '%s' from CSheetId because the file not exists", (*olditStr).second.c_str ());
					itStr2++;
					tempMap.erase (olditStr);
					removednbfiles++;
				}
			}
			nlinfo ("SHEETID: Removed %d files on %d from CSheetId because these files doesn't exists", removednbfiles, nbfiles);
		}

		// Convert the map to one big string and 1 static map (id to name)
		{
			// Get the number and size of all strings
			vector<CChar> tempVec; // Used to initialise the first map
			uint32 nNb = 0;
			uint32 nSize = 0;
			map<uint32,string>::const_iterator it = tempMap.begin();
			while (it != tempMap.end())
			{
				nSize += (uint32)it->second.size()+1;
				nNb++;
				it++;
			}

			// Make the big string (composed of all strings) and a vector referencing each string
			tempVec.resize(nNb);
			_AllStrings.Ptr = new char[nSize];
			it = tempMap.begin();
			nSize = 0;
			nNb = 0;
			while (it != tempMap.end())
			{
				tempVec[nNb].Ptr = _AllStrings.Ptr+nSize;
				strcpy(_AllStrings.Ptr+nSize, it->second.c_str());
				toLower(_AllStrings.Ptr+nSize);
				nSize += (uint32)it->second.size()+1;
				nNb++;
				it++;
			}

			// Finally build the static map (id to name)
			_SheetIdToName.reserve(tempVec.size());
			it = tempMap.begin();
			nNb = 0;
			while (it != tempMap.end())
			{
				_SheetIdToName.add(pair<uint32, CChar>(it->first, CChar(tempVec[nNb])));

				nNb++;
				it++;
			}

			// The vector of all small string is not needed anymore we have all the info in
			// the static map and with the pointer AllStrings referencing the beginning.
		}

		// Build the invert map (Name to Id) & file extension vector
		{
			uint32 nSize = (uint32)_SheetIdToName.size();
			_SheetNameToId.reserve(nSize);
			CStaticMap<uint32,CChar>::iterator itStr;
			for( itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr )
			{
				// add entry to the inverse map
				_SheetNameToId.add( make_pair((*itStr).second, (*itStr).first) );

				// work out the type value for this entry in the map
				TSheetId sheetId;
				sheetId.Id=(*itStr).first;
				uint32 type = sheetId.IdInfos.Type;

				// check whether we need to add an entry to the file extensions vector
				if (_FileExtensions[type].empty())
				{
					// find the file extension part of the given file name
					_FileExtensions[type] = toLower(CFile::getExtension((*itStr).second.Ptr));
				}
				nSize--;
			}
			_SheetNameToId.endAdd();
		}
	}
	else
	{
		nlerror("<CSheetId::init> Can't open the file sheet_id.bin");
	}
	nldebug("Finished loading sheet_id.bin: %u entries read",_SheetIdToName.size());
}
コード例 #21
0
ファイル: connection.cpp プロジェクト: CCChaos/RyzomCore
std::string CNelLauncherConnection::checkLogin(const std::string &login, const std::string &password, const std::string &clientApp)
{
	m_Shards.clear();
	m_Login = m_Password = m_ClientApp = "";

	if(ConfigFile.exists("UseDirectClient") && ConfigFile.getVar("UseDirectClient").asBool())
	{
		ucstring pwd = ucstring(password);
		NLMISC::CHashKeyMD5 hk = NLMISC::getMD5((uint8*)pwd.c_str(), pwd.size());
		std::string cpwd = hk.toString();
		nlinfo("The crypted password is %s", cpwd.c_str());
		std::string result = NLNET::CLoginClient::authenticate(ConfigFile.getVar("StartupHost").asString(), login, cpwd, clientApp);
		if (!result.empty()) return result;
		for(uint i = 0; i < NLNET::CLoginClient::ShardList.size(); ++i)
		{
			nldebug("Shard '%u' '%s' '%u'", NLNET::CLoginClient::ShardList[i].Id, NLNET::CLoginClient::ShardList[i].Name.toString().c_str(), NLNET::CLoginClient::ShardList[i].NbPlayers);
			m_Shards.push_back(CShard("1", true,
				NLNET::CLoginClient::ShardList[i].Id, NLNET::CLoginClient::ShardList[i].Name.toString(), NLNET::CLoginClient::ShardList[i].NbPlayers,
				"1", "1"));
		}
		m_Login = login;
		m_Password = password;
		m_ClientApp = clientApp;
		return "";
	}

	if(!connect())
		return "Can't connect (error code 1)";

	//if(VerboseLog) nlinfo("Connected");

	if(!send(ConfigFile.getVar("StartupPage").asString()+"?login="******"&password="******"&clientApplication="+clientApp))
		return "Can't send (error code 2)";

	//if(VerboseLog) nlinfo("Sent request login check");

	std::string res;

	if(!receive(res))
		return "Can't receive (error code 3)";

	//if(VerboseLog) nlinfo("Received request login check");

	if(res.empty())
		return "Empty answer from server (error code 4)";

	if(res[0] == '0')
	{
		// server returns an error
		nlwarning("server error: %s", res.substr(2).c_str());
		return res.substr(2);
	}
	else if(res[0] == '1')
	{
		// server returns ok, we have the list of shard
		uint nbs = atoi(res.substr(2).c_str());
		std::vector<std::string> lines;

		NLMISC::explode(res, std::string("\n"), lines, true);

	//	if(VerboseLog)
	//	{
			//nlinfo ("Exploded, with nl, %d res", lines.size());
/*		      for (uint i = 0; i < lines.size(); i++)
			{
				nlinfo (" > '%s'", lines[i].c_str());
			}*/
	//	}

		if(lines.size() != nbs+1)
		{
			nlwarning("bad shard lines number %d != %d", lines.size(), nbs+1);
			nlwarning("'%s'", res.c_str());
			return "bad lines numbers (error code 5)";
		}

		for(uint i = 1; i < lines.size(); i++)
		{
			std::vector<std::string> res;
			NLMISC::explode(lines[i], std::string("|"), res);

	//		if(VerboseLog)
	//		{
	//			nlinfo ("Exploded with '%s', %d res", "|", res.size());
/*			      for (uint i = 0; i < res.size(); i++)
				{
					nlinfo (" > '%s'", res[i].c_str());
				}*/
	//		}

			if(res.size() != 7)
			{
				nlwarning("bad | numbers %d != %d", res.size(), 7);
				nlwarning("'%s'", lines[i].c_str());
				return "bad pipe numbers (error code 6)";
			}
			m_Shards.push_back(CShard(res[0], atoi(res[1].c_str())>0, atoi(res[2].c_str()), res[3], atoi(res[4].c_str()), res[5], res[6]));
		}
	}
	else
	{
		// server returns ???
		nlwarning("%s", res.c_str());
		return res;
	}

	m_Login = login;
	m_Password = password;
	m_ClientApp = clientApp;

	return "";
}
コード例 #22
0
ファイル: formdelegate.cpp プロジェクト: sythaeryn/pndrpg
	void FormDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
		const QModelIndex &index) const
	{
		const CGeorgesFormProxyModel * mp = dynamic_cast<const CGeorgesFormProxyModel *>(index.model());
		const CGeorgesFormModel * m = dynamic_cast<const CGeorgesFormModel *>(mp->sourceModel());

		const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType();
		int numDefinitions = type->getNumDefinition();

		if (numDefinitions) 
		{
			QComboBox *comboBox = static_cast<QComboBox*>(editor);
			QString value = comboBox->currentText();
			QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
			if (value == oldValue) 
			{
				// nothing's changed
			}
			else 
			{
				nldebug(QString("setModelData from %1 to %2")
					.arg(oldValue).arg(value).toUtf8().constData());
				model->setData(index, value, Qt::EditRole);
			}
		}
		else 
		{
			switch (type->getType()) 
			{
			case NLGEORGES::UType::UnsignedInt:
			case NLGEORGES::UType::SignedInt:
				{
					QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
					int value = spinBox->value();
					QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
					if (QString("%1").arg(value) == oldValue) 
					{
						// nothing's changed
					}
					else 
					{
						nldebug(QString("setModelData from %1 to %2")
							.arg(oldValue).arg(value).toUtf8().constData());
						model->setData(index, value, Qt::EditRole);
					}
					break;
				}
			case NLGEORGES::UType::Double:
				{
					QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
					double value = spinBox->value();
					QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
					if (QString("%1").arg(value) == oldValue) 
					{
						// nothing's changed
					}
					else 
					{
						nldebug(QString("setModelData from %1 to %2")
							.arg(oldValue).arg(value).toUtf8().constData());
						model->setData(index, value, Qt::EditRole);
					}
					break;
				}
			case NLGEORGES::UType::Color:
				{
					break; // TODO
				}
			default: // UType::String
				{
					QLineEdit *textEdit = static_cast<QLineEdit*>(editor);
					QString value = textEdit->text();
					QString oldValue = index.model()->data(index, Qt::DisplayRole).toString();
					if (value == oldValue) 
					{
						// nothing's changed
					}
					else 
					{
						nldebug(QString("setModelData from %1 to %2")
							.arg(oldValue).arg(value).toUtf8().constData());
						model->setData(index, value, Qt::EditRole);
					}
					break;
				}
			}
		}
	}