@@ -770,65 +770,65 @@ class ABMHandler
770
770
771
771
v3s16 p0;
772
772
for (p0.X =0 ; p0.X <MAP_BLOCKSIZE; p0.X ++)
773
- for (p0.Y =0 ; p0.Y <MAP_BLOCKSIZE; p0.Y ++)
774
- for (p0.Z =0 ; p0.Z <MAP_BLOCKSIZE; p0.Z ++)
775
- {
776
- const MapNode &n = block->getNodeUnsafe (p0);
777
- content_t c = n.getContent ();
773
+ for (p0.Y =0 ; p0.Y <MAP_BLOCKSIZE; p0.Y ++)
774
+ for (p0.Z =0 ; p0.Z <MAP_BLOCKSIZE; p0.Z ++)
775
+ {
776
+ const MapNode &n = block->getNodeUnsafe (p0);
777
+ content_t c = n.getContent ();
778
778
779
- if (c >= m_aabms.size () || !m_aabms[c])
780
- continue ;
779
+ if (c >= m_aabms.size () || !m_aabms[c])
780
+ continue ;
781
781
782
- v3s16 p = p0 + block->getPosRelative ();
783
- for (std::vector<ActiveABM>::iterator
784
- i = m_aabms[c]->begin (); i != m_aabms[c]->end (); ++i) {
785
- if (myrand () % i->chance != 0 )
786
- continue ;
782
+ v3s16 p = p0 + block->getPosRelative ();
783
+ for (std::vector<ActiveABM>::iterator
784
+ i = m_aabms[c]->begin (); i != m_aabms[c]->end (); ++i) {
785
+ if (myrand () % i->chance != 0 )
786
+ continue ;
787
787
788
- // Check neighbors
789
- if (!i->required_neighbors .empty ())
790
- {
791
- v3s16 p1;
792
- for (p1.X = p0.X -1 ; p1.X <= p0.X +1 ; p1.X ++)
793
- for (p1.Y = p0.Y -1 ; p1.Y <= p0.Y +1 ; p1.Y ++)
794
- for (p1.Z = p0.Z -1 ; p1.Z <= p0.Z +1 ; p1.Z ++)
795
- {
796
- if (p1 == p0)
797
- continue ;
798
- content_t c;
799
- if (block->isValidPosition (p1)) {
800
- // if the neighbor is found on the same map block
801
- // get it straight from there
802
- const MapNode &n = block->getNodeUnsafe (p1);
803
- c = n.getContent ();
804
- } else {
805
- // otherwise consult the map
806
- MapNode n = map->getNodeNoEx (p1 + block->getPosRelative ());
807
- c = n.getContent ();
808
- }
809
- std::set<content_t >::const_iterator k;
810
- k = i->required_neighbors .find (c);
811
- if (k != i->required_neighbors .end ()){
812
- goto neighbor_found;
813
- }
814
- }
815
- // No required neighbor found
788
+ // Check neighbors
789
+ if (!i->required_neighbors .empty ())
790
+ {
791
+ v3s16 p1;
792
+ for (p1.X = p0.X -1 ; p1.X <= p0.X +1 ; p1.X ++)
793
+ for (p1.Y = p0.Y -1 ; p1.Y <= p0.Y +1 ; p1.Y ++)
794
+ for (p1.Z = p0.Z -1 ; p1.Z <= p0.Z +1 ; p1.Z ++)
795
+ {
796
+ if (p1 == p0)
816
797
continue ;
798
+ content_t c;
799
+ if (block->isValidPosition (p1)) {
800
+ // if the neighbor is found on the same map block
801
+ // get it straight from there
802
+ const MapNode &n = block->getNodeUnsafe (p1);
803
+ c = n.getContent ();
804
+ } else {
805
+ // otherwise consult the map
806
+ MapNode n = map->getNodeNoEx (p1 + block->getPosRelative ());
807
+ c = n.getContent ();
817
808
}
818
- neighbor_found:
819
-
820
- // Call all the trigger variations
821
- i->abm ->trigger (m_env, p, n);
822
- i->abm ->trigger (m_env, p, n,
823
- active_object_count, active_object_count_wider);
824
-
825
- // Count surrounding objects again if the abms added any
826
- if (m_env->m_added_objects > 0 ) {
827
- active_object_count = countObjects (block, map, active_object_count_wider);
828
- m_env->m_added_objects = 0 ;
809
+ std::set<content_t >::const_iterator k;
810
+ k = i->required_neighbors .find (c);
811
+ if (k != i->required_neighbors .end ()){
812
+ goto neighbor_found;
829
813
}
830
814
}
815
+ // No required neighbor found
816
+ continue ;
831
817
}
818
+ neighbor_found:
819
+
820
+ // Call all the trigger variations
821
+ i->abm ->trigger (m_env, p, n);
822
+ i->abm ->trigger (m_env, p, n,
823
+ active_object_count, active_object_count_wider);
824
+
825
+ // Count surrounding objects again if the abms added any
826
+ if (m_env->m_added_objects > 0 ) {
827
+ active_object_count = countObjects (block, map, active_object_count_wider);
828
+ m_env->m_added_objects = 0 ;
829
+ }
830
+ }
831
+ }
832
832
}
833
833
};
834
834
0 commit comments