Jump to content
Maintenance ×
×
×
  • Create New...

Reload Map Regens InGame


Recommended Posts

  • Moon

M2 Download Center

This is the hidden content, please
( Internal )

Author: (c) Metin2 Factory/Guild Wars

This implementation includes a new ingame GM command:

/reload_regen which reloads ingame current map regen(regen.txt,boss.txt,stones.txt,etc) including server_attr

 

Please follow the following steps:

Open cmd.cpp

look for:
ACMD(do_purge);
 

Add below:

ACMD(reload_regen);

 

Look for:
{ "nowar",        do_nowar,        0,            POS_DEAD,    GM_PLAYER    },

Add below:
 

{ "reload_regen", reload_regen ,    0,        POS_DEAD,    GM_GOD        },

 

Open cmd_gm.cpp

 

look for the end of ACMD(do_purge) function

and add below:

 

ACMD(reload_regen)
{
    std::vector<LPEVENT> regenEvent = SECTREE_MANAGER::instance().GetRegenEvent(ch->GetMapIndex());
    for (std::vector<LPEVENT>::iterator it = regenEvent.begin(); it != regenEvent.end(); ++it)
    {
        event_cancel(&(*it));
    }
    FuncPurge func(ch);
    func.m_bAll = true;
    LPSECTREE_MAP lm = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
    lm->for_each(func);
    char * mapIndex;
    mapIndex = number_to_str(ch->GetMapIndex(), 10);
    SECTREE_MANAGER::instance().BuildMap(mapIndex, LocaleService_GetMapPath().c_str());
}

 

Open sectree_manager.cpp

Look for the end of int SECTREE_MANAGER::Build(const char * c_pszListFileName, const char* c_pszMapBasePath) function

Add below:
 

int SECTREE_MANAGER::BuildMap(const char * c_pszMapID, const char* c_pszMapBasePath)
{
    
    std::string mapIndexPath = c_pszMapBasePath;
    mapIndexPath += "/index";
    int test;
    FILE* fp = fopen(mapIndexPath.c_str(), "rb");
    if (fp == NULL)
    {
        return 0;
    }
    std::string line;
    char buf[256 + 1];
    while (fgets(buf, 256, fp))
    {
        std::string tmp = buf;
        if (tmp.find(c_pszMapID) != std::string::npos)
        {
            printf("found!!");
            break;
        }
        
    }

    char szFilename[256];
    char szMapName[256];
    int iIndex;

    *strrchr(buf, '\n') = '\0';

    if (!strncmp(buf, "//", 2) || *buf == '#')
        return 0;

    sscanf(buf, " %d %s ", &iIndex, szMapName);

    snprintf(szFilename, sizeof(szFilename), "%s/%s/Setting.txt", c_pszMapBasePath, szMapName);

    TMapSetting setting;
    setting.iIndex = iIndex;

        if (!LoadSettingFile(iIndex, szFilename, setting))
        {
            sys_err("can't load file %s in LoadSettingFile", szFilename);
            return 0;
        }

        snprintf(szFilename, sizeof(szFilename), "%s/%s/Town.txt", c_pszMapBasePath, szMapName);

        if (!LoadMapRegion(szFilename, setting, szMapName))
        {
            sys_err("can't load file %s in LoadMapRegion", szFilename);
            return 0;
        }

        if (true == test_server)
            sys_log(0, "[BUILD] Build %s %s %d ", c_pszMapBasePath, szMapName, iIndex);

        // ¸ÕÀú ÀÌ ¼­¹ö¿¡¼­ ÀÌ ¸ÊÀÇ ¸ó½ºÅ͸¦ ½ºÆùÇØ¾ß Çϴ°¡ È®ÀÎ ÇÑ´Ù.
        if (map_allow_find(iIndex))
        {
            LPSECTREE_MAP pkMapSectree = BuildSectreeFromSetting(setting);
            m_map_pkSectree.insert(std::map<DWORD, LPSECTREE_MAP>::value_type(iIndex, pkMapSectree));

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

            snprintf(szFilename, sizeof(szFilename), "%s/%s/regen.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

            snprintf(szFilename, sizeof(szFilename), "%s/%s/npc.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

            snprintf(szFilename, sizeof(szFilename), "%s/%s/boss.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

            snprintf(szFilename, sizeof(szFilename), "%s/%s/stone.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

            snprintf(szFilename, sizeof(szFilename), "%s/%s/dungeon.txt", c_pszMapBasePath, szMapName);
            LoadDungeon(iIndex, szFilename);

            pkMapSectree->Build();
        }
    return 1;
}

Open regen.cpp

Look for:
regen->event = event_create(regen_event, info, PASSES_PER_SEC(number(0, 16)) + PASSES_PER_SEC(regen->time)); 

add below:
 

SECTREE_MANAGER::instance().AddRegenEventToMap(lMapIndex, regen->event);

Open sectree_manager.h
Look for:
std::map<DWORD, std::vector<npc_info> > m_mapNPCPosition;
Add below:
 

std::map<long, std::vector<LPEVENT>> m_mapRegen;

Look for:
bool        GetRandomLocation(long lMapIndex, PIXEL_POSITION & r_pos, DWORD dwCurrentX = 0, DWORD dwCurrentY = 0, int iMaxDistance = 0);

Add below:

void		AddRegenEventToMap(long lMapIndex, LPEVENT event) { m_mapRegen[lMapIndex].push_back(event); }
		std::vector<LPEVENT>		GetRegenEvent(long lMapIndex) { return m_mapRegen[lMapIndex]; }

 

Open utils.h from common folder
Look for:
/*----atoi function-----*/

Add below:
 

/*----itoa function-----*/

inline char* number_to_str(int val, int base)
{
	static char buf[32] = { 0 };

	int i = 30;

	for (; val && i; --i, val /= base)

		buf[i] = "0123456789abcdef"[val % base];

	return &buf[i + 1];

}

/*----itoa function-----*/

 

Recompile the source and enjoy.

  • Metin2 Dev 3
  • Love 6
  • Good 1
Link to comment
Share on other sites

  • Moon
4 hours ago, Galet said:

Thanks ! I remember this feature was a part of samouraï core, but I'm unsure, by the way, thanks !

This feature was created custom made by me. but a similar version may be included in other servers.

and np :)

 

Quote

Do you have a feature to reload the  item\mob proto?
With "/reload p" nothing happens

 

It should work, you have an issue with your server files/src.

I can help you and fix it(not for free), send me a pm.

Link to comment
Share on other sites

  • Premium
On 23.08.2017 at 4:43 PM, metin2-factory said:

This feature was created custom made by me. but a similar version may be included in other servers.

and np :)

 

 

It should work, you have an issue with your server files/src.

I can help you and fix it(not for free), send me a pm.

I think he uses .txt and he doesn't even know.

Link to comment
Share on other sites

  • 3 years later...

It's giving me this error when compiling

cmd_gm.cpp: In function 'void reload_regen(LPCHARACTER, const char*, int, int)':
cmd_gm.cpp:1284:33: error: 'class SECTREE_MANAGER' has no member named 'BuildMap'
     SECTREE_MANAGER::instance().BuildMap(mapIndex, LocaleService_GetMapPath().c_str());

Any solutions please?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 0

      erorrs after update granny to 2.9

    2. 0

      Navicat Premium 16.1.1 x64

    3. 5

      problem Dargon Soul Changre Attribute

    4. 5

      problem Dargon Soul Changre Attribute

    5. 41

      Global Chat

    6. 5

      problem Dargon Soul Changre Attribute

    7. 2

      Startup Loading Window Library

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.