tuned lava/universal damage code
[oweals/minetest.git] / src / game.cpp
index 6c0474ee70688d51608294b9028c44f8dcc9d98d..c740ed252c2c949ba6abbffd57923dba8b0af215 100644 (file)
@@ -538,6 +538,56 @@ void getPointedNode(Client *client, v3f player_position,
                                }
                        }
                }
+
+               else if(n.getContent() == CONTENT_LADDER)
+               {
+                       v3s16 dir = unpackDir(n.param2);
+                       v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
+                       dir_f *= BS/2 - BS/6 - BS/20;
+                       v3f cpf = npf + dir_f;
+                       f32 distance = (cpf - camera_position).getLength();
+
+                       v3f vertices[4] =
+                       {
+                               v3f(BS*0.42,-BS/2,-BS/2),
+                               v3f(BS*0.49, BS/2, BS/2),
+                       };
+
+                       for(s32 i=0; i<2; i++)
+                       {
+                               if(dir == v3s16(1,0,0))
+                                       vertices[i].rotateXZBy(0);
+                               if(dir == v3s16(-1,0,0))
+                                       vertices[i].rotateXZBy(180);
+                               if(dir == v3s16(0,0,1))
+                                       vertices[i].rotateXZBy(90);
+                               if(dir == v3s16(0,0,-1))
+                                       vertices[i].rotateXZBy(-90);
+                               if(dir == v3s16(0,-1,0))
+                                       vertices[i].rotateXYBy(-90);
+                               if(dir == v3s16(0,1,0))
+                                       vertices[i].rotateXYBy(90);
+
+                               vertices[i] += npf;
+                       }
+
+                       core::aabbox3d<f32> box;
+
+                       box = core::aabbox3d<f32>(vertices[0]);
+                       box.addInternalPoint(vertices[1]);
+
+                       if(distance < mindistance)
+                       {
+                               if(box.intersectsWithLine(shootline))
+                               {
+                                       nodefound = true;
+                                       nodepos = np;
+                                       neighbourpos = np;
+                                       mindistance = distance;
+                                       nodehilightbox = box;
+                               }
+                       }
+               }
                else if(n.getContent() == CONTENT_RAIL)
                {
                        v3s16 dir = unpackDir(n.param0);
@@ -1012,6 +1062,14 @@ void the_game(
        {
                //std::cerr<<"frame"<<std::endl;
 
+               if(client.accessDenied())
+               {
+                       error_message = L"Access denied. Reason: "
+                                       +client.accessDeniedReason();
+                       std::cout<<DTIME<<wide_to_narrow(error_message)<<std::endl;
+                       break;
+               }
+
                if(g_gamecallback->disconnect_requested)
                {
                        g_gamecallback->disconnect_requested = false;
@@ -1471,7 +1529,8 @@ void the_game(
                }
                
                // Get player position
-               v3f player_position = client.getPlayerPosition();
+               v3f camera_position;
+               v3f player_position = client.getPlayerPosition(&camera_position);
 
                //TimeTaker //timer2("//timer2");
 
@@ -1531,11 +1590,6 @@ void the_game(
                v3f camera_direction = v3f(0,0,1);
                camera_direction.rotateYZBy(camera_pitch);
                camera_direction.rotateXZBy(camera_yaw);
-               
-               // This is at the height of the eyes of the current figure
-               //v3f camera_position = player_position + v3f(0, BS+BS/2, 0);
-               // This is more like in minecraft
-               v3f camera_position = player_position + v3f(0, BS+BS*0.625, 0);
 
                camera->setPosition(camera_position);
                // *100.0 helps in large map coordinates
@@ -1955,9 +2009,15 @@ void the_game(
                */
                if(farmesh)
                {
+                       farmesh_range = draw_control.wanted_range * 10;
+                       if(draw_control.range_all && farmesh_range < 500)
+                               farmesh_range = 500;
+                       if(farmesh_range > 1000)
+                               farmesh_range = 1000;
+
                        farmesh->step(dtime);
                        farmesh->update(v2f(player_position.X, player_position.Z),
-                                       0.05+brightness*0.95);
+                                       0.05+brightness*0.95, farmesh_range);
                }
                
                // Store brightness value
@@ -2148,6 +2208,7 @@ void the_game(
                if(client.getLocalInventoryUpdated()
                                || g_selected_item != old_selected_item)
                {
+                       client.selectPlayerItem(g_selected_item);
                        old_selected_item = g_selected_item;
                        //std::cout<<"Updating local inventory"<<std::endl;
                        client.getLocalInventory(local_inventory);
@@ -2254,6 +2315,13 @@ void the_game(
                // 0-1ms
                guienv->drawAll();
 
+               /*
+                       Environment post fx
+               */
+               {
+                       client.getEnv()->drawPostFx(driver, camera_position);
+               }
+               
                /*
                        Draw hotbar
                */
@@ -2276,13 +2344,6 @@ void the_game(
                                        NULL);
                }
 
-               /*
-                       Environment post fx
-               */
-               {
-                       client.getEnv()->drawPostFx(driver, camera_position);
-               }
-               
                /*
                        End scene
                */