This commit is contained in:
Shyotl
2020-05-09 04:51:12 -05:00
10 changed files with 78 additions and 67 deletions

View File

@@ -85,6 +85,7 @@ if (WINDOWS)
/TP
/W3
/c
/Zc:__cplusplus
/Zc:forScope
/Zc:rvalueCast
/Zc:wchar_t

View File

@@ -50,12 +50,10 @@ if (LINUX)
set(DL_LIBRARY dl)
set(RT_LIBRARY rt)
set(PTHREAD_LIBRARY pthread)
set(FMT_LIBRARY "")
else (LINUX)
set(DL_LIBRARY "")
set(RT_LIBRARY "")
set(PTHREAD_LIBRARY "")
set(FMT_LIBRARY fmt::fmt)
endif (LINUX)
if (WINDOWS)
@@ -77,6 +75,6 @@ else (WINDOWS)
set(WINDOWS_LIBRARIES "")
endif (WINDOWS)
mark_as_advanced(DL_LIBRARY RT_LIBRARY PTHREAD_LIBRARY FMT_LIBRARY WINDOWS_LIBRARIES)
mark_as_advanced(DL_LIBRARY RT_LIBRARY PTHREAD_LIBRARY WINDOWS_LIBRARIES)
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)

View File

@@ -9,16 +9,18 @@ FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.11.0
GIT_SHALLOW TRUE
)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 6.1.2
GIT_TAG 0463665ef136d685fe07a564d93c782456456d3d
)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.7.3
GIT_SHALLOW TRUE
)
FetchContent_Declare(
absl
@@ -45,9 +47,7 @@ if (BUILD_TESTING)
endif()
#Download the rest of the libraries
if(WINDOWS)
FetchContent_MakeAvailable(fmt)
endif()
# Typically you don't care so much for a third party library's tests to be
# run from your own project's code.

View File

@@ -300,6 +300,7 @@ target_link_libraries(
${CORESERVICES_LIBRARY}
${URIPARSER_LIBRARY}
nlohmann_json::nlohmann_json
absl::strings
${RT_LIBRARY}
)

View File

@@ -29,6 +29,16 @@
#include <boost/optional/optional.hpp>
#include <string>
#if __cplusplus < 201606
#include <absl/strings/string_view.h>
namespace std {
typedef absl::string_view string_view;
}
#else
#include <string_view>
#endif
#include <cstdio>
//#include <locale>
#include <iomanip>

View File

@@ -2146,7 +2146,7 @@ void LLRender::setLineWidth(F32 line_width)
}
if (mNewContext.lineWidth != line_width || mDirty)
{
if (mMode == LLRender::LINES || LLRender::LINE_STRIP)
if (mMode == LLRender::LINES || mMode == LLRender::LINE_STRIP)
{
flush();
}
@@ -2492,7 +2492,8 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count)
mColorsp[mCount] = mColorsp[mCount-1];
}
mVerticesp[mCount] = mVerticesp[mCount-1];
if (mCount > 0) // ND: Guard against crashes if mCount is zero, yes it can happen
mVerticesp[mCount] = mVerticesp[mCount-1];
mPrimitiveReset = false;
}
@@ -2528,9 +2529,12 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32
mCount++;
mColorsp[mCount] = mColorsp[mCount-1];
}
mVerticesp[mCount] = mVerticesp[mCount-1];
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
if (mCount > 0)
{
mVerticesp[mCount] = mVerticesp[mCount - 1];
mTexcoordsp[mCount] = mTexcoordsp[mCount - 1];
}
mPrimitiveReset = false;
}
@@ -2564,9 +2568,12 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo
mColorsp.copyArray(mCount, colors, vert_count);
mCount += vert_count;
mVerticesp[mCount] = mVerticesp[mCount-1];
mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
mColorsp[mCount] = mColorsp[mCount-1];
if (mCount > 0)
{
mVerticesp[mCount] = mVerticesp[mCount - 1];
mTexcoordsp[mCount] = mTexcoordsp[mCount - 1];
mColorsp[mCount] = mColorsp[mCount - 1];
}
mPrimitiveReset = false;
}

View File

@@ -1709,7 +1709,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
absl::flat_hash_map
absl::node_hash_map
nlohmann_json::nlohmann_json
${FMT_LIBRARY}
fmt::fmt
)
if (LINUX)

View File

@@ -560,7 +560,7 @@ void LLIMProcessing::processNewMessage(const LLUUID& from_id,
chat.mFromID = from_id;
chat.mFromName = name;
chat.mSourceType = (from_id.isNull() || (name == SYSTEM_FROM)) ? CHAT_SOURCE_SYSTEM :
(dialog == IM_FROM_TASK && dialog == IM_FROM_TASK_AS_ALERT) ? CHAT_SOURCE_OBJECT : CHAT_SOURCE_AGENT;
(dialog == IM_FROM_TASK || dialog == IM_FROM_TASK_AS_ALERT) ? CHAT_SOURCE_OBJECT : CHAT_SOURCE_AGENT;
bool is_muted = LLMuteList::getInstance()->isMuted(from_id, name, LLMute::flagTextChat)
// object IMs contain sender object id in session_id (STORM-1209)

View File

@@ -1609,22 +1609,8 @@ std::string LLPreviewGesture::getLabel(const std::vector<std::string>& v_labels)
for(const auto& pair : LLPreview::sInstances)
{
const auto& pPreview(pair.second);
#ifndef LL_WINDOWS
#if __cplusplus >= 201606
constexpr std::string_view gesture("Gesture");
if (pPreview && pPreview->getTitleName().compare(gesture) == 0)
LL_COMPILE_TIME_MESSAGE("String view support detected, remove this macro check, this line and the old check below");
#endif
#endif
if (pPreview && pPreview->getTitleName() ==
#ifndef LL_WINDOWS
static_cast<const std::string>(
#endif
"Gesture"
#ifndef LL_WINDOWS
)
#endif
)
if (pPreview && std::string_view(pPreview->getTitleName()) == gesture)
{
wait_anim = pPreview->getChild<LLCheckBoxCtrl>("wait_anim_check")->getLabel();
break;

View File

@@ -152,10 +152,6 @@ bool can_block(const LLUUID& id);
static const boost::regex NEWLINES("\\n{1}");
// NaCl End
extern AIHTTPTimeoutPolicy authHandler_timeout;
//
// Constants
//
@@ -3877,17 +3873,18 @@ void process_sound_trigger(LLMessageSystem* msg, void**)
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ObjectID, object_id);
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (NACLAntiSpamRegistry::instanceExists())
{
auto& antispam = NACLAntiSpamRegistry::instance();
static const LLCachedControl<U32> _NACL_AntiSpamSoundMulti("_NACL_AntiSpamSoundMulti");
if (owner_id.isNull())
{
bool is_collision_sound(const std::string & sound);
if (!is_collision_sound(sound_id.asString())
&& antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, object_id, LFIDBearer::OBJECT, _NACL_AntiSpamSoundMulti))
&& antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, object_id, LFIDBearer::OBJECT, _NACL_AntiSpamSoundMulti))
return;
}
else if (antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, owner_id, LFIDBearer::AVATAR, _NACL_AntiSpamSoundMulti)) return;
else if (antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, owner_id, LFIDBearer::AVATAR, _NACL_AntiSpamSoundMulti)) return;
}
// NaCl End
@@ -3967,12 +3964,13 @@ void process_preload_sound(LLMessageSystem* msg, void** user_data)
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (NACLAntiSpamRegistry::instanceExists())
{
auto& antispam = NACLAntiSpamRegistry::instance();
static const LLCachedControl<U32> _NACL_AntiSpamSoundPreloadMulti("_NACL_AntiSpamSoundPreloadMulti");
if ((owner_id.isNull()
&& antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, object_id, LFIDBearer::OBJECT, _NACL_AntiSpamSoundPreloadMulti))
|| antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, owner_id, LFIDBearer::AVATAR, _NACL_AntiSpamSoundPreloadMulti))
&& antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, object_id, LFIDBearer::OBJECT, _NACL_AntiSpamSoundPreloadMulti))
|| antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND_PRELOAD, owner_id, LFIDBearer::AVATAR, _NACL_AntiSpamSoundPreloadMulti))
return;
}
// NaCl End
@@ -4012,11 +4010,12 @@ void process_attached_sound(LLMessageSystem* msg, void** user_data)
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (NACLAntiSpamRegistry::instanceExists())
{
auto& antispam = NACLAntiSpamRegistry::instance();
if ((owner_id.isNull()
&& antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, object_id, LFIDBearer::OBJECT))
|| antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, owner_id))
&& antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, object_id, LFIDBearer::OBJECT))
|| antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SOUND, owner_id))
return;
}
// NaCl End
@@ -5775,9 +5774,11 @@ void process_economy_data(LLMessageSystem* msg, void** /*user_data*/)
void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted)
{
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, notification["payload"]["task_id"].asUUID(), LFIDBearer::OBJECT))
if (NACLAntiSpamRegistry::instanceExists())
{
if (NACLAntiSpamRegistry::instance().checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, notification["payload"]["task_id"].asUUID(), LFIDBearer::OBJECT))
return;
}
// NaCl End
// only continue if at least some permissions were requested
if (orig_questions)
@@ -6052,11 +6053,12 @@ void process_script_question(LLMessageSystem* msg, void** user_data)
msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid);
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (NACLAntiSpamRegistry::instanceExists())
{
auto& antispam = NACLAntiSpamRegistry::instance();
if ((taskid.isNull()
&& antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, itemid, LFIDBearer::NONE))
|| antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, taskid, LFIDBearer::OBJECT))
&& antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, itemid, LFIDBearer::NONE))
|| antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, taskid, LFIDBearer::OBJECT))
return;
}
// NaCl End
@@ -7104,6 +7106,12 @@ void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool
}
}
// We've got the name of the person who owns the object hurling the url.
void callback_load_url_avatar_name(const LLUUID& id, const LLAvatarName& av_name)
{
callback_load_url_name(id, av_name.getUserName(), false);
}
void process_load_url(LLMessageSystem* msg, void**)
{
LLUUID object_id;
@@ -7124,11 +7132,12 @@ void process_load_url(LLMessageSystem* msg, void**)
msg->getBOOL("Data", "OwnerIsGroup", owner_is_group);
// NaCl - Antispam Registry
if (auto antispam = NACLAntiSpamRegistry::getIfExists())
if (NACLAntiSpamRegistry::instanceExists())
{
auto& antispam = NACLAntiSpamRegistry::instance();
if ((owner_id.isNull()
&& antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, object_id, LFIDBearer::OBJECT))
|| antispam->checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, owner_id, owner_is_group ? LFIDBearer::GROUP : LFIDBearer::AVATAR))
&& antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, object_id, LFIDBearer::OBJECT))
|| antispam.checkQueue(NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG, owner_id, owner_is_group ? LFIDBearer::GROUP : LFIDBearer::AVATAR))
return;
}
// NaCl End
@@ -7157,8 +7166,14 @@ void process_load_url(LLMessageSystem* msg, void**)
// Add to list of pending name lookups
gLoadUrlList.push_back(payload);
gCacheName->get(owner_id, owner_is_group,
boost::bind(&callback_load_url_name, _1, _2, _3));
if (owner_is_group)
{
gCacheName->getGroup(owner_id, boost::bind(&callback_load_url_name, _1, _2, _3));
}
else
{
LLAvatarNameCache::get(owner_id, boost::bind(&callback_load_url_avatar_name, _1, _2));
}
}
@@ -7308,21 +7323,15 @@ void onCovenantLoadComplete(LLVFS* vfs,
S32 file_length = file.getSize();
char* buffer = new char[file_length+1];
if (buffer == NULL)
{
LL_ERRS("Messaging") << "Memory Allocation failed" << LL_ENDL;
return;
}
file.read((U8*)buffer, file_length); /* Flawfinder: ignore */
std::vector<char> buffer(file_length + 1);
file.read((U8*)&buffer[0], file_length);
// put a EOS at the end
buffer[file_length] = 0;
if( (file_length > 19) && !strncmp( buffer, "Linden text version", 19 ) )
buffer[file_length] = '\0';
if ((file_length > 19) && !strncmp(&buffer[0], "Linden text version", 19))
{
LLViewerTextEditor * editor = new LLViewerTextEditor(std::string("temp"), LLRect(0,0,0,0), file_length+1);
if( !editor->importBuffer( buffer, file_length+1 ) )
if( !editor->importBuffer( &buffer[0], file_length+1 ) )
{
LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL;
covenant_text = "Problem importing estate covenant.";
@@ -7339,7 +7348,6 @@ void onCovenantLoadComplete(LLVFS* vfs,
LL_WARNS("Messaging") << "Problem importing estate covenant: Covenant file format error." << LL_ENDL;
covenant_text = "Problem importing estate covenant: Covenant file format error.";
}
delete[] buffer;
}
else
{