Skip to content

Commit

Permalink
Merge remote-tracking branch 'minetest/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 6, 2016
2 parents 0283b91 + 667975f commit 2526d40
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/camera.cpp
Expand Up @@ -790,7 +790,7 @@ void Camera::drawNametags()
// shadow can remain.
continue;
}
v3f pos = nametag->parent_node->getPosition() + v3f(0.0, 1.1 * BS, 0.0);
v3f pos = nametag->parent_node->getAbsolutePosition() + v3f(0.0, 1.1 * BS, 0.0);
f32 transformed_pos[4] = { pos.X, pos.Y, pos.Z, 1.0f };
trans.multiplyWith1x4Matrix(transformed_pos);
if (transformed_pos[3] > 0) {
Expand Down
12 changes: 4 additions & 8 deletions src/client.cpp
Expand Up @@ -614,10 +614,8 @@ void Client::step(float dtime)
Update positions of sounds attached to objects
*/
{
for(std::map<int, u16>::iterator
i = m_sounds_to_objects.begin();
i != m_sounds_to_objects.end(); ++i)
{
for(UNORDERED_MAP<int, u16>::iterator i = m_sounds_to_objects.begin();
i != m_sounds_to_objects.end(); ++i) {
int client_id = i->first;
u16 object_id = i->second;
ClientActiveObject *cao = m_env.getActiveObject(object_id);
Expand All @@ -637,10 +635,8 @@ void Client::step(float dtime)
m_removed_sounds_check_timer = 0;
// Find removed sounds and clear references to them
std::vector<s32> removed_server_ids;
for(std::map<s32, int>::iterator
i = m_sounds_server_to_client.begin();
i != m_sounds_server_to_client.end();)
{
for(UNORDERED_MAP<s32, int>::iterator i = m_sounds_server_to_client.begin();
i != m_sounds_server_to_client.end();) {
s32 server_id = i->first;
int client_id = i->second;
++i;
Expand Down
6 changes: 3 additions & 3 deletions src/client.h
Expand Up @@ -676,11 +676,11 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
// Sounds
float m_removed_sounds_check_timer;
// Mapping from server sound ids to our sound ids
std::map<s32, int> m_sounds_server_to_client;
UNORDERED_MAP<s32, int> m_sounds_server_to_client;
// And the other way!
std::map<int, s32> m_sounds_client_to_server;
UNORDERED_MAP<int, s32> m_sounds_client_to_server;
// And relations to objects
std::map<int, u16> m_sounds_to_objects;
UNORDERED_MAP<int, u16> m_sounds_to_objects;

// Privileges
UNORDERED_SET<std::string> m_privileges;
Expand Down
10 changes: 4 additions & 6 deletions src/clientobject.cpp
Expand Up @@ -46,12 +46,11 @@ ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,
IGameDef *gamedef, ClientEnvironment *env)
{
// Find factory function
std::map<u16, Factory>::iterator n;
n = m_types.find(type);
UNORDERED_MAP<u16, Factory>::iterator n = m_types.find(type);
if(n == m_types.end()) {
// If factory is not found, just return.
warningstream<<"ClientActiveObject: No factory for type="
<<(int)type<<std::endl;
warningstream << "ClientActiveObject: No factory for type="
<< (int)type << std::endl;
return NULL;
}

Expand All @@ -62,8 +61,7 @@ ClientActiveObject* ClientActiveObject::create(ActiveObjectType type,

void ClientActiveObject::registerType(u16 type, Factory f)
{
std::map<u16, Factory>::iterator n;
n = m_types.find(type);
UNORDERED_MAP<u16, Factory>::iterator n = m_types.find(type);
if(n != m_types.end())
return;
m_types[type] = f;
Expand Down
3 changes: 2 additions & 1 deletion src/clientobject.h
Expand Up @@ -26,6 +26,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#include "irrlichttypes_extrabloated.h"
#include "activeobject.h"
#include <map>
#include "util/cpp11_container.h"

/*
Expand Down Expand Up @@ -106,7 +107,7 @@ class ClientActiveObject : public ActiveObject
ClientEnvironment *m_env;
private:
// Used for creating objects based on type
static std::map<u16, Factory> m_types;
static UNORDERED_MAP<u16, Factory> m_types;
};

struct DistanceSortedActiveObject
Expand Down
2 changes: 1 addition & 1 deletion src/content_cao.cpp
Expand Up @@ -54,7 +54,7 @@ struct ToolCapabilities;

#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"

std::map<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;
UNORDERED_MAP<u16, ClientActiveObject::Factory> ClientActiveObject::m_types;

SmoothTranslator::SmoothTranslator():
vect_old(0,0,0),
Expand Down
4 changes: 1 addition & 3 deletions src/network/clientpackethandler.cpp
Expand Up @@ -824,9 +824,7 @@ void Client::handleCommand_StopSound(NetworkPacket* pkt)

*pkt >> server_id;

std::map<s32, int>::iterator i =
m_sounds_server_to_client.find(server_id);

UNORDERED_MAP<s32, int>::iterator i = m_sounds_server_to_client.find(server_id);
if (i != m_sounds_server_to_client.end()) {
int client_id = i->second;
m_sound->stopSound(client_id);
Expand Down
4 changes: 2 additions & 2 deletions src/script/lua_api/l_mapgen.cpp
Expand Up @@ -247,7 +247,7 @@ bool read_schematic_def(lua_State *L, int index,
schem->schemdata = new MapNode[numnodes];

size_t names_base = names->size();
std::map<std::string, content_t> name_id_map;
UNORDERED_MAP<std::string, content_t> name_id_map;

u32 i = 0;
for (lua_pushnil(L); lua_next(L, -2); i++, lua_pop(L, 1)) {
Expand All @@ -269,7 +269,7 @@ bool read_schematic_def(lua_State *L, int index,
u8 param2 = getintfield_default(L, -1, "param2", 0);

//// Find or add new nodename-to-ID mapping
std::map<std::string, content_t>::iterator it = name_id_map.find(name);
UNORDERED_MAP<std::string, content_t>::iterator it = name_id_map.find(name);
content_t name_index;
if (it != name_id_map.end()) {
name_index = it->second;
Expand Down
34 changes: 18 additions & 16 deletions src/server.cpp
Expand Up @@ -979,7 +979,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)

// Key = object id
// Value = data sent by object
std::map<u16, std::vector<ActiveObjectMessage>* > buffered_messages;
UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* > buffered_messages;

// Get active object messages from environment
for(;;) {
Expand All @@ -988,7 +988,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
break;

std::vector<ActiveObjectMessage>* message_list = NULL;
std::map<u16, std::vector<ActiveObjectMessage>* >::iterator n;
UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator n;
n = buffered_messages.find(aom.id);
if (n == buffered_messages.end()) {
message_list = new std::vector<ActiveObjectMessage>;
Expand All @@ -1008,7 +1008,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
std::string reliable_data;
std::string unreliable_data;
// Go through all objects in message buffer
for (std::map<u16, std::vector<ActiveObjectMessage>* >::iterator
for (UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator
j = buffered_messages.begin();
j != buffered_messages.end(); ++j) {
// If object is not known by client, skip it
Expand Down Expand Up @@ -3122,19 +3122,21 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
if (ate)
return L"";

switch (player->canSendChatMessage()) {
case RPLAYER_CHATRESULT_FLOODING: {
std::wstringstream ws;
ws << L"You cannot send more messages. You are limited to "
<< g_settings->getFloat("chat_message_limit_per_10sec")
<< " messages per 10 seconds.";
return ws.str();
}
case RPLAYER_CHATRESULT_KICK:
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
return L"";
case RPLAYER_CHATRESULT_OK: break;
default: FATAL_ERROR("Unhandled chat filtering result found.");
if (player) {
switch (player->canSendChatMessage()) {
case RPLAYER_CHATRESULT_FLOODING: {
std::wstringstream ws;
ws << L"You cannot send more messages. You are limited to "
<< g_settings->getFloat("chat_message_limit_per_10sec")
<< " messages per 10 seconds.";
return ws.str();
}
case RPLAYER_CHATRESULT_KICK:
DenyAccess_Legacy(player->peer_id, L"You have been kicked due to message flooding.");
return L"";
case RPLAYER_CHATRESULT_OK: break;
default: FATAL_ERROR("Unhandled chat filtering result found.");
}
}

if (m_max_chatmessage_length > 0 && wmessage.length() > m_max_chatmessage_length) {
Expand Down
7 changes: 5 additions & 2 deletions src/unittest/test_settings.cpp
Expand Up @@ -32,7 +32,7 @@ class TestSettings : public TestBase {
void testAllSettings();

static const char *config_text_before;
static const char *config_text_after;
static const std::string config_text_after;
};

static TestSettings g_test_instance;
Expand Down Expand Up @@ -69,7 +69,7 @@ const char *TestSettings::config_text_before =
"np_terrain = 5, 40, (250, 250, 250), 12341, 5, 0.7, 2.4\n"
"zoop = true";

const char *TestSettings::config_text_after =
const std::string TestSettings::config_text_after =
"leet = 1337\n"
"leetleet = 13371337\n"
"leetleet_neg = -13371337\n"
Expand Down Expand Up @@ -197,7 +197,10 @@ void TestSettings::testAllSettings()
UASSERT(s.updateConfigObject(is, os, "", 0) == true);
//printf(">>>> expected config:\n%s\n", TEST_CONFIG_TEXT_AFTER);
//printf(">>>> actual config:\n%s\n", os.str().c_str());
#if __cplusplus < 201103L
// This test only works in older C++ versions than C++11 because we use unordered_map
UASSERT(os.str() == config_text_after);
#endif
} catch (SettingNotFoundException &e) {
UASSERT(!"Setting not found!");
}
Expand Down
1 change: 1 addition & 0 deletions src/unittest/test_threading.cpp
Expand Up @@ -163,6 +163,7 @@ class AtomicTestThread : public Thread {
void TestThreading::testAtomicSemaphoreThread()
{
Atomic<u32> val;
val = 0;
Semaphore trigger;
static const u8 num_threads = 4;

Expand Down
3 changes: 2 additions & 1 deletion src/util/string.h
Expand Up @@ -24,6 +24,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
#define UTIL_STRING_HEADER

#include "irrlichttypes_bloated.h"
#include "cpp11_container.h"
#include <stdlib.h>
#include <string>
#include <cstring>
Expand Down Expand Up @@ -58,7 +59,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
(((unsigned char)(x) < 0xe0) ? 2 : \
(((unsigned char)(x) < 0xf0) ? 3 : 4))

typedef std::map<std::string, std::string> StringMap;
typedef UNORDERED_MAP<std::string, std::string> StringMap;

struct FlagDesc {
const char *name;
Expand Down
12 changes: 2 additions & 10 deletions util/travis/before_install.sh
@@ -1,16 +1,8 @@
#!/bin/bash -e

if [[ $TRAVIS_OS_NAME == "linux" ]]; then
if [[ $CC == "clang" ]]; then
export PATH="/usr/bin/:$PATH"
sudo sh -c 'echo "deb http://ppa.launchpad.net/eudoxos/llvm-3.1/ubuntu precise main" >> /etc/apt/sources.list'
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 92DE8183
sudo apt-get update
sudo apt-get install llvm-3.1
sudo apt-get install clang
fi
sudo apt-get update
sudo apt-get install p7zip-full
sudo apt-get install p7zip-full $COMPILER
fi

if [[ $PLATFORM == "Unix" ]]; then
Expand All @@ -25,7 +17,7 @@ if [[ $PLATFORM == "Unix" ]]; then
else
brew update
brew install freetype gettext hiredis irrlicht jpeg leveldb libogg libvorbis luajit
brew upgrade postgresql
#brew upgrade postgresql
fi
elif [[ $PLATFORM == "Win32" ]]; then
wget http://minetest.kitsunemimi.pw/mingw_w64_i686_ubuntu12.04_4.9.1.7z -O mingw.7z
Expand Down
4 changes: 4 additions & 0 deletions util/travis/script.sh
Expand Up @@ -4,6 +4,10 @@ if [[ $PLATFORM == "Unix" ]]; then
mkdir -p travisbuild
cd travisbuild || exit 1
CMAKE_FLAGS=''
if [[ $COMPILER == "g++-6" ]]; then
export CC=gcc-6
export CXX=g++-6
fi
# Clang builds with FreeType fail on Travis
if [[ $CC == "clang" ]]; then
CMAKE_FLAGS+=' -DENABLE_FREETYPE=FALSE'
Expand Down

0 comments on commit 2526d40

Please sign in to comment.