summaryrefslogtreecommitdiff
path: root/src/environment.cpp
diff options
context:
space:
mode:
authorLars Hofhansl <larsh@apache.org>2017-01-04 11:11:55 -0800
committersfan5 <sfan5@live.de>2017-01-04 21:37:29 +0100
commitca3629637cb20cea318b8811e717e2caab579dc0 (patch)
tree76f21d687974e641bfa7ff8795f55f10514b3832 /src/environment.cpp
parentad10b8b762d8097092f307867a36e55049d69546 (diff)
downloadminetest-ca3629637cb20cea318b8811e717e2caab579dc0.tar.gz
minetest-ca3629637cb20cea318b8811e717e2caab579dc0.tar.bz2
minetest-ca3629637cb20cea318b8811e717e2caab579dc0.zip
Fixes for using std:vector in ABMHander and further perf improvements
Diffstat (limited to 'src/environment.cpp')
-rw-r--r--src/environment.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/environment.cpp b/src/environment.cpp
index 5eb9d9770..a0cf9dca5 100644
--- a/src/environment.cpp
+++ b/src/environment.cpp
@@ -827,7 +827,7 @@ public:
{
content_t c = *k;
if (c >= m_aabms.size())
- m_aabms.resize(c + 256, (std::vector<ActiveABM> *) NULL);
+ m_aabms.resize(c + 256, NULL);
if (!m_aabms[c])
m_aabms[c] = new std::vector<ActiveABM>;
m_aabms[c]->push_back(aabm);
@@ -872,7 +872,7 @@ public:
}
void apply(MapBlock *block)
{
- if(m_aabms.empty())
+ if(m_aabms.empty() || block->isDummy())
return;
ServerMap *map = &m_env->getServerMap();
@@ -886,13 +886,13 @@ public:
for(p0.Y=0; p0.Y<MAP_BLOCKSIZE; p0.Y++)
for(p0.Z=0; p0.Z<MAP_BLOCKSIZE; p0.Z++)
{
- MapNode n = block->getNodeNoEx(p0);
+ const MapNode &n = block->getNodeUnsafe(p0);
content_t c = n.getContent();
- v3s16 p = p0 + block->getPosRelative();
- if (!m_aabms[c])
+ if (c >= m_aabms.size() || !m_aabms[c])
continue;
+ v3s16 p = p0 + block->getPosRelative();
for(std::vector<ActiveABM>::iterator
i = m_aabms[c]->begin(); i != m_aabms[c]->end(); ++i) {
if(myrand() % i->chance != 0)