mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
Fix for potion belt name loading.
This commit is contained in:
parent
c0cbbf3a65
commit
aa021addc1
@ -103,6 +103,7 @@ SET(common_headers
|
||||
crash.h
|
||||
crc16.h
|
||||
crc32.h
|
||||
data_verification.h
|
||||
database.h
|
||||
dbcore.h
|
||||
debug.h
|
||||
|
||||
@ -38,6 +38,11 @@ T ClampUpper(const T& value, const T& upper) {
|
||||
return std::min(value, upper);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
||||
return value >= lower && value <= upper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -26,12 +26,6 @@
|
||||
#include "dbcore.h"
|
||||
#include "linked_list.h"
|
||||
#include "eq_packet_structs.h"
|
||||
/*#include "eq_stream.h"
|
||||
#include "guilds.h"
|
||||
#include "misc_functions.h"
|
||||
#include "mutex.h"
|
||||
#include "item.h"
|
||||
#include "extprofile.h"*/
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@ -29,6 +29,7 @@ public:
|
||||
TEST_ADD(DataVerificationTest::Clamp);
|
||||
TEST_ADD(DataVerificationTest::ClampUpper);
|
||||
TEST_ADD(DataVerificationTest::ClampLower);
|
||||
TEST_ADD(DataVerificationTest::ValueWithin);
|
||||
}
|
||||
|
||||
~DataVerificationTest() {
|
||||
@ -89,6 +90,19 @@ public:
|
||||
TEST_ASSERT_EQUALS(vi1, 500);
|
||||
TEST_ASSERT_EQUALS(vi2, 750);
|
||||
}
|
||||
|
||||
void ValueWithin() {
|
||||
float value_f = 500.0f;
|
||||
int value_i = 500;
|
||||
|
||||
TEST_ASSERT(EQEmu::ValueWithin(value_f, 0.0f, 1000.0f));
|
||||
TEST_ASSERT(!EQEmu::ValueWithin(value_f, 0.0f, 400.0f));
|
||||
TEST_ASSERT(!EQEmu::ValueWithin(value_f, 600.0f, 900.0f));
|
||||
|
||||
TEST_ASSERT(EQEmu::ValueWithin(value_i, 0, 1000));
|
||||
TEST_ASSERT(!EQEmu::ValueWithin(value_i, 0, 400));
|
||||
TEST_ASSERT(!EQEmu::ValueWithin(value_i, 600, 900));
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -48,6 +48,7 @@
|
||||
#include "../common/guilds.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "petitions.h"
|
||||
#include "npc_ai.h"
|
||||
#include "../common/skills.h"
|
||||
@ -10490,7 +10491,13 @@ void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app)
|
||||
DumpPacket(app);
|
||||
return;
|
||||
}
|
||||
|
||||
MovePotionToBelt_Struct *mptbs = (MovePotionToBelt_Struct*)app->pBuffer;
|
||||
if(!EQEmu::ValueWithin(mptbs->SlotNumber, 0U, 3U)) {
|
||||
LogFile->write(EQEMuLog::Debug, "Client::Handle_OP_PotionBelt mptbs->SlotNumber out of range.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mptbs->Action == 0) {
|
||||
const Item_Struct *BaseItem = database.GetItem(mptbs->ItemID);
|
||||
if (BaseItem) {
|
||||
|
||||
@ -301,6 +301,7 @@ luabind::scope lua_register_packet() {
|
||||
.def("ReadFixedLengthString", &Lua_Packet::ReadFixedLengthString);
|
||||
}
|
||||
|
||||
//TODO: Reorder these to match emu_oplist.h again
|
||||
luabind::scope lua_register_packet_opcodes() {
|
||||
return luabind::class_<Opcodes>("Opcode")
|
||||
.enum_("constants")
|
||||
|
||||
@ -1178,8 +1178,14 @@ bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struc
|
||||
}
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
i = atoi(row[0]); /* Potion belt slot number */
|
||||
pp->potionbelt.items[i].item_id = atoi(row[1]);
|
||||
uint32 item_id = atoi(row[1]);
|
||||
const Item_Struct *item = database.GetItem(item_id);
|
||||
|
||||
if(item) {
|
||||
pp->potionbelt.items[i].item_id = item_id;
|
||||
pp->potionbelt.items[i].icon = atoi(row[2]);
|
||||
strncpy(pp->potionbelt.items[i].item_name, item->Name, 64);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user