Subversion Repositories eoserv

Compare Revisions

Ignore whitespace Rev 375 → Rev 376

/trunk/src/util.cpp
141,7 → 141,7
c -= 'A' - 'a';
}
 
for (std::size_t ii = 0; ii < sizeof(period_names)/sizeof(char); ++ii)
for (std::size_t ii = 0; ii < sizeof(period_names); ++ii)
{
if (c == period_names[ii])
{
/trunk/src/world.cpp
248,6 → 248,7
 
Handlers::SetDelay(PACKET_ATTACK, PACKET_USE, rate_attack);
 
 
std::array<double, 7> npc_speed_table;
 
std::vector<std::string> rate_list = util::explode(',', this->config["NPCMovementRate"]);
254,11 → 255,29
 
for (std::size_t i = 0; i < std::min<std::size_t>(7, rate_list.size()); ++i)
{
npc_speed_table[i] = util::tdparse(rate_list[i]);
if (i < rate_list.size())
npc_speed_table[i] = util::tdparse(rate_list[i]);
else
npc_speed_table[i] = 1.0;
}
 
NPC::SetSpeedTable(npc_speed_table);
 
 
this->i18n.SetLangFile(this->config["ServerLanguage"]);
 
 
this->instrument_ids.clear();
 
std::vector<std::string> instrument_list = util::explode(',', this->config["InstrumentItems"]);
this->instrument_ids.reserve(instrument_list.size());
 
for (std::size_t i = 0; i < instrument_list.size(); ++i)
{
this->instrument_ids.push_back(int(util::tdparse(instrument_list[i])));
}
 
 
if (this->db.Pending() && !this->config["TimedSave"])
this->CommitDB();
}
1240,6 → 1259,11
return std::find(except_list.begin(), except_list.end(), mapid) != except_list.end();
}
 
bool World::IsInstrument(int graphic_id)
{
return std::find(UTIL_RANGE(this->instrument_ids), graphic_id) != this->instrument_ids.end();
}
 
World::~World()
{
std::list<Character *> todelete;
/trunk/src/handlers/Item.cpp
315,8 → 315,16
builder.AddChar(character->level);
builder.AddShort(character->statpoints);
builder.AddShort(character->skillpoints);
// TODO: Something better than this
character->Emote(EMOTE_LEVELUP, true);
 
UTIL_FOREACH(character->map->characters, check)
{
if (character != check && character->InRange(check))
{
PacketBuilder builder(PACKET_ITEM, PACKET_ACCEPT, 2);
builder.AddShort(character->player->id);
character->Send(builder);
}
}
}
 
character->Send(reply);
/trunk/src/handlers/Jukebox.cpp
74,9 → 74,35
std::for_each(UTIL_CRANGE(character->map->characters), std::bind(&Character::Send, _1, builder));
}
 
// Bard skill music
void Jukebox_Use(Character *character, PacketReader &reader)
{
/*unsigned char instrument = */reader.GetChar();
unsigned char note = reader.GetChar();
 
const auto& eif = character->world->eif;
const auto& esf = character->world->esf;
 
// Check if user has the bard skill
auto find_it = find_if(UTIL_RANGE(character->spells),
[&](const Character_Spell& spell) { return esf->Get(spell.id).type == ESF::Bard; });
 
if (find_it == character->spells.end())
return;
 
// Check if the held weapon is an instrument
int instrument = eif->Get(character->paperdoll[Character::Weapon]).dollgraphic;
 
if (!character->world->IsInstrument(instrument))
return;
 
character->PlayBard(instrument, note, false);
}
 
PACKET_HANDLER_REGISTER(PACKET_JUKEBOX)
Register(PACKET_OPEN, Jukebox_Open, Playing);
Register(PACKET_MSG, Jukebox_Msg, Playing);
Register(PACKET_USE, Jukebox_Use, Playing);
PACKET_HANDLER_REGISTER_END()
 
}
/trunk/src/character.cpp
585,6 → 585,26
}
}
 
void Character::PlayBard(unsigned char instrument, unsigned char note, bool echo )
{
PacketBuilder builder(PACKET_JUKEBOX, PACKET_MSG, 5);
 
builder.AddShort(this->player->id);
builder.AddChar(this->direction);
builder.AddChar(instrument);
builder.AddChar(note);
 
UTIL_FOREACH(this->map->characters, character)
{
if (!echo && (character == this || !this->InRange(character)))
{
continue;
}
 
character->Send(builder);
}
}
 
int Character::HasItem(short item)
{
UTIL_IFOREACH(this->inventory, it)
1000,7 → 1020,7
{
if (this->paperdoll[Weapon])
{
const EIF_Data weapon_eif = this->world->eif->Get(this->paperdoll[Weapon]);
const EIF_Data& weapon_eif = this->world->eif->Get(this->paperdoll[Weapon]);
 
if (weapon_eif.subtype == EIF::TwoHanded
&& (weapon_eif.dual_wield_dollgraphic || (eif.subtype != EIF::Arrows && eif.subtype != EIF::Wings)))
/trunk/src/world.hpp
110,7 → 110,8
 
std::array<Board *, 8> boards;
 
std::array<int, 254> exp_table;
std::array<int, 254> exp_table;
std::vector<int> instrument_ids;
 
int admin_count;
 
178,7 → 179,9
bool PlayerOnline(std::string username);
 
bool PKExcept(const Map *map);
bool PKExcept(int mapid);
bool PKExcept(int mapid);
 
bool IsInstrument(int graphic_id);
 
~World();
};
/trunk/src/map.cpp
1362,7 → 1362,10
from->arena->Attack(from, direction);
}
 
if (this->pk || (this->world->config["GlobalPK"] && !this->world->PKExcept(this->id)))
int wep_graphic = this->world->eif->Get(from->paperdoll[Character::Weapon]).dollgraphic;
bool is_instrument = (wep_graphic != 0 && this->world->IsInstrument(wep_graphic));
 
if (!is_instrument && (this->pk || (this->world->config["GlobalPK"] && !this->world->PKExcept(this->id))))
{
if (this->AttackPK(from, direction))
{
1384,6 → 1387,9
character->Send(builder);
}
 
if (is_instrument)
return;
 
int target_x = from->x;
int target_y = from->y;
 
/trunk/src/eoserv_config.cpp
213,6 → 213,7
eoserv_config_default(config, "ComputerNameLength" , 64);
eoserv_config_default(config, "LimitAttack" , 251);
eoserv_config_default(config, "MuteLength" , 90);
eoserv_config_default(config, "InstrumentItems" , "49, 50");
eoserv_config_default(config, "MaxBankGold" , 2000000000);
eoserv_config_default(config, "MaxItem" , 2000000000);
eoserv_config_default(config, "MaxDrop" , 10000000);
/trunk/src/character.hpp
223,6 → 223,7
void Stand();
void Emote(enum Emote emote, bool echo = true);
void Effect(int effect, bool echo = true);
void PlayBard(unsigned char instrument, unsigned char note, bool echo = true);
int HasItem(short item);
bool HasSpell(short spell);
short SpellLevel(short spell);
/trunk/config/extra.ini
161,7 → 161,12
# Length of time a temporary mute lasts
MuteLength = 90s
 
## InstrumentItems (number[])
# Graphic IDs of weapons which can be played as instruments using the 'Bard' skill
InstrumentItems = 49,50
 
 
 
## ITEM LIMITS ##
 
## ChestSlots (number)
/trunk/config/misc.ini
82,7 → 82,7
# Gains made by partied characters are totalled and handled to PartyShareMode
# 0 = last hit takes all
# 1 = most damage takes all
# 2 = fair share based on damage each player attacks
# 2 = fair share based on the ratio of damage each player inflicts
# 3 = fair share between all attackers
ShareMode = 2