mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-14 06:34:55 +02:00
fix set outfit functionality
This commit is contained in:
@@ -343,4 +343,6 @@ static constexpr int32_t PSTRG_RESERVED_RANGE_SIZE = 10000000;
|
||||
static constexpr int32_t PSTRG_OUTFITS_RANGE_START = (PSTRG_RESERVED_RANGE_START + 1000);
|
||||
static constexpr int32_t PSTRG_OUTFITS_RANGE_SIZE = 500;
|
||||
|
||||
#define IS_IN_KEYRANGE(key, range) (key >= PSTRG_##range##_START && ((key - PSTRG_##range##_START) <= PSTRG_##range##_SIZE))
|
||||
|
||||
#endif
|
||||
|
@@ -220,6 +220,13 @@ void mainLoader(int, char*[], ServiceManager* services)
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << ">> Loading outfits" << std::endl;
|
||||
auto& outfits = Outfits::getInstance();
|
||||
if (!outfits.loadFromXml()) {
|
||||
startupErrorMessage("Unable to load outfits!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << ">> Checking world type... " << std::flush;
|
||||
std::string worldType = asLowerCaseString(g_config.getString(ConfigManager::WORLD_TYPE));
|
||||
if (worldType == "pvp") {
|
||||
|
@@ -509,6 +509,20 @@ uint16_t Player::getLookCorpse() const
|
||||
|
||||
void Player::addStorageValue(const uint32_t key, const int32_t value)
|
||||
{
|
||||
if (IS_IN_KEYRANGE(key, RESERVED_RANGE)) {
|
||||
if (IS_IN_KEYRANGE(key, OUTFITS_RANGE)) {
|
||||
outfits.emplace_back(
|
||||
value >> 16,
|
||||
value & 0xFF
|
||||
);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
std::cout << "Warning: unknown reserved key: " << key << " player: " << getName() << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (value != -1) {
|
||||
storageMap[key] = value;
|
||||
} else {
|
||||
|
@@ -1738,7 +1738,7 @@ void ProtocolGame::sendOutfitWindow()
|
||||
}
|
||||
|
||||
protocolOutfits.emplace_back(outfit.name, outfit.lookType, addons);
|
||||
if (protocolOutfits.size() == 100) { // Game client doesn't allow more than 100 outfits
|
||||
if (protocolOutfits.size() == 15) { // Game client doesn't allow more than 15 outfits
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1746,7 +1746,6 @@ void ProtocolGame::sendOutfitWindow()
|
||||
msg.addByte(protocolOutfits.size());
|
||||
for (const ProtocolOutfit& outfit : protocolOutfits) {
|
||||
msg.add<uint16_t>(outfit.lookType);
|
||||
msg.addString(outfit.name);
|
||||
msg.addByte(outfit.addons);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user