mirror of
https://github.com/EQEmu/Server.git
synced 2026-10-08 05:23:39 +00:00
Starting rewrite of lua parser in earnest
This commit is contained in:
1 parent
d1aef18974
commit
f40b44a454
63 files changed
+1625
-1770
No files matched your search
+40
-50
@@ -40,30 +40,6 @@ SET(zone_sources
|
||||
horse.cpp
|
||||
inventory.cpp
|
||||
loottables.cpp
|
||||
lua_bit.cpp
|
||||
lua_corpse.cpp
|
||||
lua_client.cpp
|
||||
lua_door.cpp
|
||||
lua_encounter.cpp
|
||||
lua_entity.cpp
|
||||
lua_entity_list.cpp
|
||||
lua_general.cpp
|
||||
lua_group.cpp
|
||||
lua_hate_list.cpp
|
||||
lua_inventory.cpp
|
||||
lua_item.cpp
|
||||
lua_iteminst.cpp
|
||||
lua_mob.cpp
|
||||
lua_mod.cpp
|
||||
lua_npc.cpp
|
||||
lua_object.cpp
|
||||
lua_packet.cpp
|
||||
lua_parser.cpp
|
||||
lua_parser_events.cpp
|
||||
lua_raid.cpp
|
||||
lua_spawn.cpp
|
||||
lua_spell.cpp
|
||||
lua_stat_bonuses.cpp
|
||||
embperl.cpp
|
||||
embxs.cpp
|
||||
entity.cpp
|
||||
@@ -156,7 +132,7 @@ SET(zone_headers
|
||||
command.h
|
||||
common.h
|
||||
corpse.h
|
||||
data_bucket.h
|
||||
data_bucket.h
|
||||
doors.h
|
||||
embparser.h
|
||||
embperl.h
|
||||
@@ -173,31 +149,6 @@ SET(zone_headers
|
||||
hate_list.h
|
||||
heal_rotation.h
|
||||
horse.h
|
||||
lua_bit.h
|
||||
lua_client.h
|
||||
lua_corpse.h
|
||||
lua_door.h
|
||||
lua_encounter.h
|
||||
lua_entity.h
|
||||
lua_entity_list.h
|
||||
lua_general.h
|
||||
lua_group.h
|
||||
lua_hate_list.h
|
||||
lua_inventory.h
|
||||
lua_item.h
|
||||
lua_iteminst.h
|
||||
lua_mob.h
|
||||
lua_mod.h
|
||||
lua_npc.h
|
||||
lua_object.h
|
||||
lua_packet.h
|
||||
lua_parser.h
|
||||
lua_parser_events.h
|
||||
lua_ptr.h
|
||||
lua_raid.h
|
||||
lua_spawn.h
|
||||
lua_spell.h
|
||||
lua_stat_bonuses.h
|
||||
map.h
|
||||
masterentity.h
|
||||
maxskill.h
|
||||
@@ -245,6 +196,45 @@ SET(zone_headers
|
||||
zonedump.h
|
||||
)
|
||||
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
|
||||
SET(zone_sources ${zone_sources}
|
||||
lua/lua_client.cpp
|
||||
lua/lua_corpse.cpp
|
||||
lua/lua_door.cpp
|
||||
lua/lua_entity.cpp
|
||||
lua/lua_npc.cpp
|
||||
lua/lua_mob.cpp
|
||||
lua/lua_object.cpp
|
||||
lua/lua_general.cpp
|
||||
lua/lua_parser.cpp
|
||||
)
|
||||
|
||||
SET(zone_headers ${zone_headers}
|
||||
lua/lua_events.h
|
||||
lua/lua_forward.h
|
||||
lua/lua_parser.h
|
||||
lua/lua_structs.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(lua FILES
|
||||
lua/lua_client.cpp
|
||||
lua/lua_corpse.cpp
|
||||
lua/lua_door.cpp
|
||||
lua/lua_entity.cpp
|
||||
lua/lua_events.h
|
||||
lua/lua_forward.h
|
||||
lua/lua_npc.cpp
|
||||
lua/lua_mob.cpp
|
||||
lua/lua_object.cpp
|
||||
lua/lua_general.cpp
|
||||
lua/lua_parser.cpp
|
||||
lua/lua_parser.h
|
||||
lua/lua_structs.h
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
IF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
ADD_DEFINITIONS(-DDEPOP_INVALIDATES_NPC_TYPES_CACHE)
|
||||
ENDIF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../client.h"
|
||||
|
||||
void lua_register_client(sol::state *state) {
|
||||
state->new_usertype<Client>("Client",
|
||||
sol::base_classes, sol::bases<Mob, Entity>()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../corpse.h"
|
||||
|
||||
void lua_register_corpse(sol::state *state) {
|
||||
state->new_usertype<Corpse>("Corpse",
|
||||
sol::base_classes, sol::bases<Mob, Entity>()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../doors.h"
|
||||
|
||||
void lua_register_doors(sol::state *state) {
|
||||
state->new_usertype<Doors>("Doors",
|
||||
sol::base_classes, sol::bases<Entity>()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <sol.hpp>
|
||||
#include "../entity.h"
|
||||
#include "../client.h"
|
||||
#include "../npc.h"
|
||||
#include "../corpse.h"
|
||||
#include "../doors.h"
|
||||
#include "../object.h"
|
||||
|
||||
void lua_register_entity(sol::state *state) {
|
||||
state->new_usertype<Entity>("Entity",
|
||||
"IsClient", &Entity::IsClient,
|
||||
"IsNPC", &Entity::IsNPC,
|
||||
"IsMob", &Entity::IsMob,
|
||||
"IsMerc", &Entity::IsMerc,
|
||||
"IsCorpse", &Entity::IsCorpse,
|
||||
"IsPlayerCorpse", &Entity::IsPlayerCorpse,
|
||||
"IsNPCCorpse", &Entity::IsNPCCorpse,
|
||||
"IsObject", &Entity::IsObject,
|
||||
"IsDoor", &Entity::IsDoor,
|
||||
"IsTrap", &Entity::IsTrap,
|
||||
"IsBeacon", &Entity::IsBeacon,
|
||||
"IsEncounter", &Entity::IsEncounter,
|
||||
"IsBot", &Entity::IsBot,
|
||||
"IsAura", &Entity::IsAura,
|
||||
"CastToClient", (Client*(Entity::*)())&Entity::CastToClient,
|
||||
"CastToMob", (Mob*(Entity::*)())&Entity::CastToMob,
|
||||
//"CastToMerc", (Merc*(Entity::*)())&Entity::CastToMerc,
|
||||
"CastToCorpse", (Corpse*(Entity::*)())&Entity::CastToCorpse,
|
||||
"CastToObject", (Object*(Entity::*)())&Entity::CastToObject,
|
||||
"CastToDoors", (Doors*(Entity::*)())&Entity::CastToDoors,
|
||||
//"CastToTrap", (Trap*(Entity::*)())&Entity::CastToTrap,
|
||||
//"CastToBeacon", (Beacon*(Entity::*)())&Entity::CastToBeacon,
|
||||
//"CastToEncounter", (Encounter*(Entity::*)())&Entity::CastToEncounter,
|
||||
"GetID", &Entity::GetID,
|
||||
"GetName", &Entity::GetName
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
const char *LuaEvents[_LargestEventID] = {
|
||||
"event_say",
|
||||
"event_trade",
|
||||
"event_death",
|
||||
"event_spawn",
|
||||
"event_attack",
|
||||
"event_combat",
|
||||
"event_aggro",
|
||||
"event_slay",
|
||||
"event_npc_slay",
|
||||
"event_waypoint_arrive",
|
||||
"event_waypoint_depart",
|
||||
"event_timer",
|
||||
"event_signal",
|
||||
"event_hp",
|
||||
"event_enter",
|
||||
"event_exit",
|
||||
"event_enter_zone",
|
||||
"event_click_door",
|
||||
"event_loot",
|
||||
"event_zone",
|
||||
"event_level_up",
|
||||
"event_killed_merit",
|
||||
"event_cast_on",
|
||||
"event_task_accepted",
|
||||
"event_task_stage_complete",
|
||||
"event_task_update",
|
||||
"event_task_complete",
|
||||
"event_task_fail",
|
||||
"event_aggro_say",
|
||||
"event_player_pickup",
|
||||
"event_popup_response",
|
||||
"event_environmental_damage",
|
||||
"event_proximity_say",
|
||||
"event_cast",
|
||||
"event_cast_begin",
|
||||
"event_scale_calc",
|
||||
"event_item_enter_zone",
|
||||
"event_target_change",
|
||||
"event_hate_list",
|
||||
"event_spell_effect",
|
||||
"event_spell_effect",
|
||||
"event_spell_buff_tic",
|
||||
"event_spell_buff_tic",
|
||||
"event_spell_fade",
|
||||
"event_spell_effect_translocate_complete",
|
||||
"event_combine_success",
|
||||
"event_combine_failure",
|
||||
"event_item_click",
|
||||
"event_item_click_cast",
|
||||
"event_group_change",
|
||||
"event_forage_success",
|
||||
"event_forage_failure",
|
||||
"event_fish_start",
|
||||
"event_fish_success",
|
||||
"event_fish_failure",
|
||||
"event_click_object",
|
||||
"event_discover_item",
|
||||
"event_disconnect",
|
||||
"event_connect",
|
||||
"event_item_tick",
|
||||
"event_duel_win",
|
||||
"event_duel_lose",
|
||||
"event_encounter_load",
|
||||
"event_encounter_unload",
|
||||
"event_command",
|
||||
"event_drop_item",
|
||||
"event_destroy_item",
|
||||
"event_feign_death",
|
||||
"event_weapon_proc",
|
||||
"event_equip_item",
|
||||
"event_unequip_item",
|
||||
"event_augment_item",
|
||||
"event_unaugment_item",
|
||||
"event_augment_insert",
|
||||
"event_augment_remove",
|
||||
"event_enter_area",
|
||||
"event_leave_area",
|
||||
"event_respawn",
|
||||
"event_death_complete",
|
||||
"event_unhandled_opcode",
|
||||
"event_tick",
|
||||
"event_spawn_zone",
|
||||
"event_death_zone",
|
||||
"event_use_skill"
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
void lua_register_general(sol::state *state);
|
||||
void lua_register_entity(sol::state *state);
|
||||
void lua_register_mob(sol::state *state);
|
||||
void lua_register_npc(sol::state *state);
|
||||
void lua_register_client(sol::state *state);
|
||||
void lua_register_doors(sol::state *state);
|
||||
void lua_register_corpse(sol::state *state);
|
||||
void lua_register_object(sol::state *state);
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <sol.hpp>
|
||||
|
||||
void lua_register_general(sol::state *state) {
|
||||
auto table = state->create_named_table("eqemu");
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../mob.h"
|
||||
|
||||
void lua_register_mob(sol::state *state) {
|
||||
state->new_usertype<Mob>("Mob",
|
||||
sol::base_classes, sol::bases<Entity>()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../npc.h"
|
||||
|
||||
void lua_register_npc(sol::state *state) {
|
||||
state->new_usertype<NPC>("NPC",
|
||||
sol::base_classes, sol::bases<Mob, Entity>()
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <sol.hpp>
|
||||
#include "../object.h"
|
||||
|
||||
void lua_register_object(sol::state *state) {
|
||||
state->new_usertype<Object>("Object",
|
||||
sol::base_classes, sol::bases<Entity>()
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,20 +1,9 @@
|
||||
#ifndef _EQE_LUA_PARSER_H
|
||||
#define _EQE_LUA_PARSER_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#include "quest_parser_collection.h"
|
||||
#include "quest_interface.h"
|
||||
#pragma once
|
||||
#include "../quest_parser_collection.h"
|
||||
#include "../quest_interface.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
#include <sol_forward.hpp>
|
||||
|
||||
#include "zone_config.h"
|
||||
#include "lua_mod.h"
|
||||
|
||||
extern const ZoneConfig *Config;
|
||||
|
||||
struct lua_State;
|
||||
class Client;
|
||||
class NPC;
|
||||
|
||||
@@ -23,15 +12,6 @@ namespace EQEmu
|
||||
class ItemInstance;
|
||||
}
|
||||
|
||||
#include "lua_parser_events.h"
|
||||
|
||||
struct lua_registered_event;
|
||||
namespace luabind {
|
||||
namespace adl {
|
||||
class object;
|
||||
}
|
||||
}
|
||||
|
||||
class LuaParser : public QuestInterface {
|
||||
public:
|
||||
~LuaParser();
|
||||
@@ -87,7 +67,7 @@ public:
|
||||
return &inst;
|
||||
}
|
||||
|
||||
bool HasFunction(std::string function, std::string package_name);
|
||||
bool HasFunction(const std::string &function, const std::string &package_name);
|
||||
|
||||
//Mod Extensions
|
||||
void MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
|
||||
@@ -102,27 +82,25 @@ public:
|
||||
|
||||
private:
|
||||
LuaParser();
|
||||
LuaParser(const LuaParser&);
|
||||
LuaParser& operator=(const LuaParser&);
|
||||
LuaParser(const LuaParser&) = delete;
|
||||
LuaParser& operator=(const LuaParser&) = delete;
|
||||
|
||||
int _EventNPC(std::string package_name, QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<EQEmu::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
std::vector<EQEmu::Any> *extra_pointers, sol::function *l_func = nullptr);
|
||||
int _EventPlayer(std::string package_name, QuestEventID evt, Client *client, std::string data, uint32 extra_data,
|
||||
std::vector<EQEmu::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
std::vector<EQEmu::Any> *extra_pointers, sol::function *l_func = nullptr);
|
||||
int _EventItem(std::string package_name, QuestEventID evt, Client *client, EQEmu::ItemInstance *item, Mob *mob, std::string data,
|
||||
uint32 extra_data, std::vector<EQEmu::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
uint32 extra_data, std::vector<EQEmu::Any> *extra_pointers, sol::function *l_func = nullptr);
|
||||
int _EventSpell(std::string package_name, QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data,
|
||||
std::vector<EQEmu::Any> *extra_pointers, luabind::adl::object *l_func = nullptr);
|
||||
std::vector<EQEmu::Any> *extra_pointers, sol::function *l_func = nullptr);
|
||||
int _EventEncounter(std::string package_name, QuestEventID evt, std::string encounter_name, std::string data, uint32 extra_data,
|
||||
std::vector<EQEmu::Any> *extra_pointers);
|
||||
|
||||
void LoadScript(std::string filename, std::string package_name);
|
||||
void MapFunctions(lua_State *L);
|
||||
void LoadScript(const std::string &filename);
|
||||
void LoadScript(const std::string &filename, const std::string &package_name);
|
||||
void MapFunctions();
|
||||
QuestEventID ConvertLuaEvent(QuestEventID evt);
|
||||
|
||||
struct Implementation;
|
||||
std::unique_ptr<Implementation> mImpl;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
struct Script
|
||||
{
|
||||
bool Loaded;
|
||||
sol::environment Env;
|
||||
};
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -37,240 +37,240 @@ struct Filters { };
|
||||
struct MessageTypes { };
|
||||
struct Rule { };
|
||||
|
||||
struct lua_registered_event {
|
||||
std::string encounter_name;
|
||||
luabind::adl::object lua_reference;
|
||||
QuestEventID event_id;
|
||||
};
|
||||
|
||||
extern std::map<std::string, std::list<lua_registered_event>> lua_encounter_events_registered;
|
||||
extern std::map<std::string, bool> lua_encounters_loaded;
|
||||
extern std::map<std::string, Encounter *> lua_encounters;
|
||||
|
||||
extern void MapOpcodes();
|
||||
extern void ClearMappedOpcode(EmuOpcode op);
|
||||
|
||||
void unregister_event(std::string package_name, std::string name, int evt);
|
||||
|
||||
void load_encounter(std::string name) {
|
||||
if(lua_encounters_loaded.count(name) > 0)
|
||||
return;
|
||||
auto enc = new Encounter(name.c_str());
|
||||
entity_list.AddEncounter(enc);
|
||||
lua_encounters[name] = enc;
|
||||
lua_encounters_loaded[name] = true;
|
||||
parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, "", 0);
|
||||
}
|
||||
|
||||
void load_encounter_with_data(std::string name, std::string info_str) {
|
||||
if(lua_encounters_loaded.count(name) > 0)
|
||||
return;
|
||||
auto enc = new Encounter(name.c_str());
|
||||
entity_list.AddEncounter(enc);
|
||||
lua_encounters[name] = enc;
|
||||
lua_encounters_loaded[name] = true;
|
||||
std::vector<EQEmu::Any> info_ptrs;
|
||||
info_ptrs.push_back(&info_str);
|
||||
parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, "", 0, &info_ptrs);
|
||||
}
|
||||
|
||||
void unload_encounter(std::string name) {
|
||||
if(lua_encounters_loaded.count(name) == 0)
|
||||
return;
|
||||
|
||||
auto liter = lua_encounter_events_registered.begin();
|
||||
while(liter != lua_encounter_events_registered.end()) {
|
||||
std::list<lua_registered_event> &elist = liter->second;
|
||||
auto iter = elist.begin();
|
||||
while(iter != elist.end()) {
|
||||
if((*iter).encounter_name.compare(name) == 0) {
|
||||
iter = elist.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
if(elist.size() == 0) {
|
||||
lua_encounter_events_registered.erase(liter++);
|
||||
} else {
|
||||
++liter;
|
||||
}
|
||||
}
|
||||
|
||||
lua_encounters[name]->Depop();
|
||||
lua_encounters.erase(name);
|
||||
lua_encounters_loaded.erase(name);
|
||||
parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, "", 0);
|
||||
}
|
||||
|
||||
void unload_encounter_with_data(std::string name, std::string info_str) {
|
||||
if(lua_encounters_loaded.count(name) == 0)
|
||||
return;
|
||||
|
||||
auto liter = lua_encounter_events_registered.begin();
|
||||
while(liter != lua_encounter_events_registered.end()) {
|
||||
std::list<lua_registered_event> &elist = liter->second;
|
||||
auto iter = elist.begin();
|
||||
while(iter != elist.end()) {
|
||||
if((*iter).encounter_name.compare(name) == 0) {
|
||||
iter = elist.erase(iter);
|
||||
}
|
||||
else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
if(elist.size() == 0) {
|
||||
lua_encounter_events_registered.erase(liter++);
|
||||
}
|
||||
else {
|
||||
++liter;
|
||||
}
|
||||
}
|
||||
|
||||
lua_encounters[name]->Depop();
|
||||
lua_encounters.erase(name);
|
||||
lua_encounters_loaded.erase(name);
|
||||
std::vector<EQEmu::Any> info_ptrs;
|
||||
info_ptrs.push_back(&info_str);
|
||||
parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, "", 0, &info_ptrs);
|
||||
}
|
||||
|
||||
void register_event(std::string package_name, std::string name, int evt, luabind::adl::object func) {
|
||||
if(lua_encounters_loaded.count(name) == 0)
|
||||
return;
|
||||
|
||||
unregister_event(package_name, name, evt);
|
||||
|
||||
lua_registered_event e;
|
||||
e.encounter_name = name;
|
||||
e.lua_reference = func;
|
||||
e.event_id = static_cast<QuestEventID>(evt);
|
||||
|
||||
auto liter = lua_encounter_events_registered.find(package_name);
|
||||
if(liter == lua_encounter_events_registered.end()) {
|
||||
std::list<lua_registered_event> elist;
|
||||
elist.push_back(e);
|
||||
lua_encounter_events_registered[package_name] = elist;
|
||||
} else {
|
||||
std::list<lua_registered_event> &elist = liter->second;
|
||||
elist.push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
void unregister_event(std::string package_name, std::string name, int evt) {
|
||||
auto liter = lua_encounter_events_registered.find(package_name);
|
||||
if(liter != lua_encounter_events_registered.end()) {
|
||||
std::list<lua_registered_event> elist = liter->second;
|
||||
auto iter = elist.begin();
|
||||
while(iter != elist.end()) {
|
||||
if(iter->event_id == evt && iter->encounter_name.compare(name) == 0) {
|
||||
iter = elist.erase(iter);
|
||||
break;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
lua_encounter_events_registered[package_name] = elist;
|
||||
}
|
||||
}
|
||||
|
||||
void register_npc_event(std::string name, int evt, int npc_id, luabind::adl::object func) {
|
||||
if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
std::stringstream package_name;
|
||||
package_name << "npc_" << npc_id;
|
||||
|
||||
register_event(package_name.str(), name, evt, func);
|
||||
}
|
||||
}
|
||||
|
||||
void register_npc_event(int evt, int npc_id, luabind::adl::object func) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
register_npc_event(name, evt, npc_id, func);
|
||||
}
|
||||
|
||||
void unregister_npc_event(std::string name, int evt, int npc_id) {
|
||||
std::stringstream package_name;
|
||||
package_name << "npc_" << npc_id;
|
||||
|
||||
unregister_event(package_name.str(), name, evt);
|
||||
}
|
||||
|
||||
void unregister_npc_event(int evt, int npc_id) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
unregister_npc_event(name, evt, npc_id);
|
||||
}
|
||||
|
||||
void register_player_event(std::string name, int evt, luabind::adl::object func) {
|
||||
if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
register_event("player", name, evt, func);
|
||||
}
|
||||
}
|
||||
|
||||
void register_player_event(int evt, luabind::adl::object func) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
register_player_event(name, evt, func);
|
||||
}
|
||||
|
||||
void unregister_player_event(std::string name, int evt) {
|
||||
unregister_event("player", name, evt);
|
||||
}
|
||||
|
||||
void unregister_player_event(int evt) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
unregister_player_event(name, evt);
|
||||
}
|
||||
|
||||
void register_item_event(std::string name, int evt, int item_id, luabind::adl::object func) {
|
||||
std::string package_name = "item_";
|
||||
package_name += std::to_string(item_id);
|
||||
|
||||
if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
register_event(package_name, name, evt, func);
|
||||
}
|
||||
}
|
||||
|
||||
void register_item_event(int evt, int item_id, luabind::adl::object func) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
register_item_event(name, evt, item_id, func);
|
||||
}
|
||||
|
||||
void unregister_item_event(std::string name, int evt, int item_id) {
|
||||
std::string package_name = "item_";
|
||||
package_name += std::to_string(item_id);
|
||||
|
||||
unregister_event(package_name, name, evt);
|
||||
}
|
||||
|
||||
void unregister_item_event(int evt, int item_id) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
unregister_item_event(name, evt, item_id);
|
||||
}
|
||||
|
||||
void register_spell_event(std::string name, int evt, int spell_id, luabind::adl::object func) {
|
||||
if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
std::stringstream package_name;
|
||||
package_name << "spell_" << spell_id;
|
||||
|
||||
register_event(package_name.str(), name, evt, func);
|
||||
}
|
||||
}
|
||||
|
||||
void register_spell_event(int evt, int spell_id, luabind::adl::object func) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
register_spell_event(name, evt, spell_id, func);
|
||||
}
|
||||
|
||||
void unregister_spell_event(std::string name, int evt, int spell_id) {
|
||||
std::stringstream package_name;
|
||||
package_name << "spell_" << spell_id;
|
||||
|
||||
unregister_event(package_name.str(), name, evt);
|
||||
}
|
||||
|
||||
void unregister_spell_event(int evt, int spell_id) {
|
||||
std::string name = quest_manager.GetEncounter();
|
||||
unregister_spell_event(name, evt, spell_id);
|
||||
}
|
||||
//struct lua_registered_event {
|
||||
// std::string encounter_name;
|
||||
// luabind::adl::object lua_reference;
|
||||
// QuestEventID event_id;
|
||||
//};
|
||||
//
|
||||
//extern std::map<std::string, std::list<lua_registered_event>> lua_encounter_events_registered;
|
||||
//extern std::map<std::string, bool> lua_encounters_loaded;
|
||||
//extern std::map<std::string, Encounter *> lua_encounters;
|
||||
//
|
||||
//extern void MapOpcodes();
|
||||
//extern void ClearMappedOpcode(EmuOpcode op);
|
||||
//
|
||||
//void unregister_event(std::string package_name, std::string name, int evt);
|
||||
//
|
||||
//void load_encounter(std::string name) {
|
||||
// if(lua_encounters_loaded.count(name) > 0)
|
||||
// return;
|
||||
// auto enc = new Encounter(name.c_str());
|
||||
// entity_list.AddEncounter(enc);
|
||||
// lua_encounters[name] = enc;
|
||||
// lua_encounters_loaded[name] = true;
|
||||
// parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, "", 0);
|
||||
//}
|
||||
//
|
||||
//void load_encounter_with_data(std::string name, std::string info_str) {
|
||||
// if(lua_encounters_loaded.count(name) > 0)
|
||||
// return;
|
||||
// auto enc = new Encounter(name.c_str());
|
||||
// entity_list.AddEncounter(enc);
|
||||
// lua_encounters[name] = enc;
|
||||
// lua_encounters_loaded[name] = true;
|
||||
// std::vector<EQEmu::Any> info_ptrs;
|
||||
// info_ptrs.push_back(&info_str);
|
||||
// parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, "", 0, &info_ptrs);
|
||||
//}
|
||||
//
|
||||
//void unload_encounter(std::string name) {
|
||||
// if(lua_encounters_loaded.count(name) == 0)
|
||||
// return;
|
||||
//
|
||||
// auto liter = lua_encounter_events_registered.begin();
|
||||
// while(liter != lua_encounter_events_registered.end()) {
|
||||
// std::list<lua_registered_event> &elist = liter->second;
|
||||
// auto iter = elist.begin();
|
||||
// while(iter != elist.end()) {
|
||||
// if((*iter).encounter_name.compare(name) == 0) {
|
||||
// iter = elist.erase(iter);
|
||||
// } else {
|
||||
// ++iter;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(elist.size() == 0) {
|
||||
// lua_encounter_events_registered.erase(liter++);
|
||||
// } else {
|
||||
// ++liter;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// lua_encounters[name]->Depop();
|
||||
// lua_encounters.erase(name);
|
||||
// lua_encounters_loaded.erase(name);
|
||||
// parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, "", 0);
|
||||
//}
|
||||
//
|
||||
//void unload_encounter_with_data(std::string name, std::string info_str) {
|
||||
// if(lua_encounters_loaded.count(name) == 0)
|
||||
// return;
|
||||
//
|
||||
// auto liter = lua_encounter_events_registered.begin();
|
||||
// while(liter != lua_encounter_events_registered.end()) {
|
||||
// std::list<lua_registered_event> &elist = liter->second;
|
||||
// auto iter = elist.begin();
|
||||
// while(iter != elist.end()) {
|
||||
// if((*iter).encounter_name.compare(name) == 0) {
|
||||
// iter = elist.erase(iter);
|
||||
// }
|
||||
// else {
|
||||
// ++iter;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(elist.size() == 0) {
|
||||
// lua_encounter_events_registered.erase(liter++);
|
||||
// }
|
||||
// else {
|
||||
// ++liter;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// lua_encounters[name]->Depop();
|
||||
// lua_encounters.erase(name);
|
||||
// lua_encounters_loaded.erase(name);
|
||||
// std::vector<EQEmu::Any> info_ptrs;
|
||||
// info_ptrs.push_back(&info_str);
|
||||
// parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, "", 0, &info_ptrs);
|
||||
//}
|
||||
//
|
||||
//void register_event(std::string package_name, std::string name, int evt, luabind::adl::object func) {
|
||||
// if(lua_encounters_loaded.count(name) == 0)
|
||||
// return;
|
||||
//
|
||||
// unregister_event(package_name, name, evt);
|
||||
//
|
||||
// lua_registered_event e;
|
||||
// e.encounter_name = name;
|
||||
// e.lua_reference = func;
|
||||
// e.event_id = static_cast<QuestEventID>(evt);
|
||||
//
|
||||
// auto liter = lua_encounter_events_registered.find(package_name);
|
||||
// if(liter == lua_encounter_events_registered.end()) {
|
||||
// std::list<lua_registered_event> elist;
|
||||
// elist.push_back(e);
|
||||
// lua_encounter_events_registered[package_name] = elist;
|
||||
// } else {
|
||||
// std::list<lua_registered_event> &elist = liter->second;
|
||||
// elist.push_back(e);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void unregister_event(std::string package_name, std::string name, int evt) {
|
||||
// auto liter = lua_encounter_events_registered.find(package_name);
|
||||
// if(liter != lua_encounter_events_registered.end()) {
|
||||
// std::list<lua_registered_event> elist = liter->second;
|
||||
// auto iter = elist.begin();
|
||||
// while(iter != elist.end()) {
|
||||
// if(iter->event_id == evt && iter->encounter_name.compare(name) == 0) {
|
||||
// iter = elist.erase(iter);
|
||||
// break;
|
||||
// }
|
||||
// ++iter;
|
||||
// }
|
||||
// lua_encounter_events_registered[package_name] = elist;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void register_npc_event(std::string name, int evt, int npc_id, luabind::adl::object func) {
|
||||
// if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
// std::stringstream package_name;
|
||||
// package_name << "npc_" << npc_id;
|
||||
//
|
||||
// register_event(package_name.str(), name, evt, func);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void register_npc_event(int evt, int npc_id, luabind::adl::object func) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// register_npc_event(name, evt, npc_id, func);
|
||||
//}
|
||||
//
|
||||
//void unregister_npc_event(std::string name, int evt, int npc_id) {
|
||||
// std::stringstream package_name;
|
||||
// package_name << "npc_" << npc_id;
|
||||
//
|
||||
// unregister_event(package_name.str(), name, evt);
|
||||
//}
|
||||
//
|
||||
//void unregister_npc_event(int evt, int npc_id) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// unregister_npc_event(name, evt, npc_id);
|
||||
//}
|
||||
//
|
||||
//void register_player_event(std::string name, int evt, luabind::adl::object func) {
|
||||
// if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
// register_event("player", name, evt, func);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void register_player_event(int evt, luabind::adl::object func) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// register_player_event(name, evt, func);
|
||||
//}
|
||||
//
|
||||
//void unregister_player_event(std::string name, int evt) {
|
||||
// unregister_event("player", name, evt);
|
||||
//}
|
||||
//
|
||||
//void unregister_player_event(int evt) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// unregister_player_event(name, evt);
|
||||
//}
|
||||
//
|
||||
//void register_item_event(std::string name, int evt, int item_id, luabind::adl::object func) {
|
||||
// std::string package_name = "item_";
|
||||
// package_name += std::to_string(item_id);
|
||||
//
|
||||
// if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
// register_event(package_name, name, evt, func);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void register_item_event(int evt, int item_id, luabind::adl::object func) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// register_item_event(name, evt, item_id, func);
|
||||
//}
|
||||
//
|
||||
//void unregister_item_event(std::string name, int evt, int item_id) {
|
||||
// std::string package_name = "item_";
|
||||
// package_name += std::to_string(item_id);
|
||||
//
|
||||
// unregister_event(package_name, name, evt);
|
||||
//}
|
||||
//
|
||||
//void unregister_item_event(int evt, int item_id) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// unregister_item_event(name, evt, item_id);
|
||||
//}
|
||||
//
|
||||
//void register_spell_event(std::string name, int evt, int spell_id, luabind::adl::object func) {
|
||||
// if(luabind::type(func) == LUA_TFUNCTION) {
|
||||
// std::stringstream package_name;
|
||||
// package_name << "spell_" << spell_id;
|
||||
//
|
||||
// register_event(package_name.str(), name, evt, func);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//void register_spell_event(int evt, int spell_id, luabind::adl::object func) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// register_spell_event(name, evt, spell_id, func);
|
||||
//}
|
||||
//
|
||||
//void unregister_spell_event(std::string name, int evt, int spell_id) {
|
||||
// std::stringstream package_name;
|
||||
// package_name << "spell_" << spell_id;
|
||||
//
|
||||
// unregister_event(package_name.str(), name, evt);
|
||||
//}
|
||||
//
|
||||
//void unregister_spell_event(int evt, int spell_id) {
|
||||
// std::string name = quest_manager.GetEncounter();
|
||||
// unregister_spell_event(name, evt, spell_id);
|
||||
//}
|
||||
|
||||
Lua_Mob lua_spawn2(int npc_type, int grid, int unused, double x, double y, double z, double heading) {
|
||||
auto position = glm::vec4(x, y, z, heading);
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,11 +2,11 @@
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/object.hpp>
|
||||
|
||||
#include "../common/spdat.h"
|
||||
#include "masterentity.h"
|
||||
#include "questmgr.h"
|
||||
#include "zone.h"
|
||||
#include "zone_config.h"
|
||||
#include "../../common/spdat.h"
|
||||
#include "../masterentity.h"
|
||||
#include "../questmgr.h"
|
||||
#include "../zone.h"
|
||||
#include "../zone_config.h"
|
||||
|
||||
#include "lua_parser.h"
|
||||
#include "lua_mod.h"
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@
|
||||
#include "lua.hpp"
|
||||
#include <luabind/luabind.hpp>
|
||||
|
||||
#include "../common/spdat.h"
|
||||
#include "../../common/spdat.h"
|
||||
#include "lua_spell.h"
|
||||
|
||||
Lua_Spell::Lua_Spell(int id) {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
-1389
File diff suppressed because it is too large.
Load diff
@@ -1,55 +0,0 @@
|
||||
#ifndef EQEMU_LUA_PTR_H
|
||||
#define EQEMU_LUA_PTR_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#ifndef EQEMU_UNSAFE_LUA
|
||||
#define Lua_Safe_Call_Void() if(!d_) { return; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Bool() if(!d_) { return false; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Int() if(!d_) { return 0; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Real() if(!d_) { return 0.0; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_String() if(!d_) { return ""; } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Class(type) if(!d_) { return type(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#else
|
||||
#define Lua_Safe_Call_Void() NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Bool() NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Int() NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Real() NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_String() NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Class(type) NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
class Lua_Ptr
|
||||
{
|
||||
public:
|
||||
Lua_Ptr() {
|
||||
}
|
||||
|
||||
Lua_Ptr(T *d) : d_(d) {
|
||||
}
|
||||
|
||||
~Lua_Ptr() {
|
||||
}
|
||||
|
||||
T *GetLuaPtrData() {
|
||||
return d_;
|
||||
}
|
||||
|
||||
void SetLuaPtrData(T *d) {
|
||||
d_ = d;
|
||||
}
|
||||
|
||||
bool Null() {
|
||||
return d_ == nullptr;
|
||||
}
|
||||
|
||||
bool Valid() {
|
||||
return d_ != nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
T *d_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in new issue
Block a user