Skill caps load with new smem scheme

This commit is contained in:
KimLS 2013-02-20 13:54:26 -08:00
parent 12bde7434a
commit 8eb7d0aaa8
54 changed files with 311 additions and 253 deletions

View File

@ -1,5 +1,5 @@
#include "../common/types.h"
#include "../zone/features.h"
#include "../common/features.h"
#include "../zone/faction.h"
#include "../common/EMuShareMem.h"

View File

@ -130,6 +130,7 @@ SET(common_headers
eqtime.h
errmsg.h
extprofile.h
features.h
fixed_memory_hash_set.h
guild_base.h
guilds.h

View File

@ -19,7 +19,7 @@
#define COMMON_PROFILE_H
#ifdef ZONE
#include "../zone/features.h"
#include "../common/features.h"
#ifndef EQPROFILE
#ifdef COMMON_PROFILE

View File

@ -50,7 +50,7 @@ namespace EQEmu {
byte *ptr = data;
*reinterpret_cast<key_type*>(ptr) = max_element_id;
offset_count_ = max_element_id;
offset_count_ = max_element_id + 1;
ptr += sizeof(key_type);
*reinterpret_cast<key_type*>(ptr) = element_count;
@ -227,7 +227,7 @@ namespace EQEmu {
//! Calculates how much memory we should allocate based on element size and count
static size_type estimated_size(key_type element_count, key_type max_elements) {
size_type total_size = 3 * sizeof(key_type);
total_size += sizeof(key_type) * max_elements;
total_size += sizeof(key_type) * (max_elements + 1);
total_size += sizeof(T) * element_count;
return total_size;
}

View File

@ -1,17 +1,20 @@
#include "shareddb.h"
#include "../common/Item.h"
#include "../common/EMuShareMem.h"
#include "../common/classes.h"
#include "../common/rulesys.h"
#include "../common/seperator.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
#include "Item.h"
#include "EMuShareMem.h"
#include "classes.h"
#include "rulesys.h"
#include "seperator.h"
#include "MiscFunctions.h"
#include "eq_packet_structs.h"
#include "guilds.h"
#include "extprofile.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
#include "memory_mapped_file.h"
#include "ipc_mutex.h"
#include "eqemu_exception.h"
using namespace std;
@ -22,14 +25,14 @@ extern LoadEMuShareMemDLL EMuShareMemDLL;
SharedDatabase *SharedDatabase::s_usedb = NULL;
SharedDatabase::SharedDatabase()
: Database()
: Database(), skill_caps_mmf(NULL)
{
SDBInitVars();
s_usedb = this;
}
SharedDatabase::SharedDatabase(const char* host, const char* user, const char* passwd, const char* database, uint32 port)
: Database(host, user, passwd, database, port)
: Database(host, user, passwd, database, port), skill_caps_mmf(NULL)
{
SDBInitVars();
s_usedb = this;
@ -46,6 +49,7 @@ void SharedDatabase::SDBInitVars() {
}
SharedDatabase::~SharedDatabase() {
safe_delete(skill_caps_mmf);
}
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
@ -1519,15 +1523,62 @@ bool SharedDatabase::extDBLoadSkillCaps() {
}
bool SharedDatabase::LoadSkillCaps() {
if (!EMuShareMemDLL.Load())
return false;
uint8 class_count = PLAYER_CLASS_COUNT;
uint8 skill_count = HIGHEST_SKILL+1;
uint8 level_count = HARD_LEVEL_CAP+1;
if(skill_caps_mmf)
return true;
return EMuShareMemDLL.SkillCaps.LoadSkillCaps(&extDBLoadSkillCaps,
sizeof(uint16), class_count, skill_count, level_count);
uint32 class_count = PLAYER_CLASS_COUNT;
uint32 skill_count = HIGHEST_SKILL + 1;
uint32 level_count = HARD_LEVEL_CAP + 1;
uint32 size = (class_count * skill_count * level_count * sizeof(uint16));
try {
EQEmu::IPCMutex mutex("skill_caps");
mutex.Lock();
skill_caps_mmf = new EQEmu::MemoryMappedFile("shared/skill_caps");
if(skill_caps_mmf->Size() != size) {
EQ_EXCEPT("SharedDatabase", "Unable to load skill caps: skill_caps_mmf->Size() != size");
}
mutex.Unlock();
} catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "Error loading skill caps: %s", ex.what());
return false;
}
return true;
}
void SharedDatabase::LoadSkillCaps(void *data) {
uint32 class_count = PLAYER_CLASS_COUNT;
uint32 skill_count = HIGHEST_SKILL + 1;
uint32 level_count = HARD_LEVEL_CAP + 1;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if(RunQuery(query, MakeAnyLenString(&query,
"SELECT skillID, class, level, cap FROM skill_caps ORDER BY skillID, class, level"),
errbuf, &result)) {
safe_delete_array(query);
while((row = mysql_fetch_row(result))) {
uint8 skillID = atoi(row[0]);
uint8 class_ = atoi(row[1]) - 1;
uint8 level = atoi(row[2]);
uint16 cap = atoi(row[3]);
if(skillID >= skill_count || class_ >= class_count || level >= level_count)
continue;
uint32 index = (((class_ * class_count) + skillID) * level_count) + level;
uint16 *skill_caps_table = reinterpret_cast<uint16*>(data);
skill_caps_table[index] = cap;
}
mysql_free_result(result);
} else {
LogFile->write(EQEMuLog::Error, "Error loading skill caps from database: %s", errbuf);
safe_delete_array(query);
}
}
bool SharedDatabase::DBLoadSkillCaps() {
@ -1567,48 +1618,82 @@ bool SharedDatabase::DBLoadSkillCaps() {
}
uint16 SharedDatabase::GetSkillCap(uint8 Class_, SkillType Skill, uint8 Level) {
if(Class_ == 0)
return(0);
int SkillMaxLevel = RuleI(Character, SkillCapMaxLevel);
if (SkillMaxLevel < 1) {
SkillMaxLevel = RuleI(Character, MaxLevel);
}
if(Level > SkillMaxLevel){
return EMuShareMemDLL.SkillCaps.GetSkillCap(Class_-1, Skill, SkillMaxLevel);
}
else{
return EMuShareMemDLL.SkillCaps.GetSkillCap(Class_-1, Skill, Level);
}
if(!skill_caps_mmf) {
return 0;
}
if(Class_ == 0)
return 0;
int SkillMaxLevel = RuleI(Character, SkillCapMaxLevel);
if(SkillMaxLevel < 1) {
SkillMaxLevel = RuleI(Character, MaxLevel);
}
uint32 class_count = PLAYER_CLASS_COUNT;
uint32 skill_count = HIGHEST_SKILL + 1;
uint32 level_count = HARD_LEVEL_CAP + 1;
if(Level > static_cast<uint8>(SkillMaxLevel)){
Level = static_cast<uint8>(SkillMaxLevel);
}
uint32 index = ((((Class_ - 1) * class_count) + Skill) * level_count) + Level;
uint16 *skill_caps_table = reinterpret_cast<uint16*>(skill_caps_mmf->Get());
return skill_caps_table[index];
}
uint8 SharedDatabase::GetTrainLevel(uint8 Class_, SkillType Skill, uint8 Level) {
if(Class_ == 0)
return(0);
if(!skill_caps_mmf) {
return 0;
}
uint8 ret = 0;
int SkillMaxLevel = RuleI(Character, SkillCapMaxLevel);
if (SkillMaxLevel < 1) {
SkillMaxLevel = RuleI(Character, MaxLevel);
}
if(Level > SkillMaxLevel) {
ret = EMuShareMemDLL.SkillCaps.GetTrainLevel(Class_-1, Skill, SkillMaxLevel);
if(Class_ == 0)
return 0;
int SkillMaxLevel = RuleI(Character, SkillCapMaxLevel);
if (SkillMaxLevel < 1) {
SkillMaxLevel = RuleI(Character, MaxLevel);
}
uint32 class_count = PLAYER_CLASS_COUNT;
uint32 skill_count = HIGHEST_SKILL + 1;
uint32 level_count = HARD_LEVEL_CAP + 1;
uint8 ret = 0;
if(Level > static_cast<uint8>(SkillMaxLevel)) {
uint32 index = ((((Class_ - 1) * skill_count) + Skill) * level_count);
uint16 *skill_caps_table = reinterpret_cast<uint16*>(skill_caps_mmf->Get());
for(uint8 x = 0; x < Level; x++){
if(skill_caps_table[index + x]){
ret = x;
break;
}
}
}
else
{
ret = EMuShareMemDLL.SkillCaps.GetTrainLevel(Class_-1, Skill, Level);
uint32 index = ((((Class_ - 1) * skill_count) + Skill) * level_count);
uint16 *skill_caps_table = reinterpret_cast<uint16*>(skill_caps_mmf->Get());
for(int x = 0; x < SkillMaxLevel; x++){
if(skill_caps_table[index + x]){
ret = x;
break;
}
}
}
if(ret > GetSkillCap(Class_, Skill, Level))
ret = GetSkillCap(Class_, Skill, Level);
if(ret > GetSkillCap(Class_, Skill, Level))
ret = GetSkillCap(Class_, Skill, Level);
return ret;
return ret;
}
void SharedDatabase::DBLoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID) {
const char *DSQuery = "SELECT `spellid`, `type` from `damageshieldtypes` WHERE `spellid` > 0 "
"AND `spellid` <= %i";
const char *ERR_MYSQLERROR = "Error in DBLoadDamageShieldTypes: %s %s";
const char *ERR_MYSQLERROR = "Error in LoadDamageShieldTypes: %s %s";
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
@ -1777,10 +1862,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
sp[tempid].base2[y]=atoi(row[32+y]); // effect_limit_value
for(y=0; y< EFFECT_COUNT;y++)
sp[tempid].max[y]=atoi(row[44+y]);
sp[tempid].icon=atoi(row[56]);
sp[tempid].memicon=atoi(row[57]);
for(y=0; y< 4;y++)
sp[tempid].components[y]=atoi(row[58+y]);
@ -1793,7 +1875,6 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
for(y=0; y< EFFECT_COUNT;y++)
sp[tempid].formula[y]=atoi(row[70+y]);
sp[tempid].LightType=atoi(row[82]);
sp[tempid].goodEffect=atoi(row[83]);
sp[tempid].Activated=atoi(row[84]);
sp[tempid].resisttype=atoi(row[85]);
@ -1816,63 +1897,31 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
sp[tempid].classes[y]=atoi(row[104+y]);
sp[tempid].CastingAnim=atoi(row[120]);
sp[tempid].TargetAnim=atoi(row[121]);
sp[tempid].TravelType=atoi(row[122]);
sp[tempid].SpellAffectIndex=atoi(row[123]);
sp[tempid].disallow_sit=atoi(row[124]);
sp[tempid].spacing125=atoi(row[125]);
for (y = 0; y < 16; y++)
sp[tempid].deities[y]=atoi(row[126+y]);
for (y = 0; y < 2; y++)
sp[tempid].spacing142[y]=atoi(row[142+y]);
sp[tempid].new_icon=atoi(row[144]);
sp[tempid].spellanim=atoi(row[145]);
sp[tempid].uninterruptable=atoi(row[146]);
sp[tempid].ResistDiff=atoi(row[147]);
sp[tempid].dot_stacking_exempt=atoi(row[148]);
sp[tempid].deletable=atoi(row[149]);
sp[tempid].RecourseLink = atoi(row[150]);
for(y = 0; y < 3;y++)
sp[tempid].spacing151[y]=atoi(row[151+y]);
sp[tempid].short_buff_box = atoi(row[154]);
sp[tempid].descnum = atoi(row[155]);
sp[tempid].typedescnum = atoi(row[156]);
sp[tempid].effectdescnum = atoi(row[157]);
for(y = 0; y < 4;y++)
sp[tempid].spacing158[y]=atoi(row[158+y]);
sp[tempid].bonushate=atoi(row[162]);
for(y = 0; y < 3;y++)
sp[tempid].spacing163[y]=atoi(row[163+y]);
sp[tempid].EndurCost=atoi(row[166]);
sp[tempid].EndurTimerIndex=atoi(row[167]);
sp[tempid].IsDisciplineBuff=atoi(row[168]);
for(y = 0; y < 4; y++)
sp[tempid].spacing169[y]=atoi(row[169+y]);
sp[tempid].HateAdded=atoi(row[173]);
sp[tempid].EndurUpkeep=atoi(row[174]);
sp[tempid].spacing175=atoi(row[175]);
sp[tempid].numhits = atoi(row[176]);
sp[tempid].pvpresistbase=atoi(row[177]);
sp[tempid].pvpresistcalc=atoi(row[178]);
sp[tempid].pvpresistcap=atoi(row[179]);
sp[tempid].spell_category=atoi(row[180]);
for(y = 0; y < 4;y++)
sp[tempid].spacing181[y]=atoi(row[181+y]);
sp[tempid].can_mgb=atoi(row[185]);
sp[tempid].dispel_flag = atoi(row[186]);
sp[tempid].MinResist = atoi(row[189]);
@ -1883,14 +1932,14 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
sp[tempid].directional_start = (float)atoi(row[194]);
sp[tempid].directional_end = (float)atoi(row[195]);
sp[tempid].spellgroup=atoi(row[207]);
sp[tempid].field209=atoi(row[209]);
sp[tempid].powerful_flag=atoi(row[209]);
sp[tempid].CastRestriction = atoi(row[211]);
sp[tempid].AllowRest = atoi(row[212]) != 0;
sp[tempid].DamageShieldType = 0;
}
mysql_free_result(result);
DBLoadDamageShieldTypes(sp, max_spells);
LoadDamageShieldTypes(sp, max_spells);
} else {
_log(SPELLS__LOAD_ERR, "Error in LoadSpells query '%s' %s", query, errbuf);
safe_delete_array(query);

View File

@ -16,6 +16,9 @@ struct NPCFactionList;
struct Faction;
struct LootTable_Struct;
struct LootDrop_Struct;
namespace EQEmu {
class MemoryMappedFile;
}
/*
* This object is inherited by world and zone's DB object,
@ -94,10 +97,11 @@ public:
bool DBLoadNPCFactionLists(int32 iNPCFactionListCount, uint32 iMaxNPCFactionListID);
bool DBLoadLoot();
bool DBLoadSkillCaps();
void DBLoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID);
int GetMaxSpellID();
void LoadSpells(void *data, int max_spells);
void LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpellID);
void LoadSkillCaps(void *data);
bool LoadSkillCaps();
@ -125,6 +129,7 @@ protected:
uint32 npc_spells_maxid;
EQEmu::MemoryMappedFile *skill_caps_mmf;
private:
static SharedDatabase *s_usedb;
};

View File

@ -18,8 +18,8 @@
#ifndef SPDAT_H
#define SPDAT_H
#include "../common/classes.h"
#include "../common/skills.h"
#include "classes.h"
#include "skills.h"
#define SPELL_UNKNOWN 0xFFFF
#define SPELLBOOK_UNKNOWN 0xFFFFFFFF //player profile spells are 32 bit
@ -603,7 +603,7 @@ typedef enum {
//
struct SPDat_Spell_Struct
{
/* 000 */ int id; // not used
/* 000 */ //int id; // not used
/* 001 */ char name[64]; // Name of the spell
/* 002 */ char player_1[32]; // "PLAYER_1"
/* 003 */ char teleport_zone[64]; // Teleport zone, pet name summoned, or item summoned
@ -623,93 +623,82 @@ struct SPDat_Spell_Struct
/* 017 */ uint32 buffduration;
/* 018 */ uint32 AEDuration; // sentinel, rain of something
/* 019 */ uint16 mana; // Mana Used
/* 020 */ int32 base[EFFECT_COUNT]; //various purposes
/* 032 */ int base2[EFFECT_COUNT]; //various purposes
/* 020 */ int base[EFFECT_COUNT]; //various purposes
/* 032 */ int base2[EFFECT_COUNT]; //various purposes
/* 044 */ int16 max[EFFECT_COUNT];
/* 056 */ uint16 icon; // Spell icon
/* 057 */ uint16 memicon; // Icon on membarthing
/* 056 */ //uint16 icon; // Spell icon
/* 057 */ //uint16 memicon; // Icon on membarthing
/* 058 */ int32 components[4]; // reagents
/* 062 */ int component_counts[4]; // amount of regents used
/* 066 */ signed NoexpendReagent[4]; // focus items (Need but not used; Flame Lick has a Fire Beetle Eye focus.)
/* 066 */ int NoexpendReagent[4]; // focus items (Need but not used; Flame Lick has a Fire Beetle Eye focus.)
// If it is a number between 1-4 it means components[number] is a focus and not to expend it
// If it is a valid itemid it means this item is a focus as well
/* 070 */ uint16 formula[EFFECT_COUNT]; // Spell's value formula
/* 082 */ int LightType; // probaly another effecttype flag
/* 083 */ int goodEffect; //0=detrimental, 1=Beneficial, 2=Beneficial, Group Only
/* 082 */ //int LightType; // probaly another effecttype flag
/* 083 */ int8 goodEffect; //0=detrimental, 1=Beneficial, 2=Beneficial, Group Only
/* 084 */ int Activated; // probaly another effecttype flag
/* 085 */ int resisttype;
/* 086 */ int effectid[EFFECT_COUNT]; // Spell's effects
/* 098 */ SpellTargetType targettype; // Spell's Target
/* 099 */ int basediff; // base difficulty fizzle adjustment
/* 100 */ SkillType skill;
/* 101 */ int16 zonetype; // 01=Outdoors, 02=dungeons, ff=Any
/* 102 */ uint16 EnvironmentType;
/* 103 */ int TimeOfDay;
/* 101 */ int8 zonetype; // 01=Outdoors, 02=dungeons, ff=Any
/* 102 */ int8 EnvironmentType;
/* 103 */ int8 TimeOfDay;
/* 104 */ uint8 classes[PLAYER_CLASS_COUNT]; // Classes, and their min levels
/* 120 */ uint8 CastingAnim;
/* 121 */ uint8 TargetAnim;
/* 122 */ uint32 TravelType;
/* 121 */ //uint8 TargetAnim;
/* 122 */ //uint32 TravelType;
/* 123 */ uint16 SpellAffectIndex;
/* 124 */ int disallow_sit; // 124: high-end Yaulp spells (V, VI, VII, VIII [Rk 1, 2, & 3], & Gallenite's Bark of Fury
/* 125 */ int spacing125; // 125: Words of the Skeptic
/* 124 */ int8 disallow_sit; // 124: high-end Yaulp spells (V, VI, VII, VIII [Rk 1, 2, & 3], & Gallenite's Bark of Fury
/* 125 */ // 125: Words of the Skeptic
/* 126 */ int8 deities[16]; // Deity check. 201 - 216 per http://www.eqemulator.net/wiki/wikka.php?wakka=DeityList
// -1: Restrict to Deity; 1: Restrict to Deity, but only used on non-Live (Test Server "Blessing of ...") spells; 0: Don't restrict
/* 142 */ int spacing142[2]; // 142: between 0 & 100
/* 142 */ // 142: between 0 & 100
// 143: always set to 0
/* 144 */ int16 new_icon; // Spell icon used by the client in uifiles/default/spells??.tga, both for spell gems & buff window. Looks to depreciate icon & memicon
/* 145 */ int16 spellanim; // Doesn't look like it's the same as #doanim, so not sure what this is
/* 144 */ //int16 new_icon // Spell icon used by the client in uifiles/default/spells??.tga, both for spell gems & buff window. Looks to depreciate icon & memicon
/* 145 */ //int16 spellanim; // Doesn't look like it's the same as #doanim, so not sure what this is
/* 146 */ int8 uninterruptable; // Looks like anything != 0 is uninterruptable. Values are mostly -1, 0, & 1 (Fetid Breath = 90?)
/* 147 */ int16 ResistDiff;
/* 148 */ int dot_stacking_exempt;
/* 149 */ int deletable;
/* 150 */ uint16 RecourseLink;
/* 151 */ int spacing151[3]; // 151: -1, 0, or 1
/* 148 */ //int dot_stacking_exempt;
/* 149 */ //int deletable;
/* 150 */ uint16 RecourseLink;
/* 151 */ // 151: -1, 0, or 1
// 152 & 153: all set to 0
/* 154 */ int8 short_buff_box; // != 0, goes to short buff box. Not really supported in the server code
/* 154 */ int8 short_buff_box; // != 0, goes to short buff box.
/* 155 */ int descnum; // eqstr of description of spell
/* 156 */ int typedescnum; // eqstr of type description
/* 156 */ //int typedescnum; // eqstr of type description
/* 157 */ int effectdescnum; // eqstr of effect description
/* 158 */ int spacing158[4];
/* 158 */
/* 162 */ int bonushate;
/* 163 */ int spacing163[3];
/* 163 */
/* 166 */ int EndurCost;
/* 167 */ int EndurTimerIndex;
/* 168 */ int IsDisciplineBuff; //Will goto the combat window when cast
/* 169 */ int spacing169[4];
/* 167 */ int8 EndurTimerIndex;
/* 168 */ //int IsDisciplineBuff; //Will goto the combat window when cast
/* 169 */
/* 173 */ int HateAdded;
/* 174 */ int EndurUpkeep;
/* 175 */ int spacing175;
/* 175 */
/* 176 */ int numhits;
/* 177 */ int pvpresistbase;
/* 178 */ int pvpresistcalc;
/* 179 */ int pvpresistcap;
/* 180 */ int spell_category;
/* 181 */ int spacing181[4];
/* 185 */ int can_mgb; // 0=no, -1 or 1 = yes
/* 181 */
/* 185 */ int8 can_mgb; // 0=no, -1 or 1 = yes
/* 186 */ int dispel_flag;
/* 189 */ int MinResist;
/* 190 */ int MaxResist;
/* 191 */ int viral_targets;
/* 192 */ int viral_timer;
/* 191 */ uint8 viral_targets;
/* 192 */ uint8 viral_timer;
/* 193 */ int NimbusEffect;
/* 194 */ float directional_start;
/* 195 */ float directional_end;
/* 207 */ int spellgroup;
/* 209 */ int field209; // Need more investigation to figure out what to call this, for now we know -1 makes charm spells not break before their duration is complete, it does alot more though
/* 209 */ int powerful_flag; // Need more investigation to figure out what to call this, for now we know -1 makes charm spells not break before their duration is complete, it does alot more though
/* 211 */ int CastRestriction; //Various restriction categories for spells most seem targetable race related but have also seen others for instance only castable if target hp 20% or lower or only if target out of combat
/* 212 */ bool AllowRest;
/* 219 */ int maxtargets; // not in DB yet, is used for beam and ring spells for target # limits
//shared memory errors
/* 186 */ /*int8 nodispell;*/ // 0=can be dispelled, -1=can't be dispelled at all, 1=most can be cancelled w/ a cure but not dispelled
/* 187 */ /*uint8 npc_category;*/ // 0=not used, 1=AoE Detrimental, 2=DD, 3=Buffs, 4=Pets, 5=Healing, 6=Gate, 7=Debuff, 8=Dispell
/* 188 */ /*uint32 npc_usefulness;*/ // higher number = more useful, lower number = less useful
/* 189 */ /*int spacing189[18];*/
/* 207 */ /*uint32 spellgroup;*/
/* 208 */ /*int spacing208[7];*/
// Might be newer fields in the live version, which is what some of the last fields are
/* 219 */ //int maxtargets; // not in DB yet, is used for beam and ring spells for target # limits
uint8 DamageShieldType; // This field does not exist in spells_us.txt
};

View File

@ -3,10 +3,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(shared_memory_sources
main.cpp
spells.cpp
skill_caps.cpp
)
SET(shared_memory_headers
spells.h
skill_caps.h
)
ADD_EXECUTABLE(shared_memory ${shared_memory_sources} ${shared_memory_headers})

View File

@ -25,6 +25,7 @@
#include "../common/rulesys.h"
#include "../common/eqemu_exception.h"
#include "spells.h"
#include "skill_caps.h"
//blah global variables =(
RuleManager *rules = new RuleManager();
@ -55,6 +56,8 @@ int main(int argc, char **argv) {
bool load_all = true;
bool load_spells = true;
bool load_skill_caps = true;
if(load_all || load_spells) {
LogFile->write(EQEMuLog::Status, "Loading spells...");
try {
@ -64,6 +67,16 @@ int main(int argc, char **argv) {
return 0;
}
}
if(load_all || load_skill_caps) {
LogFile->write(EQEMuLog::Status, "Loading skill caps...");
try {
LoadSkillCaps(&database);
} catch(std::exception &ex) {
LogFile->write(EQEMuLog::Error, "%s", ex.what());
return 0;
}
}
return 0;
}

View File

@ -0,0 +1,45 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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
*/
#include "skill_caps.h"
#include "../common/debug.h"
#include "../common/shareddb.h"
#include "../common/ipc_mutex.h"
#include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h"
#include "../common/spdat.h"
#include "../common/classes.h"
#include "../common/features.h"
void LoadSkillCaps(SharedDatabase *database) {
EQEmu::IPCMutex mutex("skill_caps");
mutex.Lock();
uint32 class_count = PLAYER_CLASS_COUNT;
uint32 skill_count = HIGHEST_SKILL + 1;
uint32 level_count = HARD_LEVEL_CAP + 1;
uint32 size = (class_count * skill_count * level_count * sizeof(uint16));
EQEmu::MemoryMappedFile mmf("shared/skill_caps", size);
mmf.ZeroFile();
void *ptr = mmf.Get();
database->LoadSkillCaps(ptr);
mmf.SetLoaded();
mutex.Unlock();
}

View File

@ -0,0 +1,25 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
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
*/
#ifndef __EQEMU_SHARED_MEMORY_SKILL_CAPS_H
#define __EQEMU_SHARED_MEMORY_SKILL_CAPS_H
class SharedDatabase;
void LoadSkillCaps(SharedDatabase *database);
#endif

View File

@ -27,11 +27,10 @@
void LoadSpells(SharedDatabase *database) {
EQEmu::IPCMutex mutex("spells");
mutex.Lock();
int records = database->GetMaxSpellID();
if(records == -1) {
EQ_EXCEPT("Shared Memory", "Unable to get maximum number of spells from the database.");
int records = database->GetMaxSpellID() + 1;
if(records == 0) {
EQ_EXCEPT("Shared Memory", "Unable to get any spells from the database.");
}
++records;
uint32 size = records * sizeof(SPDat_Spell_Struct);
EQEmu::MemoryMappedFile mmf("shared/spells", size);

View File

@ -106,7 +106,6 @@ SET(zone_headers
errmsg.h
event_codes.h
faction.h
features.h
forage.h
groups.h
guild_mgr.h

View File

@ -32,7 +32,7 @@ using namespace std;
#include "StringIDs.h"
#include "../common/MiscFunctions.h"
#include "../common/rulesys.h"
#include "features.h"
#include "../common/features.h"
#include "QuestParserCollection.h"
#include "watermap.h"

View File

@ -25,7 +25,7 @@
#include "../common/packet_functions.h"
#include "../common/packet_dump.h"
#include "../common/MiscFunctions.h"
#include "features.h"
#include "../common/features.h"
#include "StringIDs.h"
using namespace std;

View File

@ -4,7 +4,7 @@
#include "QuestInterface.h"
#include "zone.h"
#include "zonedb.h"
#include "features.h"
#include "../common/features.h"
#include <stdio.h>
#include <stdlib.h>

View File

@ -1441,7 +1441,7 @@ bool Mob::PassCharismaCheck(Mob* caster, Mob* spellTarget, uint16 spell_id) {
if(IsCharmSpell(spell_id)) {
if (spells[spell_id].field209 == -1) //If charm spell has this set(-1), it can not break till end of duration.
if (spells[spell_id].powerful_flag == -1) //If charm spell has this set(-1), it can not break till end of duration.
return true;
//1: The mob has a default 25% chance of being allowed a resistance check against the charm.

View File

@ -45,7 +45,7 @@ using namespace std;
extern volatile bool RunLoops;
#include "features.h"
#include "../common/features.h"
#include "masterentity.h"
#include "worldserver.h"
#include "../common/misc.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#ifdef CLIENT_LOGS
#include "client_logs.h"

View File

@ -19,7 +19,7 @@
#ifndef CLIENT_LOGS_H
#define CLIENT_LOGS_H
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#ifdef CLIENT_LOGS
#include "../common/eq_packet_structs.h"

View File

@ -56,7 +56,7 @@
#include "masterentity.h"
#include "map.h"
#include "watermap.h"
#include "features.h"
#include "../common/features.h"
#include "pathing.h"
#include "client_logs.h"
#include "guild_mgr.h"
@ -4285,13 +4285,10 @@ void command_spellinfo(Client *c, const Seperator *sep)
c->Message(0, " base[12]: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", s->base[0], s->base[1], s->base[2], s->base[3], s->base[4], s->base[5], s->base[6], s->base[7], s->base[8], s->base[9], s->base[10], s->base[11]);
c->Message(0, " base22[12]: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", s->base2[0], s->base2[1], s->base2[2], s->base2[3], s->base2[4], s->base2[5], s->base2[6], s->base2[7], s->base2[8], s->base2[9], s->base2[10], s->base2[11]);
c->Message(0, " max[12]: %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d", s->max[0], s->max[1], s->max[2], s->max[3], s->max[4], s->max[5], s->max[6], s->max[7], s->max[8], s->max[9], s->max[10], s->max[11]);
c->Message(0, " icon: %d", s->icon);
c->Message(0, " memicon: %d", s->memicon);
c->Message(0, " components[4]: %d, %d, %d, %d", s->components[0], s->components[1], s->components[2], s->components[3]);
c->Message(0, " component_counts[4]: %d, %d, %d, %d", s->component_counts[0], s->component_counts[1], s->component_counts[2], s->component_counts[3]);
c->Message(0, " NoexpendReagent[4]: %d, %d, %d, %d", s->NoexpendReagent[0], s->NoexpendReagent[1], s->NoexpendReagent[2], s->NoexpendReagent[3]);
c->Message(0, " formula[12]: 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x", s->formula[0], s->formula[1], s->formula[2], s->formula[3], s->formula[4], s->formula[5], s->formula[6], s->formula[7], s->formula[8], s->formula[9], s->formula[10], s->formula[11]);
c->Message(0, " LightType: %d", s->LightType);
c->Message(0, " goodEffect: %d", s->goodEffect);
c->Message(0, " Activated: %d", s->Activated);
c->Message(0, " resisttype: %d", s->resisttype);
@ -4307,7 +4304,6 @@ void command_spellinfo(Client *c, const Seperator *sep)
s->classes[5], s->classes[6], s->classes[7], s->classes[8], s->classes[9],
s->classes[10], s->classes[11], s->classes[12], s->classes[13], s->classes[14]);
c->Message(0, " CastingAnim: %d", s->CastingAnim);
c->Message(0, " TargetAnim: %d", s->TargetAnim);
c->Message(0, " SpellAffectIndex: %d", s->SpellAffectIndex);
c->Message(0, " RecourseLink: %d", s->RecourseLink);
}

View File

@ -25,7 +25,7 @@
#include "../common/debug.h"
#include "masterentity.h"
#include "features.h"
#include "../common/features.h"
#include "embparser.h"
#include "questmgr.h"
#include "command.h"

View File

@ -9,7 +9,7 @@
#include "client.h"
#include "parser.h"
#include "embperl.h"
#include "features.h"
#include "../common/features.h"
#include "QuestParserCollection.h"
#include "QuestInterface.h"

View File

@ -16,7 +16,7 @@ Eglin
#include <vector>
#include "embperl.h"
#include "embxs.h"
#include "features.h"
#include "../common/features.h"
#ifndef GvCV_set
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
#endif

View File

@ -40,7 +40,7 @@ using namespace std;
#include "../common/packet_functions.h"
#include "petitions.h"
#include "../common/spdat.h"
#include "features.h"
#include "../common/features.h"
#include "StringIDs.h"
#include "parser.h"
#include "../common/dbasync.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#include "masterentity.h"
#include "StringIDs.h"
#include "../common/MiscFunctions.h"

View File

@ -19,7 +19,7 @@
#define FACTION_H
#include "../common/types.h"
#include "features.h"
#include "../common/features.h"
#include <map>
#include <string>

View File

@ -24,7 +24,7 @@
#include "../common/eq_packet_structs.h"
#include "entity.h"
#include "mob.h"
#include "features.h"
#include "../common/features.h"
#include "../common/servertalk.h"
#define MAX_MARKED_NPCS 3

View File

@ -18,7 +18,7 @@
#ifndef MOB_H
#define MOB_H
#include "features.h"
#include "../common/features.h"
#include "common.h"
#include "entity.h"
#include "hate_list.h"

View File

@ -17,7 +17,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#include <iostream>
using namespace std;
#include <string.h>
@ -599,15 +599,6 @@ NetConnection::~NetConnection() {
if (WorldAddress != 0)
safe_delete_array(WorldAddress);
}
bool chrcmpI(const char* a, const char* b) {
#if EQDEBUG >= 11
_log(EQEMuLog::Debug, "crhcmpl() a:%i b:%i", (int*) a, (int*) b);
#endif
if(((int)* a)==((int)* b))
return false;
else
return true;
}
void LoadSpells(EQEmu::MemoryMappedFile **mmf) {
int records = database.GetMaxSpellID() + 1;
@ -618,7 +609,7 @@ void LoadSpells(EQEmu::MemoryMappedFile **mmf) {
*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)");
EQ_EXCEPT("Zone", "Unable to load spells: (*mmf)->Size() != records * sizeof(SPDat_Spell_Struct)");
}
spells = reinterpret_cast<SPDat_Spell_Struct*>((*mmf)->Get());
@ -658,59 +649,3 @@ void UpdateWindowTitle(char* iNewTitle) {
#endif
}
/*bool ZoneBootup(uint32 iZoneID, bool iStaticZone) {
const char* zonename = database.GetZoneName(iStaticZone);
if (iZoneID == 0 || zonename == 0)
return false;
if (zone != 0 || ZoneLoaded) {
cerr << "Error: Zone::Bootup call when zone already booted!" << endl;
worldserver.SetZone(0);
return false;
}
numclients = 0;
zone = new Zone(iZoneID, zonename, net.GetZoneAddress(), net.GetZonePort());
if (!zone->Init(iStaticZone)) {
safe_delete(zone);
cerr << "Zone->Init failed" << endl;
worldserver.SetZone(0);
return false;
}
if (!eqns.Open(net.GetZonePort())) {
safe_delete(zone);
cerr << "NetConnection::Init failed" << endl;
worldserver.SetZone(0);
return false;
}
if (!zone->LoadZoneCFG(zone->GetShortName(), true)) // try loading the zone name...
zone->LoadZoneCFG(zone->GetFileName()); // if that fails, try the file name, then load defaults
//petition_list.ClearPetitions();
//petition_list.ReadDatabase();
ZoneLoaded = true;
worldserver.SetZone(iZoneID);
zone->GetTimeSync();
cout << "-----------" << endl << "Zone server '" << zonename << "' listening on port:" << net.GetZonePort() << endl << "-----------" << endl;
//entity_list.WriteEntityIDs();
UpdateWindowTitle();
return true;
}*/
// Original source found at http://www.castaglia.org/proftpd/doc/devel-guide/src/lib/strsep.c.html
char *strsep(char **stringp, const char *delim)
{
char *res;
if(!stringp || !*stringp || !**stringp)
return (char*)0;
res = *stringp;
while(**stringp && !strchr(delim,**stringp))
(*stringp)++;
if(**stringp) {
**stringp = '\0';
(*stringp)++;
}
return res;
}

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include <list>

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#include "client.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#include "client.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"

View File

@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL_XS_CLASSES
#include "../common/debug.h"
#include "embperl.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "features.h"
#include "../common/features.h"
#ifdef EMBPERL
#ifdef EMBPERL_XS

View File

@ -741,7 +741,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
// define spells with fixed duration
// charm spells with -1 in field 209 are all of fixed duration, so lets use that instead of spell_ids
if(spells[spell_id].field209 == -1)
if(spells[spell_id].powerful_flag == -1)
bBreak = true;
if (!bBreak)

View File

@ -30,7 +30,7 @@ Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net)
#include "../common/MiscFunctions.h"
#include "../common/rulesys.h"
#include "masterentity.h"
#include "features.h"
#include "../common/features.h"
#include "QuestParserCollection.h"

View File

@ -17,7 +17,7 @@
*/
#include "../common/debug.h"
#include "../common/eq_packet_structs.h"
#include "features.h"
#include "../common/features.h"
#include "masterentity.h"
#include "../common/packet_dump.h"
#include "../common/MiscFunctions.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#ifdef PACKET_UPDATE_MANAGER
#include "updatemgr.h"

View File

@ -18,7 +18,7 @@
#ifndef UPDATE_MANAGER_H
#define UPDATE_MANAGER_H
#include "features.h"
#include "../common/features.h"
#ifdef PACKET_UPDATE_MANAGER
#include "../common/timer.h"

View File

@ -33,7 +33,7 @@ using namespace std;
#include "StringIDs.h"
#include "../common/MiscFunctions.h"
#include "../common/rulesys.h"
#include "features.h"
#include "../common/features.h"
#include "QuestParserCollection.h"
struct wp_distance

View File

@ -35,7 +35,7 @@ using namespace std;
#endif
#include "masterentity.h"
#include "features.h"
#include "../common/features.h"
#include "spawngroup.h"
#include "spawn2.h"
#include "zone.h"

View File

@ -25,7 +25,7 @@
#include "../common/servertalk.h"
#include "../common/rulesys.h"
#include "../common/eq_packet_structs.h"
#include "features.h"
#include "../common/features.h"
#include "spawngroup.h"
//#include "mob.h"
#include "zonedump.h"

View File

@ -16,7 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "features.h"
#include "../common/features.h"
#ifdef EQPROFILE
#include "zone_profile.h"

View File

@ -19,7 +19,7 @@
#define ZONE_PROFILE_H
#ifdef ZONE //only possibly profile if we are building zone
#include "features.h"
#include "../common/features.h"
#endif
#ifdef EQPROFILE