]> git.localhorst.tv Git - blank.git/blobdiff - src/world/world.cpp
launch xvfb on travis
[blank.git] / src / world / world.cpp
index 2292d15418f6dd30420bb329b9f09fb2fcb2c8f4..528bc40c1b242358cd6026d81969e8c53ab62463 100644 (file)
@@ -764,6 +764,26 @@ Entity &World::ForceAddEntity(std::uint32_t id) {
 }
 
 
+Player *World::FindPlayer(const std::string &name) {
+       for (Player &p : players) {
+               if (p.Name() == name) {
+                       return &p;
+               }
+       }
+       return nullptr;
+}
+
+Entity *World::FindEntity(const std::string &name) {
+       // TODO: this may get inefficient
+       for (Entity &e : entities) {
+               if (e.Name() == name) {
+                       return &e;
+               }
+       }
+       return nullptr;
+}
+
+
 namespace {
 
 struct Candidate {
@@ -1103,7 +1123,7 @@ void World::RenderDebug(Viewport &viewport) {
        PrimitiveMesh debug_mesh;
        PlainColor &prog = viewport.WorldColorProgram();
        for (const Entity &entity : entities) {
-               debug_buf.OutlineBox(entity.Bounds(), TVEC4<unsigned char, glm::precision(0)>(255, 0, 0, 255));
+               debug_buf.OutlineBox(entity.Bounds(), PrimitiveMesh::Color(255, 0, 0, 255));
                debug_mesh.Update(debug_buf);
                prog.SetM(entity.Transform(players.front().GetEntity().ChunkCoords()));
                debug_mesh.DrawLines();