mirror of
https://bitbucket.org/theswgsource/src-1.2.git
synced 2026-10-19 09:02:53 -04:00
Added serverGame library
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildInfo.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/GuildInfo.h"
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
void get(ReadIterator & source, GuildInfo & target)
|
||||
{
|
||||
get(source, target.m_name);
|
||||
get(source, target.m_abbrev);
|
||||
get(source, target.m_leaderId);
|
||||
get(source, target.m_guildElectionPreviousEndTime);
|
||||
get(source, target.m_guildElectionNextEndTime);
|
||||
get(source, target.m_guildFaction);
|
||||
get(source, target.m_timeLeftGuildFaction);
|
||||
get(source, target.m_guildGcwDefenderRegion);
|
||||
get(source, target.m_timeJoinedGuildGcwDefenderRegion);
|
||||
get(source, target.m_timeLeftGuildGcwDefenderRegion);
|
||||
get(source, target.m_sponsoredCount);
|
||||
get(source, target.m_sponsoredAndMemberCount);
|
||||
get(source, target.m_guildWarInclusionCount);
|
||||
get(source, target.m_guildWarExclusionCount);
|
||||
}
|
||||
|
||||
void put(ByteStream & target, const GuildInfo & source)
|
||||
{
|
||||
put(target, source.m_name);
|
||||
put(target, source.m_abbrev);
|
||||
put(target, source.m_leaderId);
|
||||
put(target, source.m_guildElectionPreviousEndTime);
|
||||
put(target, source.m_guildElectionNextEndTime);
|
||||
put(target, source.m_guildFaction);
|
||||
put(target, source.m_timeLeftGuildFaction);
|
||||
put(target, source.m_guildGcwDefenderRegion);
|
||||
put(target, source.m_timeJoinedGuildGcwDefenderRegion);
|
||||
put(target, source.m_timeLeftGuildGcwDefenderRegion);
|
||||
put(target, source.m_sponsoredCount);
|
||||
put(target, source.m_sponsoredAndMemberCount);
|
||||
put(target, source.m_guildWarInclusionCount);
|
||||
put(target, source.m_guildWarExclusionCount);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GuildInfo::GuildInfo() :
|
||||
m_name(),
|
||||
m_abbrev(),
|
||||
m_leaderId(),
|
||||
m_guildElectionPreviousEndTime(0),
|
||||
m_guildElectionNextEndTime(0),
|
||||
m_guildFaction(0),
|
||||
m_timeLeftGuildFaction(0),
|
||||
m_guildGcwDefenderRegion(),
|
||||
m_timeJoinedGuildGcwDefenderRegion(0),
|
||||
m_timeLeftGuildGcwDefenderRegion(0),
|
||||
m_sponsoredCount(0),
|
||||
m_sponsoredAndMemberCount(0),
|
||||
m_guildWarInclusionCount(0),
|
||||
m_guildWarExclusionCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GuildInfo::GuildInfo(GuildInfo const * const gi) :
|
||||
m_name(),
|
||||
m_abbrev(),
|
||||
m_leaderId(),
|
||||
m_guildElectionPreviousEndTime(0),
|
||||
m_guildElectionNextEndTime(0),
|
||||
m_guildFaction(0),
|
||||
m_timeLeftGuildFaction(0),
|
||||
m_guildGcwDefenderRegion(),
|
||||
m_timeJoinedGuildGcwDefenderRegion(0),
|
||||
m_timeLeftGuildGcwDefenderRegion(0),
|
||||
m_sponsoredCount(0),
|
||||
m_sponsoredAndMemberCount(0),
|
||||
m_guildWarInclusionCount(0),
|
||||
m_guildWarExclusionCount(0)
|
||||
{
|
||||
if (gi)
|
||||
{
|
||||
m_name = gi->m_name;
|
||||
m_abbrev = gi->m_abbrev;
|
||||
m_leaderId = gi->m_leaderId;
|
||||
m_guildElectionPreviousEndTime = gi->m_guildElectionPreviousEndTime;
|
||||
m_guildElectionNextEndTime = gi->m_guildElectionNextEndTime;
|
||||
m_guildFaction = gi->m_guildFaction;
|
||||
m_timeLeftGuildFaction = gi->m_timeLeftGuildFaction;
|
||||
m_guildGcwDefenderRegion = gi->m_guildGcwDefenderRegion;
|
||||
m_timeJoinedGuildGcwDefenderRegion = gi->m_timeJoinedGuildGcwDefenderRegion;
|
||||
m_timeLeftGuildGcwDefenderRegion = gi->m_timeLeftGuildGcwDefenderRegion;
|
||||
m_sponsoredCount = gi->m_sponsoredCount;
|
||||
m_sponsoredAndMemberCount = gi->m_sponsoredAndMemberCount;
|
||||
m_guildWarInclusionCount = gi->m_guildWarInclusionCount;
|
||||
m_guildWarExclusionCount = gi->m_guildWarExclusionCount;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GuildInfo::~GuildInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildInfo::operator== (const GuildInfo& rhs) const
|
||||
{
|
||||
if (this == &rhs)
|
||||
return true;
|
||||
|
||||
return ((m_name == rhs.m_name) &&
|
||||
(m_abbrev == rhs.m_abbrev) &&
|
||||
(m_leaderId == rhs.m_leaderId) &&
|
||||
(m_guildElectionPreviousEndTime == rhs.m_guildElectionPreviousEndTime) &&
|
||||
(m_guildElectionNextEndTime == rhs.m_guildElectionNextEndTime) &&
|
||||
(m_guildFaction == rhs.m_guildFaction) &&
|
||||
(m_timeLeftGuildFaction == rhs.m_timeLeftGuildFaction) &&
|
||||
(m_guildGcwDefenderRegion == rhs.m_guildGcwDefenderRegion) &&
|
||||
(m_timeJoinedGuildGcwDefenderRegion == rhs.m_timeJoinedGuildGcwDefenderRegion) &&
|
||||
(m_timeLeftGuildGcwDefenderRegion == rhs.m_timeLeftGuildGcwDefenderRegion) &&
|
||||
(m_sponsoredCount == rhs.m_sponsoredCount) &&
|
||||
(m_sponsoredAndMemberCount == rhs.m_sponsoredAndMemberCount) &&
|
||||
(m_guildWarInclusionCount == rhs.m_guildWarInclusionCount) &&
|
||||
(m_guildWarExclusionCount == rhs.m_guildWarExclusionCount));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildInfo::operator!= (const GuildInfo& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int GuildInfo::getCountMembersOnly() const
|
||||
{
|
||||
return std::max(0, (m_sponsoredAndMemberCount - m_sponsoredCount));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int GuildInfo::getCountSponsoredOnly() const
|
||||
{
|
||||
return m_sponsoredCount;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int GuildInfo::getCountMembersAndSponsored() const
|
||||
{
|
||||
return m_sponsoredAndMemberCount;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
int GuildInfo::getCountMembersGuildWarPvPEnabled() const
|
||||
{
|
||||
if (m_guildWarInclusionCount)
|
||||
return m_guildWarInclusionCount;
|
||||
|
||||
return std::max(0, (m_sponsoredAndMemberCount - m_sponsoredCount - m_guildWarExclusionCount));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,62 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildInfo.h
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _GuildInfo_H_
|
||||
#define _GuildInfo_H_
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class GuildInfo
|
||||
{
|
||||
public:
|
||||
GuildInfo();
|
||||
GuildInfo(GuildInfo const * gi);
|
||||
~GuildInfo();
|
||||
|
||||
bool operator== (const GuildInfo& rhs) const;
|
||||
bool operator!= (const GuildInfo& rhs) const;
|
||||
|
||||
int getCountMembersOnly() const;
|
||||
int getCountSponsoredOnly() const;
|
||||
int getCountMembersAndSponsored() const;
|
||||
int getCountMembersGuildWarPvPEnabled() const;
|
||||
|
||||
std::string m_name;
|
||||
std::string m_abbrev;
|
||||
NetworkId m_leaderId;
|
||||
int m_guildElectionPreviousEndTime;
|
||||
int m_guildElectionNextEndTime;
|
||||
uint32 m_guildFaction;
|
||||
int m_timeLeftGuildFaction;
|
||||
std::string m_guildGcwDefenderRegion;
|
||||
int m_timeJoinedGuildGcwDefenderRegion;
|
||||
int m_timeLeftGuildGcwDefenderRegion;
|
||||
|
||||
int m_sponsoredCount;
|
||||
int m_sponsoredAndMemberCount;
|
||||
int m_guildWarInclusionCount;
|
||||
int m_guildWarExclusionCount;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
class ReadIterator;
|
||||
class ByteStream;
|
||||
|
||||
void get(ReadIterator & source, GuildInfo & target);
|
||||
void put(ByteStream & target, const GuildInfo & source);
|
||||
}
|
||||
// ======================================================================
|
||||
|
||||
#endif // _GuildInfo_H_
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,166 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildInterface.h
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _GuildInterface_H_
|
||||
#define _GuildInterface_H_
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class CreatureObject;
|
||||
class GuildInfo;
|
||||
class GuildMemberInfo;
|
||||
class GuildObject;
|
||||
class NetworkId;
|
||||
class ScriptParams;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class GuildInterface // static
|
||||
{
|
||||
public:
|
||||
// Note: These should never be moved, and should be in sync with what is in
|
||||
// guild.scriptlib and ConsoleCommandParserGuild.cpp::getGuildPermissionsText()
|
||||
enum GuildPermissions
|
||||
{
|
||||
None = 0, // sponsored
|
||||
|
||||
// administrative permissions
|
||||
Member = (1<<0),
|
||||
Sponsor = (1<<1),
|
||||
Disband = (1<<2),
|
||||
Accept = (1<<3),
|
||||
Kick = (1<<4),
|
||||
Mail = (1<<5),
|
||||
Title = (1<<6),
|
||||
Namechange = (1<<7),
|
||||
War = (1<<8),
|
||||
Rank = (1<<9),
|
||||
|
||||
// if you need to add a new administrative guild permission,
|
||||
// use one of the following reserved administrative guild
|
||||
// permissions, which has been reserved for that specific purpose
|
||||
AdministrativeReserved1 = (1<<10),
|
||||
AdministrativeReserved2 = (1<<11),
|
||||
AdministrativeReserved3 = (1<<12),
|
||||
AdministrativeReserved4 = (1<<13),
|
||||
AdministrativeReserved5 = (1<<14),
|
||||
AdministrativeReserved6 = (1<<15),
|
||||
AdministrativeReserved7 = (1<<16),
|
||||
AdministrativeReserved8 = (1<<17),
|
||||
AdministrativeReserved9 = (1<<18),
|
||||
AdministrativeReserved10 = (1<<19),
|
||||
|
||||
AllAdministrativePermissions = (Member | Sponsor | Disband | Accept | Kick | Mail | Title | Namechange | War | Rank | AdministrativeReserved1 | AdministrativeReserved2 | AdministrativeReserved3 | AdministrativeReserved4 | AdministrativeReserved5 | AdministrativeReserved6 | AdministrativeReserved7 | AdministrativeReserved8 | AdministrativeReserved9 | AdministrativeReserved10),
|
||||
|
||||
// non-administrative permissions
|
||||
ElectionCandidate = (1<<20), // guild member is running in the current guild election
|
||||
WarInclusion = (1<<21), // guild member is in the guild war inclusion list
|
||||
WarExclusion = (1<<22) // guild member is in the guild war exclusion list
|
||||
};
|
||||
|
||||
static void update();
|
||||
static void touchEnemies();
|
||||
|
||||
static int getGuildId(NetworkId const &memberId);
|
||||
static int getGuildIdForSponsored(NetworkId const &memberId);
|
||||
static int getGuildIdForGuildLeader(NetworkId const &leaderId);
|
||||
static void getAllGuildIds(stdvector<int>::fwd &results);
|
||||
static int findGuild(std::string const &name);
|
||||
static bool guildExists(int guildId);
|
||||
static std::pair<int, time_t> const *hasDeclaredWarAgainst(int actorGuildId, int targetGuildId);
|
||||
static GuildInfo const *getGuildInfo(int guildId);
|
||||
static std::string const &getGuildName(int guildId);
|
||||
static std::string const &getGuildAbbrev(int guildId);
|
||||
static NetworkId const &getGuildLeaderId(int guildId);
|
||||
static int getGuildElectionPreviousEndTime(int guildId);
|
||||
static int getGuildElectionNextEndTime(int guildId);
|
||||
static uint32 getGuildCurrentFaction(int guildId);
|
||||
static uint32 getGuildCurrentFaction(GuildInfo const & gi);
|
||||
static uint32 getGuildPreviousFaction(int guildId);
|
||||
static uint32 getGuildPreviousFaction(GuildInfo const & gi);
|
||||
static int getTimeLeftGuildPreviousFaction(int guildId);
|
||||
static int getTimeLeftGuildPreviousFaction(GuildInfo const & gi);
|
||||
static std::string const &getGuildCurrentGcwDefenderRegion(int guildId);
|
||||
static std::string const &getGuildCurrentGcwDefenderRegion(GuildInfo const & gi);
|
||||
static int getTimeJoinedGuildCurrentGcwDefenderRegion(int guildId);
|
||||
static int getTimeJoinedGuildCurrentGcwDefenderRegion(GuildInfo const & gi);
|
||||
static std::string const &getGuildPreviousGcwDefenderRegion(int guildId);
|
||||
static std::string const &getGuildPreviousGcwDefenderRegion(GuildInfo const & gi);
|
||||
static int getTimeLeftGuildPreviousGcwDefenderRegion(int guildId);
|
||||
static int getTimeLeftGuildPreviousGcwDefenderRegion(GuildInfo const & gi);
|
||||
static std::map<std::pair<std::string, int>, uint32> const & getGcwRegionDefenderGuilds();
|
||||
static std::map<std::string, std::pair<int, int> > const & getGcwRegionDefenderGuildsCount();
|
||||
static int getGcwRegionDefenderGuildsVersion();
|
||||
static void getGuildMemberIds(int guildId, stdvector<NetworkId>::fwd &results);
|
||||
static void getGuildMemberIdsWithPermissions(int guildId, int permissions, stdvector<NetworkId>::fwd &results);
|
||||
static int getGuildCountMembersOnly(int guildId);
|
||||
static int getGuildCountSponsoredOnly(int guildId);
|
||||
static int getGuildCountMembersAndSponsored(int guildId);
|
||||
static int getGuildCountMembersGuildWarPvPEnabled(int guildId);
|
||||
static GuildMemberInfo const *getGuildMemberInfo(int guildId, NetworkId const &memberId);
|
||||
static bool getGuildMemberGuildWarEnabled(int guildId, NetworkId const &memberId);
|
||||
static stdvector<int>::fwd const &getGuildEnemies(int guildId);
|
||||
static stdmap<int, std::pair<int, time_t> >::fwd const &getGuildEnemiesKillInfo(int guildId);
|
||||
static std::pair<int, time_t> const &getGuildEnemyKillInfo(int guildIdA, int guildIdB);
|
||||
static stdvector<int>::fwd const &getGuildsAtWarWith(int guildId);
|
||||
static ScriptParams const *getMasterGuildWarTableDictionary();
|
||||
static void updateInactiveGuildWarTrackingInfo(GuildObject &masterGuildObject, int guildAId, int guildAKillCount, int guildBId, int guildBKillCount);
|
||||
static ScriptParams const *getInactiveGuildWarTableDictionary();
|
||||
|
||||
static bool isValidGuildName(std::string const &guildName);
|
||||
static bool isValidGuildAbbrev(std::string const &guildAbbrev);
|
||||
static int createGuild(std::string const &guildName, std::string const &guildAbbrev);
|
||||
static void disbandGuild(int guildId);
|
||||
static void removeGuildMember(int guildId, NetworkId const &memberId);
|
||||
static void setGuildLeader(int guildId, NetworkId const &leaderId);
|
||||
static void setGuildElectionEndTime(int guildId, int electionPreviousEndTime, int electionNextEndTime);
|
||||
static void setGuildFaction(int guildId, uint32 guildFaction);
|
||||
static void setGuildGcwDefenderRegion(int guildId, std::string const &guildGcwDefenderRegion);
|
||||
static void addGuildCreatorMember(int guildId, NetworkId const &memberId);
|
||||
static void addGuildSponsorMember(int guildId, NetworkId const &memberId);
|
||||
static void setGuildMemberPermission(int guildId, NetworkId const &memberId, int permissions);
|
||||
static void setGuildMemberTitle(int guildId, NetworkId const &memberId, std::string const &title);
|
||||
static void setGuildMemberAllegiance(int guildId, NetworkId const &memberId, NetworkId const &allegiance);
|
||||
static void setGuildMemberPermissionAndAllegiance(int guildId, NetworkId const &memberId, int permissions, NetworkId const &allegiance);
|
||||
static void setGuildMemberProfessionInfo(int guildId, NetworkId const &memberId, std::string const &memberProfessionSkillTemplate, int memberLevel);
|
||||
static void addGuildMemberRank(int guildId, NetworkId const &memberId, std::string const &rankName);
|
||||
static void removeGuildMemberRank(int guildId, NetworkId const &memberId, std::string const &rankName);
|
||||
static bool hasGuildMemberRank(int guildId, NetworkId const &memberId, std::string const &rankName);
|
||||
static void getGuildMemberRank(int guildId, NetworkId const &memberId, stdvector<std::string>::fwd &ranks);
|
||||
static void setGuildEnemy(int guildId, int enemyId);
|
||||
static void removeGuildEnemy(int guildId, int enemyId);
|
||||
static void updateGuildWarKillTracking(CreatureObject const &killer, CreatureObject const &victim);
|
||||
static void setGuildName(int guildId, std::string const &newName);
|
||||
static void setGuildAbbrev(int guildId, std::string const &newAbbrev);
|
||||
|
||||
static void onGuildIdSet(CreatureObject const &who);
|
||||
static void onAboutToClearGuildId(CreatureObject const &who);
|
||||
static void verifyGuildMemberName(NetworkId const &memberId, std::string const &memberName);
|
||||
|
||||
static void enterGuildChatRoom(CreatureObject const &who);
|
||||
static void reenterGuildChatRoom(CreatureObject const &who);
|
||||
static void leaveGuildChatRoom(CreatureObject const &who);
|
||||
static void sendGuildChat(CreatureObject const &who, Unicode::String const &text);
|
||||
static void onChatRoomCreate(std::string const &path);
|
||||
static void createAllGuildChatRooms();
|
||||
static std::pair<int, std::pair<std::string, std::string> > mailToGuild(CreatureObject const &who, Unicode::String const &subject, Unicode::String const &message, Unicode::String const &oob);
|
||||
static std::pair<int, std::pair<std::string, std::string> > mailToGuild(int guildId, Unicode::String const &subject, Unicode::String const &message, Unicode::String const &oob);
|
||||
static std::pair<int, std::pair<std::string, std::string> > mailToGuildRank(CreatureObject const &who, int guildRankSlotId, Unicode::String const &subject, Unicode::String const &message, Unicode::String const &oob);
|
||||
|
||||
static void onVoiceChatRoomCreate(std::string const &path);
|
||||
static void enterGuildVoiceChatRoom(CreatureObject const &who);
|
||||
static void leaveGuildVoiceChatRoom(NetworkId const & netID, std::string const & firstName, int guildID);
|
||||
|
||||
private:
|
||||
static void buildEnemies(GuildObject const &guildObject);
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _GuildInterface_H_
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildMemberInfo.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/GuildMemberInfo.h"
|
||||
|
||||
#include "Archive/Archive.h"
|
||||
#include "sharedFoundation/NetworkIdArchive.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
void get(ReadIterator & source, GuildMemberInfo & target)
|
||||
{
|
||||
get(source, target.m_name);
|
||||
get(source, target.m_professionSkillTemplate);
|
||||
get(source, target.m_level);
|
||||
get(source, target.m_permissions);
|
||||
get(source, target.m_rank);
|
||||
get(source, target.m_title);
|
||||
get(source, target.m_allegiance);
|
||||
}
|
||||
|
||||
void put(ByteStream & target, const GuildMemberInfo & source)
|
||||
{
|
||||
put(target, source.m_name);
|
||||
put(target, source.m_professionSkillTemplate);
|
||||
put(target, source.m_level);
|
||||
put(target, source.m_permissions);
|
||||
put(target, source.m_rank);
|
||||
put(target, source.m_title);
|
||||
put(target, source.m_allegiance);
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
GuildMemberInfo::GuildMemberInfo() :
|
||||
m_name(),
|
||||
m_professionSkillTemplate(),
|
||||
m_level(0),
|
||||
m_permissions(0),
|
||||
m_rank(),
|
||||
m_title(),
|
||||
m_allegiance()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GuildMemberInfo::GuildMemberInfo(GuildMemberInfo const * const gmi) :
|
||||
m_name(),
|
||||
m_professionSkillTemplate(),
|
||||
m_level(0),
|
||||
m_permissions(0),
|
||||
m_rank(),
|
||||
m_title(),
|
||||
m_allegiance()
|
||||
{
|
||||
if (gmi)
|
||||
{
|
||||
m_name = gmi->m_name;
|
||||
m_professionSkillTemplate = gmi->m_professionSkillTemplate;
|
||||
m_level = gmi->m_level;
|
||||
m_permissions = gmi->m_permissions;
|
||||
m_rank = gmi->m_rank;
|
||||
m_title = gmi->m_title;
|
||||
m_allegiance = gmi->m_allegiance;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
GuildMemberInfo::~GuildMemberInfo()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildMemberInfo::operator== (const GuildMemberInfo& rhs) const
|
||||
{
|
||||
if (this == &rhs)
|
||||
return true;
|
||||
|
||||
return ((m_name == rhs.m_name) &&
|
||||
(m_professionSkillTemplate == rhs.m_professionSkillTemplate) &&
|
||||
(m_level == rhs.m_level) &&
|
||||
(m_permissions == rhs.m_permissions) &&
|
||||
(m_rank == rhs.m_rank) &&
|
||||
(m_title == rhs.m_title) &&
|
||||
(m_allegiance == rhs.m_allegiance));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildMemberInfo::operator!= (const GuildMemberInfo& rhs) const
|
||||
{
|
||||
return !operator==(rhs);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
@@ -0,0 +1,51 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildMemberInfo.h
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _GuildMemberInfo_H_
|
||||
#define _GuildMemberInfo_H_
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#include "sharedFoundation/BitArray.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class GuildMemberInfo
|
||||
{
|
||||
public:
|
||||
GuildMemberInfo();
|
||||
GuildMemberInfo(GuildMemberInfo const * gmi);
|
||||
~GuildMemberInfo();
|
||||
|
||||
bool operator== (const GuildMemberInfo& rhs) const;
|
||||
bool operator!= (const GuildMemberInfo& rhs) const;
|
||||
|
||||
std::string m_name;
|
||||
std::string m_professionSkillTemplate;
|
||||
int m_level;
|
||||
int m_permissions;
|
||||
BitArray m_rank;
|
||||
std::string m_title;
|
||||
NetworkId m_allegiance;
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
namespace Archive
|
||||
{
|
||||
class ReadIterator;
|
||||
class ByteStream;
|
||||
|
||||
void get(ReadIterator & source, GuildMemberInfo & target);
|
||||
void put(ByteStream & target, const GuildMemberInfo & source);
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _GuildMemberInfo_H_
|
||||
@@ -0,0 +1,322 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildStringParser.cpp
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#include "serverGame/FirstServerGame.h"
|
||||
#include "serverGame/GuildStringParser.h"
|
||||
|
||||
#include "sharedFoundation/BitArray.h"
|
||||
#include "sharedFoundation/NetworkId.h"
|
||||
#include "sharedGame/PvpData.h"
|
||||
|
||||
// ======================================================================
|
||||
|
||||
static void skipField(std::string const &source, unsigned int &pos)
|
||||
{
|
||||
while (source[pos] && source[pos] != ':')
|
||||
++pos;
|
||||
if (source[pos] == ':')
|
||||
++pos;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static void nextInt(std::string const &source, unsigned int &pos, int &ret)
|
||||
{
|
||||
ret = atoi(source.c_str()+pos);
|
||||
skipField(source, pos);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static void nextString(std::string const &source, unsigned int &pos, std::string &ret)
|
||||
{
|
||||
unsigned int oldPos = pos;
|
||||
while (source[pos] && source[pos] != ':')
|
||||
++pos;
|
||||
ret = source.substr(oldPos, pos-oldPos);
|
||||
if (source[pos] == ':')
|
||||
++pos;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
static void nextOid(std::string const &source, unsigned int &pos, NetworkId &ret)
|
||||
{
|
||||
unsigned int oldPos = pos;
|
||||
skipField(source, pos);
|
||||
ret = NetworkId(source.substr(oldPos, pos-oldPos));
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
bool GuildStringParser::parseGuildName(std::string const &source, int &guildId, std::string &guildName, int &guildElectionPreviousEndTime, int &guildElectionNextEndTime, uint32 &guildFaction, int &timeLeftGuildFaction, std::string &guildGcwDefenderRegion, int &timeJoinedGuildGcwDefenderRegion, int &timeLeftGuildGcwDefenderRegion)
|
||||
{
|
||||
// need to parse different versions
|
||||
if (source.find("v3:") == 0) // version 3
|
||||
{
|
||||
unsigned int pos = 3;
|
||||
nextInt(source, pos, guildId);
|
||||
nextString(source, pos, guildName);
|
||||
nextInt(source, pos, guildElectionPreviousEndTime);
|
||||
nextInt(source, pos, guildElectionNextEndTime);
|
||||
|
||||
int temp;
|
||||
nextInt(source, pos, temp);
|
||||
guildFaction = static_cast<uint32>(temp);
|
||||
|
||||
nextInt(source, pos, timeLeftGuildFaction);
|
||||
nextString(source, pos, guildGcwDefenderRegion);
|
||||
nextInt(source, pos, timeJoinedGuildGcwDefenderRegion);
|
||||
nextInt(source, pos, timeLeftGuildGcwDefenderRegion);
|
||||
}
|
||||
else if (source.find("v2:") == 0) // version 2
|
||||
{
|
||||
unsigned int pos = 3;
|
||||
nextInt(source, pos, guildId);
|
||||
nextString(source, pos, guildName);
|
||||
nextInt(source, pos, guildElectionPreviousEndTime);
|
||||
nextInt(source, pos, guildElectionNextEndTime);
|
||||
guildFaction = 0;
|
||||
timeLeftGuildFaction = 0;
|
||||
guildGcwDefenderRegion.clear();
|
||||
timeJoinedGuildGcwDefenderRegion = 0;
|
||||
timeLeftGuildGcwDefenderRegion = 0;
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
nextInt(source, pos, guildId);
|
||||
nextString(source, pos, guildName);
|
||||
guildElectionPreviousEndTime = 0;
|
||||
guildElectionNextEndTime = 0;
|
||||
guildFaction = 0;
|
||||
timeLeftGuildFaction = 0;
|
||||
guildGcwDefenderRegion.clear();
|
||||
timeJoinedGuildGcwDefenderRegion = 0;
|
||||
timeLeftGuildGcwDefenderRegion = 0;
|
||||
}
|
||||
|
||||
bool const ok = guildId && !guildName.empty();
|
||||
WARNING(!ok, ("GuildStringParser::parseGuildName: bad string [%s]", source.c_str()));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildStringParser::parseGuildAbbrev(std::string const &source, int &guildId, std::string &guildAbbrev)
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
nextInt(source, pos, guildId);
|
||||
nextString(source, pos, guildAbbrev);
|
||||
bool ok = guildId && !guildAbbrev.empty();
|
||||
WARNING(!ok, ("GuildStringParser::parseGuildAbbrev: bad string [%s]", source.c_str()));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildStringParser::parseGuildLeader(std::string const &source, int &guildId, NetworkId &leaderId)
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
nextInt(source, pos, guildId);
|
||||
nextOid(source, pos, leaderId);
|
||||
bool ok = guildId && leaderId != NetworkId::cms_invalid;
|
||||
WARNING(!ok, ("GuildStringParser::parseGuildAbbrev: bad string [%s]", source.c_str()));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildStringParser::parseMemberInfo(std::string const &source, int &guildId, NetworkId &memberId, std::string &memberName, std::string &memberProfessionSkillTemplate, int &memberLevel, int &permissions, BitArray &rank, std::string &title, NetworkId &allegiance)
|
||||
{
|
||||
// need to parse different versions
|
||||
if (source.find("v2:") == 0) // version 2
|
||||
{
|
||||
unsigned int pos = 3;
|
||||
nextInt(source, pos, guildId);
|
||||
nextOid(source, pos, memberId);
|
||||
nextString(source, pos, memberName);
|
||||
nextString(source, pos, memberProfessionSkillTemplate);
|
||||
nextInt(source, pos, memberLevel);
|
||||
nextInt(source, pos, permissions);
|
||||
nextString(source, pos, title);
|
||||
nextOid(source, pos, allegiance);
|
||||
|
||||
std::string rankStr;
|
||||
nextString(source, pos, rankStr);
|
||||
rank.setFromDbTextString(rankStr.c_str());
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
nextInt(source, pos, guildId);
|
||||
nextOid(source, pos, memberId);
|
||||
nextString(source, pos, memberName);
|
||||
memberProfessionSkillTemplate.clear();
|
||||
memberLevel = 0;
|
||||
nextInt(source, pos, permissions);
|
||||
nextString(source, pos, title);
|
||||
nextOid(source, pos, allegiance);
|
||||
rank.clear();
|
||||
}
|
||||
|
||||
bool const ok = guildId && memberId != NetworkId::cms_invalid && !memberName.empty();
|
||||
WARNING(!ok, ("GuildStringParser::parseMemberInfo: bad string [%s]", source.c_str()));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
bool GuildStringParser::parseEnemyInfo(std::string const &source, int &guildId, int &enemyId, int &killCount, int &lastUpdateTime)
|
||||
{
|
||||
// need to parse different versions
|
||||
if (source.find("v2:") == 0) // version 2
|
||||
{
|
||||
unsigned int pos = 3;
|
||||
nextInt(source, pos, guildId);
|
||||
nextInt(source, pos, enemyId);
|
||||
nextInt(source, pos, killCount);
|
||||
nextInt(source, pos, lastUpdateTime);
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
unsigned int pos = 0;
|
||||
nextInt(source, pos, guildId);
|
||||
nextInt(source, pos, enemyId);
|
||||
killCount = 0;
|
||||
lastUpdateTime = 0;
|
||||
}
|
||||
|
||||
bool const ok = guildId && enemyId;
|
||||
WARNING(!ok, ("GuildStringParser::parseEnemyInfo: bad string [%s]", source.c_str()));
|
||||
return ok;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GuildStringParser::buildNameSpec(int guildId, std::string const &guildName, int guildElectionPreviousEndTime, int guildElectionNextEndTime, uint32 guildFaction, int timeLeftGuildFaction, std::string const & guildGcwDefenderRegion, int timeJoinedGuildGcwDefenderRegion, int timeLeftGuildGcwDefenderRegion, std::string &result)
|
||||
{
|
||||
FATAL(guildName.length() > 25, ("GuildStringParser::buildNameSpec: bad guild name"));
|
||||
|
||||
// DB column to store information is VARCHAR2(500)
|
||||
char buffer[501]; // 500 chars + terminating \0
|
||||
|
||||
// only write out newer version if there is actually new version information
|
||||
if (!PvpData::isNeutralFactionId(guildFaction) || (timeLeftGuildFaction > 0) || (timeJoinedGuildGcwDefenderRegion > 0) || (timeLeftGuildGcwDefenderRegion > 0)) // version 3
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "v3:%d:%s:%d:%d:%d:%d:%s:%d:%d", guildId, guildName.c_str(), guildElectionPreviousEndTime, guildElectionNextEndTime, static_cast<int>(guildFaction), timeLeftGuildFaction, guildGcwDefenderRegion.c_str(), timeJoinedGuildGcwDefenderRegion, timeLeftGuildGcwDefenderRegion);
|
||||
}
|
||||
else if ((guildElectionPreviousEndTime > 0) || (guildElectionNextEndTime > 0)) // version 2
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "v2:%d:%s:%d:%d", guildId, guildName.c_str(), guildElectionPreviousEndTime, guildElectionNextEndTime);
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%d:%s", guildId, guildName.c_str());
|
||||
}
|
||||
|
||||
// absolutely, positively make sure that there is no more than 500
|
||||
// characters in buffer (not including the terminating \0) or the DB
|
||||
// will ***CRASH*** because the column is defined as VARCHAR2(500)
|
||||
buffer[500] = '\0';
|
||||
result = buffer;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GuildStringParser::buildAbbrevSpec(int guildId, std::string const &guildAbbrev, std::string &result)
|
||||
{
|
||||
FATAL(guildAbbrev.length() > 5, ("GuildStringParser::buildAbbrevSpec: bad guild abbrev"));
|
||||
char buffer[32];
|
||||
// max field lengths - 11:5 -> 16
|
||||
snprintf(buffer, sizeof(buffer)-1, "%d:%s", guildId, guildAbbrev.c_str());
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
result = buffer;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GuildStringParser::buildLeaderSpec(int guildId, NetworkId const &leaderId, std::string &result)
|
||||
{
|
||||
char buffer[64];
|
||||
// max field lengths - 11:21 -> 33
|
||||
snprintf(buffer, sizeof(buffer)-1, "%d:%s", guildId, leaderId.getValueString().c_str());
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
result = buffer;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GuildStringParser::buildMemberSpec(int const guildId, NetworkId const &memberId, std::string const &memberName, std::string const &memberProfessionSkillTemplate, int const memberLevel, int const permissions, BitArray const &rank, std::string const &title, NetworkId const &allegiance, std::string &result)
|
||||
{
|
||||
FATAL(title.length() > 25, ("GuildStringParser::buildMemberSpec: bad title"));
|
||||
|
||||
std::string rankStr;
|
||||
rank.getAsDbTextString(rankStr);
|
||||
|
||||
// DB column to store information is VARCHAR2(500)
|
||||
char buffer[501]; // 500 chars + terminating \0
|
||||
|
||||
// only write out newer version if there is actually new version information
|
||||
if ((memberLevel > 0) || !rankStr.empty() || !memberProfessionSkillTemplate.empty()) // version 2
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "v2:%d:%s:%s:%s:%d:%d:%s:%s:%s",
|
||||
guildId,
|
||||
memberId.getValueString().c_str(),
|
||||
memberName.c_str(),
|
||||
memberProfessionSkillTemplate.c_str(),
|
||||
memberLevel,
|
||||
permissions,
|
||||
title.c_str(),
|
||||
allegiance.getValueString().c_str(),
|
||||
rankStr.c_str());
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%d:%s:%s:%d:%s:%s",
|
||||
guildId,
|
||||
memberId.getValueString().c_str(),
|
||||
memberName.c_str(),
|
||||
permissions,
|
||||
title.c_str(),
|
||||
allegiance.getValueString().c_str());
|
||||
}
|
||||
|
||||
// absolutely, positively make sure that there is no more than 500
|
||||
// characters in buffer (not including the terminating \0) or the DB
|
||||
// will ***CRASH*** because the column is defined as VARCHAR2(500)
|
||||
buffer[500] = '\0';
|
||||
result = buffer;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void GuildStringParser::buildEnemySpec(int guildId, int enemyId, int killCount, int lastUpdateTime, std::string &result)
|
||||
{
|
||||
// DB column to store information is VARCHAR2(500)
|
||||
char buffer[501]; // 500 chars + terminating \0
|
||||
|
||||
// only write out newer version if there is actually new version information
|
||||
if (killCount > 0) // version 2
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "v2:%d:%d:%d:%d", guildId, enemyId, killCount, lastUpdateTime);
|
||||
}
|
||||
else // version 1
|
||||
{
|
||||
snprintf(buffer, sizeof(buffer), "%d:%d", guildId, enemyId);
|
||||
}
|
||||
|
||||
// absolutely, positively make sure that there is no more than 500
|
||||
// characters in buffer (not including the terminating \0) or the DB
|
||||
// will ***CRASH*** because the column is defined as VARCHAR2(500)
|
||||
buffer[500] = '\0';
|
||||
result = buffer;
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// ======================================================================
|
||||
//
|
||||
// GuildStringParser.h
|
||||
//
|
||||
// Copyright 2002 Sony Online Entertainment
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef _GuildStringParser_H_
|
||||
#define _GuildStringParser_H_
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class BitArray;
|
||||
class NetworkId;
|
||||
|
||||
// ======================================================================
|
||||
|
||||
class GuildStringParser // static
|
||||
{
|
||||
public:
|
||||
static bool parseGuildName (std::string const &source, int &guildId, std::string &guildName, int &guildElectionPreviousEndTime, int &guildElectionNextEndTime, uint32 &guildFaction, int &timeLeftGuildFaction, std::string &guildGcwDefenderRegion, int &timeJoinedGuildGcwDefenderRegion, int &timeLeftGuildGcwDefenderRegion);
|
||||
static bool parseGuildAbbrev (std::string const &source, int &guildId, std::string &guildAbbrev);
|
||||
static bool parseGuildLeader (std::string const &source, int &guildId, NetworkId &leaderId);
|
||||
static bool parseMemberInfo (std::string const &source, int &guildId, NetworkId &memberId, std::string &memberName, std::string &memberProfessionSkillTemplate, int &memberLevel, int &permissions, BitArray &rank, std::string &title, NetworkId &allegiance);
|
||||
static bool parseEnemyInfo (std::string const &source, int &guildId, int &enemyId, int &killCount, int &lastUpdateTime);
|
||||
|
||||
static void buildNameSpec (int guildId, std::string const &guildName, int guildElectionPreviousEndTime, int guildElectionNextEndTime, uint32 guildFaction, int timeLeftGuildFaction, std::string const & guildGcwDefenderRegion, int timeJoinedGuildGcwDefenderRegion, int timeLeftGuildGcwDefenderRegion, std::string &result);
|
||||
static void buildAbbrevSpec (int guildId, std::string const &guildAbbrev, std::string &result);
|
||||
static void buildLeaderSpec (int guildId, NetworkId const &leaderId, std::string &result);
|
||||
static void buildMemberSpec (int guildId, NetworkId const &memberId, std::string const &memberName, std::string const &memberProfessionSkillTemplate, int memberLevel, int permissions, BitArray const &rank, std::string const &title, NetworkId const &allegiance, std::string &result);
|
||||
static void buildEnemySpec (int guildId, int enemyId, int killCount, int lastUpdateTime, std::string &result);
|
||||
|
||||
private:
|
||||
GuildStringParser();
|
||||
};
|
||||
|
||||
// ======================================================================
|
||||
|
||||
#endif // _GuildStringParser_H_
|
||||
|
||||
Reference in New Issue
Block a user