mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Compiler option for playing with npctype_cache as was requested for a feature. Not entirely tested may need some work. Currently defaults to old behavior on #repop.
This commit is contained in:
parent
1ab19920f4
commit
6e0a214bcc
@ -118,6 +118,9 @@ SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
|
||||
10 - More errors than you ever wanted to see"
|
||||
)
|
||||
|
||||
#NPC Types Cache Behavior
|
||||
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
|
||||
|
||||
#Bots are a compile time option so on/off
|
||||
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
||||
|
||||
|
||||
@ -200,6 +200,10 @@ SET(zone_headers
|
||||
zonedump.h
|
||||
)
|
||||
|
||||
IF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
ADD_DEFINITIONS(-DDEPOP_INVALIDATES_NPC_TYPES_CACHE)
|
||||
ENDIF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
|
||||
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
|
||||
|
||||
INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
@ -448,7 +448,8 @@ int command_init(void) {
|
||||
command_add("augmentitem", "Force augments an item. Must have the augment item window open.", 250, command_augmentitem) ||
|
||||
command_add("questerrors", "Shows quest errors.", 100, command_questerrors) ||
|
||||
command_add("enablerecipe", "[recipe_id] - Enables a recipe using the recipe id.", 80, command_enablerecipe) ||
|
||||
command_add("disablerecipe", "[recipe_id] - Disables a recipe using the recipe id.", 80, command_disablerecipe)
|
||||
command_add("disablerecipe", "[recipe_id] - Disables a recipe using the recipe id.", 80, command_disablerecipe) ||
|
||||
command_add("npctype_cache", "[id] or all - Clears the npc type cache for either the id or all npcs.", 250, command_npctype_cache)
|
||||
)
|
||||
{
|
||||
command_deinit();
|
||||
@ -11452,3 +11453,28 @@ void command_disablerecipe(Client *c, const Seperator *sep)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void command_npctype_cache(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->argnum > 0) {
|
||||
for (int i = 0; i < sep->argnum; ++i) {
|
||||
if (strcasecmp(sep->arg[i + 1], "all") == 0) {
|
||||
c->Message(0, "Clearing all npc types from the cache.");
|
||||
zone->ClearNPCTypeCache(-1);
|
||||
}
|
||||
else {
|
||||
int id = atoi(sep->arg[i + 1]);
|
||||
if (id > 0) {
|
||||
c->Message(0, "Clearing npc type %d from the cache.", id);
|
||||
zone->ClearNPCTypeCache(id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
c->Message(0, "Usage:");
|
||||
c->Message(0, "#npctype_cache [npctype_id] ...");
|
||||
c->Message(0, "#npctype_cache all");
|
||||
}
|
||||
}
|
||||
@ -323,6 +323,7 @@ void command_questerrors(Client *c, const Seperator *sep);
|
||||
void command_enablerecipe(Client *c, const Seperator *sep);
|
||||
void command_disablerecipe(Client *c, const Seperator *sep);
|
||||
void command_showspellslist(Client *c, const Seperator *sep);
|
||||
void command_npctype_cache(Client *c, const Seperator *sep);
|
||||
|
||||
#ifdef EQPROFILE
|
||||
void command_profiledump(Client *c, const Seperator *sep);
|
||||
|
||||
@ -1518,16 +1518,40 @@ bool Zone::Depop(bool StartSpawnTimer) {
|
||||
std::map<uint32,NPCType *>::iterator itr;
|
||||
entity_list.Depop(StartSpawnTimer);
|
||||
|
||||
#ifdef DEPOP_INVALIDATES_NPC_TYPES_CACHE
|
||||
// Refresh npctable, getting current info from database.
|
||||
while(npctable.size()) {
|
||||
itr=npctable.begin();
|
||||
delete itr->second;
|
||||
npctable.erase(itr);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Zone::ClearNPCTypeCache(int id) {
|
||||
if (id <= 0) {
|
||||
auto iter = npctable.begin();
|
||||
while (iter != npctable.end()) {
|
||||
delete iter->second;
|
||||
++iter;
|
||||
}
|
||||
npctable.clear();
|
||||
}
|
||||
else {
|
||||
auto iter = npctable.begin();
|
||||
while (iter != npctable.end()) {
|
||||
if (iter->first == (uint32)id) {
|
||||
delete iter->second;
|
||||
npctable.erase(iter);
|
||||
return;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::Repop(uint32 delay) {
|
||||
|
||||
if(!Depop())
|
||||
|
||||
@ -144,6 +144,7 @@ public:
|
||||
|
||||
bool Depop(bool StartSpawnTimer = false);
|
||||
void Repop(uint32 delay = 0);
|
||||
void ClearNPCTypeCache(int id);
|
||||
void SpawnStatus(Mob* client);
|
||||
void ShowEnabledSpawnStatus(Mob* client);
|
||||
void ShowDisabledSpawnStatus(Mob* client);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user