Skip to content

Commit

Permalink
[9633] Some code clean up.
Browse files Browse the repository at this point in the history
Signed-off-by: hunuza <hunuza@gmail.com>
  • Loading branch information
hunuza committed Mar 28, 2010
1 parent c004378 commit 0a54580
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/game/Level3.cpp
Expand Up @@ -3961,7 +3961,7 @@ bool ChatHandler::HandleExploreCheatCommand(const char* args)
ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING,GetNameLink().c_str());
}

for (uint8 i=0; i<128; ++i)
for (uint8 i=0; i<PLAYER_EXPLORED_ZONES_SIZE; ++i)
{
if (flag != 0)
{
Expand Down Expand Up @@ -4118,7 +4118,7 @@ bool ChatHandler::HandleShowAreaCommand(const char* args)
int offset = area / 32;
uint32 val = (uint32)(1 << (area % 32));

if(area<0 || offset >= 128)
if(area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
Expand Down Expand Up @@ -4149,7 +4149,7 @@ bool ChatHandler::HandleHideAreaCommand(const char* args)
int offset = area / 32;
uint32 val = (uint32)(1 << (area % 32));

if(area<0 || offset >= 128)
if(area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
SendSysMessage(LANG_BAD_VALUE);
SetSentErrorMessage(true);
Expand Down
47 changes: 15 additions & 32 deletions src/game/Player.cpp
Expand Up @@ -608,10 +608,10 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
SetUInt32Value( PLAYER_GUILDRANK, 0 );
SetUInt32Value( PLAYER_GUILD_TIMESTAMP, 0 );

SetUInt64Value( PLAYER__FIELD_KNOWN_TITLES, 0 ); // 0=disabled
SetUInt64Value( PLAYER__FIELD_KNOWN_TITLES1, 0 ); // 0=disabled
SetUInt64Value( PLAYER__FIELD_KNOWN_TITLES2, 0 ); // 0=disabled
for(int i = 0; i < KNOWN_TITLES_SIZE; ++i)
SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES + i, 0); // 0=disabled
SetUInt32Value( PLAYER_CHOSEN_TITLE, 0 );

SetUInt32Value( PLAYER_FIELD_KILLS, 0 );
SetUInt32Value( PLAYER_FIELD_LIFETIME_HONORBALE_KILLS, 0 );
SetUInt32Value( PLAYER_FIELD_TODAY_CONTRIBUTION, 0 );
Expand Down Expand Up @@ -5889,9 +5889,9 @@ void Player::CheckExploreSystem()
return;
int offset = areaFlag / 32;

if(offset >= 128)
if(offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
sLog.outError("Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < 128 ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset);
sLog.outError("Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < %u ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset, PLAYER_EXPLORED_ZONES_SIZE);
return;
}

Expand Down Expand Up @@ -14651,39 +14651,21 @@ float Player::GetFloatValueFromArray(Tokens const& data, uint16 index)
return result;
}

void Player::_LoadExploredZones(const char* data)
void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count)
{
if(!data)
return;

Tokens tokens = StrSplit(data, " ");

if(tokens.size() != 128)
if(tokens.size() != count)
return;

Tokens::iterator iter;
int index;
for (iter = tokens.begin(), index = 0; index < 128; ++iter, ++index)
uint32 index;
for (iter = tokens.begin(), index = 0; index < count; ++iter, ++index)
{
m_uint32Values[PLAYER_EXPLORED_ZONES_1 + index] = atol((*iter).c_str());
}
}

void Player::_LoadKnownTitles(const char* data)
{
if(!data)
return;

Tokens tokens = StrSplit(data, " ");

if(tokens.size() != 6)
return;

Tokens::iterator iter;
int index;
for (iter = tokens.begin(), index = 0; index < 6; ++iter, ++index)
{
m_uint32Values[PLAYER__FIELD_KNOWN_TITLES + index] = atol((*iter).c_str());
m_uint32Values[startOffset + index] = atol((*iter).c_str());
}
}

Expand Down Expand Up @@ -14746,8 +14728,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8());
SetUInt32Value(PLAYER_XP, fields[7].GetUInt32());

_LoadExploredZones(fields[60].GetString());
_LoadKnownTitles(fields[63].GetString());
_LoadIntoDataField(fields[60].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
_LoadIntoDataField(fields[63].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2);

SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
Expand Down Expand Up @@ -16368,7 +16351,7 @@ void Player::SaveToDB()
ss << ", ";
ss << uint32(m_specsCount) << ", ";
ss << uint32(m_activeSpec) << ", '";
for(uint32 i = 0; i < 128; ++i )
for(uint32 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i )
{
ss << GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + i) << " ";
}
Expand All @@ -16381,7 +16364,7 @@ void Player::SaveToDB()

ss << "',";
ss << GetUInt32Value(PLAYER_AMMO_ID) << ", '";
for(uint32 i = 0; i < 6; ++i )
for(uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i )
{
ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << " ";
}
Expand Down
11 changes: 6 additions & 5 deletions src/game/Player.h
Expand Up @@ -57,8 +57,9 @@ class Item;

typedef std::deque<Mail*> PlayerMails;

#define PLAYER_MAX_SKILLS 127
#define PLAYER_MAX_DAILY_QUESTS 25
#define PLAYER_MAX_SKILLS 127
#define PLAYER_MAX_DAILY_QUESTS 25
#define PLAYER_EXPLORED_ZONES_SIZE 128

// Note: SPELLMOD_* values is aura types in fact
enum SpellModType
Expand Down Expand Up @@ -548,7 +549,8 @@ enum PlayerFlags
#define PLAYER_TITLE_HAND_OF_ADAL UI64LIT(0x0000008000000000) // 39
#define PLAYER_TITLE_VENGEFUL_GLADIATOR UI64LIT(0x0000010000000000) // 40

#define MAX_TITLE_INDEX (3*64) // 3 uint64 fields
#define KNOWN_TITLES_SIZE 3
#define MAX_TITLE_INDEX (KNOWN_TITLES_SIZE*64) // 3 uint64 fields

// used in PLAYER_FIELD_BYTES values
enum PlayerFieldByteFlags
Expand Down Expand Up @@ -2320,8 +2322,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void _LoadEquipmentSets(QueryResult *result);
void _LoadBGData(QueryResult* result);
void _LoadGlyphs(QueryResult *result);
void _LoadExploredZones(const char* data);
void _LoadKnownTitles(const char* data);
void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count);

/*********************************************************/
/*** SAVE SYSTEM ***/
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 "9632"
#define REVISION_NR "9633"
#endif // __REVISION_NR_H__

0 comments on commit 0a54580

Please sign in to comment.