Exemple #1
0
//-----------------------------------------------------------------------------
void USER_IMPL::Run()
{
STG_LOCKER lock(&mutex);

if (stgTime > static_cast<time_t>(lastWriteStat + settings->GetStatWritePeriod()))
    {
    printfd(__FILE__, "USER::WriteStat user=%s\n", GetLogin().c_str());
    WriteStat();
    }
if (creditExpire.ConstData() && creditExpire.ConstData() < stgTime)
    {
    WriteServLog("User: %s. Credit expired.", login.c_str());
    credit = 0;
    creditExpire = 0;
    WriteConf();
    }

if (passive.ConstData()
    && (stgTime % 30 == 0)
    && (passiveTime.ModificationTime() != stgTime))
    {
    passiveTime = passiveTime + (stgTime - passiveTime.ModificationTime());
    printfd(__FILE__, "===== %s: passiveTime=%d =====\n", login.c_str(), passiveTime.ConstData());
    }

if (!authorizedBy.empty())
    {
    if (connected)
        property.Stat().lastActivityTime = stgTime;

    if (!connected && IsInetable())
        Connect();

    if (connected && !IsInetable())
        {
        if (disabled)
            Disconnect(false, "disabled");
        else if (passive)
            Disconnect(false, "passive");
        else
            Disconnect(false, "no cash");
        }

    if (stgTime - lastScanMessages > 10)
        {
        ScanMessage();
        lastScanMessages = stgTime;
        }
    }
else
    {
    if (connected)
        Disconnect(false, "not authorized");
    }

}
	void UserStatusPage::initializePage ()
	{
		auto cup = qobject_cast<ReportWizard*> (wizard ())->GetChooseUserPage ();

		const auto& login = cup->GetLogin ();
		const auto& pass = cup->GetPassword ();

		if (cup->GetUser () == ChooseUserPage::User::New)
			RegisterUser (login, pass, cup);
	}
Exemple #3
0
	bool ChooseUserPage::isComplete () const
	{
		switch (GetUser ())
		{
		case User::Anonymous:
			return true;
		case User::Existing:
			return !GetLogin ().isEmpty () && !GetPassword ().isEmpty ();
		default:
			return false;
		}
	}
Exemple #4
0
	void ChooseUserPage::SaveCredentials ()
	{
		if (GetUser () != User::Existing)
			return;

		QSettings settings (QCoreApplication::organizationName (),
			QCoreApplication::applicationName () + "_Dolozhee");
		settings.beginGroup ("Credentials");
		settings.setValue ("Login", GetLogin ());
		settings.endGroup ();

		Util::SavePassword (GetPassword (), GetPassKey (), Proxy_);
	}
Exemple #5
0
BOOL CaNodeLogin::Matched (CaNodeLogin* pObj, MatchObjectFlag nFlag)
{
    if (nFlag == MATCHED_NAME)
    {
        return (pObj->GetLogin().CompareNoCase (GetLogin()) == 0);
    }
    else
    {
        BOOL bOk = FALSE;
        if (pObj->GetNodeName().CompareNoCase (GetNodeName()) != 0)
            return FALSE;
        if (pObj->GetLogin().CompareNoCase (GetLogin()) != 0)
            return FALSE;
        if (pObj->IsLoginPrivate() != IsLoginPrivate())
            return FALSE;

        return TRUE;
    }
    //
    // Need the implementation ?
    ASSERT (FALSE);
    return FALSE;
}
Exemple #6
0
/*
 * LoginReset:  We've gotten an error from the server in LOGIN state;
 *   bring up appropriate dialog.
 */ 
void LoginReset(void)
{
   /* If login failed here, bring up dialog again */
   config.quickstart = FALSE;
   if (!logged_in)
   { 
      if (connection != CON_NONE)
	 if (GetLogin())
	    LoginSendInfo();
	 else Logoff();
      return;
   }

   EnterGame();
}
void ConnectionSettings::Save()
{
    QSettings settings(QApplication::organizationName(), QApplication::applicationName());
    settings.beginGroup(connectionSettingsSection);
    settings.setValue(dcNameParam, QString::fromStdWString(GetDC()));
    settings.setValue(userNameParam, QString::fromStdWString(GetLogin()));    
    QString protectedPassword = ProtectPassword(QString::fromStdWString(GetPassword()));
    settings.setValue(passwordParam, protectedPassword);    
    settings.setValue(currentUserCredParam, CurrentUserCredentials());
    settings.setValue(currentDomainParam, CurrentDomain());
#pragma warning(push, 3)
#pragma warning(disable: 4003)
    BOOST_SCOPE_EXIT(&settings) { settings.endGroup(); }BOOST_SCOPE_EXIT_END
#pragma warning(pop)    
}
Exemple #8
0
//==============================================================================
void GameServer::HandleExamine_(const QVariantMap& request, QVariantMap& response)
{
  auto id = request["id"].toInt();
  if (!id
      || idToActor_.count(id) == 0)
  {
    WriteResult_(response, EFEMPResult::BAD_ID);
    return;
  }

  Actor* actor = idToActor_[id];
  response["type"] = TypeToString[actor->GetType()];
  if (actor->GetType() != EActorType::ITEM
      && actor->GetType() != EActorType::PROJECTILE)
  {
    auto m = dynamic_cast<Creature*>(actor);
    response["health"] = m->GetHealth();
    response["maxHealth"] = m->GetMaxHealth();
  }

  if (response["health"] <= 0
      && response["type"] != "item"
      && response["type"] != "projectile")
  {
    WriteResult_ (response, EFEMPResult::BAD_ID);
    return;
  }

  if (actor->GetType() == EActorType::MONSTER)
  {
    auto m = dynamic_cast<Monster*>(actor);
    response["mobType"] = m->GetName();
    response["race"] = m->GetRace();
    QVariantList items;

    for (auto& a : m->items)
    {
      QVariantMap item;
      item["id"] = a->GetId();
      item["name"] = a->Getname();
      item["type"] = a->GetTypeItem();
      item["class"] = a->GetClass();
      item["subtype"] = a->GetSubtype();
      item["weight"] = a->GetWeight();
      items << item;
    }

    response["inventory"] = items;

    QVariantMap stats;

    for (auto i = StringToStat.begin(); i != StringToStat.end(); i++)
    {
      stats[i.key()] = m->GetStatValue(i.value());
    }

    response["stats"] = stats;
  }

  if (actor->GetType() == EActorType::ITEM)
  {
    auto m = dynamic_cast<Item*>(actor);
    QVariantMap item;
    item["name"] = m->Getname();
    item["type"] = m->GetTypeItem();
    item["class"] = m->GetClass();
    item["subtype"] = m->GetSubtype();
    item["weight"] = m->GetWeight();
    response["item"] = item;
  }

  if (actor->GetType() == EActorType::PLAYER)
  {
    auto p = dynamic_cast<Player*>(actor);
    response["login"] = p->GetLogin();

    QVariantList items;
    for (auto& a : p->items_)
    {
      QVariantMap item;
      item["id"] = a->GetId();
      item["name"] = a->Getname();
      item["type"] = a->GetTypeItem();
      item["class"] = a->GetClass();
      item["subtype"] = a->GetSubtype();
      item["weight"] = a->GetWeight();
      items << item;
    }

    response["inventory"] = items;

    QVariantMap slots_;

    for (auto i = SlotToString.begin(); i != SlotToString.end(); i++)
    {
      Item* item_ = p->GetSlot(i.value());
      if (item_
          && item_->GetId() != -1)
      {
          QVariantMap item;
          item["id"] = item_->GetId();
          item["name"] = item_->Getname();
          item["type"] = item_->GetTypeItem();
          item["class"] = item_->GetClass();
          item["subtype"] = item_->GetSubtype();
          item["weight"] = item_->GetWeight();
          slots_[i.key()] = item;
      }
    }
    response["slots"] = slots_;

    QVariantMap stats;
    for (auto i = StringToStat.begin(); i != StringToStat.end(); i++)
    {
      stats[i.key()] = p->GetStatValue(i.value());
    }
    response["stats"] = stats;
  }

  response["x"] = actor->GetPosition().x;
  response["y"] = actor->GetPosition().y;
  response["id"] = actor->GetId();
}
Exemple #9
0
string TClient::GetFullLogin() {
    return GetLogin() + "@" + GetHost();
}