Skip to content

Commit

Permalink
Partial implementation of leadership in raids
Browse files Browse the repository at this point in the history
Currently working: stat bonuses and client side only effects
Currently not working: Mark NPC and others that need more server side work

Currently only tested on UF, Ti and 62 may work, but not tested
SoF, SoD, and RoF need packet translators, which are most likely the same as UF
  • Loading branch information
mackal committed Oct 14, 2014
1 parent 15cec40 commit be0621d
Show file tree
Hide file tree
Showing 19 changed files with 891 additions and 42 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 10/13/2014 ==
demonstar55: Partially implement leadership and raids
Currently working: client side only effects and stat bonuses.
Not working: Mark NPC, and other stuff that need extra server side support
Currently only UF tested (Tit and 62 may just work, others need packet work)

== 10/12/2014 ==
Akkadius: Fix for LDON Character Stat load

Expand Down
136 changes: 136 additions & 0 deletions common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3169,6 +3169,142 @@ const char* Database::GetRaidLeaderName(uint32 rid)
return name;
}

// maintank, assist, puller, marknpc currently unused
void Database::GetGroupLeadershipInfo(uint32 gid, uint32 rid, char *maintank,
char *assist, char *puller, char *marknpc, GroupLeadershipAA_Struct *GLAA)
{
std::string query = StringFormat(
"SELECT maintank, assist, puller, marknpc, leadershipaa FROM raid_leaders WHERE gid = %lu AND rid = %lu",
(unsigned long)gid, (unsigned long)rid);
auto results = QueryDatabase(query);

if (!results.Success() || results.RowCount() == 0) {
if (maintank)
maintank[0] = '\0';

if (assist)
assist[0] = '\0';

if (puller)
puller[0] = '\0';

if (marknpc)
marknpc[0] = '\0';

return;
}

auto row = results.begin();

if (maintank)
strcpy(maintank, row[0]);

if (assist)
strcpy(assist, row[1]);

if (puller)
strcpy(puller, row[2]);

if (marknpc)
strcpy(marknpc, row[3]);

if (GLAA && results.LengthOfColumn(4) == sizeof(GroupLeadershipAA_Struct))
memcpy(GLAA, row[4], sizeof(GroupLeadershipAA_Struct));

return;
}

// maintank, assist, puller, marknpc currently unused
void Database::GetRaidLeadershipInfo(uint32 rid, char *maintank,
char *assist, char *puller, char *marknpc, RaidLeadershipAA_Struct *RLAA)
{
std::string query = StringFormat(
"SELECT maintank, assist, puller, marknpc, leadershipaa FROM raid_leaders WHERE gid = %lu AND rid = %lu",
(unsigned long)0xFFFFFFFF, (unsigned long)rid);
auto results = QueryDatabase(query);

if (!results.Success() || results.RowCount() == 0) {
if (maintank)
maintank[0] = '\0';

if (assist)
assist[0] = '\0';

if (puller)
puller[0] = '\0';

if (marknpc)
marknpc[0] = '\0';

return;
}

auto row = results.begin();

if (maintank)
strcpy(maintank, row[0]);

if (assist)
strcpy(assist, row[1]);

if (puller)
strcpy(puller, row[2]);

if (marknpc)
strcpy(marknpc, row[3]);

if (RLAA && results.LengthOfColumn(4) == sizeof(RaidLeadershipAA_Struct))
memcpy(RLAA, row[4], sizeof(RaidLeadershipAA_Struct));

return;
}

void Database::SetRaidGroupLeaderInfo(uint32 gid, uint32 rid)
{
std::string query = StringFormat("UPDATE raid_leaders SET leadershipaa = '', WHERE gid = %lu AND rid = %lu",
(unsigned long)gid, (unsigned long)rid);
auto results = QueryDatabase(query);

if (results.RowsAffected() != 0)
return;

query = StringFormat("INSERT INTO raid_leaders(gid, rid, marknpc, leadershipaa, maintank, assist, puller) VALUES(%lu, %lu, '', '', '', '', '')",
(unsigned long)gid, (unsigned long)rid);
results = QueryDatabase(query);

if (!results.Success())
std::cout << "Unable to set raid/group leader: " << results.ErrorMessage() << std::endl;

return;
}

// Clearing all raid leaders
void Database::ClearAllRaidLeaders(void)
{
std::string query("DELETE from raid_leaders");
auto results = QueryDatabase(query);

if (!results.Success())
std::cout << "Unable to clear raid leaders: " << results.ErrorMessage() << std::endl;

return;
}

void Database::ClearRaidLeader(uint32 gid, uint32 rid)
{
if (rid == 0) {
ClearAllRaidLeaders();
return;
}

std::string query = StringFormat("DELETE from raid_leaders where gid = %lu and rid = %lu",
(unsigned long)gid, (unsigned long)rid);
auto results = QueryDatabase(query);

if (!results.Success())
std::cout << "Unable to clear raid leader: " << results.ErrorMessage() << std::endl;
}

bool Database::VerifyInstanceAlive(uint16 instance_id, uint32 char_id)
{
//we are not saved to this instance so set our instance to 0
Expand Down
7 changes: 7 additions & 0 deletions common/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ class Database : public DBcore {
void ClearRaidDetails(uint32 rid = 0);
uint32 GetRaidID(const char* name);
const char *GetRaidLeaderName(uint32 rid);
void GetGroupLeadershipInfo(uint32 gid, uint32 rid, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
GroupLeadershipAA_Struct* GLAA = nullptr);
void GetRaidLeadershipInfo(uint32 rid, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
RaidLeadershipAA_Struct* RLAA = nullptr);
void SetRaidGroupLeaderInfo(uint32 gid, uint32 rid);
void ClearRaidLeader(uint32 gid = 0xFFFFFFFF, uint32 rid = 0);

bool CheckDatabaseConversions();

Expand Down Expand Up @@ -273,6 +279,7 @@ class Database : public DBcore {
*/
void ClearAllRaids();
void ClearAllRaidDetails();
void ClearAllRaidLeaders();
};

#endif
67 changes: 62 additions & 5 deletions common/eq_packet_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,62 @@ struct MovePotionToBelt_Struct {
static const uint32 MAX_GROUP_LEADERSHIP_AA_ARRAY = 16;
static const uint32 MAX_RAID_LEADERSHIP_AA_ARRAY = 16;
static const uint32 MAX_LEADERSHIP_AA_ARRAY = (MAX_GROUP_LEADERSHIP_AA_ARRAY+MAX_RAID_LEADERSHIP_AA_ARRAY);
struct LeadershipAA_Struct {
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
struct GroupLeadershipAA_Struct {
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 groupAAMarkNPC;
uint32 groupAANPCHealth;
uint32 groupAADelegateMainAssist;
uint32 groupAADelegateMarkNPC;
uint32 groupAA4;
uint32 groupAA5;
uint32 groupAAInspectBuffs;
uint32 groupAA7;
uint32 groupAASpellAwareness;
uint32 groupAAOffenseEnhancement;
uint32 groupAAManaEnhancement;
uint32 groupAAHealthEnhancement;
uint32 groupAAHealthRegeneration;
uint32 groupAAFindPathToPC;
uint32 groupAAHealthOfTargetsTarget;
uint32 groupAA15;
};
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
};
};

struct RaidLeadershipAA_Struct {
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 raidAAMarkNPC;
uint32 raidAANPCHealth;
uint32 raidAADelegateMainAssist;
uint32 raidAADelegateMarkNPC;
uint32 raidAA4;
uint32 raidAA5;
uint32 raidAA6;
uint32 raidAASpellAwareness;
uint32 raidAAOffenseEnhancement;
uint32 raidAAManaEnhancement;
uint32 raidAAHealthEnhancement;
uint32 raidAAHealthRegeneration;
uint32 raidAAFindPathToPC;
uint32 raidAAHealthOfTargetsTarget;
uint32 raidAA14;
uint32 raidAA15;
};
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
};
};

struct LeadershipAA_Struct {
union {
struct {
GroupLeadershipAA_Struct group;
RaidLeadershipAA_Struct raid;
};
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
};

/**
Expand Down Expand Up @@ -3934,6 +3982,15 @@ struct RaidMOTD_Struct {
/*136*/ char motd[0]; // max size is 1024, but reply is variable
};

struct RaidLeadershipUpdate_Struct {
/*000*/ uint32 action;
/*004*/ char player_name[64];
/*068*/ char leader_name[64];
/*132*/ GroupLeadershipAA_Struct group; //unneeded
/*196*/ RaidLeadershipAA_Struct raid;
/*260*/ char Unknown260[128]; //unverified
};

struct RaidAdd_Struct {
/*000*/ uint32 action; //=0
/*004*/ char player_name[64]; //should both be the player's name
Expand Down
58 changes: 53 additions & 5 deletions common/patches/client62_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,62 @@ struct PotionBelt_Struct {
static const uint32 MAX_GROUP_LEADERSHIP_AA_ARRAY = 16;
static const uint32 MAX_RAID_LEADERSHIP_AA_ARRAY = 16;
static const uint32 MAX_LEADERSHIP_AA_ARRAY = (MAX_GROUP_LEADERSHIP_AA_ARRAY+MAX_RAID_LEADERSHIP_AA_ARRAY);
struct LeadershipAA_Struct {
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
struct GroupLeadershipAA_Struct {
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 groupAAMarkNPC;
uint32 groupAANPCHealth;
uint32 groupAADelegateMainAssist;
uint32 groupAADelegateMarkNPC;
uint32 groupAA4;
uint32 groupAA5;
uint32 groupAAInspectBuffs;
uint32 groupAA7;
uint32 groupAASpellAwareness;
uint32 groupAAOffenseEnhancement;
uint32 groupAAManaEnhancement;
uint32 groupAAHealthEnhancement;
uint32 groupAAHealthRegeneration;
uint32 groupAAFindPathToPC;
uint32 groupAAHealthOfTargetsTarget;
uint32 groupAA15;
};
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
};
};

struct RaidLeadershipAA_Struct {
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 raidAAMarkNPC;
uint32 raidAANPCHealth;
uint32 raidAADelegateMainAssist;
uint32 raidAADelegateMarkNPC;
uint32 raidAA4;
uint32 raidAA5;
uint32 raidAA6;
uint32 raidAASpellAwareness;
uint32 raidAAOffenseEnhancement;
uint32 raidAAManaEnhancement;
uint32 raidAAHealthEnhancement;
uint32 raidAAHealthRegeneration;
uint32 raidAAFindPathToPC;
uint32 raidAAHealthOfTargetsTarget;
uint32 raidAA14;
uint32 raidAA15;
};
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
};
};

struct LeadershipAA_Struct {
union {
struct {
GroupLeadershipAA_Struct group;
RaidLeadershipAA_Struct raid;
};
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
};

/*
Expand Down
58 changes: 53 additions & 5 deletions common/patches/rof_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,62 @@ struct PotionBelt_Struct {
BandolierItem_Struct items[MAX_POTIONS_IN_BELT];
};

struct LeadershipAA_Struct {
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
struct GroupLeadershipAA_Struct {
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 groupAAMarkNPC;
uint32 groupAANPCHealth;
uint32 groupAADelegateMainAssist;
uint32 groupAADelegateMarkNPC;
uint32 groupAA4;
uint32 groupAA5;
uint32 groupAAInspectBuffs;
uint32 groupAA7;
uint32 groupAASpellAwareness;
uint32 groupAAOffenseEnhancement;
uint32 groupAAManaEnhancement;
uint32 groupAAHealthEnhancement;
uint32 groupAAHealthRegeneration;
uint32 groupAAFindPathToPC;
uint32 groupAAHealthOfTargetsTarget;
uint32 groupAA15;
};
uint32 ranks[MAX_GROUP_LEADERSHIP_AA_ARRAY];
};
};

struct RaidLeadershipAA_Struct {
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
union {
struct {
uint32 raidAAMarkNPC;
uint32 raidAANPCHealth;
uint32 raidAADelegateMainAssist;
uint32 raidAADelegateMarkNPC;
uint32 raidAA4;
uint32 raidAA5;
uint32 raidAA6;
uint32 raidAASpellAwareness;
uint32 raidAAOffenseEnhancement;
uint32 raidAAManaEnhancement;
uint32 raidAAHealthEnhancement;
uint32 raidAAHealthRegeneration;
uint32 raidAAFindPathToPC;
uint32 raidAAHealthOfTargetsTarget;
uint32 raidAA14;
uint32 raidAA15;
};
uint32 ranks[MAX_RAID_LEADERSHIP_AA_ARRAY];
};
};

struct LeadershipAA_Struct {
union {
struct {
GroupLeadershipAA_Struct group;
RaidLeadershipAA_Struct raid;
};
uint32 ranks[MAX_LEADERSHIP_AA_ARRAY];
};
};

/**
Expand Down

0 comments on commit be0621d

Please sign in to comment.