moved map generator to separate source files

This commit is contained in:
Perttu Ahola 2011-06-25 18:12:41 +03:00
parent b55d2d4a65
commit f2c26e2014
7 changed files with 2002 additions and 1920 deletions

View File

@ -61,6 +61,7 @@ configure_file(
)
set(common_SRCS
mapgen.cpp
content_inventory.cpp
content_nodemeta.cpp
content_craft.cpp

View File

@ -29,16 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "map.h"
#include "client.h"
/*
Temporarily exposed map generator stuff
Should only be used for testing
*/
//extern double base_rock_level_2d(u64 seed, v2s16 p);
//extern double get_mud_add_amount(u64 seed, v2s16 p);
extern s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
extern bool get_have_sand(u64 seed, v2s16 p2d);
extern double tree_amount_2d(u64 seed, v2s16 p);
#include "mapgen.h"
FarMesh::FarMesh(
scene::ISceneNode* parent,
@ -127,14 +118,14 @@ HeightPoint ground_height(u64 seed, v2s16 p2d)
if(n)
return n->getValue();
HeightPoint hp;
s16 level = find_ground_level_from_noise(seed, p2d, 3);
s16 level = mapgen::find_ground_level_from_noise(seed, p2d, 3);
hp.gh = (level-4)*BS;
hp.ma = (4)*BS;
/*hp.gh = BS*base_rock_level_2d(seed, p2d);
hp.ma = BS*get_mud_add_amount(seed, p2d);*/
hp.have_sand = get_have_sand(seed, p2d);
hp.have_sand = mapgen::get_have_sand(seed, p2d);
if(hp.gh > BS*WATER_LEVEL)
hp.tree_amount = tree_amount_2d(seed, p2d);
hp.tree_amount = mapgen::tree_amount_2d(seed, p2d);
else
hp.tree_amount = 0;
// No mud has been added if mud amount is less than 1

File diff suppressed because it is too large Load Diff

1936
src/mapgen.cpp Normal file

File diff suppressed because it is too large Load Diff

51
src/mapgen.h Normal file
View File

@ -0,0 +1,51 @@
/*
Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MAPGEN_HEADER
#define MAPGEN_HEADER
#include "common_irrlicht.h"
struct BlockMakeData;
class MapBlock;
namespace mapgen
{
// Finds precise ground level at any position
s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision);
// Find out if block is completely underground
bool block_is_underground(u64 seed, v3s16 blockpos);
// Main map generation routine
void make_block(BlockMakeData *data);
// Add objects according to block content
void add_random_objects(MapBlock *block);
/*
These are used by FarMesh
*/
bool get_have_sand(u64 seed, v2s16 p2d);
double tree_amount_2d(u64 seed, v2s16 p);
}; // namespace mapgen
#endif

View File

@ -2546,12 +2546,12 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
}
/*
Send the removal to all other clients.
Send the removal to all close-by players.
- If other player is close, send REMOVENODE
- Otherwise set blocks not sent
*/
core::list<u16> far_players;
sendRemoveNode(p_under, peer_id, &far_players, 100);
sendRemoveNode(p_under, peer_id, &far_players, 30);
/*
Update and send inventory
@ -2714,10 +2714,10 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
n.dir = packDir(p_under - p_over);
/*
Send to all players
Send to all close-by players
*/
core::list<u16> far_players;
sendAddNode(p_over, n, 0, &far_players, 100);
sendAddNode(p_over, n, 0, &far_players, 30);
/*
Handle inventory

View File

@ -17,10 +17,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
(c) 2010 Perttu Ahola <celeron55@gmail.com>
*/
#ifndef SERVER_HEADER
#define SERVER_HEADER