mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-30 22:06:46 +00:00
Redoing event item api
This commit is contained in:
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(common_sources
|
||||
BasePacket.cpp
|
||||
callback_manager.cpp
|
||||
classes.cpp
|
||||
Condition.cpp
|
||||
crash.cpp
|
||||
@@ -93,6 +94,7 @@ SET(common_headers
|
||||
BasePacket.h
|
||||
bodytypes.h
|
||||
breakdowns.h
|
||||
callback_manager.h
|
||||
classes.h
|
||||
common_profile.h
|
||||
Condition.h
|
||||
|
||||
@@ -65,6 +65,7 @@ ItemInst::ItemInst(const Item_Struct* item, int16 charges) {
|
||||
m_color = 0;
|
||||
m_merchantcount = 1;
|
||||
m_SerialNumber = GetNextItemInstSerialNumber();
|
||||
m_on_destroy = GetEQCallback("OnItemInstDestroy");
|
||||
}
|
||||
|
||||
ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
|
||||
@@ -80,6 +81,7 @@ ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
|
||||
m_color = 0;
|
||||
m_merchantcount = 1;
|
||||
m_SerialNumber = GetNextItemInstSerialNumber();
|
||||
m_on_destroy = GetEQCallback("OnItemInstDestroy");
|
||||
}
|
||||
|
||||
ItemInstQueue::~ItemInstQueue() {
|
||||
@@ -170,11 +172,16 @@ ItemInst::ItemInst(const ItemInst& copy)
|
||||
}
|
||||
m_SerialNumber = copy.m_SerialNumber;
|
||||
m_custom_data = copy.m_custom_data;
|
||||
m_on_destroy = copy.m_on_destroy;
|
||||
}
|
||||
|
||||
// Clean up container contents
|
||||
ItemInst::~ItemInst()
|
||||
{
|
||||
if(m_on_destroy) {
|
||||
m_on_destroy(this);
|
||||
}
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
@@ -1677,6 +1684,8 @@ EvoItemInst::EvoItemInst(const EvoItemInst ©) {
|
||||
m_scaledItem = new Item_Struct(*copy.m_scaledItem);
|
||||
else
|
||||
m_scaledItem = nullptr;
|
||||
|
||||
m_on_destroy = GetEQCallback("OnItemInstDestroy");
|
||||
}
|
||||
|
||||
EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
|
||||
@@ -1716,6 +1725,7 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
|
||||
m_activated = false;
|
||||
m_evolveInfo = nullptr;
|
||||
m_scaledItem = nullptr;
|
||||
m_on_destroy = copy->m_on_destroy;
|
||||
}
|
||||
|
||||
EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
|
||||
@@ -1736,9 +1746,13 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
|
||||
m_activated = false;
|
||||
m_evolveInfo = nullptr;
|
||||
m_scaledItem = nullptr;
|
||||
m_on_destroy = GetEQCallback("OnItemInstDestroy");
|
||||
}
|
||||
|
||||
EvoItemInst::~EvoItemInst() {
|
||||
if(m_on_destroy) {
|
||||
m_on_destroy(this);
|
||||
}
|
||||
safe_delete(m_scaledItem);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class EvolveInfo; // Stores information about an evolving item family
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include "../common/eq_constants.h"
|
||||
#include "../common/item_struct.h"
|
||||
#include "callback_manager.h"
|
||||
|
||||
// Helper typedefs
|
||||
typedef std::list<ItemInst*>::const_iterator iter_queue;
|
||||
@@ -265,6 +266,8 @@ public:
|
||||
m_instnodrop = false;
|
||||
m_merchantslot = 0;
|
||||
m_color = 0;
|
||||
|
||||
m_on_destroy = GetEQCallback("OnItemInstDestroy");
|
||||
}
|
||||
|
||||
ItemInst(const ItemInst& copy);
|
||||
@@ -404,6 +407,7 @@ protected:
|
||||
// Items inside of this item (augs or contents);
|
||||
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
|
||||
std::map<std::string, std::string> m_custom_data;
|
||||
eqemu_callback m_on_destroy;
|
||||
};
|
||||
|
||||
class EvoItemInst: public ItemInst {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <map>
|
||||
#include "callback_manager.h"
|
||||
|
||||
std::map<std::string, eqemu_callback> callback_functions;
|
||||
|
||||
void RegisterEQCallback(std::string name, eqemu_callback func) {
|
||||
callback_functions[name] = func;
|
||||
}
|
||||
|
||||
eqemu_callback GetEQCallback(std::string name) {
|
||||
auto iter = callback_functions.find(name);
|
||||
if(iter == callback_functions.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return iter->second;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef EQEMU_CALLBACK_MANAGER_H
|
||||
#define EQEMU_CALLBACK_MANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
typedef std::function<void(void*)> eqemu_callback;
|
||||
|
||||
void RegisterEQCallback(std::string name, eqemu_callback func);
|
||||
eqemu_callback GetEQCallback(std::string name);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user