State of Commit: Testable if you ask me (Akkadius) what you need to do

- Need to convert a list of functions and columns and should be ready to start intensive testing phase
 - All preliminary tests show things working great

- All of player profile is saved and loaded from the database
- DBAsync has been completely removed from all code
	- Removed zone/dbasync.cpp/.h
	- Removed common/dbasync.cpp/.h
	- Removed dbasync from cmake commmon and zone
- Cleaned up a ton of functions
- Added several tables to world CheckDatabaseConversions script:
	- `character_skills`
	- `character_languages`
	- `character_bind`
	- `character_alternate_abilities`
	- `character_currency`
	- `character_data`
	- `character_spells`
	- `character_memmed_spells`
	- `character_disciplines`
	- `character_material`
	- `character_tribute`
	- `character_bandolier`
	- `character_potionbelt`
- Character select now loads from `character_data`
- Character creation now creates to `character_data`
- Updated function Database::UpdateName to use `character_data`
- Updated function Database::CheckUsedName to use `character_data`
- Updated function Database::MoveCharacterToZone to use `character_data`
- Updated function Database::SetLoginFlags to use `character_data`
- Updated function Database::SetFirstLogon to use `character_data`
- Updated function Database::SetLFG to use `character_data`
- Removed CopyCharacter functions and commands, to be recreated later since it never worked to begin with
- Removed SharedDatabase::SetPlayerProfile
- Trimmed down redundant case switch statements for World sendpackets to QueryServ
- Added Character Methods to Database class:
	Loads:
		bool	LoadCharacterBandolier(uint32 character_id, PlayerProfile_Struct* pp);
		bool	LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
		bool	LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp);
	Saves:
		bool	SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home);
		bool	SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
		bool	SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
		bool	SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level);
		bool	SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot);
		bool	SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
		bool	SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
		bool	SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color);
		bool	SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value);
		bool	SaveCharacterLanguage(uint32 character_id, uint32 lang_id, uint32 value);
		bool	SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id);
		bool	SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
		bool	SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name);
		bool	SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon);
	Deletes:
		bool	DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
		bool	DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
		bool	DeleteCharacterDisc(uint32 character_id, uint32 slot_id);
		bool	DeleteCharacterBandolier(uint32 character_id, uint32 band_id);
This commit is contained in:
Akkadius
2014-09-04 07:24:17 -05:00
parent 0a9222e1ee
commit 4432c07081
37 changed files with 1235 additions and 2370 deletions
-2
View File
@@ -119,7 +119,6 @@ SET(zone_sources
zone_logsys.cpp
zone_config.cpp
zonedb.cpp
zonedbasync.cpp
zoning.cpp
)
@@ -207,7 +206,6 @@ SET(zone_headers
zone.h
zone_config.h
zonedb.h
zonedbasync.h
zonedump.h
)
+29 -61
View File
@@ -73,8 +73,6 @@ extern uint32 numclients;
extern PetitionList petition_list;
bool commandlogged;
char entirecommand[255];
extern DBAsyncFinishedQueue MTdbafq;
extern DBAsync *dbasync;
Client::Client(EQStreamInterface* ieqs)
: Mob("No name", // name
@@ -544,8 +542,9 @@ bool Client::Save(uint8 iCommitNow) {
/* Save Character Currency */
database.SaveCharacterCurrency(this->CharacterID(), &m_pp);
/* Save Character AA */
// SaveAA();
/* Save Current Bind Points : Sets Instance to 0 because it is currently not implemented */
database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, 0, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0, 0); /* Regular bind */
database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[4].zoneId, 0, m_pp.binds[4].x, m_pp.binds[4].y, m_pp.binds[4].z, 0, 1); /* Home Bind */
/* Save Character Buffs */
database.SaveBuffs(this);
@@ -557,15 +556,11 @@ bool Client::Save(uint8 iCommitNow) {
/* Save Mercs */
if (GetMercInfo().MercTimerRemaining > RuleI(Mercs, UpkeepIntervalMS)){ GetMercInfo().MercTimerRemaining = RuleI(Mercs, UpkeepIntervalMS); }
if(GetMercTimer()->Enabled()) { GetMercInfo().MercTimerRemaining = GetMercTimer()->GetRemainingTime(); }
if (GetMercTimer()->Enabled()) { GetMercInfo().MercTimerRemaining = GetMercTimer()->GetRemainingTime(); }
if (GetMerc() && !dead) { }
else { memset(&m_mercinfo, 0, sizeof(struct MercInfo)); }
m_pp.lastlogin = time(nullptr);
if (pQueuedSaveWorkID) {
dbasync->CancelWork(pQueuedSaveWorkID);
pQueuedSaveWorkID = 0;
}
if (GetPet() && !GetPet()->IsFamiliar() && GetPet()->CastToNPC()->GetPetSpellID() && !dead) {
NPC *pet = GetPet()->CastToNPC();
@@ -585,34 +580,10 @@ bool Client::Save(uint8 iCommitNow) {
p_timers.Store(&database);
/* Save Character Task */
SaveTaskState();
database.SaveCharacterTribute(this->CharacterID(), &m_pp);
// if (iCommitNow <= 1) {
// // char* query = 0;
// // uint32_breakdown workpt;
// // workpt.b4() = DBA_b4_Entity;
// // workpt.w2_3() = GetID();
// // workpt.b1() = DBA_b1_Entity_Client_Save;
// // DBAsyncWork* dbaw = new DBAsyncWork(&database, &MTdbafq, workpt, DBAsync::Write, 0xFFFFFFFF);
// // dbaw->AddQuery(iCommitNow == 0 ? true : false, &query, database.SetPlayerProfile_MQ(&query, account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets), false);
// // if (iCommitNow == 0){
// // pQueuedSaveWorkID = dbasync->AddWork(&dbaw, 2500);
// // }
// // else {
// // dbasync->AddWork(&dbaw, 0);
// // SaveBackup();
// // }
// // safe_delete_array(query);
// // return true;
// }
// else if (database.SetPlayerProfile(account_id, character_id, &m_pp, &m_inv, &m_epp, 0, 0, MaxXTargets)) {
// SaveBackup();
// }
// else {
// std::cerr << "Failed to update player profile" << std::endl;
// return false;
// }
/* Save Character Task */
SaveTaskState();
/* Save Character Data */
database.SaveCharacterData(this->CharacterID(), this->AccountID(), &m_pp);
@@ -624,12 +595,6 @@ bool Client::Save(uint8 iCommitNow) {
}
void Client::SaveBackup() {
if (!RunLoops)
return;
char* query = 0;
DBAsyncWork* dbaw = new DBAsyncWork(&database, &DBAsyncCB_CharacterBackup, this->CharacterID(), DBAsync::Read);
dbaw->AddQuery(0, &query, MakeAnyLenString(&query, "Select id, UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ts) as age from character_backup where charid=%u and backupreason=0 order by ts asc", this->CharacterID()), true);
dbasync->AddWork(&dbaw, 0);
}
CLIENTPACKET::CLIENTPACKET()
@@ -1393,12 +1358,14 @@ bool Client::UpdateLDoNPoints(int32 points, uint32 theme)
void Client::SetSkill(SkillUseTypes skillid, uint16 value) {
if (skillid > HIGHEST_SKILL)
return;
m_pp.skills[skillid] = value; // We need to be able to #setskill 254 and 255 to reset skills
return;
m_pp.skills[skillid] = value; // We need to be able to #setskill 254 and 255 to reset skills
database.SaveCharacterSkill(this->CharacterID(), skillid, value);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SkillUpdate, sizeof(SkillUpdate_Struct));
SkillUpdate_Struct* skill = (SkillUpdate_Struct*)outapp->pBuffer;
skill->skillId=skillid;
skill->skillId=skillid;
skill->value=value;
QueuePacket(outapp);
safe_delete(outapp);
@@ -1414,10 +1381,12 @@ void Client::IncreaseLanguageSkill(int skill_id, int value) {
if (m_pp.languages[skill_id] > 100) //Lang skill above max
m_pp.languages[skill_id] = 100;
database.SaveCharacterLanguage(this->CharacterID(), skill_id, m_pp.languages[skill_id]);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SkillUpdate, sizeof(SkillUpdate_Struct));
SkillUpdate_Struct* skill = (SkillUpdate_Struct*)outapp->pBuffer;
skill->skillId = 100 + skill_id;
skill->value = m_pp.languages[skill_id];
skill->value = m_pp.languages[skill_id];
QueuePacket(outapp);
safe_delete(outapp);
@@ -2165,32 +2134,27 @@ void Client::AddMoneyToPP(uint64 copper, bool updateclient){
uint64 tmp2;
tmp = copper;
// Add Amount of Platinum
/* Add Amount of Platinum */
tmp2 = tmp/1000;
int32 new_val = m_pp.platinum + tmp2;
if(new_val < 0) {
m_pp.platinum = 0;
} else {
m_pp.platinum = m_pp.platinum + tmp2;
}
if(new_val < 0) { m_pp.platinum = 0; }
else { m_pp.platinum = m_pp.platinum + tmp2; }
tmp-=tmp2*1000;
//if (updateclient)
// SendClientMoneyUpdate(3,tmp2);
// Add Amount of Gold
/* Add Amount of Gold */
tmp2 = tmp/100;
new_val = m_pp.gold + tmp2;
if(new_val < 0) {
m_pp.gold = 0;
} else {
m_pp.gold = m_pp.gold + tmp2;
}
if(new_val < 0) { m_pp.gold = 0; }
else { m_pp.gold = m_pp.gold + tmp2; }
tmp-=tmp2*100;
//if (updateclient)
// SendClientMoneyUpdate(2,tmp2);
// Add Amount of Silver
/* Add Amount of Silver */
tmp2 = tmp/10;
new_val = m_pp.silver + tmp2;
if(new_val < 0) {
@@ -2226,8 +2190,7 @@ void Client::AddMoneyToPP(uint64 copper, bool updateclient){
LogFile->write(EQEMuLog::Debug, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
}
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient){
void Client::EVENT_ITEM_ScriptStopReturn(){
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
*/
@@ -2236,6 +2199,10 @@ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 plat
gettimeofday(&read_time, 0);
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
this->SetEntityVariable("Stop_Return", buffer);
}
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient){
this->EVENT_ITEM_ScriptStopReturn();
int32 new_value = m_pp.platinum + platinum;
if(new_value >= 0 && new_value > m_pp.platinum)
@@ -3184,6 +3151,7 @@ void Client::SetLanguageSkill(int langid, int value)
value = 100; //Max lang value
m_pp.languages[langid] = value;
database.SaveCharacterLanguage(this->CharacterID(), langid, value);
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SkillUpdate, sizeof(SkillUpdate_Struct));
SkillUpdate_Struct* skill = (SkillUpdate_Struct*)outapp->pBuffer;
+5 -5
View File
@@ -234,7 +234,6 @@ public:
bool KeyRingCheck(uint32 item_id);
void KeyRingList();
virtual bool IsClient() const { return true; }
virtual void DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw);
void CompleteConnect();
bool TryStacking(ItemInst* item, uint8 type = ItemPacketTrade, bool try_worn = true, bool try_cursor = true);
void SendTraderPacket(Client* trader, uint32 Unknown72 = 51);
@@ -654,14 +653,14 @@ public:
void OnDisconnect(bool hard_disconnect);
uint16 GetSkillPoints() {return m_pp.points;}
void SetSkillPoints(int inp) {m_pp.points = inp;}
uint16 GetSkillPoints() { return m_pp.points;}
void SetSkillPoints(int inp) { m_pp.points = inp;}
void IncreaseSkill(int skill_id, int value = 1) { if (skill_id <= HIGHEST_SKILL) { m_pp.skills[skill_id] += value; } }
void IncreaseLanguageSkill(int skill_id, int value = 1);
virtual uint16 GetSkill(SkillUseTypes skill_id) const { if (skill_id <= HIGHEST_SKILL) { return((itembonuses.skillmod[skill_id] > 0)? m_pp.skills[skill_id]*(100 + itembonuses.skillmod[skill_id])/100 : m_pp.skills[skill_id]); } return 0; }
virtual uint16 GetSkill(SkillUseTypes skill_id) const { if (skill_id <= HIGHEST_SKILL) { return((itembonuses.skillmod[skill_id] > 0) ? m_pp.skills[skill_id] * (100 + itembonuses.skillmod[skill_id]) / 100 : m_pp.skills[skill_id]); } return 0; }
uint32 GetRawSkill(SkillUseTypes skill_id) const { if (skill_id <= HIGHEST_SKILL) { return(m_pp.skills[skill_id]); } return 0; }
bool HasSkill(SkillUseTypes skill_id) const;
bool HasSkill(SkillUseTypes skill_id) const;
bool CanHaveSkill(SkillUseTypes skill_id) const;
void SetSkill(SkillUseTypes skill_num, uint16 value);
void AddSkill(SkillUseTypes skillid, uint16 value);
@@ -782,6 +781,7 @@ public:
int16 acmod();
// Item methods
void EVENT_ITEM_ScriptStopReturn();
uint32 NukeItem(uint32 itemnum, uint8 where_to_check =
(invWhereWorn | invWherePersonal | invWhereBank | invWhereSharedBank | invWhereTrading | invWhereCursor));
void SetTint(int16 slot_id, uint32 color);
+11 -50
View File
@@ -77,9 +77,6 @@ extern volatile bool ZoneLoaded;
extern WorldServer worldserver;
extern PetitionList petition_list;
extern EntityList entity_list;
extern DBAsyncFinishedQueue MTdbafq;
extern DBAsync *dbasync;
typedef void (Client::*ClientPacketProc)(const EQApplicationPacket *app);
//Use a map for connecting opcodes since it dosent get used a lot and is sparse
@@ -525,7 +522,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
client_state = CLIENT_KICKED;
return;
}
strcpy(name, cze->char_name);
/* Check for Client Spoofing */
@@ -592,19 +588,20 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
if (LFG){ LFG = atoi(row[12]); }
if (firstlogon){ firstlogon = atoi(row[15]); }
}
loaditems = database.GetInventory(cid, &m_inv); /* Load Character Inventory */
database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */
database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */
database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */
database.LoadCharacterPotions(cid, &m_pp); /* Load Character Potion Belt */
database.LoadCharacterCurrency(cid, &m_pp); /* Load Character Currency into PP */
database.LoadCharacterData(cid, &m_pp); /* Load Character Data from DB into PP */
database.GetPlayerInspectMessage(m_pp.name, &m_inspect_message); /* Move to another method when can, this is pointless... */
database.LoadCharacterCurrency(cid, &m_pp); /* Load Character Currency */
database.LoadCharacterSkills(cid, &m_pp); /* Load Character Skills */
database.LoadCharacterLanguages(cid, &m_pp); /* Load Character Languages */
database.GetPlayerInspectMessage(m_pp.name, &m_inspect_message); /* Move to another method when can, this is pointless... */
database.LoadCharacterSpellBook(cid, &m_pp); /* Load Character Spell Book */
database.LoadCharacterMemmedSpells(cid, &m_pp); /* Load Character Memorized Spells */
database.LoadCharacterDisciplines(cid, &m_pp); /* Load Character Disciplines */
database.LoadCharacterLanguages(cid, &m_pp); /* Load Character Languages */
if (level){ level = m_pp.level; }
@@ -612,9 +609,6 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
if (gmhideme) { trackable = false; }
/* Set Con State for Reporting */
conn_state = PlayerProfileLoaded;
// m_pp.zone_id = zone->GetZoneID();
// m_pp.zoneInstance = zone->GetInstanceID();
/* Set Total Seconds Played */
TotalSecondsPlayed = m_pp.timePlayedMin * 60;
@@ -9168,38 +9162,6 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
return;
}
void Client::DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) {
Entity::DBAWComplete(workpt_b1, dbaw);
switch (workpt_b1) {
case DBA_b1_Entity_Client_Save: {
clock_t t = std::clock(); /* Function timer start */
char errbuf[MYSQL_ERRMSG_SIZE];
uint32 affected_rows = 0;
DBAsyncQuery* dbaq = dbaw->PopAnswer();
if (dbaq->GetAnswer(errbuf, 0, &affected_rows) && affected_rows == 1) {
if (dbaq->QPT()) {
SaveBackup();
}
}
else {
std::cout << "Async client save failed. '" << errbuf << "'" << std::endl;
Message(13, "Error: Asyncronous save of your character failed.");
if (Admin() >= 200)
Message(13, "errbuf: %s", errbuf);
}
pQueuedSaveWorkID = 0;
LogFile->write(EQEMuLog::Status, "Client::DBAWComplete Save Character Async done... Took %f seconds", ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
break;
}
default: {
std::cout << "Error: Client::DBAWComplete(): Unknown workpt_b1" << std::endl;
break;
}
}
}
/* Finish client connecting state */
void Client::CompleteConnect() {
UpdateWho();
@@ -9221,7 +9183,7 @@ void Client::CompleteConnect() {
SendAppearancePacket(AT_GuildID, GuildID(), false);
SendAppearancePacket(AT_GuildRank, GuildRank(), false);
}
for (uint32 spellInt = 0; spellInt < MAX_PP_SPELLBOOK; spellInt++) {
for (uint32 spellInt = 0; spellInt < MAX_PP_REF_SPELLBOOK; spellInt++) {
if (m_pp.spell_book[spellInt] < 3 || m_pp.spell_book[spellInt] > 50000)
m_pp.spell_book[spellInt] = 0xFFFFFFFF;
}
@@ -9417,7 +9379,7 @@ void Client::CompleteConnect() {
SendWearChange(x);
Mob *pet = GetPet();
if (pet != nullptr) {
for (x = 0; x < 8; x++)
for (x = 0; x < 8; x++)
pet->SendWearChange(x);
}
@@ -9497,6 +9459,8 @@ void Client::CompleteConnect() {
alternate_currency_loaded = true;
ProcessAlternateCurrencyQueue();
CalcItemScale();
DoItemEnterZone();
@@ -10504,8 +10468,7 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) {
}
}
void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) {
void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) {
if(app->size != sizeof(MovePotionToBelt_Struct)) {
LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_PotionBelt expected %i got %i",
sizeof(MovePotionToBelt_Struct), app->size);
@@ -10519,6 +10482,7 @@ void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) {
m_pp.potionbelt.items[mptbs->SlotNumber].item_id = BaseItem->ID;
m_pp.potionbelt.items[mptbs->SlotNumber].icon = BaseItem->Icon;
strn0cpy(m_pp.potionbelt.items[mptbs->SlotNumber].item_name, BaseItem->Name, sizeof(BaseItem->Name));
database.SaveCharacterPotionBelt(this->CharacterID(), mptbs->SlotNumber, m_pp.potionbelt.items[mptbs->SlotNumber].item_id, m_pp.potionbelt.items[mptbs->SlotNumber].icon);
}
}
else {
@@ -10526,9 +10490,6 @@ void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) {
m_pp.potionbelt.items[mptbs->SlotNumber].icon = 0;
strncpy(m_pp.potionbelt.items[mptbs->SlotNumber].item_name, "\0", 1);
}
Save();
}
void Client::Handle_OP_LFGGetMatchesRequest(const EQApplicationPacket *app) {
+2 -1
View File
@@ -1717,6 +1717,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app)
}
uint16 skilllevel = GetRawSkill(skill);
if(skilllevel == 0) {
//this is a new skill..
uint16 t_level = SkillTrainLevel(skill, GetClass());
@@ -1726,7 +1727,7 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app)
}
SetSkill(skill, t_level);
} else {
} else {
switch(skill) {
case SkillBrewing:
case SkillMakePoison:
+5 -27
View File
@@ -225,7 +225,6 @@ int command_init(void) {
command_add("worldshutdown","- Shut down world and all zones",200,command_worldshutdown) ||
command_add("sendzonespawns","- Refresh spawn list for all clients in zone",150,command_sendzonespawns) ||
command_add("dbspawn2","[spawngroup] [respawn] [variance] - Spawn an NPC from a predefined row in the spawn2 table",100,command_dbspawn2) ||
command_add("copychar","[character name] [new character] [new account id] - Create a copy of a character",100,command_copychar) ||
command_add("shutdown","- Shut this zone process down",150,command_shutdown) ||
command_add("delacct","[accountname] - Delete an account",150,command_delacct) ||
command_add("setpass","[accountname] [password] - Set local password for accountname",150,command_setpass) ||
@@ -2227,28 +2226,6 @@ void command_dbspawn2(Client *c, const Seperator *sep)
}
}
void command_copychar(Client *c, const Seperator *sep)
{
if(sep->arg[1][0]==0 || sep->arg[2][0] == 0 || sep->arg[3][0] == 0)
c->Message(0, "Usage: #copychar [character name] [new character] [new account id]");
//CheckUsedName.... TRUE=No Char, FALSE=Char/Error
//If there is no source...
else if (database.CheckUsedName((char*)sep->arg[1])) {
c->Message(0, "Source character not found!");
}
else {
//If there is a name is not used....
if (database.CheckUsedName((char*) sep->arg[2])) {
if (!database.CopyCharacter((char*) sep->arg[1], (char*) sep->arg[2], atoi(sep->arg[3])))
c->Message(0, "Character copy operation failed!");
else
c->Message(0, "Character copy complete.");
}
else
c->Message(0, "Target character already exists!");
}
}
void command_shutdown(Client *c, const Seperator *sep)
{
CatchSignal(2);
@@ -2423,8 +2400,8 @@ void command_showskills(Client *c, const Seperator *sep)
c->Message(0, "Skills for %s", t->GetName());
for (SkillUseTypes i=Skill1HBlunt; i <= HIGHEST_SKILL; i=(SkillUseTypes)(i+1))
c->Message(0, "Skill [%d] is at [%d]", i, t->GetSkill(i));
}
c->Message(0, "Skill [%d] is at [%d] - %u", i, t->GetSkill(i), t->GetRawSkill(i));
}
void command_findspell(Client *c, const Seperator *sep)
{
@@ -2801,7 +2778,7 @@ void command_charbackup(Client *c, const Seperator *sep)
if (sep->IsNumber(2))
charid = atoi(sep->arg[2]);
else
database.GetAccountIDByChar(sep->arg[2], &charid);
database.GetAccountIDByChar(sep->arg[2]);
if (charid) {
if (database.RunQuery(query, MakeAnyLenString(&query,
"Select id, backupreason, charid, account_id, zoneid, DATE_FORMAT(ts, '%%m/%%d/%%Y %%H:%%i:%%s') "
@@ -2828,7 +2805,7 @@ void command_charbackup(Client *c, const Seperator *sep)
if (sep->IsNumber(2))
charid = atoi(sep->arg[2]);
else
database.GetAccountIDByChar(sep->arg[2], &charid);
database.GetAccountIDByChar(sep->arg[2]);
if (charid && sep->IsNumber(3)) {
uint32 cbid = atoi(sep->arg[3]);
@@ -8725,6 +8702,7 @@ void command_traindisc(Client *c, const Seperator *sep)
break; //continue the 1st loop
} else if(t->GetPP().disciplines.values[r] == 0) {
t->GetPP().disciplines.values[r] = curspell;
database.SaveCharacterDisc(c->CharacterID(), r, curspell);
t->SendDisciplineUpdate();
t->Message(0, "You have learned a new discipline!");
count++; //success counter
-1
View File
@@ -125,7 +125,6 @@ void command_worldshutdown(Client *c, const Seperator *sep);
void command_sendzonespawns(Client *c, const Seperator *sep);
void command_zsave(Client *c, const Seperator *sep);
void command_dbspawn2(Client *c, const Seperator *sep);
void command_copychar(Client *c, const Seperator *sep);
void command_shutdown(Client *c, const Seperator *sep);
void command_delacct(Client *c, const Seperator *sep);
void command_setpass(Client *c, const Seperator *sep);
+1
View File
@@ -606,6 +606,7 @@ bool Client::TrainDiscipline(uint32 itemid) {
return(false);
} else if(m_pp.disciplines.values[r] == 0) {
m_pp.disciplines.values[r] = spell_id;
database.SaveCharacterDisc(this->CharacterID(), r, spell_id);
SendDisciplineUpdate();
Message(0, "You have learned a new discipline!");
return(true);
+1 -4
View File
@@ -40,7 +40,6 @@
#include "../common/spdat.h"
#include "../common/features.h"
#include "string_ids.h"
#include "../common/dbasync.h"
#include "guild_mgr.h"
#include "raids.h"
#include "quest_parser_collection.h"
@@ -57,7 +56,6 @@ extern WorldServer worldserver;
extern NetConnection net;
extern uint32 numclients;
extern PetitionList petition_list;
extern DBAsync *dbasync;
extern char errorname[32];
extern uint16 adverrornum;
@@ -65,12 +63,11 @@ extern uint16 adverrornum;
Entity::Entity()
{
id = 0;
pDBAsyncWorkID = 0;
}
Entity::~Entity()
{
dbasync->CancelWork(pDBAsyncWorkID);
}
Client *Entity::CastToClient()
+1 -3
View File
@@ -28,7 +28,6 @@
#include "zonedb.h"
#include "zonedump.h"
#include "zonedbasync.h"
#include "qglobals.h"
class EQApplicationPacket;
@@ -53,7 +52,7 @@ class Bot;
class BotRaids;
#endif
extern EntityList entity_list;
extern EntityList entity_list;
class Entity
{
@@ -100,7 +99,6 @@ public:
inline const uint16& GetID() const { return id; }
virtual const char* GetName() { return ""; }
virtual void DBAWComplete(uint8 workpt_b1, DBAsyncWork* dbaw) { pDBAsyncWorkID = 0; }
bool CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z, float trg_x, float trg_y, float trg_z, float perwalk=1);
#ifdef BOTS
+1 -8
View File
@@ -51,14 +51,7 @@ static uint32 MaxBankedRaidLeadershipPoints(int Level)
void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) {
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
*/
struct timeval read_time;
char buffer[50];
gettimeofday(&read_time, 0);
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
this->SetEntityVariable("Stop_Return", buffer);
this->EVENT_ITEM_ScriptStopReturn();
uint32 add_exp = in_add_exp;
+6 -18
View File
@@ -200,14 +200,7 @@ bool Client::CheckLoreConflict(const Item_Struct* item) {
}
bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, uint32 aug3, uint32 aug4, uint32 aug5, bool attuned, uint16 to_slot) {
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
*/
struct timeval read_time;
char buffer[50];
gettimeofday(&read_time, 0);
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
this->SetEntityVariable("Recieved_Item", buffer);
this->EVENT_ITEM_ScriptStopReturn();
// TODO: update calling methods and script apis to handle a failure return
@@ -2320,10 +2313,8 @@ void Client::CreateBandolier(const EQApplicationPacket *app) {
_log(INVENTORY__BANDOLIER, "Char: %s Creating Bandolier Set %i, Set Name: %s", GetName(), bs->number, bs->name);
strcpy(m_pp.bandoliers[bs->number].name, bs->name);
const ItemInst* InvItem;
const Item_Struct *BaseItem;
const ItemInst* InvItem;
const Item_Struct *BaseItem;
int16 WeaponSlot;
for(int BandolierSlot = bandolierMainHand; BandolierSlot <= bandolierAmmo; BandolierSlot++) {
@@ -2334,6 +2325,7 @@ void Client::CreateBandolier(const EQApplicationPacket *app) {
_log(INVENTORY__BANDOLIER, "Char: %s adding item %s to slot %i", GetName(),BaseItem->Name, WeaponSlot);
m_pp.bandoliers[bs->number].items[BandolierSlot].item_id = BaseItem->ID;
m_pp.bandoliers[bs->number].items[BandolierSlot].icon = BaseItem->Icon;
database.SaveCharacterBandolier(this->CharacterID(), bs->number, BandolierSlot, m_pp.bandoliers[bs->number].items[BandolierSlot].item_id, m_pp.bandoliers[bs->number].items[BandolierSlot].icon, bs->name);
}
else {
_log(INVENTORY__BANDOLIER, "Char: %s no item in slot %i", GetName(), WeaponSlot);
@@ -2341,21 +2333,17 @@ void Client::CreateBandolier(const EQApplicationPacket *app) {
m_pp.bandoliers[bs->number].items[BandolierSlot].icon = 0;
}
}
Save();
}
void Client::RemoveBandolier(const EQApplicationPacket *app) {
// Delete bandolier with the specified number
BandolierDelete_Struct *bds = (BandolierDelete_Struct*)app->pBuffer;
_log(INVENTORY__BANDOLIER, "Char: %s removing set", GetName(), bds->number);
memset(m_pp.bandoliers[bds->number].name, 0, 32);
for(int i = bandolierMainHand; i <= bandolierAmmo; i++) {
m_pp.bandoliers[bds->number].items[i].item_id = 0;
m_pp.bandoliers[bds->number].items[i].icon = 0;
m_pp.bandoliers[bds->number].items[i].icon = 0;
}
Save();
database.DeleteCharacterBandolier(this->CharacterID(), bds->number);
}
void Client::SetBandolier(const EQApplicationPacket *app) {
-10
View File
@@ -97,8 +97,6 @@ extern Zone* zone;
EQStreamFactory eqsf(ZoneStream);
npcDecayTimes_Struct npcCorpseDecayTimes[100];
TitleManager title_manager;
DBAsyncFinishedQueue MTdbafq;
DBAsync *dbasync = nullptr;
QueryServ *QServ = 0;
TaskManager *taskmanager = 0;
QuestParserCollection *parse = 0;
@@ -168,8 +166,6 @@ int main(int argc, char** argv) {
_log(ZONE__INIT_ERR, "Cannot continue without a database connection.");
return 1;
}
dbasync = new DBAsync(&database);
dbasync->AddFQ(&MTdbafq);
guild_mgr.SetDatabase(&database);
GuildBanks = nullptr;
@@ -444,10 +440,6 @@ int main(int argc, char** argv) {
}
}
DBAsyncWork* dbaw = 0;
while ((dbaw = MTdbafq.Pop())) {
DispatchFinishedDBAsync(dbaw);
}
if (InterserverTimer.Check()) {
InterserverTimer.Start();
database.ping();
@@ -507,8 +499,6 @@ int main(int argc, char** argv) {
//Fix for Linux world server problem.
eqsf.Close();
worldserver.Disconnect();
dbasync->CommitWrites();
dbasync->StopThread();
safe_delete(taskmanager);
command_deinit();
safe_delete(parse);
+7 -5
View File
@@ -974,6 +974,7 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
SpellGlobalCheckResult = initiator->SpellGlobalCheck(curspell, Char_ID);
if (SpellGlobalCheckResult) {
initiator->GetPP().disciplines.values[r] = curspell;
database.SaveCharacterDisc(Char_ID, r, curspell);
initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!");
count++; //success counter
@@ -981,11 +982,12 @@ uint16 QuestManager::traindiscs(uint8 max_level, uint8 min_level) {
break; //continue the 1st loop
}
else {
initiator->GetPP().disciplines.values[r] = curspell;
initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!");
count++; //success counter
break; //continue the 1st loop
initiator->GetPP().disciplines.values[r] = curspell;
database.SaveCharacterDisc(Char_ID, r, curspell);
initiator->SendDisciplineUpdate();
initiator->Message(0, "You have learned a new discipline!");
count++; //success counter
break; //continue the 1st loop
}
} //if we get to this point, there's already a discipline in this slot, so we skip it
}
+2 -1
View File
@@ -4933,8 +4933,9 @@ void Client::UntrainDisc(int slot, bool update_client)
if(slot >= MAX_PP_DISCIPLINES || slot < 0)
return;
mlog(CLIENT__SPELLS, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot);
mlog(CLIENT__SPELLS, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot);
m_pp.disciplines.values[slot] = 0;
database.DeleteCharacterDisc(this->CharacterID(), slot);
if(update_client)
{
+2 -9
View File
@@ -913,14 +913,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
if(!tradingWith->IsMoving())
tradingWith->FaceTarget(this);
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
*/
struct timeval read_time;
char buffer[50];
gettimeofday(&read_time, 0);
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
this->SetEntityVariable("Stop_Return", buffer);
this->EVENT_ITEM_ScriptStopReturn();
}
}
@@ -938,7 +931,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
parse->AddVar(temp1, temp2);
snprintf(temp1, 100, "platinum.%d", tradingWith->GetNPCTypeID());
snprintf(temp2, 100, "%u", trade->pp);
parse->AddVar(temp1, temp2);
parse->AddVar(temp1, temp2);
if(tradingWith->GetAppearance() != eaDead) {
tradingWith->FaceTarget(this);
+6 -4
View File
@@ -254,8 +254,10 @@ int32 Client::TributeItem(uint32 slot, uint32 quantity) {
return(0);
}
//make sure they have enough of them
//and remove it from inventory
/*
Make sure they have enough of them
and remove it from inventory
*/
if(inst->IsStackable()) {
if(inst->GetCharges() < (int32)quantity) //dont have enough....
return(0);
@@ -267,7 +269,7 @@ int32 Client::TributeItem(uint32 slot, uint32 quantity) {
pts *= quantity;
//add the tribute value in points
/* Add the tribute value in points */
AddTributePoints(pts);
return(pts);
}
@@ -279,7 +281,7 @@ int32 Client::TributeMoney(uint32 platinum) {
return(0);
}
//add the tribute value in points
/* Add the tribute value in points */
AddTributePoints(platinum);
return(platinum);
}
-5
View File
@@ -77,8 +77,6 @@ extern bool staticzone;
Zone* zone = 0;
volatile bool ZoneLoaded = false;
extern QuestParserCollection* parse;
extern DBAsyncFinishedQueue MTdbafq;
extern DBAsync *dbasync;
bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
const char* zonename = database.GetZoneName(iZoneID);
@@ -705,7 +703,6 @@ void Zone::Shutdown(bool quite)
zone->ResetAuth();
safe_delete(zone);
dbasync->CommitWrites();
entity_list.ClearAreas();
parse->ReloadQuests(true);
UpdateWindowTitle();
@@ -844,8 +841,6 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
}
Zone::~Zone() {
if(pQueuedMerchantsWorkID != 0)
dbasync->CancelWork(pQueuedMerchantsWorkID);
spawn2_list.Clear();
safe_delete(zonemap);
safe_delete(watermap);
+265 -130
View File
@@ -626,8 +626,7 @@ TraderCharges_Struct* ZoneDatabase::LoadTraderItemWithCharges(uint32 char_id){
return loadti;
}
ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) {
ItemInst* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNumber) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
@@ -687,8 +686,7 @@ void ZoneDatabase::SaveTraderItem(uint32 CharID, uint32 ItemID, uint32 SerialNum
safe_delete_array(query);
}
void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) {
void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) {
_log(TRADING__CLIENT, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges);
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
@@ -784,8 +782,7 @@ void ZoneDatabase::DeleteBuyLines(uint32 CharID){
safe_delete_array(query);
}
void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) {
void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char* ItemName, uint32 Quantity, uint32 Price) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
if (!(RunQuery(query,MakeAnyLenString(&query, "replace INTO buyer VALUES(%i,%i, %i,\"%s\",%i,%i)",
@@ -795,8 +792,7 @@ void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, cons
safe_delete_array(query);
}
void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) {
void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) {
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
@@ -806,8 +802,7 @@ void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) {
safe_delete_array(query);
}
void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) {
void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) {
if(Quantity <= 0) {
RemoveBuyLine(CharID, BuySlot);
return;
@@ -1016,7 +1011,7 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct*
}
bool ZoneDatabase::LoadCharacterFactionValues(uint32 character_id, faction_map & val_list) {
std::string query = StringFormat("SELECT faction_id,current_value FROM faction_values WHERE char_id = %i", character_id);
std::string query = StringFormat("SELECT `faction_id`, `current_value` FROM `faction_values` WHERE `char_id` = %i", character_id);
auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) { val_list[atoi(row[0])] = atoi(row[1]); }
return true;
@@ -1055,8 +1050,12 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str
"`value` "
"FROM "
"`character_languages` "
"WHERE `id` = %u ORDER BY `language_id`", character_id);
"WHERE `id` = %u ORDER BY `lang_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0;
/* Initialize Languages */
for (i = 0; i < MAX_PP_LANGUAGE; i++){
pp->languages[i] = 0;
}
for (auto row = results.begin(); row != results.end(); ++row) { i = atoi(row[0]); pp->languages[i] = atoi(row[1]); }
return true;
}
@@ -1069,8 +1068,8 @@ bool ZoneDatabase::LoadCharacterDisciplines(uint32 character_id, PlayerProfile_S
"`character_disciplines`"
"WHERE `id` = %u ORDER BY `disc_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0;
for (auto row = results.begin(); row != results.end(); ++row) { pp->disciplines.values[i] = atoi(row[0]); i++; }
return true;
for (auto row = results.begin(); row != results.end(); ++row) { pp->disciplines.values[i] = atoi(row[0]); i++; }
return true;
}
bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct* pp){
@@ -1081,7 +1080,11 @@ bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct
"FROM "
"`character_skills` "
"WHERE `id` = %u ORDER BY `skill_id`", character_id);
auto results = database.QueryDatabase(query); int i = 0;
auto results = database.QueryDatabase(query); int i = 0;
/* Initialize Skill */
for (i = 0; i < MAX_PP_SKILL; i++){
pp->skills[i] = 0;
}
for (auto row = results.begin(); row != results.end(); ++row) { i = atoi(row[0]); pp->skills[i] = atoi(row[1]); }
return true;
}
@@ -1131,44 +1134,162 @@ bool ZoneDatabase::LoadCharacterCurrency(uint32 character_id, PlayerProfile_Stru
return true;
}
bool ZoneDatabase::LoadCharacterMaterialColor(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT slot, blue, green, red, use_tint, color FROM `character_material` WHERE `id` = %u LIMIT 9", character_id);
auto results = database.QueryDatabase(query); int i = 0; int r = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
r = 0;
i = atoi(row[r]); /* Slot */ r++;
pp->item_tint[i].rgb.blue = atoi(row[r]); r++;
pp->item_tint[i].rgb.green = atoi(row[r]); r++;
pp->item_tint[i].rgb.red = atoi(row[r]); r++;
pp->item_tint[i].rgb.use_tint = atoi(row[r]);
}
return true;
}
bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `bandolier_id`, `bandolier_slot`, `item_id`, `icon`, `bandolier_name` FROM `character_bandolier` WHERE `id` = %u LIMIT 16", character_id);
auto results = database.QueryDatabase(query); int i = 0; int r = 0; int si = 0;
for (i = 0; i <= EmuConstants::BANDOLIERS_COUNT; i++){
for (int si = 0; si < EmuConstants::BANDOLIER_SIZE; si++){
pp->bandoliers[i].items[si].icon = 0;
}
}
for (auto row = results.begin(); row != results.end(); ++row) {
r = 0;
i = atoi(row[r]); /* Bandolier ID */ r++;
si = atoi(row[r]); /* Bandolier Slot */ r++;
pp->bandoliers[i].items[si].item_id = atoi(row[r]); r++;
pp->bandoliers[i].items[si].icon = atoi(row[r]); r++;
strcpy(pp->bandoliers[i].name, row[r]); r++;
si++;
}
return true;
}
bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `tier`, `tribute` FROM `character_tribute` WHERE `id` = %u", character_id);
auto results = database.QueryDatabase(query); int i = 0;
for (i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){
pp->tributes[i].tribute = 0;
pp->tributes[i].tier = 0;
}
for (auto row = results.begin(); row != results.end(); ++row) {
pp->tributes[i].tier = atoi(row[0]);
pp->tributes[i].tribute = atoi(row[1]);
}
return true;
}
bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT `potion_id`, `item_id`, `icon` FROM `character_potionbelt` WHERE `id` = %u LIMIT 4", character_id);
auto results = database.QueryDatabase(query); int i = 0;
for (i = 0; i < EmuConstants::POTION_BELT_SIZE; i++){
pp->potionbelt.items[i].icon = 0;
pp->potionbelt.items[i].item_id = 0;
strncpy(pp->potionbelt.items[i].item_name, "\0", 1);
}
for (auto row = results.begin(); row != results.end(); ++row) {
i = atoi(row[0]); /* Potion belt slot number */
pp->potionbelt.items[i].item_id = atoi(row[1]);
pp->potionbelt.items[i].icon = atoi(row[2]);
}
return true;
}
bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT id, zone_id, instance_id, x, y, z, heading FROM character_bind_home WHERE `id` = %u", character_id);
std::string query = StringFormat("SELECT zone_id, instance_id, x, y, z, heading, is_home FROM character_bind WHERE `id` = %u LIMIT 2", character_id);
auto results = database.QueryDatabase(query); int i = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
pp->binds[4].zoneId = atoi(row[i]); i++;
i++; /* Instance ID can go here eventually */
pp->binds[4].x = atoi(row[i]); i++;
pp->binds[4].y = atoi(row[i]); i++;
pp->binds[4].z = atoi(row[i]); i++;
pp->binds[4].heading = atoi(row[i]); i++;
i = 0;
/* Is home bind */
if (atoi(row[6]) == 1){
pp->binds[4].zoneId = atoi(row[i]); i++;
i++; /* Instance ID can go here eventually */
pp->binds[4].x = atoi(row[i]); i++;
pp->binds[4].y = atoi(row[i]); i++;
pp->binds[4].z = atoi(row[i]); i++;
pp->binds[4].heading = atoi(row[i]); i++;
}
/* Is regular bind point */
else{
pp->binds[0].zoneId = atoi(row[i]); i++;
i++; /* Instance ID can go here eventually */
pp->binds[0].x = atoi(row[i]); i++;
pp->binds[0].y = atoi(row[i]); i++;
pp->binds[0].z = atoi(row[i]); i++;
pp->binds[0].heading = atoi(row[i]); i++;
}
}
return true;
}
bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, uint32 value){
std::string query = StringFormat("REPLACE INTO `character_languages` (id, lang_id, value) VALUES (%u, %u, %u)", character_id, lang_id, value); QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterLanguage for character ID: %i, lang_id:%u value:%u done", character_id, lang_id, value);
return true;
}
bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home){
/* Save Home Bind Point */
std::string query = StringFormat("REPLACE INTO `character_bind` (id, zone_id, instance_id, x, y, z, heading, is_home)"
" VALUES (%u, %u, %u, %f, %f, %f, %f, %i)", character_id, zone_id, instance_id, x, y, z, heading, is_home);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u instance_id: %u x: %f y: %f z: %f heading: %f ishome: %u", character_id, zone_id, instance_id, x, y, z, heading, is_home);
auto results = QueryDatabase(query); if (!results.RowsAffected()){ std::cout << "ERROR Bind Home Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
return true;
}
bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color){
std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, color, use_tint) VALUES (%u, %u, %u, 255)", character_id, slot_id, color); QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color);
return true;
}
bool ZoneDatabase::LoadCharacterMaterialColor(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("SELECT slot, blue, green, red, use_tint, color FROM `character_material` WHERE `id` = %u LIMIT 9", character_id);
auto results = database.QueryDatabase(query); int i = 0; int r = 0;
for (auto row = results.begin(); row != results.end(); ++row) {
r = 0;
i = atoi(row[r]); /* Slot */ r++;
pp->item_tint[i].rgb.blue = atoi(row[r]); r++;
pp->item_tint[i].rgb.green = atoi(row[r]); r++;
pp->item_tint[i].rgb.red = atoi(row[r]); r++;
pp->item_tint[i].rgb.use_tint = atoi(row[r]);
printf("Material Load: %u %u %u %u\n", pp->item_tint[i].rgb.blue, pp->item_tint[i].rgb.green, pp->item_tint[i].rgb.red, pp->item_tint[i].rgb.use_tint);
bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value){
std::string query = StringFormat("REPLACE INTO `character_skills` (id, skill_id, value) VALUES (%u, %u, %u)", character_id, skill_id, value); QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterSkill for character ID: %i, skill_id:%u value:%u done", character_id, skill_id, value);
return true;
}
bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id){
std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id); QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u value:%u done", character_id, slot_id, disc_id);
return true;
}
bool ZoneDatabase::SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp){
std::string query = StringFormat("DELETE FROM `character_tribute` WHERE `id` = %u", character_id); QueryDatabase(query);
/* Save Tributes only if we have values... */
for (int i = 0; i < EmuConstants::TRIBUTE_SIZE; i++){
if (pp->tributes[i].tribute > 0 && pp->tributes[i].tribute != UINT32_MAX){
std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute);
}
}
return true;
}
bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name){
char bandolier_name_esc[64];
DoEscapeString(bandolier_name_esc, bandolier_name, strlen(bandolier_name));
std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc);
auto results = QueryDatabase(query);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name);
if (!results.RowsAffected()){ std::cout << "ERROR Bandolier Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
return true;
}
bool ZoneDatabase::SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon) {
std::string query = StringFormat("REPLACE INTO `character_potionbelt` (id, potion_id, item_id, icon) VALUES (%u, %u, %u, %u)", character_id, potion_id, item_id, icon);
auto results = QueryDatabase(query);
if (!results.RowsAffected()){ std::cout << "ERROR Potionbelt Save: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
return true;
}
bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp){
clock_t t = std::clock(); /* Function timer start */
if (pp->tribute_time_remaining < 0 || pp->tribute_time_remaining == 4294967295){ pp->tribute_time_remaining = 0; }
std::string query = StringFormat(
"REPLACE INTO `character_data` ("
" id, "
@@ -1352,97 +1473,97 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla
"%u," // raid_auto_consent pp->raidAutoconsent, " raid_auto_consent, "
"%u," // guild_auto_consent pp->guildAutoconsent, " guild_auto_consent, "
"%u" // RestTimer pp->RestTimer, " RestTimer) "
")",
character_id,
account_id,
pp->name,
pp->last_name,
pp->gender,
pp->race,
pp->class_,
pp->level,
pp->deity,
pp->birthday,
pp->lastlogin,
pp->timePlayedMin,
pp->pvp,
pp->level2,
pp->anon,
pp->gm,
pp->intoxication,
pp->haircolor,
pp->beardcolor,
pp->eyecolor1,
pp->eyecolor2,
pp->hairstyle,
pp->beard,
pp->ability_time_seconds,
pp->ability_number,
pp->ability_time_minutes,
pp->ability_time_hours,
pp->title,
pp->suffix,
pp->exp,
pp->points,
pp->mana,
pp->cur_hp,
pp->STR,
pp->STA,
pp->CHA,
pp->DEX,
pp->INT,
pp->AGI,
pp->WIS,
pp->face,
pp->y,
pp->x,
pp->z,
pp->heading,
pp->pvp2,
pp->pvptype,
pp->autosplit,
pp->zone_change_count,
pp->drakkin_heritage,
pp->drakkin_tattoo,
pp->drakkin_details,
pp->toxicity,
pp->hunger_level,
pp->thirst_level,
pp->ability_up,
pp->zone_id,
pp->zoneInstance,
pp->leadAAActive,
pp->ldon_points_guk,
pp->ldon_points_mir,
pp->ldon_points_mmc,
pp->ldon_points_ruj,
pp->ldon_points_tak,
pp->ldon_points_available,
pp->tribute_time_remaining,
pp->showhelm,
pp->career_tribute_points,
pp->tribute_points,
pp->tribute_active,
pp->endurance,
pp->group_leadership_exp,
pp->raid_leadership_exp,
pp->group_leadership_points,
pp->raid_leadership_points,
pp->air_remaining,
pp->PVPKills,
pp->PVPDeaths,
pp->PVPCurrentPoints,
pp->PVPCareerPoints,
pp->PVPBestKillStreak,
pp->PVPWorstDeathStreak,
pp->PVPCurrentKillStreak,
pp->aapoints_spent,
pp->expAA,
pp->aapoints,
pp->groupAutoconsent,
pp->raidAutoconsent,
pp->guildAutoconsent,
pp->RestTimer
")",
character_id, // " id, "
account_id, // " account_id, "
pp->name, // " `name`, "
pp->last_name, // " last_name, "
pp->gender, // " gender, "
pp->race, // " race, "
pp->class_, // " class, "
pp->level, // " `level`, "
pp->deity, // " deity, "
pp->birthday, // " birthday, "
pp->lastlogin, // " last_login, "
pp->timePlayedMin, // " time_played, "
pp->pvp, // " pvp_status, "
pp->level2, // " level2, "
pp->anon, // " anon, "
pp->gm, // " gm, "
pp->intoxication, // " intoxication, "
pp->haircolor, // " hair_color, "
pp->beardcolor, // " beard_color, "
pp->eyecolor1, // " eye_color_1, "
pp->eyecolor2, // " eye_color_2, "
pp->hairstyle, // " hair_style, "
pp->beard, // " beard, "
pp->ability_time_seconds, // " ability_time_seconds, "
pp->ability_number, // " ability_number, "
pp->ability_time_minutes, // " ability_time_minutes, "
pp->ability_time_hours, // " ability_time_hours, "
pp->title, // " title, "
pp->suffix, // " suffix, "
pp->exp, // " exp, "
pp->points, // " points, "
pp->mana, // " mana, "
pp->cur_hp, // " cur_hp, "
pp->STR, // " str, "
pp->STA, // " sta, "
pp->CHA, // " cha, "
pp->DEX, // " dex, "
pp->INT, // " `int`, "
pp->AGI, // " agi, "
pp->WIS, // " wis, "
pp->face, // " face, "
pp->y, // " y, "
pp->x, // " x, "
pp->z, // " z, "
pp->heading, // " heading, "
pp->pvp2, // " pvp2, "
pp->pvptype, // " pvp_type, "
pp->autosplit, // " autosplit_enabled, "
pp->zone_change_count, // " zone_change_count, "
pp->drakkin_heritage, // " drakkin_heritage, "
pp->drakkin_tattoo, // " drakkin_tattoo, "
pp->drakkin_details, // " drakkin_details, "
pp->toxicity, // " toxicity, "
pp->hunger_level, // " hunger_level, "
pp->thirst_level, // " thirst_level, "
pp->ability_up, // " ability_up, "
pp->zone_id, // " zone_id, "
pp->zoneInstance, // " zone_instance, "
pp->leadAAActive, // " leadership_exp_on, "
pp->ldon_points_guk, // " ldon_points_guk, "
pp->ldon_points_mir, // " ldon_points_mir, "
pp->ldon_points_mmc, // " ldon_points_mmc, "
pp->ldon_points_ruj, // " ldon_points_ruj, "
pp->ldon_points_tak, // " ldon_points_tak, "
pp->ldon_points_available, // " ldon_points_available, "
pp->tribute_time_remaining, // " tribute_time_remaining, "
pp->showhelm, // " show_helm, "
pp->career_tribute_points, // " career_tribute_points, "
pp->tribute_points, // " tribute_points, "
pp->tribute_active, // " tribute_active, "
pp->endurance, // " endurance, "
pp->group_leadership_exp, // " group_leadership_exp, "
pp->raid_leadership_exp, // " raid_leadership_exp, "
pp->group_leadership_points, // " group_leadership_points, "
pp->raid_leadership_points, // " raid_leadership_points, "
pp->air_remaining, // " air_remaining, "
pp->PVPKills, // " pvp_kills, "
pp->PVPDeaths, // " pvp_deaths, "
pp->PVPCurrentPoints, // " pvp_current_points, "
pp->PVPCareerPoints, // " pvp_career_points, "
pp->PVPBestKillStreak, // " pvp_best_kill_streak, "
pp->PVPWorstDeathStreak, // " pvp_worst_death_streak, "
pp->PVPCurrentKillStreak, // " pvp_current_kill_streak, "
pp->aapoints_spent, // " aa_points_spent, "
pp->expAA, // " aa_exp, "
pp->aapoints, // " aa_points, "
pp->groupAutoconsent, // " group_auto_consent, "
pp->raidAutoconsent, // " raid_auto_consent, "
pp->guildAutoconsent, // " guild_auto_consent, "
pp->RestTimer // " RestTimer) "
);
auto results = database.QueryDatabase(query);
if (!results.RowsAffected()){ std::cout << "ERROR ZoneDatabase:SaveCharacterData: " << results.ErrorMessage() << "\n\n" << query << "\n" << std::endl; }
@@ -1459,6 +1580,10 @@ bool ZoneDatabase::SaveCharacterCurrency(uint32 character_id, PlayerProfile_Stru
if (pp->silver_bank < 0) { pp->silver_bank = 0; }
if (pp->gold_bank < 0) { pp->gold_bank = 0; }
if (pp->platinum_bank < 0) { pp->platinum_bank = 0; }
if (pp->platinum_cursor < 0) { pp->platinum_cursor = 0; }
if (pp->gold_cursor < 0) { pp->gold_cursor = 0; }
if (pp->silver_cursor < 0) { pp->silver_cursor = 0; }
if (pp->copper_cursor < 0) { pp->copper_cursor = 0; }
std::string query = StringFormat(
"REPLACE INTO `character_currency` (id, platinum, gold, silver, copper,"
"platinum_bank, gold_bank, silver_bank, copper_bank,"
@@ -1499,12 +1624,16 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur
bool ZoneDatabase::SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot){
std::string rquery = StringFormat("UPDATE `character_spells` SET `slot_id` = %u WHERE `slot_id` = %u AND `id` = %u",
to_slot, from_slot, character_id);
clock_t t = std::clock(); /* Function timer start */
clock_t t = std::clock(); /* Function timer start */
auto results = QueryDatabase(rquery);
LogFile->write(EQEMuLog::Status, "ZoneDatabase::SaveCharacterSpellSwap for character ID: %u, from_slot: %u to_slot: %u spell: %u time: %f seconds", character_id, from_slot, to_slot, spell_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
return true;
}
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;
}
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;
}
@@ -1513,8 +1642,12 @@ bool ZoneDatabase::DeleteCharacterSpell(uint32 character_id, uint32 spell_id, ui
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::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;
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;
}
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;
}
bool ZoneDatabase::DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id){
@@ -1715,7 +1848,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
tmpNPCType->aggroradius = (int32)atoi(row[r++]);
// set defaultvalue for aggroradius
if (tmpNPCType->aggroradius <= 0)
tmpNPCType->aggroradius = 70;
tmpNPCType->aggroradius = 70;
tmpNPCType->assistradius = (int32)atoi(row[r++]);
if (tmpNPCType->assistradius <= 0)
tmpNPCType->assistradius = tmpNPCType->aggroradius;
@@ -3715,4 +3848,6 @@ void ZoneDatabase::StoreCharacterLookup(uint32 char_id) {
" FROM `character_` "
" WHERE `id` = %i ", char_id);
QueryDatabase(c_lookup);
}
}
+53 -95
View File
@@ -6,6 +6,7 @@
#include "../common/loottable.h"
#include "zonedump.h"
#include "../common/faction.h"
#include <stdint.h>
//#include "doors.h"
struct wplist {
@@ -212,9 +213,7 @@ public:
ZoneDatabase(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
virtual ~ZoneDatabase();
/*
* Objects and World Containers
*/
/* Objects and World Containers */
void LoadWorldContainer(uint32 parentid, ItemInst* container);
void SaveWorldContainer(uint32 zone_id, uint32 parent_id, const ItemInst* container);
void DeleteWorldContainer(uint32 parent_id,uint32 zone_id);
@@ -223,10 +222,7 @@ public:
void DeleteObject(uint32 id);
Ground_Spawns* LoadGroundSpawns(uint32 zone_id, int16 version, Ground_Spawns* gs);
/*
* Traders
*/
/* Traders */
void SaveTraderItem(uint32 char_id,uint32 itemid,uint32 uniqueid, int32 charges,uint32 itemcost,uint8 slot);
void UpdateTraderItemCharges(int char_id, uint32 ItemInstID, int32 charges);
void UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice);
@@ -236,16 +232,13 @@ public:
Trader_Struct* LoadTraderItem(uint32 char_id);
TraderCharges_Struct* LoadTraderItemWithCharges(uint32 char_id);
// Buyer/Barter
//
/* Buyer/Barter */
void AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, const char *ItemName, uint32 Quantity, uint32 Price);
void RemoveBuyLine(uint32 CharID, uint32 BuySlot);
void DeleteBuyLines(uint32 CharID);
void UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity);
/*
* General Character Related Stuff
*/
/* General Character Related Stuff */
void StoreCharacterLookup(uint32 char_id);
bool SetServerFilters(char* name, ServerSideFilters_Struct *ssfs);
uint32 GetServerFilters(char* name, ServerSideFilters_Struct *ssfs);
@@ -267,28 +260,36 @@ public:
bool LoadCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterMaterialColor(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterBandolier(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
bool LoadCharacterPotions(uint32 character_id, PlayerProfile_Struct* pp);
/* Character Data Saves */
bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level);
bool SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot);
bool SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color);
bool SaveCharacterBindPoint(uint32 character_id, uint32 zone_id, uint32 instance_id, float x, float y, float z, float heading, uint8 is_home);
bool SaveCharacterCurrency(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterData(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
bool SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 current_level);
bool SaveCharacterSpellSwap(uint32 character_id, uint32 spell_id, uint32 from_slot, uint32 to_slot);
bool SaveCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool SaveCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool SaveCharacterMaterialColor(uint32 character_id, uint32 slot_id, uint32 color);
bool SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value);
bool SaveCharacterLanguage(uint32 character_id, uint32 lang_id, uint32 value);
bool SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id);
bool SaveCharacterTribute(uint32 character_id, PlayerProfile_Struct* pp);
bool SaveCharacterBandolier(uint32 character_id, uint8 bandolier_id, uint8 bandolier_slot, uint32 item_id, uint32 icon, const char* bandolier_name);
bool SaveCharacterPotionBelt(uint32 character_id, uint8 potion_id, uint32 item_id, uint32 icon);
/* Character Data Deletes */
bool DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterMemorizedSpell(uint32 character_id, uint32 spell_id, uint32 slot_id);
bool DeleteCharacterDisc(uint32 character_id, uint32 slot_id);
bool DeleteCharacterBandolier(uint32 character_id, uint32 band_id);
/*
* Character Inventory
*/
/* Character Inventory */
bool NoRentExpired(const char* name);
/*
* Corpses
*/
/* Corpses */
bool GetDecayTimes(npcDecayTimes_Struct* npcCorpseDecayTimes);
uint32 CreatePlayerCorpse(uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading);
bool CreatePlayerCorpseBackup(uint32 dbid, uint32 charid, const char* charname, uint32 zoneid, uint16 instanceid, uchar* data, uint32 datasize, float x, float y, float z, float heading);
@@ -314,9 +315,7 @@ public:
uint32 GetPlayerCorpseItemAt(uint32 corpse_id, uint16 slotid);
uint32 GetPlayerCorpseTimeLeft(uint8 corpse, uint8 type);
/*
* Faction
*/
/* Faction */
bool GetNPCFactionList(uint32 npcfaction_id, int32* faction_id, int32* value, uint8* temp, int32* primary_faction = 0);
bool GetFactionData(FactionMods* fd, uint32 class_mod, uint32 race_mod, uint32 deity_mod, int32 faction_id); //rembrant, needed for factions Dec, 16 2001
bool GetFactionName(int32 faction_id, char* name, uint32 buflen); // rembrant, needed for factions Dec, 16 2001
@@ -324,9 +323,7 @@ public:
bool SetCharacterFactionLevel(uint32 char_id, int32 faction_id, int32 value, uint8 temp, faction_map &val_list); // rembrant, needed for factions Dec, 16 2001
bool LoadFactionData();
/*
* AAs
*/
/* AAs */
bool LoadAAEffects();
bool LoadAAEffects2();
bool LoadSwarmSpells();
@@ -338,9 +335,7 @@ public:
uint32 CountAAEffects();
void FillAAEffects(SendAA_Struct* aa_struct);
/*
* Zone related
*/
/* Zone related */
bool GetZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct *data, bool &can_bind, bool &can_combat, bool &can_levitate, bool &can_castoutdoor, bool &is_city, bool &is_hotzone, bool &allow_mercs, uint8 &zone_type, int &ruleset, char **map_filename);
bool SaveZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct* zd);
bool LoadStaticZonePoints(LinkedList<ZonePoint*>* zone_point_list,const char* zonename, uint32 version);
@@ -348,9 +343,7 @@ public:
uint8 GetUseCFGSafeCoords();
int getZoneShutDownDelay(uint32 zoneID, uint32 version);
/*
* Spawns and Spawn Points
*/
/* Spawns and Spawn Points */
bool LoadSpawnGroups(const char* zone_name, uint16 version, SpawnGroupList* spawn_group_list);
bool LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList* spawn_group_list);
bool PopulateZoneSpawnList(uint32 zoneid, LinkedList<Spawn2*> &spawn2_list, int16 version, uint32 repopdelay = 0);
@@ -360,9 +353,7 @@ public:
uint32 GetSpawnTimeLeft(uint32 id, uint16 instance_id);
void UpdateSpawn2Status(uint32 id, uint8 new_status);
/*
* Grids/Paths
*/
/* Grids/Paths */
uint32 GetFreeGrid(uint16 zoneid);
void DeleteGrid(Client *c, uint32 sg2, uint32 grid_num, bool grid_too,uint16 zoneid);
void DeleteWaypoint(Client *c, uint32 grid_num, uint32 wp_num,uint16 zoneid);
@@ -378,9 +369,7 @@ public:
int GetHighestGrid(uint32 zoneid);
int GetHighestWaypoint(uint32 zoneid, uint32 gridid);
/*
* NPCs
*/
/* NPCs */
const NPCType* GetNPCType(uint32 id);
uint32 NPCSpawnDB(uint8 command, const char* zone, uint32 zone_version, Client *c, NPC* spawn = 0, uint32 extra = 0); // 0 = Create 1 = Add; 2 = Update; 3 = Remove; 4 = Delete
bool SetSpecialAttkFlag(uint8 id, const char* flag);
@@ -394,9 +383,7 @@ public:
DBnpcspells_Struct* GetNPCSpells(uint32 iDBSpellsID);
DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID);
/*
* Mercs
*/
/* Mercs */
const NPCType* GetMercType(uint32 id, uint16 raceid, uint32 clientlevel);
void LoadMercEquipment(Merc *merc);
void SaveMercBuffs(Merc *merc);
@@ -408,9 +395,7 @@ public:
//void LoadMercTypesForMercMerchant(NPC *merchant);
//void LoadMercsForMercMerchant(NPC *merchant);
/*
* Petitions
*/
/* Petitions */
void UpdateBug(BugStruct* bug);
void UpdateBug(PetitionBug_Struct* bug);
void DeletePetitionFromDB(Petition* wpet);
@@ -418,16 +403,11 @@ public:
void InsertPetitionToDB(Petition* wpet);
void RefreshPetitionsFromDB();
/*
* Merchants
*/
/* Merchants */
void SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 item, uint32 charges);
void DeleteMerchantTemp(uint32 npcid, uint32 slot);
/*
* Tradeskills
*/
/* Tradeskills */
bool GetTradeRecipe(const ItemInst* container, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec);
bool GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id, uint32 char_id, DBTradeskillRecipe_Struct *spec);
uint32 GetZoneForage(uint32 ZoneID, uint8 skill); /* for foraging */
@@ -436,14 +416,10 @@ public:
bool EnableRecipe(uint32 recipe_id);
bool DisableRecipe(uint32 recipe_id);
/*
* Tribute
*/
/* Tribute */
bool LoadTributes();
/*
* Doors
*/
/* Doors */
bool DoorIsOpen(uint8 door_id,const char* zone_name);
void SetDoorPlace(uint8 value,uint8 door_id,const char* zone_name);
bool LoadDoors(int32 iDoorCount, Door *into, const char *zone_name, int16 version);
@@ -456,64 +432,46 @@ public:
int32 GetDoorsDBCountPlusOne(const char *zone_name, int16 version);
void InsertDoor(uint32 did, uint16 ddoorid, const char* ddoor_name, float dxpos, float dypos, float dzpos, float dheading, uint8 dopentype, uint16 dguildid, uint32 dlockpick, uint32 dkeyitem, uint8 ddoor_param, uint8 dinvert, int dincline, uint16 dsize);
/*
* Blocked Spells
*/
/* Blocked Spells */
int32 GetBlockedSpellsCount(uint32 zoneid);
bool LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked* into, uint32 zoneid);
/*
* Traps
*/
/* Traps */
bool LoadTraps(const char* zonename, int16 version);
char* GetTrapMessage(uint32 trap_id);
/*
* Time
*/
/* Time */
uint32 GetZoneTZ(uint32 zoneid, uint32 version);
bool SetZoneTZ(uint32 zoneid, uint32 version, uint32 tz);
/*
* Group
*/
/* Group */
void RefreshGroupFromDB(Client *c);
uint8 GroupCount(uint32 groupid);
/*
* Raid
*/
/* Raid */
uint8 RaidGroupCount(uint32 raidid, uint32 groupid);
/*
* Instancing
*/
/* Instancing */
void ListAllInstances(Client* c, uint32 charid);
/*
* QGlobals
*/
/* QGlobals */
void QGlobalPurge();
/*
* Alternate Currency
*/
/* Alternate Currency */
void LoadAltCurrencyValues(uint32 char_id, std::map<uint32, uint32> &currency);
void UpdateAltCurrencyValue(uint32 char_id, uint32 currency_id, uint32 value);
/*
* Misc stuff.
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD
* REALLY HAS NO BETTER SECTION
* Misc stuff.
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD
* REALLY HAS NO BETTER SECTION
*/
bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
void GetEventLogs(const char* name,char* target,uint32 account_id=0,uint8 eventid=0,char* detail=0,char* timestamp=0, CharacterEventLog_Struct* cel=0);
uint32 GetKarma(uint32 acct_id);
void UpdateKarma(uint32 acct_id, uint32 amount);
/*
* Things which really dont belong here...
*/
/* Things which really dont belong here... */
int16 CommandRequirement(const char* commandname);
protected:
-103
View File
@@ -1,103 +0,0 @@
#include "../common/debug.h"
#include <iostream>
#include "entity.h"
#include "masterentity.h"
#include "../common/string_util.h"
#include "../common/breakdowns.h"
#include <stdlib.h>
extern EntityList entity_list;
void DispatchFinishedDBAsync(DBAsyncWork* dbaw) {
uint32_breakdown workpt;
workpt = dbaw->WPT();
switch (workpt.b4()) {
case DBA_b4_Entity: {
Entity* entity = entity_list.GetID(workpt.w2_3());
if (!entity)
break;
entity->DBAWComplete(workpt.b1(), dbaw);
break;
}
default: {
std::cout << "Error: DispatchFinishedDBAsync(): Unknown workpt.b4: " << (int) workpt.b4() << ", workpt=" << workpt << std::endl;
break;
}
}
safe_delete(dbaw);
}
#define MAX_TO_DELETE 10
#define MAX_BACKUPS 5
bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork) { // return true means delete data
char errbuf[MYSQL_ERRMSG_SIZE] = "dbaq == 0";
MYSQL_RES* result = 0;
MYSQL_ROW row;
char* query = 0;
uint32 i;
uint8 ToDeleteIndex = 0;
uint32 ToDelete[MAX_TO_DELETE];
memset(ToDelete, 0, sizeof(ToDelete));
uint32 BackupAges[MAX_BACKUPS]; // must be sorted, highest value in lowest index
memset(BackupAges, 0, sizeof(BackupAges));
bool FoundBackup[MAX_BACKUPS];
memset(FoundBackup, 0, sizeof(FoundBackup));
BackupAges[0] = 86400;
BackupAges[1] = 3600;
DBAsyncQuery* dbaq = iWork->PopAnswer();
if (dbaq && dbaq->GetAnswer(errbuf, &result)) {
while ((row = mysql_fetch_row(result))) {
for (i=0; i<MAX_BACKUPS; i++) {
if (BackupAges[i] == 0 || (uint32)atoi(row[1]) > BackupAges[i])
i = MAX_BACKUPS;
else if (!FoundBackup[i]) {
FoundBackup[i] = true;
break;
}
}
if (i >= MAX_BACKUPS)
ToDelete[ToDeleteIndex++] = atoi(row[0]);
if (ToDeleteIndex >= MAX_TO_DELETE)
break;
}
if (ToDelete[0]) {
uint32 len = 0, size = 0;
AppendAnyLenString(&query, &size, &len, "Delete from character_backup where id=%u", ToDelete[0]);
for (uint8 i=1; i<ToDeleteIndex; i++) {
AppendAnyLenString(&query, &size, &len, " or id=%u", ToDelete[i]);
}
if (!database.RunQuery(query, len, errbuf)) {
LogFile->write(EQEMuLog::Error, "Error in DBAsyncCB_CharacterBackup query2 '%s' %s", query, errbuf);
safe_delete_array(query);
return true;
}
safe_delete_array(query);
}
bool needtoinsert = false;
for (i=0; i<MAX_BACKUPS; i++) {
if (BackupAges[i] != 0 && !FoundBackup[i])
needtoinsert = true;
}
if (needtoinsert) {
if (!database.RunQuery(query, MakeAnyLenString(&query,
"Insert Delayed into character_backup (charid, account_id, name, profile, level, class, x, y, z, zoneid) "
"select id, account_id, name, profile, level, class, x, y, z, zoneid "
"from character_ where id=%u", iWork->WPT()), errbuf)) {
std::cout << "Error in DBAsyncCB_CharacterBackup query3 '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return true;
}
safe_delete_array(query);
}
}
else {
// std::cout << "Error in DBAsyncCB_CharacterBackup query1 '" << query << "' " << errbuf << std::endl;
safe_delete_array(query);
return true;
}
return true;
}
-22
View File
@@ -1,22 +0,0 @@
#ifndef ZONEDBASYNC_H
#define ZONEDBASYNC_H
#include "../common/dbasync.h"
void DispatchFinishedDBAsync(DBAsyncWork* iDBAW);
bool DBAsyncCB_CharacterBackup(DBAsyncWork* iWork);
#define DBA_b4_Main 1
#define DBA_b4_Worldserver 2
#define DBA_b4_Zone 3
#define DBA_b4_Entity 4
#define DBA_b1_Entity_SeeQPT 0
#define DBA_b1_Entity_Client_InfoForLogin 1
#define DBA_b1_Entity_Client_Save 2
#define DBA_b1_Entity_Client_Backup 3
#define DBA_b1_Entity_Corpse_Backup 4
#define DBA_b1_Zone_MerchantLists 5
#define DBA_b1_Zone_MerchantListsTemp 6
#endif
+1 -9
View File
@@ -50,10 +50,6 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) {
#endif
ZoneChange_Struct* zc=(ZoneChange_Struct*)app->pBuffer;
printf("INCOMING CLIENT\n\n");
printf("%s\n", zc->char_name);
printf("%u\n", zc->zoneID);
uint16 target_zone_id = 0;
uint16 target_instance_id = zc->instanceID;
ZonePoint* zone_point = nullptr;
@@ -568,7 +564,6 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
if(ReadyToZone) {
zone_mode = zm;
printf("\n\n ZONE MODE %u \n\n", zm);
if(zm == ZoneToBindPoint) {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ZonePlayerToBind, sizeof(ZonePlayerToBind_Struct) + iZoneNameLength);
ZonePlayerToBind_Struct* gmg = (ZonePlayerToBind_Struct*) outapp->pBuffer;
@@ -602,10 +597,6 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
gmg->instance_id = instance_id;
gmg->type = 0x01; //an observed value, not sure of meaning
printf("gmg->zone_id %u \n", gmg->zone_id);
printf("gmg->x %u \n", gmg->x);
printf("gmg->y %u \n", gmg->y);
outapp->priority = 6;
FastQueuePacket(&outapp);
safe_delete(outapp);
@@ -726,6 +717,7 @@ void Client::SetBindPoint(int to_zone, float new_x, float new_y, float new_z) {
m_pp.binds[0].y = new_y;
m_pp.binds[0].z = new_z;
}
database.SaveCharacterBindPoint(this->CharacterID(), m_pp.binds[0].zoneId, 0, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, 0, 0);
}
void Client::GoToBind(uint8 bindnum) {