From df86e644f445ef579bfdfa152ae98c4bc18e69d3 Mon Sep 17 00:00:00 2001 From: Paul Coene Date: Tue, 10 Jan 2017 20:18:16 -0500 Subject: [PATCH] Now the actual code changes - lol --- common/eq_packet_structs.h | 1 + common/patches/rof2.cpp | 1 + common/patches/rof2_structs.h | 3 ++- common/shareddb.cpp | 5 ++-- common/shareddb.h | 2 +- utils/sql/db_update_manifest.txt | 1 + zone/client.cpp | 40 +++++++++++++++++++++++++++----- 7 files changed, 43 insertions(+), 10 deletions(-) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 1d25e4d66..a3e26a9a4 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -2495,6 +2495,7 @@ struct BookRequest_Struct { uint8 window; // where to display the text (0xFF means new window) uint8 type; //type: 0=scroll, 1=book, 2=item info.. prolly others. uint32 invslot; // Only used in Sof and later clients; + int16 subslot; // The subslot inside of a bag if it is inside one. char txtfile[20]; }; diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index d56791bef..8f8d41281 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -5154,6 +5154,7 @@ namespace RoF2 IN(type); IN(invslot); + IN(subslot); emu->window = (uint8)eq->window; strn0cpy(emu->txtfile, eq->txtfile, sizeof(emu->txtfile)); diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index 850df8ddf..1ed1b9916 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -2826,7 +2826,8 @@ struct BookText_Struct { struct BookRequest_Struct { /*0000*/ uint32 window; // where to display the text (0xFFFFFFFF means new window). /*0004*/ uint16 invslot; // Is the slot, but the RoF2 conversion causes it to fail. Turned to 0 since it isnt required anyway. -/*0008*/ uint32 unknown006; // Seen FFFFFFFF +/*0006*/ int16 subslot; // Inventory sub-slot (0-x) +/*0008*/ uint16 unknown006; // Seen FFFF /*0010*/ uint16 unknown008; // seen 0000 /*0012*/ uint32 type; // 0 = Scroll, 1 = Book, 2 = Item Info. Possibly others /*0016*/ uint32 unknown0012; diff --git a/common/shareddb.cpp b/common/shareddb.cpp index fc628ea6f..a4d0e6235 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1136,13 +1136,13 @@ const EQEmu::ItemData* SharedDatabase::IterateItems(uint32* id) { return nullptr; } -std::string SharedDatabase::GetBook(const char *txtfile) +std::string SharedDatabase::GetBook(const char *txtfile, int16 *language) { char txtfile2[20]; std::string txtout; strcpy(txtfile2, txtfile); - std::string query = StringFormat("SELECT txtfile FROM books WHERE name = '%s'", txtfile2); + std::string query = StringFormat("SELECT txtfile, language FROM books WHERE name = '%s'", txtfile2); auto results = QueryDatabase(query); if (!results.Success()) { txtout.assign(" ",1); @@ -1157,6 +1157,7 @@ std::string SharedDatabase::GetBook(const char *txtfile) auto row = results.begin(); txtout.assign(row[0],strlen(row[0])); + *language = static_cast(atoi(row[1])); return txtout; } diff --git a/common/shareddb.h b/common/shareddb.h index b58d1f138..d3d8020a1 100644 --- a/common/shareddb.h +++ b/common/shareddb.h @@ -94,7 +94,7 @@ class SharedDatabase : public Database bool SetStartingItems(PlayerProfile_Struct* pp, EQEmu::InventoryProfile* inv, uint32 si_race, uint32 si_class, uint32 si_deity, uint32 si_current_zone, char* si_name, int admin); - std::string GetBook(const char *txtfile); + std::string GetBook(const char *txtfile, int16 *language); /* Item Methods diff --git a/utils/sql/db_update_manifest.txt b/utils/sql/db_update_manifest.txt index aa72310ce..816a35a7c 100644 --- a/utils/sql/db_update_manifest.txt +++ b/utils/sql/db_update_manifest.txt @@ -355,6 +355,7 @@ 9099|2016_08_27_ip_exemptions.sql|SHOW TABLES LIKE 'ip_exemptions'|empty| 9100|2016_08_27_object_display_name.sql|SHOW COLUMNS FROM `object` LIKE 'display_name'|empty| 9101|2016_12_01_pcnpc_only.sql|SHOW COLUMNS FROM `spells_new` LIKE 'pcnpc_only_flag'|empty| +9102|2017_01_10_book_languages.sql|SHOW COLUMNS FROM `books` LIKE 'language'|empty| # Upgrade conditions: # This won't be needed after this system is implemented, but it is used database that are not diff --git a/zone/client.cpp b/zone/client.cpp index ddf10d9d5..6b6de32c1 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -33,6 +33,7 @@ extern volatile bool RunLoops; #include "../common/eqemu_logsys.h" #include "../common/features.h" +#include "../common/emu_legacy.h" #include "../common/spdat.h" #include "../common/guilds.h" #include "../common/rulesys.h" @@ -1998,6 +1999,7 @@ void Client::SetGM(bool toggle) { } void Client::ReadBook(BookRequest_Struct *book) { + int16 book_language=0; char *txtfile = book->txtfile; if(txtfile[0] == '0' && txtfile[1] == '\0') { @@ -2005,7 +2007,7 @@ void Client::ReadBook(BookRequest_Struct *book) { return; } - std::string booktxt2 = database.GetBook(txtfile); + std::string booktxt2 = database.GetBook(txtfile, &book_language); int length = booktxt2.length(); if (booktxt2[0] != '\0') { @@ -2016,21 +2018,47 @@ void Client::ReadBook(BookRequest_Struct *book) { BookText_Struct *out = (BookText_Struct *) outapp->pBuffer; out->window = book->window; - if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) - { - const EQEmu::ItemInstance *inst = m_inv[book->invslot]; + + + if (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) { + // Find out what slot the book was read from. + // SoF+ need to look up book type for the output message. + int16 read_from_slot; + + if (book->subslot >= 0) { + uint16 offset; + offset = (book->invslot-23) * 10; // How many packs to skip. + read_from_slot = 251 + offset + book->subslot; + } + else { + read_from_slot = book->invslot -1; + } + + const EQEmu::ItemInstance *inst = 0; + + if (read_from_slot <= EQEmu::legacy::SLOT_PERSONAL_BAGS_END) + { + inst = m_inv[read_from_slot]; + } + if(inst) out->type = inst->GetItem()->Book; else out->type = book->type; } - else - { + else { out->type = book->type; } out->invslot = book->invslot; + memcpy(out->booktext, booktxt2.c_str(), length); + if (book_language > 0 && book_language < MAX_PP_LANGUAGE) { + if (m_pp.languages[book_language] < 100) { + GarbleMessage(out->booktext, (100 - m_pp.languages[book_language])); + } + } + QueuePacket(outapp); safe_delete(outapp); }