Example #1
0
int main(int argc, char**argv)
{
  logOut("\n        [SW3::PHOENIXIA]\n");
  logOut("        by[studio AMANgA]@[http://studioamanga.free.fr]\n\n\n");
  
  logOut("        from :");
  logOut(argv[0]);


  // Initialisation d'OpenGL et création de la fenêtre
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
  glutInitWindowSize(SCREEN_X,SCREEN_Y);
  glutInitWindowPosition(10,10);
  glutCreateWindow("SW3::PHOENIXIA");
  // Initialisation des variables
  Init();

  // Activation de la gestion du clavier
  glutKeyboardFunc(Keyboard);
  glutKeyboardUpFunc(KeyboardUp);
  glutSpecialFunc(Special);
  // Activation de la fonction de rendu
  glutDisplayFunc(Display);
  // Activation des fonctions de remise à jour
  glutReshapeFunc(Reshape);
  glutIdleFunc(Idle);

  logOut("  [OK] Initialisation terminée\n");

  // Entrée dans la boucle principale
  glutMainLoop();

  return 0;
}
Example #2
0
cssList* cssListInit(cssList * _this){
	cssObjectInit(cssAs(cssObject*,_this));
    
	_this->_begin = createAndInitCssListItem();
	_this->_begin->next = _this->_begin;
	_this->_begin->pre = _this->_begin;
    
	_this->_length = 0;
	_this->getLength = &cssListGetLength;
    
	_this->addAtLast = &cssListAddAtLast;
	_this->addAtFirst = &cssListAddAtFirst;
	_this->addAt = &cssListAddAt;
	_this->removeAt = &cssListRemoveAt;
	_this->removeFirst = &cssListRemoveFirst;
	_this->removeLast = &cssListRemoveLast;
	_this->remove = &cssListRemove;
	_this->get = &cssListGet;
    _this->clear = &cssListClear;
    
	_this->onCssObjectDelloc = _this->onDelloc;
	_this->onDelloc = &cssListOnDelloc;
    
    logOut("init cssList");
	return _this;
}
Example #3
0
void TitleWidget::initAction()
{
	m_menu = new QMenu(this);
	m_menu->setObjectName("MainMenu");

	QAction *searchAction = new QAction("搜索", m_menu);
	searchAction->setIcon(QIcon(":/menu_icon/search"));
	searchAction->setShortcut(tr("Ctrl+S"));
	searchAction->setStatusTip("搜索单曲,歌单...");
	connect(searchAction, SIGNAL(triggered()), this, SIGNAL(search()));

	QAction *logOutAction = new QAction("注销", m_menu);
	logOutAction->setIcon(QIcon(":/menu_icon/logout"));
	logOutAction->setShortcut(tr("Ctrl+E"));
	logOutAction->setStatusTip("退出登录...");
	connect(logOutAction, SIGNAL(triggered()), this, SIGNAL(logOut()));

	allLoopAction = new QAction("列表循环", m_menu);
	//allLoopAction->setIcon(QIcon(":/menu_icon/list_loop"));
	allLoopAction->setShortcut(tr("Ctrl+A"));
	allLoopAction->setCheckable(true);
	allLoopAction->setChecked(true);
	allLoopAction->setStatusTip("列表循环播放歌曲...");
	connect(allLoopAction, SIGNAL(triggered()), this, SLOT(setAllLoopChecked()));

	oneLoopAction = new QAction("单曲循环", m_menu);
	//oneLoopAction->setIcon(QIcon(":/menu_icon/one_loop"));
	oneLoopAction->setShortcut(tr("Ctrl+O"));
	oneLoopAction->setCheckable(true);
	oneLoopAction->setChecked(false);
	oneLoopAction->setStatusTip("单曲循环播放歌曲...");
	connect(oneLoopAction, SIGNAL(triggered()), this, SLOT(setOneLoopChecked()));

	randomLoopAction = new QAction("随机循环", m_menu);
	//randomLoopAction->setIcon(QIcon(":/menu_icon/random_loop"));
	randomLoopAction->setCheckable(true);
	randomLoopAction->setChecked(false);
	randomLoopAction->setShortcut(tr("Ctrl+R"));
	randomLoopAction->setStatusTip("随机循环播放歌曲...");
	connect(randomLoopAction, SIGNAL(triggered()), this, SLOT(setRandomLoopChecked()));

	QAction *exitAction = new QAction("退出软件", m_menu);
	exitAction->setIcon(QIcon(":/menu_icon/exit"));
	exitAction->setShortcut(tr("Ctrl+Q"));
	connect(exitAction, SIGNAL(triggered()), this, SIGNAL(exitWidget()));


	m_menu->addAction(searchAction);
	m_menu->addSeparator();
	m_menu->addAction(oneLoopAction);
	m_menu->addAction(allLoopAction);
	m_menu->addAction(randomLoopAction);
	m_menu->addSeparator();
	m_menu->addAction(logOutAction);
	m_menu->addSeparator();
	m_menu->addAction(exitAction);
	m_menu->adjustSize();

	m_menu->setVisible(false);
}
Example #4
0
void User::initPipe()
{
	if (m_pPipeClient)
		return;

	m_pPipeClient = new UserIPCPipeClient(getUserName(), getAppDataPath(), true);
	m_pPipeClient->onDisconnectEvent += delegate(&onPipeDisconnect);

	size_t x=0;

	do
	{
		try
		{
			m_pPipeClient->start();
			break;
		}
		catch (gcException &)
		{
			if (x > 5)
			{
				logOut();
				throw;
			}
			else
			{
				gcSleep(100);
				x++;
			}
		}
	}
	while (true);
}
Example #5
0
static void cssListOnDelloc(cssList * _this){
    
    logOut("destory cssList");
    
	cssListClear(_this);
    
	cssDelloc(_this->_begin);
    
	_this->onCssObjectDelloc(_this);
}
Example #6
0
void Logic::receive() {
    std::string msg = security.receive();
    int type = msg[0];
    std::string content(msg.data()+1, msg.size()-1);
    switch(type) {
        case 9: receiveFile(content); break;
        case 6: receiveFileRequest(content); break;
        case 12: logOut(); break;
        default: break;
    }
}
Example #7
0
StudentWindow::StudentWindow(DatabaseLayer *db, User loggedInUser) : MainWindow(db, loggedInUser, new StudentMainWidget())
{
    this->studentMainWidget = (StudentMainWidget *)mainWidget;
    this->lessonWidget = new StudentLessonWidget();
    this->testWidget = new TestWidget(db, email);

    connect(this->studentMainWidget, SIGNAL(selectedLesson(int)), this, SLOT(showLessonWidget(int)));
    connect(db, SIGNAL(newLessonCreated()), this, SLOT(newLessonCreated()));

    connect(this->lessonWidget, SIGNAL(prepared()), this->lessonWidget, SLOT(show()));
    connect(this->lessonWidget, SIGNAL(prepared()), this->studentMainWidget, SLOT(hide()));

    connect(this->lessonWidget, SIGNAL(transitLessons()), this->studentMainWidget, SLOT(show()));
    connect(this->lessonWidget, SIGNAL(logOut()), this, SLOT(save()));
    connect(this->lessonWidget, SIGNAL(logOut()), this, SLOT(logoff()));
    connect(this->lessonWidget, SIGNAL(transitLessons()), this->lessonWidget, SLOT(hide()));
    connect(this->lessonWidget, SIGNAL(logOut()), this->lessonWidget, SLOT(close()));

    QObject::connect(this->studentMainWidget->logOutButton, SIGNAL(clicked()), this, SLOT(save()));

}
void CServerListener::OnDisconnect ( CNetworkPeer &peer )
{
	tmNetUserMap::iterator itr = users.find(&peer);
	if (itr == users.end())	// we don't know who he is
		return;

	if (!game)
		return;

	game->remove(itr->second,peer);

	logOut("client disconnect","CServerListener::OnDisconnect",eLogLevel5);
}
void CServerListener::OnMessage ( CNetworkPeer &peer, CNetworkMessage &message )
{
	tmNetUserMap::iterator itr = users.find(&peer);
	if (itr == users.end())	// we don't know who he is
		return;

	if (!game)
		return;

	game->message(itr->second,peer,message);

	logOut("client message","CServerListener::OnMessage",eLogLevel5);

}
Example #10
0
void CServerListener::OnConnect ( CNetworkPeer &peer )
{
	tmNetUserMap::iterator itr = users.find(&peer);
	if (itr != users.end())	// we all ready have them and they have and ID
		return;

	users[&peer] = lastID++;
	if (!game)
		return;

	game->add(lastID-1,peer);

	logOut("client connect","CServerListener::OnConnect",eLogLevel5);
}
Example #11
0
int main( int argc, char *argv[] )
{
	{
	BinaryLogOut logOut( "IIdd", "test.txt" );
	int i = 1;
	logOut.log( &i, 1 );
	logOut.log( &i, 1 );
	double j = 1;
	logOut.log( &j, 1 );
	logOut.log( &j, 1 );
	}
	BinaryLogToCsv( "test.txt", "test.csv" );
	return 0;
}
Example #12
0
bool recordDatabase::removeUser(){
	if (isLoggedIn()){
		try{
			CString q = _T("");
			q.Format(_T("DELETE FROM accounts WHERE %s=%d"), dbFieldNames[ID],id);
			rawQuery(q,NULL);
			logOut();
			return true;
		}
		catch (int e){
			return false;
		}
	}
	return false;
}
Example #13
0
// Fonction de sortie du programme
void eXit(void)
{
  // Sauvegarde des configurations
  SaveCfg();
  // Destruction des objets dynamiques
  // destruction du menu
  if(SkinMenu)
    delete SkinMenu;
  //
  DelJ();

  if(Particule)
    delete Particule;

  if(mapDetail)
    {
      for(int iM=0 ; iM<nbMaps ; iM++)
	{
	  delete mapDetail[iM].tabClimat;
	}
      free(mapDetail);
    }

  clAvaMan::Kill();

  clSoundMan::Kill();

  // Sortie du programme
  logOut("\n  [OK] Destruction terminée ( time : %d )\n\n");//,int(TisT.GetTime()));
  logOut("  sw3..phoenixia(v0.4b)\n\n");

  exit(0);

  return;

}
Example #14
0
static void cssListRemoveAt(cssList * _this,long index){
    
	if (index<0||index>=_this->_length||_this->_length<=0) {
		logOut("cssListRemoveAt:index out of bounds");
		return;
	}
    
	cssListItem * tmp = _this->_begin;
	long i=0;
    
    if (index!=0) {
        if (index<_this->_length/2) {
            for (i = 0; i < index; ++i) {
                tmp = tmp->next;
            }
        }else{
            for (i = _this->_length-1; i >=index; --i) {
                tmp=tmp->pre;
            }
        }
        
        tmp->next->pre = tmp->pre;
        tmp->pre->next = tmp->next;
        
        tmp->value->release(tmp->value);
        
        cssDelloc(tmp);
    }else{
        
        _this->_begin->value->release(_this->_begin->value);
        
        //second
        tmp = _this->_begin->next;
        
        if (tmp!=_this->_begin) {
            _this->_begin->value = tmp->value;
            _this->_begin->next = tmp->next;
            _this->_begin->next->pre = _this->_begin;
            
            cssDelloc(tmp);
        }else{
            _this->_begin->value = NULL;
        }
    }
    
    _this->_length--;
}
Example #15
0
File: client.c Project: mannias/SO
void readConsole() {
	int a;
	char result[30];
	if (status == 0) {
		printf("Ingrese Numero de Opcion:\n");
		printf("1: Login\n");
		printf("2: Registrarse\n");
		printf("3: Cerrar\n");
		scanf("%d", &a);
		if (a == 1) {
			printf(
					"Ingrese Usuario y Contraseña\nSeparados por ',' de la forma Usuario,Contraseña\n");
			scanf("%30s", result);
			sendData(0, fillMessageData("login", "login", result), sizeof(Message));
			getResponce(0);

		} else if (a == 2) {
			printf(
					"Ingrese Nombre, Usuario y Contraseña\nSeparados por ',' de la forma\nNombre,Usuario,Contraseña\n");
			scanf("%30s", result);
			sendData(0, fillMessageData("login", "register", result), sizeof(Message));
			getResponce(0);

		} else if( a == 3){
			sendData(0, fillMessageData("client", "close", ""), sizeof(Message));
			closeConnection(0);
			exit(0);
		}
	} else if (status == 1) {
		printf("Ingrese Numero de Opcion:\n");
		printf("1: Enviar Email\n");
		printf("2: Recibir Emails\n");
		printf("3: Consultar Tarifacion\n");
		printf("4: Log Out\n");
		scanf("%d", &a);
		if (a == 1) {
			writeEmail();
		} else if (a == 2) {
			grabNewEmails();
		} else if( a == 3){
			getFee();
		} else if( a == 4){
			logOut();
		}
	}
}
Example #16
0
static void cssListAddAt(cssList * _this,cssObject * obj,long index){
    
	if (index<0||index>_this->_length) {
		logOut("cssListAddAt:index out of bounds");
		return;
	}
    
	if (_this->_begin->value!=NULL) {
		cssListItem * newItem = createAndInitCssListItem();
        
		if (index==_this->_length) {
			newItem->value = obj;
			newItem->pre = _this->_begin->pre;
			newItem->next = _this->_begin;
		}else if (index==0) {
			//switch value with begin
			newItem->value = _this->_begin->value;
			_this->_begin->value = obj;
			//add after begin
			newItem->pre = _this->_begin;
			newItem->next = _this->_begin->next;
		}else{
			cssListItem * tmp = _this->_begin;
			long i = 0;
			if (index<_this->_length/2) {
				for (i = 0; i < index; ++i) {
					tmp=tmp->next;
				}
			}else{
				for (i = _this->_length-1; i >= index; --i) {
					tmp=tmp->pre;
				}
			}
			newItem->next = tmp;
			newItem->pre = tmp->pre;
		}
		//insert new item
		newItem->pre->next = newItem;
		newItem->next->pre = newItem;
	}else{
		_this->_begin->value = obj;
	}
    
	obj->retain(obj);
	_this->_length++;
}
Example #17
0
void MainApp::logOut(bool bShowLogin, bool autoLogin, bool webLoggedOut)
{
	gcTrace("");

	m_pInternalLink->closeAll();
	safe_delete(m_pInternalLink);

	closeMainForm();
	wxTheApp->ProcessIdle();

	{
		std::lock_guard<std::mutex> a(m_UserLock);
		if (g_pUserHandle)
		{
			auto user = g_pUserHandle;

			g_pUserHandle = nullptr;
			DesuraJSBinding::gs_pItemManager = nullptr;

			user->getPipeDisconnectEvent() -= guiDelegate(this, &MainApp::onPipeDisconnect);
			user->logOut(!autoLogin);

			user->getAppUpdateProgEvent()				-= guiDelegate(this, &MainApp::onAppUpdateProg);
			user->getAppUpdateCompleteEvent()			-= guiDelegate(this, &MainApp::onAppUpdate);
			user->getWebCore()->getCookieUpdateEvent() -= guiDelegate(this, &MainApp::onCookieUpdate);
			user->getWebCore()->getLoggedOutEvent()		-= delegate(&onLoggedOutEvent);

			user->destroy();
		}
	}

	GetCVarManager()->saveAll();
	GetCVarManager()->cleanUserCvars();

	m_bLoggedIn = false;
	m_iMode = APP_MODE::MODE_UNINT;

	if (bShowLogin)
		showLogin(!autoLogin, webLoggedOut);

	HideLogForm();

	DeleteCookies();
	SetCrashDumpSettings(nullptr, true);
}
Example #18
0
 static string logForOpenGLObject(GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc)
 {
     GLint logLength = 0, charsWritten = 0;
     
     infoFunc(object, GL_INFO_LOG_LENGTH, &logLength);   
     
     if (logLength < 1)
         return string();
     
     char *buffer = new char[logLength];
     logFunc(object, logLength, &charsWritten, buffer);
     string logOut((const char*)buffer, logLength);        
     delete [] buffer;
     
     CHECK_GL_ERROR_DEBUG();
     
     return logOut;
 }
Example #19
0
void MainApp::offlineMode()
{
	if (m_iMode == APP_MODE::MODE_OFFLINE)
		return;

	if (m_bLoggedIn)
		logOut(false);

	closeMainForm();

	{
		std::lock_guard<std::mutex> a(m_UserLock);

		gcString path = UTIL::OS::getAppDataPath();

		if (g_pUserHandle)
			g_pUserHandle->destroy();

		g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE);
		g_pUserHandle->init(path.c_str());

		try
		{
			g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar);
			g_pUserHandle->getItemManager()->loadItems();
		}
		catch (gcException &)
		{
			g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar);
			g_pUserHandle->logOut();
			g_pUserHandle->destroy();
			throw;
		}
	}

	GetCVarManager()->loadUser(GetUserCore()->getUserId());
	m_iMode = APP_MODE::MODE_OFFLINE;

	showMainWindow();
	m_pInternalLink = new InternalLink(this);
}
Example #20
0
static cssObject * cssListGet(cssList * _this,long index){
    
	if (index<0||index>=_this->_length) {
		logOut("cssListGet:index out of bounds");
		return NULL;
	}
    
	cssListItem * tmp = _this->_begin;
	long i = 0;
	if (index<_this->_length/2) {
		for (i = 0; i < index; ++i) {
			tmp = tmp->next;
		}
	}else{
		for (i = _this->_length-1; i <= index; ++i) {
			tmp = tmp->pre;
		}
	}
    
	return tmp->value;
}
Example #21
0
mainClient::mainClient(const string& us, const string& pw, QMainWindow* from) : pagPadre(from) {
    try {
        client=new LinQedInClient(us,pw);
        this->setStyleSheet("background-color:lightblue;");
        this->setFixedSize(600, 430);
        QRect screenGeometry=QApplication::desktop()->screenGeometry();
        int x=(screenGeometry.width()-width())/2;
        int y=(screenGeometry.height()-height())/2;
        move(x,y);

        QLabel* titolo= new QLabel(this);
        titolo->setText("LinQedIn");
        titolo->setGeometry(20,15,200,30);
        QFont font("Ubuntu",20, QFont::Bold);
        titolo->setFont(font);

        QPushButton* logout=new QPushButton("LogOut",this);
        logout->setGeometry(490,20,90,30);
        logout->setStyleSheet("background-color:blue;color:white; font-weight:bold;");

        QPushButton* mostraPr=new QPushButton("Visualizza il profilo",this);
        mostraPr->setGeometry(40,70,150,30);
        mostraPr->setStyleSheet("background-color:white;");

        QPushButton* modificaPr=new QPushButton("Modifica il profilo",this);
        modificaPr->setGeometry(215,70,150,30);
        modificaPr->setStyleSheet("background-color:white;");

        QPushButton* modificaCont=new QPushButton("Gestisci i tuoi contatti",this);
        modificaCont->setGeometry(390,70,170,30);
        modificaCont->setStyleSheet("background-color:white;");

        areaRisultato=new QScrollArea(this);
        areaRisultato->setGeometry(30,115,540,220);
        areaRisultato->setStyleSheet("background-color:white;");
        areaRisultato->setFrameShadow(QFrame::Raised);
        areaRisultato->setFrameShape(QFrame::WinPanel);
        areaRisultato->setLineWidth(1);
        areaRisultato->setWidgetResizable(true);

        output=new QLabel(areaRisultato);
        output->setAlignment(Qt::AlignTop);
        output->setMargin(5);

        QLabel* indicazione=new QLabel("Inserire lo username dell'utente che si desidera cercare:",this);
        indicazione->setGeometry(30,350,500,25);

        campo=new QLineEdit(this);
        campo->setGeometry(30,380,400,30);
        campo->setStyleSheet("background-color:white;");

        QPushButton* ricerca=new QPushButton("Cerca",this);
        ricerca->setGeometry(450,380,100,30);
        ricerca->setStyleSheet("background-color:white;");

        connect(logout,SIGNAL(released()),this,SLOT(logOut()));
        connect(mostraPr,SIGNAL(released()),this,SLOT(mostraProfilo()));
        connect(modificaPr,SIGNAL(released()),this,SLOT(modificaProfilo()));
        connect(modificaCont,SIGNAL(released()),this,SLOT(gestisciContatti()));
        connect(ricerca,SIGNAL(released()),this,SLOT(ricerca()));
    }
    catch(Errore err) {
        throw(err);
    }


}
Example #22
0
void User::logIn(const char* user, const char* pass)
{
	gcString appDataPath = UTIL::OS::getAppDataPath();
	m_pThreadPool->unBlockTasks();

	if (!m_pWebCore)
		throw gcException(ERR_NULLWEBCORE);

	
	tinyxml2::XMLDocument doc;
	m_pWebCore->logIn(user, pass, doc);

	tinyxml2::XMLElement *uNode = doc.FirstChildElement("memberlogin");

	uint32 version = 0;
	XML::GetAtt("version", version, uNode);

	if (version == 0)
		version = 1;

	m_bDelayLoading = (version >= 3);

	if (!uNode)
	{
		logOut();
		throw gcException(ERR_BADXML);
	}

	tinyxml2::XMLElement *memNode = uNode->FirstChildElement("member");
	
	if (memNode)
	{

		const char* idStr =  memNode->Attribute("siteareaid");

		if (idStr)
		{
			m_iUserId = atoi(idStr);

			if ((int)m_iUserId <= 0)
			{
				logOut();
				throw gcException(ERR_BAD_PORU);
			}
		}
		else
		{
			logOut();
			throw gcException(ERR_BAD_PORU);
		}
	}

	XML::GetChild("admin", m_bAdmin,  memNode);
	XML::GetChild("name", m_szUserName,  memNode);
	XML::GetChild("nameid", m_szUserNameId,  memNode);
	XML::GetChild("url", m_szProfileUrl,  memNode);
	XML::GetChild("urledit", m_szProfileEditUrl,  memNode);


	initPipe();

#ifdef WIN32
	if (getServiceMain())
		getServiceMain()->fixFolderPermissions(appDataPath.c_str());

	try
	{
		testMcfCache();
	}
	catch (...)
	{
		if (getServiceMain())
			getServiceMain()->fixFolderPermissions(m_szMcfCachePath.c_str());

		try
		{
			testMcfCache();
		}
		catch (gcException &e)
		{
			Warning(gcString("Failed to set mcf cache path to be writeable: {0}", e));
		}
	}
#endif

	gcString szAvatar;
	XML::GetChild("avatar", szAvatar, memNode);

	m_pThreadPool->queueTask(new UserCore::Task::DownloadAvatarTask(this, szAvatar.c_str(), m_iUserId) );


	tinyxml2::XMLElement *msgNode = memNode->FirstChildElement("messages");
	if (msgNode)
	{
		XML::GetChild("updates", m_iUpdates, msgNode);
		XML::GetChild("privatemessages", m_iPms, msgNode);
		XML::GetChild("cart", m_iCartItems, msgNode);
		XML::GetChild("threadwatch", m_iThreads, msgNode);
	}

	m_pToolManager->loadItems();
	m_pItemManager->loadItems();

	try
	{
		if (m_bDelayLoading)
		{
			//do nothing as the update thread will grab it
		}
		else if (version == 2)
		{
			m_pItemManager->parseLoginXml2(memNode->FirstChildElement("games"), memNode->FirstChildElement("platforms"));
		}
		else
		{
			m_pItemManager->parseLoginXml(memNode->FirstChildElement("games"), memNode->FirstChildElement("developer"));
		}
	}
	catch (gcException &)
	{
		logOut();
		throw;
	}

	tinyxml2::XMLElement *newsNode = memNode->FirstChildElement("news");
	if (newsNode)
		parseNews(newsNode);

	tinyxml2::XMLElement *giftsNode = memNode->FirstChildElement("gifts");
	if (giftsNode)
		parseGifts(giftsNode);

	m_pUThread = m_pThreadManager->newUpdateThread(&onForcePollEvent, m_bDelayLoading);
	m_pUThread->start();

#ifdef WIN32
	m_pGameExplorerManager->loadItems();
#endif

	if (getServiceMain())
		getServiceMain()->updateShortCuts();

	if (!m_bDelayLoading)
		m_pItemManager->enableSave();

#ifdef WIN32
#ifdef DEBUG
	gcString val("\"{0}\"", UTIL::OS::getCurrentDir(L"desura-d.exe"));
#else
	gcString val("\"{0}\"", UTIL::OS::getCurrentDir(L"desura.exe"));
#endif

	val +=  " \"%1\" -urllink";
	updateRegKey("HKEY_CLASSES_ROOT\\Desura\\shell\\open\\command\\", val.c_str());
#endif
}
Example #23
0
///=============================================================================
void* sm2obj::window::exportThreadFunc(void* Data){
	// General settings
	//bool exportMaterials = (radioUvMapsAtlas->getValue() || radioUvMapsTiles->getValue());
	//bool exportAtlas = radioUvMapsAtlas->getValue();
	//bool exportObject = true;
	//bool exportTextures = true;
	std::string mtlOutputPath = outputFolder + "\\" + blueprintName + ".mtl";
	std::string objOutputPath = outputFolder + "\\" + blueprintName + ".obj";
	std::string blueprintFolder = starMadeFolder + "\\Blueprints\\" + blueprintName;
	std::string blockTypesPath = starMadeFolder + "\\data\\config\\BlockTypes.properties";
	std::string blockConfigPath = starMadeFolder + "\\data\\config\\BlockConfig.xml";
	std::string tempFolder = outputFolder + "\\" + blueprintName + "_TEMP_DELETE_THIS";
	std::string textureFolder = starMadeFolder + "\\data\\textures\\block\\Default\\";
	int textureSize = 0;
	int numOfThreads = comboNumOfThreads->getSelected() +1;
	bool exportAttachments = checkboxExportAttachments->getValue();
	bool exportDiffuse = checkboxMatDiffuse->getValue();
	bool exportAlpha = checkboxMatAlpha->getValue();
	bool exportNormals = (radioMatBumps->getValue() || radioMatNormals->getValue());
	bool exportEmissive = checkboxMatEmissive->getValue();
	warningMessageFlag = false; // extern in config
	exportFinished = false;
	std::vector<threadInfoStruct*> threads;
	std::string textureExtension;
	progressStruct guiProgress;

	switch(comboTextureFormat->getSelected()){
		case 0: textureExtension = "png"; break;
		case 1: textureExtension = "tga"; break;
		case 2: textureExtension = "bmp"; break;
		case 3: textureExtension = "tiff"; break;
	}

	switch(comboTextureSize->getSelected()){
		case 0: textureFolder += "64"; textureSize = 64; break;
		case 1: textureFolder += "128"; textureSize = 128; break;
		case 2: textureFolder += "256"; textureSize = 256; break;
	}

	ffw::logDebug() << "Exporting object? -> " << (exportObject ? "true" : "False");
	ffw::logDebug() << "Exporting textures? -> " << (exportTextures ? "true" : "False");
	ffw::logDebug() << "Exporting materials? -> " << (exportMaterials ? "true" : "False");

	// Edit GUI labels & progressbars
	if(exportObject){
		labelReadingMeta->setColor(ffw::rgb(0x000000));
		labelLoadingChunks->setColor(ffw::rgb(0x000000));
		labelGeneratingBlocks->setColor(ffw::rgb(0x000000));
		labelCreatingPolys->setColor(ffw::rgb(0x000000));
		labelMergingVertices->setColor(ffw::rgb(0x000000));

		labelReadingMeta->setValue(L"Reading meta: ...");
		labelLoadingChunks->setValue(L"Loading chunks: ...");
		labelGeneratingBlocks->setValue(L"Generating blocks: ...");
		labelCreatingPolys->setValue(L"Creating polygons: ...");
		labelMergingVertices->setValue(L"Merging vertices: ...");
	} else {
		labelReadingMeta->setColor(ffw::rgb(0x777777));
		labelLoadingChunks->setColor(ffw::rgb(0x777777));
		labelGeneratingBlocks->setColor(ffw::rgb(0x777777));
		labelCreatingPolys->setColor(ffw::rgb(0x777777));
		labelMergingVertices->setColor(ffw::rgb(0x777777));

		labelReadingMeta->setValue(L"Reading meta: X");
		labelLoadingChunks->setValue(L"Loading chunks: X");
		labelGeneratingBlocks->setValue(L"Generating blocks: X");
		labelCreatingPolys->setValue(L"Creating polygons: X");
		labelMergingVertices->setValue(L"Merging vertices: X");
	}

	if(exportTextures){
		labelExportingTextures->setColor(ffw::rgb(0x000000));
		labelExportingTextures->setValue(L"Exporting textures: ...");
	} else {
		labelExportingTextures->setColor(ffw::rgb(0x777777));
		labelExportingTextures->setValue(L"Exporting textures: X");
	}

	labelBlockConfig->setColor(ffw::rgb(0x000000));
	labelBlockConfig->setValue(L"Block config: ...");

	// Output files
	ffw::file objOutput;
	ffw::file mtlOutput;

	// Block config data
	std::vector<blockTypeStruct> blockTypes;
	std::vector<blockInfoStruct> blockInfo;

	// Blueprint output data
	entityInfoStruct entityRoot;

	if(exportObject){
		// Open MTL file
		if(exportObject && exportMaterials){
			if(!mtlOutput.open(mtlOutputPath, std::ios::out | std::ios::trunc)){
				ffw::showModalError(this, L"Error!", L"Can not open output file for writing: " + ffw::utf8ToWstr(mtlOutputPath));
				buttonCancel->setLabel(L"Close");
				exportFinished = true;
				return NULL;
			} else {
				ffw::logSuccess() << "MTL destination path: " << objOutputPath;
			}
		}

		// Open OBJ file
		if(exportObject){
			if(!objOutput.open(objOutputPath, std::ios::out | std::ios::trunc)){
				ffw::showModalError(this, L"Error!", L"Can not open output file for writing: " + ffw::utf8ToWstr(objOutputPath));
				buttonCancel->setLabel(L"Close");
				exportFinished = true;
				return NULL;
			} else {
				ffw::logSuccess() << "OBJ destination path: " << objOutputPath;
			}
		}
	}

	labelBlockConfig->setValue(L"Block config: 0/2");
	progressBlockConfig->setValue(0);

	std::cout << "checking... " << exportThreadStop << std::endl;

	// Check for cancelation
	if(exportThreadStop){
		return NULL;
	}

	std::cout << "loading..." << std::endl;

	// Load block types
	if(!loadBlockTypes(blockTypes, blockTypesPath)){
		ffw::showModalError(this, L"Error!", L"Failed to open block type properties: " + ffw::utf8ToWstr(blockTypesPath));
		buttonCancel->setLabel(L"Close");
		exportFinished = true;
		return NULL;
	}

	ffw::logSuccess() << "Loaded: " << blockTypes.size() << " block types";
	labelBlockConfig->setValue(L"Block config: 1/2");
	progressBlockConfig->setValue(50);

	// Check for cancelation
	if(exportThreadStop){
		return NULL;
	}

	// Load block config
	if(!loadBlockConfig(blockTypes, blockInfo, blockConfigPath)){
		ffw::showModalError(this, L"Error!", L"Failed to open block config: " + ffw::utf8ToWstr(blockConfigPath));
		buttonCancel->setLabel(L"Close");
		exportFinished = true;
		return NULL;
	}

	// Check for cancelation
	if(exportThreadStop){
		return NULL;
	}

	ffw::logSuccess() << "Loaded: " << blockInfo.size() << " blocks from config";
	labelBlockConfig->setValue(L"Block config: 2/2");
	progressBlockConfig->setValue(100);

	if(exportObject){
		labelReadingMeta->setValue(L"Reading meta: 0/1");
		progressReadingMeta->setValue(0);

		// Load meta files if exporting attachments
		if(exportAttachments){
			ffw::logDebug() << "Loading attached ships and turrets...";
			if(!recursiveMetaLoader(&entityRoot, blueprintFolder, blueprintName, "")){
				ffw::showModalError(this, L"Error!", L"Failed to load meta data! Try to export the ship without attached turrets and ships!");
				buttonCancel->setLabel(L"Close");
				exportFinished = true;
				return NULL;
			}
		}

		labelReadingMeta->setValue(L"Reading meta: 1/1");
		progressReadingMeta->setValue(100);

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}

		// Dump information about ship
		recursiveMetaDump(&entityRoot, 0);

		// Create temp folder
		ffw::createDirectory(tempFolder);

		// Export chunks to temp folder
		int fileIndex = 0;
		guiProgress.label = labelLoadingChunks;
		guiProgress.progressbar = progressLoadingChunks;
		guiProgress.total = getTotalEntities(&entityRoot);
		guiProgress.status = 0;
		guiProgress.setProgress("Loading chunks");
		if(!recursiveChunkLoader(&entityRoot, blueprintFolder, tempFolder, fileIndex, guiProgress, exportThreadStop)){
			ffw::showModalError(this, L"Error!", L"Failed to export chunks to temporary folder! The ship might be corrupted or program has no privileges to create temporary files");
			buttonCancel->setLabel(L"Close");
			exportFinished = true;
			return NULL;
		}

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}

		// Create thread data
		for(int i = 0; i < numOfThreads; i++){
			threads.push_back(new threadInfoStruct(blockInfo));
			threads[i]->thread.bindFunction(&processChunk);
		}

		// Export chunks
		guiProgress.label = labelGeneratingBlocks;
		guiProgress.progressbar = progressGeneratingBlocks;
		guiProgress.total = fileIndex;
		guiProgress.status = 0;
		guiProgress.setProgress("Generating blocks");
		recursiveChunkExport(&entityRoot, tempFolder, threads, guiProgress, blockInfo, exportThreadStop);

		// Delete threads
		for(int i = 0; i < numOfThreads; i++){
			delete threads[i];
		}
		threads.clear();

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}

		// Generate queue
		std::vector<entityInfoStruct*> entityQueue;
		generateEntityQueue(&entityRoot, &entityQueue);

		// Export vertices
		//progress = 0;
		uint64_t indicesOffset = 0;
		uint64_t texPosOffset = 0;
		chunkBufferStruct* chunkRawBuffer = new chunkBufferStruct;

		guiProgress.label = labelCreatingPolys;
		guiProgress.progressbar = progressCreatingPolys;
		guiProgress.total = entityQueue.size();
		guiProgress.status = 0;
		guiProgress.setProgress("Creating polygons");

		for(auto& entity : entityQueue){
			chunkRawBuffer->extractedMaterialsList.clear();
			for(auto& chunk : entity->chunks){
				//progress++;
				//ffw::logDebug() << "Generating vertices: " << progress << " out of: " << progressTotal;
				//Args.callbackProgress(progress, progressTotal);
				// Load a temp block to memory
				sm2obj::loadRawBlocks(tempFolder, chunkRawBuffer, chunk.fileIndex);
				// Export block to temp as indices and vertices
				sm2obj::extractBlocks(tempFolder, chunkRawBuffer, chunk.fileIndex, &indicesOffset, &texPosOffset, exportAtlas, exportMaterials, exportUV, blockInfo);
			}

			if(!exportAtlas)texPosOffset += 4;
			else texPosOffset += chunkRawBuffer->extractedMaterialsList.size()*4;

			if(exportAtlas){
				for(auto i : chunkRawBuffer->extractedMaterialsList)entity->extractedTiles.push_back(i.x);
			} else {
				for(auto i : chunkRawBuffer->extractedMaterialsList)entity->extractedMaterials.push_back(i);
			}

			guiProgress.status++;
			guiProgress.setProgress("Creating polygons");
		}
		delete chunkRawBuffer;

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}

		// Merge files
		guiProgress.label = labelMergingVertices;
		guiProgress.progressbar = progressMergingVertices;
		guiProgress.total = entityQueue.size();
		guiProgress.status = 0;
		guiProgress.setProgress("Merging vertices");
		ffw::logSuccess() << "Merging vertices and indices into a single file...";

		objOutput.writeLine("# SM2OBJ");
		if(exportMaterials)objOutput.writeLine("mtllib " + blueprintName + ".mtl");

		//recursiveVerticesMerge(&entityRoot, tempFolder, &objOutput, !Args.useAtlas, Args.exportUV);
		for(auto& entity : entityQueue){
			mergeVertices(entity, tempFolder, &objOutput, !exportAtlas, exportUV);

			guiProgress.status++;
			guiProgress.setProgress("Merging vertices");
		}

		ffw::logSuccess() << "Creating material file...";

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}

		// Export materials
		if(exportMaterials && exportAtlas){
			ffw::logDebug() << "Exporting altas materials";
			ffw::logDebug() << "Creating 3 materials...";
			createMaterialAtlas(&mtlOutput, true, exportDiffuse, exportAlpha, exportNormals, exportEmissive, textureExtension);

		} else if(exportMaterials){
			ffw::logDebug() << "Exporting block materials";
			std::vector<ffw::vec2i> materialList;

			for(auto& entity : entityQueue){
				for(auto& mat :entity->extractedMaterials){
					// Find if material is already added
					bool found = false;
					for(auto& item : materialList){
						if(item == mat){
							found = true;
							break;
						}
					}
					if(found)continue;
					// Add to list
					materialList.push_back(mat);
				}
			}

			ffw::logDebug() << "Creating " << materialList.size() << " materials...";

			mtlOutput.writeLine("# SM2OBJ\n");
			for(auto& mat : materialList){
				const blockInfoStruct* block = findBlock(blockInfo, mat.x);
				if(block == NULL)continue;
				createMaterialTile(&mtlOutput, block, mat.y, true, exportDiffuse, exportAlpha, exportNormals, exportEmissive, textureExtension);
			}
		}

		// Check for cancelation
		if(exportThreadStop){
			return NULL;
		}
	}

	// Export textures
	if(exportTextures){
		guiProgress.label = labelExportingTextures;
		guiProgress.progressbar = progressExportingTextures;
		guiProgress.total = 0;
		if(exportDiffuse)guiProgress.total++;
		if(exportAlpha)guiProgress.total++;
		if(exportEmissive && exportAtlas)guiProgress.total++;
		if(exportNormals)guiProgress.total++;
		guiProgress.status = 0;
		guiProgress.setProgress("Exporting textures");

		std::string textureOutputFolder = outputFolder + "\\textures";
		ffw::createDirectory(textureOutputFolder);

		if(exportAtlas){
			if(exportDiffuse){
				exportDiffuseAtlas(textureFolder + "\\t000.png", textureSize, textureOutputFolder + "\\Atlas_0_diff." + textureExtension);
				exportDiffuseAtlas(textureFolder + "\\t001.png", textureSize, textureOutputFolder + "\\Atlas_1_diff." + textureExtension);
				exportDiffuseAtlas(textureFolder + "\\t002.png", textureSize, textureOutputFolder + "\\Atlas_2_diff." + textureExtension);

				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

			// Check for cancelation
			if(exportThreadStop){
				return NULL;
			}

			if(exportAlpha){
				exportAlphaAtlas(textureFolder + "\\t000.png", textureSize, textureOutputFolder + "\\Atlas_0_alpha." + textureExtension);
				exportAlphaAtlas(textureFolder + "\\t001.png", textureSize, textureOutputFolder + "\\Atlas_1_alpha." + textureExtension);
				exportAlphaAtlas(textureFolder + "\\t002.png", textureSize, textureOutputFolder + "\\Atlas_2_alpha." + textureExtension);

				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

			// Check for cancelation
			if(exportThreadStop){
				return NULL;
			}

			if(exportEmissive){
				exportEmissiveAtlas(blockInfo, textureSize, 0, textureOutputFolder + "\\Atlas_0_emissive." + textureExtension);
				exportEmissiveAtlas(blockInfo, textureSize, 1, textureOutputFolder + "\\Atlas_1_emissive." + textureExtension);
				exportEmissiveAtlas(blockInfo, textureSize, 2, textureOutputFolder + "\\Atlas_2_emissive." + textureExtension);

				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

			// Check for cancelation
			if(exportThreadStop){
				return NULL;
			}

			if(exportNormals && useBumps){
				exportBumpAtlas(textureFolder + "\\t000_NRM.png", textureSize, textureOutputFolder + "\\Atlas_0_bump." + textureExtension);
				exportBumpAtlas(textureFolder + "\\t001_NRM.png", textureSize, textureOutputFolder + "\\Atlas_1_bump." + textureExtension);
				exportBumpAtlas(textureFolder + "\\t002_NRM.png", textureSize, textureOutputFolder + "\\Atlas_2_bump." + textureExtension);

				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");

			} else if(exportNormals){
				exportNormalAtlas(textureFolder + "\\t000_NRM.png", textureSize, textureOutputFolder + "\\Atlas_0_bump." + textureExtension);
				exportNormalAtlas(textureFolder + "\\t001_NRM.png", textureSize, textureOutputFolder + "\\Atlas_1_bump." + textureExtension);
				exportNormalAtlas(textureFolder + "\\t002_NRM.png", textureSize, textureOutputFolder + "\\Atlas_2_bump." + textureExtension);

				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

		} else {
			if(exportDiffuse){
				exportTileDiffuse(blockInfo, textureFolder, textureSize, textureOutputFolder, textureExtension);
				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

			// Check for cancelation
			if(exportThreadStop){
				return NULL;
			}

			if(exportAlpha){
				exportTileAlpha(blockInfo, textureFolder, textureSize, textureOutputFolder, textureExtension);
				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}

			// Check for cancelation
			if(exportThreadStop){
				return NULL;
			}

			if(exportNormals && useBumps){
				exportTileBump(blockInfo, textureFolder, textureSize, textureOutputFolder, textureExtension);
				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");

			} else if(exportNormals){
				exportTileNormals(blockInfo, textureFolder, textureSize, textureOutputFolder, textureExtension);
				guiProgress.status++;
				guiProgress.setProgress("Exporting textures");
			}
		}
	}

	std::fstream logIn(ffw::getExecutablePath() + "\\log.txt", std::ios::in);
	std::fstream logOut(outputFolder + "\\" + blueprintName + "_log.txt", std::ios::out | std::ios::trunc);
	if(logIn && logOut){
		logOut << logIn.rdbuf();
		logIn.close();
		logOut.close();
	}

	if(warningMessageFlag) ffw::showModalWarning(this, L"Warning!", L"Blueprint might not be correctly exported! There were some minor errors! Check log file located in exported folder for warning and errors messages!");
	else ffw::showModalInfo(this, L"Success!", L"Blueprint exported without any errors nor warnings! Destination folder: " + ffw::utf8ToWstr(outputFolder));

	buttonCancel->setLabel(L"Close");
	exportFinished = true;
	return NULL;
}
Example #24
0
//*--------------------------------------------------------------------------*//
//* MAIN                                                                MAIN *//
//*--------------------------------------------------------------------------*//
int main(int argc, char* argv[])
{  
   // Initialise random number generator
	srandom(time(NULL));
	clock_t t0 = clock();
   
   // Print header
   printHeader();
	
	// Read options
   Options uo = parseCommandLine(argc,argv);
   if(!uo.noHybrid)
   {
      if(uo.funcGroupVec[AROM] && uo.funcGroupVec[LIPO])
      {
         uo.funcGroupVec[HYBL] = true;
      }
      if(uo.funcGroupVec[HDON] && uo.funcGroupVec[HACC])
      {
         uo.funcGroupVec[HYBH] = true;
      }
   }
   std::cerr << uo.print() << std::endl;
   
   if (uo.version)
   {
		printHeader();
		exit(0);
	}
   
	if (uo.help)
   {
		printUsage();
		exit(0);
	}
	
	// Db file and pharmacophore out are mandatory elements
	if (uo.dbInpFile.empty())
   {
		mainErr("Missing database file. This is a required option (-d).");
	}
   
	if (uo.pharmOutFile.empty() && uo.molOutFile.empty() && uo.scoreOutFile.empty())
   {
		mainErr("No output file defined. So there is actually no use to compute anything at all.");
	}	
   
	if ((uo.pharmOutFile.empty() && uo.scoreOutFile.empty()) && !uo.molOutFile.empty())
   {
		mainErr("No file defined to write pharmacophore information.");
	}	
	
	if (uo.refInpFile.empty() && uo.pharmOutFile.empty() && uo.molOutFile.empty() && !uo.scoreOutFile.empty())
   {
		mainErr("Only score file requested when no reference is given. Unable to generate this output.");
	}	
  
	// Reference variables
   Pharmacophore refPharm;
   refPharm.clear();
   std::string refId;
   double refVolume(0.0);
   int refSize(0);
	int exclSize(0);
  
	// Database variables
   std::vector<Result*> resList;
   Pharmacophore dbPharm;
   std::string dbId;
   double dbVolume(0.0);
   int dbSize(0);
  
   //----------------------------------------------------------------------------
	//...(A).. Process the reference
   //----------------------------------------------------------------------------
  
	if (!uo.refInpFile.empty())
	{
      //-------------------------------------------------------
      //...(1).. get reference pharmacophore
      //-------------------------------------------------------
    
      if (uo.refInpType == UNKNOWN)
      {
         std::string ext(getExt(uo.refInpFile));
         if (ext == ".phar")
         {
            uo.refInpType = PHAR;
         }
         else 
         {
            uo.refInpType = MOL;
         }
      }
		
      if (uo.refInpType == MOL)
      {
         OpenBabel::OBMol m;
         OpenBabel::OBConversion* reader = new OpenBabel::OBConversion();
         reader->SetInFormat(reader->FormatFromExt(uo.refInpFile.c_str()));
         if (!reader->Read(&m, uo.refInpStream))
         {
            mainErr("Unable to read reference molecule");
         }
         calcPharm(&m, &refPharm, uo);
         refId = m.GetTitle();
         delete reader;
         reader = NULL;
      }
      else if (uo.refInpType == PHAR)
      {
         PharmacophoreReader* reader = new PharmacophoreReader();
         refPharm = reader->read(uo.refInpStream, refId);
         if (refPharm.empty())
         {
            mainErr("Error reading reference pharmacophore");
         }
         delete reader;
         reader = NULL;
      }
      else
      {
         mainErr("Unknown format of reference molecule.");
      }
		
      //-------------------------------------------------------
		//...(2).. process reference pharmacophore
      //-------------------------------------------------------
		
      if (uo.merge)
      {
         pharMerger.merge(refPharm);
      }
    
      refSize = refPharm.size();
      for (unsigned int i(0); i < refSize; ++i)
		{
         if (refPharm[i].func == EXCL)
         {
				// extract overlap with exclusion spheres
				for (unsigned int j(0); j < refPharm.size(); ++j)
            {
					if (refPharm[j].func != EXCL)
               {
						refVolume -= VolumeOverlap(refPharm[i], refPharm[j], !uo.noNormal);
					}
				}
				exclSize++;
			}
         else
         {
				// add point self-overlap
				refVolume += VolumeOverlap(refPharm[i], refPharm[i], !uo.noNormal);
			}
      }
      
      if(!uo.isQuiet)
      {
         std::cerr << "Reference pharmacophore " << refId << std::endl;
         std::cerr << "   number of points:            " << refSize - exclSize << std::endl;
			std::cerr << "   number of exclusion spheres: " << exclSize << std::endl;
         std::cerr << "   totalvolume:                 " << refVolume << std::endl;
      }
	}

   //----------------------------------------------------------------------------
	//...(B).. Process the database file
   //----------------------------------------------------------------------------

   // DB files
   if (uo.dbInpType == UNKNOWN)
   {
      std::string ext(getExt(uo.dbInpFile));
      if (ext==".phar")
      {
         uo.dbInpType = PHAR;
      }
      else
      {
         uo.dbInpType = MOL;
      }
   }
	
	// local storage of the rotation matrix
	SiMath::Matrix rotMat(3,3,0.0);

   unsigned int molCount(0);
   
   OpenBabel::OBConversion* molReader = NULL;
	PharmacophoreReader* pharmReader = NULL;
   
   if (uo.dbInpType == PHAR)
   {
      pharmReader = new PharmacophoreReader();
   }
   else if (uo.dbInpType == MOL)
   {
      molReader = new OpenBabel::OBConversion();
      molReader->SetInFormat(molReader->FormatFromExt(uo.dbInpFile.c_str()));
      molReader->SetInStream(uo.dbInpStream);
   }
   else
   {
      mainErr("Unknown format of db file.");
   }

   bool done(false);
   OpenBabel::OBMol m;
   while (!done)
   {	
      dbPharm.clear();
      m.Clear();

      if (uo.dbInpType == MOL)
      {
         if (!molReader->Read(&m))
         {
            done = true;
            break;
         }
         else
         {
            calcPharm(&m, &dbPharm, uo);
            dbId = m.GetTitle();
         }
      }
      else
      {
         if (uo.dbInpStream->eof())
         {
            done = true;
            break;
         }
         else
         {
            dbPharm = pharmReader->read(uo.dbInpStream, dbId);
         }
      }
      if (dbPharm.empty())
      {
         continue;
      }

      ++molCount;
      if (!uo.isQuiet )
      {
         if ((molCount % 10) == 0)
         {
            std::cerr << "." << std::flush;
         }
         if ((molCount % 500) == 0)
         {
            std::cerr << molCount << std::endl << std::flush;
         }
      }

			
      if (uo.merge)
      {
         pharMerger.merge(dbPharm);
      }
      
      if (uo.refInpFile.empty())
      {
         if (!(uo.isQuiet))
         {
            printProgress(molCount);
         } 
         if( !uo.pharmOutFile.empty())
         {
            uo.pharmOutWriter->write(dbPharm, uo.pharmOutStream, dbId);
         }
         continue;
      }

      //-------------------------------------------------------
      //...(1).. Alignment
      //-------------------------------------------------------
      
      dbSize = dbPharm.size();
      dbVolume = 0.0;
      for (unsigned int i(0); i < dbSize; ++i) 
      {
         if (dbPharm[i].func == EXCL)
         {
            continue;
         }
         dbVolume += VolumeOverlap(dbPharm[i], dbPharm[i], !uo.noNormal);
      }
			
      // Create a result structure
      Result res;
      res.refId           = refId;
      res.refVolume       = refVolume;
      res.dbId            = dbId;
      res.dbVolume        = dbVolume;
      res.overlapVolume   = 0.0;
      res.exclVolume      = 0.0;
      res.resMol          = m;
      res.resPharSize     = 0;
			
      if (uo.scoreOnly)
      {
         FunctionMapping funcMap(&refPharm, &dbPharm, uo.epsilon);
         PharmacophoreMap fMap = funcMap.getNextMap();
         double volBest(-9999.999);
         
         // loop over all reference points
         while (!fMap.empty())
         {
            double newVol(0.0);
            double exclVol(0.0);
            for (PharmacophoreMap::iterator itP = fMap.begin(); itP != fMap.end(); ++itP) 
            {
               if ((itP->first)->func == EXCL)
               {
                  exclVol += VolumeOverlap((itP->first), (itP->second), !uo.noNormal);					
               }
               else if (((itP->first)->func == (itP->second)->func ) || 
                       (((itP->first)->func == HYBH || 
                         (itP->first)->func == HDON || 
                         (itP->first)->func == HACC) 
                     && ((itP->second)->func == HDON || 
                         (itP->second)->func == HACC ||
                         (itP->second)->func == HYBH))
                     || (((itP->first)->func == HYBL || 
                          (itP->first)->func == AROM || 
                          (itP->first)->func == LIPO)
                      && ((itP->second)->func == AROM || 
                          (itP->second)->func == LIPO || 
                          (itP->second)->func == HYBL)))
               {
                  newVol += VolumeOverlap((itP->first),(itP->second), !uo.noNormal);
               }
            }
					
            if ((newVol - exclVol) > volBest)
            {
               res.resPhar.clear();
               res.resPharSize = 0;
               for (PharmacophoreMap::iterator itP = fMap.begin(); itP != fMap.end(); ++itP) 
               {
                  // add point to resulting pharmacophore
                  PharmacophorePoint p(itP->second);
                  (res.resPhar).push_back(p);
                  ++res.resPharSize;
               }						
               res.overlapVolume = newVol;
               res.exclVolume = exclVol;
               volBest = newVol - exclVol;
            }
            // get the next map
            fMap.clear();
            fMap = funcMap.getNextMap();
         }
      }
      else
      {
         FunctionMapping funcMap(&refPharm, &dbPharm, uo.epsilon);
         PharmacophoreMap fMap = funcMap.getNextMap();
         PharmacophoreMap bestMap;
				
         // default solution
         SolutionInfo best;
         best.volume = -999.9;
         
         // rotor is set to no rotation 
         best.rotor.resize(4);
         best.rotor = 0.0;
         best.rotor[0] = 1.0;
				
         double bestScore = -1000;
         int mapSize(fMap.size());
         int maxSize = mapSize - 3;
				
         while (!fMap.empty())
         {
            int msize = fMap.size();
            
            // add the exclusion spheres to the alignment procedure
            if (uo.withExclusion)
            {
               for (unsigned int i(0); i < refSize ; ++i)
               {
                  if (refPharm[i].func != EXCL)
                  {
                     continue;
                  }
                  for (unsigned int j(0); j < dbSize; ++j)
                  {
                     if (dbPharm[j].func == EXCL)
                     {
                        continue;
                     }
                     fMap.insert(std::make_pair(&(refPharm[i]), &(dbPharm[j])));
                  }
               }
            }
					
            // Only align if the expected score has any chance of being larger 
            // than best score so far
            if ((msize > maxSize)
            && (((double) msize / (refSize - exclSize + dbSize - msize)) > bestScore))
            {
               Alignment align(fMap);
               SolutionInfo r = align.align(!uo.noNormal);

               if (best.volume < r.volume)
               {
                  best = r;
                  bestScore = best.volume / (refVolume + dbVolume - best.volume);
                  bestMap = fMap;
                  mapSize = msize;
               }
            }
            else
            {
               // Level of mapping site to low
               break;
            }
	
            if (bestScore > 0.98)
            {
               break;
            }
					
            // Get the next map
            fMap.clear();
            fMap = funcMap.getNextMap();
         }
				
         // Transform the complete pharmacophore and the molecule towards the 
         // best alignment
         rotMat = quat2Rotation(best.rotor);
         positionPharmacophore(dbPharm, rotMat, best);
         positionMolecule(&res.resMol, rotMat, best);
				
         // Update result
         res.info = best;

         // Compute overlap volume between exlusion spheres and pharmacophore 
         // points
         for (int i(0); i < refSize; ++i) 
         {
            if (refPharm[i].func != EXCL)
            {
               continue;
            }
            for (int j(0); j < dbSize; ++j)
            {
               res.exclVolume += VolumeOverlap(refPharm[i], dbPharm[j], !uo.noNormal);
            }
         }
				
         // make copy of the best map and compute the volume overlap
         for (PharmacophoreMap::iterator itP = bestMap.begin(); itP != bestMap.end(); ++itP) 
         {
            if(((itP->first)->func == EXCL) || ((itP->second)->func == EXCL))
            { 
               continue; 
            }
					
            // compute overlap
            res.overlapVolume += VolumeOverlap(itP->first, itP->second, !uo.noNormal);
					
            // add point to resulting pharmacophore
				PharmacophorePoint p(itP->second);
            (res.resPhar).push_back(p);
            ++res.resPharSize;
         }
      }
			
      // update scores
      res.info.volume = res.overlapVolume - res.exclVolume;
      if (res.info.volume > 0.0)
      {
         res.tanimoto = res.info.volume / (res.refVolume + res.dbVolume - res.info.volume);
         res.tversky_ref = res.info.volume / res.refVolume;
         res.tversky_db = res.info.volume / res.dbVolume;
      }

      switch (uo.rankby) 
      {
         case TANIMOTO:
            res.rankbyScore = res.tanimoto;
            break;
         case TVERSKY_REF:
            res.rankbyScore = res.tversky_ref;
            break;
         case TVERSKY_DB:
            res.rankbyScore = res.tversky_db;
            break;
      }

      //-------------------------------------------------------
      //...(5).. Generate output
      //-------------------------------------------------------
      if (uo.cutOff != 0.0)
      {
         if (res.rankbyScore < uo.cutOff)
         {
            continue;
         }
      }

      if (uo.best != 0)
      {
         addBest(res, uo, resList);
      }
      else 
      { 
         if (!uo.molOutFile.empty())
         { 
            logOut(&res, uo);
         }
         if (!uo.pharmOutFile.empty())
         {
            logPharmacophores(&res, uo);
         }
         if (!uo.scoreOutFile.empty())
         {
            logScores(&res, uo);
         }
      }
   }

   if (molReader)
   {
      delete molReader;
      molReader = NULL;
   }
   if (pharmReader)
   {
      delete pharmReader;
      pharmReader = NULL;
   }
  
   //----------------------------------------------------------------------------
   //...(C).. Process best list (if defined)
   //----------------------------------------------------------------------------

   if (uo.best != 0)
   {
      std::vector<Result*>::iterator itR;
      for (itR = resList.begin(); itR != resList.end(); ++itR) 
      {
         Result* res(*itR);
         if (!uo.molOutFile.empty())
         {
            logOut(res, uo);
         }
         if (!uo.pharmOutFile.empty())
         {
            logPharmacophores(res, uo);
         }
         if (!uo.scoreOutFile.empty())
         {
            logScores(res, uo);
         }
         delete res;
      }
   }

   // done processing database
   if (!uo.isQuiet)
   {
      if (uo.refInpFile.empty())
      {
         std::cerr << std::endl;
         std::cerr << "Processed " << molCount << " molecules";
         double tt = (double)(clock() - t0 )/CLOCKS_PER_SEC;
         std::cerr << " in " << tt << " seconds (";
         std::cerr << molCount/tt << " molecules per second)." << std::endl;
      }
      else
      {
         std::cerr << std::endl;
         std::cerr << "Processed " << molCount << " molecules" << std::endl;
         double tt = (double)(clock() - t0 )/CLOCKS_PER_SEC;
         std::cerr << molCount << " alignments in " << tt << " seconds (";
         std::cerr << molCount/tt << " alignments per second)." << std::endl;
      }
   }
	
   exit(0);

}
void LoggedInDialog::connections()
{
    connect(cloudProviderAccountSetupPushButton,SIGNAL(clicked()),this,SLOT(showCloudProviderAccountSetup()));
    connect(builderAndPusherPushButton,SIGNAL(clicked()),this,SLOT(showBuilderAndPusher()));
    connect(logOutPushButton,SIGNAL(clicked()),this,SLOT(logOut()));
}
Example #26
0
// Gestion d'initialisation globale
void InitJ(void)
{
  if(Particule)
    {
      delete Particule;
      Particule= new ParticuleManager;
      logOut("  [OK] Moteur à Particule initialisé\n");
    }
  // Chargement des textures à partir des fichiers
  Map=new cl_model(MAPURL);

  // Allocation mémoire de la classe 'wing' du vaisseau principal
  fly=new cl_wing(WINGURL);

  // Allocation mémoire de la classe 'bsp' des collisions de la map
  MapColl=new cl_bsp(MAPURL);

  // Textures des mask
  tmask=new cl_texture("./data/texture/interf/mask.bmp");
  tcache=new cl_texture("./data/texture/interf/m1.tga");

  char *urlLT=getStrFromMadMap(MAPURL,'L',1);
  tLiquid=new cl_texture(urlLT);
  delete urlLT;

  // Initialisation des drones Shoker
  try
    {
      int nbDrone=getNbFromMadMap(MAPURL,'S');
      swVertex *tPos=new swVertex[nbDrone];
      for(int i=0 ; i<nbDrone ; i++)
	{
	  tPos[i]=getVertexFromMadMap(MAPURL,'S',i+1);
	}
      Shokers= new cl_Serie('S',nbDrone,tPos);
      delete tPos;

      // Initialisation des drones Crystal
      nbDrone=getNbFromMadMap(MAPURL,'D');
      tPos=new swVertex[nbDrone];
      for(int i=0 ; i<nbDrone ; i++)
	{
	  tPos[i]=getVertexFromMadMap(MAPURL,'D',i+1);
	}
      Crystals= new cl_Serie('C',nbDrone,tPos);
      delete tPos;
    }
  catch(...)
    {
      logOut(" [!]Erreur dans l'initialisation des Drones\n");
      exit(0);
    }
	

  float BackColor[4]={MapColl->Climat->getR(),MapColl->Climat->getG(),MapColl->Climat->getB(),1.0};

  // Paramètrage du brouillard
  glFogi(GL_FOG_MODE, GL_LINEAR);
  glFogfv(GL_FOG_COLOR, BackColor);
  glHint(GL_FOG_HINT, GL_DONT_CARE);
  glFogf(GL_FOG_START, MapColl->Climat->getFog());
  glFogf(GL_FOG_END, MapColl->Climat->getFog()+500);
  // Activation du brouillard
  glEnable(GL_FOG);


  if(MapColl->Climat->IsPluie())
    Particule->AddPluie(fly,50);
  if(MapColl->Climat->IsNeige())
    Particule->AddNeige(fly,40);

  //Particule->AddFumee(fly, swVertex(1.5,0,0), 0.5, "data/texture/part/serv03.tga", 2);//250

  clSoundMan * Sound=clSoundMan::Create();
  /*signed char rCD=FSOUND_CD_Play(0,0);
  if(rCD==FMOD_ERR_CDDEVICE || FSOUND_CD_GetNumTracks(0)==0)
    Sound->JouerStream (MUSIC_THEME, CANAL_MUSIQUE, true);
  else
    {
      Sound->CtrlMusicActive(true);
      FSOUND_CD_SetPlayMode(0, FSOUND_CD_PLAYCONTINUOUS);
      printf("Lecture du CD, %d pistes\n", FSOUND_CD_GetNumTracks(0));
    }
  */
  Sound->JouerStream (SOUND_WING, CANAL_JOUEUR, true);

  TIMElast=TIMEcur=GETTIME;
   
  switch(cursMod)
    {
    case MOD_DEFI :
      menuSetComment(MOD_DEFI_MISSIONS[cursDefiMission-1].Comment,5000);
      break;
    case MOD_EXPLORATION :
    default :
      char * inf=getStrFromMadMap(MAPURL,'F',1);
      menuSetComment(inf,5000);
      delete inf;
    }

  return;
}
Server::~Server() {
    logOut();
    SDLNet_Quit();
}
Example #28
0
int innerMain(bool testInstall, char* installPath, char* installUser) {
    logOut("PufferPanel Installer - Version C-%s (%s)\n", INSTALLERVERSION, PPVERSION);
    logOutFile("Testing install: %s\n", testInstall ? "true" : "false");
    logOutFile("Install path: %s\n", installPath);
    logOutFile("Install user: %s\n", installUser);

    logOut("-----\n");
    bool result = validateDependencies();
    logOut("-----\n");
    if (result) {
        logOut("Dependencies are met, installing.\n");
        if (testInstall) {
            logOut("Halting installation due to test flag being present.\n");
            return (EXIT_SUCCESS);
        }
    } else {
        logOut("Halting installation as dependencies are not met. Please fix this before continuing.\n");
        return (EXIT_FAILURE);
    }

    logOut("-----\n");
    logOut("Extracting panel\n");
    if (!extractPanel(installPath, installUser)) {
        return (EXIT_FAILURE);
    }

    logOut("-----\n");
    if (!finalizeInstall(installPath, installUser)) {
        return (EXIT_FAILURE);
    }

    logOut("-----\n");
    logOut("Installation complete, thank you for choosing PufferPanel!\n");

    return (EXIT_SUCCESS);
}
Example #29
0
void MainApp::onLoggedOut()
{
	logOut(true, false, true);
}
Example #30
0
///////////////////////////////////////////
// Dispatches Zone data packets based on the opCode
void EQPacket::dispatchZoneData(const uint8_t *data, size_t len, 
				uint8_t dir, uint16_t opCode)
{
#ifdef DEBUG_PACKET
    debug ("dispatchZoneData()");
#endif /* DEBUG_PACKET */

    QString  tempStr;

    bool unk = true;

    switch (opCode)
      {
      case OP_ClientUpdate: // old PlayerPosCode:
        {
#ifdef PACKET_PAYLOAD_SIZE_DIAG
	  if ((len != sizeof(playerSpawnPosStruct)) &&
	      (len != sizeof(playerSelfPosStruct)))
	  {
	    fprintf(stderr, "WARNING: OP_ClientUpdate (%04x) (dataLen: %d != sizeof(playerSpawnPosStruct):%d or sizeof(playerSpawnSelfStruct):%d)\n",
		    OP_ClientUpdate, len, 
		    sizeof(playerSpawnPosStruct), sizeof(playerSelfPosStruct));
	    unk = true;
	  }
	  else
	    unk = false;
#else
	  unk = false;
#endif
	  
	  if (len == sizeof(playerSpawnPosStruct))
	    emit playerUpdate((const playerSpawnPosStruct*)data, len, dir);
	  else if (len == sizeof(playerSelfPosStruct))
	    emit playerUpdate((const playerSelfPosStruct*)data, len, dir);
	  else
	    unk = true;
	  
	  break;
        }

      case OP_MobUpdate: // old MobUpdateCode:
        {
	  unk = ! ValidatePayload(OP_MobUpdate, spawnPositionUpdate);
	  
	  emit updateSpawns((const spawnPositionUpdate *)data, len, dir);
	  
	  break;
        }
	
      case OP_WearChange: // old SpawnUpdateCode:
        {
	  unk = ! ValidatePayload(OP_WearChange, SpawnUpdateStruct);
	  SpawnUpdateStruct *su = (SpawnUpdateStruct*)data;
//	    printf("SpawnUpdateCode(id=%d, sub=%d, arg1=%d, arg2=%d)\n", 
//		   su->spawnId, su->subcommand, 
//		   su->arg1, su->arg2);
	    /* Belith - I believe this is depreciated no? Doesn't work anyway ;) */
	  switch(su->subcommand) {
	  case 17:
	    emit updateSpawnMaxHP(su, len, dir);
	    break;
	  }
	  
	  break;
	  emit updateSpawnInfo(su, len, dir);
        }

      case OP_SpawnAppearance: // old SpawnAppearanceCode:
        {
	  unk = false;
	  
	  emit spawnAppearance((const spawnAppearanceStruct*)data, len, dir);
	  break;
        }
	
      case OP_CommonMessage: // old ChannelMessageCode:
	{
	  unk = false;
	  
	  emit channelMessage((const channelMessageStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_FormattedMessage: // old FormattedMessageCode:
	{
	  unk = false;
	  
	  emit formattedMessage((const formattedMessageStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_SimpleMessage: // old SimpleMessageCode:
	{
	  unk = false;

	  emit simpleMessage((const simpleMessageStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_SpecialMesg:
	{
	  unk = false;
	  
	  emit specialMessage((const specialMessageStruct*)data, len, dir);

	  break;
	}
	
      case OP_GuildMOTD:
	{
	  unk = false;
	  
	  emit guildMOTD((const guildMOTDStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_Death: // old NewCorpseCode:
	{
	  unk = ! ValidatePayload(OP_Death, newCorpseStruct);

	  emit killSpawn((const newCorpseStruct*) data, len, dir);
	  
	  break;
	} /* end CorpseCode */
	
      case OP_DeleteSpawn: // old DeleteSpawnCode:
	{
	  unk = ! ValidatePayload(OP_DeleteSpawn, deleteSpawnStruct);
	  
	  emit deleteSpawn((const deleteSpawnStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_ItemLinkResponse: // old ItemInfoCode:
	{
	  unk = false;
	  
	  if (dir == DIR_SERVER)
	    emit itemInfo((const itemInfoStruct*)data, len, dir);
	  else
	    emit itemInfoReq((const itemInfoReqStruct*)data, len, dir);
	}
	
      case OP_ItemPacket: // old ItemCode:
	{
	  unk = false;
	  
	  if (dir == DIR_SERVER)
	    emit item((const itemPacketStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_ItemPlayerPacket:
	{
	  unk = false;
	  
	  if (dir == DIR_SERVER)
	    emit playerItem((const char*)data, len, dir);
	  
	  break;
	}

      case OP_NewSpawn: // old NewSpawnCode:
	{
	  unk = ! ValidatePayload(OP_NewSpawn, newSpawnStruct);
	  
	  emit newSpawn((const newSpawnStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_ItemTextFile: // old BookTextCode:
	{
	  unk = false;
	  
	  printf("BOOK: '%s'\n", ((const bookTextStruct *)data)->text);
	  emit bookText((const bookTextStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_MoneyOnCorpse: // old MoneyOnCorpseCode:
	{
	  unk = ! ValidatePayload(OP_MoneyOnCorpse, moneyOnCorpseStruct);
	  
	  emit moneyOnCorpse((const moneyOnCorpseStruct*)data, len, dir);
	  
	  break;
	} /* end MoneyOnCorpseCode */
	
      case OP_RandomReply: // old RandomCode:
        {
	  unk = ! ValidatePayload(OP_RandomReply, randomStruct);
	  
	  emit random((const randomStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_RandomReq: // RandomReqCode:
        {
	  unk = ! ValidatePayload(OP_RandomReq, randomReqStruct);
	  
	  emit random((const randomReqStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_Emote: // old EmoteEmoteTextCode:
        {
	  unk = false;
	  
	  emit emoteText((const emoteTextStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_CorpseLocResponse: // old CorpseLocCode:
        {
	  unk = ! ValidatePayload(OP_CorpseLocResponse, corpseLocStruct);
	  
	  emit corpseLoc((const corpseLocStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_InspectAnswer: // old InspectDataCode:
        {
	  unk = ! ValidatePayload(OP_InspectAnswer, inspectDataStruct);
	  
	  emit inspectData((const inspectDataStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_HPUpdate: // old NpcHpUpdateCode:
	{
	  unk = ! ValidatePayload(OP_HPUpdate, hpNpcUpdateStruct);
	  
	  emit updateNpcHP((const hpNpcUpdateStruct*)data, len, dir);
	  
	  break;
	}
	
      case SPMesgCode:
        {
	  unk = false;
	  
	  emit spMessage((const spMesgStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_MemorizeSpell: // old MemSpellCode:
        {
	  unk = ! ValidatePayload(OP_MemorizeSpell, memSpellStruct);
	  
	  emit handleSpell((const memSpellStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_BeginCast: // old BeginCastCode
        {
	  unk = ! ValidatePayload(OP_BeginCast, beginCastStruct);
	  
	  emit beginCast((const beginCastStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_CastSpell: // old StartCastCode:
        {
	  unk = ! ValidatePayload(OP_CastSpell, startCastStruct);
	  
	  emit startCast((const startCastStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_BuffFadeMsg: // old SpellFadeCode:
	{
	  unk = false;
	  
	  emit spellFaded((const spellFadedStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_ExpUpdate: // old ExpUpdateCode:
        {
	  unk = ! ValidatePayload(OP_ExpUpdate, expUpdateStruct);
	  
	  emit updateExp((const expUpdateStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_LevelUpdate: // old LevelUpUpdateCode:
        {
	  unk = ! ValidatePayload(OP_LevelUpdate, levelUpUpdateStruct);
	  
	  emit updateLevel((const levelUpUpdateStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_SkillUpdate: // old SkillIncCode
        {
	  unk = ! ValidatePayload(OP_SkillUpdate, skillIncStruct);
	  
	  emit increaseSkill((const skillIncStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_MoveDoor: // old DoorOpenCode:
        {
	  unk = false;
	  
	  emit doorOpen(data, len, dir);
	  
	  break;
        }
	
      case OP_Illusion: // old IllusionCode:
        {
	  unk = false;
	  
	  emit illusion(data, len, dir);
	  
	  break;
        }
	
      case OP_ZoneChange: // old ZoneChangeCode:
        {
	  unk = ! ValidatePayload(OP_ZoneChange, zoneChangeStruct);
	  
	  // in the process of zoning, server hasn't switched yet.
	  
	  emit zoneChange((const zoneChangeStruct*)data, len, dir);
	  break;
        }
	
      case OP_ZoneEntry: // old ZoneEntryCode:
        {
	  // We're only interested in the server version
	  
	  if (dir == DIR_CLIENT)
	  {
	    unk = ! ValidatePayload(OP_ZoneEntry, ClientZoneEntryStruct);
	    emit zoneEntry((const ClientZoneEntryStruct*)data, len, dir);
	    break;
	  }
	  
	  unk = ! ValidatePayload(OP_ZoneEntry, ServerZoneEntryStruct);
	  
	  emit zoneEntry((const ServerZoneEntryStruct*)data, len, dir);
	  
	  break;
        } /* end ZoneEntryCode */
	
      case OP_NewZone: // old - NewZoneCode:
        {
	  unk = ! ValidatePayload(OP_NewZone, newZoneStruct);
	  
	  emit zoneNew((const newZoneStruct*)data, len, dir);
	  
	  if (m_vPacket)
	    printf("New Zone at byte: %ld\n", m_vPacket->FilePos());
	  
	  break;
        }
	
      case OP_PlayerProfile:	// Character Profile server to client - old CharProfileCode
	{
	  unk = false;
	  
	  ValidatePayload(OP_PlayerProfile, charProfileStruct);
	  
	  emit backfillPlayer((const charProfileStruct*)data, len, DIR_SERVER);
	  
	  break;
	}
	
      case OP_ZoneSpawns: // ZoneSpawnsCode:
	{
	  unk = false; 
	  
	  emit zoneSpawns((const zoneSpawnsStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_TimeOfDay: // old TimeOfDayCode:
	{
	  unk = ! ValidatePayload(OP_TimeOfDay, timeOfDayStruct);
	  
	  emit timeOfDay((const timeOfDayStruct*)data, len, dir);
	  
	  break;
	}
	
      case WearChangeCode:
        {
	  unk = ! ValidatePayload(WearChangeCode, wearChangeStruct);
	  
	  emit spawnWearingUpdate ((const wearChangeStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_Action:
	{
	  unk = ! ValidatePayload(OP_Action, actionStruct);
	  
	  emit action((const actionStruct*)data, len, dir);
	  
	  break;
	}
	
      case OP_CastBuff: // old ActionCode:
        {
	  unk = false;
	  
	  emit action2Message ((const action2Struct *)data, len, dir);
	  
	  break;
        }
	
      case OP_Stamina: /// old StaminaCode:
        {
	  unk = ! ValidatePayload(OP_Stamina, staminaStruct);
	  
	  emit updateStamina((const staminaStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_GroundSpawn: // old MakeDropCode:
        {
#ifdef PACKET_PAYLOAD_SIZE_DIAG
	  if ((len != sizeof(makeDropStruct)) &&
	      (len != 0))
	    {
	      fprintf(stderr, "WARNING: OP_GroundSpawn (%04x) (dataLen: %d != sizeof(makeDropStruct):%d or 0)\n",
		      OP_GroundSpawn, len, 
		      sizeof(makeDropStruct));
	      unk = true;
	    }
	  else
	    unk = false;
#else
	  unk = false;
#endif
	  
	  emit newGroundItem((const makeDropStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_ClickObject: // Old RemDropCode:
        {
	  unk = ! ValidatePayload(OP_ClickObject, remDropStruct);
	  
	  emit removeGroundItem((const remDropStruct *)data, len, dir);
	  
	  break;
        }
	
      case OP_ShopRequest: // old OpenVendorCode:
        {
	  unk = false;
	  
	  emit openVendor(data, len, dir);
	  
	  break;
        }
	
      case OP_ShopEnd: // old CloseVendorCode:
        {
	  unk = false;
	  
	  emit closeVendor(data, len, dir);
	  
	  break;
        }
	
      case OP_GMTraining: // old OpenGMCode:
        {
	  unk = false;
	  
	  emit openGM(data, len, dir);
	  
	  break;
        }
	
      case OP_GMEndTrainingResponse: // old CloseGMCode:
        {
	  unk = false;
	  
	  emit closeGM(data, len, dir);
	  
	  break;
        }
	
      case OP_Consider: // old ConsiderCode:
        {
	  unk = false;
	  
	  ValidatePayload(OP_Consider, considerStruct);
	  
	  emit consMessage((const considerStruct*)data, len, dir);
	  
	  break;
        }
	
      case OP_TargetMouse: // old ClientTargetCode:
        {
	  unk = ! ValidatePayload(OP_TargetMouse, clientTargetStruct);
	  
	  emit clientTarget((const clientTargetStruct*) data, len, dir);
	  
	  break;
        }
	
      case OP_SpawnDoor: // old DoorSpawnsCode:
        {
	  unk = false;
	  
#ifdef PACKET_PAYLOAD_SIZE_DIAG
	  // verify size
	  
	  if (len % sizeof(doorStruct) != 0)
          {
	    printf("WARNING: OP_SpawnDoor (%.04x) (dataLen:%d "
		   "%% sizeof(doorStruct):%d) != 0!\n", 
		   OP_SpawnDoor, len, sizeof(doorStruct));
	    
	    unk = true;
	    break;
            }
#endif
	  int nDoors = len / sizeof(doorStruct);
	  const DoorSpawnsStruct *doorsStruct = (const DoorSpawnsStruct *)data;
	  for (int i = 0; i < nDoors; i++) {
	    emit newDoorSpawn(&doorsStruct->doors[i], len, dir);
	  }
	  
	  emit newDoorSpawns(doorsStruct, len, dir);
	  
	  break;
        }

      case OP_Buff: // old BuffDropCode: 
	{
	  unk = ! ValidatePayload(OP_Buff, buffStruct);
	  
	  emit buff((const buffStruct*)data, len, dir);
	  
	  // this is the server 'buff fading' AND the client 'cancel buff'
	  break;
	}
	
      case OP_Logout: // no contents
	{
	  unk = false;
	  
	  emit logOut(data, len, dir);
	  
	  break;
	}
	
      case OP_SendZonePoints:
	{
	  unk = false;
#ifdef PACKET_PAYLOAD_SIZE_DIAG
	  const zonePointsStruct* zp = (const zonePointsStruct*)data;
	  // verify size
	  if (((len - sizeof(zp->count) - sizeof(zp->unknown0xxx)) 
	       % sizeof(zonePointStruct)) != 0)
	  {
	    fprintf(stderr, "WARNING: OP_SendZonePoints (%04x) (dataLen: %d %% sizeof(zonePointStruct):%d) != 0!\n",
		    OP_SendZonePoints, len, sizeof(zonePointStruct));
	    unk = true;
	    break;
	  }
#endif

	  emit zonePoints((const zonePointsStruct*)data, len, dir);

	  break;
	}
	
      case OP_GuildMemberList: // old GuildMemberListCode
	{
	  unk = false;
	  break;
	}
	
      case OP_GuildMemberUpdate: // old GuildMemberUpdateCode:
	{
	  unk = false;
	  break;
	}
	
      case OP_SetRunMode: // old cRunToggleCode:
	{
	  //unk = ! ValidatePayload(cRunToggleCode, cRunToggleStruct);
	  //emit cRunToggle((const cRunToggleStruct*)data, len, dir);
	  unk = false;
	  break;
	}
	
      case OP_Jump: // old cJumpCode:
	{
	  //no data
	  unk = false;
	  break;
	}
	
      case OP_Camp: // old cStartCampingCode:
	{
	  //no data
	  unk = false;
	  break;
	}
	
      case OP_SenseHeading: // old cSenseHeadingCode:
	{
	  //no data
	  unk = false;
	  break;
	}
	
      case OP_Forage: // old ForageCode:
	{
	  //no data
	  unk = false;
	  break;
	}

#if 0 // ZBTEMP	: If we don't bother setting unk, don't bother processing
      case OP_ConsiderCorpse: //unknown contents // old cConCorpseCode:  
	{
	  //unk = ! ValidatePayload(cConCorpseCode, cConCorpseStruct);
	  //emit cConCorpse((const cConCorpseStruct*)data, len, dir);
	  break;
	}
	
      case OP_LootRequest:  //unknown contents - old cLootCorpseCode
	{
	  //unk = ! ValidatePayload(cLootCorpseCode, cLootCorpseStruct);
	  //emit cLootCorpse((const cLootCorpseStruct*)data, len, dir);
	  break;
	}
	
      case OP_EndLootRequest:  //unknown contents - old cDoneLootingCode
	{
	  //unk = ! ValidatePayload(cDoneLootingCode, cDoneLootingStruct);
	  //emit cDoneLooting((const cDoneLootingStruct*)data, len, dir);
	  break;
	}
	
      case OP_LootComplete:  //unknown contents - old sDoneLootingCode
	{
	  //unk = ! ValidatePayload(sDoneLootingCode, sDoneLootingStruct);
	  //emit sDoneLooting((const sDoneLootingStruct*)data, len, dir);
	  break;
	}
	
      case OP_WhoAllRequest:  //unknown contents - old WhoAllReqCode
	{
	  //unk = ! ValidatePayload(cWhoAllCode, cWhoAllStruct);
	  //emit cWhoAll((const cWhoAllStruct*)data, len, dir);
	  break;
	}
	
      case OP_WhoAllResponse: // old sWhoAllOutputCode: unknown contents
	{
	  //unk = ! ValidatePayload(sWhoAllOutputCode, sWhoAllOutputStruct);
	  //emit sWhoAllOutput((const sWhoAllOutputStruct*)data, len, dir);
	  break;
	}
      
      case OP_ShopPlayerBuy:  //unknown contents - old BuyItemCode
	{
	  //unk = ! ValidatePayload(xBuyItemCode, xBuyItemStruct);
	  //emit xBuyItem((const xBuyItemStruct*)data, len, dir);
	  //both the client command and the server acknowledgement when buying
	  break;
	}
#endif // ZBTEMP

#if 0 // ZBTEMP: OPCode Graveyard
      case CastOnCode:
        {
	  unk = false;
	  
	  emit castOn((castOnStruct*)data, len, dir);
	  
	  break;
        }
	
      case ManaDecrementCode:
        {
	  unk = ! ValidatePayload(ManaDecrementCode, manaDecrementStruct);
	  
	  emit manaChange((struct manaDecrementStruct *)data, len, dir);
	  
	  break;
        }
	
      case BadCastCode:
        {
	  unk = false; //! ValidatePayload(BadCastCode, badCastStruct);
	  
	  emit interruptSpellCast((const badCastStruct*)data, len, dir);
	  
	  break;
        }
	
      case SysMsgCode:
        {
	  unk = false;
	  
	  emit systemMessage((const sysMsgStruct*)data, len, dir);
	  
	  break;
        }
	
      case AltExpUpdateCode:
        {
	  unk = ! ValidatePayload(AltExpUpdateCode, altExpUpdateStruct);
	  
	  emit updateAltExp((const altExpUpdateStruct*)data, len, dir);
	  
	  break;
        }
	
      case Attack2Code:
        {
	  unk = false;
	  
	  emit attack2Hand1 ((const attack2Struct *)data, len, dir);
	  
	  break;
        }
	
      case NewGuildInZoneCode:
        {
	  unk = false;
	  
	  break;
        }
	
      case MoneyUpdateCode:
        {  
	  unk = false;
	  
	  emit moneyUpdate((const moneyUpdateStruct*)data, len, dir);
	  
	  break;
        }
	
      case MoneyThingCode:
        {
            unk = false;
	    
	    emit moneyThing((const moneyThingStruct*)data, len, dir);
	    
            break;
        }
	
      case BindWoundCode:
        {
	  unk = false;
	  
	  emit bindWound((bindWoundStruct*)data, len, dir);
	  
	  break;
        }
	
      case GroupInfoCode:
        {
	  // Too much still unknown.
	  
	  unk = ! ValidatePayload(GroupInfoCode, groupMemberStruct);
	  
	  emit groupInfo((const groupMemberStruct*)data, len, dir);
	  
	  break;
        }
	
      case GroupInviteCode:
        {
	  unk = ! ValidatePayload(GroupInviteCode, groupInviteStruct);
	  
	  emit groupInvite((const groupInviteStruct*)data, len, dir);
	  
	  break;
        }
	
      case GroupDeclineCode:
        {
	  unk = ! ValidatePayload(GroupDeclineCode, groupDeclineStruct);
	  
	  emit groupDecline((const groupDeclineStruct*)data, len, dir);
	  
	  break;
        }
	
      case GroupAcceptCode:
        {
	  unk = ! ValidatePayload(GroupAcceptCode, groupAcceptStruct);
	  
	  emit groupAccept((const groupAcceptStruct*)data, len, dir);
	  
	  break;
        }
	
      case GroupDeleteCode:
        {
	  unk = ! ValidatePayload(GroupDeleteCode, groupDeleteStruct);
	  
	  emit groupDelete((const groupDeleteStruct*)data, len, dir);
	  
	  break;
        }
	
      case CharUpdateCode:
        {
	  break;
        }
	
      case cChatFiltersCode:
	{
	  //unk = ! ValidatePayload(cChatFiltersCode, cChatFiltersStruct);
	  //emit cChatFilters((const cChatFiltersStruct*)data, len, dir);
	  unk = false;
	  break;
	}
	
      case cOpenSpellBookCode:
	{
	  //unk = ! ValidatePayload(cOpenSpellBookCode, cOpenSpellBookStruct);
	  //emit cOpenSpellBook((const cOpenSpellBookStruct*)data, len, dir);
	  unk = false;
	  break;
	}
	
      case OP_SwapSpell: // old TradeSpellBookSlotsCode:
	{
	  unk = ! ValidatePayload(OP_SwapSpell, tradeSpellBookSlotsStruct);
	  emit tradeSpellBookSlots((const tradeSpellBookSlotsStruct*)data, len, dir);
	  break;
	}
	
      case sSpellFizzleRegainCode:  //unknown contents, also comes when you Forage
	{
	  //unk = ! ValidatePayload(sSpellFizzleRegainCode, sSpellFizzleRegainStruct);
	  //emit sSpellFizzleRegain((const sSpellFizzleRegainStruct*)data, len, dir);
	  break;
	}
	
      case sSpellInterruptedCode:  //unknown contents
	{
	  //unk = ! ValidatePayload(sSpellInterruptedCode, sSpellInterruptedStruct);
	  //emit sSpellInterrupted((const sSpellInterruptedStruct*)data, len, dir);
	  break;
	}
	
      case cHideCode:
	{
	  //no data
	  unk = false;
	  break;
	}
	
      case cSneakCode:
	{
	  //no data
	  unk = false;
	  break;
	}
	
      case cTrackCode:
	{
	  //no data
	  unk = false;
	  break;
	}
#endif // ZBTEMP // Currently dead opcodes
	
      default:
        {
        }
      } /* end switch(opCode) */

    emit decodedZonePacket(data, len, dir, opCode, unk);
}