Esempio n. 1
0
bool CShop::BuyShopItemAndDelete(int Pos, int aIndex,CShop *Shop)
{
	LPOBJ lpObj = &gObj[aIndex];
	if ( Shop->m_item[Pos].IsItem() == TRUE )
	{
		PMSG_BUYRESULT pResult;

		PHeadSetB((LPBYTE)&pResult, 0x32, sizeof(pResult));
		pResult.Result = -1;

		int iStoreTaxMoney = Shop->m_item[Pos].m_BuyMoney + (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney < 0 )
			iStoreTaxMoney  = 0;

		int iStoreTaxMoney2 = (int)((__int64)Shop->m_item[Pos].m_BuyMoney * (__int64)g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index) / (__int64)100);

		if ( iStoreTaxMoney2 < 0 )
			iStoreTaxMoney2  = 0;

		if ( lpObj->Money < iStoreTaxMoney )
			pResult.Result = -1;
		else
		{
			BOOL bNoItem = TRUE;

			if ( (Shop->m_item[Pos].m_Type >= ITEMGET(14,0) && Shop->m_item[Pos].m_Type <= ITEMGET(14,8)) ||
				(Shop->m_item[Pos].m_Type >= ITEMGET(14,35) && Shop->m_item[Pos].m_Type <= ITEMGET(14,40)))
			{
				int dur = (int)Shop->m_item[Pos].m_Durability;

				if ( dur == 0 )
					dur = 1;

				if ( ::gObjSearchItem(lpObj, Shop->m_item[Pos].m_Type,dur, Shop->m_item[Pos].m_Level) == TRUE )
				{
					bNoItem = FALSE;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;


					::GCMoneySend(lpObj->m_Index, lpObj->Money);
				}
			}

			if ( bNoItem != FALSE )
			{
				pResult.Result = gObjShopBuyInventoryInsertItem(lpObj->m_Index, Shop->m_item[Pos]);

				if ( pResult.Result != 0xFF )
				{
					ItemByteConvert((LPBYTE)&pResult.ItemInfo, Shop->m_item[Pos]);
					int lc64 = Shop->m_item[Pos].m_BuyMoney;
					lpObj->Money -= iStoreTaxMoney;
					::g_CastleSiegeSync.AddTributeMoney(iStoreTaxMoney2);

					if ( lpObj->Money < 0 )
						lpObj->Money = 0;

					GCMoneySend(lpObj->m_Index, lpObj->Money);
					int iTaxRate = g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index);

					for (int i = 0; i < Type.size(); i++)
					{
						int type = ITEMGET(Type[i],Index[i]); 
						if ( type == Shop->m_item[Pos].m_Type && Dur[i] == Shop->m_item[Pos].m_Durability && Level[i] == Shop->m_item[Pos].m_Level && 
							Opt1[i] == Shop->m_item[Pos].m_Option1 && Opt2[i] == Shop->m_item[Pos].m_Option2 && Opt3[i] == Shop->m_item[Pos].m_Option3 )
						{
							Type[i] = -1;
							Index[i] = -1;
							Dur[i] = -1;
							Level[i] = -1;
							Opt1[i] = -1;
							Opt2[i] = -1;
							Opt3[i] = -1;
							break;
						}
					}

					Shop->m_item[Pos].Clear();

					Shop->SendItemDataLen -= 8;
					Shop->ItemCount -- ;
					Shop->RefreshShopItems();
					DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);


					LogAdd("[%s][%s] (%d) Shop buy [%d][%d][%d][%s] LEV:%d, DUR:%d, OP:[%d][%d][%d]",
						lpObj->AccountID, lpObj->Name, 14, lc64, iTaxRate, lc64+iStoreTaxMoney2, Shop->m_item[Pos].GetName(),
						Shop->m_item[Pos].m_Level, Shop->m_item[Pos].m_Durability,
						Shop->m_item[Pos].m_Option1, Shop->m_item[Pos].m_Option2,
						Shop->m_item[Pos].m_Option3);


					if ( Shop->ItemCount < 1 )
					{
						PMSG_TALKRESULT pResult;
						lpObj->TargetShopNumber = -1;
						lpObj->m_IfState.use = 0;
						lpObj->m_IfState.type = 0;
						lpObj->m_ShopTime = 0;
						pResult.h.c = 0xC3;
						pResult.h.headcode = 0x30;
						pResult.h.size = sizeof(pResult);
						pResult.result = -1;
						DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);

						/*if ( Random(0,1) != 0 )
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 119)), aIndex);//#info - ChatTargetSend - может что то интересненькое
						else
							ChatTargetSend(&gObj[DealerNumber], lMsg.Get(MSGGET(4, 120)), aIndex);*/

						return true;
					}
					else
					{
						lpObj->TargetShopNumber = 14;
						lpObj->m_IfState.use = 1;
						lpObj->m_IfState.type = 3;
						lpObj->m_ShopTime = 0;

						

						PMSG_SHOPITEMCOUNT pShopItemCount;
						BYTE SendByte[1024];
						int lOfs = 0;

						lOfs += sizeof(pShopItemCount );

						int size = lOfs + Shop->SendItemDataLen;
						PHeadSetW((LPBYTE)&pShopItemCount, 0x31, size);
						pShopItemCount.Type = 0;
						pShopItemCount.count = Shop->ItemCount;
						memcpy(SendByte, &pShopItemCount, sizeof(pShopItemCount));
						memcpy(&SendByte[lOfs], Shop->SendItemData, Shop->SendItemDataLen);

						DataSend(lpObj->m_Index, SendByte, size);
						GCAnsCsMapSvrTaxInfo(lpObj->m_Index,2,  ::g_CastleSiegeSync.GetTaxRateStore(lpObj->m_Index));

						return true;
					}

				}
			}
		}
	}

	return false;
}
Esempio n. 2
0
void CMagicDamage::Set(char* name, int skill, int damage,  int rlevel,  int mana,  int bp,  int dis, int Attr,  int iSkillType, unsigned char* ReqClass, int rEnergy, int rLeadership, int rdelay)
{
	if ( skill <0 || skill > MAX_SKILL -1 )
	{
		MsgBox("Limit error : (%s %d)", __FILE__, __LINE__);
		return;
	}

	if ( this->m_Damage[skill] != -1 )
	{
		MsgBox("Damage value is already set.(%s %d)", __FILE__, __LINE__);
		return;
	}

	strcpy_s(this->m_Name[skill], sizeof(this->m_Name[skill]), name);
	this->m_Damage[skill] = damage;
	this->m_rLevel[skill] = rlevel;
	this->m_Mana[skill] = mana;
	this->m_Distance[skill] = dis;
	this->m_RequireLeadership[skill] = rLeadership;
	this->m_Delay[skill] = rdelay;
	this->m_BrainPower[skill] = bp;
	this->m_Attr[skill] = Attr;
	this->m_iSkillType[skill] = iSkillType;
	memcpy(this->m_RequireClass[skill], ReqClass, sizeof(this->m_RequireClass[0]));
	this->m_RequireEnergy[skill] = (rEnergy * rlevel * 4) / 100 + 20;

	if ( skill == 13 ) // Blast
	{
		LogAdd("skill:%d", this->m_RequireEnergy[skill]);
	}

	// Set Level Requirements for Skills
	this->m_RequireLevel[skill] = 0;	// Required Level to use the skill

	if ( skill == 41 )	// Twisting Slash
	{
		this->m_RequireLevel[skill] = 80;
	}
	else if ( skill == 42 )	// Rageful Blow
	{
		this->m_RequireLevel[skill] = 170;
	}
	else if ( skill == 43 )	// Death Stab
	{
		this->m_RequireLevel[skill] = 160;
	}
	else if ( skill == 47 )	// Impale
	{
		this->m_RequireLevel[skill] = 28;
	}
	else if ( skill == 48 )	// Inner Strength
	{
		this->m_RequireLevel[skill] = 120;
	}
	else if ( skill == 52 )	
	{
		this->m_RequireLevel[skill] = 130;
	}

	if ( skill == 30 )
	{
		this->m_RequireEnergy[skill] = 30;
	}
	else if ( skill == 31 )
	{
		this->m_RequireEnergy[skill] = 60;
	}
	else if ( skill == 32 )
	{
		this->m_RequireEnergy[skill] = 90;
	}
	else if ( skill == 33 )
	{
		this->m_RequireEnergy[skill] = 130;
	}
	else if ( skill == 34 )
	{
		this->m_RequireEnergy[skill] = 170;
	}
	else if ( skill == 35 )
	{
		this->m_RequireEnergy[skill] = 210;
	}
	else if ( skill == 36 )
	{
		this->m_RequireEnergy[skill] = 300;
	}
	else if ( skill == 41 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 42 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 43 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 47 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 48 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 49  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 55  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 51  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 52  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 24  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 17 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 18 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 19 )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 20  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 21  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 22  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 23  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 25  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 56  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 60  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 44  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 45  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 46  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 57  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 73  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 74  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 67  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 68  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 69  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 70  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 71  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 72  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 76  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 77  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 78  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 79  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
	else if ( skill == 62  )
	{
		this->m_RequireEnergy[skill] = 0;
	}
}
Esempio n. 3
0
BOOL CCastleDeepEvent::Load(char * lpszFileName)
{	
	//DebugLog("%s START",__FUNCTION__);
	if( lpszFileName == NULL ) return FALSE;
		
	SMDFile = fopen(lpszFileName, "r");
	
	if ( SMDFile == FALSE )
	{
		MsgBox("[CastleDeep Event] Info file Load Fail [%s]", lpszFileName);
		
		//DebugLog("%s END",__FUNCTION__);
		return FALSE;
	}
	EnterCriticalSection(&this->m_critEventData);

	this->m_vtAssultType.clear();
	this->m_vtAssultTypeRate.clear();
	this->m_mapSpawnTime.clear();
	this->m_mapMonsterInfo.clear();
	this->m_vtEventTime.clear();
	this->m_vtAssultTypeRate.clear();
	this->m_mapRunCheck.clear();

	LeaveCriticalSection(&this->m_critEventData);

	this->m_bHasData = FALSE;
	int type = -1;
	SMDToken Token;

	while( true )
	{
		Token = GetToken();
		if( Token == 2 )
		{
			break;
		}

		if( Token == NUMBER )
		{
			while(true)
			{
				//Token = GetToken();
				type = TokenNumber;

				if( type == 0 )
				{
					while(true)
					{
						Token = GetToken();
					
						if( strcmp("end", TokenString) == 0 ) 
						{
							type++;
							break;
						}
					
						CASTLEDEEP_EVENTTIME m_EventTime;

						m_EventTime.m_iHour = TokenNumber; 
						Token = GetToken();
						m_EventTime.m_iMinute = TokenNumber;

						this->m_vtEventTime.push_back(m_EventTime);
					}
				}
				else if( type == 1 )
				{
					while(true)
					{
						std::vector<CASTLEDEEP_MONSTERINFO> vecMonsterInfo;
						std::vector<CASTLEDEEP_SPAWNTIME> vecEventSpawnTime;
						Token = GetToken();

						if( strcmp("end", TokenString) == 0 ) 
						{
							vecMonsterInfo.clear();
							vecEventSpawnTime.clear();
							type++;
							break;
						}
						CASTLEDEEP_SPAWNTIME	m_SpawnTime;

						m_SpawnTime.m_iMonsterGroup = TokenNumber;
						
						Token = GetToken();
						m_SpawnTime.m_iMonsterSpawnMinute = TokenNumber;

						this->m_mapMonsterInfo.insert( std::pair<int, std::vector<CASTLEDEEP_MONSTERINFO> >(m_SpawnTime.m_iMonsterGroup,vecMonsterInfo) );
						this->m_mapSpawnTime.insert( std::pair<int, std::vector<CASTLEDEEP_SPAWNTIME> >(m_SpawnTime.m_iMonsterGroup, vecEventSpawnTime ) );
					
						this->m_vtAssultType.push_back(m_SpawnTime.m_iMonsterGroup);
						this->m_vtAssultTypeRate.push_back(m_SpawnTime.m_iMonsterSpawnMinute);
					}
				}
				else if(type == 2)
				{
					while(true)
					{
						Token = GetToken();
						if( strcmp("end", TokenString) == 0 ) 
						{
							type++;
							break;
						}

						CASTLEDEEP_SPAWNTIME	m_SpawnTime;
						int m_iSpawnTimeIndex;

						m_iSpawnTimeIndex = TokenNumber;

						Token = GetToken();
						m_SpawnTime.m_iMonsterGroup = TokenNumber;

						Token = GetToken();
						m_SpawnTime.m_iMonsterSpawnMinute = TokenNumber;

						EnterCriticalSection(&this->m_critEventData);

						std::map<int, std::vector<CASTLEDEEP_SPAWNTIME> >::iterator it = this->m_mapSpawnTime.find(m_iSpawnTimeIndex);

						if( it != this->m_mapSpawnTime.end() )
						{
							it->second.push_back(m_SpawnTime);
						}
					
						LeaveCriticalSection(&this->m_critEventData);
					}
				}
				else if(type == 3)
				{
					while(true)
					{
						Token = GetToken();
						if( strcmp("end", TokenString) == 0 ) 
						{
							break;
						}

						CASTLEDEEP_MONSTERINFO	m_MonsterInfo;
						int m_iMonsterInfoIndex;

						m_iMonsterInfoIndex = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iMonsterGroup = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iMonsterType = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iMonsterNumber = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iSX = TokenNumber;
						
						Token = GetToken();
						m_MonsterInfo.m_iSY = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iDX = TokenNumber;

						Token = GetToken();
						m_MonsterInfo.m_iDY = TokenNumber;

						EnterCriticalSection(&this->m_critEventData);

						std::map<int, std::vector<CASTLEDEEP_MONSTERINFO> >::iterator it = this->m_mapMonsterInfo.find(m_iMonsterInfoIndex);
						if( it != this->m_mapMonsterInfo.end() )
						{
							it->second.push_back(m_MonsterInfo);
						}
					
						LeaveCriticalSection(&this->m_critEventData);
					}
				}
				break;
			}
		}
	}

	fclose(SMDFile);

	LogAdd("%s file load!",lpszFileName);

	this->m_bHasData = TRUE;

	//DebugLog("%s END",__FUNCTION__);
	return TRUE;
}
Esempio n. 4
0
BOOL RecvDataParse(LPPER_IO_CONTEXT	lpIOContext, int uIndex)
{
    if ( lpIOContext->nSentBytes < 3 )
    {
        return TRUE;
    }

    LPBYTE recvbuf;
    int lOfs = 0;
    int size = 0;
    BYTE headcode;
    BYTE xcode = 0;
    BYTE byDec[7024];

    recvbuf = (LPBYTE)lpIOContext->Buffer;

    while ( 1 )
    {
        if( recvbuf[lOfs] == 0xC1 ||
                recvbuf[lOfs] == 0xC3 )
        {
            PBMSG_HEAD* lphead = (PBMSG_HEAD*)(recvbuf+lOfs);
            size				= lphead->size;
            headcode			= lphead->headcode;
            xcode				= recvbuf[lOfs];
        }
        else if( recvbuf[lOfs] == 0xC2 ||
                 recvbuf[lOfs] == 0xC4 ) //
        {
            PWMSG_HEAD* lphead	= (PWMSG_HEAD*)(recvbuf+lOfs);
            size				= ((WORD)(lphead->sizeH)<<8);
            size			   |= (WORD)(lphead->sizeL);
            headcode			= lphead->headcode;
            xcode				= recvbuf[lOfs];
        }
        else  // 헤더가 맞지 않다면..
        {
            LogAdd("error-L1 : Header error (%s %d)lOfs:%d, size:%d",
                   __FILE__, __LINE__, lOfs,
                   lpIOContext->nSentBytes);
            lpIOContext->nSentBytes = 0;
            return FALSE;
        }
        if ( size <= 0 )
        {
            LogAdd("error-L1 : size %d",size);
            return FALSE;
        }

        if ( size <= lpIOContext->nSentBytes )
        {
            if ( xcode == 0xC3 )
            {
                int iSize = g_SimpleModulusCS.Decrypt( byDec+2,(recvbuf+lOfs+2), size-2);

                if ( iSize < 0 )
                {

                }
                else
                {
                    PBMSG_HEAD* lphead = (PBMSG_HEAD*)(byDec+1);
                    headcode		= lphead->headcode;
                    BYTE subhead	= byDec[2];
                    byDec[1]		= 0xC1;
                    byDec[2]		= ((BYTE)iSize)+2;

                    CStreamPacketEngine_Server PacketStream;

                    PacketStream.Clear();

                    if ( PacketStream.AddData(byDec+1, iSize+2) == 0 )
                    {
                        LogAddC(2, "error-L1 : CStreamPacketEngine Adding Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                                gObj[uIndex].Ip_addr,
                                gObj[uIndex].AccountID,
                                gObj[uIndex].Name,
                                headcode,
                                __FILE__, __LINE__,
                                gObj[uIndex].Connected);
                        return FALSE;
                    }

                    if ( PacketStream.ExtractPacket(byDec) != 0 )
                    {
                        LogAddC(2, "error-L1 : CStreamPacketEngine ExtractPacket Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                                gObj[uIndex].Ip_addr,
                                gObj[uIndex].AccountID,
                                gObj[uIndex].Name,
                                headcode,
                                __FILE__, __LINE__,
                                gObj[uIndex].Connected);
                        return FALSE;
                    }

                    if ( xcode == 0xC3 && headcode == 0xC5 )
                    {
                        LogAdd("암호패킷 : [0x%x]" , headcode);
                    }

                    if( IsHackTool(headcode, size, uIndex, xcode) == 1 )
                    {
                        return FALSE;
                    }
                    ProtocolCore(headcode, byDec, iSize, uIndex, 1, subhead);
                }
            }

            else if ( xcode == 0xC4 )
            {
                int iSize = g_SimpleModulusCS.Decrypt( byDec+3, (recvbuf+lOfs+3), size-3);
                if ( iSize < 0 )
                {

                }
                else
                {
                    BYTE* pDecBuf = byDec+1;
                    BYTE subhead	= byDec[3];
                    byDec[1]		= 0xC2;
                    WORD wsize		= ((WORD)iSize)+3;
                    byDec[2]		= SET_NUMBERH(wsize);
                    byDec[3]		= SET_NUMBERL(wsize);

                    CStreamPacketEngine_Server PacketStream;

                    PacketStream.Clear();
                    if ( PacketStream.AddData(byDec+1, iSize+3) == 0 )
                    {
                        LogAddC(2, "error-L1 : CStreamPacketEngine Adding Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                                gObj[uIndex].Ip_addr,
                                gObj[uIndex].AccountID,
                                gObj[uIndex].Name,
                                headcode,
                                __FILE__,
                                __LINE__,
                                gObj[uIndex].Connected);
                        return FALSE;
                    }

                    if ( PacketStream.ExtractPacket(byDec) != 0 )
                    {
                        LogAddC(2, "error-L1 : CStreamPacketEngine ExtractPacket Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                                gObj[uIndex].Ip_addr,
                                gObj[uIndex].AccountID,
                                gObj[uIndex].Name,
                                headcode,
                                __FILE__,
                                __LINE__,
                                gObj[uIndex].Connected);
                        return FALSE;
                    }

                    headcode = pDecBuf[2];

                    if ( xcode == 0xC4 && headcode == 0xC5 )
                    {
                        LogAdd("암호패킷 : [0x%x]" , headcode);
                    }
                    if( IsHackTool(headcode, size, uIndex, xcode) == TRUE )
                    {
                        return FALSE;
                    }
                    ProtocolCore(headcode, byDec, iSize, uIndex, 1, subhead);
                }
            }
            else
            {
                CStreamPacketEngine_Server ps;
                ps.Clear();

                if ( ps.AddData(recvbuf+lOfs, size) == 0 )
                {
                    LogAddC(2, "error-L1 : CStreamPacketEngine Adding Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                            gObj[uIndex].Ip_addr,
                            gObj[uIndex].AccountID,
                            gObj[uIndex].Name,
                            headcode,
                            __FILE__, __LINE__,
                            gObj[uIndex].Connected);
                    return FALSE;
                }

                if ( ps.ExtractPacket(byDec) != 0 )
                {
                    LogAddC(2, "error-L1 : CStreamPacketEngine ExtractPacket Error : ip = %s account:%s name:%s HEAD:%x (%s,%d) State:%d",
                            gObj[uIndex].Ip_addr,
                            gObj[uIndex].AccountID,
                            gObj[uIndex].Name,
                            headcode,
                            __FILE__, __LINE__,
                            gObj[uIndex].Connected);
                    return FALSE;
                }
                if( IsHackTool(headcode, size, uIndex, xcode) == TRUE )
                {
                    return FALSE;
                }
                ProtocolCore(headcode, byDec, size, uIndex, 0, -1);
            }

            lOfs += size;
            lpIOContext->nSentBytes  -= size;

            if ( lpIOContext->nSentBytes <= 0 )
            {
                break;
            }
        }
        else if ( lOfs > 0 )
        {
            if ( lpIOContext->nSentBytes < 1 )
            {
                LogAdd("error-L1 : recvbuflen 1 %s %d", __FILE__, __LINE__);
                break;
            }

            if ( lpIOContext->nSentBytes < MAX_IO_BUFFER_SIZE )
            {
                memcpy(recvbuf, &recvbuf[lOfs], lpIOContext->nSentBytes);
                LogAdd("Message copy %d", lpIOContext->nSentBytes);
                //break;
            }
            break;

        }
        else
        {
            break;
        }

    }

    return true;
}
Esempio n. 5
0
void CMagicDamage::LogSkillList(char* Buffer, int iSize)
{
	this->Init();
	CWzMemScript WzMemScript;

	WzMemScript.SetBuffer(Buffer, iSize);

	int Token;
	int n=0;
	int number;
	char name[50];
	int requireLevel;
	int damage;
	int mana;
	int bp=0;
	int dis;
	int rEnergy;
	int iSkillType;
	int rLeadership;
	int rDelay;
	int attr;
	int iSkillUseType;
	int iSkillBrand;
	int iKillCount;
	int RequireStatus[MAX_REQ_SKILL_STATUS] = {0};
	BYTE RequireClass[MAX_TYPE_PLAYER];

	while ( true )
	{
		Token = WzMemScript.GetToken();

		if ( Token == 2 )
		{
			break;
		}

		if ( Token == 1 )
		{
			number = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			strcpy_s(name, sizeof(name), WzMemScript.GetString() );

			Token = WzMemScript.GetToken();
			requireLevel = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			damage = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			mana = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			bp = (int)WzMemScript.GetNumber();	// Agility Gauge

			Token = WzMemScript.GetToken();
			dis = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			rDelay = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			rEnergy = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			rLeadership = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			attr = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			iSkillType = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			iSkillUseType = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			iSkillBrand = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			iKillCount = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireStatus[0] = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireStatus[1] = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireStatus[2] = (int)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireClass[0] = (BYTE)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireClass[1] = (BYTE)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireClass[2] = (BYTE)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireClass[3] = (BYTE)WzMemScript.GetNumber();

			Token = WzMemScript.GetToken();
			RequireClass[4] = (BYTE)WzMemScript.GetNumber();


			this->Set(name, number,damage, requireLevel, mana, bp, dis, attr, iSkillType, RequireClass, rEnergy, rLeadership, rDelay);
			this->SetEx(number, iSkillUseType, iSkillBrand, iKillCount, RequireStatus);
			DefMagicInf[number].Set(number, 0);
		}
	}

	LogAdd("(%s) Skill information data load complete", "Skill");
}
Esempio n. 6
0
BOOL CCrywolf::LoadData(LPSTR lpszFileName)
{
	this->m_bFileDataLoad = FALSE;

	if ( !lpszFileName || !strcmp(lpszFileName, "") )
	{
		MsgBox("[Crywolf Main Job] - File load error : File Name Error");
		return FALSE;
	}

	try
	{
		SMDToken Token;
		if (fopen_s(&SMDFile,lpszFileName, "r") != 0 )
		{
			MsgBox("[Crywolf Main Job] - Can't Open %s ", lpszFileName);
			return FALSE;
		}

		this->DelAllData();
		int iType = -1;

		while ( true )
		{
			Token = GetToken();

			if ( Token == END )
				break;

			iType = (int)TokenNumber;

			while ( true )
			{
				if ( iType == 0 )
				{
					int iScheduleMode = 0;
					int iStateNumber = -1;
					int iMonth = -1;
					int iDay = -1;
					int iDayOfWeek = -1;
					int iHour = -1;
					int iMinute = -1;
					int iContinuanceTime = 0;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					iScheduleMode = (int)TokenNumber;

					Token = GetToken();
					iStateNumber = (int)TokenNumber;

					Token = GetToken();
					iMonth = (int)TokenNumber;

					Token = GetToken();
					iDay = (int)TokenNumber;

					Token = GetToken();
					iDayOfWeek = (int)TokenNumber;

					Token = GetToken();
					iHour = (int)TokenNumber;

					Token = GetToken();
					iMinute = (int)TokenNumber;

					Token = GetToken();
					iContinuanceTime = (int)TokenNumber;

					/*if ( this->m_StartTimeInfoCount <= -1 || this->m_StartTimeInfoCount >= MAX_CRYWOLF_STATE_TIME )
					{
						MsgBox("[Crywolf Main Job] - Excced MAX StartTime (%d)", this->m_StartTimeInfoCount);
					}*/
					CCrywolfStateTimeInfo Info;
					Info.m_iStateNumber = iStateNumber;
					Info.m_iMonth = iMonth;
					Info.m_iDay = iDay;
					Info.m_iDayOfWeek = iDayOfWeek;
					Info.m_iHour = iHour;
					Info.m_iMinute = iMinute;
					Info.m_iContinuanceTime = iContinuanceTime;
					Info.m_bUsed = TRUE;

					this->m_StartTimeInfo.push_back(Info);


					this->m_iScheduleMode = iScheduleMode;
					/*this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iStateNumber = iStateNumber;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iMonth = iMonth;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iDay = iDay;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iDayOfWeek = iDayOfWeek;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iHour = iHour;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iMinute = iMinute;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_iContinuanceTime = iContinuanceTime;
					this->m_StartTimeInfo[this->m_StartTimeInfoCount].m_bUsed = TRUE;
					this->m_StartTimeInfoCount++;*/
				}

				if ( iType == 1 )
				{
					int iStateNumber = -1;
					int iHour = 0;
					int iMinute = 0;
					int iSecond = 0;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					iStateNumber = (int)TokenNumber;
					
					Token = GetToken();
					iHour = (int)TokenNumber;

					Token = GetToken();
					iMinute = (int)TokenNumber;

					Token = GetToken();
					iSecond = (int)TokenNumber;

					this->m_StateTimeInfo[iStateNumber].m_iStateNumber = iStateNumber;
					this->m_StateTimeInfo[iStateNumber].m_iHour = iHour;
					this->m_StateTimeInfo[iStateNumber].m_iMinute = iMinute;
					this->m_StateTimeInfo[iStateNumber].m_iSecond = iSecond;
					this->m_StateTimeInfo[iStateNumber].m_iContinuanceTime = iHour * 60 * 60 * 1000 + iMinute * 60 * 1000 + iSecond * 1000;
					this->m_StateTimeInfo[iStateNumber].m_bUsed = TRUE;
				}

				if ( iType == 2 )
				{
					int iGroupNumber = -1;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					iGroupNumber = (int)TokenNumber;

					if ( iGroupNumber <= -1 || iGroupNumber >= MAX_CRYWOLF_MONSTER_GROUP )	
					{
						MsgBox("[Crywolf Main Job] - Invalid Monster Group Number (%d)", iGroupNumber);
					}

					this->m_iMonsterGroupNumberArray[this->m_iMonsterGroupNumberCount] = iGroupNumber;
					this->m_iMonsterGroupNumberCount++;
				}

				if ( iType == 3 )
				{
					int iGroupNumber = -1;
					int iTurnUpTime = 0;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					iGroupNumber = (int)TokenNumber;
					
					Token = GetToken();
					iTurnUpTime = (int)TokenNumber;

					if ( iGroupNumber <= -1 || iGroupNumber >= MAX_CRYWOLF_MONSTER_GROUP )	
					{
						MsgBox("[Crywolf Main Job] - Invalid Monster Boss Group Number (%d)", iGroupNumber);
					}

					this->m_iBossGroupNumber = iGroupNumber;
					this->m_iBossTurnUpTime = iTurnUpTime;
				}

				if ( iType == 4 )
				{
					int iChangeAITime = 0;

					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					iChangeAITime = (int)TokenNumber;
					this->m_iMonsterGroupChangeAITime = iChangeAITime;
				}

				if ( iType == 5 )
				{
					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					this->m_iMVPScoreTable[0] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[1] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[2] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[3] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[4] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[5] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPScoreTable[6] = (int)TokenNumber;
				}

				if ( iType == 6 )
				{
					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					this->m_iMVPRankScoreTable[0] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankScoreTable[1] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankScoreTable[2] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankScoreTable[3] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankScoreTable[4] = (int)TokenNumber;
				}

				if ( iType == 7 )
				{
					Token = GetToken();

					if ( !strcmp("end", TokenString))
						break;

					this->m_iMVPRankExpTable[0] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankExpTable[1] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankExpTable[2] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankExpTable[3] = (int)TokenNumber;

					Token = GetToken();
					this->m_iMVPRankExpTable[4] = (int)TokenNumber;
				}
			}	// while ( true )
		}	// while ( true )

		fclose(SMDFile);
		LogAdd( "[Crywolf Main Job] - %s file is Loaded", lpszFileName);
		this->m_bFileDataLoad = TRUE;
	}	// __try
	catch ( DWORD )
	{
		MsgBox("[Crywolf Main Job] - Loading Exception Error (%s) File. ", lpszFileName);
	}

	return this->m_bFileDataLoad;
}
Esempio n. 7
0
DWORD WINAPI IocpServerWorker(LPVOID p)
{
    SYSTEM_INFO SystemInfo;
    DWORD ThreadID;
    SOCKET Accept;
    int nRet;
    int ClientIndex;
    SOCKADDR_IN cAddr;
    IN_ADDR		cInAddr;
    int			cAddrlen = sizeof( cAddr );
    LPPER_SOCKET_CONTEXT lpPerSocketContext = NULL;
    DWORD RecvBytes;
    DWORD Flags=0;

    InitializeCriticalSection(&criti);
    GetSystemInfo(&SystemInfo);

    g_dwThreadCount = SystemInfo.dwNumberOfProcessors * 2;
    __try
    {

        g_CompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
        if ( g_CompletionPort == NULL)
        {
            LogAdd("CreateIoCompletionPort failed with error: %d", GetLastError());
            __leave;
        }

        for(DWORD dwCPU = 0; dwCPU < g_dwThreadCount; dwCPU++)
        {
            HANDLE ThreadHandle;
            // Create a server worker thread and pass the completion port to the thread.

            ThreadHandle = CreateThread(NULL, 0, ServerWorkerThread, g_CompletionPort, 0, &ThreadID);
            if ( ThreadHandle == NULL)
            {
                LogAdd("CreateThread() failed with error %d", GetLastError());
                __leave;
            }
            g_ThreadHandles[dwCPU] = ThreadHandle;
            CloseHandle(ThreadHandle);

        }

        if (!CreateListenSocket() )
            __leave;


        while(TRUE)
        {
            Accept = WSAAccept(g_Listen, (LPSOCKADDR)&cAddr, &cAddrlen, NULL, 0);
            if (Accept==SOCKET_ERROR)
            {
                EnterCriticalSection(&criti);
                LogAdd("WSAAccept() failed with error %d", WSAGetLastError());
                LeaveCriticalSection(&criti);
                continue;
            }
            EnterCriticalSection(&criti);

            memcpy( &cInAddr, &cAddr.sin_addr.s_addr, 4 );

            ClientIndex = gObjAddSearch(Accept, inet_ntoa(cInAddr) );

            if ( ClientIndex == -1 )
            {
                LogAddL("error-L2 : ClientIndex = -1");
                closesocket(Accept);
                LeaveCriticalSection(&criti);
                continue;
            }

            if (UpdateCompletionPort(Accept, ClientIndex, 1) == 0 )
            {
                LogAddL("error-L1 : %d %d CreateIoCompletionPort failed with error %d", Accept, ClientIndex, GetLastError() );
                closesocket(Accept);
                LeaveCriticalSection(&criti);
                continue;
            }

            if (gObjAdd(Accept, inet_ntoa(cInAddr), ClientIndex) == -1 )
            {
                LogAddL("error-L1 : %d %d gObjAdd() failed with error %d", Accept, ClientIndex, GetLastError() );
                LeaveCriticalSection(&criti);
                closesocket(Accept);
                continue;
            }

            memset(&gObj[ClientIndex].PerSocketContext->IOContext[0].Overlapped, 0, sizeof(OVERLAPPED));
            memset(&gObj[ClientIndex].PerSocketContext->IOContext[1].Overlapped, 0, sizeof(OVERLAPPED));
            gObj[ClientIndex].PerSocketContext->IOContext[0].wsabuf.buf = gObj[ClientIndex].PerSocketContext->IOContext[0].Buffer;
            gObj[ClientIndex].PerSocketContext->IOContext[0].wsabuf.len = MAX_IO_BUFFER_SIZE;
            gObj[ClientIndex].PerSocketContext->IOContext[0].nTotalBytes = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[0].nSentBytes = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[0].nWaitIO    = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[0].nSecondOfs = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[0].IOOperation = RECV_IO;

            gObj[ClientIndex].PerSocketContext->IOContext[1].wsabuf.buf = gObj[ClientIndex].PerSocketContext->IOContext[0].Buffer;
            gObj[ClientIndex].PerSocketContext->IOContext[1].wsabuf.len = MAX_IO_BUFFER_SIZE;
            gObj[ClientIndex].PerSocketContext->IOContext[1].nTotalBytes= 0;
            gObj[ClientIndex].PerSocketContext->IOContext[1].nSentBytes = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[1].nWaitIO    = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[1].nSecondOfs = 0;
            gObj[ClientIndex].PerSocketContext->IOContext[1].IOOperation = SEND_IO;
            gObj[ClientIndex].PerSocketContext->m_socket = Accept;
            gObj[ClientIndex].PerSocketContext->nIndex   = ClientIndex;

            nRet = WSARecv(Accept, &(gObj[ClientIndex].PerSocketContext->IOContext[0].wsabuf), 1, &RecvBytes, &Flags,
                           &(gObj[ClientIndex].PerSocketContext->IOContext[0].Overlapped), NULL);

            if( nRet == SOCKET_ERROR && WSAGetLastError() != ERROR_IO_PENDING )
            {
                LogAdd("error-L1 : WSARecv() failed with error %d", WSAGetLastError());
                gObj[ClientIndex].PerSocketContext->IOContext[0].nWaitIO = 4;
                CloseClient(gObj[ClientIndex].PerSocketContext, FALSE);
                LeaveCriticalSection(&criti);
                continue;
            }

            gObj[ClientIndex].PerSocketContext->IOContext[0].nWaitIO = 1;
            gObj[ClientIndex].PerSocketContext->dwIOCount++;

            LeaveCriticalSection(&criti);
            SCPJoinResultSend(ClientIndex, 1);

        }
    }
    __finally
    {
        if( g_CompletionPort )
        {
            for (DWORD i = 0; i < g_dwThreadCount; i++)
                PostQueuedCompletionStatus(g_CompletionPort, 0, 0, NULL);
        }
        if( g_CompletionPort )
        {
            CloseHandle(g_CompletionPort);
            g_CompletionPort = NULL;
        }
        if (g_Listen != INVALID_SOCKET)
        {
            closesocket(g_Listen);
            g_Listen = INVALID_SOCKET;
        }
    }
    return TRUE;
}
Esempio n. 8
0
int CKanturu::CheckEnterKanturu(int iUserIndex)
{
	if ( !gObjIsConnected(iUserIndex) )
		return -1;

	if ( gObj[iUserIndex].MapNumber != MAP_INDEX_KANTURU2 ) 
	{
		LogAdd("[ KANTURU ][ Entrance Fail ] Invalid Map Number(%d) [%s][%s] State(%d)",
			gObj[iUserIndex].MapNumber, gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
			this->GetKanturuState());

		return 4;
	}

	if ( this->GetKanturuState() == KANTURU_STATE_BATTLE_OF_MAYA &&
		 this->m_BattleOfMaya.GetEntrancePermit() == TRUE)
	{
		if ( g_KanturuBattleUserMng.IsOverMaxUser() == TRUE )
		{
			LogAdd("[ KANTURU ][ Entrance Fail ] Over Max User [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 1;
		}

		if ( this->CheckEqipmentMoonStone(iUserIndex) == FALSE )
		{
			LogAdd("[ KANTURU ][ Entrance Fail ] Moon Stone is not exist [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 2;
		}

		if ( (gObj[iUserIndex].pInventory[7].m_Type < ITEMGET(12,0) || gObj[iUserIndex].pInventory[7].m_Type > ITEMGET(12,6) ) && gObj[iUserIndex].pInventory[7].m_Type < ITEMGET(12,36) &&
			 gObj[iUserIndex].pInventory[7].m_Type != ITEMGET(13,30) &&
			 gObj[iUserIndex].pInventory[8].m_Type != ITEMGET(13,3)  &&
			 gObj[iUserIndex].pInventory[8].m_Type != ITEMGET(13,37) )
		{
			LogAdd("[ KANTURU ][ Entrance Fail ] Wing Item is not exist [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 7;
		}

		if ( gObj[iUserIndex].pInventory[8].m_Type == ITEMGET(13,2) )
		{
			LogAdd("[ KANTURU ][ Entrance Fail ] Uniria Item is exist [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 5;
		}

		if ( gObj[iUserIndex].pInventory[11].m_Type == ITEMGET(13,10) ||
			gObj[iUserIndex].pInventory[10].m_Type == ITEMGET(13,10) )
		{
			LogAdd("[ KANTURU ][ Entrance Fail ] Trasportation Ring is exist [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 6;
		}


        if ( gObj[iUserIndex].pInventory[11].m_Type == ITEMGET(13,40) ||
                gObj[iUserIndex].pInventory[10].m_Type == ITEMGET(13,40) )
        {
                LogAdd("[ Kanturu ][ Entrance Fail ] Jack'O Lantern Polymorph Ring is exist [%s][%s] State(%d)-(%d)",
                        gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
                        this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

                return 6;
        }

        if ( gObj[iUserIndex].pInventory[11].m_Type == ITEMGET(13,41) ||
                gObj[iUserIndex].pInventory[10].m_Type == ITEMGET(13,41) )
        {
                LogAdd("[ Kanturu ][ Entrance Fail ] Santa Polymorph Ring is exist [%s][%s] State(%d)-(%d)",
                        gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
                        this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

                return 6;
        }


		if ( gObj[iUserIndex].pInventory[11].m_Type == ITEMGET(13,39) ||
			gObj[iUserIndex].pInventory[10].m_Type == ITEMGET(13,39) )
		{
			LogAdd("[ Kanturu ][ Entrance Fail ] EliteSkelletoneChangeRing is exist [%s][%s] State(%d)-(%d)",
				gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
				this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

			return 6;
		}

		LogAdd("[ KANTURU ][ Entrance Success ] [%s][%s] State(%d)-(%d)",
			gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
			this->GetKanturuState(), this->m_BattleOfMaya.GetBattleOfMayaState());

		return 0;
	}

	if ( this->GetKanturuState() == KANTURU_STATE_TOWER_OF_REFINEMENT &&
		 this->m_TowerOfRefinement.GetEntrancePermit() == TRUE )
	{
		LogAdd("[ KANTURU ][ Entrance Success ] [%s][%s] State(%d)-(%d)",
			gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
			this->GetKanturuState(), this->m_TowerOfRefinement.GetTowerOfRefinementState());

		return 0;
	}

	LogAdd("[ KANTURU ][ Entrance Fail ] [%s][%s] State(%d)",
		gObj[iUserIndex].AccountID, gObj[iUserIndex].Name,
		this->GetKanturuState());

	return 3;
}
bool CEventManagement::Load(LPSTR lpszFileName)
{
    this->m_bHasData = false;
    this->Clear();

    SMDFile = fopen(lpszFileName, "r");

    if ( SMDFile == NULL )
    {
        MsgBox("[DOTH] Info file Load Fail [%s]", lpszFileName);

        return false;
    }

    int Token;
    int type = -1;

    while ( true )
    {
        Token = GetToken();

        if ( Token == 2 )
        {
            break;
        }

        type = TokenNumber;

        while ( true )
        {
            if ( type == 0 )
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                EVENT_ID_TIME EIT;

                EIT.m_eEventKind = TokenNumber;

                Token = GetToken();
                EIT.m_iHour = TokenNumber;

                Token = GetToken();
                EIT.m_iMinute = TokenNumber;

                EIT.m_bEventStarted = false;

                this->m_vtEventTime.push_back(EIT);
            }
        }
    }

    fclose(SMDFile);
    LogAdd("[DOTH] %s file load!", lpszFileName);

    this->m_bHasData = true;

    return true;
}
Esempio n. 10
0
void CKanturu::SetState_END()
{
	LogAdd( "[ KANTURU ] State(%d) -> END", this->m_iKanturuState);
	this->SetKanturuState(KANTURU_STATE_END);
	g_KanturuBattleUserMng.ResetAllData();
}
Esempio n. 11
0
BOOL CKanturu::LoadData(LPSTR lpszFileName)
{
	this->m_bFileDataLoad = FALSE;

	if ( !lpszFileName || !strcmp(lpszFileName, ""))
	{
		MsgBox("[ KANTURU ] - File load error : File Name Error");
		return FALSE;
	}

	try
	{

		if (fopen_s(&SMDFile,lpszFileName, "r") !=0 )
		{
			DWORD dwError = GetLastError();
			MsgBox("[ KANTURU ] - Can't Open %s ", lpszFileName);
			return FALSE;
		}

		this->ResetAllData();

		enum SMDToken Token;
		int iType = -1;
		int iState = 0;
		int iCondition = 0;
		int iValue = 0;

		while ( true )
		{
			Token = (SMDToken)GetToken();
			
			if ( Token ==  END )
				break;
			
			iType = (int)TokenNumber;

			while ( true )
			{
				if ( iType == 0 )
				{
					iState = 0;
					iCondition = 0;
					iValue = 0;

					Token = (SMDToken)GetToken();
					
					if ( !strcmp("end", TokenString))
						break;

					iState = (int)TokenNumber;

					Token = (SMDToken)GetToken();
					iCondition = (int)TokenNumber;

					Token = (SMDToken)GetToken();
					iValue = (int)TokenNumber;

					if ( this->m_StateInfoCount < 0 || this->m_StateInfoCount >= MAX_KANTURU_STATE_INFO )
					{
						MsgBox("[ KANTURU ] - Exceed Max State Time (%d)", this->m_StateInfoCount);
						break;
					}

					this->m_StateInfo[this->m_StateInfoCount].SetStateInfo(iState);
					this->m_StateInfo[this->m_StateInfoCount].SetCondition(iCondition);

					if ( iCondition == 1 )
						iValue *= 1000;

					this->m_StateInfo[this->m_StateInfoCount].SetValue(iValue);

					this->m_StateInfoCount++;
				}
				else if ( iType == 10 )
				{
					BOOL bEnableCheckMoonStone = FALSE;

					Token = (SMDToken)GetToken();
					
					if ( !strcmp("end", TokenString))
						break;

					bEnableCheckMoonStone = (BOOL)TokenNumber;
					this->SetEnableCheckMoonStone(bEnableCheckMoonStone);
				}
				else
				{
					Token = (SMDToken)GetToken();
					
					if ( !strcmp("end", TokenString))
						break;
				}
			}
		}

		fclose(SMDFile);
		LogAdd( "[ KANTURU ] - %s file is Loaded", lpszFileName);
		
		this->m_bFileDataLoad = TRUE;

		// Load Other Resources from Kanturu.dat
		this->m_BattleStanby.LoadData(gDirPath.GetNewPath("Kanturu.dat"));
		this->m_BattleOfMaya.LoadData(gDirPath.GetNewPath("Kanturu.dat"));
		this->m_BattleOfNightmare.LoadData(gDirPath.GetNewPath("Kanturu.dat"));
		this->m_TowerOfRefinement.LoadData(gDirPath.GetNewPath("Kanturu.dat"));
	}
	catch ( DWORD )
	{
		MsgBox("[ KANTURU ] - Loading Exception Error (%s) File. ", lpszFileName);
	}

	return this->m_bFileDataLoad;
}
Esempio n. 12
0
void CKanturu::SetState_BATTLE_OF_NIGHTMARE()
{
	LogAdd( "[ KANTURU ] State(%d) -> BATTLE_OF_NIGHTMARE", this->m_iKanturuState);
	this->SetKanturuState(KANTURU_STATE_BATTLE_OF_NIGHTMARE);
	this->m_BattleOfNightmare.SetState(1);
}
Esempio n. 13
0
void CKanturu::SetState_BATTLE_OF_MAYA()
{
	LogAdd( "[ KANTURU ] State(%d) -> BATTLE_OF_MAYA", this->m_iKanturuState);
	this->SetKanturuState(KANTURU_STATE_BATTLE_OF_MAYA);
	this->m_BattleOfMaya.SetState(1);
}
Esempio n. 14
0
void CKanturu::SetState_NONE()
{
	LogAdd( "[ KANTURU ] State(%d) -> NONE", this->m_iKanturuState);
	this->SetKanturuState(KANTURU_STATE_NONE);
}
Esempio n. 15
0
void CItemBag::LoadItem(char* script_file)
{
    SMDFile = fopen(script_file, "r");

    if ( SMDFile == NULL )
    {
        LogAdd(lMsg.Get(MSGGET(1, 197)), script_file);
        return ;
    }

    int Token;
    int n = 0;

    while ( true )
    {
        Token = GetToken();

        if ( Token == 2 )
        {
            break;
        }

        if ( Token == 1 )
        {
            n = this->BagObjectCount;

            this->BagObject[n].m_type = TokenNumber;

            Token = GetToken();
            this->BagObject[n].m_index = TokenNumber;

            Token = GetToken();
            this->BagObject[n].m_level = TokenNumber;

            Token = GetToken();
            this->BagObject[n].m_op1 = TokenNumber;

            Token = GetToken();
            this->BagObject[n].m_op2 = TokenNumber;

            Token = GetToken();
            this->BagObject[n].m_op3 = TokenNumber;

            if ( this->BagObject[n].m_op2 != 0 )
            {
                this->BagExItemCount++;
            }
            else
            {
                this->BagNormalItemCount++;
            }

            this->BagObjectCount++;

            if ( this->BagObjectCount > MAX_ITEMBAG_ATTR-1 )
            {
                break;
            }
        }
    }

    fclose(SMDFile);

    LogAdd(lMsg.Get(MSGGET(1, 198)), script_file);
}
Esempio n. 16
0
BOOL CQuestInfo::LoadQuestInfo(char* Buffer, int iSize)
{

	CWzMemScript WzMemScript;
	int Token;
	int n;

	WzMemScript.SetBuffer(Buffer, iSize);
	this->Init();

	n = 0;

	while ( true )
	{
		Token = WzMemScript.GetToken();

		if ( Token == 2 )
		{
			break;
		}
		else
		{
			if ( Token == 1 )
			{
				int Type = WzMemScript.GetNumber();

				if ( Type == 0 )
				{
					Token = WzMemScript.GetToken();
					auto int iQuestIndex = WzMemScript.GetNumber();
					this->QuestInfo[iQuestIndex].QuestIndex = iQuestIndex;

					Token = WzMemScript.GetToken();
					this->QuestInfo[iQuestIndex].QuestStartType = WzMemScript.GetNumber();

					Token = WzMemScript.GetToken();
					this->QuestInfo[iQuestIndex].QuestStartSubType = WzMemScript.GetNumber();

					Token = WzMemScript.GetToken();
					strcpy( this->QuestInfo[iQuestIndex].Name, WzMemScript.GetString());

					this->QuestInfo[iQuestIndex].QuestSubInfoCount = 0;

					while ( true )
					{
						int iSubInfoCount = this->QuestInfo[iQuestIndex].QuestSubInfoCount;

						Token = WzMemScript.GetToken();

						if ( Token == 0 )
						{
							if ( strcmp("end", WzMemScript.GetString()) == 0 )
							{
								break;
							}
						}
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].QuestType = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedType = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedSubType = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ItemLevel = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedNumber = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedTargetMinLevel = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedTargetMaxLevel = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedDropRate = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardType = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardSubType = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardCount = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].LinkConditionIndex = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextBeforeReg = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextAfterReg = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextCompleteQuest = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextQuestClear = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[0] = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[1] = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[2] = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[3] = WzMemScript.GetNumber();

						Token = WzMemScript.GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[4] = WzMemScript.GetNumber();

						this->QuestInfo[iQuestIndex].QuestSubInfoCount++;

					
					}
					
					LogAdd("[Quest] (%s) Load : Index %d, SubInfoCount %d",
						this->QuestInfo[iQuestIndex].Name, iQuestIndex,
						this->QuestInfo[iQuestIndex].QuestSubInfoCount );
						this->m_QuestCount++;
				}
				else if ( Type == 1 )
				{
					Token = WzMemScript.GetToken();
					auto int iQuestIndex = WzMemScript.GetNumber();

					while ( true )
					{
						auto int iFailInfoCount = this->QuestInfo[iQuestIndex].QuestConditionCount;
						Token = WzMemScript.GetToken();

						if ( Token == 0 )
						{
							if ( strcmp("end", WzMemScript.GetString()) == 0 )
							{
								break;
							}
						}	
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].Index = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].NeedQuestIndex = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].MinLevel = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].MaxLevel = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].ReqStr = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].NeedZen = WzMemScript.GetNumber();

							Token = WzMemScript.GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].StartContext = WzMemScript.GetNumber();

							this->QuestInfo[iQuestIndex].QuestConditionCount++;
						
					}
				}
				else
				{
					MsgBox("Quest Info Read Fail");
					fclose(SMDFile);
					return false;
				}
			}
		}
	}

	this->InitQuestItem();
	return true;
}
Esempio n. 17
0
void CMagicDamage::LogSkillList(char * filename)
{
	this->Init();


	SMDFile = fopen(filename, "r");

	if ( SMDFile == NULL )
	{
		MsgBox(lMsg.Get(MSGGET(1, 199)), filename);
		return;
	}

	int Token;
	int n=0;
	int number;
	char name[50];
	int requireLevel;
	int damage;
	int mana;
	int bp=0;
	int dis;
	int rEnergy;
	int iSkillType;
	int rLeadership;
	int rDelay;
	int attr;
	int iSkillUseType;
	int iSkillBrand;
	int iKillCount;
	int RequireStatus[MAX_REQ_SKILL_STATUS] = {0};
	BYTE RequireClass[MAX_TYPE_PLAYER];
	short nSkillRank;
	short nSkillGroup;
	short nRequireMLPoint;
	short nHP;
	short nSD;
	WORD wKeepTime;
	short nRequireStr;
	short nRequireDex;
	BYTE btIconNum;
	int nSkillType;
	BYTE btItemSkill;
	BYTE btIsDamage;

	while ( true )
	{
		Token = GetToken();

		if ( Token == 2 )
		{
			break;
		}

		if ( Token == 1 )
		{
			number = (int)TokenNumber;

			Token = GetToken();
			strcpy_s(name, sizeof(name), TokenString);

			Token = GetToken();
			requireLevel = (int)TokenNumber;

			Token = GetToken();
			damage = (int)TokenNumber;

			Token = GetToken();
			mana = (int)TokenNumber;

			Token = GetToken();
			bp = (int)TokenNumber;	// Agility Gauge

			Token = GetToken();
			dis = (int)TokenNumber;

			Token = GetToken();
			rDelay = (int)TokenNumber;

			Token = GetToken();
			rEnergy = (int)TokenNumber;

			Token = GetToken();
			rLeadership = (int)TokenNumber;

			Token = GetToken();
			attr = (int)TokenNumber;

			Token = GetToken();
			iSkillType = (int)TokenNumber;

			Token = GetToken();
			iSkillUseType = (int)TokenNumber;

			Token = GetToken();
			iSkillBrand = (int)TokenNumber;

			Token = GetToken();
			iKillCount = (int)TokenNumber;
			/*
			CLASS_WIZARD = 0x0,
  CLASS_KNIGHT = 0x1,
  CLASS_ELF = 0x2,
  CLASS_MAGUMSA = 0x3,
  CLASS_DARKLORD = 0x4,
  CLASS_SUMMONER = 0x5,
  CLASS_FIGHTER = 0x6,*/
			Token = GetToken();
			RequireStatus[0] = (int)TokenNumber;

			Token = GetToken();
			RequireStatus[1] = (int)TokenNumber;

			Token = GetToken();
			RequireStatus[2] = (int)TokenNumber;

			Token = GetToken();
			RequireClass[0] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[1] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[2] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[3] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[4] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[5] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[6] = (BYTE)TokenNumber;

			Token = GetToken();
			nSkillRank = (WORD)TokenNumber;

			Token = GetToken();
			nSkillGroup = (WORD)TokenNumber;

			Token = GetToken();
			nRequireMLPoint = (WORD)TokenNumber;

			Token = GetToken();
			nHP = (WORD)TokenNumber;

			Token = GetToken();
			nSD = (WORD)TokenNumber;

			Token = GetToken();
			wKeepTime = (WORD)TokenNumber;

			Token = GetToken();
			nRequireStr = (WORD)TokenNumber;

			Token = GetToken();
			nRequireDex = (WORD)TokenNumber;

			Token = GetToken();
			btIconNum = (BYTE)TokenNumber;

			Token = GetToken();
			nSkillType = TokenNumber;

			Token = GetToken();
			btItemSkill = (BYTE)TokenNumber;

			Token = GetToken();
			btIsDamage = (BYTE)TokenNumber;

			this->Set(name, number,damage, requireLevel, mana, bp, dis, attr, iSkillType, RequireClass, rEnergy, rLeadership, rDelay, btItemSkill, btIsDamage );
			this->SetEx(number, iSkillUseType, iSkillBrand, iKillCount, RequireStatus);
			this->SetMasterLevelSkillInfo(number,nSkillRank,nSkillGroup,nRequireMLPoint,nHP,nSD,wKeepTime,nRequireStr,nRequireDex);
			DefMagicInf[number].Set(number, 0);
		}
	}

	fclose(SMDFile);
	LogAdd(lMsg.Get(MSGGET(1, 200)), filename);
}
Esempio n. 18
0
BOOL CQuestInfo::LoadQuestInfo(char * filename)
{
	int Token;
	int n;

	SMDFile = fopen(filename, "r");

	if ( SMDFile == NULL )
	{
		MsgBox("load error %s", filename);
		return false;
	}

	this->Init();

	n = 0;

	while ( true )
	{
		Token = GetToken();

		if ( Token == 2 )
		{
			break;
		}
		else
		{
			if ( Token == 1 )
			{
				int Type = TokenNumber;

				if ( Type == 0 )
				{
					Token = GetToken();
					auto int iQuestIndex = TokenNumber;
					this->QuestInfo[iQuestIndex].QuestIndex = iQuestIndex;

					Token = GetToken();
					this->QuestInfo[iQuestIndex].QuestStartType = TokenNumber;

					Token = GetToken();
					this->QuestInfo[iQuestIndex].QuestStartSubType = TokenNumber;

					Token = GetToken();
					strcpy( this->QuestInfo[iQuestIndex].Name, TokenString);

					this->QuestInfo[iQuestIndex].QuestSubInfoCount = 0;

					while ( true )
					{
						int iSubInfoCount = this->QuestInfo[iQuestIndex].QuestSubInfoCount;

						Token = GetToken();

						if ( Token == 0 )
						{
							if ( strcmp("end", TokenString) == 0 )
							{
								break;
							}
						}
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].QuestType = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedType = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedSubType = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ItemLevel = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedNumber = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedTargetMinLevel = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedTargetMaxLevel = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].NeedDropRate = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardType = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardSubType = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RewardCount = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].LinkConditionIndex = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextBeforeReg = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextAfterReg = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextCompleteQuest = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].ContextQuestClear = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[0] = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[1] = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[2] = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[3] = TokenNumber;

						Token = GetToken();
						this->QuestInfo[iQuestIndex].QuestSubInfo[iSubInfoCount].RequireClass[4] = TokenNumber;

						this->QuestInfo[iQuestIndex].QuestSubInfoCount++;

					
					}
					
					LogAdd("[Quest] (%s) Load : Index %d, SubInfoCount %d",
						this->QuestInfo[iQuestIndex].Name, iQuestIndex,
						this->QuestInfo[iQuestIndex].QuestSubInfoCount );
						this->m_QuestCount++;
				}
				else if ( Type == 1 )
				{
					Token = GetToken();
					auto int iQuestIndex = TokenNumber;

					while ( true )
					{
						auto int iFailInfoCount = this->QuestInfo[iQuestIndex].QuestConditionCount;
						Token = GetToken();

						if ( Token == 0 )
						{
							if ( strcmp("end", TokenString) == 0 )
							{
								break;
							}
						}
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].Index = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].NeedQuestIndex = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].MinLevel = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].MaxLevel = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].ReqStr = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].NeedZen = TokenNumber;

							Token = GetToken();
							this->QuestInfo[iQuestIndex].QuestCondition[iFailInfoCount].StartContext = TokenNumber;

							this->QuestInfo[iQuestIndex].QuestConditionCount++;
						
					}
				}
				else
				{
					MsgBox("Quest Info Read Fail");
					fclose(SMDFile);
					return false;
				}
			}
		}
	}

	fclose(SMDFile);
	this->InitQuestItem();
	return true;
}
Esempio n. 19
0
void CAttackEvent::Active()
{
	for ( int n = 0; n < OBJ_MAXMONSTER ; n++ )
	{
		if ( gObj[n].Class == 53 || gObj[n].Class == 54 )	// Golden Titan + Golden Soldier
		{
			gObj[n].Live = true;

			if ( gObj[n].Class == 53 )
			{
				this->m_MapNumber = MAP_INDEX_DEVIAS;
				gObj[n].MapNumber = this->m_MapNumber;

				while (	gMSetBase.GetBoxPosition(this->m_MapNumber, 10, 10, 240, 240, gObj[n].X, gObj[n].Y) == 0 )
				{

				}

				this->m_BossMap53 = gObj[n].MapNumber;
				this->m_BossMapX53 = gObj[n].X;
				this->m_BossMapY53 = gObj[n].Y;

				LogAdd("event %d %d %d create ", this->m_BossMap53, this->m_BossMapX53, this->m_BossMapY53);

			}
			else
			{
				this->m_MapNumber = this->m_BossMap53;
				gObj[n].MapNumber = this->m_MapNumber;

				while (	gMSetBase.GetBoxPosition(this->m_MapNumber, this->m_BossMapX53 -4, this->m_BossMapY53-4, this->m_BossMapX53+4, this->m_BossMapY53+4, gObj[n].X, gObj[n].Y) == 0 )
				{

				}
			}
				
			gObj[n].TX = gObj[n].X;
			gObj[n].TY = gObj[n].Y;
			gObj[n].MTX = gObj[n].X;
			gObj[n].MTY = gObj[n].Y;
			gObj[n].StartX = gObj[n].X;
			gObj[n].StartY = gObj[n].Y;
			gObj[n].m_State = 1;
			
		}
		else if ( gObj[n].Class == 55 || gObj[n].Class == 56 )	// Death Bone + Death King
		{
			gObj[n].Live = TRUE;

			if ( gObj[n].Class == 55 )
			{
				if ( (rand() % 2 ) == 0 )
				{
					this->m_MapNumber = MAP_INDEX_RORENCIA;
				}
				else
				{
					this->m_MapNumber = MAP_INDEX_NORIA;
				}

				gObj[n].MapNumber = this->m_MapNumber;


				while ( gMSetBase.GetBoxPosition(this->m_MapNumber, 10, 10, 240, 240, gObj[n].X, gObj[n].Y) == 0 )
				{

				}

				this->m_BossMap55 = gObj[n].MapNumber;
				this->m_BossMapX55 = gObj[n].X;
				this->m_BossMapY55 = gObj[n].Y;
				LogAdd("event %d %d %d create ", this->m_BossMap55, this->m_BossMapX55, this->m_BossMapY55 );
			}
			else
			{
				this->m_MapNumber = this->m_BossMap55;
				gObj[n].MapNumber = this->m_MapNumber;


				while (	gMSetBase.GetBoxPosition(this->m_MapNumber, this->m_BossMapX55 -4, this->m_BossMapY55-4, this->m_BossMapX55+4, this->m_BossMapY55+4, gObj[n].X, gObj[n].Y) == 0 )
				{

				}
			}

			gObj[n].TX = gObj[n].X;
			gObj[n].TY = gObj[n].Y;
			gObj[n].MTX = gObj[n].X;
			gObj[n].MTY = gObj[n].Y;
			gObj[n].StartX = gObj[n].X;
			gObj[n].StartY = gObj[n].Y;
			gObj[n].m_State = 1;
		}
	}
}
Esempio n. 20
0
void ConnectEx::SendLogin(int UserIndex, CONNECTEX_LOGIN * Data)
{
	/*if(		g_License.GetLicenseID() != Customer::Zeon
		&&	g_License.GetLicenseID() != Customer::Refinery
		&&	g_License.GetLicenseID() != Customer::Bereznuk
		&&	g_License.GetLicenseID() != Customer::Reedlan
		&&	g_License.GetLicenseID() != Customer::MUAngel
		&&	g_License.GetLicenseID() != Customer::MUAngel2 
		&&	g_License.GetLicenseID() != Customer::White
		&&	g_License.GetLicenseID() != Customer::White2 
		&&  g_License.GetLicenseID() != Customer::drynea 
		&&  g_License.GetLicenseID() != Customer::virnet )
	{
		return;
	}*/
	// ----
	BuxConvert(Data->AccountID, MAX_ACCOUNT_LEN);
	BuxConvert(Data->Password, MAX_ACCOUNT_LEN);
	// ----
	char id[11];
	id[10]=0;
	memcpy(id, Data->AccountID, sizeof(Data->AccountID));
	BuxConvert(id, MAX_ACCOUNT_LEN);
	// ----
	GJPUserClose(id); //Force connection
	// ----
	if( bCanConnectMember == TRUE )
	{
		if( ConMember.IsMember(id) == FALSE )
		{
			GCJoinResult(JS_ONLY_VIP_MEMBERS, UserIndex);
			return;
		}
	}
	// ----
	LPOBJ lpObj = &gObj[UserIndex];
	// ----
	if( gObj[UserIndex].Connected != PLAYER_CONNECTED )
	{
		LogAdd(lMsg.Get(MSGGET(1, 218)), UserIndex, id);
		CloseClient(UserIndex);
		return;
	}
	// ----
	if( gObj[UserIndex].LoginMsgSnd != FALSE )
	{
		if( gObj[UserIndex].LoginMsgSnd == TRUE )
		{
			LogAdd(lMsg.Get(MSGGET(1, 219)), UserIndex, id, gObj[UserIndex].Ip_addr );
		}
		else
		{
			LogAdd("error : %d %s %d", gObj[UserIndex].LoginMsgSnd, __FILE__, __LINE__);
		}

		return;
	}
	// ----
	if( lpObj->Connected >= PLAYER_LOGGED )
	{
		return;
	}
	// ----
	SDHP_IDPASS spMsg;
	// ----
	PHeadSetB((LPBYTE)&spMsg, 0x01, sizeof(spMsg));
	spMsg.Number = UserIndex;
	memcpy(spMsg.Id, Data->AccountID, sizeof(spMsg.Id));
	memcpy(spMsg.Pass, Data->Password, sizeof(spMsg.Pass));
	strcpy(spMsg.IpAddress, gObj[UserIndex].Ip_addr);
	gObj[UserIndex].CheckTick = Data->TickCount;
	gObj[UserIndex].CheckTick2 = GetTickCount();
	gObj[UserIndex].ConnectCheckTime = GetTickCount();
	gObj[UserIndex].CheckSpeedHack = true;
	gObj[UserIndex].LoginMsgSnd = 1;
	gObj[UserIndex].LoginMsgCount = 1;
	gObj[UserIndex].AccountID[MAX_ACCOUNT_LEN] = 0;
	gObj[UserIndex].Name[MAX_ACCOUNT_LEN] = 0;
	memcpy(gObj[UserIndex].AccountID, id, MAX_ACCOUNT_LEN);
	memcpy(gObj[UserIndex].Name, Data->Name, MAX_ACCOUNT_LEN);
	gObj[UserIndex].m_cAccountItemBlock = 0;
	gObj[UserIndex].m_ConnectEx = true;
	gObj[UserIndex].ukn_30 = 0;
	// ----
	wsJServerCli.DataSend((char*)&spMsg, spMsg.h.size);
	LogAddTD("join send : (%d)%s", UserIndex, gObj[UserIndex].AccountID);
	lpObj->m_bMapSvrMoveReq = false;
	lpObj->m_sPrevMapSvrCode = -1; 
	lpObj->m_sDestMapNumber = -1;
	lpObj->m_btDestX = 0;
	lpObj->m_btDestY = 0;
}
Esempio n. 21
0
DWORD WINAPI ServerWorkerThread(LPVOID CompletionPortID)
{
    HANDLE	CompletionPort = (HANDLE) CompletionPortID;
    DWORD	dwIoSize;
    DWORD	RecvBytes;
    DWORD	Flags;
    DWORD	dwSendNumBytes = 0;
    BOOL	bSuccess = FALSE;
    int		nRet;
    int     ClientIndex;

    LPPER_SOCKET_CONTEXT	lpPerSocketContext = NULL;
    LPOVERLAPPED			lpOverlapped = NULL;
    LPPER_IO_CONTEXT		lpIOContext = NULL;

    while(TRUE)
    {
        bSuccess = GetQueuedCompletionStatus(
                       CompletionPort,
                       &dwIoSize,
                       (LPDWORD)&ClientIndex,
                       &lpOverlapped,
                       INFINITE
                   );

        if( !bSuccess )
        {
            if( lpOverlapped != NULL )
            {
                int aError = GetLastError();
                if ( (aError != ERROR_NETNAME_DELETED) && (aError != ERROR_CONNECTION_ABORTED) && (aError != ERROR_OPERATION_ABORTED) && (aError != 0x79) )
                {
                    EnterCriticalSection(&criti);
                    LogAdd("Error Thread : GetQueueCompletionStatus( %d )", GetLastError());
                    LeaveCriticalSection(&criti);
                    return 0;
                }
            }
        }

        EnterCriticalSection(&criti);
        lpPerSocketContext = gObj[ClientIndex].PerSocketContext;

        lpPerSocketContext->dwIOCount--;

        if( dwIoSize == 0 )
        {
            LogAdd("Connection Closed, dwIoSize == 0 (Index:%d)", lpPerSocketContext->nIndex);
            CloseClient(lpPerSocketContext, 0);
            LeaveCriticalSection(&criti);
            continue;
        }

        lpIOContext = (LPPER_IO_CONTEXT)lpOverlapped;

        if( lpIOContext == NULL ) continue;
        if( lpIOContext->IOOperation == SEND_IO )
        {
            lpIOContext->nSentBytes += dwIoSize;

            if( lpIOContext->nSentBytes >= lpIOContext->nTotalBytes )
            {
                lpIOContext->nWaitIO = 0;
                if( lpIOContext->nSecondOfs > 0 )
                {
                    IoSendSecond(lpPerSocketContext);
                }
            }
            else
            {
                IoMoreSend(lpPerSocketContext);
            }
        }
        else if( lpIOContext->IOOperation == RECV_IO )
        {
            RecvBytes = 0;

            lpIOContext->nSentBytes += dwIoSize;

            if( RecvDataParse(lpIOContext, lpPerSocketContext->nIndex) == FALSE )
            {
                LogAdd("error-L1 : Socket Header error %d, %d", WSAGetLastError(), lpPerSocketContext->nIndex);
                CloseClient(lpPerSocketContext, 0);
                LeaveCriticalSection(&criti);
                continue;
            }

            lpIOContext->nWaitIO = 0;
            Flags = 0;
            ZeroMemory(&(lpIOContext->Overlapped), sizeof(OVERLAPPED));

            lpIOContext->wsabuf.len		= MAX_IO_BUFFER_SIZE-lpIOContext->nSentBytes;
            lpIOContext->wsabuf.buf		= lpIOContext->Buffer+lpIOContext->nSentBytes;
            lpIOContext->IOOperation	= RECV_IO;

            nRet = WSARecv(lpPerSocketContext->m_socket, &(lpIOContext->wsabuf), 1, &RecvBytes, &Flags,
                           &(lpIOContext->Overlapped), NULL);

            if( nRet == SOCKET_ERROR && (WSAGetLastError() != ERROR_IO_PENDING) )
            {
                LogAdd("WSARecv() failed with error %d", WSAGetLastError());
                //lpIOContext->nWaitIO = 2;
                CloseClient( lpPerSocketContext, FALSE);
                LeaveCriticalSection(&criti);
                continue;
            }

            lpPerSocketContext->dwIOCount++;
            lpIOContext->nWaitIO = 1;
        }
        LeaveCriticalSection(&criti);
    }
    return TRUE;
}
void CDevilSquare::gObjExpParty(LPOBJ lpObj, LPOBJ lpTargetObj, int AttackDamage, BOOL MSBFlag)
{
    int n;
    __int64 exp;
    __int64 maxexp = 0;
    __int64 totalexp;
    int level = ((lpTargetObj->Level + 25) * lpTargetObj->Level) / 3;
    int number;
    int partynum = 0;
    int totallevel = 0;
    int partylevel;
    int partycount;
    int dis[6];
    int viewplayer = 0;
    int viewpercent = 100;
    BOOL bApplaySetParty = FALSE;
    bool bCheckSetParty[6];
    partynum = lpObj->PartyNumber;
    LPOBJ lpPartyObj;


    int toplevel = 0;
    int distance;

    for (n=0; n<MAX_USER_IN_PARTY; n++)
    {
        number = gParty.m_PartyS[partynum].Number[n];

        if ( number >= 0 )
        {
            lpPartyObj = &gObj[number];

            distance = gObjCalDistance(lpObj,lpPartyObj);

            if( distance < 10 )
            {
                if(lpPartyObj->Level > toplevel)
                {
                    toplevel = lpPartyObj->Level;
                }
            }
        }
    }

    if ( OBJMAX_RANGE(partynum) == FALSE )
    {
        LogAdd("error : %s %d", __FILE__, __LINE__);
        return;
    }

    partycount = gParty.m_PartyS[partynum].Count;

    for ( n =0; n<MAX_USER_IN_PARTY; n++)
    {
        number = gParty.m_PartyS[partynum].Number[n];

        if ( number >= 0 )
        {
            lpPartyObj = &gObj[number];

            if ( lpTargetObj->MapNumber ==lpPartyObj->MapNumber )
            {
                dis[n] = gObjCalDistance(lpTargetObj, &gObj[number]);

                if ( dis[n] < 10 )
                {
                    lpPartyObj = &gObj[number];

                    if ( toplevel >= (lpPartyObj->Level + 200 ) ) // #formula
                    {
                        totallevel = totallevel + lpPartyObj->Level + 200;
                    }
                    else
                    {
                        totallevel += lpPartyObj->Level;
                    }

                    viewplayer++;
                    bCheckSetParty[lpPartyObj->Class] = true;
                }
            }
        }
    }

    viewpercent += gParty.GetExpBonus(lpObj, lpTargetObj, partynum);

    if ( viewplayer > 1 )
    {
        partylevel = totallevel / viewplayer;
    }
    else
    {
        partylevel = totallevel;
    }

    if ( (lpTargetObj->Level +10) < partylevel )
    {
        level = (level * (lpTargetObj->Level+10) ) / partylevel;
    }

    if ( lpTargetObj->Level >= 65 )
    {
        if ( viewplayer == 1 )
        {
            level += (lpTargetObj->Level - 64) * (lpTargetObj->Level/ 4);
        }
        else
        {
            level += (int)(200.0 - (lpObj->Level * 0.2));
        }
    }

    if ( level > 0 )
    {
        maxexp = level / 2;
    }
    else
    {
        level = 0;
    }

    if ( maxexp < 1 )
    {
        totalexp = level;
    }
    else
    {
        totalexp = level + rand()%maxexp;
    }

    if ( lpTargetObj->Type == OBJ_MONSTER )
    {
        lpTargetObj->Money = (int)totalexp;
    }

    for ( n=0; n<MAX_USER_IN_PARTY; n++)
    {
        number = gParty.m_PartyS[partynum].Number[n];

        if ( number >= 0 )
        {
            lpPartyObj = &gObj[number];

            if ( lpTargetObj->MapNumber == lpPartyObj->MapNumber )
            {
                if ( dis[n] < 10 )
                {
                    DWORD myexp = gLevelExperience[lpPartyObj->Level];
                    exp = ((totalexp * viewpercent* lpPartyObj->Level ) / totallevel ) / 100;

                    if ( exp > myexp  )
                    {
                        exp = myexp;
                    }

                    if( lpPartyObj->Type == OBJ_USER )
                    {
                        if ( lpTargetObj->Type == OBJ_USER )
                        {
                            exp = 0;
                        }
                    }

                    if ( g_MasterExp.IsEnabled(lpPartyObj) == FALSE )
                    {
                        exp += (exp * m_ObjBill[lpPartyObj->m_Index].GetExp()) / 100;
                        exp = int(exp * g_MapRateInfo.GetExp(lpPartyObj->MapNumber));
                    }

                    if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE)
                    {
                        exp =  (exp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100;
                    }

                    if ( exp > 0 )
                    {
                        if ( lpPartyObj->Type == OBJ_USER )
                        {

                            CheckItemOptForGetExpEx(lpPartyObj,exp,0);

                            lpPartyObj->Experience += (DWORD)exp;
                            lpPartyObj->m_nEventExp += (int)exp;

                            if ( gObjLevelUp(lpPartyObj, &exp, lpTargetObj->Class, EVENT_TYPE_PARTY) == false )
                            {
                                continue;
                            }
                        }
                    }

                    if ( lpPartyObj->Type == OBJ_USER )
                    {
                        GCKillPlayerExpSend(lpPartyObj->m_Index, lpTargetObj->m_Index,(int)exp, AttackDamage, MSBFlag);
                    }
                }
            }
        }
    }
}
Esempio n. 23
0
int DataSend(int aIndex, LPBYTE lpMsg, DWORD dwSize)
{
    DWORD SendBytes;
    LPPER_SOCKET_CONTEXT lpPerSocketContext;
    LPBYTE SendBuf;


    if ( aIndex < OBJ_STARTUSERINDEX )
    {
        return true;
    }

    EnterCriticalSection(&criti);

    if ( ((aIndex < 0)? FALSE : (aIndex > OBJMAX-1)? FALSE : TRUE )  == FALSE )
    {
        LogAdd("error-L2 : Index(%d) %x %x %x ", dwSize, lpMsg[0], lpMsg[1], lpMsg[2]);
        LeaveCriticalSection(&criti);
        return false;
    }

    if ( lpMsg[0] == 0xC3 || lpMsg[0] == 0xC4 )
    {
        int ret;
        BYTE btsize;

        if ( lpMsg[0] == 0xC3 )
        {
            btsize = lpMsg[1];
            lpMsg[1]=gNSerialCheck[aIndex].GetSendSerial();
            ret = g_SimpleModulusSC.Encrypt(&ExSendBuf[2], &lpMsg[1], dwSize-1);
            ExSendBuf[0] = 0xC3;
            ExSendBuf[1] = ret + 2;
            SendBuf = ExSendBuf;
            dwSize = ret + 2;
            lpMsg[1] = btsize;
        }
        else
        {
            btsize = lpMsg[2];
            lpMsg[2] = gNSerialCheck[aIndex].GetSendSerial();
            ret = g_SimpleModulusSC.Encrypt(&ExSendBuf[3], &lpMsg[2], dwSize-2);
            ExSendBuf[0] = 0xC4;
            ExSendBuf[1] = SET_NUMBERH(ret +3 );
            ExSendBuf[2] = SET_NUMBERL(ret+3);
            SendBuf = ExSendBuf;
            dwSize = ret + 3;
            lpMsg[2] = btsize;
        }
    }
    else
    {
        SendBuf = lpMsg;
    }

    if ( gObj[aIndex].Connected < PLAYER_CONNECTED )
    {
        LeaveCriticalSection(&criti);
        return FALSE;
    }

    lpPerSocketContext= gObj[aIndex].PerSocketContext;

    if ( dwSize > sizeof(lpPerSocketContext->IOContext[0].Buffer))
    {
        LogAdd("Error : Max msg(%d) %s %d", dwSize, __FILE__, __LINE__);
        CloseClient(aIndex);
        LeaveCriticalSection(&criti);
        return false;
    }

    LPPER_IO_CONTEXT	lpIoCtxt = (LPPER_IO_CONTEXT)&lpPerSocketContext->IOContext[1];

    if ( lpIoCtxt->nWaitIO > 0 )
    {
        if ( ( lpIoCtxt->nSecondOfs + dwSize ) > MAX_IO_BUFFER_SIZE-1 )
        {
            LogAdd("(%d)error-L2 MAX BUFFER OVER %d %d %d [%s][%s]",
                   aIndex, lpIoCtxt->nTotalBytes, lpIoCtxt->nSecondOfs,
                   dwSize, gObj[aIndex].AccountID, gObj[aIndex].Name);

            lpIoCtxt->nWaitIO = 0;
            CloseClient(aIndex);
            LeaveCriticalSection(&criti);
            return true;
        }

        memcpy( &lpIoCtxt->BufferSecond[lpIoCtxt->nSecondOfs], SendBuf, dwSize);
        lpIoCtxt->nSecondOfs += dwSize;
        LeaveCriticalSection(&criti);
        return true;
    }

    lpIoCtxt->nTotalBytes = 0;

    if ( lpIoCtxt->nSecondOfs > 0 )
    {
        memcpy(lpIoCtxt->Buffer, lpIoCtxt->BufferSecond, lpIoCtxt->nSecondOfs);
        lpIoCtxt->nTotalBytes = lpIoCtxt->nSecondOfs;
        lpIoCtxt->nSecondOfs = 0;
    }

    if ( (lpIoCtxt->nTotalBytes+dwSize) > MAX_IO_BUFFER_SIZE-1 )
    {
        LogAdd("(%d)error-L2 MAX BUFFER OVER %d %d [%s][%s]",
               aIndex, lpIoCtxt->nTotalBytes, dwSize,
               gObj[aIndex].AccountID, gObj[aIndex].Name);

        lpIoCtxt->nWaitIO = 0;
        CloseClient(aIndex);
        LeaveCriticalSection(&criti);
        return FALSE;
    }

    memcpy( &lpIoCtxt->Buffer[lpIoCtxt->nTotalBytes], SendBuf, dwSize);
    lpIoCtxt->nTotalBytes += dwSize;
    lpIoCtxt->wsabuf.buf = (char*)&lpIoCtxt->Buffer;
    lpIoCtxt->wsabuf.len = lpIoCtxt->nTotalBytes;
    lpIoCtxt->nSentBytes = 0;
    lpIoCtxt->IOOperation = SEND_IO;

    if ( WSASend( gObj[aIndex].m_socket, &lpIoCtxt->wsabuf , 1, &SendBytes, 0, &lpIoCtxt->Overlapped, NULL) == -1 )
    {

        if ( WSAGetLastError() != WSA_IO_PENDING )
        {
            lpIoCtxt->nWaitIO = 0;


            if ( lpIoCtxt->wsabuf.buf[0] == 0xC1 )
            {
                LogAdd("(%d)WSASend(%d) failed with error [%x][%x] %d %s ",
                       __LINE__, aIndex, (BYTE)lpIoCtxt->wsabuf.buf[0],
                       (BYTE)lpIoCtxt->wsabuf.buf[2], WSAGetLastError(), gObj[aIndex].Ip_addr);
            }
            else if ( lpIoCtxt->wsabuf.buf[0] == 0xC2 )
            {
                LogAdd("(%d)WSASend(%d) failed with error [%x][%x] %d %s ",
                       __LINE__, aIndex, (BYTE)lpIoCtxt->wsabuf.buf[0],
                       (BYTE)lpIoCtxt->wsabuf.buf[3], WSAGetLastError(), gObj[aIndex].Ip_addr);
            }
            CloseClient(aIndex);
            LeaveCriticalSection(&criti);
            return false;
        }
    }
    else
    {
        lpPerSocketContext->dwIOCount ++;
    }


    lpIoCtxt->nWaitIO = 1;
    LeaveCriticalSection(&criti);
    return true;
}
void CDevilSquare::Load(char * filename)
{
    int i;
    for ( i=0; i<MAX_DEVILSQUARE_GROUND; i++)
    {
        this->m_DevilSquareGround[i].Init(i);
    }

    int Token;
    int number;
    int type;
    int monstertype;
    int starttime;
    int endtime;
    int x;
    int y;
    int tx;
    int ty;

    SMDFile = fopen(filename, "r");

    if ( SMDFile == NULL )
    {
        MsgBox("[DevilSquare] Info file Load Fail [%s]", filename);
        return;
    }

    while ( true )
    {
        Token = GetToken();

        if ( Token == 2 )
        {
            break;
        }

        type = (int)TokenNumber;

        while ( true )
        {
            if ( type == 0 )	// Time Sync
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                this->m_iCloseTime = (int)TokenNumber;

                Token = GetToken();
                this->m_iOpenTime = (int)TokenNumber;

                Token = GetToken();
                this->m_iPlaytime = (int)TokenNumber;
            }
            else if ( type == 1 )	// Normal Monster Settings
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                number = (int)TokenNumber;	// Devils Square Index;

                Token = GetToken();
                monstertype = (int)TokenNumber;

                Token = GetToken();
                starttime = (int)TokenNumber;

                Token = GetToken();
                endtime = (int)TokenNumber;

                this->m_DevilSquareGround[number].Set(monstertype, starttime, endtime);
            }
            else if ( type == 2 )	// Boss Monster Set
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                number = (int)TokenNumber;	// Devils Square Index;

                Token = GetToken();
                monstertype = (int)TokenNumber;

                Token = GetToken();
                starttime = (int)TokenNumber;

                Token = GetToken();
                x = (int)TokenNumber;

                Token = GetToken();
                y = (int)TokenNumber;

                Token = GetToken();
                tx = (int)TokenNumber;

                Token = GetToken();
                ty = (int)TokenNumber;

                this->m_DevilSquareGround[number].SetBoss(monstertype, starttime, x, y, tx, ty);
            }
            else if ( type == 3 ) // Bonus Sttings
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                int index;
                int rank;
                int zen;
                int exp;

                index = (int)TokenNumber;

                Token = GetToken();
                rank = (int)TokenNumber;

                Token = GetToken();
                exp = (int)TokenNumber;

                Token = GetToken();
                zen = (int)TokenNumber;

                this->m_DevilSquareGround[index].SetBonus(rank, exp, zen);
            }
            else if ( type == 4 )
            {
                DS_TIME tmp;

                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    break;
                }

                tmp.iHour = (int)TokenNumber;
                Token = GetToken();
                tmp.iMinute = (int)TokenNumber;

                m_EventTime.push_back(tmp);
            }
            else if ( type == 5 )
            {
                Token = GetToken();

                if ( strcmp("end", TokenString) == 0 )
                {
                    for( i = 0; i < MAX_DEVILSQUARE_GROUND; i++)
                    {
                        this->m_DevilSquareGround[i].IncBonus(m_BonusIncValue[i]);
                    }
                    break;
                }

                int index = (int)TokenNumber;

                if( DS_LEVEL_RANGE(index) )
                {
                    Token = GetToken();
                    m_BonusIncValue[index] = TokenNumber;
                }
                else
                {
                    Token = GetToken();
                }
            }
        }
    }

    fclose (SMDFile );
    LogAdd("%s file load!", filename);
}
Esempio n. 25
0
void CMagicDamage::LogSkillList(char * filename)
{
	this->Init();

	if ( fopen_s(&SMDFile,filename, "r") != 0 )
	{
		MsgBox("(%s) Skill information load error", filename);
		return;
	}

	int Token;
	int n=0;
	int number;
	char name[50];
	int requireLevel;
	int damage;
	int mana;
	int bp=0;
	int dis;
	int rEnergy;
	int iSkillType;
	int rLeadership;
	int rDelay;
	int attr;
	int iSkillUseType;
	int iSkillBrand;
	int iKillCount;
	int RequireStatus[MAX_REQ_SKILL_STATUS] = {0};
	BYTE RequireClass[MAX_TYPE_PLAYER];

	while ( true )
	{
		Token = GetToken();

		if ( Token == 2 )
		{
			break;
		}

		if ( Token == 1 )
		{
			number = (int)TokenNumber;

			Token = GetToken();
			strcpy_s(name, sizeof(name), TokenString);

			Token = GetToken();
			requireLevel = (int)TokenNumber;

			Token = GetToken();
			damage = (int)TokenNumber;

			Token = GetToken();
			mana = (int)TokenNumber;

			Token = GetToken();
			bp = (int)TokenNumber;	// Agility Gauge

			Token = GetToken();
			dis = (int)TokenNumber;

			Token = GetToken();
			rDelay = (int)TokenNumber;

			Token = GetToken();
			rEnergy = (int)TokenNumber;

			Token = GetToken();
			rLeadership = (int)TokenNumber;

			Token = GetToken();
			attr = (int)TokenNumber;

			Token = GetToken();
			iSkillType = (int)TokenNumber;

			Token = GetToken();
			iSkillUseType = (int)TokenNumber;

			Token = GetToken();
			iSkillBrand = (int)TokenNumber;

			Token = GetToken();
			iKillCount = (int)TokenNumber;

			Token = GetToken();
			RequireStatus[0] = (int)TokenNumber;

			Token = GetToken();
			RequireStatus[1] = (int)TokenNumber;

			Token = GetToken();
			RequireStatus[2] = (int)TokenNumber;

			Token = GetToken();
			RequireClass[0] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[1] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[2] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[3] = (BYTE)TokenNumber;

			Token = GetToken();
			RequireClass[4] = (BYTE)TokenNumber;


			this->Set(name, number,damage, requireLevel, mana, bp, dis, attr, iSkillType, RequireClass, rEnergy, rLeadership, rDelay);
			this->SetEx(number, iSkillUseType, iSkillBrand, iKillCount, RequireStatus);
			DefMagicInf[number].Set(number, 0);
		}
	}

	fclose(SMDFile);
	LogAdd("(%s) Skill information data load complete", filename);
}
Esempio n. 26
0
int CIllusionTempleEvent::GetEnterLevel(int aIndex)
{
	int TempleLevel = 0;
	LPOBJ lpObj = &gObj[aIndex];

	if( OBJMAX_RANGE( aIndex ) == FALSE )
	{
		LogAdd("return %s %d",__FILE__,__LINE__);
		return -1;
	}

	if( lpObj->Level < 220 )
	{
		return 0;
	}

	if( lpObj->Level < 271 )
	{
		return 1;
	}

	if( lpObj->Level < 321 )
	{
		return 2;
	}

	if( lpObj->Level < 351 )
	{
		return 3;
	}

	if( lpObj->Level < 381 )
	{
		return 4;
	}

	if( lpObj->Level < 400 )
	{
		return 5;
	}

	if( lpObj->Level == 400 )
	{
		if( lpObj->ChangeUP == FALSE )
		{
			return 5;
		}
	}

	if( lpObj->Level == 400 )
	{
		if( lpObj->ChangeUP != FALSE )
		{
			if( g_bMaxLevelIllusion != 0 )
			{
				return 6;
			}
			else
			{
				return 5;
			}
		}
	}
return -1;
}
Esempio n. 27
0
void CGambleSystem::Load(char* filename) //0049B9D0  (Identical)
{
	this->bLoad = FALSE;
	this->m_iGambleBagCount = 0;

	SMDFile = fopen(filename, "r");	//ok

	if ( SMDFile == NULL )
	{
		LogAdd(lMsg.Get(453), filename);
		return;
	}
	SMDToken Token;

	int n = 0;
	int iProbability = 0;
	int Count = 0;

	while(true)
	{
		Token = GetToken();

		if ( Token == END )
		{
			break;
		}

		if ( Token == 1 )
		{
			int Type = TokenNumber;

			if (Type == 0)
			{
				Count = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							break;
						}
					}

					if ( Count > GAMBLE_MAX_ITEM_INFO )
					{
						MsgBox("Load Script Error %s",filename);
						break;
					}

					m_GamblingInfo[Count].m_iSkillRate = TokenNumber;

					Token = GetToken();
					m_GamblingInfo[Count].m_iLuckRate = TokenNumber;

					Token = GetToken();
					m_GamblingInfo[Count].m_iOptionRate = TokenNumber;

					Token = GetToken();
					m_GamblingInfo[Count].m_iExcRate = TokenNumber;

					Token = GetToken();
					m_GamblingInfo[Count].m_iSortItemRate = TokenNumber;
					
					Count++;
				}
			}
			else if (Type == 1)
			{
				Count = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							break;
						}
					}
					if ( Count > GAMBLE_MAX_SECRET_ITEM_CLASS )
					{
						MsgBox("Load Script Error %s",filename);
						break;
					}

					this->m_iBagItemOptionRate[Count] = TokenNumber;

					Count++;
				}
			}
			else if (Type == 2)
			{
				Count = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							break;
						}
					}

					if ( Count > GAMBLE_MAX_NORMAL_ITEM )
					{
						MsgBox("Load Script Error %s",filename);
						break;
					}

					this->m_dwSpecialItemRate[Count] = TokenNumber;

					Count++;
				}
			}
			else if (Type == 3)
			{
				Count = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							break;
						}
					}
					if ( Count > GAMBLE_MAX_SECRET_ITEM_CLASS )
					{
						MsgBox("Load Script Error %s",filename);
						break;
					}

					this->m_iBagItemExcRate[Count] = TokenNumber;

					Count++;
				}
			}
			else if (Type == 4)
			{
				Count = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							break;
						}
					}

					if ( Count > GAMBLE_MAX_SECRET_ITEM_TYPE )
					{
						MsgBox("Load Script Error %s",filename);
						break;
					}

					this->m_iExcRatePerItemKind[Count] = TokenNumber;

					Token = GetToken();
					this->m_iGeneralExcRate[Count] = TokenNumber;

					Count++;
				}
			}
			else if (Type >= 5)
			{
				n = 0;

				while(true)
				{
					Token = GetToken();

					if( Token == 0 )
					{
						if (strcmp("end",TokenString) == 0)
						{
							this->m_iDropRatePerItemCount[iProbability] = n;
							break;
						}
					}
					
					this->BagObject[m_iGambleBagCount].m_type = TokenNumber;
						
					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_index = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_minLevel = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_maxLevel = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_isskill = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_isluck = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_isoption = TokenNumber;

					Token = GetToken();
					this->BagObject[m_iGambleBagCount].m_isexitem = TokenNumber;

					if(this->BagObject[m_iGambleBagCount].m_minLevel > this->BagObject[m_iGambleBagCount].m_maxLevel )
					{
						MsgBox("Load Script Error %s",filename);
						return;
					}
					
					n++;
					this->m_iGambleBagCount++;

					if (this->m_iGambleBagCount > GAMBLE_MAX_ITEM-1 )
					{
						break;
					}

				}

				iProbability++;

				if(iProbability > GAMBLE_MAX_ITEM_INFO-1)
				{
					break;
				}

				this->m_iRateKindCount = iProbability;
			}
		}
	}

	fclose(SMDFile);
	LogAdd(lMsg.Get(454), filename);
	this->bLoad = TRUE;
}
Esempio n. 28
0
BOOL CIllusionTempleEvent::LoadFile(char* szFileName)
{
	SMDFile = fopen(szFileName,"r");

	if(SMDFile == NULL)
	{
		MsgBox("[Illusion Temple] Info file Load Fail [%s]",szFileName);
		return FALSE;
	}

	int Token,Index;

	ILLUSION_TIME pTmp;

	while( TRUE )
	{
		Token = GetToken();

		if( Token == END )
			break;

		Index = (int)TokenNumber;

		while( TRUE )
		{
			if( Index == 0 )
			{
				Token = GetToken();

				if( strcmp("end",TokenString) == NULL )
					break;

				m_iIT_TIME_MIN_OPEN = (int)TokenNumber;

				Token = GetToken();
				m_iIT_TIME_MIN_PREPARE = (int)TokenNumber;

				Token = GetToken();
				m_iIT_TIME_MIN_PLAY = (int)TokenNumber;

				Token = GetToken();
				m_iIT_TIME_MIN_CLOSE = (int)TokenNumber;
			}
			else if(Index == 1)
			{
				Token = GetToken();

				if( strcmp("end",TokenString) == NULL )
					break;

				pTmp.iHour = (int)TokenNumber;

				Token = GetToken();
				pTmp.iMinute = (int)TokenNumber;

				m_IllusionStartTime.push_back(pTmp);
			}
		}
	}

	fclose(SMDFile);

	LogAdd("%s file load!",szFileName);

return TRUE;
}
Esempio n. 29
0
void ProtocolCore(int aIndex, LPBYTE aRecv, int aLen)
{
	BYTE protoNum = 0;
	if((aRecv[0] == 0xC1) || (aRecv[0] == 0xC3))
	{
		protoNum = aRecv[2];
	}else
	{
		protoNum = aRecv[3];
	}

	switch(protoNum)
	{
		case 0x05 :
			CSVersionRecv(aIndex,(PMSG_VERSION *)aRecv);
		break;	

		case 0x04 :		// HTTP
			CSHTTPVersionRecv(aIndex, (PMSG_VERSION *)aRecv);
		break;

		case 0xF4:
		{
			PMSG_DEFAULT2 * lpDef = (PMSG_DEFAULT2 *)aRecv;
			switch(lpDef->subcode)
			{
				case 3: //Connect to Server
				{
					//PMSG_DEFAULT2 encPacket ={0};
					//PHeadSubSetB((LPBYTE)&encPacket, 0xEE, 0x54, sizeof(encPacket));
					//DataSend(aIndex, (unsigned char*)&encPacket, encPacket.h.size);

					BYTE i=aRecv[5];
					BYTE j=aRecv[4];
					PMSG_SENDSERVER pResult;
					PHeadSubSetB((LPBYTE)&pResult, 0xF4, 0x03, sizeof(pResult));
					strcpy(pResult.IpAddress,serverManager.Server[i][j].IpAddress);
					pResult.port = serverManager.Server[i][j].Port;
					DataSend(aIndex, (unsigned char*)&pResult, pResult.h.size);
					LogAddTD("IP: %s is connected to server [%d,%d](%s:%d)",Obj[aIndex].Ip_addr,i,j,serverManager.Server[i][j].IpAddress,serverManager.Server[i][j].Port);
					serverManager.DelAutoAntiFloodIP(Obj[aIndex].Ip_addr);
				}break;
				case 6: //Send Server List
				{
					if(Obj[aIndex].SendListCount>=serverManager.MaxSendListCount)
					{
						LogAddC(2,"[AntiFlood] IP: %s requested serverlist %d times",Obj[aIndex].Ip_addr,Obj[aIndex].SendListCount);
						serverManager.AutoAntiFloodCheck(Obj[aIndex].Ip_addr);
						CloseClient(aIndex);
						return;
					}
					Obj[aIndex].SendListCount++;
					LogAddTD("IP: %s requested serverlist",Obj[aIndex].Ip_addr);
					DataSend(aIndex,serverManager.List,serverManager.ListSize);
				}break;
				default:
				{
					LogAdd("error-L2 : IP:%s HEAD:%x SUBCODE:%x",Obj[aIndex].Ip_addr,protoNum,lpDef->subcode);
					CloseClient(aIndex);
				}
			}
		}break;
		default:
		{
			LogAdd("error-L2 : IP:%s HEAD:%x",Obj[aIndex].Ip_addr,protoNum);
			CloseClient(aIndex);
		}break;
	}
}
//0063AED0	-> OK
BOOL CJewelOfHarmonySystem::NpcJewelOfHarmony(LPOBJ lpNpc, LPOBJ lpObj)
{
    if ( lpObj->m_IfState.use > 0 )
        return TRUE;

    PMSG_TALKRESULT pResult;

    pResult.h.c = 0xC3;
    pResult.h.headcode = 0x30;
    pResult.h.size = sizeof(pResult);

    if ( lpNpc->Class == 368 )
    {
        pResult.result = 17;
        pResult.level1 = this->m_iRatePuritySuccess;

        if ( this->m_bSystemPrutiyJewel != TRUE )
        {
            GCServerMsgStringSend(lMsg.Get(MSGGET(13,50)), lpObj->m_Index, 1);
            return TRUE;
        }

        if ( !this->IsEnableToUsePuritySystem() )
        {
            GCServerMsgStringSend(lMsg.Get(MSGGET(13,50)), lpObj->m_Index, 1);
            LogAddTD("[JewelOfHarmony][%s][%s] Not Purtiy Time ",
                     lpObj->AccountID, lpObj->Name);

            return TRUE;
        }
    }
    else  if ( lpNpc->Class == 369 )
    {
        pResult.result = 18;
        pResult.level1 = this->m_iRateMixSmeltingStoneNor;
        pResult.level2 = this->m_iRateMixSmeltingStoneExt;

        if ( this->m_bSystemMixSmeltingStone != TRUE )
        {
            ChatTargetSend(lpNpc, lMsg.Get(MSGGET(13,53)), lpObj->m_Index);
            return TRUE;
        }
    }
    else if ( lpNpc->Class == 370 )
    {
        pResult.result = 19;

        if ( this->m_bSystemRestoreStrengthen != TRUE )
        {
            ChatTargetSend(lpNpc, lMsg.Get(MSGGET(13,54)), lpObj->m_Index);
            return TRUE;
        }
    }
    else
    {
        LogAddTD("[JewelOfHarmony][%s][%s] Open Chaos Box Failed NpcType [%d]",
                 lpObj->AccountID, lpObj->Name, lpNpc->Class);

        return TRUE;
    }

    if ( bCanChaosBox == TRUE )
    {
        if ( lpObj->m_bPShopOpen == true )
        {
            LogAdd("[JewelOfHarmony][%s][%s] is Already Opening PShop, ChaosBox Failed",
                   lpObj->AccountID, lpObj->Name);

            GCServerMsgStringSend(lMsg.Get(MSGGET(4,194)), lpObj->m_Index, 1);
            return TRUE;
        }

        lpObj->m_IfState.type = 7;
        lpObj->m_IfState.state = 0;
        lpObj->m_IfState.use = 1;
        lpObj->bIsChaosMixCompleted = false;

        DataSend(lpObj->m_Index, (LPBYTE)&pResult, pResult.h.size);
        gObjInventoryTrans(lpObj->m_Index);

        LogAddTD("[JewelOfHarmony][%s][%s] Open Chaos Box",
                 lpObj->AccountID, lpObj->Name);

        gObjItemTextSave(lpObj);
        gObjWarehouseTextSave(lpObj);
        GCAnsCsMapSvrTaxInfo(lpObj->m_Index, 1, g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index));
    }

    return TRUE;
}