bug-fixin'

This commit is contained in:
Perttu Ahola 2011-02-08 01:12:55 +02:00
parent 25a7fabed8
commit dd9e82f5bc
24 changed files with 347 additions and 178 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -77,6 +77,7 @@ Compiling on Windows:
for many people. The old build system is still included, but it's not for many people. The old build system is still included, but it's not
documented anywhere. documented anywhere.
- You need CMake, Irrlicht, Zlib and Visual Studio or MinGW - You need CMake, Irrlicht, Zlib and Visual Studio or MinGW
- you can get zlibwapi.lib from a file called zlib125dll.zip
- NOTE: Probably it will not work easily and you will need to fix some stuff. - NOTE: Probably it will not work easily and you will need to fix some stuff.
- Steps: - Steps:
- Start up the CMake GUI - Start up the CMake GUI

View File

@ -24,6 +24,7 @@
#enable_fog = true #enable_fog = true
#new_style_water = true #new_style_water = true
#new_style_leaves = true
# Server side stuff # Server side stuff

View File

@ -219,10 +219,6 @@
RelativePath=".\src\guiTextInputMenu.cpp" RelativePath=".\src\guiTextInputMenu.cpp"
> >
</File> </File>
<File
RelativePath=".\src\heightmap.cpp"
>
</File>
<File <File
RelativePath=".\src\inventory.cpp" RelativePath=".\src\inventory.cpp"
> >
@ -275,6 +271,10 @@
RelativePath=".\src\mineral.cpp" RelativePath=".\src\mineral.cpp"
> >
</File> </File>
<File
RelativePath=".\src\noise.cpp"
>
</File>
<File <File
RelativePath=".\src\player.cpp" RelativePath=".\src\player.cpp"
> >

View File

@ -30,7 +30,9 @@ else()
endif(BUILD_CLIENT) endif(BUILD_CLIENT)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
set(PLATFORM_LIBS -lpthread) set(PLATFORM_LIBS -lpthread)
set(CLIENT_PLATFORM_LIBS -lXxf86vm) #set(CLIENT_PLATFORM_LIBS -lXxf86vm)
find_library(XXF86VM_LIBRARY, Xxf86vm)
set(CLIENT_PLATFORM_LIBS ${XXF86VM_LIBRARY})
endif() endif()
configure_file( configure_file(

View File

@ -279,10 +279,11 @@ void Client::step(float dtime)
// [0] u16 TOSERVER_INIT // [0] u16 TOSERVER_INIT
// [2] u8 SER_FMT_VER_HIGHEST // [2] u8 SER_FMT_VER_HIGHEST
// [3] u8[20] player_name // [3] u8[20] player_name
SharedBuffer<u8> data(2+1+20); SharedBuffer<u8> data(2+1+PLAYERNAME_SIZE);
writeU16(&data[0], TOSERVER_INIT); writeU16(&data[0], TOSERVER_INIT);
writeU8(&data[2], SER_FMT_VER_HIGHEST); writeU8(&data[2], SER_FMT_VER_HIGHEST);
memcpy(&data[3], myplayer->getName(), 20); memset((char*)&data[3], 0, PLAYERNAME_SIZE);
snprintf((char*)&data[3], PLAYERNAME_SIZE, "%s", myplayer->getName());
// Send as unreliable // Send as unreliable
Send(0, data, false); Send(0, data, false);
} }

View File

@ -23,6 +23,9 @@ extern Settings g_settings;
void set_default_settings() void set_default_settings()
{ {
// Client and server
g_settings.setDefault("footprints", "false");
// Client stuff // Client stuff
g_settings.setDefault("wanted_fps", "30"); g_settings.setDefault("wanted_fps", "30");
g_settings.setDefault("fps_max", "60"); g_settings.setDefault("fps_max", "60");
@ -37,7 +40,7 @@ void set_default_settings()
g_settings.setDefault("client_delete_unused_sectors_timeout", "1200"); g_settings.setDefault("client_delete_unused_sectors_timeout", "1200");
g_settings.setDefault("enable_fog", "true"); g_settings.setDefault("enable_fog", "true");
g_settings.setDefault("new_style_water", "true"); g_settings.setDefault("new_style_water", "true");
g_settings.setDefault("terrain_viewer", "false"); g_settings.setDefault("new_style_leaves", "true");
g_settings.setDefault("free_move", "false"); g_settings.setDefault("free_move", "false");
g_settings.setDefault("continuous_forward", "false"); g_settings.setDefault("continuous_forward", "false");

View File

@ -118,9 +118,9 @@ void Environment::step(float dtime)
/* /*
Apply water resistance Apply water resistance
*/ */
if(player->in_water) if(player->in_water_stable)
{ {
f32 max_down = 1.0*BS; f32 max_down = 1.5*BS;
if(speed.Y < -max_down) speed.Y = -max_down; if(speed.Y < -max_down) speed.Y = -max_down;
f32 max = 2.5*BS; f32 max = 2.5*BS;
@ -155,6 +155,8 @@ void Environment::step(float dtime)
/* /*
Add footsteps to grass Add footsteps to grass
*/ */
if(g_settings.getBool("footprints"))
{
// Get node that is at BS/4 under player // Get node that is at BS/4 under player
v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0)); v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0));
try{ try{
@ -179,6 +181,7 @@ void Environment::step(float dtime)
} }
} }
} }
}
while(dtime > 0.001); while(dtime > 0.001);
//std::cout<<"Looped "<<loopcount<<" times."<<std::endl; //std::cout<<"Looped "<<loopcount<<" times."<<std::endl;

View File

@ -261,13 +261,13 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
case 257: // Start game case 257: // Start game
acceptInput(); acceptInput();
quitMenu(); quitMenu();
break; return true;
case 260: // Delete map case 260: // Delete map
// Don't accept input data, just set deletion request // Don't accept input data, just set deletion request
m_data->delete_map = true; m_data->delete_map = true;
m_accepted = true; m_accepted = true;
quitMenu(); quitMenu();
break; return true;
} }
} }
if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER)
@ -277,7 +277,7 @@ bool GUIMainMenu::OnEvent(const SEvent& event)
case 256: case 257: case 258: case 256: case 257: case 258:
acceptInput(); acceptInput();
quitMenu(); quitMenu();
break; return true;
} }
} }
} }

View File

@ -142,7 +142,7 @@ bool GUIMessageMenu::OnEvent(const SEvent& event)
case 257: case 257:
m_status = true; m_status = true;
quitMenu(); quitMenu();
break; return true;
} }
} }
} }

View File

@ -193,15 +193,16 @@ bool GUIPauseMenu::OnEvent(const SEvent& event)
{ {
case 256: // continue case 256: // continue
quitMenu(); quitMenu();
break; // ALWAYS return immediately after quitMenu()
return true;
case 260: // disconnect case 260: // disconnect
m_gamecallback->disconnect(); m_gamecallback->disconnect();
quitMenu(); quitMenu();
break; return true;
case 257: // exit case 257: // exit
m_gamecallback->exitToOS(); m_gamecallback->exitToOS();
quitMenu(); quitMenu();
break; return true;
} }
} }
} }

View File

@ -172,7 +172,8 @@ bool GUITextInputMenu::OnEvent(const SEvent& event)
case 257: case 257:
acceptInput(); acceptInput();
quitMenu(); quitMenu();
break; // quitMenu deallocates menu
return true;
} }
} }
if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER)
@ -182,7 +183,8 @@ bool GUITextInputMenu::OnEvent(const SEvent& event)
case 256: case 256:
acceptInput(); acceptInput();
quitMenu(); quitMenu();
break; // quitMenu deallocates menu
return true;
} }
} }
} }

View File

@ -112,19 +112,12 @@ Documentation:
Build system / running: Build system / running:
----------------------- -----------------------
NOTE: The following fixme is not apparently valid, and it does work.
FIXME: Graphical mode seems to segfault with Irrlicht 1.7.1 on 64-bit
systems. (Ubuntu)
- http://pastebin.no/32bo
- Might be just a bad build, too
- Doesn't affect Irrlicht 1.7.2 or 32-bit 1.7.1. (Arch/Debian)
- A similar error occurs when getTexture is called from a thread
when the texture has not been already loaded from disk:
http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?p=68830
FIXME: Some network errors on Windows that cause local game to not work FIXME: Some network errors on Windows that cause local game to not work
- See siggjen's emails. - See siggjen's emails.
- Is this the famous "windows 7 problem"? - Is this the famous "windows 7 problem"?
- Apparently there might be other errors too
- There is some problem with the menu system, something like the
.Parent of guiPauseMenu to end up being 0xfeeefeee
Networking and serialization: Networking and serialization:
----------------------------- -----------------------------
@ -254,26 +247,10 @@ TODO: Flowing water to actually contain flow direction information
TODO: Remove duplicate lighting implementation from Map (leave TODO: Remove duplicate lighting implementation from Map (leave
VoxelManipulator, which is faster) VoxelManipulator, which is faster)
FEATURE: Map generator version 2 FEATURE: Create a system that allows a huge amount of different "map
- Create a system that allows a huge amount of different "map
generator modules/filters" generator modules/filters"
FEATURE: The map could be generated procedually: FEATURE: Erosion simulation at map generation time
- This would need the map to be generated in larger pieces
- How large? How do they connect to each other?
- It has to be split vertically also
- Lighting would not have to be necessarily calculated until
the blocks are actually needed - it would be quite fast
- Something like 64*64*16 MapBlocks?
- No, MapSectors. And as much as it is efficient to do,
64x64 might be too much.
- FIXME: This is currently halfway done and the generator is
fairly broken
* Make the stone level with a heightmap
* Carve out stuff in the stone
* Dump dirt all around, and simulate it falling off steep
places
* Erosion simulation at map generation time
- Simulate water flows, which would carve out dirt fast and - Simulate water flows, which would carve out dirt fast and
then turn stone into gravel and sand and relocate it. then turn stone into gravel and sand and relocate it.
- How about relocating minerals, too? Coal and gold in - How about relocating minerals, too? Coal and gold in
@ -294,8 +271,7 @@ Doing now (most important at the top):
- map/meta.txt, which should contain only plain text, something like this: - map/meta.txt, which should contain only plain text, something like this:
seed = 7ff1bafcd7118800 seed = 7ff1bafcd7118800
chunksize = 8 chunksize = 8
- map/chunks.dat - map/chunks.dat: chunk positions and flags in binary format
* Save chunk metadata on disk
* Make server find the spawning place from the real map data, not from * Make server find the spawning place from the real map data, not from
the heightmap the heightmap
- But the changing borders of chunk have to be avoided, because - But the changing borders of chunk have to be avoided, because
@ -306,7 +282,6 @@ Doing now (most important at the top):
* Check the fixmes in the list above * Check the fixmes in the list above
=== Stuff to do after release === Stuff to do after release
* Set backface culling on, especially for water
* Add some kind of erosion and other stuff that now is possible * Add some kind of erosion and other stuff that now is possible
* Make client to fetch stuff asynchronously * Make client to fetch stuff asynchronously
- Needs method SyncProcessData - Needs method SyncProcessData
@ -316,7 +291,7 @@ Doing now (most important at the top):
* Water doesn't start flowing after map generation like it should * Water doesn't start flowing after map generation like it should
- Are there still problems? - Are there still problems?
* Better water generation (spread it to underwater caverns but don't * Better water generation (spread it to underwater caverns but don't
fill dungeons that don't touch outside air) fill dungeons that don't touch big water masses)
* When generating a chunk and the neighboring chunk doesn't have mud * When generating a chunk and the neighboring chunk doesn't have mud
and stuff yet and the ground is fairly flat, the mud will flow to and stuff yet and the ground is fairly flat, the mud will flow to
the other chunk making nasty straight walls when the other chunk the other chunk making nasty straight walls when the other chunk
@ -1943,7 +1918,9 @@ int main(int argc, char *argv[])
continue; continue;
} }
std::cout<<DTIME<<"Connecting to server..."<<std::endl; dstream<<DTIME<<"Connecting to server at ";
connect_address.print(&dstream);
dstream<<std::endl;
client.connect(connect_address); client.connect(connect_address);
try{ try{

View File

@ -1455,8 +1455,8 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks)
u32 loopcount = 0; u32 loopcount = 0;
u32 initial_size = m_transforming_liquid.size(); u32 initial_size = m_transforming_liquid.size();
if(initial_size != 0) /*if(initial_size != 0)
dstream<<"transformLiquids(): initial_size="<<initial_size<<std::endl; dstream<<"transformLiquids(): initial_size="<<initial_size<<std::endl;*/
while(m_transforming_liquid.size() != 0) while(m_transforming_liquid.size() != 0)
{ {
@ -1912,7 +1912,8 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0)
p1.Y -= 1; p1.Y -= 1;
VoxelArea leaves_a(v3s16(-2,-2,-2), v3s16(2,2,2)); VoxelArea leaves_a(v3s16(-2,-2,-2), v3s16(2,2,2));
SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]); //SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
Buffer<u8> leaves_d(leaves_a.getVolume());
for(s32 i=0; i<leaves_a.getVolume(); i++) for(s32 i=0; i<leaves_a.getVolume(); i++)
leaves_d[i] = 0; leaves_d[i] = 0;
@ -1974,7 +1975,7 @@ double tree_amount_2d(u64 seed, v2s16 p)
double noise = noise2d_perlin( double noise = noise2d_perlin(
0.5+(float)p.X/250, 0.5+(float)p.Y/250, 0.5+(float)p.X/250, 0.5+(float)p.Y/250,
seed+2, 5, 0.6); seed+2, 5, 0.6);
double zeroval = -0.4; double zeroval = -0.3;
if(noise < zeroval) if(noise < zeroval)
return 0; return 0;
else else
@ -2009,11 +2010,17 @@ double base_rock_level_2d(u64 seed, v2s16 p)
{ {
// The base ground level // The base ground level
double base = WATER_LEVEL - 4.0 + 25. * noise2d_perlin( double base = WATER_LEVEL - 4.0 + 25. * noise2d_perlin(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed, 6, 0.6); (seed>>32)+654879876, 6, 0.6);
/*// A bit hillier one
double base2 = WATER_LEVEL - 4.0 + 40. * noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
(seed>>27)+90340, 6, 0.69);
if(base2 > base)
base = base2;*/
#if 1
// Higher ground level // Higher ground level
double higher = WATER_LEVEL + 23. + 30. * noise2d_perlin( double higher = WATER_LEVEL + 13. + 50. * noise2d_perlin(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
seed+85039, 6, 0.69); seed+85039, 6, 0.69);
//higher = 30; // For debugging //higher = 30; // For debugging
@ -2027,21 +2034,30 @@ double base_rock_level_2d(u64 seed, v2s16 p)
0.5+(float)p.X/250., 0.5+(float)p.Y/250., 0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed-932, 7, 0.7); seed-932, 7, 0.7);
b = rangelim(b, 0.0, 1000.0); b = rangelim(b, 0.0, 1000.0);
// Make steep stuff very steep and non-steep stuff very non-steep b = pow(b, 5);
b = pow(b, 4); b *= 7;
b *= 10; b = rangelim(b, 3.0, 1000.0);
//dstream<<"b="<<b<<std::endl;
//double b = 20; //double b = 20;
// Offset to more low
double a_off = -0.3;
// High/low selector // High/low selector
double a = 0.5 + b * noise2d_perlin( /*double a = 0.5 + b * (a_off + noise2d_perlin(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
seed-359, 6, 0.7); seed-359, 6, 0.7));*/
double a = 0.5 + b * (a_off + noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed-359, 5, 0.60));
// Limit
a = rangelim(a, 0.0, 1.0); a = rangelim(a, 0.0, 1.0);
//dstream<<"a="<<a<<std::endl; //dstream<<"a="<<a<<std::endl;
double h = base*(1.0-a) + higher*a; double h = base*(1.0-a) + higher*a;
#else
double h = base;
#endif
return h; return h;
} }
@ -2397,12 +2413,12 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
/* /*
Make dungeons Make dungeons
*/ */
u32 dungeons_count = relative_volume / 600000; //u32 dungeons_count = relative_volume / 600000;
u32 bruises_count = relative_volume * stone_surface_max_y / 40000000; /*u32 bruises_count = relative_volume * stone_surface_max_y / 40000000;
if(stone_surface_max_y < WATER_LEVEL) if(stone_surface_max_y < WATER_LEVEL)
bruises_count = 0; bruises_count = 0;*/
//dungeons_count = 0; u32 dungeons_count = 0;
//bruises_count = 0; u32 bruises_count = 0;
for(u32 jj=0; jj<dungeons_count+bruises_count; jj++) for(u32 jj=0; jj<dungeons_count+bruises_count; jj++)
{ {
s16 min_tunnel_diameter = 2; s16 min_tunnel_diameter = 2;
@ -2536,7 +2552,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
//s16 si2 = rs - MYMAX(0, maxabsxz-rs/4); //s16 si2 = rs - MYMAX(0, maxabsxz-rs/4);
s16 si2 = rs - MYMAX(0, maxabsxz-rs/7); s16 si2 = rs - MYMAX(0, maxabsxz-rs/7);
//s16 si2 = rs - abs(x0); //s16 si2 = rs - abs(x0);
for(s16 y0=-si2+1; y0<=si2-1; y0++) for(s16 y0=-si2+1+1; y0<=si2-1; y0++)
{ {
s16 z = cp.Z + z0; s16 z = cp.Z + z0;
s16 y = cp.Y + y0; s16 y = cp.Y + y0;
@ -2723,7 +2739,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
m_seed+1, 3, 0.55)); m_seed+1, 3, 0.55));
// Find ground level // Find ground level
s16 surface_y = find_ground_level(vmanip, p2d); s16 surface_y = find_ground_level_clever(vmanip, p2d);
/* /*
If topmost node is grass, change it to mud. If topmost node is grass, change it to mud.
@ -3031,7 +3047,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500,
m_seed+59420, 3, 0.50); m_seed+59420, 3, 0.50);
bool have_sand = (sandnoise > 0.0); bool have_sand = (sandnoise > -0.15);
if(have_sand == false) if(have_sand == false)
continue; continue;

View File

@ -210,10 +210,10 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p,
v3f vertex_pos[4]; v3f vertex_pos[4];
// If looking towards z+, this is the face that is behind // If looking towards z+, this is the face that is behind
// the center point, facing towards z+. // the center point, facing towards z+.
vertex_pos[0] = v3f( BS/2,-BS/2,BS/2); vertex_pos[0] = v3f(-BS/2,-BS/2,BS/2);
vertex_pos[1] = v3f(-BS/2,-BS/2,BS/2); vertex_pos[1] = v3f( BS/2,-BS/2,BS/2);
vertex_pos[2] = v3f(-BS/2, BS/2,BS/2); vertex_pos[2] = v3f( BS/2, BS/2,BS/2);
vertex_pos[3] = v3f( BS/2, BS/2,BS/2); vertex_pos[3] = v3f(-BS/2, BS/2,BS/2);
if(dir == v3s16(0,0,1)) if(dir == v3s16(0,0,1))
{ {
@ -609,7 +609,12 @@ void MapBlock::updateMesh(u32 daynight_ratio)
m_temp_mods.copy(temp_mods); m_temp_mods.copy(temp_mods);
} }
/*
Some settings
*/
bool new_style_water = g_settings.getBool("new_style_water"); bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
float node_water_level = 1.0; float node_water_level = 1.0;
if(new_style_water) if(new_style_water)
node_water_level = 0.9; node_water_level = 0.9;
@ -695,6 +700,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
material.BackfaceCulling = false; material.BackfaceCulling = false;
material.setFlag(video::EMF_BILINEAR_FILTER, false); material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF); material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
material.setFlag(video::EMF_FOG_ENABLE, true); material.setFlag(video::EMF_FOG_ENABLE, true);
for(u32 i=0; i<fastfaces_new.size(); i++) for(u32 i=0; i<fastfaces_new.size(); i++)
@ -708,10 +714,13 @@ void MapBlock::updateMesh(u32 daynight_ratio)
continue; continue;
material.setTexture(0, texture); material.setTexture(0, texture);
if(f.tile.alpha != 255)
f.tile.applyMaterialOptions(material);
/*if(f.tile.alpha != 255)
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
else else
material.MaterialType = video::EMT_SOLID; material.MaterialType = video::EMT_SOLID;*/
collector.append(material, f.vertices, 4, indices, 6); collector.append(material, f.vertices, 4, indices, 6);
} }
@ -727,14 +736,22 @@ void MapBlock::updateMesh(u32 daynight_ratio)
//TimeTaker timer2("updateMesh() adding special stuff"); //TimeTaker timer2("updateMesh() adding special stuff");
// Flowing water material // Flowing water material
video::SMaterial material_w1; video::SMaterial material_water1;
material_w1.setFlag(video::EMF_LIGHTING, false); material_water1.setFlag(video::EMF_LIGHTING, false);
material_w1.setFlag(video::EMF_BACK_FACE_CULLING, false); material_water1.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_w1.setFlag(video::EMF_BILINEAR_FILTER, false); material_water1.setFlag(video::EMF_BILINEAR_FILTER, false);
material_w1.setFlag(video::EMF_FOG_ENABLE, true); material_water1.setFlag(video::EMF_FOG_ENABLE, true);
material_w1.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; material_water1.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
material_w1.setTexture(0, material_water1.setTexture(0, g_irrlicht->getTexture("water.png"));
g_irrlicht->getTexture("water.png"));
// New-style leaves material
video::SMaterial material_leaves1;
material_leaves1.setFlag(video::EMF_LIGHTING, false);
//material_leaves1.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_leaves1.setFlag(video::EMF_BILINEAR_FILTER, false);
material_leaves1.setFlag(video::EMF_FOG_ENABLE, true);
material_leaves1.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
material_leaves1.setTexture(0, g_irrlicht->getTexture("leaves.png"));
for(s16 z=0; z<MAP_BLOCKSIZE; z++) for(s16 z=0; z<MAP_BLOCKSIZE; z++)
for(s16 y=0; y<MAP_BLOCKSIZE; y++) for(s16 y=0; y<MAP_BLOCKSIZE; y++)
@ -1020,7 +1037,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material_w1, vertices, 4, indices, 6); collector.append(material_water1, vertices, 4, indices, 6);
} }
/* /*
@ -1047,11 +1064,11 @@ void MapBlock::updateMesh(u32 daynight_ratio)
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material_w1, vertices, 4, indices, 6); collector.append(material_water1, vertices, 4, indices, 6);
} }
} }
/* /*
Add water sources to mesh Add water sources to mesh if using new style
*/ */
else if(n.d == CONTENT_WATERSOURCE && new_style_water) else if(n.d == CONTENT_WATERSOURCE && new_style_water)
{ {
@ -1089,7 +1106,66 @@ void MapBlock::updateMesh(u32 daynight_ratio)
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material_w1, vertices, 4, indices, 6); collector.append(material_water1, vertices, 4, indices, 6);
}
/*
Add leaves if using new style
*/
else if(n.d == CONTENT_LEAVES && new_style_leaves)
{
u8 l = decode_light(n.getLightBlend(daynight_ratio));
video::SColor c(255,l,l,l);
for(u32 j=0; j<6; j++)
{
video::S3DVertex vertices[4] =
{
video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, 0,1),
video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 1,1),
video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, 1,0),
video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, 0,0),
};
if(j == 0)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateXZBy(0);
}
else if(j == 1)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateXZBy(180);
}
else if(j == 2)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateXZBy(-90);
}
else if(j == 3)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateXZBy(90);
}
else if(j == 4)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateYZBy(-90);
}
else if(j == 5)
{
for(u16 i=0; i<4; i++)
vertices[i].Pos.rotateYZBy(90);
}
for(u16 i=0; i<4; i++)
{
vertices[i].Pos += intToFloat(p + getPosRelative());
}
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
collector.append(material_leaves1, vertices, 4, indices, 6);
}
} }
} }

View File

@ -40,6 +40,9 @@ ContentFeatures & content_features(u8 i)
void init_mapnode(IIrrlichtWrapper *irrlicht) void init_mapnode(IIrrlichtWrapper *irrlicht)
{ {
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
u8 i; u8 i;
ContentFeatures *f = NULL; ContentFeatures *f = NULL;
@ -92,9 +95,25 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
i = CONTENT_LEAVES; i = CONTENT_LEAVES;
f = &g_content_features[i]; f = &g_content_features[i];
f->setAllTextures(irrlicht->getTextureId("leaves.png")); f->light_propagates = true;
f->param_type = CPT_MINERAL; //f->param_type = CPT_MINERAL;
f->param_type = CPT_LIGHT;
f->is_ground_content = true; f->is_ground_content = true;
if(new_style_leaves)
{
f->solidness = 0; // drawn separately, makes no faces
}
else
{
f->setAllTextures(irrlicht->getTextureId("leaves.png"));
}
/*{
TileSpec t;
t.spec = TextureSpec(irrlicht->getTextureId("leaves.png"));
//t.material_type = MATERIAL_ALPHA_SIMPLE;
//t.material_flags |= MATERIAL_FLAG_BACKFACE_CULLING;
f->setAllTiles(t);
}*/
i = CONTENT_COALSTONE; i = CONTENT_COALSTONE;
f = &g_content_features[i]; f = &g_content_features[i];
@ -141,17 +160,26 @@ void init_mapnode(IIrrlichtWrapper *irrlicht)
f->buildable_to = true; f->buildable_to = true;
f->liquid_type = LIQUID_FLOWING; f->liquid_type = LIQUID_FLOWING;
bool new_style_water = g_settings.getBool("new_style_water");
i = CONTENT_WATERSOURCE; i = CONTENT_WATERSOURCE;
f = &g_content_features[i]; f = &g_content_features[i];
//f->setTexture(0, irrlicht->getTextureId("water.png"), WATER_ALPHA);
if(new_style_water == false)
f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
f->setInventoryTexture(irrlicht->getTextureId("water.png")); f->setInventoryTexture(irrlicht->getTextureId("water.png"));
if(new_style_water)
{
f->solidness = 0; // drawn separately, makes no faces
}
else // old style
{
f->setAllTextures(irrlicht->getTextureId("water.png"), WATER_ALPHA);
TileSpec t;
t.spec = TextureSpec(irrlicht->getTextureId("water.png"));
t.alpha = WATER_ALPHA;
t.material_type = MATERIAL_ALPHA_VERTEX;
t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
f->setAllTiles(t);
f->solidness = 1;
}
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->light_propagates = true; f->light_propagates = true;
f->solidness = 1;
f->walkable = false; f->walkable = false;
f->pointable = false; f->pointable = false;
f->diggable = false; f->diggable = false;

View File

@ -167,25 +167,38 @@ struct ContentFeatures
~ContentFeatures(); ~ContentFeatures();
// Quickhands for simple materials
void setTexture(u16 i, const TextureSpec &spec, u8 alpha=255)
{
tiles[i].spec = spec;
if(alpha != 255)
{
tiles[i].alpha = alpha;
tiles[i].material_type = MATERIAL_ALPHA_VERTEX;
}
}
void setAllTextures(const TextureSpec &spec, u8 alpha=255) void setAllTextures(const TextureSpec &spec, u8 alpha=255)
{ {
for(u16 i=0; i<6; i++) for(u16 i=0; i<6; i++)
{ {
tiles[i].spec = spec; setTexture(i, spec, alpha);
tiles[i].alpha = alpha;
} }
// Set this too so it can be left as is most times // Set this too so it can be left as is most times
/*if(inventory_image_path == "")
inventory_image_path = porting::getDataPath(imgname.c_str());*/
if(inventory_texture.empty()) if(inventory_texture.empty())
inventory_texture = spec; inventory_texture = spec;
} }
void setTexture(u16 i, const TextureSpec &spec, u8 alpha=255)
void setTile(u16 i, const TileSpec &tile)
{ {
tiles[i].spec = spec; tiles[i] = tile;
tiles[i].alpha = alpha; }
void setAllTiles(const TileSpec &tile)
{
for(u16 i=0; i<6; i++)
{
setTile(i, tile);
}
} }
void setInventoryTexture(const TextureSpec &spec) void setInventoryTexture(const TextureSpec &spec)
@ -417,12 +430,11 @@ struct MapNode
union union
{ {
u8 param2;
/* /*
Direction for torches and other stuff. The second parameter. Initialized to 0.
Format is freeform. e.g. packDir or encode_dirs can be used. Direction for torches and flowing water.
*/ */
u8 param2;
u8 dir; u8 dir;
}; };

View File

@ -86,7 +86,10 @@ public:
} }
/* /*
This should be called when the menu wants to quit This should be called when the menu wants to quit.
WARNING: THIS DEALLOCATES THE MENU FROM MEMORY. Return
immediately if you call this from the menu itself.
*/ */
void quitMenu() void quitMenu()
{ {

View File

@ -30,7 +30,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Player::Player(): Player::Player():
touching_ground(false), touching_ground(false),
in_water(false), in_water(false),
in_water_stable(false),
swimming_up(false),
peer_id(PEER_ID_INEXISTENT), peer_id(PEER_ID_INEXISTENT),
m_pitch(0),
m_yaw(0),
m_speed(0,0,0), m_speed(0,0,0),
m_position(0,0,0) m_position(0,0,0)
{ {
@ -275,11 +279,10 @@ void LocalPlayer::move(f32 dtime, Map &map)
position += m_speed * dtime; position += m_speed * dtime;
bool free_move = g_settings.getBool("free_move"); bool free_move = g_settings.getBool("free_move");
bool terrain_viewer = g_settings.getBool("terrain_viewer");
// Skip collision detection if player is non-local or // Skip collision detection if player is non-local or
// a special movement mode is used // a special movement mode is used
if(isLocal() == false || free_move || terrain_viewer) if(isLocal() == false || free_move)
{ {
setPosition(position); setPosition(position);
return; return;
@ -292,7 +295,7 @@ void LocalPlayer::move(f32 dtime, Map &map)
v3s16 pos_i = floatToInt(position); v3s16 pos_i = floatToInt(position);
/* /*
Check if player is in water Check if player is in water (the oscillating value)
*/ */
try{ try{
if(in_water) if(in_water)
@ -311,6 +314,18 @@ void LocalPlayer::move(f32 dtime, Map &map)
in_water = false; in_water = false;
} }
/*
Check if player is in water (the stable value)
*/
try{
v3s16 pp = floatToInt(position + v3f(0,0,0));
in_water_stable = content_liquid(map.getNode(pp).d);
}
catch(InvalidPositionException &e)
{
in_water_stable = false;
}
// The frame length is limited to the player going 0.1*BS per call // The frame length is limited to the player going 0.1*BS per call
f32 d = (float)BS * 0.15; f32 d = (float)BS * 0.15;
@ -526,10 +541,12 @@ void LocalPlayer::applyControl(float dtime)
speed.Y = 6.5*BS; speed.Y = 6.5*BS;
setSpeed(speed); setSpeed(speed);
} }
// Use the oscillating value for getting out of water
// (so that the player doesn't fly on the surface)
else if(in_water) else if(in_water)
{ {
v3f speed = getSpeed(); v3f speed = getSpeed();
speed.Y = 2.0*BS; speed.Y = 1.5*BS;
setSpeed(speed); setSpeed(speed);
swimming_up = true; swimming_up = true;
} }

View File

@ -114,7 +114,10 @@ public:
void deSerialize(std::istream &is); void deSerialize(std::istream &is);
bool touching_ground; bool touching_ground;
// This oscillates so that the player jumps a bit above the surface
bool in_water; bool in_water;
// This is more stable and defines the maximum speed of the player
bool in_water_stable;
bool swimming_up; bool swimming_up;
Inventory inventory; Inventory inventory;

View File

@ -81,8 +81,9 @@ void initializePaths()
#include <unistd.h> #include <unistd.h>
char buf[BUFSIZ]; char buf[BUFSIZ];
memset(buf, 0, BUFSIZ);
// Get path to executable // Get path to executable
readlink("/proc/self/exe", buf, BUFSIZ); readlink("/proc/self/exe", buf, BUFSIZ-1);
pathRemoveFile(buf, '/'); pathRemoveFile(buf, '/');
@ -144,8 +145,9 @@ void initializePaths()
#include <unistd.h> #include <unistd.h>
char buf[BUFSIZ]; char buf[BUFSIZ];
memset(buf, 0, BUFSIZ);
// Get path to executable // Get path to executable
readlink("/proc/self/exe", buf, BUFSIZ); readlink("/proc/self/exe", buf, BUFSIZ-1);
pathRemoveFile(buf, '/'); pathRemoveFile(buf, '/');

View File

@ -962,8 +962,8 @@ void PlayerInfo::PrintLine(std::ostream *s)
{ {
(*s)<<id<<": "; (*s)<<id<<": ";
(*s)<<"\""<<name<<"\" (" (*s)<<"\""<<name<<"\" ("
<<position.X<<","<<position.Y <<(position.X/10)<<","<<(position.Y/10)
<<","<<position.Z<<") "; <<","<<(position.Z/10)<<") ";
address.print(s); address.print(s);
(*s)<<" avg_rtt="<<avg_rtt; (*s)<<" avg_rtt="<<avg_rtt;
(*s)<<std::endl; (*s)<<std::endl;
@ -2668,6 +2668,7 @@ void Server::SendPlayerInfos()
"peer_id="<<player->peer_id<<std::endl;*/ "peer_id="<<player->peer_id<<std::endl;*/
writeU16(&data[start], player->peer_id); writeU16(&data[start], player->peer_id);
memset((char*)&data[start+2], 0, PLAYERNAME_SIZE);
snprintf((char*)&data[start+2], PLAYERNAME_SIZE, "%s", player->getName()); snprintf((char*)&data[start+2], PLAYERNAME_SIZE, "%s", player->getName());
start += 2+PLAYERNAME_SIZE; start += 2+PLAYERNAME_SIZE;
} }
@ -3204,7 +3205,7 @@ Player *Server::emergePlayer(const char *name, const char *password,
#if 1 #if 1
player->setPosition(intToFloat(v3s16( player->setPosition(intToFloat(v3s16(
0, 0,
40, //64, 45, //64,
0 0
))); )));
#endif #endif

View File

@ -25,51 +25,69 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "texture.h" #include "texture.h"
#include <string> #include <string>
enum MaterialType{
MATERIAL_ALPHA_NONE,
MATERIAL_ALPHA_VERTEX,
MATERIAL_ALPHA_SIMPLE, // >127 = opaque
MATERIAL_ALPHA_BLEND,
};
// Material flags
#define MATERIAL_FLAG_BACKFACE_CULLING 0x01
/*
This fully defines the looks of a tile.
The SMaterial of a tile is constructed according to this.
*/
struct TileSpec struct TileSpec
{ {
TileSpec(): TileSpec():
alpha(255) alpha(255),
material_type(MATERIAL_ALPHA_NONE),
material_flags(
MATERIAL_FLAG_BACKFACE_CULLING
)
{ {
} }
bool operator==(TileSpec &other) bool operator==(TileSpec &other)
{ {
return (spec == other.spec && alpha == other.alpha); return (
spec == other.spec &&
alpha == other.alpha &&
material_type == other.material_type &&
material_flags == other.material_flags
);
} }
// Sets everything else except the texture in the material
void applyMaterialOptions(video::SMaterial &material)
{
if(alpha != 255 && material_type != MATERIAL_ALPHA_VERTEX)
dstream<<"WARNING: TileSpec: alpha != 255 "
"but not MATERIAL_ALPHA_VERTEX"
<<std::endl;
if(material_type == MATERIAL_ALPHA_NONE)
material.MaterialType = video::EMT_SOLID;
else if(material_type == MATERIAL_ALPHA_VERTEX)
material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
else if(material_type == MATERIAL_ALPHA_SIMPLE)
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
else if(material_type == MATERIAL_ALPHA_BLEND)
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
material.BackfaceCulling = (material_flags & MATERIAL_FLAG_BACKFACE_CULLING) ? true : false;
}
// Specification of texture
TextureSpec spec; TextureSpec spec;
// Vertex alpha
u8 alpha; u8 alpha;
// Material type
u8 material_type;
// Material flags
u8 material_flags;
}; };
#if 0
struct TileSpec
{
TileSpec():
alpha(255)
{
}
TileSpec(const std::string &a_name):
name(a_name),
alpha(255)
{
}
TileSpec(const char *a_name):
name(a_name),
alpha(255)
{
}
bool operator==(TileSpec &other)
{
return (name == other.name && alpha == other.alpha);
}
// path + mods
std::string name;
u8 alpha;
};
#endif
#endif #endif

View File

@ -1087,6 +1087,8 @@ public:
n = m_defaults.find(name); n = m_defaults.find(name);
if(n == NULL) if(n == NULL)
{ {
dstream<<"INFO: Settings: Setting not found: \""
<<name<<"\""<<std::endl;
throw SettingNotFoundException("Setting not found"); throw SettingNotFoundException("Setting not found");
} }
} }