Skip to content

Commit

Permalink
[6813] Allow have team dependent graveyards at entrance map for insta…
Browse files Browse the repository at this point in the history
…nces.

Entrance map graveyards selected by same way as local (by distance from entrance)
Until DB support will work in old way base at current DB data.
  • Loading branch information
VladimirMangos committed Nov 9, 2008
1 parent eb5cff8 commit 7734fce
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 41 deletions.
3 changes: 1 addition & 2 deletions sql/mangos.sql
Expand Up @@ -22,7 +22,7 @@
DROP TABLE IF EXISTS `db_version`;
CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`required_2008_11_09_02_mangos_command` bit(1) default NULL
`required_2008_11_09_03_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -2474,7 +2474,6 @@ INSERT INTO `mangos_string` VALUES
(450,'Graveyard #%u already linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(451,'Graveyard #%u linked to zone #%u (current).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(452,'Graveyard #%u can\'t be linked to subzone or not existed zone #%u (internal error).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(453,'Graveyard can be linked to zone at another map only for all factions (no faction value).',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(454,'No faction in Graveyard with id= #%u , fix your DB',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(455,'invalid team, please fix database',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(456,'any',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
Expand Down
2 changes: 1 addition & 1 deletion src/game/Language.h
Expand Up @@ -388,7 +388,7 @@ enum MangosStrings
LANG_COMMAND_GRAVEYARDALRLINKED = 450,
LANG_COMMAND_GRAVEYARDLINKED = 451,
LANG_COMMAND_GRAVEYARDWRONGZONE = 452,
LANG_COMMAND_GRAVEYARDWRONGTEAM = 453,
// = 453,
LANG_COMMAND_GRAVEYARDERROR = 454,
LANG_COMMAND_GRAVEYARD_NOTEAM = 455,
LANG_COMMAND_GRAVEYARD_ANY = 456,
Expand Down
7 changes: 0 additions & 7 deletions src/game/Level3.cpp
Expand Up @@ -3527,13 +3527,6 @@ bool ChatHandler::HandleLinkGraveCommand(const char* args)
return false;
}

if(graveyard->map_id != areaEntry->mapid && g_team != 0)
{
SendSysMessage(LANG_COMMAND_GRAVEYARDWRONGTEAM);
SetSentErrorMessage(true);
return false;
}

if(objmgr.AddGraveYardLink(g_id,player->GetZoneId(),g_team))
PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id,zoneId);
else
Expand Down
84 changes: 58 additions & 26 deletions src/game/ObjectMgr.cpp
Expand Up @@ -4732,12 +4732,6 @@ void ObjectMgr::LoadGraveyardZones()
continue;
}

if(entry->map_id != areaEntry->mapid && team != 0)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record for ghost zone (%u) at map %u and graveyard (%u) at map %u for team %u, but in case maps are different, player faction setting is ignored. Use faction 0 instead.",zoneId,areaEntry->mapid, safeLocId, entry->map_id, team);
team = 0;
}

if(!AddGraveYardLink(safeLocId,zoneId,team,false))
sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId);
} while( result->NextRow() );
Expand All @@ -4759,7 +4753,7 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
// if mapId == graveyard.mapId (ghost in plain zone or city or battleground) and search graveyard at same map
// then check faction
// if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated
// then skip check faction
// then check faction
GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId);
GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId);
if(graveLow==graveUp)
Expand All @@ -4768,11 +4762,21 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
return NULL;
}

// at corpse map
bool foundNear = false;
float distNear;
WorldSafeLocsEntry const* entryNear = NULL;

// at entrance map for corpse map
bool foundEntr = false;
float distEntr;
WorldSafeLocsEntry const* entryEntr = NULL;

// some where other
WorldSafeLocsEntry const* entryFar = NULL;

MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);

for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr)
{
GraveYardData const& data = itr->second;
Expand All @@ -4784,40 +4788,68 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
continue;
}

// remember first graveyard at another map and ignore other
if(MapId != entry->map_id)
{
if(!entryFar)
entryFar = entry;
continue;
}

// skip enemy faction graveyard at same map (normal area, city, or battleground)
// skip enemy faction graveyard
// team == 0 case can be at call from .neargrave
if(data.team != 0 && team != 0 && data.team != team)
continue;

// find now nearest graveyard at same map
float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z);
if(foundNear)
// find now nearest graveyard at other map
if(MapId != entry->map_id)
{
if(dist2 < distNear)
// if find graveyard at different map from where entrance placed (or no entrance data), use any first
if (!mapEntry || mapEntry->entrance_map < 0 || mapEntry->entrance_map != entry->map_id ||
mapEntry->entrance_x == 0 && mapEntry->entrance_y == 0)
{
distNear = dist2;
entryNear = entry;
// not have any corrdinates for check distance anyway
entryFar = entry;
continue;
}

// at entrance map calculate distance (2D);
float dist2 = (entry->x - mapEntry->entrance_x)*(entry->x - mapEntry->entrance_x)
+(entry->y - mapEntry->entrance_y)*(entry->y - mapEntry->entrance_y);
if(foundEntr)
{
if(dist2 < distEntr)
{
distEntr = dist2;
entryEntr = entry;
}
}
else
{
foundEntr = true;
distEntr = dist2;
entryEntr = entry;
}
}
// find now nearest graveyard at same map
else
{
foundNear = true;
distNear = dist2;
entryNear = entry;
float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z);
if(foundNear)
{
if(dist2 < distNear)
{
distNear = dist2;
entryNear = entry;
}
}
else
{
foundNear = true;
distNear = dist2;
entryNear = entry;
}
}
}

if(entryNear)
return entryNear;

if(entryEntr)
return entryEntr;

return entryFar;
}

Expand Down Expand Up @@ -4988,7 +5020,7 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
if(!mapEntry) return NULL;
for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); itr++)
{
if(itr->second.target_mapId == mapEntry->parent_map)
if(itr->second.target_mapId == mapEntry->entrance_map)
{
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
if(atEntry && atEntry->mapid == Map)
Expand Down
6 changes: 3 additions & 3 deletions src/shared/Database/DBCStructure.h
Expand Up @@ -408,9 +408,9 @@ struct MapEntry
// 99 text flags
//chat* unknownText2 // 100-115 unknown empty text fields
// 116 text flags
int32 parent_map; // 117 map_id of parent map
//float start_x // 118 enter x coordinate (if exist single entry)
//float start_y // 119 enter y coordinate (if exist single entry)
int32 entrance_map; // 117 map_id of entrance map
float entrance_x; // 118 entrance x coordinate (if exist single entry)
float entrance_y; // 119 entrance y coordinate (if exist single entry)
uint32 resetTimeRaid; // 120
uint32 resetTimeHeroic; // 121
// 122-123
Expand Down
2 changes: 1 addition & 1 deletion src/shared/Database/DBCfmt.cpp
Expand Up @@ -52,7 +52,7 @@ const char ItemRandomSuffixfmt[]="nxxxxxxxxxxxxxxxxxxiiiiii";
const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii";
const char LockEntryfmt[]="niiiiixxxiiiiixxxiixxxxxxxxxxxxxx";
const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char MapEntryfmt[]="nxixssssssssssssssssxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxiixxi";
const char MapEntryfmt[]="nxixssssssssssssssssxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiffiixxi";
const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx";
const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii";
const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxi";
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 "6812"
#define REVISION_NR "6813"
#endif // __REVISION_NR_H__

0 comments on commit 7734fce

Please sign in to comment.