Fix Auth on server also some fixes and cleanups. Big thx to TOM_RUS.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-04-11 11:11:32 +04:00
parent 36e13c1d1c
commit 8db7c06e6b
19 changed files with 104 additions and 55 deletions
+2 -2
View File
@@ -1705,8 +1705,8 @@ void BattleGroundMgr::CreateInitialBattleGrounds()
//check values from DB
if (MaxPlayersPerTeam == 0 || MinPlayersPerTeam == 0 || MinPlayersPerTeam > MaxPlayersPerTeam)
{
MaxPlayersPerTeam = bl->maxplayersperteam;
MinPlayersPerTeam = bl->maxplayersperteam / 2;
MinPlayersPerTeam = 0; // by default now expected strong full bg requirement
MaxPlayersPerTeam = 40;
}
if (MinLvl == 0 || MaxLvl == 0 || MinLvl > MaxLvl)
{
+6 -2
View File
@@ -209,8 +209,12 @@ enum AchievementCriteriaTypes
// 0..115 => 116 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115,
ACHIEVEMENT_CRITERIA_TYPE_USE_LFD_TO_GROUP_WITH_PLAYERS = 119,
// 0..119 => 120 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 120,
// 120
// 121
// 122
// 123
// 0..123 => 124 criteria types total
ACHIEVEMENT_CRITERIA_TYPE_TOTAL = 124,
};
enum AreaFlags
+10 -10
View File
@@ -596,13 +596,13 @@ struct BattlemasterListEntry
uint32 id; // 0
int32 mapid[8]; // 1-8 mapid
uint32 type; // 9 (3 - BG, 4 - arena)
uint32 maxplayersperteam; // 10
//uint32 unk1; // 11 (0 or 1)
char* name[16]; // 12-27
// 28 string flag, unused
// 29 unused
//uint32 unk2; // 30 new 3.1
//uint32 canJoinAsGroup; // 10 (0 or 1)
char* name[16]; // 11-26
//uint32 nameFlags // 27 string flag, unused
//uint32 maxGroupSize // 28 maxGroupSize, used for checking if queue as group
//uint32 HolidayWorldStateId; // 29 new 3.1
//uint32 MinLevel; // 30
//uint32 SomeLevel; // 31, may be max level
};
#define MAX_OUTFIT_ITEMS 24
@@ -1434,8 +1434,8 @@ struct SpellEntry
int32 EquippedItemInventoryTypeMask; // 70 m_equippedItemInvTypes (mask)
uint32 Effect[MAX_SPELL_EFFECTS]; // 71-73 m_effect
int32 EffectDieSides[MAX_SPELL_EFFECTS]; // 74-76 m_effectDieSides
int32 EffectBaseDice[MAX_SPELL_EFFECTS]; // 77-79 m_effectBaseDice
float EffectDicePerLevel[MAX_SPELL_EFFECTS]; // 80-82 m_effectDicePerLevel
//int32 EffectBaseDice[MAX_SPELL_EFFECTS]; // 77-79 m_effectBaseDice
//float EffectDicePerLevel[MAX_SPELL_EFFECTS]; // 80-82 m_effectDicePerLevel
float EffectRealPointsPerLevel[MAX_SPELL_EFFECTS]; // 83-85 m_effectRealPointsPerLevel
int32 EffectBasePoints[MAX_SPELL_EFFECTS]; // 86-88 m_effectBasePoints (don't must be used in spell/auras explicitly, must be used cached Spell::m_currentBasePoints)
uint32 EffectMechanic[MAX_SPELL_EFFECTS]; // 89-91 m_effectMechanic
@@ -1525,7 +1525,7 @@ struct SpellEntry
//uint32 spellDescriptionVariableID; // 238 3.2.0
*/
// helpers
int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(EffectBaseDice[eff]); }
int32 CalculateSimpleValue(uint8 eff) const { return EffectBasePoints[eff]+int32(1); }
private:
// prevent creating custom entries (copy data from original in fact)
+2 -2
View File
@@ -30,7 +30,7 @@ const char AreaTriggerEntryfmt[]="niffffffff";
const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx";
const char BankBagSlotPricesEntryfmt[]="ni";
const char BarberShopStyleEntryfmt[]="nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii";
const char BattlemasterListEntryfmt[]="niiiiiiiiiixssssssssssssssssxxx";
const char BattlemasterListEntryfmt[]="niiiiiiiiixssssssssssssssssxxxxx";
const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi";
const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
@@ -93,7 +93,7 @@ const char SpellDifficultyfmt[]="niiii";
const std::string CustomSpellDifficultyfmt="ppppp";
const std::string CustomSpellDifficultyIndex="id";
const char SpellDurationfmt[]="niii";
const char SpellEntryfmt[]="niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
const char SpellEntryfmt[]="niiiiiiiiiixixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxx";
const std::string CustomSpellEntryfmt="pappppppppaaaaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
const std::string CustomSpellEntryIndex = "Id";
const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
+2 -2
View File
@@ -330,8 +330,8 @@ void Item::SaveToDB()
}break;
case ITEM_REMOVED:
{
if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
//if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
// CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
+1 -1
View File
@@ -717,7 +717,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket & recv_data)
return;
}
bodyItem->SetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID , itemTextId);
//bodyItem->SetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID , itemTextId);
bodyItem->SetUInt32Value(ITEM_FIELD_CREATOR, m->sender);
sLog.outDetail("HandleMailCreateTextItem mailid=%u",mailId);
+12 -5
View File
@@ -1443,13 +1443,20 @@ void WorldSession::HandleTimeSyncResp(WorldPacket & recv_data)
{
sLog.outDebug("CMSG_TIME_SYNC_RESP");
uint32 counter, time_;
recv_data >> counter >> time_;
uint32 counter, clientTicks;
recv_data >> counter >> clientTicks;
// time_ seems always more than getMSTime()
uint32 diff = getMSTimeDiff(getMSTime(),time_);
if (counter != _player->m_timeSyncCounter - 1)
sLog.outDebug("Wrong time sync counter from player %s (cheater?)", _player->GetName());
sLog.outDebug("response sent: counter %u, time %u (HEX: %X), ms. time %u, diff %u", counter, time_, time_, getMSTime(), diff);
sLog.outDebug("Time sync received: counter %u, client ticks %u, time since last sync %u", counter, clientTicks, clientTicks - _player->m_timeSyncClient);
uint32 ourTicks = clientTicks + (getMSTime() - _player->m_timeSyncServer);
// diff should be small
sLog.outDebug("Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - clientTicks, GetLatency());
_player->m_timeSyncClient = clientTicks;
}
void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/)
+20 -2
View File
@@ -1322,8 +1322,26 @@ enum Opcodes
UMSG_UNKNOWN_1283 = 0x503,
UMSG_UNKNOWN_1284 = 0x504,
UMSG_UNKNOWN_1285 = 0x505,
UMSG_UNKNOWN_1286 = 0x506,
NUM_MSG_TYPES = 0x507
SMSG_UNKNOWN_1286 = 0x506, // ERR_CORPSE_IS_NOT_IN_INSTANCE = 0x1A8,
UMSG_UNKNOWN_1287 = 0x507, // not found
CMSG_UNKNOWN_1288 = 0x508, // lua: SetAllowLowLevelRaid
CMSG_UNKNOWN_1289 = 0x509, // lua: SetAllowLowLevelRaid
SMSG_UNKNOWN_1290 = 0x50A, // camera shake?
SMSG_UNKNOWN_1291 = 0x50B, // some item update packet?
UMSG_UNKNOWN_1292 = 0x50C, // not found
UMSG_UNKNOWN_1293 = 0x50D, // not found - disconnect
CMSG_UNKNOWN_1294 = 0x50E, // something with networking
UMSG_UNKNOWN_1295 = 0x50F, // not found - disconnect
CMSG_UNKNOWN_1296 = 0x510, // something with networking
UMSG_UNKNOWN_1297 = 0x511, // not found - crash
CMSG_UNKNOWN_1298 = 0x512, // something with networking
UMSG_UNKNOWN_1299 = 0x513, // not found
SMSG_UNKNOWN_1300 = 0x514, // SMSG
SMSG_UNKNOWN_1301 = 0x515, // event 0x204 (opens dungeon finder, probably for outdoor bosses)
SMSG_UNKNOWN_1302 = 0x516, // something with player movement (move event 58?)
CMSG_UNKNOWN_1303 = 0x517, // something with player movement (move event 58?)
SMSG_UNKNOWN_1304 = 0x518, // something with player movement (move event 58?), speed packet
NUM_MSG_TYPES = 0x519
};
/// Player state
+19 -6
View File
@@ -1607,8 +1607,18 @@ bool Player::BuildEnumData(QueryResult_AutoPtr result, WorldPacket * p_data)
*p_data << uint8(proto->InventoryType);
*p_data << uint32(enchant ? enchant->aura_id : 0);
}
*p_data << uint32(0); // first bag display id
*p_data << uint8(0); // first bag inventory type
*p_data << uint32(0); // bag 1 display id
*p_data << uint8(0); // bag 1 inventory type
*p_data << uint32(0); // enchant?
*p_data << uint32(0); // bag 2 display id
*p_data << uint8(0); // bag 2 inventory type
*p_data << uint32(0); // enchant?
*p_data << uint32(0); // bag 3 display id
*p_data << uint8(0); // bag 3 inventory type
*p_data << uint32(0); // enchant?
*p_data << uint32(0); // bag 4 display id
*p_data << uint8(0); // bag 4 inventory type
*p_data << uint32(0); // enchant?
return true;
@@ -23343,18 +23353,21 @@ void Player::ActivateSpec(uint8 spec)
void Player::ResetTimeSync()
{
m_timeSyncCount = 0;
m_timeSyncCounter = 0;
m_timeSyncTimer = 0;
m_timeSyncClient = 0;
m_timeSyncServer = getMSTime();
}
void Player::SendTimeSync()
{
WorldPacket data(SMSG_TIME_SYNC_REQ, 4);
data << uint32(m_timeSyncCount++);
data << uint32(m_timeSyncCounter++);
GetSession()->SendPacket(&data);
// Send another opcode in 10s again
m_timeSyncTimer = 10000;
// Schedule next sync in 10 sec
m_timeSyncTimer = 10000;
m_timeSyncServer = getMSTime();
}
void Player::SetReputation(uint32 factionentry, uint32 value)
+4 -2
View File
@@ -2618,8 +2618,10 @@ class Player : public Unit, public GridObject<Player>
uint32 m_ChampioningFaction;
uint32 m_timeSyncCount;
uint32 m_timeSyncTimer;
uint32 m_timeSyncCounter;
uint32 m_timeSyncTimer;
uint32 m_timeSyncClient;
uint32 m_timeSyncServer;
};
void AddItemsSetItem(Player*player,Item *item);
+2 -2
View File
@@ -312,8 +312,8 @@ void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
{
case DTT_INVENTORY:
StoreGUID(result,3,items); break; // item guid collection
case DTT_ITEM:
StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break;
//case DTT_ITEM:
//StoreGUID(result,0,ITEM_FIELD_ITEM_TEXT_ID,texts); break;
// item text id collection
case DTT_PET:
StoreGUID(result,0,pets); break; // pet guid collection
+4 -4
View File
@@ -12240,14 +12240,14 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde
level -= int32(spellProto->spellLevel);
float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index];
float randomPointsPerLevel = spellProto->EffectDicePerLevel[effect_index];
float randomPointsPerLevel = 1;
int32 basePoints = int32(effBasePoints + level * basePointsPerLevel);
int32 randomPoints = int32(spellProto->EffectDieSides[effect_index] + level * randomPointsPerLevel);
// range can have possitive and negative values, so order its for irand
int32 randvalue = int32(spellProto->EffectBaseDice[effect_index]) >= randomPoints
? irand(randomPoints, int32(spellProto->EffectBaseDice[effect_index]))
: irand(int32(spellProto->EffectBaseDice[effect_index]), randomPoints);
int32 randvalue = int32(1) >= randomPoints
? irand(randomPoints, int32(1))
: irand(int32(1), randomPoints);
int32 value = basePoints + randvalue;
//random damage
+3 -3
View File
@@ -23,7 +23,7 @@
#include "Log.h"
#include "BigNumber.h"
AuthCrypt::AuthCrypt()
AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH)
{
_initialized = false;
}
@@ -35,11 +35,11 @@ AuthCrypt::~AuthCrypt()
void AuthCrypt::Init(BigNumber *K)
{
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0x22, 0xBE, 0xE5, 0xCF, 0xBB, 0x07, 0x64, 0xD9, 0x00, 0x45, 0x1B, 0xD0, 0x24, 0xB8, 0xD5, 0x45 };
uint8 ServerEncryptionKey[SEED_KEY_SIZE] = { 0xCC, 0x98, 0xAE, 0x04, 0xE8, 0x97, 0xEA, 0xCA, 0x12, 0xDD, 0xC0, 0x93, 0x42, 0x91, 0x53, 0x57 };
HmacHash serverEncryptHmac(SEED_KEY_SIZE, (uint8*)ServerEncryptionKey);
uint8 *encryptHash = serverEncryptHmac.ComputeHash(K);
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xF4, 0x66, 0x31, 0x59, 0xFC, 0x83, 0x6E, 0x31, 0x31, 0x02, 0x51, 0xD5, 0x44, 0x31, 0x67, 0x98 };
uint8 ServerDecryptionKey[SEED_KEY_SIZE] = { 0xC2, 0xB3, 0x72, 0x3C, 0xC6, 0xAE, 0xD9, 0xB5, 0x34, 0x3C, 0x53, 0xEE, 0x2F, 0x43, 0x67, 0xCE };
HmacHash clientDecryptHmac(SEED_KEY_SIZE, (uint8*)ServerDecryptionKey);
uint8 *decryptHash = clientDecryptHmac.ComputeHash(K);
+3 -2
View File
@@ -166,7 +166,7 @@ bool BigNumber::isZero() const
return BN_is_zero(_bn)!=0;
}
uint8 *BigNumber::AsByteArray(int minSize)
uint8 *BigNumber::AsByteArray(int minSize, bool reverse)
{
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();
@@ -183,7 +183,8 @@ uint8 *BigNumber::AsByteArray(int minSize)
BN_bn2bin(_bn, (unsigned char *)_array);
std::reverse(_array, _array + length);
if (reverse)
std::reverse(_array, _array + length);
return _array;
}
+1 -1
View File
@@ -83,7 +83,7 @@ class BigNumber
struct bignum_st *BN() { return _bn; }
uint32 AsDword();
uint8* AsByteArray(int minSize = 0);
uint8* AsByteArray(int minSize = 0, bool reverse = true);
const char *AsHexStr();
const char *AsDecStr();
+6 -3
View File
@@ -23,10 +23,8 @@
HmacHash::HmacHash(uint32 len, uint8 *seed)
{
ASSERT(len == SEED_KEY_SIZE);
HMAC_CTX_init(&m_ctx);
HMAC_Init_ex(&m_ctx, seed, SEED_KEY_SIZE, EVP_sha1(), NULL);
HMAC_Init_ex(&m_ctx, seed, len, EVP_sha1(), NULL);
}
HmacHash::~HmacHash()
@@ -44,6 +42,11 @@ void HmacHash::UpdateData(const uint8 *data, int length)
HMAC_Update(&m_ctx, data, length);
}
void HmacHash::UpdateData(const std::string &str)
{
UpdateData((uint8 const*)str.c_str(), str.length());
}
void HmacHash::Finalize()
{
uint32 length = 0;
+1
View File
@@ -36,6 +36,7 @@ class HmacHash
~HmacHash();
void UpdateBigNumber(BigNumber *bn);
void UpdateData(const uint8 *data, int length);
void UpdateData(const std::string &str);
void Finalize();
uint8 *ComputeHash(BigNumber *bn);
uint8 *GetDigest() { return (uint8*)m_digest; }
+4 -4
View File
@@ -19,18 +19,18 @@
#include "Auth/SARC4.h"
#include <openssl/sha.h>
SARC4::SARC4()
SARC4::SARC4(uint8 len)
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
}
SARC4::SARC4(uint8 *seed)
SARC4::SARC4(uint8 *seed, uint8 len)
{
EVP_CIPHER_CTX_init(&m_ctx);
EVP_EncryptInit_ex(&m_ctx, EVP_rc4(), NULL, NULL, NULL);
EVP_CIPHER_CTX_set_key_length(&m_ctx, SHA_DIGEST_LENGTH);
EVP_CIPHER_CTX_set_key_length(&m_ctx, len);
EVP_EncryptInit_ex(&m_ctx, NULL, NULL, seed, NULL);
}
+2 -2
View File
@@ -25,8 +25,8 @@
class SARC4
{
public:
SARC4();
SARC4(uint8 *seed);
SARC4(uint8 len);
SARC4(uint8 *seed, uint8 len);
~SARC4();
void Init(uint8 *seed);
void UpdateData(int len, uint8 *data);