Jump to content

Reload estendido


F-Caneiras
 Share

Recommended Posts

Boas a todos seguindo o topico anterior .

https://m2dev.net/topic/2522-reload-mob_drop_item/

Aqui deixo  a função completa para todos os ficheiros .

Descrição e comandos:

Comandos e o que fazem os mesmos?

 

Shop_item table: ( lojas e npc ) comando a ser usado - /reload p

item_attr && item_attr_rare table: comando a ser usado - /reload p

etc_drop_item.txt, mob_drop_item.txt, special_item_group.txt: comando a ser usado - /reload drop

group.txt, group_group.txt; comando a ser usado /reload group

regen.txt, npc.txt, boss.txt, stone.txtcomando a ser usado  /reload regen usado no mapa corrente  em cada mapa 

 

Bom vamos ao tuto.

 

vamos a game/src/ procuramos cmd.cpp.

Adicionar no topo onde tem mais ACMDs no meu caso meti no final de todos.

Spoiler
ACMD(do_free_regen);

 

 Agora debaixo de:

Spoiler
	{ "who",		do_who,			0,			POS_DEAD,	GM_IMPLEMENTOR	},

 

Adicionamos 

Spoiler
	{ "free_regens", do_free_regen,	0,			POS_DEAD,	GM_IMPLEMENTOR	},

 

Ir a  game/src/ procuramos cmd_gm.cpp

Adicionar no final do ficheiro 

Spoiler
ACMD(do_free_regen)
{
	ch->ChatPacket(CHAT_TYPE_INFO, "freeing regens on mapindex %ld", ch->GetMapIndex());
	regen_free_map(ch->GetMapIndex());
	ch->ChatPacket(CHAT_TYPE_INFO, "the regens now FREEEE! :)");
}

 

E torcar toda a função do ACMD(do_purge) por esta

Spoiler
ACMD(do_purge)
{
	char arg1[256];
	one_argument(argument, arg1, sizeof(arg1));

	FuncPurge func(ch);

	if (*arg1 && !strcmp(arg1, "map"))
	{
		CHARACTER_MANAGER::instance().DestroyCharacterInMap(ch->GetMapIndex());
	}
	else
	{
		if (*arg1 && !strcmp(arg1, "all"))
			func.m_bAll = true;
		LPSECTREE sectree = ch->GetSectree();
		if (sectree) // #431
			sectree->ForEachAround(func);
		else
			sys_err("PURGE_ERROR.NULL_SECTREE(mapIndex=%d, pos=(%d, %d)", ch->GetMapIndex(), ch->GetX(), ch->GetY());
	}
}

 

Na função ACMD(do_reload) procurar:

Spoiler
			case 'c':	// cube
				// ¡¤IA? CA¡¤I??¢©?¢¬¢¬ ¡Æ¡í¡í?C?¢¥?.
				Cube_init ();
				break;

 

Adicionar a baixo de break isto

Spoiler
			default:
				const int FILE_NAME_LEN = 256;
				if (strstr(arg1, "drop"))
				{
					char szETCDropItemFileName[FILE_NAME_LEN];
					char szMOBDropItemFileName[FILE_NAME_LEN];
					char szSpecialItemGroupFileName[FILE_NAME_LEN];

					snprintf(szETCDropItemFileName, sizeof(szETCDropItemFileName),
						"%s/etc_drop_item.txt", LocaleService_GetBasePath().c_str());
					snprintf(szMOBDropItemFileName, sizeof(szMOBDropItemFileName),
						"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
					snprintf(szSpecialItemGroupFileName, sizeof(szSpecialItemGroupFileName),
						"%s/special_item_group.txt", LocaleService_GetBasePath().c_str());

					ch->ChatPacket(CHAT_TYPE_INFO, "Reloading: ETCDropItem: %s", szETCDropItemFileName);
					if (!ITEM_MANAGER::instance().ReadEtcDropItemFile(szETCDropItemFileName, true))
						ch->ChatPacket(CHAT_TYPE_INFO, "failed to reload ETCDropItem: %s", szETCDropItemFileName);
					else
						ch->ChatPacket(CHAT_TYPE_INFO, "reload success: ETCDropItem: %s", szETCDropItemFileName);

					ch->ChatPacket(CHAT_TYPE_INFO, "Reloading: SpecialItemGroup: %s", szSpecialItemGroupFileName);
					if (!ITEM_MANAGER::instance().ReadSpecialDropItemFile(szSpecialItemGroupFileName, true))
						ch->ChatPacket(CHAT_TYPE_INFO, "failed to reload SpecialItemGroup: %s", szSpecialItemGroupFileName);
					else
						ch->ChatPacket(CHAT_TYPE_INFO, "reload success: SpecialItemGroup: %s", szSpecialItemGroupFileName);

					ch->ChatPacket(CHAT_TYPE_INFO, "Reloading: MOBDropItemFile: %s", szMOBDropItemFileName);
					if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroup(szMOBDropItemFileName, true))
						ch->ChatPacket(CHAT_TYPE_INFO, "failed to reload MOBDropItemFile: %s", szMOBDropItemFileName);
					else
						ch->ChatPacket(CHAT_TYPE_INFO, "reload success: MOBDropItemFile: %s", szMOBDropItemFileName);
				}
				else if (strstr(arg1, "group"))
				{
					char szGroupFileName[FILE_NAME_LEN];
					char szGroupGroupFileName[FILE_NAME_LEN];

					snprintf(szGroupFileName, sizeof(szGroupGroupFileName),
						"%s/group.txt", LocaleService_GetBasePath().c_str());
					snprintf(szGroupGroupFileName, sizeof(szGroupGroupFileName),
						"%s/group_group.txt", LocaleService_GetBasePath().c_str());

					ch->ChatPacket(CHAT_TYPE_INFO, "Reloading: mob groups: %s", szGroupFileName);
					if (!CMobManager::instance().LoadGroup(szGroupFileName, true))
						ch->ChatPacket(CHAT_TYPE_INFO, "failed to reload mob groups: %s", szGroupFileName);

					ch->ChatPacket(CHAT_TYPE_INFO, "Reloading: mob group group: %s", szGroupGroupFileName);
					if (!CMobManager::instance().LoadGroupGroup(szGroupGroupFileName, true))
						ch->ChatPacket(CHAT_TYPE_INFO, "failed to reload mob group group: %s", szGroupGroupFileName);
				}
				else if (strstr(arg1, "regen"))
				{
					SendNoticeMap("Reloading regens!", ch->GetMapIndex(), false);
					regen_free_map(ch->GetMapIndex());
					CHARACTER_MANAGER::instance().DestroyCharacterInMap(ch->GetMapIndex());
					regen_reload(ch->GetMapIndex());
					SendNoticeMap("Regens reloaded!", ch->GetMapIndex(), false);
				}
				break;

 

Ir para game/src/ procurar input_db.cpp

Procurar

Spoiler
void CInputDB::ReloadProto(const char * c_pData)

 

depois de:

Spoiler
CMotionManager::instance().Build();

 

Adicionar isto

Spoiler
	/*
	* SHOP
	*/

	wSize = decode_2bytes(c_pData);
	c_pData += sizeof(WORD);
	sys_log(0, "RELOAD: SHOP: %d", wSize);


	if (wSize)
	{
		CShopManager::instance().Initialize((TShopTable *)c_pData, wSize);
		c_pData += wSize * sizeof(TShopTable);
	}

	/*
	* REFINE
	*/
	wSize = decode_2bytes(c_pData);
	c_pData += 2;
	sys_log(0, "RELOAD: REFINE: %d", wSize);

	if (wSize)
	{
		CRefineManager::instance().Initialize((TRefineTable *)c_pData, wSize);
		c_pData += wSize * sizeof(TRefineTable);
	}

	/*
	* ATTR
	*/
	wSize = decode_2bytes(c_pData);
	c_pData += 2;
	sys_log(0, "RELOAD: ItemAtt: %d", wSize);

	if (wSize)
	{
		TItemAttrTable * p = (TItemAttrTable *)c_pData;
		g_map_itemAttr.clear();
		for (int i = 0; i < wSize; ++i, ++p)
		{
			if (p->dwApplyIndex >= MAX_APPLY_NUM)
				continue;

			g_map_itemAttr[p->dwApplyIndex] = *p;
			sys_log(0, "ITEM_ATTR[%d]: %s %u", p->dwApplyIndex, p->szApply, p->dwProb);
		}
		c_pData += wSize*sizeof(TItemAttrTable);
	}

	/*
	* ATTR_RARE
	*/
	wSize = decode_2bytes(c_pData);
	c_pData += 2;
	sys_log(0, "RELOAD: ItemRareAtt: %d", wSize);

	if (wSize)
	{
		TItemAttrTable * p = (TItemAttrTable *)c_pData;
		g_map_itemRare.clear();
		for (int i = 0; i < wSize; ++i, ++p)
		{
			if (p->dwApplyIndex >= MAX_APPLY_NUM)
				continue;

			g_map_itemRare[p->dwApplyIndex] = *p;
			sys_log(0, "ITEM_RARE[%d]: %s %u", p->dwApplyIndex, p->szApply, p->dwProb);
		}
		c_pData += wSize*sizeof(TItemAttrTable);
	}

 

Ir para game/src/ procurar shop_manager.cpp

Encontrar 

Spoiler
bool CShopManager::Initialize(TShopTable * table, int size

 

E trocamos 

Spoiler
	if (!m_map_pkShop.empty())
		return false;

 

por 

Spoiler
	if (!m_map_pkShop.empty())
	{
		for (TShopMap::iterator it = m_map_pkShop.begin(); it != m_map_pkShop.end(); it++)
		{
			it->second->RemoveAllGuests();
		}
	}

	m_map_pkShop.clear();
	m_map_pkShopByNPCVnum.clear();

 

Ir para game/src/ e procuramos refine.cpp

Insserir no topo da  função;  bool CRefineManager::Initialize(TRefineTable * table, int size)

Spoiler
	m_map_RefineRecipe.clear();

 

Ir para game/src/ e procurar char_manager.cpp

Adicionar no final do ficheiro

Spoiler
void CHARACTER_MANAGER::DestroyCharacterInMap(long lMapIndex)
{
	std::vector<LPCHARACTER> tempVec;
	for (itertype(m_map_pkChrByVID) it = m_map_pkChrByVID.begin(); it != m_map_pkChrByVID.end(); it++)
	{
		LPCHARACTER pkChr = it->second;
		if (pkChr && pkChr->GetMapIndex() == lMapIndex && pkChr->IsNPC() && !pkChr->IsPet() && pkChr->GetRider() == NULL)
		{
			tempVec.push_back(pkChr);
		}
	}
	for (std::vector<LPCHARACTER>::iterator it = tempVec.begin(); it != tempVec.end(); it++)
	{
		DestroyCharacter(*it);
	}
}

 

ir para game/src/ char_manager.h

Procuramos:

Spoiler
void			Update(int iPulse);

 

adicionamos a baixo

Spoiler
void DestroyCharacterInMap(long lMapIndex);

 

Ir para game/src/ procuramos item_manager.h

Trocar 

Spoiler
Spoiler

        bool            ReadEtcDropItemFile(const char * c_pszFileName);
        bool            ReadMonsterDropItemGroup(const char * c_pszFileName);
        bool            ReadSpecialDropItemFile(const char * c_pszFileName);

 

 

por 

Spoiler
		bool			ReadEtcDropItemFile(const char * c_pszFileName, bool isReloading = false);
		bool			ReadMonsterDropItemGroup(const char * c_pszFileName, bool isReloading = false);
		bool			ReadSpecialDropItemFile(const char * c_pszFileName, bool isReloading = false);

 

ir para game/src/ procuramos item_manager_read_tables.cpp

Primeiro trocamos 

Spoiler
bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName)

 

por 

Spoiler
bool ITEM_MANAGER::ReadEtcDropItemFile(const char * c_pszFileName, bool isReloading)

 

Agora dentro da função 

Spoiler
char buf[512]

 

add isto 

Spoiler
	std::map<DWORD, DWORD> tempLoader;
	if (isReloading)
	{
		sys_log(0, "RELOADING EtcDrop");
	}

 

E trocamos 

Spoiler
m_map_dwEtcItemDropProb[dwItemVnum] = (DWORD) (fProb * 10000.0f);

 

por

Spoiler
		if (isReloading)
			tempLoader[dwItemVnum] = (DWORD)(fProb * 10000.0f);
		else
			m_map_dwEtcItemDropProb[dwItemVnum] = (DWORD) (fProb * 10000.0f);

 

Adicionar a baixo de return true; que pode ser encontrado no final da função isto

Spoiler
	if (isReloading)
	{
		m_map_dwEtcItemDropProb.clear();
		for (std::map<DWORD, DWORD>::iterator it = tempLoader.begin(); it != tempLoader.end(); it++)
		{
			m_map_dwEtcItemDropProb[it->first] = it->second;
		}
	}

 

Muito bem terminamos esta função agora procuramos 

Spoiler
bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName)

 

e trocamos por 

Spoiler
bool ITEM_MANAGER::ReadSpecialDropItemFile(const char * c_pszFileName, bool isReloading)

 

Agora vamos trabalhar na função 

Procuramos

o primeiro for dentro da função e depois disso add 

Spoiler
	std::map<DWORD, CSpecialAttrGroup*> tempSpecAttr;
	std::map<DWORD, CSpecialItemGroup*> tempSpecItem;
	std::map<DWORD, CSpecialItemGroup*> tempSpecItemQuest;
	if (isReloading)
		sys_log(0, "RELOADING SpecialDrop");

 

e trocamos 

Spoiler
m_map_pkSpecialAttrGroup.insert(std::make_pair(iVnum, pkGroup));

 

por

Spoiler
			if (isReloading)
				tempSpecAttr.insert(std::make_pair(iVnum, pkGroup));
			else
				m_map_pkSpecialAttrGroup.insert(std::make_pair(iVnum, pkGroup));

 

trocamos tambem 

Spoiler

			if (CSpecialItemGroup::QUEST == type)
			{
				m_map_pkQuestItemGroup.insert(std::make_pair(iVnum, pkGroup));
			}
			else
			{
				m_map_pkSpecialItemGroup.insert(std::make_pair(iVnum, pkGroup));
			}

 

por

Spoiler

			if (CSpecialItemGroup::QUEST == type)
			{
				if (isReloading)
					tempSpecItemQuest.insert(std::make_pair(iVnum, pkGroup));
				else
					m_map_pkQuestItemGroup.insert(std::make_pair(iVnum, pkGroup));
			}
			else
			{
				if (isReloading)
					tempSpecItem.insert(std::make_pair(iVnum, pkGroup));
				else
					m_map_pkSpecialItemGroup.insert(std::make_pair(iVnum, pkGroup));
			}

 

e de novo no final da função abaixo de return true; adicionamos

Spoiler
	if (isReloading)
	{
		m_map_pkQuestItemGroup.clear();
		m_map_pkSpecialItemGroup.clear();
		m_map_pkSpecialAttrGroup.clear();

		for (std::map<DWORD, CSpecialAttrGroup*>::iterator it = tempSpecAttr.begin(); it != tempSpecAttr.end(); it++)
		{
			m_map_pkSpecialAttrGroup[it->first] = it->second;
		}

		for (std::map<DWORD, CSpecialItemGroup*>::iterator it = tempSpecItem.begin(); it != tempSpecItem.end(); it++)
		{
			m_map_pkSpecialItemGroup[it->first] = it->second;
		}

		for (std::map<DWORD, CSpecialItemGroup*>::iterator it = tempSpecItemQuest.begin(); it != tempSpecItemQuest.end(); it++)
		{
			m_map_pkQuestItemGroup[it->first] = it->second;
		}
	}

 

vamos trabalhar noutra função de novo  no mesmo ficheiro procuramos 

Spoiler
bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)

 

trocamos por 

Spoiler
bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName, bool isReloading)

 

E vamos editar a função como anterior 

depois do primeiro for  adicionar a baixo 

Spoiler
	std::map<DWORD, CMobItemGroup*> temMobItemGr;
	std::map<DWORD, CDropItemGroup*> tempDropItemGr;
	std::map<DWORD, CLevelItemGroup*> tempLevelItemGr;
	std::map<DWORD, CBuyerThiefGlovesItemGroup*> tempThiefGlovesGr;
	if (isReloading)
	{
		sys_log(0, "RELOADING MonsterDrop");
	}

 

Trocamos 

Spoiler
m_map_pkMobItemGroup.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup));

 

por

Spoiler
			if (isReloading)
				temMobItemGr.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup));
			else
				m_map_pkMobItemGroup.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup));

 

Spoiler
				itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find(iMobVnum);
				if (it == m_map_pkDropItemGroup.end())
				{
					pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName);
				}
				else
				{
					bNew = false;
					CDropItemGroup* pkGroup = it->second;
				}

 

por

Spoiler
			if (isReloading)
			{
				itertype(tempDropItemGr) it = tempDropItemGr.find(iMobVnum);
				if (it == tempDropItemGr.end())
				{
					pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName);
				}
				else
				{
					bNew = false;
					CDropItemGroup* pkGroup = it->second;
				}
			}
			else
			{
				itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find(iMobVnum);
				if (it == m_map_pkDropItemGroup.end())
				{
					pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName);
				}
				else
				{
					bNew = false;
					CDropItemGroup* pkGroup = it->second;
				}
			}

 

no mesmo ficheiro trocamos 

Spoiler
			if (bNew)
				m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup));

 

por

Spoiler
			if (bNew)
			{
				if (isReloading)
					tempDropItemGr.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup));
				else
					m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup));
			}

 

e este 

Spoiler
m_map_pkLevelItemGroup.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup));

 

por este 

Spoiler
			if (isReloading)
				tempLevelItemGr.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup));
			else
				m_map_pkLevelItemGroup.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup));

 

Este 

Spoiler
m_map_pkGloveItemGroup.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup));

 

por este 

Spoiler
			if (isReloading)
				tempThiefGlovesGr.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup));
			else
				m_map_pkGloveItemGroup.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup));

 

Mais uma vez no final da função a baixo de return true; add 

Spoiler
	if (isReloading)
	{
		for (std::map<DWORD, CBuyerThiefGlovesItemGroup*>::iterator it = m_map_pkGloveItemGroup.begin(); it != m_map_pkGloveItemGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkGloveItemGroup.clear();
		for (std::map<DWORD, CLevelItemGroup*>::iterator it = m_map_pkLevelItemGroup.begin(); it != m_map_pkLevelItemGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkLevelItemGroup.clear();
		for (std::map<DWORD, CDropItemGroup*>::iterator it = m_map_pkDropItemGroup.begin(); it != m_map_pkDropItemGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkDropItemGroup.clear();
		for (std::map<DWORD, CMobItemGroup*>::iterator it = m_map_pkMobItemGroup.begin(); it != m_map_pkMobItemGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkMobItemGroup.clear();

		for (std::map<DWORD, CBuyerThiefGlovesItemGroup*>::iterator it = tempThiefGlovesGr.begin(); it != tempThiefGlovesGr.end(); it++)
		{
			m_map_pkGloveItemGroup[it->first] = it->second;
		}

		for (std::map<DWORD, CLevelItemGroup*>::iterator it = tempLevelItemGr.begin(); it != tempLevelItemGr.end(); it++)
		{
			m_map_pkLevelItemGroup[it->first] = it->second;
		}

		for (std::map<DWORD, CDropItemGroup*>::iterator it = tempDropItemGr.begin(); it != tempDropItemGr.end(); it++)
		{
			m_map_pkDropItemGroup[it->first] = it->second;
		}

		for (std::map<DWORD, CMobItemGroup*>::iterator it = temMobItemGr.begin(); it != temMobItemGr.end(); it++)
		{
			m_map_pkMobItemGroup[it->first] = it->second;
		}
	}

 

Ir para game/src/ procurar mob_manager.h

Trocamos 

Spoiler
		bool		LoadGroup(const char * c_pszFileName);
		bool		LoadGroupGroup(const char * c_pszFileName);

 

por

Spoiler
		bool		LoadGroup(const char * c_pszFileName, bool isReloading = false);
		bool		LoadGroupGroup(const char * c_pszFileName, bool isReloading = false);

 

Ir para game/src/ procuramos mob_manager.cpp

trocamos 

Spoiler
bool CMobManager::LoadGroupGroup(const char * c_pszFileName)

 

por

Spoiler
bool CMobManager::LoadGroupGroup(const char * c_pszFileName, bool isReloading)

 

E vamos trabalhar na função 

Adicionar a baixo do primeiro for isto 

Spoiler
	std::map<DWORD, CMobGroupGroup *> tempLoader;
	if (isReloading)
		sys_log(0, "RELOADING group group: %s", c_pszFileName);

 

e trocamos 

Spoiler
m_map_pkMobGroupGroup.insert(std::make_pair((DWORD)iVnum, pkGroup));

 

por

Spoiler
		if (isReloading)
			tempLoader.insert(std::make_pair((DWORD)iVnum, pkGroup));
		else
			m_map_pkMobGroupGroup.insert(std::make_pair((DWORD)iVnum, pkGroup));

 

mais uma vez no final da função a baixo de return true;  adicionamos

Spoiler
	if (isReloading)
	{
		for (std::map<DWORD, CMobGroupGroup *>::iterator it = m_map_pkMobGroupGroup.begin(); it != m_map_pkMobGroupGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkMobGroupGroup.clear();
		for (std::map<DWORD, CMobGroupGroup *>::iterator it = tempLoader.begin(); it != tempLoader.end(); it++)
		{
			m_map_pkMobGroupGroup[it->first] = it->second;
		}
	}

 

bem terminamos a função agora procuramos 

Spoiler
bool CMobManager::LoadGroup(const char * c_pszFileName)

 

trocamos por 

Spoiler
bool CMobManager::LoadGroup(const char * c_pszFileName, bool isReloading)

 

vamos de novo trabalhar na função  de novo a baixo do primeiro for loop 

adicionamos 

Spoiler
	std::map<DWORD, CMobGroup *> tempLoader;
	if (isReloading)
		sys_log(0, "RELOADING groups: %s", c_pszFileName);

 

e trocamos 

Spoiler
m_map_pkMobGroup.insert(std::map<DWORD, CMobGroup *>::value_type(iVnum, pkGroup));

 

por

Spoiler
		if (isReloading)
			tempLoader.insert(std::map<DWORD, CMobGroup *>::value_type(iVnum, pkGroup));
		else
			m_map_pkMobGroup.insert(std::map<DWORD, CMobGroup *>::value_type(iVnum, pkGroup));

 

e no final da função como nas outras a baixo de return true; adicionamos 

Spoiler
	if (isReloading)
	{
		for (std::map<DWORD, CMobGroup *>::iterator it = m_map_pkMobGroup.begin(); it != m_map_pkMobGroup.end(); it++)
			M2_DELETE(it->second);
		m_map_pkMobGroup.clear();
		for (std::map<DWORD, CMobGroup *>::iterator it = tempLoader.begin(); it != tempLoader.end(); it++)
		{
			m_map_pkMobGroup[it->first] = it->second;
		}
	}

 

Ir para game/src/ procuramos em char.cpp

Spoiler
void CHARACTER::Destroy()

 

e vamos trocar 

Spoiler
	if (m_pkRegen)
	{
		if (m_pkDungeon) {
			// Dungeon regen may not be valid at this point
			if (m_pkDungeon->IsValidRegen(m_pkRegen, regen_id_)) {
				--m_pkRegen->count;
			}
		} else {
			// Is this really safe?
			--m_pkRegen->count;
		}
		m_pkRegen = NULL;
	}

 

por

Spoiler
	if (m_pkRegen)
	{
		if (m_pkDungeon) {
			// Dungeon regen may not be valid at this point
			if (m_pkDungeon->IsValidRegen(m_pkRegen, regen_id_)) {
				--m_pkRegen->count;
			}
		} else {
			// Is this really safe? NO IT ISNT! F*CK THAT SH!T!
			if (is_valid_regen(m_pkRegen))
				--m_pkRegen->count;
		}
		m_pkRegen = NULL;
	}

 

ir para game/src/ procurar  sectree_manager.cpp dentro encontrar 

Spoiler
int SECTREE_MANAGER::Build(const char * c_pszListFileName, const char* c_pszMapBasePath)

 

add em baixo de 

Spoiler
			snprintf(szFilename, sizeof(szFilename), "%s/%s/server_attr", c_pszMapBasePath, szMapName);
			LoadAttribute(pkMapSectree, szFilename, setting);

 

isto

Spoiler
			snprintf(szFilename, sizeof(szFilename), "%s/%s/", c_pszMapBasePath, szMapName);
			regen_register_map(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

 

Ir para game/src/ e procuramos regen.h debaixo de 

Spoiler
extern bool	regen_load(const char *filename, long lMapIndex, int base_x, int base_y);

 

adicionamos 

Spoiler
extern void regen_free_map(long lMapIndex);
extern void regen_reload(long lMapIndex);
extern void regen_register_map(const char * szBaseName, long lMapIndex, int base_x, int base_y);
extern bool is_valid_regen(LPREGEN currRegen);

 

Ir para game/src/ e procuramos regen.cpp dentro procuramos 

Spoiler
LPREGEN_EXCEPTION regen_exception_list = NULL;

 

adicionamos a baixo 

Spoiler
typedef struct SMapDataContainer
{
	char szBaseName[256];
	int base_x;
	int base_y;
}TMapDataContainer;

#define mbMapDataCType std::map<DWORD, TMapDataContainer*>
mbMapDataCType mbMapDataContainer;

 

adicionar no final do ficheiro 

Spoiler
bool is_valid_regen(LPREGEN currRegen)
{
	LPREGEN		regen;

	for (regen = regen_list; regen; regen = regen->next)
	{
		if (regen == currRegen)
			return true;
	}
	return false;
}

void regen_free_map(long lMapIndex)
{
	LPREGEN		regen, prev, next;

	for (regen = regen_list; regen; regen = regen->next)
	{
		if (regen->lMapIndex != lMapIndex)
			continue;
		event_cancel(&regen->event);
		REMOVE_FROM_TW_LIST(regen, regen_list, prev, next);
		M2_DELETE(regen);
	}
}

void regen_reload(long lMapIndex)
{
	if (mbMapDataContainer.find(lMapIndex) == mbMapDataContainer.end())
		return;

	char szFilename[256];
	
	snprintf(szFilename, sizeof(szFilename), "%sregen.txt", mbMapDataContainer[lMapIndex]->szBaseName);
	regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);

	snprintf(szFilename, sizeof(szFilename), "%snpc.txt", mbMapDataContainer[lMapIndex]->szBaseName);
	regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);

	snprintf(szFilename, sizeof(szFilename), "%sboss.txt", mbMapDataContainer[lMapIndex]->szBaseName);
	regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);

	snprintf(szFilename, sizeof(szFilename), "%sstone.txt", mbMapDataContainer[lMapIndex]->szBaseName);
	regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);
}

void regen_register_map(const char * szBaseName, long lMapIndex, int base_x, int base_y)
{
	TMapDataContainer* container = new TMapDataContainer;
	memset(container->szBaseName, 0, sizeof(container->szBaseName));
#ifdef __FreeBSD__
	strlcpy(container->szBaseName, szBaseName, sizeof(container->szBaseName) - 1);
#else
	strncpy(container->szBaseName, szBaseName, sizeof(container->szBaseName) - 1);
#endif
	container->base_x = base_x;
	container->base_y = base_y;
	mbMapDataContainer[lMapIndex] = container;
}

 

EVENTFUNC(regen_event)

debaixo de 

Spoiler
LPREGEN	regen = info->regen;

 

add 

Spoiler
	if (!is_valid_regen(regen))
		return 0;

 

Ir para game/src/ procurar shop.h

de baixo de 

Spoiler
		void	RemoveGuest(LPCHARACTER ch);

 

add

Spoiler
		void	RemoveAllGuests();

 

ir para game/src/ procurar shop.cpp

add ao final do ficheiro 

Spoiler
void CShop::RemoveAllGuests()
{
	if (m_map_guest.empty())
		return;
	for (GuestMapType::iterator it = m_map_guest.begin(); it != m_map_guest.end(); it++)
	{
		LPCHARACTER ch = it->first;
		if (ch)
		{
			if (ch->GetDesc() && ch->GetShop() == this)
			{
				ch->SetShop(NULL);

				TPacketGCShop pack;

				pack.header = HEADER_GC_SHOP;
				pack.subheader = SHOP_SUBHEADER_GC_END;
				pack.size = sizeof(TPacketGCShop);

				ch->GetDesc()->Packet(&pack, sizeof(pack));
			}
		}
	}
	m_map_guest.clear();
}

 

Ir a db/src/ procurar  ClientManager.cpp dentro do ficheiro procurar 

Spoiler
void CClientManager::QUERY_RELOAD_PROTO()

 

e troocamos 

Spoiler
		tmp->EncodeHeader(HEADER_DG_RELOAD_PROTO, 0, 
				sizeof(WORD) + sizeof(TSkillTable) * m_vec_skillTable.size() +
				sizeof(WORD) + sizeof(TBanwordTable) * m_vec_banwordTable.size() +
				sizeof(WORD) + sizeof(TItemTable) * m_vec_itemTable.size() +
				sizeof(WORD) + sizeof(TMobTable) * m_vec_mobTable.size());

 

por

Spoiler
		tmp->EncodeHeader(HEADER_DG_RELOAD_PROTO, 0, 
				sizeof(WORD) + sizeof(TSkillTable) * m_vec_skillTable.size() +
				sizeof(WORD) + sizeof(TBanwordTable) * m_vec_banwordTable.size() +
				sizeof(WORD) + sizeof(TItemTable) * m_vec_itemTable.size() +
				sizeof(WORD) + sizeof(TMobTable) * m_vec_mobTable.size() +
				sizeof(WORD) + sizeof(TShopTable) * m_iShopTableSize +
				sizeof(WORD) + sizeof(TRefineTable)* m_iRefineTableSize +
				sizeof(WORD) + sizeof(TItemAttrTable)*m_vec_itemAttrTable.size() +
				sizeof(WORD) + sizeof(TItemAttrTable)*m_vec_itemRareTable.size());

 

debaixo de 

Spoiler
		tmp->EncodeWORD(m_vec_mobTable.size());
		tmp->Encode(&m_vec_mobTable[0], sizeof(TMobTable) * m_vec_mobTable.size());

 

add 

Spoiler

		tmp->EncodeWORD(m_iShopTableSize);
		tmp->Encode(m_pShopTable, sizeof(TShopTable) * m_iShopTableSize);

		tmp->EncodeWORD(m_iRefineTableSize);
		tmp->Encode(m_pRefineTable, sizeof(TRefineTable) * m_iRefineTableSize);

		tmp->EncodeWORD(m_vec_itemAttrTable.size());
		tmp->Encode(&m_vec_itemAttrTable[0], sizeof(TItemAttrTable) * m_vec_itemAttrTable.size());

		tmp->EncodeWORD(m_vec_itemRareTable.size());
		tmp->Encode(&m_vec_itemRareTable[0], sizeof(TItemAttrTable) * m_vec_itemRareTable.size());

 

Bom terminamos o tuto espero que tenham boa sorte 

fonte metin2dev.org

deixo em anexo tambem o tuto em ingles 

Print ao usar o reload drop

imagea3157f65407dc9f7.png

 

 

[C++]Expanded reload commands.cpp

Edited by F-Caneiras
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...