mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 05:53:34 +00:00
working query
This commit is contained in:
parent
a49f9dc586
commit
b2c88bb6a7
@ -6,6 +6,7 @@
|
||||
|
||||
#include "Database.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "User.h"
|
||||
#include <WorldPackets.h>
|
||||
#include "Character.h"
|
||||
@ -572,28 +573,26 @@ uint32_t GetShirtColorId(uint32_t color) {
|
||||
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) {
|
||||
|
||||
shirtStyle--; // to start at 0 instead of 1
|
||||
uint32_t stylesCount = 34;
|
||||
uint32_t colorId = GetShirtColorId(shirtColor);
|
||||
|
||||
uint32_t startID = 4049; // item ID of the shirt with color 0 (red) and style 0 (plain)
|
||||
|
||||
// For some reason, if the shirt style is 34 - 39,
|
||||
// The ID is different than the original... Was this because
|
||||
// these shirts were added later?
|
||||
if (shirtStyle >= 34) {
|
||||
startID = 5730; // item ID of the shirt with color 0 (red) and style 34 (butterflies)
|
||||
shirtStyle -= stylesCount; //change style from range 35-40 to range 0-5
|
||||
stylesCount = 6;
|
||||
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 == ";
|
||||
shirtQuery += std::to_string(shirtColor);
|
||||
shirtQuery += " AND icc.decal == ";
|
||||
shirtQuery = shirtQuery + std::to_string(shirtStyle);
|
||||
auto tableData = CDClientDatabase::ExecuteQuery(shirtQuery);
|
||||
auto shirtLOT = tableData.getIntField(0, -1);
|
||||
tableData.finalize();
|
||||
return shirtLOT;
|
||||
}
|
||||
catch (const std::exception&){
|
||||
Game::logger->Log("Character Create", "Failed to use query! Using backup...");
|
||||
// in case of no shirt found in CDServer, return problematic red vest.
|
||||
return 4069;
|
||||
}
|
||||
|
||||
// Get the final ID of the shirt
|
||||
uint32_t shirtID = startID + (colorId * stylesCount) + shirtStyle;
|
||||
|
||||
return shirtID;
|
||||
}
|
||||
|
||||
uint32_t FindCharPantsID(uint32_t pantsColor) {
|
||||
|
Loading…
Reference in New Issue
Block a user