Merge branch 'master' into 303

Conflicts:
	src/game/WorldSocket.cpp
	src/shared/Database/DBCStructure.h
	src/shared/Database/DBCfmt.cpp
This commit is contained in:
tomrus88 2008-11-10 01:10:52 +03:00
commit 6fae544fbe
23 changed files with 280 additions and 118 deletions

View file

@ -16,13 +16,21 @@
#include <unistd.h>
#endif
// config
#define NUM_REMOTES 2
char remotes[NUM_REMOTES][256] = {
"git@github.com:mangos/mangos.git",
"git://github.com/mangos/mangos.git"
"git://github.com/mangos/mangos.git" // used for fetch if present
};
bool allow_replace = false;
bool local = false;
bool do_fetch = false;
// aux
char origins[NUM_REMOTES][256];
int rev;
char head_message[16384];
@ -31,11 +39,9 @@ char write_file[2048];
char buffer[256];
FILE *cmd_pipe;
bool allow_replace = false;
bool local = false;
bool find_path()
{
printf("+ finding path\n");
char cur_path[2048], *ptr;
getcwd(cur_path, 2048);
int len = strnlen(cur_path, 2048);
@ -70,7 +76,8 @@ bool find_path()
bool find_origin()
{
if( (cmd_pipe = popen( "git remote -v", "rt" )) == NULL )
printf("+ finding origin\n");
if( (cmd_pipe = popen( "git remote -v", "r" )) == NULL )
return false;
bool ret = false;
@ -91,6 +98,48 @@ bool find_origin()
return ret;
}
bool fetch_origin()
{
printf("+ fetching origin\n");
char cmd[256];
// use the public clone url if present because the private may require a password
sprintf(cmd, "git fetch %s master", origins[1][0] ? origins[1] : origins[0]);
int ret = system(cmd);
return true;
}
bool check_fwd()
{
printf("+ checking fast forward\n");
char cmd[256];
sprintf(cmd, "git log -n 1 --pretty=\"format:%%H\" %s/master", origins[1][0] ? origins[1] : origins[0]);
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
return false;
char hash[256];
if(!fgets(buffer, 256, cmd_pipe)) return false;
strncpy(hash, buffer, 256);
pclose(cmd_pipe);
if( (cmd_pipe = popen( "git log --pretty=\"format:%H\"", "r" )) == NULL )
return false;
bool found = false;
while(fgets(buffer, 256, cmd_pipe))
{
buffer[strnlen(buffer, 256) - 1] = '\0';
if(strncmp(hash, buffer, 256) == 0)
{
found = true;
break;
}
}
pclose(cmd_pipe);
if(!found) printf("WARNING: non-fastforward, use rebase!\n");
return true;
}
int get_rev(const char *from_msg)
{
// accept only the rev number format, not the sql update format
@ -102,6 +151,7 @@ int get_rev(const char *from_msg)
bool find_rev()
{
printf("+ finding next revision number\n");
// find the highest rev number on either of the remotes
for(int i = 0; i < NUM_REMOTES; i++)
{
@ -110,7 +160,7 @@ bool find_rev()
char cmd[512];
if(local) sprintf(cmd, "git log HEAD --pretty=\"format:%%s\"");
else sprintf(cmd, "git log %s/master --pretty=\"format:%%s\"", origins[i]);
if( (cmd_pipe = popen( cmd, "rt" )) == NULL )
if( (cmd_pipe = popen( cmd, "r" )) == NULL )
continue;
int nr;
@ -123,6 +173,8 @@ bool find_rev()
pclose(cmd_pipe);
}
if(rev > 0) printf("Found [%d].\n", rev);
return rev > 0;
}
@ -138,6 +190,7 @@ std::string generateHeader(char const* rev_str)
bool write_rev()
{
printf("+ writing revision_nr.h\n");
char rev_str[256];
sprintf(rev_str, "%d", rev);
std::string header = generateHeader(rev_str);
@ -154,7 +207,8 @@ bool write_rev()
bool find_head_msg()
{
if( (cmd_pipe = popen( "git log -n 1 --pretty=\"format:%s%n%n%b\"", "rt" )) == NULL )
printf("+ finding last message on HEAD\n");
if( (cmd_pipe = popen( "git log -n 1 --pretty=\"format:%s%n%n%b\"", "r" )) == NULL )
return false;
int poz = 0;
@ -163,9 +217,14 @@ bool find_head_msg()
pclose(cmd_pipe);
if(get_rev(head_message))
if(int head_rev = get_rev(head_message))
{
if(!allow_replace) return false;
if(!allow_replace)
{
printf("Last commit on HEAD is [%d]. Use -r to replace it with [%d].\n", head_rev, rev);
return false;
}
// skip the rev number in the commit
char *p = strchr(head_message, ']'), *q = head_message;
assert(p && *(p+1));
@ -180,9 +239,10 @@ bool find_head_msg()
bool amend_commit()
{
printf("+ amending last commit\n");
char cmd[512];
sprintf(cmd, "git commit --amend -F- %s", write_file);
if( (cmd_pipe = popen( cmd, "wt" )) == NULL )
if( (cmd_pipe = popen( cmd, "w" )) == NULL )
return false;
fprintf(cmd_pipe, "[%d] %s", rev, head_message);
@ -191,29 +251,47 @@ bool amend_commit()
return true;
}
#define DO(cmd) if(!cmd) { printf("FAILED\n"); return 1; }
int main(int argc, char *argv[])
{
for(int i = 1; i < argc; i++)
{
if(argv[i] == NULL) continue;
if(strncmp(argv[i], "-r", 2) == 0)
if(strncmp(argv[i], "-r", 2) == 0 || strncmp(argv[i], "--replace", 2) == 0)
allow_replace = true;
if(strncmp(argv[i], "-l", 2) == 0)
if(strncmp(argv[i], "-l", 2) == 0 || strncmp(argv[i], "--local", 2) == 0)
local = true;
if(strncmp(argv[i], "-h", 2) == 0)
if(strncmp(argv[i], "-f", 2) == 0 || strncmp(argv[i], "--fetch", 2) == 0)
do_fetch = true;
if(strncmp(argv[i], "-h", 2) == 0 || strncmp(argv[i], "--help", 2) == 0)
{
printf("Usage: git_id [OPTION]\n");
printf("Generates a new rev number and updates revision_nr.h and the commit message.\n");
printf("Should be used just before push.\n");
printf(" -h, --help show the usage\n");
printf(" -r, --replace replace the rev number if it was already applied to the last\n");
printf(" commit\n");
printf(" -l, --local search for the highest rev number on HEAD\n");
printf(" -f, --fetch fetch from origin before searching for the new rev\n");
return 0;
}
}
if(!find_path()) { printf("ERROR: can't find path\n"); return 1; }
if(!local && !find_origin()) { printf("ERROR: can't find origin\n"); return 1; }
if(!find_rev()) { printf("ERROR: can't find rev\n"); return 1; }
if(!find_head_msg()) { printf("ERROR: can't find head message\n"); return 1; }
if(!write_rev()) { printf("ERROR: can't write revision_nr.h\n"); return 1; }
if(!amend_commit()) { printf("ERROR: can't ammend commit\n"); return 1; }
printf("Generated rev %d\n", rev);
DO( find_path() );
if(!local)
{
DO( find_origin() );
if(do_fetch)
{
DO( fetch_origin() );
DO( check_fwd() );
}
}
DO( find_rev() );
DO( find_head_msg() );
DO( write_rev() );
DO( amend_commit() );
return 0;
}

View file

@ -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';
--
@ -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),

View file

@ -0,0 +1,3 @@
ALTER TABLE db_version CHANGE COLUMN required_2008_11_09_02_mangos_command required_2008_11_09_03_mangos_mangos_string bit;
DELETE FROM mangos_string WHERE entry IN (453);

View file

@ -129,6 +129,7 @@ pkgdata_DATA = \
2008_11_07_04_realmd_account.sql \
2008_11_09_01_mangos_command.sql \
2008_11_09_02_mangos_command.sql \
2008_11_09_03_mangos_mangos_string.sql \
README
## Additional files to include when running 'make dist'
@ -239,4 +240,5 @@ EXTRA_DIST = \
2008_11_07_04_realmd_account.sql \
2008_11_09_01_mangos_command.sql \
2008_11_09_02_mangos_command.sql \
2008_11_09_03_mangos_mangos_string.sql \
README

View file

@ -24,7 +24,7 @@
#if COMPILER == COMPILER_INTEL
#include <ext/hash_map>
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 4
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#include <tr1/unordered_map>
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
#include <ext/hash_map>
@ -45,10 +45,10 @@ using stdext::hash_map;
#elif COMPILER == COMPILER_INTEL
#define UNORDERED_MAP std::hash_map
using std::hash_map;
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 4
#elif COMPILER == COMPILER_GNU && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 3)
#define UNORDERED_MAP std::tr1::unordered_map
#elif COMPILER == COMPILER_GNU && __GNUC__ >= 3
#define UNORDERED_MAP std::__gnu_cxx::hash_map
#define UNORDERED_MAP __gnu_cxx::hash_map
namespace __gnu_cxx
{

View file

@ -2023,3 +2023,19 @@ TrainerSpellData const* Creature::GetTrainerSpells() const
{
return objmgr.GetNpcTrainerSpells(GetEntry());
}
// overwrite WorldObject function for proper name localization
const char* Creature::GetNameForLocaleIdx(int32 loc_idx) const
{
if (loc_idx >= 0)
{
CreatureLocale const *cl = objmgr.GetCreatureLocale(GetEntry());
if (cl)
{
if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty())
return cl->Name[loc_idx].c_str();
}
}
return GetName();
}

View file

@ -511,6 +511,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
void TextEmote(int32 textId, uint64 TargetGuid, bool IsBossEmote = false) { MonsterTextEmote(textId,TargetGuid,IsBossEmote); }
void Whisper(int32 textId, uint64 receiver, bool IsBossWhisper = false) { MonsterWhisper(textId,receiver,IsBossWhisper); }
// overwrite WorldObject function for proper name localization
const char* GetNameForLocaleIdx(int32 locale_idx) const;
void setDeathState(DeathState s); // overwrite virtual Unit::setDeathState
bool LoadFromDB(uint32 guid, Map *map);

View file

@ -1281,3 +1281,19 @@ void GameObject::Use(Unit* user)
spell->prepare(&targets);
}
// overwrite WorldObject function for proper name localization
const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const
{
if (loc_idx >= 0)
{
GameObjectLocale const *cl = objmgr.GetGameObjectLocale(GetEntry());
if (cl)
{
if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty())
return cl->Name[loc_idx].c_str();
}
}
return GetName();
}

View file

@ -449,6 +449,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
void TextEmote(int32 textId, uint64 TargetGuid) { MonsterTextEmote(textId,TargetGuid); }
void Whisper(int32 textId, uint64 receiver) { MonsterWhisper(textId,receiver); }
// overwrite WorldObject function for proper name localization
const char* GetNameForLocaleIdx(int32 locale_idx) const;
void SaveToDB();
void SaveToDB(uint32 mapid, uint8 spawnMask);
bool LoadFromDB(uint32 guid, Map *map);

View file

@ -566,6 +566,7 @@ struct ItemPrototype
{
case INVTYPE_RELIC:
case INVTYPE_SHIELD:
case INVTYPE_HOLDABLE:
return true;
}

View file

@ -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,

View file

@ -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

View file

@ -1278,7 +1278,7 @@ namespace MaNGOS
data = new WorldPacket(SMSG_MESSAGECHAT, 200);
// TODO: i_object.GetName() also must be localized?
i_object.BuildMonsterChat(data,i_msgtype,text,i_language,i_object.GetName(),i_targetGUID);
i_object.BuildMonsterChat(data,i_msgtype,text,i_language,i_object.GetNameForLocaleIdx(loc_idx),i_targetGUID);
i_data_cache[cache_idx] = data;
}

View file

@ -411,6 +411,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
const char* GetName() const { return m_name.c_str(); }
void SetName(std::string newname) { m_name=newname; }
virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); }
float GetDistance( const WorldObject* obj ) const;
float GetDistance(const float x, const float y, const float z) const;
float GetDistance2d(const WorldObject* obj) const;

View file

@ -4784,12 +4784,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() );
@ -4811,7 +4805,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)
@ -4820,11 +4814,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;
@ -4836,20 +4840,44 @@ 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 other map
if(MapId != entry->map_id)
{
// 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)
{
// 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
{
float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z);
if(foundNear)
{
@ -4866,10 +4894,14 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
entryNear = entry;
}
}
}
if(entryNear)
return entryNear;
if(entryEntr)
return entryEntr;
return entryFar;
}

View file

@ -10258,9 +10258,26 @@ Item* Player::EquipItem( uint16 pos, Item *pItem, bool update )
if(pProto && isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer == 0)
{
m_weaponChangeTimer = DEFAULT_SWITCH_WEAPON;
uint32 cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s;
if (getClass() == CLASS_ROGUE)
m_weaponChangeTimer = ROGUE_SWITCH_WEAPON;
cooldownSpell = SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s;
SpellEntry const* spellProto = sSpellStore.LookupEntry(cooldownSpell);
if (!spellProto)
sLog.outError("Weapon switch cooldown spell %u couldn't be found in Spell.dbc", cooldownSpell);
else
{
m_weaponChangeTimer = spellProto->StartRecoveryTime;
WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4);
data << uint64(GetGUID());
data << uint8(1);
data << uint32(cooldownSpell);
data << uint32(0);
GetSession()->SendPacket(&data);
}
}
}

View file

@ -697,12 +697,6 @@ struct ItemPosCount
};
typedef std::vector<ItemPosCount> ItemPosCountVec;
enum SwitchWeapon
{
DEFAULT_SWITCH_WEAPON = 1500, //cooldown in ms
ROGUE_SWITCH_WEAPON = 1000
};
enum TradeSlots
{
TRADE_SLOT_COUNT = 7,

View file

@ -1890,6 +1890,8 @@ enum CorpseDynFlags
#define SPELL_ID_GENERIC_LEARN_PET 55884 // used for learning mounts and companions
#define SPELL_ID_PASSIVE_BATTLE_STANCE 2457
#define SPELL_ID_PASSIVE_RESURRECTION_SICKNESS 15007
#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_5s 6119
#define SPELL_ID_WEAPON_SWITCH_COOLDOWN_1_0s 6123
enum WeatherType
{

View file

@ -5631,7 +5631,7 @@ void Aura::PeriodicTick()
// DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura)
pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), GetSpellSchoolMask(spellProto), spellProto);
pCaster->ProcDamageAndSpell(target, PROC_FLAG_NONE, PROC_FLAG_TAKE_DAMAGE, (pdamage <= absorb+resist) ? 0 : (pdamage-absorb-resist), GetSpellSchoolMask(spellProto), spellProto);
break;
}
case SPELL_AURA_PERIODIC_LEECH:
@ -5744,7 +5744,7 @@ void Aura::PeriodicTick()
// DO NOT ACCESS MEMBERS OF THE AURA FROM NOW ON (DealDamage can delete aura)
pCaster->ProcDamageAndSpell(target, PROC_FLAG_HIT_SPELL, PROC_FLAG_TAKE_DAMAGE, new_damage, GetSpellSchoolMask(spellProto), spellProto);
pCaster->ProcDamageAndSpell(target, PROC_FLAG_HEALED, PROC_FLAG_TAKE_DAMAGE, new_damage, GetSpellSchoolMask(spellProto), spellProto);
if (!target->isAlive() && pCaster->IsNonMeleeSpellCasted(false))
{
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; i++)
@ -5848,7 +5848,7 @@ void Aura::PeriodicTick()
// ignore item heals
if(procSpell && !haveCastItem)
pCaster->ProcDamageAndSpell(target,PROC_FLAG_HEAL, PROC_FLAG_HEALED, pdamage, SPELL_SCHOOL_MASK_NONE, spellProto);
pCaster->ProcDamageAndSpell(target,PROC_FLAG_NONE, PROC_FLAG_HEALED, pdamage, SPELL_SCHOOL_MASK_NONE, spellProto);
break;
}
case SPELL_AURA_PERIODIC_MANA_LEECH:

View file

@ -198,13 +198,16 @@ World::AddSession_ (WorldSession* s)
return;
}
WorldSession* old = m_sessions[s->GetAccountId ()];
m_sessions[s->GetAccountId ()] = s;
// if session already exist, prepare to it deleting at next world update
// NOTE - KickPlayer() should be called on "old" in RemoveSession()
if (old)
m_kicked_sessions.insert (old);
{
SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ());
if(old != m_sessions.end())
m_kicked_sessions.insert (old->second);
}
m_sessions[s->GetAccountId ()] = s;
uint32 Sessions = GetActiveAndQueuedSessionCount ();
uint32 pLimit = GetPlayerAmountLimit ();
@ -286,9 +289,7 @@ void World::RemoveQueuedPlayer(WorldSession* sess)
{
if(*iter==sess)
{
Queue::iterator iter2 = iter;
++iter;
m_QueuedPlayer.erase(iter2);
iter = m_QueuedPlayer.erase(iter);
decrease_session = false; // removing queued session
break;
}

View file

@ -261,7 +261,7 @@ int WorldSocket::handle_input (ACE_HANDLE)
if ((errno == EWOULDBLOCK) ||
(errno == EAGAIN))
{
return Update (); // interesting line ,isnt it ?
return Update (); // interesting line ,isn't it ?
}
DEBUG_LOG ("WorldSocket::handle_input: Peer error closing connection errno = %s", ACE_OS::strerror (errno));
@ -460,20 +460,20 @@ int WorldSocket::handle_input_missing_data (void)
{
if (m_Header.space () > 0)
{
//need to recieve the header
//need to receive the header
const size_t to_header = (message_block.length () > m_Header.space () ? m_Header.space () : message_block.length ());
m_Header.copy (message_block.rd_ptr (), to_header);
message_block.rd_ptr (to_header);
if (m_Header.space () > 0)
{
//couldnt recieve the whole header this time
// Couldn't receive the whole header this time.
ACE_ASSERT (message_block.length () == 0);
errno = EWOULDBLOCK;
return -1;
}
//we just recieved nice new header
// We just received nice new header
if (handle_input_header () == -1)
{
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
@ -482,16 +482,16 @@ int WorldSocket::handle_input_missing_data (void)
}
// Its possible on some error situations that this happens
// for example on closing when epoll recieves more chunked data and stuff
// for example on closing when epoll receives more chunked data and stuff
// hope this is not hack ,as proper m_RecvWPct is asserted around
if (!m_RecvWPct)
{
sLog.outError ("Forsing close on input m_RecvWPct = NULL");
sLog.outError ("Forcing close on input m_RecvWPct = NULL");
errno = EINVAL;
return -1;
}
// We have full readed header, now check the data payload
// We have full read header, now check the data payload
if (m_RecvPct.space () > 0)
{
//need more data in the payload
@ -501,14 +501,14 @@ int WorldSocket::handle_input_missing_data (void)
if (m_RecvPct.space () > 0)
{
//couldnt recieve the whole data this time
// Couldn't receive the whole data this time.
ACE_ASSERT (message_block.length () == 0);
errno = EWOULDBLOCK;
return -1;
}
}
//just recieved fresh new payload
//just received fresh new payload
if (handle_input_payload () == -1)
{
ACE_ASSERT ((errno != EWOULDBLOCK) && (errno != EAGAIN));
@ -570,7 +570,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
if (closing_)
return -1;
// dump recieved packet
// Dump received packet.
if (sWorldLog.LogWorld ())
{
sWorldLog.Log ("CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n",
@ -635,7 +635,7 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
{
// NOTE: ATM the socket is singlethreaded, have this in mind ...
// NOTE: ATM the socket is singlethread, have this in mind ...
uint8 digest[20];
uint32 clientSeed;
uint32 unk2, unk3;
@ -927,7 +927,7 @@ int WorldSocket::HandlePing (WorldPacket& recvPacket)
if (m_Session && m_Session->GetSecurity () == SEC_PLAYER)
{
sLog.outError ("WorldSocket::HandlePing: Player kicked for "
"overspeeded pings address = %s",
"over-speed pings address = %s",
GetRemoteAddress ().c_str ());
return -1;

View file

@ -53,36 +53,36 @@ typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> WorldHandler;
/**
* WorldSocket.
*
* This class is responsible for the comunication with
* This class is responsible for the communication with
* remote clients.
* Most methods return -1 on failure.
* The class uses refferece counting.
* The class uses reference counting.
*
* For output the class uses one buffer (64K usually) and
* a queue where it stores packet if there is no place on
* the queue. The reason this is done, is because the server
* does realy a lot of small-size writes to it, and it doesn't
* does really a lot of small-size writes to it, and it doesn't
* scale well to allocate memory for every. When something is
* writen to the output buffer the socket is not immideately
* written to the output buffer the socket is not immediately
* activated for output (again for the same reason), there
* is 10ms celling (thats why there is Update() method).
* This concept is simmilar to TCP_CORK, but TCP_CORK
* usses 200ms celling. As result overhead generated by
* This concept is similar to TCP_CORK, but TCP_CORK
* uses 200ms celling. As result overhead generated by
* sending packets from "producer" threads is minimal,
* and doing a lot of writes with small size is tollerated.
* and doing a lot of writes with small size is tolerated.
*
* The calls to Upate () method are managed by WorldSocketMgr
* The calls to Update () method are managed by WorldSocketMgr
* and ReactorRunnable.
*
* For input ,the class uses one 1024 bytes buffer on stack
* to which it does recv() calls. And then recieved data is
* distributed where its needed. 1024 matches pritey well the
* to which it does recv() calls. And then received data is
* distributed where its needed. 1024 matches pretty well the
* traffic generated by client for now.
*
* The input/output do speculative reads/writes (AKA it tryes
* to read all data avaible in the kernel buffer or tryes to
* write everything avaible in userspace buffer),
* which is ok for using with Level and Edge Trigered IO
* to read all data available in the kernel buffer or tryes to
* write everything available in userspace buffer),
* which is ok for using with Level and Edge Triggered IO
* notification.
*
*/
@ -97,7 +97,7 @@ class WorldSocket : protected WorldHandler
/// Declare the acceptor for this class
typedef ACE_Acceptor< WorldSocket, ACE_SOCK_ACCEPTOR > Acceptor;
/// Mutex type used for various syncronizations.
/// Mutex type used for various synchronizations.
typedef ACE_Thread_Mutex LockType;
typedef ACE_Guard<LockType> GuardType;
@ -118,10 +118,10 @@ class WorldSocket : protected WorldHandler
/// @return -1 of failure
int SendPacket (const WorldPacket& pct);
/// Add refference to this object.
/// Add reference to this object.
long AddReference (void);
/// Remove refference to this object.
/// Remove reference to this object.
long RemoveReference (void);
protected:
@ -183,7 +183,7 @@ class WorldSocket : protected WorldHandler
/// Time in which the last ping was received
ACE_Time_Value m_LastPingTime;
/// Keep track of overspeed pings ,to prevent ping flood.
/// Keep track of over-speed pings ,to prevent ping flood.
uint32 m_OverSpeedPings;
/// Address of the remote peer
@ -195,21 +195,21 @@ class WorldSocket : protected WorldHandler
/// Mutex lock to protect m_Session
LockType m_SessionLock;
/// Session to which recieved packets are routed
/// Session to which received packets are routed
WorldSession* m_Session;
/// here are stored the fragmens of the recieved data
/// here are stored the fragments of the received data
WorldPacket* m_RecvWPct;
/// This block actually refers to m_RecvWPct contents,
/// which alows easy and safe writing to it.
/// which allows easy and safe writing to it.
/// It wont free memory when its deleted. m_RecvWPct takes care of freeing.
ACE_Message_Block m_RecvPct;
/// Fragment of the recieved header.
/// Fragment of the received header.
ACE_Message_Block m_Header;
/// Mutex for protecting otuput related data.
/// Mutex for protecting output related data.
LockType m_OutBufferLock;
/// Buffer used for writing output.
@ -219,7 +219,7 @@ class WorldSocket : protected WorldHandler
size_t m_OutBufferSize;
/// Here are stored packets for which there was no space on m_OutBuffer,
/// this alows not-to kick player if its buffer is overflowed.
/// this allows not-to kick player if its buffer is overflowed.
PacketQueueT m_PacketQueue;
/// True if the socket is registered with the reactor for output

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "6810"
#define REVISION_NR "6816"
#endif // __REVISION_NR_H__