diff --git a/include/LmParty.cpp b/include/LmParty.cpp new file mode 100644 index 0000000..9db9a01 --- /dev/null +++ b/include/LmParty.cpp @@ -0,0 +1,161 @@ +// LmParty.cpp -*- C++ -*- +// $Id: LmParty.cpp,v 1.3 1997-11-17 14:05:12-08 jason Exp $ +// Copyright 1996-1997 Lyra LLC, All rights reserved. +// +// implementation + +#ifdef __GNUC__ +#pragma implementation "LmParty.h" +#endif + +#include + +#include "LmParty.h" +#include "LyraDefs.h" + +#ifndef USE_INLINE +#include "LmParty.i" +#endif + +//// +// Constructor +//// + +LmParty::LmParty() +{ + Empty(); +} + +//// +// Create +//// + +void LmParty::Create(lyra_id_t leaderid) +{ + Empty(); + leaderid_ = leaderid; + creatorid_ = leaderid; + AddPlayer(leaderid); +} + +//// +// Empty: empty party +//// + +void LmParty::Empty() +{ + for (int i = 0; i < MAX_PARTYSIZE; ++i) { + members_[i] = DEFAULT_ID; + } + leaderid_ = DEFAULT_LEADER; + creatorid_ = 0; + num_members_ = 0; +} + +//// +// AddPlayer: add player to party; return 0 if successful, -1 otherwise +//// + +int LmParty::AddPlayer(lyra_id_t playerid) +{ + if (IsFull() || (index_of(playerid) != -1)) { + return -1; + } + // add at end + members_[num_members_] = playerid; + ++num_members_; + return 0; +} + +//// +// RemovePlayer: remove player from party; return 0 if successful, -1 otherwise +//// + +int LmParty::RemovePlayer(lyra_id_t playerid) +{ + int idx = index_of(playerid); + if (idx == -1) { + return -1; + } + // remove by swapping with last item + num_members_--; + members_[idx] = members_[num_members_]; + // clear out last item (necessary if only one element) + members_[num_members_] = DEFAULT_ID; + // check if party is now empty (ie. current player is only member) and if so, clear + if (num_members_ == 1) { + Empty(); + return 0; + } + // check if leadership will change + // if party leader left, new leader is remaining player with smallest player id + if (leaderid_ == playerid) { + lyra_id_t newleader = members_[0]; + for (int i = 1; i < num_members_; ++i) { + if (members_[i] < newleader) { + newleader = members_[i]; + } + } + leaderid_ = newleader; + // if leadership changed, creator is no longer necessary + creatorid_ = Lyra::ID_UNKNOWN; + } + return 0; +} + +//// +// Dump +//// + +#ifdef USE_DEBUG +void LmParty::Dump(FILE* f, int indent) const +{ + INDENT(indent, f); + _ftprintf(f, _T("\n")); +} +#endif /* USE_DEBUG */ + +//// +// Dump1 +//// + +#ifdef USE_DEBUG +void LmParty::Dump1(FILE* f) const +{ + if (IsEmpty()) { + _ftprintf(f, _T("[]")); + } + else { + _ftprintf(f, _T("[%u:"), LeaderID()); + for (int i = 0; i < PartySize(); ++i) { + _ftprintf(f, _T("%u"), PlayerID(i)); + if (i != (PartySize() - 1)) { +_ftprintf(f, _T(",")); + } + } + _ftprintf(f, _T("]")); + } +} +#endif /* USE_DEBUG */ + +//// +// index_of: return index into members_ for given playerid, or -1 if not found +//// + +int LmParty::index_of(lyra_id_t playerid) const +{ + for (int i = 0; i < MAX_PARTYSIZE; ++i) { + if (members_[i] == playerid) { + return i; + } + } + return -1; +} diff --git a/include/lmparty.h b/include/lmparty.h deleted file mode 100644 index 51b18e8..0000000 --- a/include/lmparty.h +++ /dev/null @@ -1,69 +0,0 @@ -// LmParty.h -*- C++ -*- -// $Id: LmParty.h,v 1.6 1997-07-09 19:24:52-07 jason Exp $ -// Copyright 1996-1997 Lyra LLC, All rights reserved. -// -// "character party" class - -#ifndef INCLUDED_LmParty -#define INCLUDED_LmParty - -#ifdef __GNUC__ -#pragma interface -#endif - -#include - -#include "LyraDefs.h" - -// forward declarations - -// class declarations - -class LmParty { - -public: - - enum { - // constants - MAX_PARTYSIZE = Lyra::MAX_PARTYSIZE, - - // defaults - DEFAULT_LEADER = Lyra::ID_UNKNOWN, - DEFAULT_ID = Lyra::ID_UNKNOWN - }; - -public: - - LmParty(); - - void Create(lyra_id_t leaderid); - int RemovePlayer(lyra_id_t playerid); - int AddPlayer(lyra_id_t playerid); - void Empty(); - - int PartySize() const; - int MaxPartySize() const; - bool IsEmpty() const; - bool IsFull() const; - bool HasPlayer(lyra_id_t playerid) const; - lyra_id_t LeaderID() const; - lyra_id_t PlayerID(int index) const; - - void Dump(FILE* f, int indent = 0) const; - void Dump1(FILE* f) const; - -private: - - int index_of(lyra_id_t playerid) const; - - lyra_id_t leaderid_; - int num_members_; - lyra_id_t members_[MAX_PARTYSIZE]; - -}; - -#ifdef USE_INLINE -#include "LmParty.i" -#endif - -#endif /* INCLUDED_LmParty */ diff --git a/include/lmparty.i b/include/lmparty.i deleted file mode 100644 index 26bfe42..0000000 --- a/include/lmparty.i +++ /dev/null @@ -1,52 +0,0 @@ -// LmParty.i -*- C++ -*- -// $Id: LmParty.i,v 1.3 1997-07-18 16:04:59-07 jason Exp $ -// Copyright 1996-1997 Lyra LLC, All rights reserved. -// -// optionally inlined methods/functions - -#ifndef USE_DEBUG -INLINE void LmParty::Dump(FILE*, int) const -{ - // empty -} - -INLINE void LmParty::Dump1(FILE*) const -{ - // empty -} -#endif /* !USE_DEBUG */ - -INLINE int LmParty::PartySize() const -{ - return num_members_; -} - -INLINE int LmParty::MaxPartySize() const -{ - return MAX_PARTYSIZE; -} - -INLINE bool LmParty::IsEmpty() const -{ - return (PartySize() == 0); -} - -INLINE bool LmParty::IsFull() const -{ - return (PartySize() == MaxPartySize()); -} - -INLINE bool LmParty::HasPlayer(lyra_id_t playerid) const -{ - return (index_of(playerid) != -1); -} - -INLINE lyra_id_t LmParty::LeaderID() const -{ - return leaderid_; -} - -INLINE lyra_id_t LmParty::PlayerID(int index) const -{ - return members_[index]; -} diff --git a/server/gamed/GsPlayerThread2.cpp b/server/gamed/GsPlayerThread2.cpp index ebf60b9..9ee3ea8 100644 --- a/server/gamed/GsPlayerThread2.cpp +++ b/server/gamed/GsPlayerThread2.cpp @@ -419,7 +419,7 @@ void GsPlayerThread::handle_RMsg_PlayerMsg(LmSrvMesgBuf* msgbuf, LmConnection* c case RMsg_PlayerMsg::EXPEL: // skill, guild_id case RMsg_PlayerMsg::CHAOS_PURGE: // skill, not used case RMsg_PlayerMsg::CUP_SUMMONS: // skill, not used - // case RMsg_PlayerMsg::SUMMON_PRIME: // skill, success This goes through the given art at given skill level check below.. msg.State1() for this art is guildid not skill level + case RMsg_PlayerMsg::SUMMON_PRIME: // skill, success case RMsg_PlayerMsg::SCAN: // skill, not used case RMsg_PlayerMsg::HEAL: // skill, not used case RMsg_PlayerMsg::SANCTIFY: // skill, not used @@ -721,16 +721,7 @@ void GsPlayerThread::handle_RMsg_PlayerMsg(LmSrvMesgBuf* msgbuf, LmConnection* c break; - // summon prime check - case RMsg_PlayerMsg::SUMMON_PRIME: - if (!player_->CanUseArt(Arts::SUMMON_PRIME, 1) || !player_->HasMinRank(Guild::RULER)) { - int p_skill = player_->DB().Arts().Skill(Arts::SUMMON_PRIME); - SECLOG(4, _T("%s: player %u: illegal attempt to use Summon Prime art, own skill is %d or doesn't posess necessary guild rank"), method, - player_->PlayerID(), p_skill); - send_to_level = false; - } - break; // player attempting to spheretrain someone case RMsg_PlayerMsg::TRAIN_SPHERE: { // success, max sphere trainable @@ -987,6 +978,10 @@ void GsPlayerThread::handle_RMsg_PlayerMsg(LmSrvMesgBuf* msgbuf, LmConnection* c // determine how much XP to lose float xp_adj_pct = msg.State3() ? 0.009 : 0.01; int xp_adj = - (int) ((double) player_->DB().Stats().XP() * xp_adj_pct); // lose up to 1% + if (xp_adj < -100000) // setting a cap on xp loss to 100k + { + xp_adj = -100000; + } adjust_xp(xp_adj, _T("being dissolved by player"), msg.ReceiverID(), true); // fill in orbit (state1), DS field with "1", if player (monster/admin client will fill in fields) if (player_->DB().AccountType() == LmPlayerDB::ACCT_PLAYER) diff --git a/server/gamed/GsPlayerThread3.cpp b/server/gamed/GsPlayerThread3.cpp index 74b05ac..55a4446 100644 --- a/server/gamed/GsPlayerThread3.cpp +++ b/server/gamed/GsPlayerThread3.cpp @@ -1001,6 +1001,10 @@ void GsPlayerThread::handle_SMsg_Proxy_RMsg_PlayerMsg(LmSrvMesgBuf* msgbuf) bool agent_killed = true; if (orbit < 100) { // player, state1 = orbit xp_adj = (int) ((double) LmStats::OrbitXPBase(orbit) * 0.01); // gain up to 1% + if (xp_adj > 100000) // setting a cap on xp gain to 100k for player kills + { + xp_adj = 100000; + } agent_killed = false; } else if (orbit < 150) { // monster, state1 = 100 + nightmare index @@ -1076,6 +1080,10 @@ void GsPlayerThread::handle_SMsg_Proxy_RMsg_PlayerMsg(LmSrvMesgBuf* msgbuf) if ((orbit > 29) || (sphere_diff < 2)) { xp_adj = (int) ((double) LmStats::OrbitXPBase(orbit) * 0.01); // gain up to 1% } + if (xp_adj > 100000) //if killing this player gives you more than 100k give 100k + { + xp_adj = 100000; + } adjust_xp(xp_adj, _T("dissolving player"), msg.SenderID(), true); } else if (orbit < 150) { // monster, state1 = 100 + nightmare index xp_adj = GsUtil::NightmareXP(orbit - 100);