⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user2.cpp

📁 决战帝王1.5武神降临对喜爱决战的玩家共享研究用
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		{
			if (i < 6)
			{ 
				m_sCityRank = i - CITY_RANK_INTERVAL;
			}
			else
			{ 
				m_sCityRank = i -1 - CITY_RANK_INTERVAL;
			}
			break;
		}
	}

	if ( m_iCityValue >= g_CityRankValue[10] ) m_sCityRank = CITY_RANK_INTERVAL;

	::CopyMemory(m_strSkill, strSkill, sizeof(m_strSkill));		// 胶懦
	::CopyMemory(m_strItem, strItem, sizeof(m_strItem));		// 酒捞袍
	::CopyMemory(m_strPsi, strPsi, sizeof(m_strPsi));			// 荤捞坷葱

	StrToUserSkill((LPTSTR)strSkill);
	StrToUserItem((LPTSTR)strItem);
	StrToUserPsi((LPTSTR)strPsi);
	StrToHaveEventData((LPTSTR)strHaveEvent);
	StrToUserTel((LPSTR)strTel);

	m_dwExpNext	= GetNextLevel(m_sLevel);						// 促澜饭骇捞 登扁困茄 版氰摹

	for(i = 0; i < TOTAL_SKILL_NUM; i++)						// 胶懦 己傍啦 
	{
		GetSkillInfo(i, m_UserSkillInfo[i]);
	}
//	m_UserChangeSkillInfo;										// 傈流捞 乐阑版快 ?(5)胶懦甫 历厘

	for(i = 0; i < CLASS_NUM; i++)
	{
		m_sChangeClass[i] = sChangeClass[i];
	}

	m_tPsiAbnormal = 0;
	::CopyMemory(m_strAbnormal, strAbnormal, sizeof(m_strAbnormal));	// 惑怕捞惑 沥焊

	int index = 0;
	for(i = TOTAL_ITEM_NUM; i < TOTAL_ITEM_SLOT_NUM; i++)
	{
		m_UserItem[i].sSid = GetShort((char*)strQuickItem, index);
	}

	m_tDir = myrand(0, 7);												// 泅犁 焊绊乐绰 规氢阑 伐待栏肺 檬扁拳茄促.
		
	m_tIsOP = tIsOP;
	if(tIsOP == 1) m_tPsiAbnormal = OPERATION_MODE;						// 扁夯捞 捧疙葛靛烙...
	
	CheckInvalidGuildZone();

	m_dwHasteTime		= iHaste;
	m_dwShieldTime		= iShield;
	m_dwDexUpTime		= iDexUp;
	m_dwMaxHPUpTime		= iMaxHPUp;

	DWORD dwCurrTime	= GetTickCount();
	m_dwLastSpeedTime	= dwCurrTime;
	m_dwLastMoveAndRun	= dwCurrTime;
	m_dwLastAttackTime	= dwCurrTime;
	m_dwLastPsiAttack	= dwCurrTime;
	m_dwCastDelay		= 0;
	m_dwLastTimeCount	= dwCurrTime;
	m_dwLastAbnormalTime= dwCurrTime;
	m_dwLastHPTime		= dwCurrTime;

	m_dwLastHasteTime	= dwCurrTime;
	m_dwLastShieldTime	= dwCurrTime;
	m_dwLastDexUpTime	= dwCurrTime;
	m_dwLastMaxHPUpTime = dwCurrTime;

	GetRecoverySpeed();													// 蜡历 努贰胶狼 雀汗加档甫 搬沥茄促.
	//

	// LOADUSERBANK PROCESS...
	//StrToUserBankItem((LPTSTR)ubstrItem);
	//m_dwBankDN = ubiDN;
	//SetMemUserBank((LPCTSTR)ubstrItem);
	//

	//-------------------------------------------------------------------------
	// GameStart 贸府何...
	if( !IsZoneInThisServer(m_curz) )
	{
		ChangeServer(m_curz);
		
		ReInitMemoryDB();

		SoftClose();
		return;
	}
	// SetZoneIndex(m_curz);

	m_state = STATE_CONNECTED;

	pt = FindNearAvailablePoint_S(m_curx, m_cury);	// DB俊 历厘等 谅钎啊 框流老 荐 乐绰 谅钎牢瘤 魄窜
	if(pt.x == -1 || pt.y == -1) 
	{
		error_code = ERR_4;
		goto result_send;
	}

	m_curx = pt.x; m_cury = pt.y;
	SetUid(m_curx, m_cury, m_uid + USER_BAND );		// 蜡历 困摹沥焊 悸泼
	m_presx = -1;
	m_presy = -1;

	pt = ConvertToClient(m_curx, m_cury);

//		SetUserToMagicUser();						// 泅犁 瓷仿摹甫 悼利 蜡历函荐俊 歹茄促.
	GetMagicItemSetting();							// 泅犁 酒捞袍吝 概流 加己, 饭骇函悼阑 悼利 函荐俊 馆康茄促.

	m_UserFlag = TRUE;

	result = SUCCESS;

	m_ConnectionSuccessTick = 0;

	InitMemoryDB(m_uid);

result_send:
	TempBuf.Add(GAME_START_RESULT);
	TempBuf.Add(result);

	if(result != SUCCESS)
	{
		ReInitMemoryDB();

		TempBuf.Add(error_code);
		Send(TempBuf, TempBuf.GetLength());
//		SockCloseProcess();
		return;
	}
	
	SendCharData();										// 蜡历狼 惑技 沥焊甫 焊辰促.

	//TRACE( "Initial Point : %d %d\n", m_curx, m_cury);
	
	TempBuf.Add((short)m_curz);
	TempBuf.Add(m_uid + USER_BAND);
	TempBuf.Add((short)pt.x);
	TempBuf.Add((short)pt.y);

	TempBuf.Add(m_tDir);

	TempBuf.Add((BYTE)g_GameTime);
	TempBuf.Add((BYTE)g_GameMinute);

	Send(TempBuf, TempBuf.GetLength());

	//-------------------------------------------------------------------------
	// SetGameStartInfo() 贸府何;
	{
	SendUserStatusSkill();

	SendWeatherInMoveZone();			// 粮俊辑 朝揪函拳甫 舅酒夯促. 
	SetWeather(1, 0);					// 粮俊辑 矫埃

	m_state = STATE_GAMESTARTED;

	SendMyInfo(TO_INSIGHT, INFO_MODIFY);

	SightRecalc();						// 郴 矫具救狼 沥焊甫 唱俊霸 焊辰促.

	// LOADUSERBANK PROCESS...
	StrToUserBankItem((LPTSTR)ubstrItem);
	m_dwBankDN = ubiDN;
	SetMemUserBank((LPCTSTR)ubstrItem);
	//

	UpdateMemUserAll(TRUE);

	}

	SendSystemMsg( IDS_USER_OPERATOR_MAIL1, SYSTEM_NORMAL, TO_ME);
	SendSystemMsg( IDS_USER_OPERATOR_MAIL2, SYSTEM_NORMAL, TO_ME);
*/
}

void USER::DressingWindowOpen()
{
	CBufferEx TempBuf;

	TempBuf.Add(DRESSING_WINDOW_OPEN);

	Send(TempBuf, TempBuf.GetLength());
}

void USER::DressingReq(TCHAR *pBuf)
{
	int index = 0;

	int itemslot = (int)GetShort( pBuf, index );
	int itemcount = (int)GetShort( pBuf, index );

	int i = 0;

	CItemTable* pItem = NULL;
	ItemList* pOrgItem = NULL;

	DRESSING_DATA* pDS = NULL;

	int makecount = itemcount / 10;
	int termcount = 0;
	int randseed[200];
	int randcount = 0;
	int randindex = 0;
	int randresult = -1;
	int j = 0;
	int k = 0;

	DressingResultArray arResult;	
	DRESSING_RESULT* pNewDRResult = NULL;
	BOOL bSameExist = FALSE;

	ItemListArray	arEmpty, arSame;
	CWordArray		arEmptySlot, arSameSlot;
	ItemList		MyItem[TOTAL_ITEM_NUM], SameItem[TOTAL_ITEM_NUM];
	int				pTotalEmpty[INVENTORY_NUM];

	short sid = -1, num = -1; 
	int iSlot, iEmptyNum = 0;
	int iWeight = 0;
	int iBasicItemWeight = 0;

	// 函荐 檬扁拳 ------------------------------------------------//
	BOOL bFlag = FALSE;
	DWORD dwCost = 0;

	DWORD dwTemp = m_dwDN;

	ItemList	*pDSItem = NULL;

	CBufferEx TempBuf;

	int iItemSize = g_arItemTable.GetSize();

	if( itemslot < EQUIP_ITEM_NUM || itemslot >= TOTAL_INVEN_MAX )
	{
		// 角菩 内靛 傈价 - 盔籍捞 乐绰 牢亥狼 浇吩 锅龋啊 肋给登菌娇
		SendSystemMsg( IDS_USER_CANT_DRESSING_ITEM, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	if( itemcount >= 32767 || itemcount < 0 )
	{
		// 角菩 内靛 傈价 - 急堡窍妨绰 盔籍狼 俺荐 Overflow
		SendSystemMsg( IDS_USER_INVALID_DRESSING_COUNT, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	if( itemcount % 10 )
	{
		// 角菩 内靛 傈价 - 急堡窍妨绰 盔籍狼 俺荐啊 10俺窜困啊 酒丛
		SendSystemMsg( IDS_USER_DRESSING_COUNT_FORMAT, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	pOrgItem = &m_UserItem[itemslot];

	if( !pOrgItem )
	{
		// 角菩 内靛 傈价 - 牢亥俊辑 盔籍阑 茫阑 荐 绝澜
		SendSystemMsg( IDS_USER_CANT_DRESSING, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}
	
	if( m_UserItem[itemslot].sSid >= 0 && m_UserItem[itemslot].sSid < g_arItemTable.GetSize() )
	{
		pItem = g_arItemTable[m_UserItem[itemslot].sSid];
	}

	if( !pItem )
	{
		// 角菩 内靛 傈价 - 酒捞袍 抛捞喉俊辑 酒捞袍 茫阑 荐 绝澜
		SendSystemMsg( IDS_USER_CANT_DRESSING_ITEM, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	if( pItem->m_byWear != 107 )
	{
		// 角菩 内靛 傈价 - 急堡且 荐 绝绰 酒捞袍
		SendSystemMsg( IDS_USER_CANT_DRESSING_ITEM, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	if( m_UserItem[itemslot].sCount < itemcount )
	{
		// 角菩 内靛 傈价 - 酒捞袍 抛捞喉俊辑 酒捞袍 茫阑 荐 绝澜
		SendSystemMsg( IDS_USER_INVALID_DRESSING_COUNT, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	iBasicItemWeight = pItem->m_byWeight * itemcount;

	for( i = 0; i < g_arDressingData.GetSize(); i++ )
	{
		if( g_arDressingData[i] )
		{
			if( g_arDressingData[i]->sItemSid == pItem->m_sSid )
			{
				pDS = g_arDressingData[i];
				break;
			}
		}
	}

	if( !pDS )
	{
		// 角菩 内靛 傈价 - 急堡 抛捞喉俊辑 秦寸 盔籍阑 茫阑 荐 绝澜
		SendSystemMsg( IDS_USER_CANT_DRESSING_ITEM, SYSTEM_ERROR, TO_ME);
		bFlag = TRUE; goto go_dressing_result;
	}

	for( i = 0; i < makecount; i++ )
	{
		termcount = myrand( pDS->sCountMin, pDS->sCountMax );

		// 酒捞袍 急沥 罚待 矫靛 檬扁拳
		for( j = 0; j < 200; j++ )
		{
			randseed[j] = -1;
		}

		randindex = 0;
		for( j = 0; j < 10; j++ )
		{
			for( k = 0; k < pDS->sItemRatio[j]; k++ )
			{
				if( randindex >= 100 ) break;

				randseed[randindex] = pDS->sItem[j];
				randindex++;
			}
		}

		for( j = 0; j < termcount; j++ )
		{
			randcount = myrand( 0, 99 );

			randresult = randseed[randcount];

			if( randresult < 0 )
			{
				// 角菩 内靛 傈价 - 抛捞喉 沥焊啊 肋给 涝仿登绢 乐促(酒捞袍 急沥 犬伏捞 配呕 100捞 酒聪促)
				SendSystemMsg( IDS_USER_CANT_DRESSING, SYSTEM_ERROR, TO_ME);
				bFlag = TRUE; goto go_dressing_result;
			}

			bSameExist = FALSE;
			for( k = 0; k < arResult.GetSize(); k++ )
			{
				if( arResult[k] )
				{
					if( arResult[k]->sSid == randresult )
					{
						arResult[k]->sCount++;
						bSameExist = TRUE;
						break;
					}
				}
			}

			if( !bSameExist )
			{
				pNewDRResult = new DRESSING_RESULT;
				pNewDRResult->sSid = randresult;
				pNewDRResult->sCount = 1;
				arResult.Add( pNewDRResult );
			}
		}
	}

	if( arResult.GetSize() == 0 )
	{
		// 角菩 内靛 傈价 - 父甸绢柳 巴捞 绝促
		SendSystemMsg( IDS_USER_DRESSING_NO_RESULT, SYSTEM_ERROR, TO_ME);
//		bFlag = TRUE; goto go_dressing_result;
	}

	for(i = 0; i < TOTAL_ITEM_NUM; i++)		// 酒捞袍 沥焊 归诀
	{
		MyItem[i] = m_UserItem[i];
		SameItem[i] = m_UserItem[i];
	}

	arSameSlot.RemoveAll();
	arSame.RemoveAll();
	arEmpty.RemoveAll();
	arEmptySlot.RemoveAll();

	::ZeroMemory(pTotalEmpty, sizeof(pTotalEmpty));

	GetEmptyInvenSlot(pTotalEmpty);

	char strResult[1024];
	char strTempResult[128];
	sprintf( strResult, _ID(IDS_USER_DRESSING_RESULT) );

	// 急堡 搬苞 格废 ---------------------------------------------------//
	for( i = 0; i < arResult.GetSize(); i++ )
	{
		if( !arResult[i] ) continue;

		iSlot = -1;

		sid = (short)arResult[i]->sSid;
		num = (short)arResult[i]->sCount;

		if(iEmptyNum > INVENTORY_NUM) { bFlag = TRUE; goto go_dressing_result; }
		if(sid < 0 || num <= 0 || sid > iItemSize) { bFlag = TRUE; goto go_dressing_result; }

		pDSItem = NULL;
		pDSItem = new ItemList;
		if(pDSItem == NULL) { bFlag = TRUE; goto go_dressing_result; }

		ReSetItemSlot(pDSItem);

		pDSItem->sLevel = g_arItemTable[sid]->m_byRLevel;
		pDSItem->sSid = sid;
		pDSItem->sCount = num;
		pDSItem->sDuration = g_arItemTable[sid]->m_sDuration;
		pDSItem->sBullNum = g_arItemTable[sid]->m_sBullNum;
		for( k =0; k< MAGIC_NUM; k++ ) pDSItem->tMagic[k] = 0;
		pDSItem->tIQ = 0;
		pDSItem->iItemSerial = 0;

		sprintf( strTempResult, "%s(%d) ", g_arItemTable[sid]->m_strName, num );
		strcat( strResult, strTempResult );

		iSlot = GetSameItem(*pDSItem, INVENTORY_SLOT);

		if(iSlot != -1)
		{ 
			if(num != 0)
			{
				pDSItem->sCount = num;
				arSame.Add(pDSItem); 
				arSameSlot.Add(iSlot); 

				iWeight += g_arItemTable[sid]->m_byWeight * num;
			}
		}
		else			
		{
			iSlot = pTotalEmpty[iEmptyNum];
//			if(iSlot == 0) { bFlag = TRUE; goto go_dressing_result; }
			if(iSlot == 0) 
			{ 
				CPoint ptCell = FindNearRandomPoint(m_curx, m_cury);

				if(ptCell.x < 0 || ptCell.y < 0) { if(pDSItem) { delete pDSItem; pDSItem = NULL; } continue; }
				if(ptCell.x >= g_zone[m_ZoneIndex]->m_sizeMap.cx || ptCell.y >= g_zone[m_ZoneIndex]->m_sizeMap.cy) { if(pDSItem) { delete pDSItem; pDSItem = NULL; } continue; }

				if(InterlockedCompareExchange((PVOID*)&g_zone[m_ZoneIndex]->m_pMap[ptCell.x][ptCell.y].m_FieldUse, (PVOID)1, (PVOID)0) == (PVOID*)0)
				{
					if(m_iMaxWeight < m_iCurWeight + iWeight - iBasicItemWeight)
					{
						::InterlockedExchange(&g_zone[m_ZoneIndex]->m_pMap[ptCell.x][ptCell.y].m_FieldUse, 0);

						if(pDSItem) { delete pDSItem; pDSItem = NULL; }

						SendSystemMsg( IDS_USER_OVER_WEIGHT1, SYSTEM_ERROR, TO_ME);
						goto go_dressing_result;
					}

					pDSItem->tType = TYPE_ITEM;
					pDSItem->uid[0] = m_uid;				// 快急 鉴困
					pDSItem->SuccessRate[0] = (BYTE)100;	// 快急 鉴困 厚啦
					pDSItem->dwTime = ConvertCurTimeToSaveTime();

					m_pCom->DelThrowItem();
					m_pCom->SetThrowItem( pDSItem, ptCell.x, ptCell.y, m_ZoneIndex );

					::InterlockedExchange(&g_zone[m_ZoneIndex]->m_pMap[ptCell.x][ptCell.y].m_FieldUse, 0);
				}
				else 
				{
					if(pDSItem) { delete pDSItem; pDSItem = NULL; }
				}
			}
			else
			{
				arEmpty.Add(pDSItem); 
				arEmptySlot.Add(iSlot); 
				iEmptyNum++;

				iWeight += g_arItemTable[sid]->m_byWeight * num;
			}
		}		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -