Ejemplo n.º 1
0
int GetKillValue(int level)
{
	int iMinLevelFor1Point, iMaxLevelFor1Point;
	int iMinLevelFor2Point, iMaxLevelFor2Point;
	int iMinLevelFor3Point, iMaxLevelFor3Point;

	if (LC_IsBrazil() == true)
	{
		iMinLevelFor1Point = 35; iMaxLevelFor1Point = 50;
		iMinLevelFor2Point = 51; iMaxLevelFor2Point = 70;
		iMinLevelFor3Point = 71; iMaxLevelFor3Point = 99;
	}
	else if (LC_IsYMIR() == false)
	{
		iMinLevelFor1Point = 30; iMaxLevelFor1Point = 39;
		iMinLevelFor2Point = 40; iMaxLevelFor2Point = 49;
		iMinLevelFor3Point = 50; iMaxLevelFor3Point = 99;
	}
	else
	{
		iMinLevelFor1Point = 50; iMaxLevelFor1Point = 59;
		iMinLevelFor2Point = 60; iMaxLevelFor2Point = 69;
		iMinLevelFor3Point = 70; iMaxLevelFor3Point = 99;
	}

	if (iMinLevelFor1Point <= level && level <= iMaxLevelFor1Point)
	{
		return 1;
	}
	else if (iMinLevelFor2Point <= level && level <= iMaxLevelFor2Point)
	{
		return 2;
	}
	else if (iMinLevelFor3Point <= level && level <= iMaxLevelFor3Point)
	{
		return 3;
	}

	return 0;
}
Ejemplo n.º 2
0
bool FN_IS_VALID_LOGIN_STRING(const char *str)
{
    const char*	tmp;

    if (!str || !*str)
        return false;

    if (strlen(str) < 2)
        return false;

    for (tmp = str; *tmp; ++tmp)
    {
        // 알파벳과 수자만 허용
        if (isdigit(*tmp) || isalpha(*tmp))
            continue;

        // 캐나다는 몇몇 특수문자 허용
        if (LC_IsCanada())
        {
            switch (*tmp)
            {
            case ' ':
            case '_':
            case '-':
            case '.':
            case '!':
            case '@':
            case '#':
            case '$':
            case '%':
            case '^':
            case '&':
            case '*':
            case '(':
            case ')':
                continue;
            }
        }

        if (LC_IsYMIR() == true || LC_IsKorea() == true)
        {
            switch (*tmp)
            {
            case '-' :
            case '_' :
                continue;
            }
        }

        if (LC_IsBrazil() == true)
        {
            switch (*tmp)
            {
            case '_' :
            case '-' :
            case '=' :
                continue;
            }
        }

        if (LC_IsJapan() == true)
        {
            switch (*tmp)
            {
            case '-' :
            case '_' :
            case '@':
            case '#':
                continue;
            }
        }

        return false;
    }

    return true;
}
Ejemplo n.º 3
0
void CInputAuth::LoginOpenID(LPDESC d, const char * c_pData)
{
#ifdef ENABLE_LIMIT_TIME
#endif
    //OpenID test code.
    TPacketCGLogin5 *tempInfo1 = (TPacketCGLogin5 *)c_pData;

    //일본 웹 서버에 인증키 확인 요청을 보낸다.
    char* authKey = tempInfo1->authKey;
    char returnID[LOGIN_MAX_LEN + 1] = {0};

    int test_url_get_protocol = auth_OpenID(authKey, inet_ntoa(d->GetAddr().sin_addr), returnID);

    //인증 실패. 에러 처리
    if (0!=test_url_get_protocol)
    {
        LoginFailure(d, "OpenID Fail");
        return;
    }

    TPacketCGLogin3 tempInfo2;
    strncpy(tempInfo2.login, returnID, LOGIN_MAX_LEN);
    strncpy(tempInfo2.passwd, "0000", PASSWD_MAX_LEN);
    for(int i=0; i<4; i++)
        tempInfo2.adwClientKey[i] = tempInfo1->adwClientKey[i];
    TPacketCGLogin3 * pinfo = &tempInfo2;

    if (!g_bAuthServer)
    {
        sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.",
                 inet_ntoa(d->GetAddr().sin_addr));
        d->DelayedDisconnect(5);
        return;
    }

    // string 무결성을 위해 복사
    char login[LOGIN_MAX_LEN + 1];
    trim_and_lower(pinfo->login, login, sizeof(login));

    char passwd[PASSWD_MAX_LEN + 1];
    strlcpy(passwd, pinfo->passwd, sizeof(passwd));

    sys_log(0, "InputAuth::Login : %s(%d) desc %p",
            login, strlen(login), get_pointer(d));

    // check login string
    if (false == FN_IS_VALID_LOGIN_STRING(login))
    {
        sys_log(0, "InputAuth::Login : IS_NOT_VALID_LOGIN_STRING(%s) desc %p",
                login, get_pointer(d));
        LoginFailure(d, "NOID");
        return;
    }

    if (g_bNoMoreClient)
    {
        TPacketGCLoginFailure failurePacket;

        failurePacket.header = HEADER_GC_LOGIN_FAILURE;
        strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));

        d->Packet(&failurePacket, sizeof(failurePacket));
        return;
    }

    if (DESC_MANAGER::instance().FindByLoginName(login))
    {
        LoginFailure(d, "ALREADY");
        return;
    }

    DWORD dwKey = DESC_MANAGER::instance().CreateLoginKey(d);
    DWORD dwPanamaKey = dwKey ^ pinfo->adwClientKey[0] ^ pinfo->adwClientKey[1] ^ pinfo->adwClientKey[2] ^ pinfo->adwClientKey[3];
    d->SetPanamaKey(dwPanamaKey);

    sys_log(0, "InputAuth::Login : key %u:0x%x login %s", dwKey, dwPanamaKey, login);

    // BRAZIL_AUTH
    if (LC_IsBrazil() && !test_server)
    {
        int result = auth_brazil(login, passwd);

        switch (result)
        {
        case AUTH_BRAZIL_SERVER_ERR:
        case AUTH_BRAZIL_NOID:
            LoginFailure(d, "NOID");
            return;
        case AUTH_BRAZIL_WRONGPWD:
            LoginFailure(d, "WRONGPWD");
            return;
        case AUTH_BRAZIL_FLASHUSER:
            LoginFailure(d, "FLASH");
            return;
        }
    }

    TPacketCGLogin3 * p = M2_NEW TPacketCGLogin3;
    thecore_memcpy(p, pinfo, sizeof(TPacketCGLogin3));

    char szPasswd[PASSWD_MAX_LEN * 2 + 1];
    DBManager::instance().EscapeString(szPasswd, sizeof(szPasswd), passwd, strlen(passwd));

    char szLogin[LOGIN_MAX_LEN * 2 + 1];
    DBManager::instance().EscapeString(szLogin, sizeof(szLogin), login, strlen(login));

    // CHANNEL_SERVICE_LOGIN
    if (Login_IsInChannelService(szLogin))
    {
        sys_log(0, "ChannelServiceLogin [%s]", szLogin);

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN_OPENID, dwKey, p,
                                          "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"
                                          "UNIX_TIMESTAMP(silver_expire),"
                                          "UNIX_TIMESTAMP(gold_expire),"
                                          "UNIX_TIMESTAMP(safebox_expire),"
                                          "UNIX_TIMESTAMP(autoloot_expire),"
                                          "UNIX_TIMESTAMP(fish_mind_expire),"
                                          "UNIX_TIMESTAMP(marriage_fast_expire),"
                                          "UNIX_TIMESTAMP(money_drop_rate_expire),"
                                          "UNIX_TIMESTAMP(create_time)"
                                          " FROM account WHERE login='******'",

                                          szPasswd, szLogin);
    }
    // END_OF_CHANNEL_SERVICE_LOGIN
    else
    {
        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN_OPENID, dwKey, p,
                                          "SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"
                                          "UNIX_TIMESTAMP(silver_expire),"
                                          "UNIX_TIMESTAMP(gold_expire),"
                                          "UNIX_TIMESTAMP(safebox_expire),"
                                          "UNIX_TIMESTAMP(autoloot_expire),"
                                          "UNIX_TIMESTAMP(fish_mind_expire),"
                                          "UNIX_TIMESTAMP(marriage_fast_expire),"
                                          "UNIX_TIMESTAMP(money_drop_rate_expire),"
                                          "UNIX_TIMESTAMP(create_time)"
                                          " FROM account WHERE login='******'",
                                          szPasswd, szLogin);
    }
}
Ejemplo n.º 4
0
int CShopEx::Buy(LPCHARACTER ch, BYTE pos)
{
	BYTE tabIdx = pos / SHOP_HOST_ITEM_MAX_NUM;
	BYTE slotPos = pos % SHOP_HOST_ITEM_MAX_NUM;
	if (tabIdx >= GetTabCount())
	{
		sys_log(0, "ShopEx::Buy : invalid position %d : %s", pos, ch->GetName());
		return SHOP_SUBHEADER_GC_INVALID_POS;
	}

	sys_log(0, "ShopEx::Buy : name %s pos %d", ch->GetName(), pos);

	GuestMapType::iterator it = m_map_guest.find(ch);

	if (it == m_map_guest.end())
		return SHOP_SUBHEADER_GC_END;

	TShopTableEx& shopTab = m_vec_shopTabs[tabIdx];
	TShopItemTable& r_item = shopTab.items[slotPos];

	if (r_item.price <= 0)
	{
		LogManager::instance().HackLog("SHOP_BUY_GOLD_OVERFLOW", ch);
		return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
	}

	DWORD dwPrice = r_item.price;

	switch (shopTab.coinType)
	{
	case SHOP_COIN_TYPE_GOLD:
		if (it->second)	// if other empire, price is triple
			dwPrice *= 3;

		if (ch->GetGold() < (int) dwPrice)
		{
			sys_log(1, "ShopEx::Buy : Not enough money : %s has %d, price %d", ch->GetName(), ch->GetGold(), dwPrice);
			return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY;
		}
		break;
	case SHOP_COIN_TYPE_SECONDARY_COIN:
		{
			int count = ch->CountSpecifyTypeItem(ITEM_SECONDARY_COIN);
			if (count < dwPrice)
			{
				sys_log(1, "ShopEx::Buy : Not enough myeongdojun : %s has %d, price %d", ch->GetName(), count, dwPrice);
				return SHOP_SUBHEADER_GC_NOT_ENOUGH_MONEY_EX;
			}
		}
		break;
	}
	
	LPITEM item;

	item = ITEM_MANAGER::instance().CreateItem(r_item.vnum, r_item.count);

	if (!item)
		return SHOP_SUBHEADER_GC_SOLD_OUT;

	int iEmptyPos;
	if (item->IsDragonSoul())
	{
		iEmptyPos = ch->GetEmptyDragonSoulInventory(item);
	}
	else
	{
		iEmptyPos = ch->GetEmptyInventory(item->GetSize());
	}

	if (iEmptyPos < 0)
	{
		sys_log(1, "ShopEx::Buy : Inventory full : %s size %d", ch->GetName(), item->GetSize());
		M2_DESTROY_ITEM(item);
		return SHOP_SUBHEADER_GC_INVENTORY_FULL;
	}

	switch (shopTab.coinType)
	{
	case SHOP_COIN_TYPE_GOLD:
		ch->PointChange(POINT_GOLD, -dwPrice, false);
		break;
	case SHOP_COIN_TYPE_SECONDARY_COIN:
		ch->RemoveSpecifyTypeItem(ITEM_SECONDARY_COIN, dwPrice);
		break;
	}


	if (item->IsDragonSoul())
		item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos));
	else
		item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos));

	ITEM_MANAGER::instance().FlushDelayedSave(item);
	LogManager::instance().ItemLog(ch, item, "BUY", item->GetName());

	if (item->GetVnum() >= 80003 && item->GetVnum() <= 80007)
	{
		LogManager::instance().GoldBarLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "");
	}

	DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice);

	if (item)
		sys_log(0, "ShopEx: BUY: name %s %s(x %d):%u price %u", ch->GetName(), item->GetName(), item->GetCount(), item->GetID(), dwPrice);

	if (LC_IsBrazil())
	{
		ch->SaveReal();
		db_clientdesc->DBPacketHeader(HEADER_GD_FLUSH_CACHE, 0, sizeof(DWORD));
		DWORD pid = ch->GetPlayerID();
		db_clientdesc->Packet(&pid, sizeof(DWORD));
	}
	else
	{
		ch->Save();
	}

    return (SHOP_SUBHEADER_GC_OK);
}