Skip to content

Commit

Permalink
[12335] Fix loading Respawntimes on server start for continents.
Browse files Browse the repository at this point in the history
Thanks to overy for reporting the issue. Fix and close #56
  • Loading branch information
Schmoozerd committed Jan 18, 2013
1 parent 8046e0e commit 052d41e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions src/game/MapPersistentStateMgr.cpp
Expand Up @@ -975,14 +975,11 @@ void MapPersistentStateManager::LoadCreatureRespawnTimes()
if (!data)
continue;

if (mapId != data->mapid)
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
if (!mapEntry || (instanceId && (mapId != data->mapid || mapEntry->Instanceable())))

This comment has been minimized.

Copy link
@xfurry

xfurry Feb 15, 2013

Member

Yes, I can confirm that this commit actually breaks the instance respawn times. If I revert this line will work just fine.

This comment has been minimized.

Copy link
@Zakamurite

Zakamurite Feb 16, 2013

Contributor

after this commit all bosses are respawned after server restart, so yes, it breaks XD

This comment has been minimized.

Copy link
@Schmoozerd

Schmoozerd Feb 16, 2013

Author Member

it looks like i forgot a ! there :(

Need really to revisit my style fo manage more complicated "logic" checks in one line.
Even if i feel able to usually do this right, it appears far too easy to make a mistake - and then catching this mistake is more difficult then necessairy..

continue;

MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
continue;

if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY + 1 : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
continue;

MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
Expand Down Expand Up @@ -1041,14 +1038,11 @@ void MapPersistentStateManager::LoadGameobjectRespawnTimes()
if (!data)
continue;

if (mapId != data->mapid)
continue;

MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
if (!mapEntry || (instanceId && (mapId != data->mapid || mapEntry->Instanceable())))
continue;

if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
if (difficulty >= (!mapEntry->Instanceable() ? REGULAR_DIFFICULTY + 1 : (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY)))
continue;

MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12334"
#define REVISION_NR "12335"
#endif // __REVISION_NR_H__

2 comments on commit 052d41e

@xfurry
Copy link
Member

@xfurry xfurry commented on 052d41e Feb 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think that this commit actually broke stuff.
The respawn times in instances don't work anymore.

@Reamer
Copy link
Contributor

@Reamer Reamer commented on 052d41e Feb 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xfurry
I hope maybe a look into mangosR2 code can help you

do
{
    Field* fields = result->Fetch();
    bar.step();

    uint32 loguid               = fields[0].GetUInt32();
    uint64 respawn_time         = fields[1].GetUInt64();
    uint32 mapId                = fields[2].GetUInt32();
    uint32 instanceId           = fields[3].GetUInt32();
    uint8 difficulty            = fields[4].GetUInt8();
    time_t resetTime            = (time_t)fields[5].GetUInt64();
    uint32 completedEncounters  = fields[6].GetUInt32();

    CreatureData const* data = sObjectMgr.GetCreatureData(loguid);
    if (!data)
        continue;

    if (instanceId && mapId != data->mapid)
        continue;

    MapEntry const* mapEntry = sMapStore.LookupEntry(data->mapid);
    if (!mapEntry || (mapEntry->Instanceable() != (instanceId != 0)))
        continue;

    if (mapEntry->Instanceable() && difficulty >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
        continue;

    MapPersistentState* state = AddPersistentState(mapEntry, instanceId, Difficulty(difficulty), resetTime, mapEntry->IsDungeon(), true, true, completedEncounters);
    if (!state)
        continue;

    state->SetCreatureRespawnTime(loguid, time_t(respawn_time));

    ++count;

} while (result->NextRow());

Please sign in to comment.