Fix for luabind not compiling (jumbers), bunch of api upgrades for lua, changed where spells and items load quests from, removed some old code. etc etc.

This commit is contained in:
KimLS
2013-06-22 01:32:41 -07:00
parent 7af04798fb
commit 2529a7700e
42 changed files with 426 additions and 859 deletions
-2
View File
@@ -104,7 +104,6 @@ SET(zone_sources
trading.cpp
trap.cpp
tribute.cpp
updatemgr.cpp
watermap.cpp
waypoints.cpp
worldserver.cpp
@@ -187,7 +186,6 @@ SET(zone_headers
tasks.h
titles.h
trap.h
updatemgr.h
watermap.h
worldserver.h
zone.h
+97 -7
View File
@@ -732,8 +732,10 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
iter++;
}
//second look for /quests/spells/spell_id.ext (precedence)
filename = "quests/spells/";
//second look for /quests/global/spells/spell_id.ext (precedence)
filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY;
filename += "/spells/";
filename += itoa(spell_id);
iter = _load_precedence.begin();
@@ -750,7 +752,49 @@ QuestInterface *QuestParserCollection::GetQIBySpellQuest(uint32 spell_id, std::s
}
iter++;
}
}
//third look for /quests/zone/spells/default.ext (precedence)
filename = "quests/";
filename += zone->GetShortName();
filename += "/spells/default";
iter = _load_precedence.begin();
while(iter != _load_precedence.end()) {
tmp = filename;
std::map<uint32, std::string>::iterator ext = _extensions.find((*iter)->GetIdentifier());
tmp += ".";
tmp += ext->second;
f = fopen(tmp.c_str(), "r");
if(f) {
fclose(f);
filename = tmp;
return (*iter);
}
iter++;
}
//last look for /quests/global/spells/default.ext (precedence)
filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY;
filename += "/spells/default";
iter = _load_precedence.begin();
while(iter != _load_precedence.end()) {
tmp = filename;
std::map<uint32, std::string>::iterator ext = _extensions.find((*iter)->GetIdentifier());
tmp += ".";
tmp += ext->second;
f = fopen(tmp.c_str(), "r");
if(f) {
fclose(f);
filename = tmp;
return (*iter);
}
iter++;
}
return nullptr;
}
@@ -780,8 +824,10 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
iter++;
}
//second look for /quests/items/item_script.ext (precedence)
filename = "quests/items/";
//second look for /quests/global/items/item_script.ext (precedence)
filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY;
filename += "/items/";
filename += item_script;
iter = _load_precedence.begin();
@@ -800,6 +846,48 @@ QuestInterface *QuestParserCollection::GetQIByItemQuest(std::string item_script,
iter++;
}
//third look for /quests/zone/items/default.ext (precedence)
filename = "quests/";
filename += zone->GetShortName();
filename += "/items/default";
iter = _load_precedence.begin();
while(iter != _load_precedence.end()) {
tmp = filename;
std::map<uint32, std::string>::iterator ext = _extensions.find((*iter)->GetIdentifier());
tmp += ".";
tmp += ext->second;
f = fopen(tmp.c_str(), "r");
if(f) {
fclose(f);
filename = tmp;
return (*iter);
}
iter++;
}
//last look for /quests/global/items/default.ext (precedence)
filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY;
filename += "/items/default";
iter = _load_precedence.begin();
while(iter != _load_precedence.end()) {
tmp = filename;
std::map<uint32, std::string>::iterator ext = _extensions.find((*iter)->GetIdentifier());
tmp += ".";
tmp += ext->second;
f = fopen(tmp.c_str(), "r");
if(f) {
fclose(f);
filename = tmp;
return (*iter);
}
iter++;
}
return nullptr;
}
@@ -828,8 +916,10 @@ QuestInterface *QuestParserCollection::GetQIByEncounterQuest(std::string encount
++iter;
}
//second look for /quests/encounters/encounter_name.ext (precedence)
filename = "quests/encounters/";
//second look for /quests/global/encounters/encounter_name.ext (precedence)
filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY;
filename += "/encounters/";
filename += encounter_name;
iter = _load_precedence.begin();
+18 -22
View File
@@ -2432,19 +2432,18 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
bool changed = false;
int i;
for (i = slot_x; i < slot_y; i++) {
const ItemInst* inst = m_inv[i];
ItemInst* inst = m_inv.GetItem(i);
if(inst == 0)
continue;
bool update_slot = false;
if(inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)inst;
uint16 oldexp = e_inst->GetExp();
parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0);
uint16 oldexp = inst->GetExp();
parse->EventItem(EVENT_SCALE_CALC, this, inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
e_inst->ScaleItem();
if (inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
inst->ScaleItem();
changed = true;
update_slot = true;
}
@@ -2459,13 +2458,12 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
if(a_inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)a_inst;
uint16 oldexp = e_inst->GetExp();
parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0);
uint16 oldexp = a_inst->GetExp();
parse->EventItem(EVENT_SCALE_CALC, this, a_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp)
if (a_inst->GetExp() != oldexp)
{
e_inst->ScaleItem();
a_inst->ScaleItem();
changed = true;
update_slot = true;
}
@@ -2518,16 +2516,15 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
bool update_slot = false;
if(inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)inst;
uint16 oldexp = e_inst->GetExp();
uint16 oldexp = inst->GetExp();
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, inst, nullptr, "", 0);
if(i < 22 || i == 9999) {
parse->EventItem(EVENT_EQUIP_ITEM, this, e_inst, nullptr, "", i);
parse->EventItem(EVENT_EQUIP_ITEM, this, inst, nullptr, "", i);
}
if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
e_inst->ScaleItem();
if (inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
inst->ScaleItem();
changed = true;
update_slot = true;
}
@@ -2548,14 +2545,13 @@ bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
if(a_inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)a_inst;
uint16 oldexp = e_inst->GetExp();
uint16 oldexp = a_inst->GetExp();
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, a_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp)
if (a_inst->GetExp() != oldexp)
{
e_inst->ScaleItem();
a_inst->ScaleItem();
changed = true;
update_slot = true;
}
+9 -3
View File
@@ -146,9 +146,6 @@ Client::Client(EQStreamInterface* ieqs)
scanarea_timer(AIClientScanarea_delay),
#endif
tribute_timer(Tribute_duration),
#ifdef PACKET_UPDATE_MANAGER
update_manager(ieqs),
#endif
proximity_timer(ClientProximity_interval),
TaskPeriodic_Timer(RuleI(TaskSystem, PeriodicCheckTimer) * 1000),
charm_update_timer(6000),
@@ -7828,3 +7825,12 @@ void Client::IncrementAA(int aa_id) {
SendAAStats();
CalcBonuses();
}
void Client::SendItemScale(ItemInst *inst) {
int slot = m_inv.GetSlotByItemInst(inst);
if(slot != -1) {
inst->ScaleItem();
SendItemPacket(slot, inst, ItemPacketCharmUpdate);
CalcBonuses();
}
}
+1 -8
View File
@@ -44,7 +44,6 @@ class Client;
#include "merc.h"
#include "zone.h"
#include "AA.h"
#include "updatemgr.h"
#include "questmgr.h"
#include "QGlobals.h"
@@ -838,9 +837,6 @@ public:
void EnableTitle(int titleset);
void RemoveTitle(int titleset);
#ifdef PACKET_UPDATE_MANAGER
inline UpdateManager *GetUpdateManager() { return(&update_manager); }
#endif
void EnteringMessages(Client* client);
void SendRules(Client* client);
std::list<std::string> consent_list;
@@ -1124,6 +1120,7 @@ public:
void TryItemTick(int slot);
void ItemTimerCheck();
void TryItemTimer(int slot);
void SendItemScale(ItemInst *inst);
int16 GetActSTR() { return( std::min(GetMaxSTR(), GetSTR()) ); }
int16 GetActSTA() { return( std::min(GetMaxSTA(), GetSTA()) ); }
@@ -1356,10 +1353,6 @@ private:
#endif
Timer tribute_timer;
#ifdef PACKET_UPDATE_MANAGER
UpdateManager update_manager;
#endif
Timer proximity_timer;
Timer TaskPeriodic_Timer;
Timer charm_update_timer;
-4
View File
@@ -1269,11 +1269,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app)
if (gmhideme)
entity_list.QueueClientsStatus(this,outapp,true,Admin(),250);
else
#ifdef PACKET_UPDATE_MANAGER
entity_list.QueueManaged(this,outapp,true,false);
#else
entity_list.QueueCloseClients(this,outapp,true,300,nullptr,false);
#endif
safe_delete(outapp);
}
-4
View File
@@ -82,10 +82,6 @@ bool Client::Process() {
SendAllPackets();
}
#ifdef PACKET_UPDATE_MANAGER
update_manager.Process();
#endif
if(adventure_request_timer)
{
if(adventure_request_timer->Check())
-145
View File
@@ -1681,124 +1681,6 @@ void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool
}
}
/*
rewrite of all the queue close methods to use the update manager
void EntityList::FilterQueueCloseClients(uint8 filter, uint8 required, Mob* sender, const EQApplicationPacket* app, bool ignore_sender, float dist, Mob* SkipThisMob, bool ackreq){
if(dist <= 0) {
dist = 600;
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket* tmp_app = app->Copy();
#else
float dist2 = dist * dist; //pow(dist, 2);
#endif
LinkedListIterator<Client*> iterator(client_list);
iterator.Reset();
while(iterator.MoreElements()) {
Client* ent = iterator.GetData();
uint8 filterval=ent->GetFilter(filter);
if(required==0)
required=1;
if(filterval==required){
if ((!ignore_sender || ent != sender) && (ent != SkipThisMob)
) {
#ifdef PACKET_UPDATE_MANAGER
if(ent->Connected()) {
ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender));
}
#else
if(ent->Connected() && (ent->DistNoRoot(*sender) <= dist2 || dist == 0)) {
ent->QueuePacket(app, ackreq);
}
#endif
}
}
iterator.Advance();
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket::PacketUsed(&tmp_app);
#endif
}
void EntityList::QueueCloseClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, float dist, Mob* SkipThisMob, bool ackreq,uint8 filter) {
if (sender == 0) {
QueueClients(sender, app, ignore_sender);
return;
}
if(dist <= 0) {
dist = 600;
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket* tmp_app = app->Copy();
#else
float dist2 = dist * dist; //pow(dist, 2);
#endif
LinkedListIterator<Client*> iterator(client_list);
iterator.Reset();
while(iterator.MoreElements()) {
Client* ent = iterator.GetData();
if ((!ignore_sender || ent != sender) && (ent != SkipThisMob)) {
uint8 filter2=ent->GetFilter(filter);
if(ent->Connected() &&
(filter==0 || (filter2==1 ||
(filter2==99 && entity_list.GetGroupByClient(ent)!=0 &&
entity_list.GetGroupByClient(ent)->IsGroupMember(sender))
|| (filter2==98 && ent==sender)))
#ifdef PACKET_UPDATE_MANAGER
) {
ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender));
}
#else
&& (ent->DistNoRoot(*sender) <= dist2 || dist == 0)) {
ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
}
#endif
}
iterator.Advance();
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket::PacketUsed(&tmp_app);
#endif
}
void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
LinkedListIterator<Client*> iterator(client_list);
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket* tmp_app = app->Copy();
#endif
iterator.Reset();
while(iterator.MoreElements())
{
Client* ent = iterator.GetData();
if ((!ignore_sender || ent != sender))
{
#ifdef PACKET_UPDATE_MANAGER
ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender));
#else
ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
#endif
}
iterator.Advance();
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket::PacketUsed(&tmp_app);
#endif
}
*/
/*
void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
LinkedListIterator<Client*> iterator(client_list);
@@ -1813,33 +1695,6 @@ void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool
}
iterator.Advance();
}
}*/
void EntityList::QueueManaged(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
LinkedListIterator<Client*> iterator(client_list);
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket* tmp_app = app->Copy();
#endif
iterator.Reset();
while(iterator.MoreElements())
{
Client* ent = iterator.GetData();
if ((!ignore_sender || ent != sender))
{
#ifdef PACKET_UPDATE_MANAGER
ent->GetUpdateManager()->QueuePacket(tmp_app, ackreq, sender, ent->DistNoRoot(*sender));
#else
ent->QueuePacket(app, ackreq, Client::CLIENT_CONNECTED);
#endif
}
iterator.Advance();
}
#ifdef PACKET_UPDATE_MANAGER
EQApplicationPacket::PacketUsed(&tmp_app);
#endif
}
+7 -1
View File
@@ -1173,6 +1173,11 @@ Lua_Inventory Lua_Client::GetInventory() {
return &self->GetInv();
}
void Lua_Client::SendItemScale(Lua_ItemInst inst) {
Lua_Safe_Call_Void();
self->SendItemScale(inst);
}
luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@@ -1406,7 +1411,8 @@ luabind::scope lua_register_client() {
.def("GetRaid", (Lua_Raid(Lua_Client::*)(void))&Lua_Client::GetRaid)
.def("PutItemInInventory", (bool(Lua_Client::*)(int,Lua_ItemInst))&Lua_Client::PutItemInInventory)
.def("PushItemOnCursor", (bool(Lua_Client::*)(Lua_ItemInst))&Lua_Client::PushItemOnCursor)
.def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory);
.def("GetInventory", (Lua_Inventory(Lua_Client::*)(void))&Lua_Client::GetInventory)
.def("SendItemScale", (void(Lua_Client::*)(Lua_ItemInst))&Lua_Client::SendItemScale);
}
luabind::scope lua_register_inventory_where() {
+2 -1
View File
@@ -21,7 +21,7 @@ class Lua_Client : public Lua_Mob
typedef Client NativeType;
public:
Lua_Client() { SetLuaPtrData(nullptr); }
Lua_Client(Client *d) { SetLuaPtrData(d); }
Lua_Client(Client *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_Client() { }
operator Client*() {
@@ -261,6 +261,7 @@ public:
bool PutItemInInventory(int slot_id, Lua_ItemInst inst);
bool PushItemOnCursor(Lua_ItemInst inst);
Lua_Inventory GetInventory();
void SendItemScale(Lua_ItemInst inst);
};
#endif
+1 -1
View File
@@ -18,7 +18,7 @@ class Lua_Corpse : public Lua_Mob
typedef Corpse NativeType;
public:
Lua_Corpse() { SetLuaPtrData(nullptr); }
Lua_Corpse(Corpse *d) { SetLuaPtrData(d); }
Lua_Corpse(Corpse *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_Corpse() { }
operator Corpse*() {
+1 -1
View File
@@ -17,7 +17,7 @@ class Lua_Door : public Lua_Entity
typedef Doors NativeType;
public:
Lua_Door() { }
Lua_Door(Doors *d) { SetLuaPtrData(d); }
Lua_Door(Doors *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_Door() { }
operator Doors*() {
+1 -1
View File
@@ -21,7 +21,7 @@ namespace luabind {
luabind::scope lua_register_entity();
class Lua_Entity : public Lua_Ptr<void>
class Lua_Entity : public Lua_Ptr<Entity>
{
typedef Entity NativeType;
public:
+1 -1
View File
@@ -32,7 +32,7 @@ luabind::scope lua_register_corpse_list();
luabind::scope lua_register_object_list();
luabind::scope lua_register_door_list();
class Lua_EntityList : public Lua_Ptr<void>
class Lua_EntityList : public Lua_Ptr<EntityList>
{
typedef EntityList NativeType;
public:
+1 -1
View File
@@ -14,7 +14,7 @@ namespace luabind {
luabind::scope lua_register_group();
class Lua_Group : public Lua_Ptr<void>
class Lua_Group : public Lua_Ptr<Group>
{
typedef Group NativeType;
public:
+1 -1
View File
@@ -10,7 +10,7 @@ struct tHateEntry;
luabind::scope lua_register_hate_entry();
luabind::scope lua_register_hate_list();
class Lua_HateEntry : public Lua_Ptr<void>
class Lua_HateEntry : public Lua_Ptr<tHateEntry>
{
typedef tHateEntry NativeType;
public:
+1 -1
View File
@@ -14,7 +14,7 @@ namespace luabind {
luabind::scope lua_register_inventory();
class Lua_Inventory : public Lua_Ptr<void>
class Lua_Inventory : public Lua_Ptr<Inventory>
{
typedef Inventory NativeType;
public:
+1 -1
View File
@@ -12,7 +12,7 @@ namespace luabind {
luabind::scope lua_register_item();
class Lua_Item : public Lua_Ptr<const void>
class Lua_Item : public Lua_Ptr<const Item_Struct>
{
typedef const Item_Struct NativeType;
public:
+14 -39
View File
@@ -63,18 +63,9 @@ Lua_Item Lua_ItemInst::GetItem() {
return Lua_Item(self->GetItem());
}
void Lua_ItemInst::SetItem(Lua_Item item) {
Lua_Safe_Call_Void();
return self->SetItem(item);
}
Lua_Item Lua_ItemInst::GetUnscaledItem(int slot) {
Lua_Safe_Call_Class(Lua_Item);
if(self->IsScaling()) {
const EvoItemInst *ev = reinterpret_cast<const EvoItemInst*>(self);
return Lua_Item(ev->GetUnscaledItem());
}
return Lua_Item(self->GetItem());
return self->GetUnscaledItem();
}
uint32 Lua_ItemInst::GetItemID(int slot) {
@@ -199,53 +190,37 @@ void Lua_ItemInst::DeleteCustomData(std::string identifier) {
void Lua_ItemInst::SetScale(double scale_factor) {
Lua_Safe_Call_Void();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
ev->SetExp(static_cast<uint32>(scale_factor * 10000.0 + 0.5));
}
self->SetExp((int)(scale_factor*10000+.5));
}
void Lua_ItemInst::SetScaling(bool v) {
Lua_Safe_Call_Void();
self->SetScaling(v);
}
uint32 Lua_ItemInst::GetExp() {
Lua_Safe_Call_Int();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
return ev->GetExp();
}
return 0;
return self->GetExp();
}
void Lua_ItemInst::SetExp(uint32 exp) {
Lua_Safe_Call_Void();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
ev->SetExp(exp);
}
self->SetExp(exp);
}
void Lua_ItemInst::AddExp(uint32 exp) {
Lua_Safe_Call_Void();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
ev->AddExp(exp);
}
self->AddExp(exp);
}
int Lua_ItemInst::GetMaxEvolveLvl() {
Lua_Safe_Call_Int();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
return ev->GetMaxEvolveLvl();
}
return 0;
return self->GetMaxEvolveLvl();
}
uint32 Lua_ItemInst::GetKillsNeeded(int current_level) {
Lua_Safe_Call_Int();
if(self->IsScaling()) {
EvoItemInst *ev = reinterpret_cast<EvoItemInst*>(self);
return ev->GetKillsNeeded(current_level);
}
return 0;
return self->GetKillsNeeded(current_level);
}
Lua_ItemInst Lua_ItemInst::Clone() {
@@ -294,7 +269,6 @@ luabind::scope lua_register_iteminst() {
.def("GetID", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetID)
.def("GetItemScriptID", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetItemScriptID)
.def("GetItem", (Lua_Item(Lua_ItemInst::*)(void))&Lua_ItemInst::GetItem)
.def("SetItem", (void(Lua_ItemInst::*)(Lua_Item))&Lua_ItemInst::SetItem)
.def("GetCharges", (int(Lua_ItemInst::*)(void))&Lua_ItemInst::GetCharges)
.def("SetCharges", (void(Lua_ItemInst::*)(int))&Lua_ItemInst::SetCharges)
.def("GetPrice", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetPrice)
@@ -310,7 +284,8 @@ luabind::scope lua_register_iteminst() {
.def("SetCustomData", (void(Lua_ItemInst::*)(std::string,bool))&Lua_ItemInst::SetCustomData)
.def("GetCustomData", (std::string(Lua_ItemInst::*)(std::string))&Lua_ItemInst::GetCustomData)
.def("DeleteCustomData", (void(Lua_ItemInst::*)(std::string))&Lua_ItemInst::DeleteCustomData)
.def("SetScale", (void(Lua_ItemInst::*)(void))&Lua_ItemInst::SetScale)
.def("SetScaling", (void(Lua_ItemInst::*)(bool))&Lua_ItemInst::SetScaling)
.def("SetScale", (void(Lua_ItemInst::*)(double))&Lua_ItemInst::SetScale)
.def("GetExp", (uint32(Lua_ItemInst::*)(void))&Lua_ItemInst::GetExp)
.def("SetExp", (void(Lua_ItemInst::*)(uint32))&Lua_ItemInst::SetExp)
.def("AddExp", (void(Lua_ItemInst::*)(uint32))&Lua_ItemInst::AddExp)
+3 -2
View File
@@ -13,7 +13,7 @@ namespace luabind {
luabind::scope lua_register_iteminst();
class Lua_ItemInst : public Lua_Ptr<void>
class Lua_ItemInst : public Lua_Ptr<ItemInst>
{
typedef ItemInst NativeType;
public:
@@ -22,7 +22,7 @@ public:
Lua_ItemInst() : Lua_Ptr(nullptr), cloned_(false) { }
Lua_ItemInst(ItemInst *d) : Lua_Ptr(d), cloned_(false) { }
Lua_ItemInst(ItemInst *d, bool cloned) : Lua_Ptr(d), cloned_(cloned) { }
virtual ~Lua_ItemInst() { if(cloned_) { void *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } }
virtual ~Lua_ItemInst() { if(cloned_) { ItemInst *ptr = GetLuaPtrData(); if(ptr) { delete ptr; } } }
operator ItemInst*() {
return reinterpret_cast<ItemInst*>(GetLuaPtrData());
@@ -63,6 +63,7 @@ public:
void SetCustomData(std::string identifier, bool value);
std::string GetCustomData(std::string identifier);
void DeleteCustomData(std::string identifier);
void SetScaling(bool v);
void SetScale(double scale_factor);
uint32 GetExp();
void SetExp(uint32 exp);
+2 -1
View File
@@ -21,7 +21,7 @@ class Lua_Mob : public Lua_Entity
typedef Mob NativeType;
public:
Lua_Mob() { SetLuaPtrData(nullptr); }
Lua_Mob(Mob *d) { SetLuaPtrData(d); }
Lua_Mob(Mob *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_Mob() { }
operator Mob*() {
@@ -331,6 +331,7 @@ public:
void SetFlurryChance(int value);
int GetFlurryChance();
int GetSkill(int skill_id);
void CalcBonuses();
};
#endif
+1 -1
View File
@@ -20,7 +20,7 @@ class Lua_NPC : public Lua_Mob
typedef NPC NativeType;
public:
Lua_NPC() { SetLuaPtrData(nullptr); }
Lua_NPC(NPC *d) { SetLuaPtrData(d); }
Lua_NPC(NPC *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_NPC() { }
operator NPC*() {
+1 -1
View File
@@ -17,7 +17,7 @@ class Lua_Object : public Lua_Entity
typedef Object NativeType;
public:
Lua_Object() { SetLuaPtrData(nullptr); }
Lua_Object(Object *d) { SetLuaPtrData(d); }
Lua_Object(Object *d) { SetLuaPtrData(reinterpret_cast<Entity*>(d)); }
virtual ~Lua_Object() { }
operator Object*() {
+2 -2
View File
@@ -186,8 +186,8 @@ LuaParser::LuaParser() {
ItemArgumentDispatch[EVENT_UNEQUIP_ITEM] = handle_item_equip;
ItemArgumentDispatch[EVENT_AUGMENT_ITEM] = handle_item_augment;
ItemArgumentDispatch[EVENT_UNAUGMENT_ITEM] = handle_item_augment;
ItemArgumentDispatch[EVENT_AUGMENT_INSERT] = handle_item_augment_reverse;
ItemArgumentDispatch[EVENT_AUGMENT_REMOVE] = handle_item_augment_reverse;
ItemArgumentDispatch[EVENT_AUGMENT_INSERT] = handle_item_augment_insert;
ItemArgumentDispatch[EVENT_AUGMENT_REMOVE] = handle_item_augment_remove;
SpellArgumentDispatch[EVENT_SPELL_EFFECT_CLIENT] = handle_spell_effect;
SpellArgumentDispatch[EVENT_SPELL_BUFF_TIC_CLIENT] = handle_spell_tic;
+21 -1
View File
@@ -505,14 +505,34 @@ void handle_item_augment(QuestInterface *parse, lua_State* L, Client* client, It
luabind::object l_item_o = luabind::object(L, l_item);
l_item_o.push(L);
lua_setfield(L, -2, "aug");
lua_pushinteger(L, extra_data);
lua_setfield(L, -2, "slot_id");
}
void handle_item_augment_reverse(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
void handle_item_augment_insert(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers) {
Lua_ItemInst l_item(reinterpret_cast<ItemInst*>(extra_pointers->at(0)));
luabind::object l_item_o = luabind::object(L, l_item);
l_item_o.push(L);
lua_setfield(L, -2, "item");
lua_pushinteger(L, extra_data);
lua_setfield(L, -2, "slot_id");
}
void handle_item_augment_remove(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers) {
Lua_ItemInst l_item(reinterpret_cast<ItemInst*>(extra_pointers->at(0)));
luabind::object l_item_o = luabind::object(L, l_item);
l_item_o.push(L);
lua_setfield(L, -2, "item");
lua_pushinteger(L, extra_data);
lua_setfield(L, -2, "slot_id");
lua_pushboolean(L, *reinterpret_cast<bool*>(extra_pointers->at(1)));
lua_setfield(L, -2, "destroyed");
}
void handle_item_null(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
+3 -1
View File
@@ -98,7 +98,9 @@ void handle_item_equip(QuestInterface *parse, lua_State* L, Client* client, Item
std::vector<void*> *extra_pointers);
void handle_item_augment(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers);
void handle_item_augment_reverse(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
void handle_item_augment_insert(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers);
void handle_item_augment_remove(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers);
void handle_item_null(QuestInterface *parse, lua_State* L, Client* client, ItemInst* item, Mob *mob, std::string data, uint32 extra_data,
std::vector<void*> *extra_pointers);
+1 -1
View File
@@ -14,7 +14,7 @@ namespace luabind {
luabind::scope lua_register_raid();
class Lua_Raid : public Lua_Ptr<void>
class Lua_Raid : public Lua_Ptr<Raid>
{
typedef Raid NativeType;
public:
+1 -1
View File
@@ -12,7 +12,7 @@ namespace luabind {
luabind::scope lua_register_spell();
class Lua_Spell : public Lua_Ptr<const void>
class Lua_Spell : public Lua_Ptr<const SPDat_Spell_Struct>
{
typedef const SPDat_Spell_Struct NativeType;
public:
-14
View File
@@ -1075,9 +1075,6 @@ void Mob::SendHPUpdate()
// destructor will free the pBuffer
CreateHPPacket(&hp_app);
#ifdef MANAGE_HP_UPDATES
entity_list.QueueManaged(this, &hp_app, true);
#else
// send to people who have us targeted
entity_list.QueueClientsByTarget(this, &hp_app, false, 0, false, true, BIT_AllClients);
entity_list.QueueClientsByXTarget(this, &hp_app, false);
@@ -1115,7 +1112,6 @@ void Mob::SendHPUpdate()
{
GetPet()->CastToClient()->QueuePacket(&hp_app, false);
}
#endif //MANAGE_HP_PACKETS
// Update the damage state of destructible objects
if(IsNPC() && IsDestructibleObject())
@@ -1195,9 +1191,6 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
}
else
{
#ifdef PACKET_UPDATE_MANAGER
entity_list.QueueManaged(this, app, (iSendToSelf==0),false);
#else
if(move_tic_count == RuleI(Zone, NPCPositonUpdateTicCount))
{
entity_list.QueueClients(this, app, (iSendToSelf==0), false);
@@ -1208,7 +1201,6 @@ void Mob::SendPosUpdate(uint8 iSendToSelf) {
entity_list.QueueCloseClients(this, app, (iSendToSelf==0), 800, nullptr, false);
move_tic_count++;
}
#endif
}
safe_delete(app);
}
@@ -1372,12 +1364,6 @@ void Mob::GMMove(float x, float y, float z, float heading, bool SendUpdate) {
CastToNPC()->SaveGuardSpot(true);
if(SendUpdate)
SendPosition();
//SendPosUpdate(1);
#ifdef PACKET_UPDATE_MANAGER
if(IsClient()) {
CastToClient()->GetUpdateManager()->FlushQueues();
}
#endif
}
void Mob::SendIllusionPacket(uint16 in_race, uint8 in_gender, uint8 in_texture, uint8 in_helmtexture, uint8 in_haircolor, uint8 in_beardcolor, uint8 in_eyecolor1, uint8 in_eyecolor2, uint8 in_hairstyle, uint8 in_luclinface, uint8 in_beard, uint8 in_aa_title, uint32 in_drakkin_heritage, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, float in_size) {
+1 -1
View File
@@ -79,7 +79,7 @@ XS(XS_QuestItem_SetScale)
Mult = (float)SvNV(ST(1));
if(THIS->IsScaling()) {
((EvoItemInst*)THIS)->SetExp((int)(Mult*10000+.5));
THIS->SetExp((int)(Mult*10000+.5));
}
}
XSRETURN_EMPTY;
-9
View File
@@ -3472,15 +3472,6 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob* spelltar, bool reflect, bool use_r
TrySpellTrigger(spelltar, spell_id);
TryApplyEffect(spelltar, spell_id);
if(spell_id == 982) // Cazic Touch, hehe =P
{
char target_name[64];
strcpy(target_name, spelltar->GetCleanName());
strupr(target_name);
Shout("%s!", target_name);
}
if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) {
int32 aggro_amount = CheckAggroAmount(spell_id, isproc);
mlog(SPELLS__CASTING, "Spell %d cast on %s generated %d hate", spell_id, spelltar->GetName(), aggro_amount);
+11 -4
View File
@@ -164,6 +164,8 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
}
else
{
ItemInst *old_aug = nullptr;
const uint32 id = auged_with->GetID();
ItemInst *aug = tobe_auged->GetAugment(in_augment->augment_slot);
if(aug) {
std::vector<void*> args;
@@ -171,15 +173,20 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
parse->EventItem(EVENT_UNAUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
args.assign(1, tobe_auged);
bool destroyed = false;
if(id == 40408 || id == 40409 || id == 40410) {
destroyed = true;
}
args.push_back(&destroyed);
parse->EventItem(EVENT_AUGMENT_REMOVE, user, aug, nullptr, "", slot, &args);
}
ItemInst *old_aug=nullptr;
const uint32 id=auged_with->GetID();
if (id==40408 || id==40409 || id==40410)
if(id == 40408 || id == 40409 || id == 40410)
tobe_auged->DeleteAugment(in_augment->augment_slot);
else
old_aug=tobe_auged->RemoveAugment(in_augment->augment_slot);
old_aug = tobe_auged->RemoveAugment(in_augment->augment_slot);
itemOneToPush = tobe_auged->Clone();
if (old_aug)
-187
View File
@@ -1,187 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 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 "../common/debug.h"
#include "../common/features.h"
#ifdef PACKET_UPDATE_MANAGER
#include "updatemgr.h"
#include "mob.h"
#include "../common/EQStream.h"
//squared distances for each level
//these values are pulled out of my ass, should be tuned some day
const float UpdateManager::level_distances2[UPDATE_LEVELS]
= { 50*50, 250*250, 500*500, 800*800 };
//delay between sending packets in each level, in ms
//its best if they are all multiples of UPDATE_RESOLUTION
//these values are pulled out of my ass, should be tuned some day
const uint32 UpdateManager::level_timers[UPDATE_LEVELS+1] = { UPDATE_RESOLUTION, //.3s
2*UPDATE_RESOLUTION, //.6s
3*UPDATE_RESOLUTION, //.9s
9*UPDATE_RESOLUTION, //~2s
34*UPDATE_RESOLUTION //~10s
};
/*
This system assumes that two packets sent by a mob with the same
opcodes contain the same info at different times, and will prefer
to send only the most recent packet. If this is bad, then this
thing needs a redesign.
*/
//build a unique ID based on opcode and mob id..
#define MakeUpdateID(mob, app) (((mob->GetID())<<12) | (app->GetOpcode()&0xFFF))
UpdateManager::UpdateManager(EQStream *c)
: limiter(UPDATE_RESOLUTION)
{
net = c;
int r;
for(r = 0; r <= UPDATE_LEVELS; r++) {
timers[r] = new Timer(level_timers[r]);
}
}
UpdateManager::~UpdateManager() {
int r;
UMMap::iterator cur,end;
for(r = 0; r <= UPDATE_LEVELS; r++) {
safe_delete(timers[r]);
cur = levels[r].begin();
end = levels[r].end();
for(; cur != end; cur++) {
EQApplicationPacket *tmp = cur->second.app;
EQApplicationPacket::PacketUsed(&tmp);
}
levels[r].clear();
}
}
/*
Puts a packet into its proper spacial queue
*/
void UpdateManager::QueuePacket(EQApplicationPacket *app, bool ack_req, Mob *from, float range2) {
int r = UPDATE_LEVELS;
UMMap *cur = levels;
const float *cur_d = level_distances2;
cur += UPDATE_LEVELS; //move to the end.
cur_d += UPDATE_LEVELS - 1;
//work backwards since mobs are more likely to be further away
for(r = UPDATE_LEVELS; r >= 0; r--, cur--, cur_d--) {
if(range2 < *cur_d)
continue;
//this packet falls into this queue...
uint32 id = MakeUpdateID(from, app);
// if(r < 2)
// net->QueuePacket(app, ack_req);
//LogFile->write(EQEMuLog::Debug, "Queueing packet from %s (0x%.4x) id=0x%x at level %d\n", from->GetName(), app->GetOpcode(), id, r);
app->PacketReferenced();
//reference decrementing is taken care of my UMType destructor
//if anything is overwritten
(*cur)[id] = UMType(app, ack_req);
// (*cur)[id] = UMType(app->Copy(), ack_req);
return;
}
//if we get here, were in trouble...
}
void UpdateManager::Process() {
if(!limiter.Check())
return;
Timer **curt = timers;
int r;
for(r = 0; r <= UPDATE_LEVELS; r++, curt++) {
if(!(*curt)->Check())
continue;
_SendLevel(r);
}
}
void UpdateManager::FlushQueues() {
limiter.Start();
Timer **curt = timers;
int r;
for(r = 0; r <= UPDATE_LEVELS; r++, curt++) {
(*curt)->Start();
_SendLevel(r);
}
}
void UpdateManager::_SendLevel(int level) {
/*LogFile->write(EQEMuLog::Error, "Sending for level %d", level);
if(level > 0)
{
int r;
for(r = 0; r <= UPDATE_LEVELS; r++) {
LogFile->write(EQEMuLog::Error, "Level %d: %d", r, levels[r].size());
}
{
float range2 = 5;
int r = UPDATE_LEVELS;
UMMap *cur = levels;
const float *cur_d = level_distances2;
cur += UPDATE_LEVELS; //move to the end.
cur_d += UPDATE_LEVELS - 1;
//work backwards since mobs are more likely to be further away
for(r = UPDATE_LEVELS; r >= 0; r--, cur--, cur_d--) {
LogFile->write(EQEMuLog::Error, "If they are less than %f away, they dont go in level %d", *cur_d, r);
if(range2 < *cur_d)
continue;
LogFile->write(EQEMuLog::Error, "A mob %f away gets put into level %d", range2, r);
}
}
}*/
UMMap::iterator cur,end;
UMMap *curm;
UMMap *om = levels + level;
cur = om->begin();
end = om->end();
uint32 key;
int r;
while(cur != end) {
key = cur->first;
//relies on fast queue setting .app to null if it eats it
//LogFile->write(EQEMuLog::Debug, "Sending id 0x%x for level %d\n", key, level);
net->FastQueuePacket(&cur->second.app, cur->second.ack);
//EQApplicationPacket::PacketUsed(&cur->second.app);
cur++;
om->erase(key);
//need to clear our any updates in slower levels
//so mobs dont jump backwards from old updates
curm = om + 1;
for(r = level+1; r <= UPDATE_LEVELS; r++, curm++) {
//do we need this count check?
if(curm->count(key) != 0) {
//reference decrementing is taken care of my UMType destructor
EQApplicationPacket *tmp = (*curm)[key].app;
curm->erase(key);
EQApplicationPacket::PacketUsed(&tmp);
}
}
}
}
#endif //PACKET_UPDATE_MANAGER
-89
View File
@@ -1,89 +0,0 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2004 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 UPDATE_MANAGER_H
#define UPDATE_MANAGER_H
#include "../common/features.h"
#ifdef PACKET_UPDATE_MANAGER
#include "../common/timer.h"
#include <map>
/*typedef enum {
updateMobPOS = 1,
updateMobHP
} updateType;*/
//the number of different queue levels to use
#define UPDATE_LEVELS 4
#define UPDATE_RESOLUTION 300
#define UPDATE_DROP_RANGE 800
//if the player moves more than this ammount, all queues are flushed.
#define UPDATE_JUMP_FLUSH 200 //
class EQStream;
class EQApplicationPacket;
class Mob;
class UMType {
public:
UMType() {
app = nullptr; ack = false;
}
UMType(EQApplicationPacket *_app, bool _ack) {
app = _app; ack = _ack;
}
EQApplicationPacket *app;
bool ack;
};
typedef std::map<uint32, UMType > UMMap;
class UpdateManager {
protected:
//squared distances for each level
static const float level_distances2[UPDATE_LEVELS];
//delay between sending packets in each level, in ms
static const uint32 level_timers[UPDATE_LEVELS+1];
public:
UpdateManager(EQStream *c);
~UpdateManager();
//range2 is the range of 'from' to this client, squared
void QueuePacket(EQApplicationPacket *app, bool ack_req, Mob *from, float range2);
void Process();
void FlushQueues();
protected:
void _SendLevel(int level);
EQStream *net;
UMMap levels[UPDATE_LEVELS+1];
Timer *timers[UPDATE_LEVELS+1];
Timer limiter;
};
#endif //PACKET_UPDATE_MANAGER
#endif
-5
View File
@@ -625,11 +625,6 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z
//send out updates to people in zone.
SendPosition();
#ifdef PACKET_UPDATE_MANAGER
//flush our position queues because we dont know where we will end up
update_manager.FlushQueues();
#endif
}
EQApplicationPacket* outapp = new EQApplicationPacket(OP_RequestClientZoneChange, sizeof(RequestClientZoneChange_Struct));