Changed pants query and removed extra comments

This commit is contained in:
EmosewaMC 2022-03-24 00:30:52 -07:00
parent b2c88bb6a7
commit 4e2c352ab9
2 changed files with 11 additions and 143 deletions

View File

@ -69,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() {
@ -567,16 +557,6 @@ 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);
}
// the correct query
/**
* select obj.id, obj.name, obj._internalnotes, icc.color1, icc.decal 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";
*/
uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) { uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) {
try { try {
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 == "; 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 == ";
@ -596,91 +576,19 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) {
} }
uint32_t FindCharPantsID(uint32_t pantsColor) { uint32_t FindCharPantsID(uint32_t pantsColor) {
uint32_t pantsID = 2508; try {
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) == \"cc pants\" AND icc.color1 == ";
switch (pantsColor) { shirtQuery += std::to_string(pantsColor);
case 0: { auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery);
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 use 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() {

View File

@ -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