From c707e00195f1035ae535f3fc8697af42e73190c0 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Mon, 29 Nov 2010 10:52:07 +0200 Subject: sitä sun tätä tekeillä, toimii kivasti MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.cpp | 348 +++++++++++++++++++---------------------------------------- 1 file changed, 111 insertions(+), 237 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 258119c4a..991185ca6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,11 +21,15 @@ with this program; if not, write to the Free Software Foundation, Inc., =============================== NOTES ============================== NOTE: VBO cannot be turned on for fast-changing stuff because there - is an apparanet memory leak in irrlicht when using it + is an apparanet memory leak in irrlicht when using it (not sure) + +NOTE: iostream.imbue(std::locale("C")) is very slow +NOTE: Global locale is now set at initialization SUGGESTION: add a second lighting value to the MS nibble of param of air to tell how bright the air node is when there is no sunlight. When day changes to night, these two values can be interpolated. + TODO: Fix address to be ipv6 compatible TODO: ESC Pause mode in which the cursor is not kept at the center of window. @@ -93,9 +97,7 @@ TODO: Expose Connection's seqnums and ACKs to server and client. - This also enables server to check if client has received the most recent block sent, for example. -SUGG: Add a time value to the param of footstepped grass and check it - against a global timer when a block is accessed, to make old - steps fade away. +TODO: Add a sane bandwidth throttling system to Connection FIXME: There still are *some* tiny glitches in lighting as seen from the client side. The server calculates them right but sometimes @@ -105,8 +107,9 @@ FIXME: There still are *some* tiny glitches in lighting as seen from the sender sends the block as it was before emerging? TODO: How about adding a "revision" field to MapBlocks? -TODO: More fine-grained control of client's dumping of blocks from +SUGG: More fine-grained control of client's dumping of blocks from memory + - ...What does this mean in the first place? TODO: Somehow prioritize the sending of blocks and combine the block send queue lengths @@ -130,9 +133,6 @@ SUGG: Make client send GOTBLOCKS before updating meshes TODO: Server to load starting inventory from disk -NOTE: iostream.imbue(std::locale("C")) is very slow -NOTE: Global locale is now set at initialization - TODO: PLayers to only be hidden when the client quits. TODO: - Players to be saved on disk, with inventory TODO: Players to be saved as text in map/players/ @@ -158,12 +158,18 @@ Block object server side: - A "near blocks" buffer, in which some nearby blocks are stored. - For all blocks in the buffer, objects are stepped(). This means they are active. - - TODO All blocks going in and out of the buffer are recorded. - - TODO For outgoing blocks, a timestamp is written. - - TODO For incoming blocks, the time difference is calculated and + - TODO: A global active buffer is needed for the server + - TODO: All blocks going in and out of the buffer are recorded. + - TODO: For outgoing blocks, a timestamp is written. + - TODO: For incoming blocks, the time difference is calculated and objects are stepped according to it. TODO: A timestamp to blocks +SUGG: Add a time value to the param of footstepped grass and check it + against a global timer when a block is accessed, to make old + steps fade away. + + TODO: Add config parameters for server's sending and generating distance TODO: Copy the text of the last picked sign to inventory in creative @@ -185,12 +191,16 @@ SUGG: Split MapBlockObject serialization to to-client and to-disk - This will allow saving ages of rats on disk but not sending them to clients -TODO: Fix the long-lived Server Block Emerge Jam bug - - Is it related to the client deleting blocks? +TODO: Get rid of GotSplitPacketException + +Before release: + +TODO: Check what goes wrong with caching map to disk (Kray) Doing now: ====================================================================== +TODO: Implement lighting using VoxelManipulator ====================================================================== @@ -202,7 +212,7 @@ Doing now: the starting place to a static direction. This allows one to move around with the player and see what - is actually drawn behind solid things etc. + is actually drawn behind solid things and behind the player. */ #define FIELD_OF_VIEW_TEST 0 @@ -265,7 +275,8 @@ const char *g_material_filenames[MATERIALS_COUNT] = "../data/tree.png", "../data/leaves.png", "../data/grass_footsteps.png", - "../data/mese.png" + "../data/mese.png", + "../data/mud.png" }; video::SMaterial g_materials[MATERIALS_COUNT]; @@ -296,28 +307,39 @@ bool g_viewing_range_all = false; These are loaded from the config file. */ -std::string g_dedicated_server; - -// Client stuff -float g_wanted_fps = FPS_DEFAULT_WANTED; -float g_fps_max = FPS_DEFAULT_MAX; -s16 g_viewing_range_nodes_max = 300; -s16 g_viewing_range_nodes_min = 20; -std::string g_screenW; -std::string g_screenH; -std::string g_host_game; -std::string g_port; -std::string g_address; -std::string g_name; -bool g_random_input = false; -float g_client_delete_unused_sectors_timeout = 1200; - -// Server stuff -bool g_creative_mode = false; -HMParams g_hm_params; -MapParams g_map_params; -float g_objectdata_interval = 0.2; -u16 g_active_object_range = 2; +Settings g_settings; + +// Sets default settings +void set_default_settings() +{ + g_settings.set("dedicated_server", ""); + + // Client stuff + g_settings.set("wanted_fps", "30"); + g_settings.set("fps_max", "60"); + g_settings.set("viewing_range_nodes_max", "300"); + g_settings.set("viewing_range_nodes_min", "20"); + g_settings.set("screenW", ""); + g_settings.set("screenH", ""); + g_settings.set("host_game", ""); + g_settings.set("port", ""); + g_settings.set("address", ""); + g_settings.set("name", ""); + g_settings.set("random_input", "false"); + g_settings.set("client_delete_unused_sectors_timeout", "1200"); + + // Server stuff + g_settings.set("creative_mode", "false"); + g_settings.set("heightmap_blocksize", "128"); + g_settings.set("height_randmax", "constant 70.0"); + g_settings.set("height_randfactor", "constant 0.6"); + g_settings.set("height_base", "linear 0 35 0"); + g_settings.set("plants_amount", "1.0"); + g_settings.set("objectdata_interval", "0.2"); + g_settings.set("active_object_range", "2"); + g_settings.set("max_simultaneous_block_sends_per_client", "2"); + g_settings.set("max_simultaneous_block_sends_server_total", "4"); +} /* Random stuff @@ -354,144 +376,6 @@ std::ostream *derr_server_ptr = &dstream; std::ostream *dout_client_ptr = &dstream; std::ostream *derr_client_ptr = &dstream; -/* - Config stuff -*/ - -// Returns false on EOF -bool parseConfigObject(std::istream &is) -{ - // float g_wanted_fps - // s16 g_viewing_range_nodes_max - - if(is.eof()) - return false; - - std::string line; - std::getline(is, line); - //dstream<<"got line: \""<>g_client_delete_unused_sectors_timeout; - } - - // Server stuff - else if(name == "creative_mode") - g_creative_mode = is_yes(value); - else if(name == "mapgen_heightmap_blocksize") - { - s32 d = atoi(value.c_str()); - if(d > 0 && (d & (d-1)) == 0) - g_hm_params.heightmap_blocksize = d; - else - dstream<<"Invalid value in config file: \"" - <>g_map_params.plants_amount; - } - else if(name == "objectdata_inverval") - { - std::istringstream vis(value); - vis>>g_objectdata_interval; - } - else if(name == "active_object_range") - g_active_object_range = stoi(value, 0, 65535); - - else - { - dstream<<"Unknown option in config file: \"" - < g_viewing_range_nodes_max) - n = g_viewing_range_nodes_max; + if(n < viewing_range_nodes_min) + n = viewing_range_nodes_min; + if(n > viewing_range_nodes_max) + n = viewing_range_nodes_max; bool can_change = true; @@ -1050,10 +939,11 @@ int main(int argc, char *argv[]) disable_stderr = true; #endif + // Initialize debug streams debugstreams_init(disable_stderr, DEBUGFILE); + // Initialize debug stacks debug_stacks_init(); - DSTACK(__FUNCTION_NAME); try @@ -1063,6 +953,10 @@ int main(int argc, char *argv[]) Basic initialization */ + // Initialize default settings + set_default_settings(); + + // Print startup message dstream< yes"< no"< "< "<setResizable(true); - if(g_random_input) + if(g_settings.getBool("random_input")) g_input = new RandomInputHandler(); else g_input = new RealInputHandler(device, &receiver); @@ -1443,9 +1319,7 @@ int main(int argc, char *argv[]) */ SharedPtr server; if(hosting){ - server = new Server("../map", g_creative_mode, g_hm_params, - g_map_params, g_objectdata_interval, - g_active_object_range); + server = new Server("../map", hm_params, map_params); server->start(port); } @@ -1455,7 +1329,7 @@ int main(int argc, char *argv[]) // TODO: Get rid of the g_materials parameter or it's globalness Client client(device, g_materials, - g_client_delete_unused_sectors_timeout, + g_settings.getFloat("client_delete_unused_sectors_timeout"), playername); Address connect_address(0,0,0,0, port); @@ -1648,7 +1522,7 @@ int main(int argc, char *argv[]) */ { - float fps_max = g_fps_max; + float fps_max = g_settings.getFloat("fps_max"); u32 frametime_min = 1000./fps_max; if(busytime_u32 < frametime_min) @@ -2326,7 +2200,7 @@ int main(int argc, char *argv[]) delete g_input; /* - In the end, delete the Irrlicht device. + In the end, delete the Irrlicht device. */ device->drop(); -- cgit v1.2.3