Merge git://github.com/EQEmu/Server into Development

This commit is contained in:
KayenEQ 2014-09-23 18:58:59 -04:00
commit a5e6fa3479
8 changed files with 68 additions and 25 deletions

View File

@ -50,6 +50,16 @@
#include "extprofile.h"
extern Client client;
#ifdef _WINDOWS
#if _MSC_VER > 1700 // greater than 2012 (2013+)
# define _ISNAN_(a) std::isnan(a)
#else
# include <float.h>
# define _ISNAN_(a) _isnan(a)
#endif
#else
# define _ISNAN_(a) std::isnan(a)
#endif
/*
Establish a connection to a mysql database with the supplied parameters
@ -1743,20 +1753,21 @@ bool Database::CheckDatabaseConversions() {
*/
/* Run AA Convert */
int first_entry = 0; rquery = "";
for (i = 1; i < MAX_PP_AA_ARRAY; i++){
for (i = 0; i < MAX_PP_AA_ARRAY; i++){
if (pp->aa_array[i].AA > 0 && pp->aa_array[i].value > 0){
if (first_entry != 1){
rquery = StringFormat("REPLACE INTO `character_alternate_abilities` (id, slot, aa_id, aa_value)"
" VALUES (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value);
first_entry = 1;
} else {
rquery = rquery + StringFormat(", (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value);
}
rquery = rquery + StringFormat(", (%u, %u, %u, %u)", character_id, i, pp->aa_array[i].AA, pp->aa_array[i].value);
}
}
if (rquery != ""){ results = QueryDatabase(rquery); ThrowDBError(results.ErrorMessage(), "AA Convert", rquery); }
/* Run Bind Home Convert */
if(pp->binds[4].zoneId < 999 && !std::isnan(pp->binds[4].x) && !std::isnan(pp->binds[4].y) && !std::isnan(pp->binds[4].z) && !std::isnan(pp->binds[4].heading)) {
if(pp->binds[4].zoneId < 999 && !_ISNAN_(pp->binds[4].x) && !_ISNAN_(pp->binds[4].y) && !_ISNAN_(pp->binds[4].z) && !_ISNAN_(pp->binds[4].heading)) {
rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, 1)",
character_id, pp->binds[4].zoneId, 0, pp->binds[4].x, pp->binds[4].y, pp->binds[4].z, pp->binds[4].heading);
@ -1764,7 +1775,7 @@ bool Database::CheckDatabaseConversions() {
}
/* Run Bind Convert */
if(pp->binds[0].zoneId < 999 && !std::isnan(pp->binds[0].x) && !std::isnan(pp->binds[0].y) && !std::isnan(pp->binds[0].z) && !std::isnan(pp->binds[0].heading)) {
if(pp->binds[0].zoneId < 999 && !_ISNAN_(pp->binds[0].x) && !_ISNAN_(pp->binds[0].y) && !_ISNAN_(pp->binds[0].z) && !_ISNAN_(pp->binds[0].heading)) {
rquery = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, 0)",
character_id, pp->binds[0].zoneId, 0, pp->binds[0].x, pp->binds[0].y, pp->binds[0].z, pp->binds[0].heading);

View File

@ -1081,7 +1081,7 @@ ENCODE(OP_PlayerProfile)
// zeroes for the rest of the spellbook slots
for(uint32 r = 0; r < structs::MAX_PP_SPELLBOOK - MAX_PP_SPELLBOOK; r++)
{
outapp->WriteUInt32(0);
outapp->WriteUInt32(0xFFFFFFFFU);
}
outapp->WriteUInt32(structs::MAX_PP_MEMSPELL); // Memorised spell slots
@ -1093,7 +1093,7 @@ ENCODE(OP_PlayerProfile)
// zeroes for the rest of the slots
for(uint32 r = 0; r < structs::MAX_PP_MEMSPELL - MAX_PP_MEMSPELL; r++)
{
outapp->WriteUInt32(0);
outapp->WriteUInt32(0xFFFFFFFFU);
}
outapp->WriteUInt32(13); // Unknown count

View File

@ -537,7 +537,8 @@ ENCODE(OP_PlayerProfile) {
OUT(WIS);
OUT(face);
// OUT(unknown02264[47]);
OUT_array(spell_book, structs::MAX_PP_SPELLBOOK);
memset(eq->spell_book, 0xFF, sizeof(uint32)* structs::MAX_PP_SPELLBOOK);
OUT_array(spell_book, 480U);
// OUT(unknown4184[128]);
OUT_array(mem_spells, structs::MAX_PP_MEMSPELL);
// OUT(unknown04396[32]);

View File

@ -2324,12 +2324,14 @@ bool Client::CheckIncreaseSkill(SkillUseTypes skillid, Mob *against_who, int cha
{
// the higher your current skill level, the harder it is
int16 Chance = 10 + chancemodi + ((252 - skillval) / 20);
if (Chance < 1)
Chance = 1; // Make it always possible
Chance = (Chance * RuleI(Character, SkillUpModifier) / 100);
Chance = mod_increase_skill_chance(Chance, against_who);
if(Chance < 1)
Chance = 1; // Make it always possible
if(MakeRandomFloat(0, 99) < Chance)
{
SetSkill(skillid, GetRawSkill(skillid) + 1);
@ -8021,7 +8023,7 @@ void Client::IncrementAA(int aa_id) {
SetAA(aa_id, GetAA(aa_id) + 1);
Save();
SaveAA();
SendAA(aa_id);
SendAATable();

View File

@ -720,7 +720,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) {
for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]);
m_pp.aa_array[i].AA = atoi(row[1]);
m_pp.aa_array[i].value = atoi(row[1]);
m_pp.aa_array[i].value = atoi(row[2]);
aa[i]->AA = atoi(row[1]);
aa[i]->value = atoi(row[2]);
}

View File

@ -7681,7 +7681,7 @@ void Client::Undye() {
SendWearChange(cur_slot);
}
Save(0);
database.DeleteCharacterDye(this->CharacterID());
}
void command_undye(Client *c, const Seperator *sep)

View File

@ -958,7 +958,12 @@ bool ZoneDatabase::LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_
"FROM "
"`character_memmed_spells` "
"WHERE `id` = %u ORDER BY `slot_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0;
auto results = database.QueryDatabase(query);
int i = 0;
/* Initialize Spells */
for (i = 0; i < MAX_PP_MEMSPELL; i++){
pp->mem_spells[i] = 0xFFFFFFFF;
}
for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]);
if (i < MAX_PP_MEMSPELL){
@ -976,14 +981,15 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str
"FROM "
"`character_spells` "
"WHERE `id` = %u ORDER BY `slot_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0;
auto results = database.QueryDatabase(query);
int i = 0;
/* Initialize Spells */
for (i = 0; i < MAX_PP_SPELLBOOK; i++){
pp->spell_book[i] = 0;
pp->spell_book[i] = 0xFFFFFFFF;
}
for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]);
if (i < MAX_PP_SPELLBOOK){
i = atoi(row[0]);
if (i < MAX_PP_SPELLBOOK){
pp->spell_book[i] = atoi(row[1]);
}
}
@ -1632,35 +1638,57 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur
}
bool ZoneDatabase::SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); QueryDatabase(query); return true;
std::string query = StringFormat("REPLACE INTO `character_memmed_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id); QueryDatabase(query); return true;
std::string query = StringFormat("REPLACE INTO `character_spells` (id, slot_id, spell_id) VALUES (%u, %u, %u)", character_id, slot_id, spell_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterDisc(uint32 character_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_disciplines` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterBandolier(uint32 character_id, uint32 band_id){
std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_bandolier` WHERE `bandolier_id` = %u AND `id` = %u", band_id, character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterLeadershipAAs(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_leadership_abilities` WHERE `id` = %u", character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterAAs(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_alternate_abilities` WHERE `id` = %u", character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterDye(uint32 character_id){
std::string query = StringFormat("DELETE FROM `character_material` WHERE `id` = %u", character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id); QueryDatabase(query); return true;
std::string query = StringFormat("DELETE FROM `character_memmed_spells` WHERE `slot_id` = %u AND `id` = %u", slot_id, character_id);
QueryDatabase(query);
return true;
}
bool ZoneDatabase::NoRentExpired(const char* name){

View File

@ -288,6 +288,7 @@ public:
bool DeleteCharacterBandolier(uint32 character_id, uint32 band_id);
bool DeleteCharacterLeadershipAAs(uint32 character_id);
bool DeleteCharacterAAs(uint32 character_id);
bool DeleteCharacterDye(uint32 character_id);
/* Character Inventory */
bool NoRentExpired(const char* name);