LightSourceProfile relocation and some more formatting changes

This commit is contained in:
Uleat 2016-05-20 04:26:32 -04:00
parent 04f47f1e32
commit ebe6f95e6e
15 changed files with 128 additions and 121 deletions

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
@ -70,7 +70,9 @@ namespace EQEmu
extern uint32 ConvertClientVersionToClientVersionBit(ClientVersion client_version);
extern ClientVersion ConvertClientVersionBitToClientVersion(uint32 client_version_bit);
extern uint32 ConvertClientVersionToExpansion(ClientVersion client_version);
}
}
} /*versions*/
#endif /* COMMON_CLIENT_VERSION_H */
} /*EQEmu*/
#endif /*COMMON_CLIENT_VERSION_H*/

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
@ -55,7 +55,9 @@ namespace EQEmu
extern const char* InventoryVersionName(InventoryVersion inventory_version);
extern ClientVersion ConvertInventoryVersionToClientVersion(InventoryVersion inventory_version);
extern InventoryVersion ConvertClientVersionToInventoryVersion(ClientVersion client_version);
}
}
} /*versions*/
#endif /* COMMON_INVENTORY_VERSION_H */
} /*EQEmu*/
#endif /*COMMON_INVENTORY_VERSION_H*/

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
@ -19,24 +19,8 @@
#include "light_source.h"
#include <memory>
EQEmu::lightsource::LightSourceProfile::LightSourceProfile()
{
Clear();
}
void EQEmu::lightsource::LightSourceProfile::Clear()
{
Type.Innate = 0;
Type.Equipment = 0;
Type.Spell = 0;
Type.Active = 0;
Level.Innate = 0;
Level.Equipment = 0;
Level.Spell = 0;
Level.Active = 0;
}
uint8 EQEmu::lightsource::TypeToLevel(uint8 light_type)
{
@ -97,3 +81,19 @@ bool EQEmu::lightsource::IsLevelGreater(uint8 left_type, uint8 right_type)
return (light_levels[left_type] > light_levels[right_type]);
}
EQEmu::lightsource::Light_Struct::Light_Struct()
{
Clear();
}
void EQEmu::lightsource::Light_Struct::Clear()
{
memset(&Slot, 0, (sizeof(uint8) * sizeof(Slot)));
}
void EQEmu::LightSourceProfile::Clear()
{
Type.Clear();
Level.Clear();
}

View File

@ -1,4 +1,4 @@
/* EQEMu: Everquest Server Emulator
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
@ -26,6 +26,15 @@
namespace EQEmu
{
namespace lightsource {
enum LightSlot {
LightInnate = 0, // Defined by db field `npc_types`.`light` - where appropriate
LightEquipment, // Item_Struct::light value of worn/carried equipment
LightSpell, // Set value of any light-producing spell (can be modded to mimic equip_light behavior)
LightActive, // Highest value of all light sources
LightCount
};
enum LightType {
LightTypeNone = 0,
LightTypeCandle,
@ -61,47 +70,47 @@ namespace EQEmu
LightLevelCount
};
struct LightSourceProfile {
/*
Current criteria (light types):
Equipment: { 0 .. 15 }
General: { 9 .. 13 }
struct Light_Struct {
uint8 Slot[LightCount];
Notes:
- Initial character load and item movement updates use different light source update behaviors
-- Server procedure matches the item movement behavior since most updates occur post-character load
- MainAmmo is not considered when determining light sources
- No 'Sub' or 'Aug' items are recognized as light sources
- Light types '< 9' and '> 13' are not considered for general (carried) light sources
- If values > 0x0F are valid, then assignment limiters will need to be removed
- MainCursor 'appears' to be a valid light source update slot..but, have not experienced updates during debug sessions
- All clients have a bug regarding stackable items (light and sound updates are not processed when picking up an item)
-- The timer-based update cancels out the invalid light source
*/
LightSourceProfile();
Light_Struct();
void Clear();
// Light types (classifications)
struct {
uint8 Innate; // Defined by db field `npc_types`.`light` - where appropriate
uint8 Equipment; // Item_Struct::light value of worn/carried equipment
uint8 Spell; // Set value of any light-producing spell (can be modded to mimic equip_light behavior)
uint8 Active; // Highest value of all light sources
} Type;
// Light levels (intensities) - used to determine which light source should be active
struct {
uint8 Innate;
uint8 Equipment;
uint8 Spell;
uint8 Active;
} Level;
inline uint8& operator[](LightSlot index) { return Slot[index]; }
};
extern uint8 TypeToLevel(uint8 light_type);
extern bool IsLevelGreater(uint8 left_type, uint8 right_type);
};
}
}; /*lightsource*/
#endif /* COMMON_LIGHT_SOURCE_H */
struct LightSourceProfile {
/*
Current criteria (light types):
Equipment: { 0 .. 15 }
General: { 9 .. 13 }
Notes:
- Initial character load and item movement updates use different light source update behaviors
-- Server procedure matches the item movement behavior since most updates occur post-character load
- MainAmmo is not considered when determining light sources
- No 'Sub' or 'Aug' items are recognized as light sources
- Light types '< 9' and '> 13' are not considered for general (carried) light sources
- If values > 0x0F are valid, then assignment limiters will need to be removed
- MainCursor 'appears' to be a valid light source update slot..but, have not experienced updates during debug sessions
- All clients have a bug regarding stackable items (light and sound updates are not processed when picking up an item)
-- The timer-based update cancels out the invalid light source
*/
lightsource::Light_Struct Type; // Light types (classifications)
lightsource::Light_Struct Level; // Light levels (intensities) - used to determine which light source should be active
LightSourceProfile() { }
void Clear();
};
} /*EQEmu*/
#endif /*COMMON_LIGHT_SOURCE_H*/

View File

@ -93,7 +93,6 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, glm
timers[i] = 0;
strcpy(this->name, this->GetCleanName());
memset(&m_Light, 0, sizeof(EQEmu::lightsource::LightSourceProfile));
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
}
@ -2955,7 +2954,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
ns->spawn.size = 0;
ns->spawn.NPC = 0; // 0=player,1=npc,2=pc corpse,3=npc corpse
UpdateActiveLight();
ns->spawn.light = m_Light.Type.Active;
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
ns->spawn.helm = helmtexture; //(GetShowHelm() ? helmtexture : 0); //0xFF;
ns->spawn.equip_chest2 = texture; //0xFF;
const Item_Struct* item = 0;

View File

@ -386,7 +386,7 @@ public:
void BotTradeAddItem(uint32 id, const ItemInst* inst, int16 charges, uint32 equipableSlots, uint16 lootSlot, std::string* errorMessage, bool addToDb = true);
void EquipBot(std::string* errorMessage);
bool CheckLoreConflict(const Item_Struct* item);
virtual void UpdateEquipmentLight() { m_Light.Type.Equipment = m_inv.FindBrightestLightType(); m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment); }
virtual void UpdateEquipmentLight() { m_Light.Type[EQEmu::lightsource::LightEquipment] = m_inv.FindBrightestLightType(); m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]); }
// Static Class Methods
//static void DestroyBotRaidObjects(Client* client); // Can be removed after bot raids are dumped

View File

@ -1902,7 +1902,7 @@ void Client::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
UpdateEquipmentLight();
UpdateActiveLight();
ns->spawn.light = m_Light.Type.Active;
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
}
bool Client::GMHideMe(Client* client) {

View File

@ -737,7 +737,7 @@ public:
#endif
uint32 GetEquipment(uint8 material_slot) const; // returns item id
uint32 GetEquipmentColor(uint8 material_slot) const;
virtual void UpdateEquipmentLight() { m_Light.Type.Equipment = m_inv.FindBrightestLightType(); m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment); }
virtual void UpdateEquipmentLight() { m_Light.Type[EQEmu::lightsource::LightEquipment] = m_inv.FindBrightestLightType(); m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]); }
inline bool AutoSplitEnabled() { return m_pp.autosplit != 0; }

View File

@ -139,10 +139,8 @@ Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std:
pc->IsRezzed(rezzed);
pc->become_npc = false;
pc->m_Light.Level.Innate = pc->m_Light.Type.Innate = 0;
pc->UpdateEquipmentLight(); // itemlist populated above..need to determine actual values
pc->m_Light.Level.Spell = pc->m_Light.Type.Spell = 0;
safe_delete_array(pcs);
return pc;
@ -531,7 +529,6 @@ in_helmtexture,
SetPlayerKillItemID(0);
UpdateEquipmentLight();
m_Light.Level.Spell = m_Light.Type.Spell = 0;
UpdateActiveLight();
}
@ -1283,7 +1280,7 @@ void Corpse::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
ns->spawn.NPC = 2;
UpdateActiveLight();
ns->spawn.light = m_Light.Type.Active;
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
}
void Corpse::QueryLoot(Client* to) {
@ -1432,8 +1429,8 @@ uint32 Corpse::GetEquipmentColor(uint8 material_slot) const {
void Corpse::UpdateEquipmentLight()
{
m_Light.Type.Equipment = 0;
m_Light.Level.Equipment = 0;
m_Light.Type[EQEmu::lightsource::LightEquipment] = 0;
m_Light.Level[EQEmu::lightsource::LightEquipment] = 0;
for (auto iter = itemlist.begin(); iter != itemlist.end(); ++iter) {
if (((*iter)->equip_slot < EQEmu::legacy::EQUIPMENT_BEGIN || (*iter)->equip_slot > EQEmu::legacy::EQUIPMENT_END) && (*iter)->equip_slot != EQEmu::legacy::SlotPowerSource) { continue; }
@ -1442,8 +1439,8 @@ void Corpse::UpdateEquipmentLight()
auto item = database.GetItem((*iter)->item_id);
if (item == nullptr) { continue; }
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type.Equipment))
m_Light.Type.Equipment = item->Light;
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type[EQEmu::lightsource::LightEquipment]))
m_Light.Type[EQEmu::lightsource::LightEquipment] = item->Light;
}
uint8 general_light_type = 0;
@ -1460,10 +1457,10 @@ void Corpse::UpdateEquipmentLight()
general_light_type = item->Light;
}
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type.Equipment))
m_Light.Type.Equipment = general_light_type;
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type[EQEmu::lightsource::LightEquipment]))
m_Light.Type[EQEmu::lightsource::LightEquipment] = general_light_type;
m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment);
m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]);
}
void Corpse::AddLooter(Mob* who) {

View File

@ -1210,7 +1210,7 @@ void Merc::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {
ns->spawn.IsMercenary = 1;
UpdateActiveLight();
ns->spawn.light = m_Light.Type.Active;
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
/*
// Wear Slots are not setup for Mercs yet
@ -5041,8 +5041,8 @@ void Merc::UpdateMercAppearance() {
void Merc::UpdateEquipmentLight()
{
m_Light.Type.Equipment = 0;
m_Light.Level.Equipment = 0;
m_Light.Type[EQEmu::lightsource::LightEquipment] = 0;
m_Light.Level[EQEmu::lightsource::LightEquipment] = 0;
for (int index = SLOT_BEGIN; index < EQEmu::legacy::EQUIPMENT_SIZE; ++index) {
if (index == EQEmu::legacy::SlotAmmo) { continue; }
@ -5050,9 +5050,9 @@ void Merc::UpdateEquipmentLight()
auto item = database.GetItem(equipment[index]);
if (item == nullptr) { continue; }
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type.Equipment)) {
m_Light.Type.Equipment = item->Light;
m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment);
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type[EQEmu::lightsource::LightEquipment])) {
m_Light.Type[EQEmu::lightsource::LightEquipment] = item->Light;
m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]);
}
}
@ -5068,10 +5068,10 @@ void Merc::UpdateEquipmentLight()
general_light_type = item->Light;
}
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type.Equipment))
m_Light.Type.Equipment = general_light_type;
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type[EQEmu::lightsource::LightEquipment]))
m_Light.Type[EQEmu::lightsource::LightEquipment] = general_light_type;
m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment);
m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]);
}
void Merc::AddItem(uint8 slot, uint32 item_id) {

View File

@ -178,12 +178,10 @@ Mob::Mob(const char* in_name,
if (runspeed < 0 || runspeed > 20)
runspeed = 1.25f;
m_Light.Type.Innate = in_light;
m_Light.Level.Innate = EQEmu::lightsource::TypeToLevel(m_Light.Type.Innate);
m_Light.Level.Equipment = m_Light.Type.Equipment = 0;
m_Light.Level.Spell = m_Light.Type.Spell = 0;
m_Light.Type.Active = m_Light.Type.Innate;
m_Light.Level.Active = m_Light.Level.Innate;
m_Light.Type[EQEmu::lightsource::LightInnate] = in_light;
m_Light.Level[EQEmu::lightsource::LightInnate] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightInnate]);
m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightInnate];
m_Light.Level[EQEmu::lightsource::LightActive] = m_Light.Level[EQEmu::lightsource::LightInnate];
texture = in_texture;
helmtexture = in_helmtexture;
@ -1100,7 +1098,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
ns->spawn.findable = findable?1:0;
UpdateActiveLight();
ns->spawn.light = m_Light.Type.Active;
ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive];
ns->spawn.showhelm = (helmtexture && helmtexture != 0xFF) ? 1 : 0;
@ -2227,18 +2225,18 @@ void Mob::SetAppearance(EmuAppearance app, bool iIgnoreSelf) {
bool Mob::UpdateActiveLight()
{
uint8 old_light_level = m_Light.Level.Active;
uint8 old_light_level = m_Light.Level[EQEmu::lightsource::LightActive];
m_Light.Type.Active = 0;
m_Light.Level.Active = 0;
m_Light.Type[EQEmu::lightsource::LightActive] = 0;
m_Light.Level[EQEmu::lightsource::LightActive] = 0;
if (EQEmu::lightsource::IsLevelGreater((m_Light.Type.Innate & 0x0F), m_Light.Type.Active)) { m_Light.Type.Active = m_Light.Type.Innate; }
if (m_Light.Level.Equipment > m_Light.Level.Active) { m_Light.Type.Active = m_Light.Type.Equipment; } // limiter in property handler
if (m_Light.Level.Spell > m_Light.Level.Active) { m_Light.Type.Active = m_Light.Type.Spell; } // limiter in property handler
if (EQEmu::lightsource::IsLevelGreater((m_Light.Type[EQEmu::lightsource::LightInnate] & 0x0F), m_Light.Type[EQEmu::lightsource::LightActive])) { m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightInnate]; }
if (m_Light.Level[EQEmu::lightsource::LightEquipment] > m_Light.Level[EQEmu::lightsource::LightActive]) { m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightEquipment]; } // limiter in property handler
if (m_Light.Level[EQEmu::lightsource::LightSpell] > m_Light.Level[EQEmu::lightsource::LightActive]) { m_Light.Type[EQEmu::lightsource::LightActive] = m_Light.Type[EQEmu::lightsource::LightSpell]; } // limiter in property handler
m_Light.Level.Active = EQEmu::lightsource::TypeToLevel(m_Light.Type.Active);
m_Light.Level[EQEmu::lightsource::LightActive] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightActive]);
return (m_Light.Level.Active != old_light_level);
return (m_Light.Level[EQEmu::lightsource::LightActive] != old_light_level);
}
void Mob::ChangeSize(float in_size = 0, bool bNoRestriction) {

View File

@ -703,17 +703,17 @@ public:
bool IsDestructibleObject() { return destructibleobject; }
void SetDestructibleObject(bool in) { destructibleobject = in; }
inline uint8 GetInnateLightType() { return m_Light.Type.Innate; }
inline uint8 GetEquipmentLightType() { return m_Light.Type.Equipment; }
inline uint8 GetSpellLightType() { return m_Light.Type.Spell; }
inline uint8 GetInnateLightType() { return m_Light.Type[EQEmu::lightsource::LightInnate]; }
inline uint8 GetEquipmentLightType() { return m_Light.Type[EQEmu::lightsource::LightEquipment]; }
inline uint8 GetSpellLightType() { return m_Light.Type[EQEmu::lightsource::LightSpell]; }
virtual void UpdateEquipmentLight() { m_Light.Type.Equipment = 0; m_Light.Level.Equipment = 0; }
inline void SetSpellLightType(uint8 light_type) { m_Light.Type.Spell = (light_type & 0x0F); m_Light.Level.Spell = EQEmu::lightsource::TypeToLevel(m_Light.Type.Spell); }
virtual void UpdateEquipmentLight() { m_Light.Type[EQEmu::lightsource::LightEquipment] = 0; m_Light.Level[EQEmu::lightsource::LightEquipment] = 0; }
inline void SetSpellLightType(uint8 light_type) { m_Light.Type[EQEmu::lightsource::LightSpell] = (light_type & 0x0F); m_Light.Level[EQEmu::lightsource::LightSpell] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightSpell]); }
inline uint8 GetActiveLightType() { return m_Light.Type.Active; }
inline uint8 GetActiveLightType() { return m_Light.Type[EQEmu::lightsource::LightActive]; }
bool UpdateActiveLight(); // returns true if change, false if no change
EQEmu::lightsource::LightSourceProfile* GetLightProfile() { return &m_Light; }
EQEmu::LightSourceProfile* GetLightProfile() { return &m_Light; }
Mob* GetPet();
void SetPet(Mob* newpet);
@ -1185,7 +1185,7 @@ protected:
glm::vec4 m_Delta;
EQEmu::lightsource::LightSourceProfile m_Light;
EQEmu::LightSourceProfile m_Light;
float fixedZ;
EmuAppearance _appearance;

View File

@ -745,8 +745,8 @@ uint32 NPC::CountLoot() {
void NPC::UpdateEquipmentLight()
{
m_Light.Type.Equipment = 0;
m_Light.Level.Equipment = 0;
m_Light.Type[EQEmu::lightsource::LightEquipment] = 0;
m_Light.Level[EQEmu::lightsource::LightEquipment] = 0;
for (int index = SLOT_BEGIN; index < EQEmu::legacy::EQUIPMENT_SIZE; ++index) {
if (index == EQEmu::legacy::SlotAmmo) { continue; }
@ -754,9 +754,9 @@ void NPC::UpdateEquipmentLight()
auto item = database.GetItem(equipment[index]);
if (item == nullptr) { continue; }
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type.Equipment)) {
m_Light.Type.Equipment = item->Light;
m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment);
if (EQEmu::lightsource::IsLevelGreater(item->Light, m_Light.Type[EQEmu::lightsource::LightEquipment])) {
m_Light.Type[EQEmu::lightsource::LightEquipment] = item->Light;
m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]);
}
}
@ -772,10 +772,10 @@ void NPC::UpdateEquipmentLight()
general_light_type = item->Light;
}
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type.Equipment))
m_Light.Type.Equipment = general_light_type;
if (EQEmu::lightsource::IsLevelGreater(general_light_type, m_Light.Type[EQEmu::lightsource::LightEquipment]))
m_Light.Type[EQEmu::lightsource::LightEquipment] = general_light_type;
m_Light.Level.Equipment = EQEmu::lightsource::TypeToLevel(m_Light.Type.Equipment);
m_Light.Level[EQEmu::lightsource::LightEquipment] = EQEmu::lightsource::TypeToLevel(m_Light.Type[EQEmu::lightsource::LightEquipment]);
}
void NPC::Depop(bool StartSpawnTimer) {