Beispiel #1
0
bool RuleManager::LoadRules(Database *db, const char *ruleset) {

	int rsid = GetRulesetID(db, ruleset);
	if(rsid < 0) {
		_log(RULES__ERROR, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
		return(false);
	}

	_log(RULES__CHANGE, "Loading rule set '%s' (%d)", ruleset, rsid);

	m_activeRuleset = rsid;
	m_activeName = ruleset;

    std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id=%d", rsid);
    auto results = db->QueryDatabase(query);
	if (!results.Success())
	{
        LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str());
		return false;
	}

    for(auto row = results.begin(); row != results.end(); ++row)
        if(!SetRule(row[0], row[1], nullptr, false))
            _log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]);

	return true;
}
Beispiel #2
0
bool RuleManager::LoadRules(Database *db, const char *ruleset) {

	int rsid = GetRulesetID(db, ruleset);
	if(rsid < 0) {
		Log.Out(Logs::Detail, Logs::Rules, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
		return(false);
	}

	Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", ruleset, rsid);

	m_activeRuleset = rsid;
	m_activeName = ruleset;

    std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id=%d", rsid);
    auto results = db->QueryDatabase(query);
	if (!results.Success())
	{
		return false;
	}

    for(auto row = results.begin(); row != results.end(); ++row)
        if(!SetRule(row[0], row[1], nullptr, false))
            Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]);

	return true;
}
Beispiel #3
0
cGenIndex::cGenIndex(void)
{
  index=new cIndex(destdir);
  fileName=new cFileName(input,input && rewrite);
  writeName=new cFileName(destdir,true);

  if(rewrite) {
    SetDefaultRule(prSkip);
    SetRuleR(0xE0,0xEF,prAct2);
    SetRuleR(0xC0,0xCF,prAct1);
    SetRule(0xBD,prAct1);
    SetRule(0xBE,prAct1);
    }
  else {
    SetDefaultRule(prAct1);
    SetRuleR(0xE0,0xEF,prAct2);
    }
}
Beispiel #4
0
bool RuleManager::LoadRules(Database *database, const char *ruleset_name) {
	
	int ruleset_id = GetRulesetID(database, ruleset_name);
	if (ruleset_id < 0) {
		Log.Out(Logs::Detail, Logs::Rules, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset_name);
		return(false);
	}

	Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", ruleset_name, ruleset_id);

	m_activeRuleset = ruleset_id;
	m_activeName = ruleset_name;

	/* Load default ruleset values first if we're loading something other than default */
	if (strcasecmp(ruleset_name, "default") != 0){
		std::string default_ruleset_name = "default";
		int default_ruleset_id = GetRulesetID(database, default_ruleset_name.c_str());
		if (default_ruleset_id < 0) {
			Log.Out(Logs::Detail, Logs::Rules, "Failed to find default ruleset '%s' for load operation. Canceling.", default_ruleset_name.c_str());
			return(false);
		}
		Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", default_ruleset_name.c_str(), default_ruleset_id);

		std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id = %d", default_ruleset_id);
		auto results = database->QueryDatabase(query);
		if (!results.Success())
			return false;

		for (auto row = results.begin(); row != results.end(); ++row)
		if (!SetRule(row[0], row[1], nullptr, false))
			Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]);
	}

	std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id=%d", ruleset_id);
	auto results = database->QueryDatabase(query);
	if (!results.Success())
		return false;

	for (auto row = results.begin(); row != results.end(); ++row)
	if (!SetRule(row[0], row[1], nullptr, false))
		Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]);

	return true;
}
Beispiel #5
0
bool RuleManager::LoadRules(Database *db, const char *ruleset) {
	char errbuf[MYSQL_ERRMSG_SIZE];
	char *query = 0;
	MYSQL_RES *result;
	MYSQL_ROW row;

	int rsid = GetRulesetID(db, ruleset);
	if(rsid < 0) {
		_log(RULES__ERROR, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
		return(false);
	}

	_log(RULES__CHANGE, "Loading rule set '%s' (%d)", ruleset, rsid);

	m_activeRuleset = rsid;
	m_activeName = ruleset;

	if (db->RunQuery(query, MakeAnyLenString(&query,
		"SELECT rule_name, rule_value"
		" FROM rule_values"
		" WHERE ruleset_id=%d", rsid), errbuf, &result))
	{
		safe_delete_array(query);
		while((row = mysql_fetch_row(result))) {
			if(!SetRule(row[0], row[1], nullptr, false))
				_log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]);
		}
		mysql_free_result(result);
	} else {
		safe_delete_array(query);
		LogFile->write(EQEMuLog::Error, "Error in LoadRules query %s: %s", query, errbuf);
		return(false);
	}

	return(true);
}
void CBCGPRecurrence::Serialize (CArchive& ar)
{
	CObject::Serialize (ar);

	if (ar.IsStoring ())
	{
		ASSERT_VALID (m_pRule);

		ar << m_pRule;
		ar << (DWORD)m_Exceptions.GetCount ();

		POSITION Pos = m_Exceptions.GetStartPosition ();
		COleDateTime Key;
		XBCGPRecurrenceException* Val = NULL;

		while (Pos != NULL)
		{
			m_Exceptions.GetNextAssoc (Pos, Key, Val);

			ar << Key;
			ar << Val->m_dtStart;
			ar << Val->m_dtFinish;
			ar << Val->m_Deleted;

			if (!Val->m_Deleted)
			{
				ar << &(Val->m_Properties);
			}
		}
	}
	else
	{
		RemoveExceptions ();

		CBCGPRecurrenceBaseRule* pRule = NULL;
		ar >> pRule;

		ASSERT_VALID (pRule);

		SetRule (pRule);

		delete pRule;

		DWORD dwCount = 0;
		ar >> dwCount;

		for (DWORD i = 0; i < dwCount; i++)
		{
			COleDateTime Key;
			ar >> Key;

			XBCGPRecurrenceException* Val = new XBCGPRecurrenceException;
			ar >> Val->m_dtStart;
			ar >> Val->m_dtFinish;
			ar >> Val->m_Deleted;

			if (!Val->m_Deleted)
			{
				CBCGPAppointmentPropertyList* pList = NULL;
				ar >> pList;
				
				Val->m_Properties.CopyFrom (*pList);

				delete pList;
			}

			m_Exceptions[Key] = Val;
		}
	}
GBMJDesktopController::GBMJDesktopController( DJPanelController* panelController, const QSize& size, QWidget *parent )
    : DJDesktopMJController(panelController,size,parent)
{
    djDebug()<<"GBMJDesktopController constructor"<<size;

    PMahjongRoom pmjroom = (PMahjongRoom)((panelController->gameRoom())->privateRoom());
    SetRule(&(pmjroom->rule));

    m_toolbar	= new QWidget(desktop());
    QHBoxLayout *layout	= new QHBoxLayout( m_toolbar );
    layout->setMargin( 0 );
    layout->setSpacing( 0 );

    m_style = new QToolButton;
    m_style->setEnabled(true);
    m_style->setToolTip(tr("change style of pool cards"));
    m_style->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/arrange.png") );
    m_style->setIconSize( djToolButtonSize );
    connect(m_style,SIGNAL(clicked()),this,SLOT(ClickStyle()));
    layout->addWidget( m_style );

    m_qi = new QToolButton;
    m_qi->setEnabled(false);
    m_qi->setToolTip(tr("pass"));
    m_qi->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/qi.png") );
    m_qi->setIconSize( djToolButtonSize );
    connect(m_qi,SIGNAL(clicked()),this,SLOT(ClickQi()));
    layout->addWidget( m_qi );

    m_chu = new QToolButton;
    m_chu->setEnabled(false);
    m_chu->setToolTip(tr("throw a card"));
    m_chu->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/chu.png") );
    m_chu->setIconSize( djToolButtonSize );
    connect(m_chu,SIGNAL(clicked()),this,SLOT(ClickChu()));
    layout->addWidget( m_chu );

    m_chi = new QToolButton;
    m_chi->setEnabled(false);
    m_chi->setToolTip(tr("chi a card"));
    m_chi->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/chi.png") );
    m_chi->setIconSize( djToolButtonSize );
    connect(m_chi,SIGNAL(clicked()),this,SLOT(ClickChi()));
    layout->addWidget( m_chi );

    m_peng = new QToolButton;
    m_peng->setEnabled(false);
    m_peng->setToolTip(tr("peng a card"));
    m_peng->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/peng.png") );
    m_peng->setIconSize( djToolButtonSize );
    connect(m_peng,SIGNAL(clicked()),this,SLOT(ClickPeng()));
    layout->addWidget( m_peng );

    m_gang = new QToolButton;
    m_gang->setEnabled(false);
    m_gang->setToolTip(tr("gang a card"));
    m_gang->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/gang.png") );
    m_gang->setIconSize( djToolButtonSize );
    connect(m_gang,SIGNAL(clicked()),this,SLOT(ClickGang()));
    layout->addWidget( m_gang );

    m_ting = new QToolButton;
    m_ting->setEnabled(false);
    m_ting->setToolTip(tr("ready to hu"));
    m_ting->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/ting.png") );
    m_ting->setIconSize( djToolButtonSize );
    connect(m_ting,SIGNAL(clicked()),this,SLOT(ClickTing()));
    layout->addWidget( m_ting );

    m_hu = new QToolButton;
    m_hu->setEnabled(false);
    m_hu->setToolTip(tr("hu"));
    m_hu->setIcon( QIcon(":/BaseRes/image/desktop/toolbutton/hu.png") );
    m_hu->setIconSize( djToolButtonSize );
    connect(m_hu,SIGNAL(clicked()),this,SLOT(ClickHu()));
    layout->addWidget( m_hu );

    c_bReqTing = false;

    StaticInitDesktop();
}
Beispiel #8
0
void cGenIndex::Skip(int type)
{
  if(rewrite) SetRule(type,prSkip);
}