From bd100c5483eb77a27eeac4e476c81a1bf6afc710 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Wed, 26 Jan 2011 17:13:19 +0200 Subject: [PATCH] backing up some stuff --- src/debug.cpp | 5 ++ src/main.cpp | 195 +++++++++++++++++++++++++++++++++++++---------- src/mapblock.cpp | 2 +- src/mapnode.cpp | 4 +- src/utility.cpp | 7 ++ src/utility.h | 2 + 6 files changed, 172 insertions(+), 43 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index ca49c9b77..f267790fd 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -32,6 +32,8 @@ void debugstreams_init(bool disable_stderr, const char *filename) { if(disable_stderr) g_debugstreams[0] = NULL; + else + g_debugstreams[0] = stderr; if(filename) g_debugstreams[1] = fopen(filename, "a"); @@ -42,6 +44,9 @@ void debugstreams_init(bool disable_stderr, const char *filename) fprintf(g_debugstreams[1], " Separator \n"); fprintf(g_debugstreams[1], "-------------\n\n"); } + + DEBUGPRINT("Debug streams initialized, disable_stderr=%d\n", + disable_stderr); } void debugstreams_deinit() diff --git a/src/main.cpp b/src/main.cpp index d2b67e9a8..388ab8089 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,12 +104,8 @@ SUGG: Meshes of blocks could be split into 6 meshes facing into Gaming ideas: ------------- -- How would some GTA-style ideas work? - - Cars? Stealing? Unlawful stuff and cops? Lots of guns? +- Aim for something like controlling a single dwarf in Dwarf Fortress. -- RPG style? - -- Space racer style? Documentation: -------------- @@ -286,9 +282,16 @@ TODO: Remove duplicate lighting implementation from Map (leave VoxelManipulator, which is faster) FIXME: The new texture stuff is slow on wine - - Actually it is not too slow; updating excess amount of meshes - when making footprints is too slow. It has to be fixed. + - A basic grassy ground block takes 20-40ms + - A bit more complicated block can take 270ms + - On linux, a similar one doesn't take long at all (14ms) + - Is it a bad std::string implementation of MSVC? + - Can take up to 200ms? Is it when loading textures or always? + - Updating excess amount of meshes when making footprints is too + slow. It has to be fixed. -> implement Map::updateNodeMeshes() + TODO: Optimize TileSpec to only contain a reference number that + is fast to compare, which refers to a cached string Doing now: ---------- @@ -1266,41 +1269,106 @@ struct ChatLine std::wstring text; }; +// These are defined global so that they're not optimized too much. +// Can't change them to volatile. +s16 temp16; +f32 tempf; +v3f tempv3f1; +v3f tempv3f2; +std::string tempstring; +std::string tempstring2; + +void SpeedTests() +{ + { + dstream<<"The following test should take around 20ms."< map1; + tempf = -324; + const s16 ii=300; + for(s16 y=0; y=0; y--){ + for(s16 x=0; xsetResizable(true); diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 15f3ad9a6..f06dbc811 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -601,7 +601,7 @@ void MapBlock::updateMesh(u32 daynight_ratio) */ { - //TimeTaker timer2("updateMesh() collect"); + TimeTaker timer2("updateMesh() collect"); // Lock this, as m_temp_mods will be used directly JMutexAutoLock lock(m_temp_mods_mutex); diff --git a/src/mapnode.cpp b/src/mapnode.cpp index ebae055db..7625fab68 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -160,7 +160,9 @@ TileSpec MapNode::getTile(v3s16 dir) s32 dir_i = -1; - if(dir == v3s16(0,1,0)) + if(dir == v3s16(0,0,0)) + dir_i = -1; + else if(dir == v3s16(0,1,0)) dir_i = 0; else if(dir == v3s16(0,-1,0)) dir_i = 1; diff --git a/src/utility.cpp b/src/utility.cpp index 65615f9c9..8b2b78b44 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -54,6 +54,13 @@ u32 TimeTaker::stop(bool quiet) return 0; } +u32 TimeTaker::getTime() +{ + u32 time2 = getTimeMs(); + u32 dtime = time2 - m_time1; + return dtime; +} + const v3s16 g_26dirs[26] = { // +right, +top, +back diff --git a/src/utility.h b/src/utility.h index 785ff167c..b517848b1 100644 --- a/src/utility.h +++ b/src/utility.h @@ -409,6 +409,8 @@ public: u32 stop(bool quiet=false); + u32 getTime(); + private: const char *m_name; u32 m_time1;