What's new

Welcome to Onforum.net - Web and gaming resource community

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Ask question

Ask Questions and Get Answers from Our Community

Answer

Answer Questions and Become an Expert on Your Topic

Contact Staff

Our Experts are Ready to Answer your Questions

[Mini Tut] Server loads regen only once after start

Heathcliff™

Member
Joined
Mar 15, 2019
Messages
32
Reaction score
7
Points
8
Credits
0
Hello! :)

In the last days I needed that my server loads some mobs only once at server start. I found a function that only quests use (called: "regen_load_in_file") and it's similar what I need. I think it will be useful for some of you, so I decided to share it.

In common/service.h - Add:
C++:
#define ENABLE_REGEN_ONCE

In game/src/sectree_manager.cpp - Search:
C++:
            snprintf(szFilename, sizeof(szFilename), "%s/%s/regen.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);
Add under:
C++:
#ifdef ENABLE_REGEN_ONCE
            snprintf(szFilename, sizeof(szFilename), "%s/%s/regen_once.txt", c_pszMapBasePath, szMapName);
            regen_load_in_file(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);
#endif

In game/src/regen.cpp - Search:
C++:
    snprintf(szFilename, sizeof(szFilename), "%sregen.txt", mbMapDataContainer[lMapIndex]->szBaseName);
    regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);
Add under:
C++:
#ifdef ENABLE_REGEN_ONCE
    snprintf(szFilename, sizeof(szFilename), "%sregen_once.txt", mbMapDataContainer[lMapIndex]->szBaseName);
    regen_load_in_file(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);
#endif

If you done it, you can create regen_once.txt with some mobs, and place it to your map folder next to regen.txt. If you don't place it in every map folder, you will get some syserr that says he can't find regen_once.txt. It won't cause any problem, just making your syserr bigger:D

Best regards, and sorry for my english!
 
shape1
shape2
shape3
shape4
shape7
shape8
Top