| 1623 | } |
| 1624 | |
| 1625 | void SceneGraph::SendMessageToAllObjects(OBJECT_MSG::Type type) { |
| 1626 | // This is a simple loop instead of an iterator because sometimes this would crash as an iterator after |
| 1627 | // passing way past the end. Likely because objects_ is sometimes changed as a result of this call. |
| 1628 | // This solution means that most objects get called, some might not if they are first destroyed. |
| 1629 | // New objects will also be called assuming they are added last to the list. |
| 1630 | for (unsigned int i = 0; i < objects_.size(); i++) { |
| 1631 | Object* obj = objects_[i]; |
| 1632 | if (obj) { |
| 1633 | obj->ReceiveObjectMessage(type); |
| 1634 | } else { |
| 1635 | LOGE << "One of the objects is NULL when trying to SendMessageToAllObjects." << std::endl; |
| 1636 | } |
| 1637 | } |
| 1638 | } |
| 1639 | |
| 1640 | void SceneGraph::SendScriptMessageToAllObjects(std::string& msg) { |
| 1641 | // For consistency, I'm going to also make this a simple loop in case the same iterator problems affect |
no test coverage detected