mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Merge git://github.com/EQEmu/Server into Development
This commit is contained in:
commit
b8972e0215
1
Server
1
Server
@ -1 +0,0 @@
|
||||
Subproject commit 9d78eec485fb73c8d61ce035590474556390783e
|
||||
@ -529,7 +529,7 @@ typedef enum {
|
||||
#define SE_CastOnFadeEffectAlways 373 // implemented - Triggers if fades after natural duration OR from rune/numhits fades.
|
||||
#define SE_ApplyEffect 374 // implemented
|
||||
#define SE_DotCritDmgIncrease 375 // implemented - Increase damage of DoT critical amount
|
||||
#define SE_Fling 376 // *not implemented - used in 2 test spells (12945 | Movement Test Spell 1)
|
||||
//#define SE_Fling 376 // *not implemented - used in 2 test spells (12945 | Movement Test Spell 1)
|
||||
#define SE_CastOnFadeEffectNPC 377 // implemented - Triggers only if fades after natural duration (On live these are usually players spells that effect an NPC).
|
||||
#define SE_SpellEffectResistChance 378 // implemented - Increase chance to resist specific spell effect (base1=value, base2=spell effect id)
|
||||
#define SE_ShadowStepDirectional 379 // implemented - handled by client
|
||||
|
||||
@ -1543,10 +1543,14 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne
|
||||
{
|
||||
int i, effect_value, base2, max, effectid;
|
||||
bool AdditiveWornBonus = false;
|
||||
Mob *caster = nullptr;
|
||||
|
||||
if(!IsAISpellEffect && !IsValidSpell(spell_id))
|
||||
return;
|
||||
|
||||
if(casterId > 0)
|
||||
caster = entity_list.GetMob(casterId);
|
||||
|
||||
for (i = 0; i < EFFECT_COUNT; i++)
|
||||
{
|
||||
//Buffs/Item effects
|
||||
@ -1573,7 +1577,7 @@ void Mob::ApplySpellsBonuses(uint16 spell_id, uint8 casterlevel, StatBonuses *ne
|
||||
AdditiveWornBonus = true;
|
||||
|
||||
effectid = spells[spell_id].effectid[i];
|
||||
effect_value = CalcSpellEffectValue(spell_id, i, casterlevel, instrument_mod, nullptr, ticsremaining, casterId);
|
||||
effect_value = CalcSpellEffectValue(spell_id, i, casterlevel, instrument_mod, caster, ticsremaining);
|
||||
base2 = spells[spell_id].base2[i];
|
||||
max = spells[spell_id].max[i];
|
||||
}
|
||||
|
||||
@ -662,7 +662,7 @@ public:
|
||||
bool TryReflectSpell(uint32 spell_id);
|
||||
bool CanBlockSpell() const { return(spellbonuses.BlockNextSpell); }
|
||||
bool DoHPToManaCovert(uint16 mana_cost = 0);
|
||||
int32 ApplySpellEffectiveness(int16 spell_id, int32 value, bool IsBard = false, uint16 caster_id=0);
|
||||
int32 ApplySpellEffectiveness(Mob* caster, int16 spell_id, int32 value, bool IsBard = false);
|
||||
int8 GetDecayEffectValue(uint16 spell_id, uint16 spelleffect);
|
||||
int32 GetExtraSpellAmt(uint16 spell_id, int32 extra_spell_amt, int32 base_spell_dmg);
|
||||
void MeleeLifeTap(int32 damage);
|
||||
@ -898,7 +898,7 @@ public:
|
||||
virtual int32 CheckHealAggroAmount(uint16 spell_id, Mob *target, uint32 heal_possible = 0);
|
||||
|
||||
uint32 GetInstrumentMod(uint16 spell_id) const;
|
||||
int CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level = 1, uint32 instrument_mod = 10, Mob *caster = nullptr, int ticsremaining = 0,uint16 casterid=0);
|
||||
int CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level = 1, uint32 instrument_mod = 10, Mob *caster = nullptr, int ticsremaining = 0);
|
||||
int CalcSpellEffectValue_formula(int formula, int base, int max, int caster_level, uint16 spell_id, int ticsremaining = 0);
|
||||
virtual int CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, int caster_level2, Mob* caster1 = nullptr, Mob* caster2 = nullptr, int buffslot = -1);
|
||||
uint32 GetCastedSpellInvSlot() const { return casting_spell_inventory_slot; }
|
||||
|
||||
5148
zone/mobx.cpp
5148
zone/mobx.cpp
File diff suppressed because it is too large
Load Diff
1236
zone/mobx.h
1236
zone/mobx.h
File diff suppressed because it is too large
Load Diff
644
zone/net_Fix.cpp
644
zone/net_Fix.cpp
@ -1,644 +0,0 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define DONT_SHARED_OPCODES
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/features.h"
|
||||
#include "../common/queue.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/eq_stream.h"
|
||||
#include "../common/eq_stream_factory.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/mutex.h"
|
||||
#include "../common/version.h"
|
||||
#include "../common/eqemu_error.h"
|
||||
#include "../common/packet_dump_file.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/guilds.h"
|
||||
#include "../common/eq_stream_ident.h"
|
||||
#include "../common/patches/patches.h"
|
||||
#include "../common/rulesys.h"
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/platform.h"
|
||||
#include "../common/crash.h"
|
||||
#include "../common/ipc_mutex.h"
|
||||
#include "../common/memory_mapped_file.h"
|
||||
#include "../common/eqemu_exception.h"
|
||||
#include "../common/spdat.h"
|
||||
|
||||
#include "zone_config.h"
|
||||
#include "masterentity.h"
|
||||
#include "worldserver.h"
|
||||
#include "net.h"
|
||||
#include "zone.h"
|
||||
#include "queryserv.h"
|
||||
#include "command.h"
|
||||
#include "zone_config.h"
|
||||
#include "titles.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "tasks.h"
|
||||
|
||||
#include "quest_parser_collection.h"
|
||||
#include "embparser.h"
|
||||
#include "lua_parser.h"
|
||||
#include "client_logs.h"
|
||||
#include "questmgr.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#undef new
|
||||
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <conio.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include "../common/unix.h"
|
||||
#endif
|
||||
|
||||
volatile bool RunLoops = true;
|
||||
extern volatile bool ZoneLoaded;
|
||||
|
||||
TimeoutManager timeout_manager;
|
||||
NetConnection net;
|
||||
EntityList entity_list;
|
||||
WorldServer worldserver;
|
||||
uint32 numclients = 0;
|
||||
char errorname[32];
|
||||
uint16 adverrornum = 0;
|
||||
extern Zone* zone;
|
||||
EQStreamFactory eqsf(ZoneStream);
|
||||
npcDecayTimes_Struct npcCorpseDecayTimes[100];
|
||||
TitleManager title_manager;
|
||||
QueryServ *QServ = 0;
|
||||
TaskManager *taskmanager = 0;
|
||||
QuestParserCollection *parse = 0;
|
||||
|
||||
const SPDat_Spell_Struct* spells;
|
||||
void LoadSpells(EQEmu::MemoryMappedFile **mmf);
|
||||
int32 SPDAT_RECORDS = -1;
|
||||
|
||||
void Shutdown();
|
||||
extern void MapOpcodes();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
RegisterExecutablePlatform(ExePlatformZone);
|
||||
set_exception_handler();
|
||||
|
||||
const char *zone_name;
|
||||
|
||||
QServ = new QueryServ;
|
||||
|
||||
if(argc == 3) {
|
||||
worldserver.SetLauncherName(argv[2]);
|
||||
worldserver.SetLaunchedName(argv[1]);
|
||||
if(strncmp(argv[1], "dynamic_", 8) == 0) {
|
||||
//dynamic zone with a launcher name correlation
|
||||
zone_name = ".";
|
||||
} else {
|
||||
zone_name = argv[1];
|
||||
worldserver.SetLaunchedName(zone_name);
|
||||
}
|
||||
} else if (argc == 2) {
|
||||
worldserver.SetLauncherName("NONE");
|
||||
worldserver.SetLaunchedName(argv[1]);
|
||||
if(strncmp(argv[1], "dynamic_", 8) == 0) {
|
||||
//dynamic zone with a launcher name correlation
|
||||
zone_name = ".";
|
||||
} else {
|
||||
zone_name = argv[1];
|
||||
worldserver.SetLaunchedName(zone_name);
|
||||
}
|
||||
} else {
|
||||
zone_name = ".";
|
||||
worldserver.SetLaunchedName(".");
|
||||
worldserver.SetLauncherName("NONE");
|
||||
}
|
||||
|
||||
_log(ZONE__INIT, "Loading server configuration..");
|
||||
if (!ZoneConfig::LoadConfig()) {
|
||||
_log(ZONE__INIT_ERR, "Loading server configuration failed.");
|
||||
return 1;
|
||||
}
|
||||
const ZoneConfig *Config=ZoneConfig::get();
|
||||
|
||||
if(!load_log_settings(Config->LogSettingsFile.c_str()))
|
||||
_log(ZONE__INIT, "Warning: Unable to read %s", Config->LogSettingsFile.c_str());
|
||||
else
|
||||
_log(ZONE__INIT, "Log settings loaded from %s", Config->LogSettingsFile.c_str());
|
||||
|
||||
worldserver.SetPassword(Config->SharedKey.c_str());
|
||||
|
||||
_log(ZONE__INIT, "Connecting to MySQL...");
|
||||
if (!database.Connect(
|
||||
Config->DatabaseHost.c_str(),
|
||||
Config->DatabaseUsername.c_str(),
|
||||
Config->DatabasePassword.c_str(),
|
||||
Config->DatabaseDB.c_str(),
|
||||
Config->DatabasePort)) {
|
||||
_log(ZONE__INIT_ERR, "Cannot continue without a database connection.");
|
||||
return 1;
|
||||
}
|
||||
guild_mgr.SetDatabase(&database);
|
||||
|
||||
GuildBanks = nullptr;
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
_log(ZONE__INIT, "CURRENT_VERSION: %s", CURRENT_VERSION);
|
||||
|
||||
/*
|
||||
* Setup nice signal handlers
|
||||
*/
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
_log(ZONE__INIT_ERR, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
_log(ZONE__INIT_ERR, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
_log(ZONE__INIT_ERR, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *log_ini_file = "./log.ini";
|
||||
if(!load_log_settings(log_ini_file))
|
||||
_log(ZONE__INIT, "Warning: Unable to read %s", log_ini_file);
|
||||
else
|
||||
_log(ZONE__INIT, "Log settings loaded from %s", log_ini_file);
|
||||
|
||||
_log(ZONE__INIT, "Mapping Incoming Opcodes");
|
||||
MapOpcodes();
|
||||
_log(ZONE__INIT, "Loading Variables");
|
||||
database.LoadVariables();
|
||||
_log(ZONE__INIT, "Loading zone names");
|
||||
database.LoadZoneNames();
|
||||
_log(ZONE__INIT, "Loading items");
|
||||
if (!database.LoadItems()) {
|
||||
_log(ZONE__INIT_ERR, "Loading items FAILED!");
|
||||
_log(ZONE__INIT, "Failed. But ignoring error and going on...");
|
||||
}
|
||||
|
||||
_log(ZONE__INIT, "Loading npc faction lists");
|
||||
if (!database.LoadNPCFactionLists()) {
|
||||
_log(ZONE__INIT_ERR, "Loading npcs faction lists FAILED!");
|
||||
CheckEQEMuErrorAndPause();
|
||||
return 1;
|
||||
}
|
||||
_log(ZONE__INIT, "Loading loot tables");
|
||||
if (!database.LoadLoot()) {
|
||||
_log(ZONE__INIT_ERR, "Loading loot FAILED!");
|
||||
CheckEQEMuErrorAndPause();
|
||||
return 1;
|
||||
}
|
||||
_log(ZONE__INIT, "Loading skill caps");
|
||||
if (!database.LoadSkillCaps()) {
|
||||
_log(ZONE__INIT_ERR, "Loading skill caps FAILED!");
|
||||
CheckEQEMuErrorAndPause();
|
||||
return 1;
|
||||
}
|
||||
|
||||
_log(ZONE__INIT, "Loading spells");
|
||||
EQEmu::MemoryMappedFile *mmf = nullptr;
|
||||
LoadSpells(&mmf);
|
||||
|
||||
_log(ZONE__INIT, "Loading base data");
|
||||
if (!database.LoadBaseData()) {
|
||||
_log(ZONE__INIT_ERR, "Loading base data FAILED!");
|
||||
CheckEQEMuErrorAndPause();
|
||||
return 1;
|
||||
}
|
||||
|
||||
_log(ZONE__INIT, "Loading guilds");
|
||||
guild_mgr.LoadGuilds();
|
||||
_log(ZONE__INIT, "Loading factions");
|
||||
database.LoadFactionData();
|
||||
_log(ZONE__INIT, "Loading titles");
|
||||
title_manager.LoadTitles();
|
||||
_log(ZONE__INIT, "Loading AA effects");
|
||||
database.LoadAAEffects();
|
||||
_log(ZONE__INIT, "Loading tributes");
|
||||
database.LoadTributes();
|
||||
_log(ZONE__INIT, "Loading corpse timers");
|
||||
database.GetDecayTimes(npcCorpseDecayTimes);
|
||||
_log(ZONE__INIT, "Loading commands");
|
||||
int retval=command_init();
|
||||
if(retval<0)
|
||||
_log(ZONE__INIT_ERR, "Command loading FAILED");
|
||||
else
|
||||
_log(ZONE__INIT, "%d commands loaded", retval);
|
||||
|
||||
//rules:
|
||||
{
|
||||
char tmp[64];
|
||||
if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) {
|
||||
_log(ZONE__INIT, "Loading rule set '%s'", tmp);
|
||||
if(!RuleManager::Instance()->LoadRules(&database, tmp)) {
|
||||
_log(ZONE__INIT_ERR, "Failed to load ruleset '%s', falling back to defaults.", tmp);
|
||||
}
|
||||
} else {
|
||||
if(!RuleManager::Instance()->LoadRules(&database, "default")) {
|
||||
_log(ZONE__INIT, "No rule set configured, using default rules");
|
||||
} else {
|
||||
_log(ZONE__INIT, "Loaded default rule set 'default'", tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
_log(ZONE__INIT, "Loading Tasks");
|
||||
taskmanager = new TaskManager;
|
||||
taskmanager->LoadTasks();
|
||||
}
|
||||
|
||||
parse = new QuestParserCollection();
|
||||
#ifdef LUA_EQEMU
|
||||
LuaParser *lua_parser = new LuaParser();
|
||||
parse->RegisterQuestInterface(lua_parser, "lua");
|
||||
#endif
|
||||
|
||||
#ifdef EMBPERL
|
||||
PerlembParser *perl_parser = new PerlembParser();
|
||||
parse->RegisterQuestInterface(perl_parser, "pl");
|
||||
#endif
|
||||
|
||||
//now we have our parser, load the quests
|
||||
_log(ZONE__INIT, "Loading quests");
|
||||
parse->ReloadQuests();
|
||||
|
||||
|
||||
#ifdef CLIENT_LOGS
|
||||
LogFile->SetAllCallbacks(ClientLogs::EQEmuIO_buf);
|
||||
LogFile->SetAllCallbacks(ClientLogs::EQEmuIO_fmt);
|
||||
LogFile->SetAllCallbacks(ClientLogs::EQEmuIO_pva);
|
||||
#endif
|
||||
if (!worldserver.Connect()) {
|
||||
_log(ZONE__INIT_ERR, "worldserver.Connect() FAILED!");
|
||||
}
|
||||
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect
|
||||
#ifdef EQPROFILE
|
||||
#ifdef PROFILE_DUMP_TIME
|
||||
Timer profile_dump_timer(PROFILE_DUMP_TIME*1000);
|
||||
profile_dump_timer.Start();
|
||||
#endif
|
||||
#endif
|
||||
if (!strlen(zone_name) || !strcmp(zone_name,".")) {
|
||||
_log(ZONE__INIT, "Entering sleep mode");
|
||||
} else if (!Zone::Bootup(database.GetZoneID(zone_name), 0, true)) { //todo: go above and fix this to allow cmd line instance
|
||||
_log(ZONE__INIT_ERR, "Zone bootup FAILED!");
|
||||
zone = 0;
|
||||
}
|
||||
|
||||
//register all the patches we have avaliable with the stream identifier.
|
||||
EQStreamIdentifier stream_identifier;
|
||||
RegisterAllPatches(stream_identifier);
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Main thread running with thread id %d", pthread_self());
|
||||
#endif
|
||||
|
||||
Timer quest_timers(100);
|
||||
UpdateWindowTitle();
|
||||
bool worldwasconnected = worldserver.Connected();
|
||||
EQStream* eqss;
|
||||
EQStreamInterface *eqsi;
|
||||
uint8 IDLEZONEUPDATE = 200;
|
||||
uint8 ZONEUPDATE = 10;
|
||||
Timer zoneupdate_timer(ZONEUPDATE);
|
||||
zoneupdate_timer.Start();
|
||||
while(RunLoops) {
|
||||
{ //profiler block to omit the sleep from times
|
||||
|
||||
//Advance the timer to our current point in time
|
||||
Timer::SetCurrentTime();
|
||||
|
||||
//process stuff from world
|
||||
worldserver.Process();
|
||||
|
||||
if (!eqsf.IsOpen() && Config->ZonePort!=0) {
|
||||
_log(ZONE__INIT, "Starting EQ Network server on port %d",Config->ZonePort);
|
||||
if (!eqsf.Open(Config->ZonePort)) {
|
||||
_log(ZONE__INIT_ERR, "Failed to open port %d",Config->ZonePort);
|
||||
ZoneConfig::SetZonePort(0);
|
||||
worldserver.Disconnect();
|
||||
worldwasconnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
//check the factory for any new incoming streams.
|
||||
while ((eqss = eqsf.Pop())) {
|
||||
//pull the stream out of the factory and give it to the stream identifier
|
||||
//which will figure out what patch they are running, and set up the dynamic
|
||||
//structures and opcodes for that patch.
|
||||
struct in_addr in;
|
||||
in.s_addr = eqss->GetRemoteIP();
|
||||
_log(WORLD__CLIENT, "New connection from %s:%d", inet_ntoa(in),ntohs(eqss->GetRemotePort()));
|
||||
stream_identifier.AddStream(eqss); //takes the stream
|
||||
}
|
||||
|
||||
//give the stream identifier a chance to do its work....
|
||||
stream_identifier.Process();
|
||||
|
||||
//check the stream identifier for any now-identified streams
|
||||
while((eqsi = stream_identifier.PopIdentified())) {
|
||||
//now that we know what patch they are running, start up their client object
|
||||
struct in_addr in;
|
||||
in.s_addr = eqsi->GetRemoteIP();
|
||||
_log(WORLD__CLIENT, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort()));
|
||||
Client* client = new Client(eqsi);
|
||||
entity_list.AddClient(client);
|
||||
}
|
||||
|
||||
if ( numclients < 1 && zoneupdate_timer.GetDuration() != IDLEZONEUPDATE )
|
||||
zoneupdate_timer.SetTimer(IDLEZONEUPDATE);
|
||||
else if ( numclients > 0 && zoneupdate_timer.GetDuration() == IDLEZONEUPDATE )
|
||||
{
|
||||
zoneupdate_timer.SetTimer(ZONEUPDATE);
|
||||
zoneupdate_timer.Trigger();
|
||||
}
|
||||
|
||||
//check for timeouts in other threads
|
||||
timeout_manager.CheckTimeouts();
|
||||
|
||||
if (worldserver.Connected()) {
|
||||
worldwasconnected = true;
|
||||
}
|
||||
else {
|
||||
if (worldwasconnected && ZoneLoaded)
|
||||
entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost");
|
||||
worldwasconnected = false;
|
||||
}
|
||||
|
||||
if (ZoneLoaded && zoneupdate_timer.Check()) {
|
||||
{
|
||||
if(net.group_timer.Enabled() && net.group_timer.Check())
|
||||
entity_list.GroupProcess();
|
||||
|
||||
if(net.door_timer.Enabled() && net.door_timer.Check())
|
||||
entity_list.DoorProcess();
|
||||
|
||||
if(net.object_timer.Enabled() && net.object_timer.Check())
|
||||
entity_list.ObjectProcess();
|
||||
|
||||
if(net.corpse_timer.Enabled() && net.corpse_timer.Check())
|
||||
entity_list.CorpseProcess();
|
||||
|
||||
if(net.trap_timer.Enabled() && net.trap_timer.Check())
|
||||
entity_list.TrapProcess();
|
||||
|
||||
if(net.raid_timer.Enabled() && net.raid_timer.Check())
|
||||
entity_list.RaidProcess();
|
||||
|
||||
entity_list.Process();
|
||||
|
||||
entity_list.MobProcess();
|
||||
|
||||
entity_list.BeaconProcess();
|
||||
|
||||
if (zone) {
|
||||
if(!zone->Process()) {
|
||||
Zone::Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
if(quest_timers.Check())
|
||||
quest_manager.Process();
|
||||
|
||||
}
|
||||
}
|
||||
if (InterserverTimer.Check()) {
|
||||
InterserverTimer.Start();
|
||||
database.ping();
|
||||
// AsyncLoadVariables(dbasync, &database);
|
||||
entity_list.UpdateWho();
|
||||
if (worldserver.TryReconnect() && (!worldserver.Connected()))
|
||||
worldserver.AsyncConnect();
|
||||
}
|
||||
|
||||
#if defined(_EQDEBUG) && defined(DEBUG_PC)
|
||||
QueryPerformanceCounter(&tmp3);
|
||||
mainloop_time += tmp3.QuadPart - tmp2.QuadPart;
|
||||
if (!--tmp0) {
|
||||
tmp0 = 200;
|
||||
printf("Elapsed Tics : %9.0f (%1.4f sec)\n", (double)mainloop_time, ((double)mainloop_time/tmp.QuadPart));
|
||||
printf("NPCAI Tics : %9.0f (%1.2f%%)\n", (double)npcai_time, ((double)npcai_time/mainloop_time)*100);
|
||||
printf("FindSpell Tics: %9.0f (%1.2f%%)\n", (double)findspell_time, ((double)findspell_time/mainloop_time)*100);
|
||||
printf("AtkAllowd Tics: %9.0f (%1.2f%%)\n", (double)IsAttackAllowed_time, ((double)IsAttackAllowed_time/mainloop_time)*100);
|
||||
printf("ClientPro Tics: %9.0f (%1.2f%%)\n", (double)clientprocess_time, ((double)clientprocess_time/mainloop_time)*100);
|
||||
printf("ClientAtk Tics: %9.0f (%1.2f%%)\n", (double)clientattack_time, ((double)clientattack_time/mainloop_time)*100);
|
||||
mainloop_time = 0;
|
||||
npcai_time = 0;
|
||||
findspell_time = 0;
|
||||
IsAttackAllowed_time = 0;
|
||||
clientprocess_time = 0;
|
||||
clientattack_time = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef EQPROFILE
|
||||
#ifdef PROFILE_DUMP_TIME
|
||||
if(profile_dump_timer.Check()) {
|
||||
DumpZoneProfile();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
} //end extra profiler block
|
||||
Sleep(ZoneTimerResolution);
|
||||
}
|
||||
|
||||
entity_list.Clear();
|
||||
|
||||
parse->ClearInterfaces();
|
||||
|
||||
#ifdef EMBPERL
|
||||
safe_delete(perl_parser);
|
||||
#endif
|
||||
|
||||
#ifdef LUA_EQEMU
|
||||
safe_delete(lua_parser);
|
||||
#endif
|
||||
|
||||
safe_delete(mmf);
|
||||
safe_delete(Config);
|
||||
|
||||
if (zone != 0)
|
||||
Zone::Shutdown(true);
|
||||
//Fix for Linux world server problem.
|
||||
eqsf.Close();
|
||||
worldserver.Disconnect();
|
||||
safe_delete(taskmanager);
|
||||
command_deinit();
|
||||
safe_delete(parse);
|
||||
CheckEQEMuErrorAndPause();
|
||||
_log(ZONE__INIT, "Proper zone shutdown complete.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
#ifdef _WINDOWS
|
||||
_log(ZONE__INIT, "Recieved signal: %i", sig_num);
|
||||
#endif
|
||||
RunLoops = false;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
Zone::Shutdown(true);
|
||||
RunLoops = false;
|
||||
worldserver.Disconnect();
|
||||
// safe_delete(worldserver);
|
||||
_log(ZONE__INIT, "Shutting down...");
|
||||
}
|
||||
|
||||
uint32 NetConnection::GetIP()
|
||||
{
|
||||
char name[255+1];
|
||||
size_t len = 0;
|
||||
hostent* host = 0;
|
||||
|
||||
if (gethostname(name, len) < 0 || len <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
host = (hostent*)gethostbyname(name);
|
||||
if (host == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return inet_addr(host->h_addr);
|
||||
}
|
||||
|
||||
uint32 NetConnection::GetIP(char* name)
|
||||
{
|
||||
hostent* host = 0;
|
||||
|
||||
host = (hostent*)gethostbyname(name);
|
||||
if (host == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return inet_addr(host->h_addr);
|
||||
|
||||
}
|
||||
|
||||
void NetConnection::SaveInfo(char* address, uint32 port, char* waddress, char* filename) {
|
||||
|
||||
ZoneAddress = new char[strlen(address)+1];
|
||||
strcpy(ZoneAddress, address);
|
||||
ZonePort = port;
|
||||
WorldAddress = new char[strlen(waddress)+1];
|
||||
strcpy(WorldAddress, waddress);
|
||||
strn0cpy(ZoneFileName, filename, sizeof(ZoneFileName));
|
||||
}
|
||||
|
||||
NetConnection::NetConnection()
|
||||
:
|
||||
object_timer(5000),
|
||||
door_timer(5000),
|
||||
corpse_timer(2000),
|
||||
group_timer(1000),
|
||||
raid_timer(1000),
|
||||
trap_timer(1000)
|
||||
{
|
||||
ZonePort = 0;
|
||||
ZoneAddress = 0;
|
||||
WorldAddress = 0;
|
||||
group_timer.Disable();
|
||||
raid_timer.Disable();
|
||||
corpse_timer.Disable();
|
||||
door_timer.Disable();
|
||||
object_timer.Disable();
|
||||
trap_timer.Disable();
|
||||
}
|
||||
|
||||
NetConnection::~NetConnection() {
|
||||
if (ZoneAddress != 0)
|
||||
safe_delete_array(ZoneAddress);
|
||||
if (WorldAddress != 0)
|
||||
safe_delete_array(WorldAddress);
|
||||
}
|
||||
|
||||
void LoadSpells(EQEmu::MemoryMappedFile **mmf) {
|
||||
int records = database.GetMaxSpellID() + 1;
|
||||
|
||||
try {
|
||||
EQEmu::IPCMutex mutex("spells");
|
||||
mutex.Lock();
|
||||
*mmf = new EQEmu::MemoryMappedFile("shared/spells");
|
||||
uint32 size = (*mmf)->Size();
|
||||
if(size != (records * sizeof(SPDat_Spell_Struct))) {
|
||||
EQ_EXCEPT("Zone", "Unable to load spells: (*mmf)->Size() != records * sizeof(SPDat_Spell_Struct)");
|
||||
}
|
||||
|
||||
spells = reinterpret_cast<SPDat_Spell_Struct*>((*mmf)->Get());
|
||||
mutex.Unlock();
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEMuLog::Error, "Error loading spells: %s", ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
SPDAT_RECORDS = records;
|
||||
}
|
||||
|
||||
/* Update Window Title with relevant information */
|
||||
void UpdateWindowTitle(char* iNewTitle) {
|
||||
#ifdef _WINDOWS
|
||||
char tmp[500];
|
||||
if (iNewTitle) {
|
||||
snprintf(tmp, sizeof(tmp), "%i: %s", ZoneConfig::get()->ZonePort, iNewTitle);
|
||||
}
|
||||
else {
|
||||
if (zone) {
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid());
|
||||
#else
|
||||
snprintf(tmp, sizeof(tmp), "%s :: clients: %i inst_id: %i inst_ver: %i :: port: %i", zone->GetShortName(), numclients, zone->GetInstanceID(), zone->GetInstanceVersion(), ZoneConfig::get()->ZonePort);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if defined(GOTFRAGS) || defined(_EQDEBUG)
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid());
|
||||
#else
|
||||
snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
SetConsoleTitle(tmp);
|
||||
#endif
|
||||
}
|
||||
@ -1270,9 +1270,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
#ifdef SPELL_EFFECT_SPAM
|
||||
snprintf(effect_desc, _EDLEN, "Melee Absorb Rune: %+i", effect_value);
|
||||
#endif
|
||||
if (caster)
|
||||
effect_value = caster->ApplySpellEffectiveness(spell_id, effect_value);
|
||||
|
||||
effect_value = ApplySpellEffectiveness(caster, spell_id, effect_value);
|
||||
buffs[buffslot].melee_rune = effect_value;
|
||||
break;
|
||||
}
|
||||
@ -3022,7 +3020,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
|
||||
}
|
||||
|
||||
int Mob::CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level, uint32 instrument_mod, Mob *caster,
|
||||
int ticsremaining, uint16 caster_id)
|
||||
int ticsremaining)
|
||||
{
|
||||
int formula, base, max, effect_value;
|
||||
|
||||
@ -3050,7 +3048,7 @@ int Mob::CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level,
|
||||
spells[spell_id].effectid[effect_id] != SE_ManaRegen_v2) {
|
||||
|
||||
int oval = effect_value;
|
||||
int mod = ApplySpellEffectiveness(spell_id, instrument_mod, true, caster_id);
|
||||
int mod = ApplySpellEffectiveness(caster, spell_id, instrument_mod, true);
|
||||
effect_value = effect_value * mod / 10;
|
||||
Log.Out(Logs::Detail, Logs::Spells, "Effect value %d altered with bard modifier of %d to yeild %d",
|
||||
oval, mod, effect_value);
|
||||
@ -6045,21 +6043,16 @@ int32 Mob::GetFocusIncoming(focusType type, int effect, Mob *caster, uint32 spel
|
||||
return value;
|
||||
}
|
||||
|
||||
int32 Mob::ApplySpellEffectiveness(int16 spell_id, int32 value, bool IsBard, uint16 caster_id) {
|
||||
int32 Mob::ApplySpellEffectiveness(Mob* caster, int16 spell_id, int32 value, bool IsBard) {
|
||||
|
||||
// 9-17-12: This is likely causing crashes, disabled till can resolve.
|
||||
if (IsBard)
|
||||
return value;
|
||||
|
||||
Mob* caster = this;
|
||||
|
||||
if (caster_id && caster_id != GetID())//Make sure we are checking the casters focus
|
||||
caster = entity_list.GetMob(caster_id);
|
||||
|
||||
if (!caster)
|
||||
return value;
|
||||
|
||||
int16 focus = caster->GetFocusEffect(focusFcBaseEffects, spell_id);
|
||||
int16 focus = GetFocusEffect(focusFcBaseEffects, spell_id);
|
||||
|
||||
if (IsBard)
|
||||
value += focus;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user