Jump to content

[c++] mob_drop_item.txt Reload Ingame


Go to solution Solved by Ken,

Recommended Posts

Hello People,

my Problem is, my Game is crashed.. When a command tip ingame reload m ...

 

I would Reload the mob_drop_item.txt on Ingame... On CMD command..

 

my CMD:

			case 'm': 
				char szMOBDropItemFileName[256];
				snprintf(szMOBDropItemFileName, sizeof(szMOBDropItemFileName),
					"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
				ch->ChatPacket(CHAT_TYPE_INFO, "Reloading mob_drop_item.txt.");
				if (!ITEM_MANAGER::instance().ReadMonsterDropItemGroup(szMOBDropItemFileName))
				{
					ch->ChatPacket(CHAT_TYPE_INFO, "cannot reload mob_drop_item.txt.");
					return;
				}

But i tipped this ingame, Game is crashed.. I Hope the Community can me help, and why is Crashed:

 

Debug:

root@:/var/mt2_server/share_data # gdb game game.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
Core was generated by `game'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libmd.so.5...done.
Loaded symbols for /lib/libmd.so.5
Reading symbols from /lib/libz.so.5...done.
Loaded symbols for /lib/libz.so.5
Reading symbols from /usr/lib/libssl.so.6...done.
Loaded symbols for /usr/lib/libssl.so.6
Reading symbols from /usr/lib/libstdc++.so.6...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.5...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libthr.so.3...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /lib/libcrypto.so.6...done.
Loaded symbols for /lib/libcrypto.so.6
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x08252d0c in ITEM_MANAGER::ReadMonsterDropItemGroup (this=0xbfbfb284,
    c_pszFileName=0xbfbf97dc "locale/germany/mob_drop_item.txt")
    at new_allocator.h:107
107           { ::new(__p) _Tp(__val); }
[New Thread 289b5d80 (LWP 100116/game)]
[New Thread 289b5ec0 (LWP 100112/game)]
[New Thread 289b6140 (LWP 100111/game)]
[New Thread 28901140 (LWP 100142/initial thread)]
(gdb) backtrace
#0  0x08252d0c in ITEM_MANAGER::ReadMonsterDropItemGroup (this=0xbfbfb284,
    c_pszFileName=0xbfbf97dc "locale/germany/mob_drop_item.txt")
    at new_allocator.h:107
#1  0x080dda8b in do_reload (ch=0x32e48000, argument=0xbfbf9e2c " m", cmd=81,
    subcmd=0) at cmd_gm.cpp:2334
#2  0x080d1503 in interpret_command (ch=0x32e48000,
    argument=0xbfbfaa8f "reload m", len=8) at cmd.cpp:751
#3  0x08153cac in CInputMain::Chat (this=0x32ad149c, ch=0x32e48000,
    data=0x28b1d000 "003016", uiBytes=16) at input_main.cpp:717
#4  0x0815579a in CInputMain::Analyze (this=0x32ad149c, d=0x32ad1400,
    bHeader=<value optimized out>, c_pData=0x28b1d000 "003016")
    at input_main.cpp:3108
#5  0x0813dab9 in CInputProcessor::Process (this=0x32ad149c,
    lpDesc=0x32ad1400, c_pvOrig=0x28b1d000, iBytes=16,
    r_iBytesProceed=@0xbfbfb170) at input.cpp:108
#6  0x0810657a in DESC::ProcessInput (this=0x32ad1400) at desc.cpp:365
#7  0x08258fa4 in io_loop (fdw=0x28a427a0) at main.cpp:1077
#8  0x082599d1 in idle () at main.cpp:960
#9  0x0825b050 in main (argc=1, argv=Cannot access memory at address 0xb38b3b79
) at main.cpp:616
(gdb)

Link to comment
Share on other sites

  • Solution

You should destroy everything about mob_drop_item.txt..

 

void ITEM_MANAGER::DestroyMobDropItem()
{
	if (!m_map_pkMobItemGroup.empty())
		m_map_pkMobItemGroup.clear();
	
	if (!m_map_pkDropItemGroup.empty())
		m_map_pkDropItemGroup.clear();
	
	if (!m_map_pkLevelItemGroup.empty())
		m_map_pkLevelItemGroup.clear();
	
	if (!m_map_pkGloveItemGroup.empty())
		m_map_pkGloveItemGroup.clear();	
}

 

your case ;

case 'm':
	const int FILE_NAME_LEN = 256;
	char szMOBDropItemFileName[FILE_NAME_LEN];
	snprintf(szMOBDropItemFileName, sizeof(szMOBDropItemFileName),
		"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
	
	ITEM_MANAGER::Instance().DestroyMobDropItem();
	if (!ITEM_MANAGER::Instance().ReadMonsterDropItemGroup(szMOBDropItemFileName))
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Can not reload mob_drop_item.txt");
		return;
	}
	
	ch->ChatPacket(CHAT_TYPE_INFO, "Reloaded mob_drop_item.txt!");

Edit 1:

 

When you are kill game file, all tables will be reset. Because you are killed them. The method is work like that. 

 

Kind Regards

Ken

Edited by Ken
  • Love 5

Do not be sorry, be better.

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...
  • 6 months later...
On 05.08.2015 at 3:22 PM, nanoia said:

 

I have the source code

I want to know where I put them

search: ACMD(do_reload) -cmd_gm.cpp

add: 

Spoiler

case 'm':
	const int FILE_NAME_LEN = 256;
	char szMOBDropItemFileName[FILE_NAME_LEN];
	snprintf(szMOBDropItemFileName, sizeof(szMOBDropItemFileName),
		"%s/mob_drop_item.txt", LocaleService_GetBasePath().c_str());
	
	ITEM_MANAGER::Instance().DestroyMobDropItem();
	if (!ITEM_MANAGER::Instance().ReadMonsterDropItemGroup(szMOBDropItemFileName))
	{
		ch->ChatPacket(CHAT_TYPE_INFO, "Can not reload mob_drop_item.txt");
		return;
	}
	
	ch->ChatPacket(CHAT_TYPE_INFO, "Reloaded mob_drop_item.txt!");

 

Link to comment
Share on other sites

  • 5 months later...

I have that error:

 


cmd_gm.cpp: In function 'void do_reload(CHARACTER*, const char*, int, int)':
cmd_gm.cpp:2130: error: 'class ITEM_MANAGER' has no member named 'DestroyMobDrop                                                              Item'

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.