mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-29 10:06:30 +00:00
Merge pull request #474 from EmosewaMC/char-create-fixes
Addressed hard coded character create values for shirts and pants
This commit is contained in:
commit
529b40b66c
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "dLogger.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
#include <WorldPackets.h>
|
#include <WorldPackets.h>
|
||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
@ -68,16 +69,6 @@ void UserManager::Initialize() {
|
|||||||
StripCR(line);
|
StripCR(line);
|
||||||
m_PreapprovedNames.push_back(line);
|
m_PreapprovedNames.push_back(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Load custom ones from MySQL too:
|
|
||||||
/*sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT name FROM approvedNames;");
|
|
||||||
sql::ResultSet* res = stmt->executeQuery();
|
|
||||||
while (res->next()) {
|
|
||||||
m_PreapprovedNames.push_back(res->getString(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
delete res;
|
|
||||||
delete stmt;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManager::~UserManager() {
|
UserManager::~UserManager() {
|
||||||
@ -566,122 +557,38 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetShirtColorId(uint32_t color) {
|
|
||||||
|
|
||||||
// get the index of the color in shirtColorVector
|
|
||||||
auto colorId = std::find(shirtColorVector.begin(), shirtColorVector.end(), color);
|
|
||||||
return color = std::distance(shirtColorVector.begin(), colorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) {
|
uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) {
|
||||||
|
try {
|
||||||
shirtStyle--; // to start at 0 instead of 1
|
std::string shirtQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"character create shirt\" AND icc.color1 == ";
|
||||||
uint32_t stylesCount = 34;
|
shirtQuery += std::to_string(shirtColor);
|
||||||
uint32_t colorId = GetShirtColorId(shirtColor);
|
shirtQuery += " AND icc.decal == ";
|
||||||
|
shirtQuery = shirtQuery + std::to_string(shirtStyle);
|
||||||
uint32_t startID = 4049; // item ID of the shirt with color 0 (red) and style 0 (plain)
|
auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery);
|
||||||
|
auto shirtLOT = tableData.getIntField(0, -1);
|
||||||
// For some reason, if the shirt style is 34 - 39,
|
tableData.finalize();
|
||||||
// The ID is different than the original... Was this because
|
return shirtLOT;
|
||||||
// these shirts were added later?
|
}
|
||||||
if (shirtStyle >= 34) {
|
catch (const std::exception&){
|
||||||
startID = 5730; // item ID of the shirt with color 0 (red) and style 34 (butterflies)
|
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
||||||
shirtStyle -= stylesCount; //change style from range 35-40 to range 0-5
|
// in case of no shirt found in CDServer, return problematic red vest.
|
||||||
stylesCount = 6;
|
return 4069;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the final ID of the shirt
|
|
||||||
uint32_t shirtID = startID + (colorId * stylesCount) + shirtStyle;
|
|
||||||
|
|
||||||
return shirtID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t FindCharPantsID(uint32_t pantsColor) {
|
uint32_t FindCharPantsID(uint32_t pantsColor) {
|
||||||
uint32_t pantsID = 2508;
|
try {
|
||||||
|
std::string pantsQuery = "select obj.id from Objects as obj JOIN (select * from ComponentsRegistry as cr JOIN ItemComponent as ic on ic.id = cr.component_id where cr.component_type == 11) as icc on icc.id = obj.id where lower(obj._internalNotes) == \"cc pants\" AND icc.color1 == ";
|
||||||
switch (pantsColor) {
|
pantsQuery += std::to_string(pantsColor);
|
||||||
case 0: {
|
auto tableData = CDClientDatabase::ExecuteQuery(pantsQuery);
|
||||||
pantsID = PANTS_BRIGHT_RED;
|
auto pantsLOT = tableData.getIntField(0, -1);
|
||||||
break;
|
tableData.finalize();
|
||||||
|
return pantsLOT;
|
||||||
}
|
}
|
||||||
|
catch (const std::exception&){
|
||||||
case 1: {
|
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
||||||
pantsID = PANTS_BRIGHT_BLUE;
|
// in case of no pants color found in CDServer, return red pants.
|
||||||
break;
|
return 2508;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: {
|
|
||||||
pantsID = PANTS_DARK_GREEN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 5: {
|
|
||||||
pantsID = PANTS_BRIGHT_ORANGE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 6: {
|
|
||||||
pantsID = PANTS_BLACK;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 7: {
|
|
||||||
pantsID = PANTS_DARK_STONE_GRAY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 8: {
|
|
||||||
pantsID = PANTS_MEDIUM_STONE_GRAY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 9: {
|
|
||||||
pantsID = PANTS_REDDISH_BROWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 10: {
|
|
||||||
pantsID = PANTS_WHITE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 11: {
|
|
||||||
pantsID = PANTS_MEDIUM_BLUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 13: {
|
|
||||||
pantsID = PANTS_DARK_RED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 14: {
|
|
||||||
pantsID = PANTS_EARTH_BLUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 15: {
|
|
||||||
pantsID = PANTS_EARTH_GREEN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 16: {
|
|
||||||
pantsID = PANTS_BRICK_YELLOW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 84: {
|
|
||||||
pantsID = PANTS_SAND_BLUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 96: {
|
|
||||||
pantsID = PANTS_SAND_GREEN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pantsID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserManager::SaveAllActiveCharacters() {
|
void UserManager::SaveAllActiveCharacters() {
|
||||||
|
@ -44,7 +44,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static UserManager* m_Address; //Singleton
|
static UserManager* m_Address; //Singleton
|
||||||
//std::vector<User*> m_Users;
|
|
||||||
std::map<SystemAddress, User*> m_Users;
|
std::map<SystemAddress, User*> m_Users;
|
||||||
std::vector<User*> m_UsersToDelete;
|
std::vector<User*> m_UsersToDelete;
|
||||||
|
|
||||||
@ -54,43 +53,4 @@ private:
|
|||||||
std::vector<std::string> m_PreapprovedNames;
|
std::vector<std::string> m_PreapprovedNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CharCreatePantsColor : uint32_t {
|
|
||||||
PANTS_BRIGHT_RED = 2508,
|
|
||||||
PANTS_BRIGHT_ORANGE = 2509,
|
|
||||||
PANTS_BRICK_YELLOW = 2511,
|
|
||||||
PANTS_MEDIUM_BLUE = 2513,
|
|
||||||
PANTS_SAND_GREEN = 2514,
|
|
||||||
PANTS_DARK_GREEN = 2515,
|
|
||||||
PANTS_EARTH_GREEN = 2516,
|
|
||||||
PANTS_EARTH_BLUE = 2517,
|
|
||||||
PANTS_BRIGHT_BLUE = 2519,
|
|
||||||
PANTS_SAND_BLUE = 2520,
|
|
||||||
PANTS_DARK_STONE_GRAY = 2521,
|
|
||||||
PANTS_MEDIUM_STONE_GRAY = 2522,
|
|
||||||
PANTS_WHITE = 2523,
|
|
||||||
PANTS_BLACK = 2524,
|
|
||||||
PANTS_REDDISH_BROWN = 2526,
|
|
||||||
PANTS_DARK_RED = 2527
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::vector<uint32_t> shirtColorVector {
|
|
||||||
0, // BRIGHT_RED
|
|
||||||
1, // BRIGHT_BLUE
|
|
||||||
2, // BRIGHT_YELLOW
|
|
||||||
3, // DARK_GREEN
|
|
||||||
5, // BRIGHT_ORANGE
|
|
||||||
6, // BLACK
|
|
||||||
7, // DARK_STONE_GRAY
|
|
||||||
8, // MEDIUM_STONE_GRAY
|
|
||||||
9, // REDDISH_BROWN
|
|
||||||
10, // WHITE
|
|
||||||
11, // MEDIUM_BLUE
|
|
||||||
13, // DARK_RED
|
|
||||||
14, // EARTH_BLUE
|
|
||||||
15, // EARTH_GREEN
|
|
||||||
16, // BRICK_YELLOW
|
|
||||||
84, // SAND_BLUE
|
|
||||||
96 // SAND_GREEN
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // USERMANAGER_H
|
#endif // USERMANAGER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user