Skip to content

Commit

Permalink
Sync emu branch of eqlib with changes from live branch
Browse files Browse the repository at this point in the history
  • Loading branch information
brainiac committed Oct 2, 2024
1 parent b270a55 commit fbd6aed
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 86 deletions.
2 changes: 1 addition & 1 deletion Achievements.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class [[offsetcomments]] AchievementCategory
/*0x04*/ AchievementInfoArray achievements;
/*0x14*/ ArrayClass<int> childCategories;
/*0x24*/ int id = -1;
/*0x28*/ int parentId = -1;
/*0x28*/ int parentId = 0;
/*0x2c*/ CXStr name;
/*0x30*/ CXStr description;
/*0x34*/ CXStr bitmapId;
Expand Down
7 changes: 5 additions & 2 deletions BuildType.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@
// AdvancedLoot was released on March 25, 2015
#define HAS_ADVANCED_LOOT IS_CLIENT_DATE(20150325)

// Personas feature added in Laurion's Song
#define HAS_ALTERNATE_PERSONAS IS_EXPANSION_LEVEL(EXPANSION_LEVEL_LS)

// Autoskills was added April 19, 2017
#define HAS_AUTOSKILLS IS_CLIENT_DATE(20170419)

// DirectX 11 Support added to Test on 9/12/2023
#define HAS_DIRECTX_11 (IS_CLIENT_DATE(20230912) && IS_TEST_CLIENT)
// DirectX 11 Support added to Test on 9/12/2023 and Live on 1/16/2024
#define HAS_DIRECTX_11 ((IS_CLIENT_DATE(20230912) && IS_TEST_CLIENT) || IS_CLIENT_DATE(20240116))
#define HAS_DIRECTX_9 (!HAS_DIRECTX_11)

// Dragon Hoard was added with the Claws of Veeshan Expansion
Expand Down
62 changes: 56 additions & 6 deletions CXStr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,21 +1322,38 @@ class EQLIB_OBJECT CXStr

CXStr& replace(size_type pos, size_type count, const char* cstr, size_type count2)
{
// replace [pos, pos + count) with [cstr, cstr + count2)
CheckOffset(pos);
count = ClampSuffixSize(pos, count);
char* insertAt = m_data->utf8 + pos;

if (count == count2) {
// no resize required
traits_type::move(insertAt, cstr, count2);
return *this;
}

const size_type oldSize = size();
const size_type suffixSize = oldSize - pos - count + 1;
const size_type newSize = oldSize - (count - count2);

Assure(newSize + 1, StringEncodingUtf8);
if (count2 < count) {
// shrink
traits_type::move(insertAt, cstr, count2);
traits_type::move(insertAt + count2, insertAt + count, suffixSize);

if (count == count2)
{
traits_type::move(m_data->utf8 + pos, cstr, count2);
m_data->length = static_cast<uint32_t>(newSize);
return *this;
}

// grow
Assure(newSize + 1, StringEncodingUtf8);
m_data->length = static_cast<uint32_t>(newSize);

traits_type::move(insertAt + count2, insertAt + count, suffixSize);
traits_type::move(insertAt, cstr, count2);

return *this;
}

CXStr& replace(const_iterator first, const_iterator last,
Expand Down Expand Up @@ -1432,6 +1449,8 @@ class EQLIB_OBJECT CXStr
{
traits_type::copy(dest, m_data->utf8 + pos, count);
}

return count;
}

// Resizes the string to contain count characters. If the current size is less
Expand Down Expand Up @@ -1526,6 +1545,37 @@ class EQLIB_OBJECT CXStr
return sv.find(t, pos);
}

size_t rfind(const CXStr& str, size_type pos = 0) const noexcept
{
std::string_view sv{ *this };
return sv.rfind(std::string_view{ str }, pos);
}

size_t rfind(const char* s, size_t pos, size_t count) const
{
std::string_view sv{ *this };
return sv.rfind(s, pos, count);
}

size_t rfind(const char* s, size_type pos = 0) const
{
std::string_view sv{ *this };
return sv.rfind(s, pos);
}

size_t rfind(char ch, size_type pos = 0) const noexcept
{
std::string_view sv{ *this };
return sv.rfind(ch, pos);
}

template <typename T, typename = is_string_view_ish<T>>
size_t rfind(const T& t, size_t pos = 0) const noexcept
{
std::string_view sv{ *this };
return sv.rfind(t, pos);
}

int GetLength() const { return static_cast<int>(m_data ? m_data->length : 0); }
char GetChar(int pos) const;
char16_t GetUnicode(int pos) const;
Expand Down Expand Up @@ -1580,15 +1630,15 @@ class EQLIB_OBJECT CXStr
void FreeRep(CStrRep* rep);
void FreeRepNoLock(CStrRep* rep);

[[noreturn]] void CheckOffset(const size_type offset) const
void CheckOffset(const size_type offset) const
{
if (size() < offset)
{
throw std::out_of_range("invalid string position");
}
}

[[noreturn]] void CheckOffsetExclusive(const size_type offset) const
void CheckOffsetExclusive(const size_type offset) const
{
if (size() <= offset)
{
Expand Down
1 change: 1 addition & 0 deletions Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ namespace eqlib::detail{
#define ALT_MEMBER_ALIAS_DEPRECATED(type, orig, name, msg) \
DEPRECATE(msg) \
type& getter_ ## name() { return orig; } \
DEPRECATE(msg) \
void setter_ ## name(const type& v) { orig = v; } \
__declspec(property(get=getter_ ## name, put=setter_ ## name)) type name;

Expand Down
37 changes: 19 additions & 18 deletions Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,23 +343,23 @@ constexpr int LORE_NAME_LEN = 80;
// Deities - different from the above values, used for spells and items.
enum EQDeity
{
EQD_Agnostic = 1,
EQD_Bertoxxulous = 2,
EQD_BrellSerilis = 3,
EQD_CazicThule = 4,
EQD_ErollisiMarr = 5,
EQD_Bristlebane = 6,
EQD_Innoruuk = 7,
EQD_Karana = 8,
EQD_MithanielMarr = 9,
EQD_Prexus = 10,
EQD_Quellious = 11,
EQD_RallosZek = 12,
EQD_RodcetNife = 13,
EQD_SolusekRo = 14,
EQD_TheTribunal = 15,
EQD_Tunare = 16,
EQD_Veeshan = 17,
EQD_Agnostic = 1,
EQD_Bertoxxulous = 2,
EQD_BrellSerilis = 3,
EQD_CazicThule = 4,
EQD_ErollisiMarr = 5,
EQD_Bristlebane = 6,
EQD_Innoruuk = 7,
EQD_Karana = 8,
EQD_MithanielMarr = 9,
EQD_Prexus = 10,
EQD_Quellious = 11,
EQD_RallosZek = 12,
EQD_RodcetNife = 13,
EQD_SolusekRo = 14,
EQD_TheTribunal = 15,
EQD_Tunare = 16,
EQD_Veeshan = 17,
};
#define NUM_DEITIES 16

Expand Down Expand Up @@ -534,6 +534,7 @@ enum EQExpansion
EQExpansionCOV = EXPANSION_LEVEL_COV,
EQExpansionTOL = EXPANSION_LEVEL_TOL,
EQExpansionNOS = EXPANSION_LEVEL_NOS,
EQExpansionLS = EXPANSION_LEVEL_LS,
};

#define EQ_EXPANSION(x) (1 << (x - 1))
Expand Down Expand Up @@ -869,7 +870,7 @@ enum ALTCURRENCY
ALTCURRENCY_TIMELESSTOKEN = 59, // LS Anniversary

ALTCURRENCY_FIRST = ALTCURRENCY_DOUBLOONS,
ALTCURRENCY_LAST = ALTCURRENCY_SHADOWSTONES,
ALTCURRENCY_LAST = ALTCURRENCY_TIMELESSTOKEN,

ALTCURRENCY_CROWNS = 999999,

Expand Down
2 changes: 1 addition & 1 deletion EQClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int AchievementManager::GetAchievementCategoryIndexByName(std::string_view name)
{
const AchievementCategory& category = categories[index];

if (category.parentId == -1 && mq::ci_equals(category.name, name))
if (category.parentId <= 0 && mq::ci_equals(category.name, name))
return index;
}

Expand Down
1 change: 0 additions & 1 deletion EQClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,6 @@ class [[offsetcomments]] SkillManager
EQLIB_OBJECT unsigned int GetSkillTimerDuration(int);
EQLIB_OBJECT unsigned int GetSkillLastUsed(int);

// 363
/*0x000000*/ TSafeArrayStatic<EQ_Skill*, NUM_SKILLS> pSkill;
/*0x000190*/ int SkillCaps[MAX_CLASSES + 1][NUM_SKILLS][MAX_PC_LEVEL + 1];
/*0x1632d0*/ float SkillMods[MAX_CLASSES + 1][NUM_SKILLS][MAX_PC_LEVEL + 1];
Expand Down
2 changes: 1 addition & 1 deletion EQData.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline namespace deprecated {
using PCLASSINFO DEPRECATE("Use SClassInfo instead of CLASSINFO") = SClassInfo*;
}

static SClassInfo ClassInfo[] =
static const SClassInfo ClassInfo[] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "" }, // unk
{ 0, 0, 0, 0, 0, 0, 0, 0, 13, "Warrior", "war", "WAR" }, // war
Expand Down
15 changes: 15 additions & 0 deletions EQLib.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,19 @@
<Item Name="test">getXmlData()</Item>
</Expand>-->
</Type>

<Type Name="eqlib::PlayerClient">
<DisplayString>[PlayerClient #{SpawnID,d}, {Name,s}]</DisplayString>
</Type>

<Type Name="eqlib::PlayerHashTable">
<DisplayString>{{Size={m_count}}}</DisplayString>
<Expand>
<LinkedListItems>
<HeadPointer>m_head</HeadPointer>
<NextPointer>m_prev</NextPointer>
<ValueNode>m_value</ValueNode>
</LinkedListItems>
</Expand>
</Type>
</AutoVisualizer>
17 changes: 0 additions & 17 deletions EverQuest.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ class ChatBufferEntry;
class EQCamera;


enum ChatFilterValues
{
ChatFilterValue_Invalid = -1,
ChatFilterValue_Show = 0,
ChatFilterValue_Hide = 1,
ChatFilterValue_Me = 2,
ChatFilterValue_Group = 3,

ChatFilterValue_Max,
};

//============================================================================
// ZoneHeader
//============================================================================
Expand Down Expand Up @@ -1137,12 +1126,6 @@ class [[offsetcomments]] CEverQuest : public CEverQuestBase, public UniversalCha
ALT_MEMBER_GETTER(UniversalChatProxy*, chatService, ChatService);
};

inline namespace deprecated {
using _EVERQUEST DEPRECATE("Use EVERQUEST instead of _EVERQUEST") = CEverQuest;
using PEVERQUEST DEPRECATE("Use EVERQUEST* instead of PEVERQUEST") = CEverQuest*;
}
using EVERQUEST = CEverQuest;

//SIZE_CHECK(CEverQuest, CEverQuest_size);

} // namespace eqlib
5 changes: 5 additions & 0 deletions Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,17 @@ const char* szExpansions[NUM_EXPANSIONS + 1] = {
#endif
#if IS_EXPANSION_LEVEL(EXPANSION_LEVEL_NOS)
"Night of Shadows",
#endif
#if IS_EXPANSION_LEVEL(EXPANSION_LEVEL_LS)
"Laurion's Song",
#endif
nullptr
};
static_assert(lengthof(szExpansions) - 1 == NUM_EXPANSIONS,
"Need to update szExpansions to match NUM_EXPANSIONS");

//============================================================================

MQColor gDefaultUserDefinedColors[NUM_USER_COLORS] = {
MQColor(255, 255, 255), // 1 Say
MQColor(190, 40, 190), // 2 Tell
Expand Down
2 changes: 2 additions & 0 deletions GraphicsResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class [[offsetcomments]] CEQGBitmap

return nullptr;
}

bool HasTexture() const { return m_bHasTexture; }
};


Expand Down
2 changes: 1 addition & 1 deletion Items.h
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ Visitor& ItemContainer::VisitItemsImpl(int beginSlot, int endSlot, int depth, It
while (iter != endIter)
{
// Update the cursor
cursor.SetSlot(m_atDepth, slot);
cursor.SetSlot(m_atDepth, static_cast<short>(slot));
const ItemPtr& ptr = *iter;

if (ptr != nullptr)
Expand Down
15 changes: 8 additions & 7 deletions SoeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class IString
ensure_writable(len + 1);

std::memcpy(m_data, other, len + 1);
m_length = len;
m_length = static_cast<int>(len);
}
}

Expand All @@ -428,7 +428,7 @@ class IString
ensure_writable(length + 1);
std::memcpy(m_data, other, length);
m_data[length] = 0;
m_length = length;
m_length = static_cast<int>(length);
}
}

Expand All @@ -443,10 +443,11 @@ class IString

void ensure_writable(size_t length)
{
if ((int)length > m_space || ref_count() > 1)
if (length > static_cast<size_t>(m_space) || ref_count() > 1)
{
if (length < m_length + 1)
length = m_length + 1;
size_t neededSize = static_cast<size_t>(m_length + 1);
if (length < neededSize)
length = neededSize;

// data we need includes the std::atomic_int
size_t spaceNeeded = length + sizeof(std::atomic_int);
Expand All @@ -456,9 +457,9 @@ class IString
new (data) std::atomic_int(shared ? 1 : 0);

T* newData = reinterpret_cast<T*>(data + sizeof(std::atomic_int));
int newSpace = allocated - sizeof(std::atomic_int);
int newSpace = static_cast<int>(allocated - sizeof(std::atomic_int));
int newLength = m_length;
std::memcpy(newData, c_str(), m_length + 1);
std::memcpy(newData, c_str(), neededSize);

decrement_ref_count();

Expand Down
14 changes: 0 additions & 14 deletions XMLData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,6 @@ CParamRGB::~CParamRGB()

//----------------------------------------------------------------------------

#if 0 // emu
CParamTextRGB::CParamTextRGB()
{
nClassIdx = UI_TextRGB;
sClassName = UITypeToString(UI_TextRGB);
}

CParamTextRGB::~CParamTextRGB()
{
}
#endif

//----------------------------------------------------------------------------

CParamPoint::CParamPoint()
{
nClassIdx = UI_Point;
Expand Down
Loading

0 comments on commit fbd6aed

Please sign in to comment.