Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions include/LmParty.cpp
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>

#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("<LmParty[%p,%d]: creator=%u leader=%u members(%d)=["), this, sizeof(LmParty),
CreatorID(), LeaderID(), PartySize());
for (int i = 0; i < PartySize(); ++i) {
_ftprintf(f, _T("%u"), PlayerID(i));
if (i != (PartySize() - 1)) {
_ftprintf(f, _T(","));
}
}
_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;
}
69 changes: 0 additions & 69 deletions include/lmparty.h

This file was deleted.

52 changes: 0 additions & 52 deletions include/lmparty.i

This file was deleted.

15 changes: 5 additions & 10 deletions server/gamed/GsPlayerThread2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions server/gamed/GsPlayerThread3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down