diff --git a/CMakeLists.txt b/CMakeLists.txt index c4c37271..7fa65677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) project(streamer) -set(PLUGIN_VERSION "2.9.6") +set(PLUGIN_VERSION "2.9.7") set(CMAKE_CXX_STANDARD 17) if (MSVC) @@ -20,10 +20,10 @@ include_directories(${SAMPSDK_DIR}/amx) include_directories(${PROJECT_SOURCE_DIR}/lib/boost) if(EIGEN3_INCLUDE_DIR) - file(TO_CMAKE_PATH ${EIGEN3_INCLUDE_DIR} EIGEN3_INCLUDE_DIR) - list(APPEND CMAKE_MODULE_PATH "${EIGEN3_INCLUDE_DIR}/cmake") + file(TO_CMAKE_PATH ${EIGEN3_INCLUDE_DIR} EIGEN3_INCLUDE_DIR) + list(APPEND CMAKE_MODULE_PATH "${EIGEN3_INCLUDE_DIR}/cmake") else() - set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/eigen") + set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/eigen") endif() find_package(Eigen3 3.3.4 REQUIRED) @@ -37,25 +37,25 @@ add_subdirectory(src) set(CPACK_PACKAGE_VERSION ${PLUGIN_VERSION}) if(COMMIT_ID) - string(TIMESTAMP CURRENT_DATE "%Y%m%d") - set(PACKAGE_FILE_NAME streamer-${PLUGIN_VERSION}-${CURRENT_DATE}-${COMMIT_ID}) + string(TIMESTAMP CURRENT_DATE "%Y%m%d") + set(PACKAGE_FILE_NAME streamer-${PLUGIN_VERSION}-${CURRENT_DATE}-${COMMIT_ID}) else() - set(PACKAGE_FILE_NAME streamer-${PLUGIN_VERSION}) + set(PACKAGE_FILE_NAME streamer-${PLUGIN_VERSION}) endif() set(CPACK_OUTPUT_FILE_PREFIX package/${PACKAGE_FILE_NAME}) if(WIN32) - set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}-win32) - set(CPACK_GENERATOR ZIP) + set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}-win32) + set(CPACK_GENERATOR ZIP) else() - set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}-linux) - set(CPACK_GENERATOR TGZ) + set(CPACK_PACKAGE_FILE_NAME ${PACKAGE_FILE_NAME}-linux) + set(CPACK_GENERATOR TGZ) endif() if(CPACK_OUTPUT_FILE_POSTFIX) - string(TOLOWER "${CPACK_OUTPUT_FILE_POSTFIX}" CPACK_OUTPUT_FILE_POSTFIX) - set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-${CPACK_OUTPUT_FILE_POSTFIX}) + string(TOLOWER "${CPACK_OUTPUT_FILE_POSTFIX}" CPACK_OUTPUT_FILE_POSTFIX) + set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-${CPACK_OUTPUT_FILE_POSTFIX}) endif() include(CPack) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 583ad96b..94fda7b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,7 +38,7 @@ else() set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS " -lrt") endif() -add_definitions(-DSAMPGDK_AMALGAMATION -DSAMPGDK_CPP_WRAPPERS -D_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING -D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING) +add_definitions(-DSAMPGDK_AMALGAMATION -D_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING -D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING) set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") target_link_libraries(${PROJECT_NAME}) diff --git a/src/common.h b/src/common.h index ee07a425..e05905d4 100644 --- a/src/common.h +++ b/src/common.h @@ -48,6 +48,8 @@ #define STREAMER_STATIC_DISTANCE_CUTOFF (0.0f) +#define STREAMER_ITEM_MIN_CUSTOM_VALUE (0x40000000 & ~0x80000000) + class Cell; class Data; class Events; diff --git a/src/main.h b/src/main.h index f604ee82..4449cfba 100644 --- a/src/main.h +++ b/src/main.h @@ -17,8 +17,8 @@ #ifndef MAIN_H #define MAIN_H -#define INCLUDE_FILE_VERSION (0x296) -#define PLUGIN_VERSION "2.9.6" +#define INCLUDE_FILE_VERSION (0x297) +#define PLUGIN_VERSION "2.9.7" #include #include diff --git a/src/manipulation/int.cpp b/src/manipulation/int.cpp index 521a2a92..5f0c2128 100644 --- a/src/manipulation/int.cpp +++ b/src/manipulation/int.cpp @@ -1787,3 +1787,11 @@ int Manipulation::setIntData(AMX *amx, cell *params) } return 0; } + +void Manipulation::getIntExtraDataParams(cell *params, cell *extraParams, int object, int customDataType) +{ + extraParams[0] = sizeof(*extraParams); + extraParams[1] = static_cast(params[4]); + extraParams[2] = object; + extraParams[3] = customDataType; +} \ No newline at end of file diff --git a/src/manipulation/int.h b/src/manipulation/int.h index 12acc215..1a57428e 100644 --- a/src/manipulation/int.h +++ b/src/manipulation/int.h @@ -25,6 +25,8 @@ namespace Manipulation int setIntData(AMX *amx, cell *params); int removeIntData(AMX *amx, cell *params); int hasIntData(AMX *amx, cell *params); + + void getIntExtraDataParams(cell *params, cell *extraParams, int object, int customDataType); } #endif diff --git a/src/natives/miscellaneous.cpp b/src/natives/miscellaneous.cpp index a6be5671..23fb0b1c 100644 --- a/src/natives/miscellaneous.cpp +++ b/src/natives/miscellaneous.cpp @@ -18,6 +18,7 @@ #include "../natives.h" #include "../core.h" #include "../utility.h" +#include "../manipulation/int.h" cell AMX_NATIVE_CALL Natives::Streamer_GetDistanceToItem(AMX *amx, cell *params) { @@ -1502,14 +1503,17 @@ cell AMX_NATIVE_CALL Natives::Streamer_CountItems(AMX *amx, cell *params) cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) { - CHECK_PARAMS(8); + CHECK_PARAMS(9); Eigen::Vector2f position2d = Eigen::Vector2f(amx_ctof(params[1]), amx_ctof(params[2])); Eigen::Vector3f position3d = Eigen::Vector3f(amx_ctof(params[1]), amx_ctof(params[2]), amx_ctof(params[3])); float range = amx_ctof(params[7]) * amx_ctof(params[7]); int worldId = static_cast(params[8]); + cell customDataType = params[9]; + cell extraParams[4]; std::multimap orderedItems; std::vector pointCells; core->getGrid()->findMinimalCellsForPoint(position2d, pointCells, range); + switch (static_cast(params[4])) { case STREAMER_TYPE_OBJECT: @@ -1531,6 +1535,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) } if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, o->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, o->first)); } } @@ -1549,6 +1563,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, q->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, q->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, q->first)); } } @@ -1567,6 +1591,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, c->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, c->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, c->first)); } } @@ -1585,6 +1619,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, r->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, r->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, r->first)); } } @@ -1603,6 +1647,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, m->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, m->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, m->first)); } } @@ -1621,6 +1675,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, t->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, t->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, t->first)); } } @@ -1680,6 +1744,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) } if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, a->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, a->first)); } } @@ -1698,6 +1772,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) float distance = static_cast(boost::geometry::comparable_distance(position3d, a->second->position)); if (distance < range) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, a->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + orderedItems.insert(std::pair(distance, a->first)); } } @@ -1722,11 +1806,15 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetNearbyItems(AMX *amx, cell *params) cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params) { - CHECK_PARAMS(4); + CHECK_PARAMS(5); std::multimap orderedItems; std::unordered_map::iterator p = core->getData()->players.find(static_cast(params[1])); + if (p != core->getData()->players.end()) { + cell customDataType = params[9]; + cell extraParams[4]; + switch (static_cast(params[2])) { case STREAMER_TYPE_OBJECT: @@ -1736,6 +1824,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator o = core->getData()->objects.find(i->first); if (o != core->getData()->objects.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, o->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + float distance = 0.0f; if (o->second->attach) { @@ -1757,6 +1855,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator q = core->getData()->pickups.find(i->first.first); if (q != core->getData()->pickups.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, q->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + continue; + } + } + float distance = static_cast(boost::geometry::comparable_distance(p->second.position, q->second->position)); orderedItems.insert(std::pair(distance, q->first)); } @@ -1770,6 +1878,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator c = core->getData()->checkpoints.find(p->second.visibleCheckpoint); if (c != core->getData()->checkpoints.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, c->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + break; + } + } + float distance = static_cast(boost::geometry::comparable_distance(p->second.position, c->second->position)); orderedItems.insert(std::pair(distance, c->first)); } @@ -1783,6 +1901,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator c = core->getData()->raceCheckpoints.find(p->second.visibleRaceCheckpoint); if (c != core->getData()->raceCheckpoints.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, c->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + break; + } + } + float distance = static_cast(boost::geometry::comparable_distance(p->second.position, c->second->position)); orderedItems.insert(std::pair(distance, c->first)); } @@ -1796,6 +1924,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator m = core->getData()->mapIcons.find(i->first); if (m != core->getData()->mapIcons.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, m->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + break; + } + } + float distance = static_cast(boost::geometry::comparable_distance(p->second.position, m->second->position)); orderedItems.insert(std::pair(distance, m->first)); } @@ -1809,6 +1947,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator t = core->getData()->textLabels.find(i->first); if (t != core->getData()->textLabels.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, t->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + break; + } + } + float distance = 0.0f; if (t->second->attach) { @@ -1830,6 +1978,16 @@ cell AMX_NATIVE_CALL Natives::Streamer_GetAllVisibleItems(AMX *amx, cell *params std::unordered_map::iterator a = core->getData()->actors.find(i->first.first); if (a != core->getData()->actors.end()) { + if (customDataType >= STREAMER_ITEM_MIN_CUSTOM_VALUE) + { + Manipulation::getIntExtraDataParams(params, extraParams, a->first, customDataType); + + if (!Manipulation::hasIntData(amx, extraParams)) + { + break; + } + } + float distance = static_cast(boost::geometry::comparable_distance(p->second.position, a->second->position)); orderedItems.insert(std::pair(distance, a->first)); } diff --git a/src/sampgdk.h b/src/sampgdk.h index 4abc1f51..5c28d6c9 100644 --- a/src/sampgdk.h +++ b/src/sampgdk.h @@ -906,6 +906,8 @@ SAMPGDK_NATIVE(bool, IsValidActor(int actorid)); #ifndef DOXYGEN +#define SAMPGDK_CPP_WRAPPERS + #if defined SAMPGDK_CPP_WRAPPERS && !defined IN_SAMPGDK namespace sampgdk { @@ -6931,3 +6933,4 @@ inline bool CreateExplosionForPlayer(int playerid, float X, float Y, float Z, in #endif /* !SAMPGDK_A_PLAYERS_H */ +#undef SAMPGDK_CPP_WRAPPERS \ No newline at end of file diff --git a/streamer.inc b/streamer.inc index 28fac67a..e6aff713 100644 --- a/streamer.inc +++ b/streamer.inc @@ -116,7 +116,7 @@ // Include File Version -public Streamer_IncludeFileVersion = 0x296; +public Streamer_IncludeFileVersion = 0x297; #pragma unused Streamer_IncludeFileVersion @@ -257,8 +257,8 @@ native Streamer_DestroyAllVisibleItems(playerid, type, serverwide = 1); native Streamer_CountVisibleItems(playerid, type, serverwide = 1); native Streamer_DestroyAllItems(type, serverwide = 1); native Streamer_CountItems(type, serverwide = 1); -native Streamer_GetNearbyItems(Float:x, Float:y, Float:z, type, STREAMER_ALL_TAGS:items[], maxitems = sizeof items, Float:range = 300.0, worldid = -1); -native Streamer_GetAllVisibleItems(playerid, type, STREAMER_ALL_TAGS:items[], maxitems = sizeof items); +native Streamer_GetNearbyItems(Float:x, Float:y, Float:z, type, STREAMER_ALL_TAGS:items[], maxitems = sizeof items, Float:range = 300.0, worldid = -1, customdatatype = 0); +native Streamer_GetAllVisibleItems(playerid, type, STREAMER_ALL_TAGS:items[], maxitems = sizeof items, customdatatype = 0); native Streamer_GetItemPos(type, STREAMER_ALL_TAGS:id, &Float:x, &Float:y, &Float:z); native Streamer_SetItemPos(type, STREAMER_ALL_TAGS:id, Float:x, Float:y, Float:z); native Streamer_GetItemOffset(type, STREAMER_ALL_TAGS:id, &Float:x, &Float:y, &Float:z); diff --git a/streamer.rc b/streamer.rc index 99f9f805..5b8a2ba0 100644 --- a/streamer.rc +++ b/streamer.rc @@ -2,7 +2,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 1 VERSIONINFO - FILEVERSION 2,9,5,0 + FILEVERSION 2,9,7,0 { BLOCK "StringFileInfo" { @@ -12,7 +12,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US VALUE "LegalCopyright", "Copyright � 2017 Incognito" VALUE "OriginalFilename", "streamer.dll" VALUE "ProductName", "SA-MP Streamer Plugin" - VALUE "ProductVersion", "v2.9.6" + VALUE "ProductVersion", "v2.9.7" } } BLOCK "VarFileInfo"