]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/game.cpp
Prevent world creation if the world already exists
[dragonfireclient.git] / src / game.cpp
index 3ba90789ada36fe53b1a06bdb469d37f067f7fbb..a1a197219f4bad5b0c03d013aa0f6a859d17edfd 100644 (file)
@@ -111,6 +111,20 @@ struct TextDestNodeMetadata : public TextDest
        Client *m_client;
 };
 
+struct TextDestPlayerInventory : public TextDest
+{
+       TextDestPlayerInventory(Client *client)
+       {
+               m_client = client;
+       }
+       void gotText(std::map<std::string, std::string> fields)
+       {
+               m_client->sendInventoryFields("", fields);
+       }
+
+       Client *m_client;
+};
+
 /* Respawn menu callback */
 
 class MainRespawnInitiator: public IRespawnInitiator
@@ -1221,6 +1235,9 @@ void the_game(
        float object_hit_delay_timer = 0.0;
        float time_from_last_punch = 10;
 
+       float update_draw_list_timer = 0.0;
+       v3f update_draw_list_last_cam_dir;
+
        bool invert_mouse = g_settings->getBool("invert_mouse");
 
        bool respawn_menu_active = false;
@@ -1507,6 +1524,7 @@ void the_game(
                        assert(src);
                        menu->setFormSpec(src->getForm(), inventoryloc);
                        menu->setFormSource(src);
+                       menu->setTextDest(new TextDestPlayerInventory(&client));
                        menu->drop();
                }
                else if(input->wasKeyDown(EscapeKey))
@@ -2289,6 +2307,13 @@ void the_game(
                                                                <<playeritem.name<<" is "
                                                                <<def.node_placement_prediction<<std::endl;
                                                v3s16 p = neighbourpos;
+                                               // Place inside node itself if buildable_to
+                                               try{
+                                                       MapNode n_under = map.getNode(nodepos);
+                                                       if(nodedef->get(n_under).buildable_to)
+                                                               p = nodepos;
+                                               }catch(InvalidPositionException &e){}
+                                               // Find id of predicted node
                                                content_t id;
                                                bool found =
                                                        nodedef->getId(def.node_placement_prediction, id);
@@ -2675,7 +2700,19 @@ void the_game(
                                item = mlist->getItem(client.getPlayerItem());
                        camera.wield(item);
                }
-               
+
+               /*
+                       Update block draw list every 200ms or when camera direction has
+                       changed much
+               */
+               update_draw_list_timer += dtime;
+               if(update_draw_list_timer >= 0.2 ||
+                               update_draw_list_last_cam_dir.getDistanceFrom(camera_direction) > 0.2){
+                       update_draw_list_timer = 0;
+                       client.getEnv().getClientMap().updateDrawList(driver);
+                       update_draw_list_last_cam_dir = camera_direction;
+               }
+
                /*
                        Drawing begins
                */