diff --git a/changelog.txt b/changelog.txt index 4e5866474..e717b8cf8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 06/8/2014 == +KLS: Changed lua API: eq.get_globals(client, npc) has been removed. Use eq.get_globals(npc, client) instead. +There's a bug with something in gcc 4.6.3 (maybe other versions) on x86 that this is attempting to combat. + == 05/17/2014 == Secrets: Identified the opcode/struct for guild ranks in Rain of Fear+ clients. Secrets: Implemented a work-around for Rain of Fear clients to have all guild permissions until proper database support is added for newer ranks. diff --git a/zone/command.cpp b/zone/command.cpp index b573907a3..ea54ead17 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -7936,6 +7936,9 @@ void command_bestz(Client *c, const Seperator *sep) { case RegionTypeWater: { c->Message(0,"You/your target are in Water."); break; } case RegionTypeLava: { c->Message(0,"You/your target are in Lava."); break; } case RegionTypeVWater: { c->Message(0,"You/your target are in VWater (Icy Water?)."); break; } + case RegionTypePVP: { c->Message(0, "You/your target are in a pvp enabled area."); break; } + case RegionTypeSlime: { c->Message(0, "You/your target are in slime."); break; } + case RegionTypeIce: { c->Message(0, "You/your target are in ice."); break; } default: c->Message(0,"You/your target are in an unknown region type."); } } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index bd788695a..cfe21dc51 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -759,20 +759,52 @@ luabind::object lua_get_qglobals(lua_State *L, Lua_NPC npc, Lua_Client client) { return ret; } -luabind::object lua_get_qglobals(lua_State *L, Lua_Client client, Lua_NPC npc) { - return lua_get_qglobals(L, npc, client); -} - luabind::object lua_get_qglobals(lua_State *L, Lua_Client client) { - return lua_get_qglobals(L, Lua_NPC(nullptr), client); + luabind::object ret = luabind::newtable(L); + + NPC *n = nullptr; + Client *c = client; + + std::list global_map; + QGlobalCache::GetQGlobals(global_map, n, c, zone); + auto iter = global_map.begin(); + while (iter != global_map.end()) { + ret[(*iter).name] = (*iter).value; + ++iter; + } + return ret; } luabind::object lua_get_qglobals(lua_State *L, Lua_NPC npc) { - return lua_get_qglobals(L, npc, Lua_Client(nullptr)); + luabind::object ret = luabind::newtable(L); + + NPC *n = npc; + Client *c = nullptr; + + std::list global_map; + QGlobalCache::GetQGlobals(global_map, n, c, zone); + auto iter = global_map.begin(); + while (iter != global_map.end()) { + ret[(*iter).name] = (*iter).value; + ++iter; + } + return ret; } luabind::object lua_get_qglobals(lua_State *L) { - return lua_get_qglobals(L, Lua_NPC(nullptr), Lua_Client(nullptr)); + luabind::object ret = luabind::newtable(L); + + NPC *n = nullptr; + Client *c = nullptr; + + std::list global_map; + QGlobalCache::GetQGlobals(global_map, n, c, zone); + auto iter = global_map.begin(); + while (iter != global_map.end()) { + ret[(*iter).name] = (*iter).value; + ++iter; + } + return ret; } Lua_EntityList lua_get_entity_list() { @@ -1249,7 +1281,6 @@ luabind::scope lua_register_general() { luabind::def("cross_zone_signal_client_by_name", &lua_cross_zone_signal_client_by_name), luabind::def("cross_zone_message_player_by_name", &lua_cross_zone_message_player_by_name), luabind::def("get_qglobals", (luabind::object(*)(lua_State*,Lua_NPC,Lua_Client))&lua_get_qglobals), - luabind::def("get_qglobals", (luabind::object(*)(lua_State*,Lua_Client,Lua_NPC))&lua_get_qglobals), luabind::def("get_qglobals", (luabind::object(*)(lua_State*,Lua_Client))&lua_get_qglobals), luabind::def("get_qglobals", (luabind::object(*)(lua_State*,Lua_NPC))&lua_get_qglobals), luabind::def("get_qglobals", (luabind::object(*)(lua_State*))&lua_get_qglobals), diff --git a/zone/watermap.cpp b/zone/watermap.cpp deleted file mode 100644 index 378433a90..000000000 --- a/zone/watermap.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "../common/debug.h" -#include -#include -#include -#include - -#include "watermap.h" -#include "../common/StringUtil.h" - -#ifdef _WINDOWS -#define snprintf _snprintf -#endif - - - - -WaterMap::WaterMap() -: BSP_Root(nullptr) -{ -} - -WaterMap::~WaterMap() { - safe_delete_array(BSP_Root); -} - - -WaterRegionType WaterMap::BSPReturnRegionType(int32 node_number, float y, float x, float z) const -{ - float distance; - - const ZBSP_Node *current_node = &BSP_Root[node_number-1]; - - // Are we at a leaf - - if ((current_node->left==0) && - (current_node->right==0)) { - return (WaterRegionType) current_node->special; - } - - - // No, so determine which side of the split plane we are on - // - - distance = (x * current_node->normal[0]) + - (y * current_node->normal[1]) + - (z * current_node->normal[2]) + - current_node->splitdistance; - - // If we are exactly on the split plane, I don't know what should happen. - // - if(distance == 0.0f) { - return(RegionTypeNormal); - } - if(distance >0.0f) { - if(current_node->left==0) { - // This shouldn't happen - return(RegionTypeNormal); - } - return BSPReturnRegionType(current_node->left, y, x, z); - } - if(current_node->right==0) { - // This should't happen - return(RegionTypeNormal); - } - - return BSPReturnRegionType(current_node->right, y, x, z); -} - -bool WaterMap::InWater(float y, float x, float z) const { - if(BSP_Root == nullptr) { - return false; - } - return(BSPReturnRegionType(1, y, x, z) == RegionTypeWater); -} - -bool WaterMap::InVWater(float y, float x, float z) const { - if(BSP_Root == nullptr) { - return false; - } - return(BSPReturnRegionType(1, y, x, z) == RegionTypeVWater); -} - -bool WaterMap::InLava(float y, float x, float z) const { - if(BSP_Root == nullptr) { - return false; - } - return(BSPReturnRegionType(1, y, x, z) == RegionTypeLava); -} - -bool WaterMap::InLiquid(float y, float x, float z) const { - if(BSP_Root == nullptr) //if the water map isn't loaded, this will save ~1 CPU cycle - return false; - return (InWater(y, x, z) || InLava(y, x, z)); -} - -WaterMap* WaterMap::LoadWaterMapfile(const char* in_zonename, const char *directory) { - FILE *fp; - char zBuf[64]; - char cWork[256]; - WaterMap* ret = nullptr; - - - //have to convert to lower because the short names im getting - //are not all lower anymore, copy since strlwr edits the str. - strn0cpy(zBuf, in_zonename, 64); - - if(directory == nullptr) - directory = MAP_DIR; - snprintf(cWork, 250, "%s/%s.wtr", directory, strlwr(zBuf)); - - if ((fp = fopen( cWork, "rb" ))) { - ret = new WaterMap(); - if(ret != nullptr) { - if(ret->loadWaterMap(fp)) { - printf("Water Map %s loaded.\n", cWork); - } else { - safe_delete(ret); - printf("Water Map %s exists but could not be processed.\n", cWork); - return nullptr; - } - } else { - printf("Water Map %s loading failed.\n", cWork); - } - fclose(fp); - } - else { - printf("Water Map %s not found.\n", cWork); - } - return ret; -} - -bool WaterMap::loadWaterMap(FILE *fp) { - char EQWMagic[10]; - uint32 BSPTreeSize; - uint32 EQWVersion; - - if(fread(EQWMagic, 10, 1, fp)!=1) { - printf("Error reading Water region map.\n"); - return(false); - } - if(strncmp(EQWMagic,"EQEMUWATER",10)) { - printf("Bad header in Water region map.\n"); - return(false); - } - if(fread(&EQWVersion, sizeof(EQWVersion), 1, fp)!=1) { - printf("Error reading Water region map.\n"); - return(false); - } - if(EQWVersion!=WATERMAP_VERSION) { - printf("Incompatible Water region map version.\n"); - return(false); - } - - if(fread(&BSPTreeSize, sizeof(BSPTreeSize), 1, fp)!=1) { - printf("Error reading Water region map.\n"); - return(false); - } - - BSP_Root = (ZBSP_Node *) new ZBSP_Node[BSPTreeSize]; - - if(BSP_Root==nullptr) { - printf("Memory allocation failed while reading water map.\n"); - return(false); - } - - if(fread(BSP_Root, sizeof(ZBSP_Node), BSPTreeSize, fp) != BSPTreeSize) { - printf("Error reading Water region map.\n"); - safe_delete_array(BSP_Root); - return(false); - } - - printf("Water region map has %d nodes.\n", BSPTreeSize); - return(true); -} - - diff --git a/zone/watermap.h b/zone/watermap.h deleted file mode 100644 index c3b36483b..000000000 --- a/zone/watermap.h +++ /dev/null @@ -1,68 +0,0 @@ -/* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemu.org) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef WATERMAP_H -#define WATERMAP_H - -#define WATERMAP_VERSION 1 - -#pragma pack(1) -typedef struct ZBSP_Node { - int32 node_number; - float normal[3], splitdistance; - int32 region; - int32 special; - int32 left, right; -} ZBSP_Node; -#pragma pack() - -typedef enum { - RegionTypeUnsupported = -2, - RegionTypeUntagged = -1, - RegionTypeNormal = 0, - RegionTypeWater = 1, - RegionTypeLava = 2, - RegionTypeZoneLine = 3, - RegionTypePVP = 4, - RegionTypeSlime = 5, - RegionTypeIce = 6, - RegionTypeVWater =7 -} WaterRegionType; - -class WaterMap { - -public: - static WaterMap* LoadWaterMapfile(const char* in_zonename, const char *directory = nullptr); - WaterRegionType BSPReturnRegionType(int32 node_number, float y, float x, float z) const; - bool InWater(float y, float x, float z) const; - bool InVWater(float y, float x, float z) const; - bool InLava(float y, float x, float z) const; - bool InLiquid(float y, float x, float z) const; - - WaterMap(); - ~WaterMap(); - -private: - bool loadWaterMap(FILE *fp); - - ZBSP_Node* BSP_Root; -}; - -#endif - - -