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

📄 3droledata.cpp

📁 网络游戏魔域源代码 测试可以完整变异
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// 3DRoleData.cpp: implementation of the C3DRoleData class.
//
//////////////////////////////////////////////////////////////////////


#include "basefunc.h"
#include "3DRoleData.h"
#include "3DSimpleObj.h"
#include "GameDataSet.h"

// const...
const DWORD _ACTION_UNIVERSAL	= 999;
const DWORD _LOOKTYPE_UNIVERSAL = 999;
const DWORD _WEAPONTYPE_UNIVERSAL = 999;
const DWORD _PARTTYPE_UNIVERSAL = 999;
const DWORD _VARIABLE_UNIVERSAL = 999;

const char INI_EFFECT[]	="ini/effect.ini"; 

// gobal...
C3DRoleData g_obj3DRoleData;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
DWORD RolePartInfoStr2ID( const char* str )
{
	int i;
	unsigned int v;
	static unsigned m[70];
	strncpy((char *)m,str,256);
	for (i=0;i<256/4 && m[i];i++) ;
	m[i++]=0x9BE74448,m[i++]=0x66F42C48;
	v=0xF4FA8928;

	__asm {
		mov esi,0x37A8470E		;x0=0x37A8470E
		mov edi,0x7758B42B		;y0=0x7758B42B
		xor ecx,ecx
_loop:
		mov ebx,0x267B0B11		;w=0x267B0B11
		rol v,1
		lea eax,m
		xor ebx,v

		mov eax,[eax+ecx*4]
		mov edx,ebx
		xor esi,eax
		xor edi,eax

		add edx,edi
		or edx,0x2040801		;a=0x2040801
		and edx,0xBFEF7FDF		;c=0xBFEF7FDF

		mov eax,esi
		mul edx
		adc eax,edx
		mov edx,ebx
		adc eax,0

		add edx,esi
		or edx,0x804021			;b=0x804021
		and edx,0x7DFEFBFF		;d=0x7DFEFBFF

		mov esi,eax
		mov eax,edi
		mul edx

		add edx,edx
		adc eax,edx
		jnc _skip
		add eax,2
_skip:
		inc ecx;
		mov edi,eax
		cmp ecx,i
		jnz _loop
		xor esi,edi
		mov v,esi
	}
	return v;
}
//////////////////////////////////////////////////////////////////////

C3DRoleData::C3DRoleData()
{
}

C3DRoleData::~C3DRoleData()
{
	this->DestroyEffectLookSetInfo();
	this->DestoryWeaponInfo();
	this->DestroyActionDelayInfo();
	this->DestroyActionInfo();
	this->Destroy3DEffectInfo();
	this->DestroyWeaponCombinInfo();
	this->DestroySoundInfo();
	this->DestroyMonsterInfo();
	this->DestroyActionMapEffectInfo();
	this->DestroyMy3DEffectInfo();
	this->DestroyRolePartInfo();
	this->DestroyTransFormInfo();
	this->DestroyNpcTypeInfo();
	this->DestroySimpleObjInfo();
	this->DestroyEffectInfo();
	this->DestroyMapMagicItemInfo();
	this->DestroyPkTitleInfo();
	this->DestroyFlyObjInfo();
	this->DestroyTerrainWeatherInfo();
	this->DestroyStatusEffectInfo();
	this->DestroyUserHelpInfo();
	this->DestroyTerrainNpcTypeInfo();
	this->DestroyTipsInfo();
	this->DestroyTextAction();
	this->DestroyPetInfo();
	this->DestroyRolePartInfo();
	this->DestroyRolePartLightInfo();
	this->Destroy3DItemInfo();
	this->DestroyMedalInfo();
	this->DestroyNobilityTitleInfo();
	this->DestroyHonorTitleInfo();
	
	this->DestroyRolePartLightInfo();
	this->Destroy3DItemInfo();
	this->DestroyMedalInfo();
	this->DestroyNobilityTitleInfo();
	this->DestroyHonorTitleInfo();
	this->DestroyLightInfo();
	this->DestroyTrackInfo();
	this->DestroyEffectIndexInfo();
	this->DestroyActionCtrlInfo();
	this->DestroyActionDelayInfo();
}

//---------------------------------------------------------------------
void C3DRoleData::Init()
{
	this->CreateActionInfo();
	this->Create3DEffectInfo();
	this->CreateWeaponCombinInfo();
	this->CreateRolePartInfo();
	this->CreateSoundInfo();
	this->CreateMonsterInfo();
	this->CreateMy3DEffectInfo();
	this->LoadCommonIni();
	//this->CreateTransFormInfo();
	this->Create3DSimpleObjInfo();
	this->CreateNpcTypeInfo();
	//this->CreatePkTitleInfo();
	this->CreateEffectInfo();
	this->CreateMapMagicItemInfo();
	//this->CreateFlyObjInfo();
	//this->CreateTerrainWeatherInfo();
	this->CreateStatusEffectInfo();
	this->CreateUserHelpInfo();
	//this->CreateTerrainNpcTypeInfo();
	//this->CreateTipsInfo();
	this->CreateTextAction();
	this->CreatePetInfo();
	this->CreateLightLInfo();
	this->CreateRolePartLightInfo();
	this->Create3DItemInfo();
	this->CreateMedalInfo();
	this->CreateNobilityTitleInfo();
	this->CreateHonorTitleInfo();

	this->CreateEffectIndexInfo();

	this->CreateActionMapEffectInfo();
	
	this->CreateTrackInfo();
	this->CreateActionCtrlInfo();
	this->CreateActionDelayInfo();
	this->CreateWeaponInfo();

	this->CreateEffectLookSetInfo();
}

//---------------------------------------------------------------------
void C3DRoleData::DestroySoundInfo()
{
	m_setSoundInfo.clear();
}
//---------------------------------------------------------------------
void C3DRoleData::DestroyMonsterInfo()
{
	int nAmount = m_setMonsterInfo.size();
	for(int i = nAmount-1; i >= 0; i --)
	{
		CMonsterInfo* pInfo = m_setMonsterInfo[i];
		SAFE_DELETE(pInfo);
	}
	m_setMonsterInfo.clear();
}
//---------------------------------------------------------------------
BOOL C3DRoleData::CreateActionInfo()
{
	m_setActionInfo.clear();
	char szDataFile[]="ini/Action.dat";
	FILE* fp = fopen(szDataFile, "rb");
	if (!fp)
	{
		::ErrorOut("Open file %s error", szDataFile);
		return false;
	}
	
	DWORD dwAmount;
	fread(&dwAmount, sizeof(DWORD), 1, fp);

	// ActionInfo
	typedef struct 
	{
		DWORD	dwCheck1;
		DWORD	dwActionIndex;
		DWORD	dwCheck2;
		DWORD	dwTimeInterval;
		DWORD	dwCheck3;
	}ActionFileImage;
	for(int i = 0; i < dwAmount; i++)
	{
		ActionFileImage imageInfo;
		fread(&imageInfo, sizeof(ActionFileImage), 1, fp);		
		DWORD dwCheck1 = imageInfo.dwActionIndex * 2 + imageInfo.dwTimeInterval + i;
		DWORD dwCheck2 = i*dwCheck1 + imageInfo.dwActionIndex*imageInfo.dwTimeInterval - i;
		DWORD dwCheck3 = dwCheck1*imageInfo.dwActionIndex + dwCheck2*7 + imageInfo.dwTimeInterval*i;
		BOOL bCheckOk = true;
		if(dwCheck1 != imageInfo.dwCheck1)
			bCheckOk = false;
		if(dwCheck2 != imageInfo.dwCheck2)
			bCheckOk = false;
		if(dwCheck3 != imageInfo.dwCheck3)
			bCheckOk = false;
		if(!bCheckOk)
			MYASSERT(false);
		m_setActionInfo[imageInfo.dwActionIndex]=imageInfo.dwTimeInterval;
	}

	fclose(fp);
	return true;
}
//---------------------------------------------------------------------
void C3DRoleData::DestroyActionInfo()
{
	m_setActionInfo.clear();
}
//---------------------------------------------------------------------
DWORD C3DRoleData::GetActionTimeInterval(DWORD dwActionIndex)
{
	map<OBJID, DWORD>::iterator iter = m_setActionInfo.find(dwActionIndex);
	if (iter != m_setActionInfo.end())
	{
		return iter->second;
	}
	else
	{
		// LOOK 通配
		DWORD dwMyIndex = dwActionIndex%1000000 + 999*1000000;
		iter = m_setActionInfo.find(dwMyIndex);
		if (iter != m_setActionInfo.end())
		{
			return iter->second;
		}
		else
		{
			// weapon 通配
			DWORD dwMyIndex = dwActionIndex%1000 + 999*1000 + dwActionIndex/1000000*1000000;
			iter = m_setActionInfo.find(dwMyIndex);
			if (iter != m_setActionInfo.end())
			{
				return iter->second;
			}
			else
			{
				// 全通配
				DWORD dwMyIndex = dwActionIndex%1000 + 999*1000 + 999*1000000;
				iter = m_setActionInfo.find(dwMyIndex);
				if (iter != m_setActionInfo.end())
				{
					return iter->second;
				}
			}
		}
	}

	//MYASSERT(false);
	return 33;
}
//---------------------------------------------------------------------
BOOL C3DRoleData::CreateWeaponCombinInfo()
{
	const char szIniFile[]="ini/WeaponCombin.ini";

	FILE* fp =fopen(szIniFile, "r");
	if (!fp)
		return false;

	while (true)
	{
		DWORD idxRWeapon = 0, idxLWeapon = 0;
		int rval = fscanf(fp, "%u.%u\n", &idxRWeapon, &idxLWeapon);
		if (rval == EOF)
			break;

		WeaponCombinInfo* pInfo = new WeaponCombinInfo;
		MYASSERT (pInfo);

		pInfo->idxRWeapon = idxRWeapon;
		pInfo->idxLWeapon = idxLWeapon;

		m_setWeaponCombinInfo.push_back(pInfo);
	}
	fclose(fp);
	return true;
}
//---------------------------------------------------------------------
void C3DRoleData::DestroyWeaponCombinInfo()
{
	int nAmount = m_setWeaponCombinInfo.size();
	for(int i = 0; i < nAmount; i++)
	{
		WeaponCombinInfo* pInfo = m_setWeaponCombinInfo[i];
		SAFE_DELETE(pInfo);
	}

	m_setWeaponCombinInfo.clear();
}
//---------------------------------------------------------------------
BOOL C3DRoleData::CanWeaponCombin(DWORD idxRWeapon, DWORD idxLWeapon)
{
	int nAmount = m_setWeaponCombinInfo.size();
	for(int i = 0; i < nAmount; i++)
	{
		WeaponCombinInfo* pInfo = m_setWeaponCombinInfo[i];
		if (pInfo->idxRWeapon == idxRWeapon &&
				pInfo->idxLWeapon == idxLWeapon)
			return true;
	}

	return false;
}

//---------------------------------------------------------------------
BOOL C3DRoleData::Create3DEffectInfo()
{

	m_setGame3DEffectInfo.clear();

	const char szIniFile[]="ini/Action3DEffect.ini";
	FILE* fp =fopen(szIniFile, "r");
	if (!fp)
		return false;

	while (true)
	{
		char szLine[1024] = "";
		if (EOF == fscanf(fp, "%s\n", szLine))
			break;

		DWORD idxAction = 0, idxPart = 0, idxVar = 0, nLook = 0;
		char szEffect[256] = "";
		if (5 != sscanf(szLine, "%u.%u.%u.%u=%s", &nLook, &idxAction, &idxPart, &idxVar, szEffect))
		{
			::ErrorMsg("invalid line [%s] found in %s.", szLine, szIniFile);
			continue;
		}
		__int64 id = nLook * 1000000000 + idxAction * 1000000 + idxPart * 1000 + idxVar;
		m_setGame3DEffectInfo[id]=szEffect;
	}
	fclose(fp);
	return true;
}

//---------------------------------------------------------------------
void C3DRoleData::Destroy3DEffectInfo()
{
	m_setGame3DEffectInfo.clear();
}

//---------------------------------------------------------------------
const char* C3DRoleData::GetRolePart3DEffect(DWORD dwLook, DWORD idxAction, DWORD idxPart, DWORD idxVar)
{
	__int64 id = dwLook * 1000000000 + idxAction * 1000000 + idxPart * 1000 + idxVar;
	map<__int64, string>::iterator iter = m_setGame3DEffectInfo.find(id);
	if (iter != m_setGame3DEffectInfo.end())
		return iter->second.c_str();

	// wildcard_LOOKTYPE_UNIVERSAL
	id = dwLook * 1000000000 + _ACTION_UNIVERSAL * 1000000 + idxPart * 1000 + idxVar;
	iter = m_setGame3DEffectInfo.find(id);
	if (iter != m_setGame3DEffectInfo.end())
		return iter->second.c_str();

	id = dwLook * 1000000000 + idxAction * 1000000 + _WEAPONTYPE_UNIVERSAL * 1000 + idxVar;
	iter = m_setGame3DEffectInfo.find(id);
	if (iter != m_setGame3DEffectInfo.end())
		return iter->second.c_str();

	id = dwLook * 1000000000 + idxAction * 1000000 + idxPart * 1000 + _VARIABLE_UNIVERSAL;
	iter = m_setGame3DEffectInfo.find(id);
	if (iter != m_setGame3DEffectInfo.end())
		return iter->second.c_str();

	return NULL;
}


//---------------------------------------------------------------------
void C3DRoleData::CreateSoundInfo(void)
{
	const char szIniFile[]="ini/ActionSound.ini";
	
	FILE* fp = fopen(szIniFile, "r");
	IF_NOT (fp)
		return;

	while (true)
	{
		char szLine[1024] = "";
		if (EOF == fscanf(fp, "%s\n", szLine))
		{
			fclose(fp);
			return;
		}

		DWORD idxLook, idxAction, idxWeapon, dwTerrain;
		char szSound[256] = "";
		if (5 != sscanf(szLine, "%u.%u.%u.%u=%s", &dwTerrain, &idxLook, &idxWeapon, &idxAction, szSound))
		{
			fclose(fp);

			::ErrorOut("error line:[%s] in %s!", szLine, szIniFile);
			return;
		}

		MYASSERT (strlen(szSound) < 128);

		// new sound info

		__int64 id = dwTerrain*1000000000 + idxLook*1000000 + idxWeapon*1000+idxAction;
		m_setSoundInfo[id]=szSound;
	}
}

//---------------------------------------------------------------------
const char* C3DRoleData::GetActionSound(DWORD dwTerrain, DWORD idxLook, DWORD idxWeapon, DWORD idxAction)
{
	if (idxAction == _ACTION_STANDBY)
		return NULL;

	__int64 id = dwTerrain * 1000000000 + idxLook*1000000 + idxWeapon*1000+idxAction;
	map<__int64, string>::iterator iter = m_setSoundInfo.find(id);
	if (iter != m_setSoundInfo.end())
	{
		return iter->second.c_str();
	}

	id = dwTerrain * 1000000000 + idxLook*1000000 + 999*1000+idxAction;
	iter = m_setSoundInfo.find(id);
	if (iter != m_setSoundInfo.end())
	{
		return iter->second.c_str();
	}

	id = idxLook*1000000 + idxWeapon*1000+idxAction;
	iter = m_setSoundInfo.find(id);
	if (iter != m_setSoundInfo.end())
	{
		return iter->second.c_str();
	}

	id = idxLook*1000000 + 999*1000+idxAction;
	iter = m_setSoundInfo.find(id);
	if (iter != m_setSoundInfo.end())
	{
		return iter->second.c_str();
	}

	return NULL;
}

//---------------------------------------------------------------------

⌨️ 快捷键说明

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