Experimenting with packets

This commit is contained in:
KimLS 2015-06-09 12:39:39 -07:00
parent 250d0cc903
commit dbbe6b5a91
9 changed files with 59 additions and 148 deletions

View File

@ -4243,7 +4243,7 @@ struct AARankInfo_Struct
int32 total_cost; int32 total_cost;
int32 expansion; int32 expansion;
int32 category; int32 category;
uint8 expendable; uint8 charges;
uint8 grant_only; uint8 grant_only;
uint32 total_effects; uint32 total_effects;
uint32 total_prereqs; uint32 total_prereqs;

View File

@ -2177,7 +2177,7 @@ namespace UF
eq->next_id = emu->next_id; eq->next_id = emu->next_id;
eq->cost2 = emu->total_cost; eq->cost2 = emu->total_cost;
eq->grant_only = emu->grant_only > 0 ? true : false; eq->grant_only = emu->grant_only > 0 ? true : false;
eq->expendable_charges = emu->expendable ? 1 : 0; eq->expendable_charges = emu->charges ? 1 : 0;
eq->aa_expansion = emu->expansion; eq->aa_expansion = emu->expansion;
eq->special_category = emu->category; eq->special_category = emu->category;
eq->total_abilities = emu->total_effects; eq->total_abilities = emu->total_effects;

View File

@ -1101,6 +1101,14 @@ void Client::SendAATable() {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RespondAA, sizeof(AATable_Struct)); EQApplicationPacket* outapp = new EQApplicationPacket(OP_RespondAA, sizeof(AATable_Struct));
AATable_Struct* aa2 = (AATable_Struct *)outapp->pBuffer; AATable_Struct* aa2 = (AATable_Struct *)outapp->pBuffer;
aa2->aa_spent = 8;
//aa2->aa_list[0].AA = 11;
//aa2->aa_list[0].value = 4;
//aa2->aa_list[0].charges = 0;
//aa2->aa_list[1].AA = 202;
//aa2->aa_list[1].value = 4;
//aa2->aa_list[1].charges = 0;
//aa2->aa_spent = GetAAPointsSpent(); //aa2->aa_spent = GetAAPointsSpent();
// //
//uint32 i; //uint32 i;
@ -2089,13 +2097,16 @@ Mob *AA_SwarmPetInfo::GetOwner()
} }
void Client::SendAlternateAdvancementList() { void Client::SendAlternateAdvancementList() {
for(auto &aa : zone->aa_abilities) { //for(auto &aa : zone->aa_abilities) {
SendAlternateAdvancement(aa.first, true); // SendAlternateAdvancement(aa.first, 5);
} //}
SendAlternateAdvancement(1, 4);
SendAlternateAdvancement(2, 4);
} }
//New AA //New AA
void Client::SendAlternateAdvancement(int aa_id, bool first_login) { void Client::SendAlternateAdvancement(int aa_id, int level) {
if(!zone) if(!zone)
return; return;
@ -2108,8 +2119,12 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
return; return;
} }
if(ability->account_time_required) { AA::Rank *rank = ability->GetRankByPointsSpent(level + 1);
if((Timer::GetTimeSeconds() - account_creation) < ability->account_time_required) if(!rank)
return;
if(rank->account_time_required) {
if((Timer::GetTimeSeconds() - account_creation) < rank->account_time_required)
{ {
return; return;
} }
@ -2120,9 +2135,9 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
//if(GetAA(saa2->id) == 0) //if(GetAA(saa2->id) == 0)
// return; // return;
if(ability->expansion > 0) { if(rank->expansion > 0) {
AA::Ability *qaa = zone->GetAlternateAdvancementAbility(aa_id + 1); AA::Ability *qaa = zone->GetAlternateAdvancementAbility(aa_id + 1);
//if(qaa && qaa->expansion == ability->expansion && GetAA(aa_id) > 0) { //if(qaa && qaa->expansion == rank->expansion && GetAA(aa_id) > 0) {
// return; // return;
//} //}
} }
@ -2140,33 +2155,28 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
uint32 client_race = GetBaseRace(); uint32 client_race = GetBaseRace();
// Drakkin Bloodlines // Drakkin Bloodlines
if(ability->expansion > 522) if(rank->expansion > 522)
{ {
if(client_race != 522) if(client_race != 522)
return; return;
int heritage = this->GetDrakkinHeritage() + 523; // 523 = Drakkin Race(522) + Bloodline int heritage = this->GetDrakkinHeritage() + 523; // 523 = Drakkin Race(522) + Bloodline
if(heritage != ability->expansion) if(heritage != rank->expansion)
return; return;
} }
else if(client_race != ability->expansion) else if(client_race != rank->expansion)
{ {
return; return;
} }
} }
//Send first rank
AA::Rank *rank = ability->first;
if(!rank)
return;
//Should move this to another function //Should move this to another function
int size = sizeof(AARankInfo_Struct)+(sizeof(AARankEffect_Struct)* rank->effects.size()) + (sizeof(AARankPrereq_Struct)* rank->prereqs.size()); int size = sizeof(AARankInfo_Struct)+(sizeof(AARankEffect_Struct)* rank->effects.size()) + (sizeof(AARankPrereq_Struct)* rank->prereqs.size());
EQApplicationPacket *outapp = new EQApplicationPacket(OP_SendAATable, size); EQApplicationPacket *outapp = new EQApplicationPacket(OP_SendAATable, size);
AARankInfo_Struct *aai = (AARankInfo_Struct*)outapp->pBuffer; AARankInfo_Struct *aai = (AARankInfo_Struct*)outapp->pBuffer;
aai->id = rank->id; aai->id = ability->GetMaxRank()->id;
aai->upper_hotkey_sid = rank->upper_hotkey_sid; aai->upper_hotkey_sid = rank->upper_hotkey_sid;
aai->lower_hotkey_sid = rank->lower_hotkey_sid; aai->lower_hotkey_sid = rank->lower_hotkey_sid;
aai->title_sid = rank->title_sid; aai->title_sid = rank->title_sid;
@ -2174,7 +2184,7 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
aai->level_req = rank->level_req; aai->level_req = rank->level_req;
aai->cost = rank->cost; aai->cost = rank->cost;
aai->seq = aa_id; aai->seq = aa_id;
aai->current_level = 1; aai->current_level = level + 1;
aai->type = ability->type; aai->type = ability->type;
aai->spell = rank->spell; aai->spell = rank->spell;
aai->spell_type = rank->spell_type; aai->spell_type = rank->spell_type;
@ -2184,9 +2194,9 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
aai->prev_id = rank->prev_id; aai->prev_id = rank->prev_id;
aai->next_id = rank->next_id; aai->next_id = rank->next_id;
aai->total_cost = rank->total_cost; aai->total_cost = rank->total_cost;
aai->expansion = ability->expansion; aai->expansion = rank->expansion;
aai->category = ability->category; aai->category = ability->category;
aai->expendable = ability->expendable; aai->charges = ability->charges;
aai->grant_only = ability->grant_only; aai->grant_only = ability->grant_only;
aai->total_effects = rank->effects.size(); aai->total_effects = rank->effects.size();
aai->total_prereqs = rank->prereqs.size(); aai->total_prereqs = rank->prereqs.size();
@ -2204,106 +2214,8 @@ void Client::SendAlternateAdvancement(int aa_id, bool first_login) {
outapp->WriteSInt32(prereq.points); outapp->WriteSInt32(prereq.points);
} }
//if first_login then also send current rank if not maxed
QueuePacket(outapp); QueuePacket(outapp);
safe_delete(outapp); safe_delete(outapp);
//
//if(size == 0)
// return;
//
//uchar* buffer = new uchar[size];
//SendAA_Struct* saa = (SendAA_Struct*)buffer;
//memcpy(saa, saa2, size);
//
//if(saa->spellid == 0)
// saa->spellid = 0xFFFFFFFF;
//
//value = GetAA(saa->id);
//uint32 orig_val = value;
//
//if(value && saa->id){
//
// if(value < saa->max_level){
// saa->id += value;
// saa->next_id = saa->id + 1;
// value++;
// }
//
// else if(aa_stack && saa->sof_next_id){
// saa->id += value - 1;
// saa->next_id = saa->sof_next_id;
//
// //Prevent removal of previous AA from window if next AA belongs to a higher client version.
// SendAA_Struct* saa_next = nullptr;
// saa_next = zone->FindAA(saa->sof_next_id);
//
// // this check should work as long as we continue to just add the clients and just increase
// // each number ....
// if(saa_next && static_cast<int>(GetClientVersion()) < saa_next->clientver - 1) {
// saa->next_id = 0xFFFFFFFF;
// }
// }
//
// else{
// saa->id += value - 1;
// saa->next_id = 0xFFFFFFFF;
// }
//
// uint32 current_level_mod = 0;
// if(aa_stack)
// current_level_mod = saa->sof_current_level;
//
// saa->last_id = saa->id - 1;
// saa->current_level = value + (current_level_mod);
// saa->cost = saa2->cost + (saa2->cost_inc*(value - 1));
// saa->cost2 = 0;
// for(uint32 i = 0; i < value; i++) {
// saa->cost2 += saa2->cost + (saa2->cost_inc * i);
// }
// saa->class_type = saa2->class_type + (saa2->level_inc*(value - 1));
//}
//
//if(aa_stack){
//
// if(saa->sof_current_level >= 1 && value == 0)
// saa->current_level = saa->sof_current_level + 1;
//
// saa->max_level = saa->sof_max_level;
//}
//
//database.FillAAEffects(saa);
//
//if(value > 0)
//{
// // AA_Action stores the base ID
// const AA_DBAction *caa = &AA_Actions[saa->id - value + 1][value - 1];
//
// if(caa && caa->reuse_time > 0)
// saa->spell_refresh = CalcAAReuseTimer(caa);
//}
//
////You can now use the level_inc field in the altadv_vars table to accomplish this, though still needed
////for special cases like LOH/HT due to inability to implement correct stacking of AA's that use hotkeys.
//std::map<uint32, AALevelCost_Struct>::iterator RequiredLevel = AARequiredLevelAndCost.find(saa->id);
//
//if(RequiredLevel != AARequiredLevelAndCost.end())
//{
// saa->class_type = RequiredLevel->second.Level;
// saa->cost = RequiredLevel->second.Cost;
//}
//
//
//EQApplicationPacket* outapp = new EQApplicationPacket(OP_SendAATable);
//outapp->size = size;
//outapp->pBuffer = (uchar*)saa;
//if(id == 0 && value && (orig_val < saa->max_level)) //send previous AA only on zone in
// SendPreviousAA(id, seq);
//
//QueuePacket(outapp);
//safe_delete(outapp);
////will outapp delete the buffer for us even though it didnt make it? --- Yes, it should
} }
void Zone::LoadAlternateAdvancement() { void Zone::LoadAlternateAdvancement() {
@ -2366,21 +2278,19 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
{ {
Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities..."); Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities...");
abilities.clear(); abilities.clear();
std::string query = "SELECT id, name, expansion, category, classes, type, expendable, account_time_required, grant_only, first_rank_id FROM aa_ability"; std::string query = "SELECT id, name, category, classes, type, charges, grant_only, first_rank_id FROM aa_ability";
auto results = QueryDatabase(query); auto results = QueryDatabase(query);
if(results.Success()) { if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) { for(auto row = results.begin(); row != results.end(); ++row) {
AA::Ability *ability = new AA::Ability; AA::Ability *ability = new AA::Ability;
int id = atoi(row[0]); int id = atoi(row[0]);
ability->name = row[1]; ability->name = row[1];
ability->expansion = atoi(row[2]); ability->category = atoi(row[2]);
ability->category = atoi(row[3]); ability->classes = atoi(row[3]);
ability->classes = atoi(row[4]); ability->type = atoi(row[4]);
ability->type = atoi(row[5]); ability->charges = atoi(row[5]);
ability->expendable = atoi(row[6]) != 0 ? true : false; ability->grant_only = atoi(row[6]) != 0 ? true : false;
ability->account_time_required = atoul(row[7]); ability->first_rank_id = atoi(row[7]);
ability->grant_only = atoi(row[8]) != 0 ? true : false;
ability->first_rank_id = atoi(row[9]);
ability->first = nullptr; ability->first = nullptr;
abilities[id] = std::unique_ptr<AA::Ability>(ability); abilities[id] = std::unique_ptr<AA::Ability>(ability);
@ -2395,7 +2305,7 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks..."); Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks...");
ranks.clear(); ranks.clear();
query = "SELECT id, upper_hotkey_sid, lower_hotkey_sid, title_sid, desc_sid, cost, level_req, spell, spell_type, recast_time, " query = "SELECT id, upper_hotkey_sid, lower_hotkey_sid, title_sid, desc_sid, cost, level_req, spell, spell_type, recast_time, "
"prev_id, next_id FROM aa_ranks"; "prev_id, next_id, expansion, account_time_required FROM aa_ranks";
results = QueryDatabase(query); results = QueryDatabase(query);
if(results.Success()) { if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) { for(auto row = results.begin(); row != results.end(); ++row) {
@ -2413,6 +2323,8 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
rank->recast_time = atoi(row[9]); rank->recast_time = atoi(row[9]);
rank->prev_id = atoi(row[10]); rank->prev_id = atoi(row[10]);
rank->next_id = atoi(row[11]); rank->next_id = atoi(row[11]);
rank->expansion = atoi(row[12]);
rank->account_time_required = atoul(row[13]);
rank->base_ability = nullptr; rank->base_ability = nullptr;
rank->total_cost = 0; rank->total_cost = 0;
rank->next = nullptr; rank->next = nullptr;

View File

@ -33,17 +33,16 @@ AA::Rank *AA::Ability::GetMaxRank() {
} }
AA::Rank *AA::Ability::GetRankByPointsSpent(int current_level) { AA::Rank *AA::Ability::GetRankByPointsSpent(int current_level) {
if(current_level == 0)
return nullptr;
if(!first) if(!first)
return nullptr; return nullptr;
if(current_level == 0) {
return GetMaxRank();
}
int i = 1; int i = 1;
Rank *current = first; Rank *current = first;
while(current->next) { while(current->next) {
if(1 == current_level) { if(i == current_level) {
break; break;
} }

View File

@ -37,17 +37,16 @@ public:
~Ability() { } ~Ability() { }
Rank *GetMaxRank(); Rank *GetMaxRank();
Rank *GetRankByLevel(int level);
Rank *GetRankByPointsSpent(int current_level); Rank *GetRankByPointsSpent(int current_level);
int GetMaxLevel(bool force_calc = false); int GetMaxLevel(bool force_calc = false);
std::string name; std::string name;
int expansion;
int category; int category;
int classes; int classes;
uint32 account_time_required;
bool grant_only; bool grant_only;
int type; int type;
bool expendable; int charges;
int first_rank_id; int first_rank_id;
int max_level; int max_level;
Rank *first; Rank *first;

View File

@ -43,6 +43,8 @@ public:
Rank *prev; Rank *prev;
int next_id; int next_id;
Rank *next; Rank *next;
int expansion;
uint32 account_time_required;
int total_cost; int total_cost;
Ability *base_ability; Ability *base_ability;
std::unordered_map<int, RankEffect> effects; std::unordered_map<int, RankEffect> effects;

View File

@ -760,7 +760,7 @@ public:
inline PTimerList &GetPTimers() { return(p_timers); } inline PTimerList &GetPTimers() { return(p_timers); }
//New AA Methods //New AA Methods
void SendAlternateAdvancement(int aa_id, bool first_login = false); void SendAlternateAdvancement(int aa_id, int level);
void SendAlternateAdvancementList(); void SendAlternateAdvancementList();
//old AA Methods //old AA Methods

View File

@ -1091,10 +1091,7 @@ void Client::Handle_Connect_OP_SendAAStats(const EQApplicationPacket *app)
void Client::Handle_Connect_OP_SendAATable(const EQApplicationPacket *app) void Client::Handle_Connect_OP_SendAATable(const EQApplicationPacket *app)
{ {
//SendAAList();
SendAlternateAdvancementList(); SendAlternateAdvancementList();
return; return;
} }

View File

@ -674,12 +674,14 @@ void command_incstat(Client* c, const Seperator* sep){
} }
void command_resetaa(Client* c,const Seperator *sep){ void command_resetaa(Client* c,const Seperator *sep){
if(c->GetTarget()!=0 && c->GetTarget()->IsClient()){ c->SendAlternateAdvancement(1, 1);
c->GetTarget()->CastToClient()->ResetAA(); c->SendAlternateAdvancement(2, 1);
c->Message(13,"Successfully reset %s's AAs", c->GetTarget()->GetName()); //if(c->GetTarget()!=0 && c->GetTarget()->IsClient()){
} // c->GetTarget()->CastToClient()->ResetAA();
else // c->Message(13,"Successfully reset %s's AAs", c->GetTarget()->GetName());
c->Message(0,"Usage: Target a client and use #resetaa to reset the AA data in their Profile."); //}
//else
// c->Message(0,"Usage: Target a client and use #resetaa to reset the AA data in their Profile.");
} }
void command_help(Client *c, const Seperator *sep) void command_help(Client *c, const Seperator *sep)