From 63611932ebae93620386b26cfa82f7c4552b22ff Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 29 May 2011 21:11:16 +0300 Subject: player passwords and privileges in world/auth.txt --HG-- extra : rebase_source : 7260636295d9068fbeeddf4143c89f2b8a91446c --- doc/changelog.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'doc') diff --git a/doc/changelog.txt b/doc/changelog.txt index f43a68f12..cb3594a98 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -13,6 +13,7 @@ X: - Slightly updated map format - Player passwords - All textures first searched from texture_path +- Map directory ("map") has been renamed to "world" (just rename it to load an old world) 2011-04-24: - Smooth lighting with simple ambient occlusion -- cgit v1.2.3 From 9f7c21a0b48285fe03bef1060557f6e75976d625 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 29 May 2011 21:13:29 +0300 Subject: invert_mouse config option --HG-- extra : rebase_source : 2695ad71185244cefbcf6e3e28ba1ab5e54c882f --- doc/changelog.txt | 1 + minetest.conf.example | 2 ++ src/defaultsettings.cpp | 1 + src/game.cpp | 4 ++++ 4 files changed, 8 insertions(+) (limited to 'doc') diff --git a/doc/changelog.txt b/doc/changelog.txt index cb3594a98..e886370a6 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -14,6 +14,7 @@ X: - Player passwords - All textures first searched from texture_path - Map directory ("map") has been renamed to "world" (just rename it to load an old world) +- Mouse inversion (invert_mouse) 2011-04-24: - Smooth lighting with simple ambient occlusion diff --git a/minetest.conf.example b/minetest.conf.example index 5e6393228..1a1dbe0fc 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -42,6 +42,8 @@ #keymap_special1 = KEY_KEY_E #keymap_print_debug_stacks = KEY_KEY_P +#invert_mouse = false + # The desired FPS #wanted_fps = 30 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 1d758a2a4..6fcdc1dbb 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -65,6 +65,7 @@ void set_default_settings() g_settings.setDefault("free_move", "false"); g_settings.setDefault("continuous_forward", "false"); g_settings.setDefault("fast_move", "false"); + g_settings.setDefault("invert_mouse", "false"); // Server stuff g_settings.setDefault("enable_experimental", "false"); diff --git a/src/game.cpp b/src/game.cpp index cc758be7e..6932b45f1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -894,6 +894,8 @@ void the_game( core::list frametime_log; float damage_flash_timer = 0; + + bool invert_mouse = g_settings.getBool("invert_mouse"); /* Main loop @@ -1306,6 +1308,8 @@ void the_game( else{ s32 dx = input->getMousePos().X - displaycenter.X; s32 dy = input->getMousePos().Y - displaycenter.Y; + if(invert_mouse) + dy = -dy; //std::cout<<"window active, pos difference "< Date: Sun, 29 May 2011 21:28:22 +0300 Subject: changed version number to 0.2.20110529_0 --HG-- extra : rebase_source : 9b05d4bfee9312aef4182fa6f63b4237368cec34 --- CMakeLists.txt | 2 +- doc/changelog.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/CMakeLists.txt b/CMakeLists.txt index d5b8028f6..567b96c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ project(minetest) set(VERSION_MAJOR 0) set(VERSION_MINOR 2) -set(VERSION_PATCH 20110424_1_dev) +set(VERSION_PATCH 20110529_0) set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") # Configuration options diff --git a/doc/changelog.txt b/doc/changelog.txt index e886370a6..7089146a0 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -15,6 +15,8 @@ X: - All textures first searched from texture_path - Map directory ("map") has been renamed to "world" (just rename it to load an old world) - Mouse inversion (invert_mouse) +- Grass doesn't grow immediately anymore +- Fence added 2011-04-24: - Smooth lighting with simple ambient occlusion -- cgit v1.2.3 From e81919c818c6040de7401a037e3fdfac88b28eea Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 29 May 2011 22:34:04 +0300 Subject: hopefully fixed the privilege problems --HG-- extra : rebase_source : 9826d20176134a53ff232816a10407465d8c0f50 --- doc/changelog.txt | 2 +- src/player.cpp | 1 - src/player.h | 3 --- src/server.cpp | 48 ++++++++++++++++++++++++++++++++++++------------ src/server.h | 24 ++++++++++++++++++++++++ src/servercommand.cpp | 16 +++++++++++----- 6 files changed, 72 insertions(+), 22 deletions(-) (limited to 'doc') diff --git a/doc/changelog.txt b/doc/changelog.txt index 7089146a0..e02019783 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -3,7 +3,7 @@ Minetest-c55 changelog This should contain all the major changes. For minor stuff, refer to the commit log of the repository. -X: +2011-05-29: - Optimized smooth lighting - A number of small fixes - Added clouds and simple skyboxes diff --git a/src/player.cpp b/src/player.cpp index efb2f3447..198eca957 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -102,7 +102,6 @@ void Player::serialize(std::ostream &os) args.setV3F("position", m_position); args.setBool("craftresult_is_preview", craftresult_is_preview); args.setS32("hp", hp); - args.setU64("privs", privs); args.writeLines(os); diff --git a/src/player.h b/src/player.h index 157a25b5b..a7a2433ce 100644 --- a/src/player.h +++ b/src/player.h @@ -126,9 +126,6 @@ public: u16 hp; - // Player's privileges - a bitmaps of PRIV_xxxx. - u64 privs; - u16 peer_id; protected: diff --git a/src/server.cpp b/src/server.cpp index 4569d028e..56874c46c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2083,7 +2083,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(datasize < 13) return; - if((player->privs & PRIV_BUILD) == 0) + if((getPlayerPrivs(player) & PRIV_BUILD) == 0) return; /* @@ -2167,7 +2167,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(datasize < 7) return; - if((player->privs & PRIV_BUILD) == 0) + if((getPlayerPrivs(player) & PRIV_BUILD) == 0) return; /* @@ -2368,8 +2368,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } // Make sure the player is allowed to do it - if((player->privs & PRIV_BUILD) == 0) + if((getPlayerPrivs(player) & PRIV_BUILD) == 0) + { + dstream<<"Player "<getName()<<" cannot remove node" + <<" because privileges are "<getName()<<" cannot add node" + <<" because privileges are "<privs & PRIV_BUILD) ==0) + || no_enough_privs) { // Client probably has wrong data. // Set block not sent, so that client will get @@ -2715,7 +2727,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) #endif else if(command == TOSERVER_SIGNTEXT) { - if((player->privs & PRIV_BUILD) == 0) + if((getPlayerPrivs(player) & PRIV_BUILD) == 0) return; /* u16 command @@ -2774,7 +2786,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } else if(command == TOSERVER_SIGNNODETEXT) { - if((player->privs & PRIV_BUILD) == 0) + if((getPlayerPrivs(player) & PRIV_BUILD) == 0) return; /* u16 command @@ -2952,9 +2964,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) // Local player gets all privileges regardless of // what's set on their account. - u64 privs = player->privs; - if(g_settings.get("name") == player->getName()) - privs = PRIV_ALL; + u64 privs = getPlayerPrivs(player); // Parse commands std::wstring commandprefix = L"/#"; @@ -4288,9 +4298,6 @@ Player *Server::emergePlayer(const char *name, const char *password, u16 peer_id m_authmanager.setPrivs(name, stringToPrivs(g_settings.get("default_privs"))); - if(g_settings.exists("default_privs")) - player->privs = g_settings.getU64("default_privs"); - /* Set player position */ @@ -4503,6 +4510,23 @@ void Server::handlePeerChanges() } } +u64 Server::getPlayerPrivs(Player *player) +{ + if(player==NULL) + return 0; + std::string playername = player->getName(); + // Local player gets all privileges regardless of + // what's set on their account. + if(g_settings.get("name") == playername) + { + return PRIV_ALL; + } + else + { + return getPlayerAuthPrivs(playername); + } +} + void dedicated_server_loop(Server &server, bool &kill) { DSTACK(__FUNCTION_NAME); diff --git a/src/server.h b/src/server.h index a6da801be..7b73e476c 100644 --- a/src/server.h +++ b/src/server.h @@ -424,7 +424,29 @@ public: // Envlock and conlock should be locked when calling this void SendMovePlayer(Player *player); + + u64 getPlayerAuthPrivs(const std::string &name) + { + try{ + return m_authmanager.getPrivs(name); + } + catch(AuthNotFoundException &e) + { + dstream<<"WARNING: Auth not found for "<player->privs)); + os<server->getPlayerAuthPrivs(ctx->player->getName()))); return; } @@ -52,7 +53,7 @@ void cmd_privs(std::wostringstream &os, return; } - os<privs)); + os<server->getPlayerAuthPrivs(tp->getName()))); } void cmd_grantrevoke(std::wostringstream &os, @@ -83,14 +84,19 @@ void cmd_grantrevoke(std::wostringstream &os, os<parms[1]); + u64 privs = ctx->server->getPlayerAuthPrivs(playername); if(ctx->parms[0] == L"grant") - tp->privs |= newprivs; + privs |= newprivs; else - tp->privs &= ~newprivs; + privs &= ~newprivs; + + ctx->server->setPlayerAuthPrivs(playername, privs); os<privs)); + os< Date: Thu, 2 Jun 2011 00:15:42 +0300 Subject: 0.2.20110602_0 --- CMakeLists.txt | 2 +- doc/changelog.txt | 5 +++++ src/main.cpp | 3 --- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ae256288..c1074e6d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ project(minetest) set(VERSION_MAJOR 0) set(VERSION_MINOR 2) -set(VERSION_PATCH 20110529_3_dev) +set(VERSION_PATCH 20110602_0) set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") # Configuration options diff --git a/doc/changelog.txt b/doc/changelog.txt index e02019783..5a01b6bc4 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -3,6 +3,11 @@ Minetest-c55 changelog This should contain all the major changes. For minor stuff, refer to the commit log of the repository. +2011-06-02: +- Password crash on windows fixed +- Optimized server CPU usage a lot +- Furnaces now work also while players are not near to them + 2011-05-29: - Optimized smooth lighting - A number of small fixes diff --git a/src/main.cpp b/src/main.cpp index 958f812b3..2cde3b302 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -312,9 +312,6 @@ Stuff to do before release: Fixes to the current release: ----------------------------- -- Fix client password crash -- Remember to release the fixes (some are already done) -- A command to set one's password when the server is running Stuff to do after release: --------------------------- -- cgit v1.2.3 From 6bd4cb25629fe8f96a024f5f8251563d2c864616 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 4 Jun 2011 16:54:26 +0300 Subject: documentation update (mapformat.txt mainly) --- doc/mapformat.txt | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 6 +++++ 2 files changed, 81 insertions(+) create mode 100644 doc/mapformat.txt (limited to 'doc') diff --git a/doc/mapformat.txt b/doc/mapformat.txt new file mode 100644 index 000000000..5ee33c106 --- /dev/null +++ b/doc/mapformat.txt @@ -0,0 +1,75 @@ +I'll try to quickly document the newest block format in here (might contain +errors). Refer to the mapgen or minetestmapper script for the directory +structure and file naming. There are two sector namings possible, +sector/XXXXZZZZ and sector/XXX/ZZZ. + +There also exists files map_meta.txt and chunk_meta, that are used by the +generator. If they are not found or invalid, the generator will currently +behave quite strangely. + +The MapBlock file format (sectors2/XXX/ZZZ/YYYY): + +NOTE: Byte order is MSB first. + +u8 version +- map format version number, this one is version 17 + +u8 flags +- Flag bitmasks: + - 0x01: is_underground: Should be set to 0 if there will be no light + obstructions above the block. If/when sunlight of a block is updated and + there is no block above it, this value is checked for determining whether + sunlight comes from the top. + - 0x02: day_night_differs: Whether the lighting of the block is different on + day and night. Only blocks that have this bit set are updated when day + transforms to night. + - 0x04: lighting_expired: If true, lighting is invalid and should be updated. + If you can't calculate lighting in your generator properly, you could try + setting this 1 to everything and setting the uppermost block in every + sector as is_underground=0. I am quite sure it doesn't work properly, + though. + +zlib-compressed map data: +- content: + u8[4096]: content types + u8[4096]: param1 values + u8[4096]: param2 values + +zlib-compressed node metadata +- content: + u16 version (=1) + u16 count of metadata + foreach count: + u16 position (= p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X) + u16 type_id + u16 content_size + u8[content_size] misc. stuff contained in the metadata + +u16 mapblockobject_count +- always write as 0. +- if read != 0, just fail. + +foreach mapblockobject_count: + - deprecated, should not be used. Length of this data can only be known by + properly parsing it. Just hope not to run into any of this. + +u8 static object version: +- currently 0 + +u16 static_object_count + +foreach static_object_count: + u8 type (object type-id) + s32 pos_x * 1000 + s32 pos_y * 1000 + s32 pos_z * 1000 + u16 data_size + u8[data_size] data + +u32 timestamp +- Timestamp when last saved, as seconds from starting the game. +- 0xffffffff = invalid/unknown timestamp, nothing will be done with the time + difference when loaded (recommended) + +// END + diff --git a/src/main.cpp b/src/main.cpp index 881aa9bf7..4bf741b96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -174,6 +174,12 @@ TODO: Better control of draw_control.wanted_max_blocks TODO: Block mesh generator to tile properly on smooth lighting +TODO: Further investigate the use of GPU lighting in addition to the + current one + +TODO: Quick drawing of huge distances according to heightmap has to be + tested once again. + Configuration: -------------- -- cgit v1.2.3 From f07e445f80c6666b3d4713c85e668aaa5b086f16 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 4 Jun 2011 16:58:20 +0300 Subject: updated mapformat.txt a bit --- doc/mapformat.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc') diff --git a/doc/mapformat.txt b/doc/mapformat.txt index 5ee33c106..a0241804e 100644 --- a/doc/mapformat.txt +++ b/doc/mapformat.txt @@ -8,6 +8,7 @@ generator. If they are not found or invalid, the generator will currently behave quite strangely. The MapBlock file format (sectors2/XXX/ZZZ/YYYY): +------------------------------------------------- NOTE: Byte order is MSB first. @@ -71,5 +72,18 @@ u32 timestamp - 0xffffffff = invalid/unknown timestamp, nothing will be done with the time difference when loaded (recommended) +Node metadata format: +--------------------- + +Sign metadata: + u16 string_len + u8[string_len] string + +Furnace metadata: + TBD + +Chest metadata: + TBD + // END -- cgit v1.2.3 From 28a8218adfa103361b9ea371eae5aa093b6d7e29 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 20:16:11 +0300 Subject: Documentation update --- doc/protocol.txt | 32 ++++++++++++++++++++++++++++++++ src/main.cpp | 3 +++ 2 files changed, 35 insertions(+) create mode 100644 doc/protocol.txt (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt new file mode 100644 index 000000000..b7b433c9e --- /dev/null +++ b/doc/protocol.txt @@ -0,0 +1,32 @@ +Minetest-c55 protocol (incomplete, early draft): +Updated 2011-06-18 + +A custom protocol over UDP. + +Initialization: +- A dummy reliable packet with peer_id=PEER_ID_INEXISTENT=0 is sent to the server: + - Actually this can be sent without the reliable packet header, too, i guess, + but the sequence number in the header allows the sender to re-send the + packet without accidentally getting a double initialization. + - Packet content: + # Basic header + u32 protocol_id = PROTOCOL_ID = 0x4f457403 + u16 sender_peer_id = PEER_ID_INEXISTENT = 0 + u8 channel = 0 + # Reliable packet header + u8 type = TYPE_RELIABLE = 3 + u16 seqnum = SEQNUM_INITIAL = 6550 + # Original packet header + u8 type = TYPE_ORIGINAL = 1 + # And no actual payload. +- Server responds with something like this: + - Packet content: + # Basic header + u32 protocol_id = PROTOCOL_ID = 0x4f457403 + u16 sender_peer_id = PEER_ID_INEXISTENT = 0 + u8 channel = 0 + # Control packet header + u8 type = TYPE_CONTROL = 0 + u8 controltype = CONTROLTYPE_SET_PEER_ID = 1 + u16 peer_id_new = assigned peer id to client (other than 0 or 1) + diff --git a/src/main.cpp b/src/main.cpp index 10ece4c20..ae52bc36d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -346,6 +346,9 @@ TODO: Add a per-sector database to store surface stuff as simple flags/values - Surface ground type - Trees? +TODO: Restart irrlicht completely when coming back to main menu from game. + - This gets rid of everything that is stored in irrlicht's caches. + Making it more portable: ------------------------ -- cgit v1.2.3 From cde8c70f8c841cf56fe4173d5249a64ceba63b42 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 20:18:13 +0300 Subject: updated protocol.txt --- doc/protocol.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt index b7b433c9e..93037e70b 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -25,8 +25,20 @@ Initialization: u32 protocol_id = PROTOCOL_ID = 0x4f457403 u16 sender_peer_id = PEER_ID_INEXISTENT = 0 u8 channel = 0 + # Reliable packet header + u8 type = TYPE_RELIABLE = 3 + u16 seqnum = SEQNUM_INITIAL = 6550 # Control packet header u8 type = TYPE_CONTROL = 0 u8 controltype = CONTROLTYPE_SET_PEER_ID = 1 u16 peer_id_new = assigned peer id to client (other than 0 or 1) +- Then the connection can be disconnected by sending: + - Packet content: + # Basic header + u32 protocol_id = PROTOCOL_ID = 0x4f457403 + u16 sender_peer_id = whatever was gotten in CONTROLTYPE_SET_PEER_ID + u8 channel = 0 + # Control packet header + u8 type = TYPE_CONTROL = 0 + u8 controltype = CONTROLTYPE_DISCO = 2 -- cgit v1.2.3 From 50ef74da1eb922bccccd93b8289121d9d86b5664 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 20:21:25 +0300 Subject: Fixed typo in protocol.txt --- doc/protocol.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt index 93037e70b..9dd1e4fbf 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -15,7 +15,7 @@ Initialization: u8 channel = 0 # Reliable packet header u8 type = TYPE_RELIABLE = 3 - u16 seqnum = SEQNUM_INITIAL = 6550 + u16 seqnum = SEQNUM_INITIAL = 65500 # Original packet header u8 type = TYPE_ORIGINAL = 1 # And no actual payload. @@ -27,7 +27,7 @@ Initialization: u8 channel = 0 # Reliable packet header u8 type = TYPE_RELIABLE = 3 - u16 seqnum = SEQNUM_INITIAL = 6550 + u16 seqnum = SEQNUM_INITIAL = 65500 # Control packet header u8 type = TYPE_CONTROL = 0 u8 controltype = CONTROLTYPE_SET_PEER_ID = 1 -- cgit v1.2.3 From 0d949c68d8b250b182d50a5ae415ffcf228bbc7a Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 20:27:17 +0300 Subject: Added endianess to procotol.txt --- doc/protocol.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt index 9dd1e4fbf..76f88d67e 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -2,6 +2,8 @@ Minetest-c55 protocol (incomplete, early draft): Updated 2011-06-18 A custom protocol over UDP. +Integers are big endian. +Refer to connection.{h,cpp} for further reference. Initialization: - A dummy reliable packet with peer_id=PEER_ID_INEXISTENT=0 is sent to the server: -- cgit v1.2.3 From 90dba34d807cd2e76ff316ec202f42f1ebd78146 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 21:36:31 +0300 Subject: added a small php example --- doc/protocol.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt index 76f88d67e..a9706f839 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -44,3 +44,27 @@ Initialization: u8 type = TYPE_CONTROL = 0 u8 controltype = CONTROLTYPE_DISCO = 2 +- Here's a quick untested connect-disconnect done in PHP: +# host: ip of server (use gethostbyname(hostname) to get from a dns name) +# port: port of server +function check_if_minetestserver_up($host, $port) + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + $timeout = array("sec" => 1, "usec" => 0); + socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout); + $buf = "\x4f\x45\x74\x03\x00\x00\x00\x03\xff\xdc\x01"; + socket_sendto($socket, $buf, strlen($buf), 0, $host, $port); + $buf = socket_read($socket, 1000); + if($buf != "") + { + # We got a reply! read the peer id from it. + $peer_id = substr($buf, 9, 2); + + # Disconnect + $buf = "\x4f\x45\x74\x03".$peer_id."\x00\x00\x02"; + socket_sendto($socket, $buf, strlen($buf), 0, $host, $port); + socket_close($socket); + + return true; + } + return false; + -- cgit v1.2.3 From 3c532fff159c426322fc0c2df97f8829a5410eea Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 21:37:08 +0300 Subject: lol, i have apparently used python too much... --- doc/protocol.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc') diff --git a/doc/protocol.txt b/doc/protocol.txt index a9706f839..da2d3394f 100644 --- a/doc/protocol.txt +++ b/doc/protocol.txt @@ -48,6 +48,7 @@ Initialization: # host: ip of server (use gethostbyname(hostname) to get from a dns name) # port: port of server function check_if_minetestserver_up($host, $port) +{ $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $timeout = array("sec" => 1, "usec" => 0); socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout); @@ -67,4 +68,5 @@ function check_if_minetestserver_up($host, $port) return true; } return false; +} -- cgit v1.2.3 From 47e4eda4bb87cd9dc20dddf81ca473b523eeb150 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 25 Jun 2011 04:23:21 +0300 Subject: Reorganizing stuff (import from temporary git repo) --- .gitignore | 21 +++ CMakeLists.txt | 2 +- Makefile.bak | 90 ----------- README.txt | 239 ++++++++++++++++++++++++++++ addlicensecomments.sh | 9 -- doc/README.txt | 238 ---------------------------- genmap.py | 271 -------------------------------- makepackage_binary.sh | 63 -------- minetest.sln | 20 --- minetest.vcproj | 424 -------------------------------------------------- old/Makefile.bak | 90 +++++++++++ old/minetest.sln | 20 +++ old/minetest.vcproj | 424 ++++++++++++++++++++++++++++++++++++++++++++++++++ pnoise.py | 102 ------------ util/genmap.py | 271 ++++++++++++++++++++++++++++++++ util/pnoise.py | 102 ++++++++++++ 16 files changed, 1168 insertions(+), 1218 deletions(-) create mode 100644 .gitignore delete mode 100644 Makefile.bak create mode 100644 README.txt delete mode 100644 addlicensecomments.sh delete mode 100644 doc/README.txt delete mode 100755 genmap.py delete mode 100755 makepackage_binary.sh delete mode 100644 minetest.sln delete mode 100644 minetest.vcproj create mode 100644 old/Makefile.bak create mode 100644 old/minetest.sln create mode 100644 old/minetest.vcproj delete mode 100644 pnoise.py create mode 100755 util/genmap.py create mode 100644 util/pnoise.py (limited to 'doc') diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..bfa7d59a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +map/* +CMakeFiles/* +src/CMakeFiles/* +src/Makefile +src/cmake_config.h +src/cmake_install.cmake +src/jthread/CMakeFiles/* +src/jthread/Makefile +src/jthread/cmake_config.h +src/jthread/cmake_install.cmake +minetest.conf +bin/ +CMakeCache.txt +CPackConfig.cmake +CPackSourceConfig.cmake +Makefile +cmake_install.cmake +src/jthread/libjthread.a +debug.txt +bin/debug.txt + diff --git a/CMakeLists.txt b/CMakeLists.txt index 70d20dea4..516778995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ elseif(UNIX) # Linux, BSD etc set(EXAMPLE_CONF_DIR "share/doc/minetest") endif() -install(FILES "doc/README.txt" DESTINATION "${DOCDIR}") +install(FILES "README.txt" DESTINATION "${DOCDIR}") install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}") # diff --git a/Makefile.bak b/Makefile.bak deleted file mode 100644 index 8ba03f9bb..000000000 --- a/Makefile.bak +++ /dev/null @@ -1,90 +0,0 @@ -# Makefile for Irrlicht Examples -# It's usually sufficient to change just the target name and source file list -# and be sure that CXX is set to a valid compiler -SOURCE_FILES = porting.cpp guiMessageMenu.cpp materials.cpp guiTextInputMenu.cpp guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp - -DEBUG_TARGET = debugtest -DEBUG_SOURCES = $(addprefix src/, $(SOURCE_FILES)) -DEBUG_BUILD_DIR = debugbuild -DEBUG_OBJECTS = $(addprefix $(DEBUG_BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o)) - -FAST_TARGET = fasttest -FAST_SOURCES = $(addprefix src/, $(SOURCE_FILES)) -FAST_BUILD_DIR = fastbuild -FAST_OBJECTS = $(addprefix $(FAST_BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o)) - -SERVER_TARGET = server -SERVER_SOURCE_FILES = porting.cpp materials.cpp defaultsettings.cpp mapnode.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp servermain.cpp test.cpp -SERVER_SOURCES = $(addprefix src/, $(SERVER_SOURCE_FILES)) -SERVER_BUILD_DIR = serverbuild -SERVER_OBJECTS = $(addprefix $(SERVER_BUILD_DIR)/, $(SERVER_SOURCE_FILES:.cpp=.o)) - -IRRLICHTPATH = ../irrlicht/irrlicht-1.7.1 -JTHREADPATH = ../jthread/jthread-1.2.1 - - -all: fast - -ifeq ($(HOSTTYPE), x86_64) -LIBSELECT=64 -endif - -debug: CXXFLAGS = -Wall -g -O1 -debug: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DDEBUG -DRUN_IN_PLACE -debug: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread -lz - -fast: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686 -fast: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DUNITTEST_DISABLE -DRUN_IN_PLACE -fast: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread -lz - -server: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686 -server: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DSERVER -DUNITTEST_DISABLE -DRUN_IN_PLACE -server: LDFLAGS = -L$(JTHREADPATH)/src/.libs -ljthread -lz -lpthread - -DEBUG_DESTPATH = bin/$(DEBUG_TARGET) -FAST_DESTPATH = bin/$(FAST_TARGET) -SERVER_DESTPATH = bin/$(SERVER_TARGET) - -# Build commands - -debug: $(DEBUG_BUILD_DIR) $(DEBUG_DESTPATH) -fast: $(FAST_BUILD_DIR) $(FAST_DESTPATH) -server: $(SERVER_BUILD_DIR) $(SERVER_DESTPATH) - -$(DEBUG_BUILD_DIR): - mkdir -p $(DEBUG_BUILD_DIR) -$(FAST_BUILD_DIR): - mkdir -p $(FAST_BUILD_DIR) -$(SERVER_BUILD_DIR): - mkdir -p $(SERVER_BUILD_DIR) - -$(DEBUG_DESTPATH): $(DEBUG_OBJECTS) - $(CXX) -o $@ $(DEBUG_OBJECTS) $(LDFLAGS) - -$(FAST_DESTPATH): $(FAST_OBJECTS) - $(CXX) -o $@ $(FAST_OBJECTS) $(LDFLAGS) - -$(SERVER_DESTPATH): $(SERVER_OBJECTS) - $(CXX) -o $@ $(SERVER_OBJECTS) $(LDFLAGS) - -$(DEBUG_BUILD_DIR)/%.o: src/%.cpp - $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) - -$(FAST_BUILD_DIR)/%.o: src/%.cpp - $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) - -$(SERVER_BUILD_DIR)/%.o: src/%.cpp - $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) - -clean: clean_debug clean_fast clean_server - -clean_debug: - @$(RM) $(DEBUG_OBJECTS) $(DEBUG_DESTPATH) - -clean_fast: - @$(RM) $(FAST_OBJECTS) $(FAST_DESTPATH) - -clean_server: - @$(RM) $(SERVER_OBJECTS) $(SERVER_DESTPATH) - -.PHONY: all all_win32 clean clean_debug clean_win32 clean_fast clean_server diff --git a/README.txt b/README.txt new file mode 100644 index 000000000..41048992e --- /dev/null +++ b/README.txt @@ -0,0 +1,239 @@ +Minetest-c55 +--------------- +An InfiniMiner/Minecraft inspired game. +Copyright (c) 2010-2011 Perttu Ahola +(see source files for other contributors) + +Further documentation: +---------------------- +- Website: http://celeron.55.lt/~celeron55/minetest/ +- Wiki: http://celeron.55.lt/~celeron55/minetest/wiki/ +- Forum: http://celeron.55.lt/~celeron55/minetest/forum/ +- doc/ directory of source distribution + +This game is not finished: +-------------------------- +- Don't expect it to work as well as a finished game will. +- Please report any bugs to me. debug.txt is useful. + +Controls: +--------- +- See the in-game pause menu +- Settable in the configuration file, see the section below. + +Map directory: +-------------- +- Map is stored in a directory, which can be removed to generate a new map. +- There is a command-line option for it: --map-dir +- For a RUN_IN_PLACE build, it is located in: + ../map +- Otherwise something like this: + Windows: C:\Documents and Settings\user\Application Data\minetest\map + Linux: ~/.minetest/map + OS X: ~/Library/Application Support/minetest/map + +Configuration file: +------------------- +- An optional configuration file can be used. See minetest.conf.example. +- Path to file can be passed as a parameter to the executable: + --config +- Defaults: + - If built with -DRUN_IN_PLACE=1: + ../minetest.conf + ../../minetest.conf + - Otherwise something like this: + Windows: C:\Documents and Settings\user\Application Data\minetest\minetest.conf + Linux: ~/.minetest/minetest.conf + OS X: ~/Library/Application Support/minetest.conf + +Command-line options: +--------------------- +- Use --help + +Compiling on GNU/Linux: +----------------------- + +Install dependencies. Here's an example for Debian/Ubuntu: +$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev + +Download source, extract (this is the URL to the latest of source repository, which might not work at all times): +$ wget https://bitbucket.org/celeron55/minetest/get/tip.tar.gz +$ tar xf tip.tar.gz +$ cd minetest + +Build a version that runs directly from the source directory: +$ cmake . -DRUN_IN_PLACE=1 +$ make -j2 + +Run it: +$ cd bin +$ ./minetest + +- Use cmake . -LH to see all CMake options and their current state +- If you want to install it system-wide (or are making a distribution package), you will want to use -DRUN_IN_PLACE=0 +- You can build a bare server or a bare client by specifying -DBUILD_CLIENT=0 or -DBUILD_SERVER=0 +- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE= + - Note that the Debug build is considerably slower + +Compiling on Windows: +--------------------- + +- You need: + * CMake: + http://www.cmake.org/cmake/resources/software.html + * MinGW or Visual Studio + http://www.mingw.org/ + http://msdn.microsoft.com/en-us/vstudio/default + * Irrlicht SDK 1.7: + http://irrlicht.sourceforge.net/downloads.html + * Zlib headers (zlib125.zip) + http://www.winimage.com/zLibDll/index.html + * Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip): + http://www.winimage.com/zLibDll/index.html + * And, of course, Minetest-c55: + http://celeron.55.lt/~celeron55/minetest/download +- Steps: + - Select a directory called DIR hereafter in which you will operate. + - Make sure you have CMake and a compiler installed. + - Download all the other stuff to DIR and extract them into there. All those + packages contain a nice base directory in them, which should end up being + the direct subdirectories of DIR. + - You will end up with a directory structure like this (+=dir, -=file): + ----------------- + + DIR + - zlib-1.2.5.tar.gz + - zlib125dll.zip + - irrlicht-1.7.1.zip + - 110214175330.zip (or whatever, this is the minetest source) + + zlib-1.2.5 + - zlib.h + + win32 + ... + + zlib125dll + - readme.txt + + dll32 + ... + + irrlicht-1.7.1 + + lib + + include + ... + + minetest + + src + + doc + - CMakeLists.txt + ... + ----------------- + - Start up the CMake GUI + - Select "Browse Source..." and select DIR/minetest + - Now, if using MSVC: + - Select "Browse Build..." and select DIR/minetest-build + - Else if using MinGW: + - Select "Browse Build..." and select DIR/minetest + - Select "Configure" + - Select your compiler + - It will warn about missing stuff, ignore that at this point. (later don't) + - Make sure the configuration is as follows + (note that the versions may differ for you): + ----------------- + BUILD_CLIENT [X] + BUILD_SERVER [ ] + CMAKE_BUILD_TYPE Release + CMAKE_INSTALL_PREFIX DIR/minetest-install + IRRLICHT_SOURCE_DIR DIR/irrlicht-1.7.1 + RUN_IN_PLACE [X] + WARN_ALL [ ] + ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll + ZLIB_INCLUDE_DIR DIR/zlib-1.2.5 + ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib + ----------------- + - Hit "Configure" + - Hit "Generate" + If using MSVC: + - Open the generated minetest.sln + - The project defaults to the "Debug" configuration. Make very sure to + select "Release", unless you want to debug some stuff (it's slower) + - Build the ALL_BUILD project + - Build the INSTALL project + - You should now have a working game with the executable in + DIR/minetest-install/bin/minetest.exe + - Additionally you may create a zip package by building the PACKAGE + project. + If using MinGW: + - Using the command line, browse to the build directory and run 'make' + (or mingw32-make or whatever it happens to be) + - You should now have a working game with the executable in + DIR/minetest/bin/minetest.exe + +License of Minetest-c55 +----------------------- + +Minetest-c55 +Copyright (C) 2010-2011 celeron55, Perttu Ahola + +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. + +Irrlicht +--------------- + +This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/ + + The Irrlicht Engine License + +Copyright © 2002-2005 Nikolaus Gebhardt + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute +it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + + +JThread +--------------- + +This program uses the JThread library. License for JThread follows: + +Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + + diff --git a/addlicensecomments.sh b/addlicensecomments.sh deleted file mode 100644 index e5642e82d..000000000 --- a/addlicensecomments.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -for i in `grep -L 'This program is free software' src/*.{h,cpp}` -do - cat licensecomment.txt > tempfile - cat $i >> tempfile - cp tempfile $i -done -rm tempfile - diff --git a/doc/README.txt b/doc/README.txt deleted file mode 100644 index 645e2a560..000000000 --- a/doc/README.txt +++ /dev/null @@ -1,238 +0,0 @@ -Minetest-c55 ---------------- -An InfiniMiner/Minecraft inspired game. -Copyright (c) 2010-2011 Perttu Ahola - -Further documentation: ----------------------- -- Website: http://celeron.55.lt/~celeron55/minetest/ -- Wiki: http://celeron.55.lt/~celeron55/minetest/wiki/ -- Forum: http://celeron.55.lt/~celeron55/minetest/forum/ - -This is a development version: ------------------------------- -- Don't expect it to work as well as a finished game will. -- Please report any bugs to me. That way I can fix them to the next release. - - debug.txt is useful when the game crashes. - -Controls: ---------- -- See the in-game pause menu -- Settable in the configuration file, see the section below. - -Map directory: --------------- -- Map is stored in a directory, which can be removed to generate a new map. -- There is a command-line option for it: --map-dir -- For a RUN_IN_PLACE build, it is located in: - ../map -- Otherwise something like this: - Windows: C:\Documents and Settings\user\Application Data\minetest\map - Linux: ~/.minetest/map - OS X: ~/Library/Application Support/minetest/map - -Configuration file: -------------------- -- An optional configuration file can be used. See minetest.conf.example. -- Path to file can be passed as a parameter to the executable: - --config -- Defaults: - - If built with -DRUN_IN_PLACE=1: - ../minetest.conf - ../../minetest.conf - - Otherwise something like this: - Windows: C:\Documents and Settings\user\Application Data\minetest\minetest.conf - Linux: ~/.minetest/minetest.conf - OS X: ~/Library/Application Support/minetest.conf - -Command-line options: ---------------------- -- Use --help - -Compiling on GNU/Linux: ------------------------ - -Install dependencies. Here's an example for Debian/Ubuntu: -$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev - -Download source, extract (this is the URL to the latest of source repository, which might not work at all times): -$ wget https://bitbucket.org/celeron55/minetest/get/tip.tar.gz -$ tar xf tip.tar.gz -$ cd minetest - -Build a version that runs directly from the source directory: -$ cmake . -DRUN_IN_PLACE=1 -$ make -j2 - -Run it: -$ cd bin -$ ./minetest - -- Use cmake . -LH to see all CMake options and their current state -- If you want to install it system-wide (or are making a distribution package), you will want to use -DRUN_IN_PLACE=0 -- You can build a bare server or a bare client by specifying -DBUILD_CLIENT=0 or -DBUILD_SERVER=0 -- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE= - - Note that the Debug build is considerably slower - -Compiling on Windows: ---------------------- - -- You need: - * CMake: - http://www.cmake.org/cmake/resources/software.html - * MinGW or Visual Studio - http://www.mingw.org/ - http://msdn.microsoft.com/en-us/vstudio/default - * Irrlicht SDK 1.7: - http://irrlicht.sourceforge.net/downloads.html - * Zlib headers (zlib125.zip) - http://www.winimage.com/zLibDll/index.html - * Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip): - http://www.winimage.com/zLibDll/index.html - * And, of course, Minetest-c55: - http://celeron.55.lt/~celeron55/minetest/download -- Steps: - - Select a directory called DIR hereafter in which you will operate. - - Make sure you have CMake and a compiler installed. - - Download all the other stuff to DIR and extract them into there. All those - packages contain a nice base directory in them, which should end up being - the direct subdirectories of DIR. - - You will end up with a directory structure like this (+=dir, -=file): - ----------------- - + DIR - - zlib-1.2.5.tar.gz - - zlib125dll.zip - - irrlicht-1.7.1.zip - - 110214175330.zip (or whatever, this is the minetest source) - + zlib-1.2.5 - - zlib.h - + win32 - ... - + zlib125dll - - readme.txt - + dll32 - ... - + irrlicht-1.7.1 - + lib - + include - ... - + minetest - + src - + doc - - CMakeLists.txt - ... - ----------------- - - Start up the CMake GUI - - Select "Browse Source..." and select DIR/minetest - - Now, if using MSVC: - - Select "Browse Build..." and select DIR/minetest-build - - Else if using MinGW: - - Select "Browse Build..." and select DIR/minetest - - Select "Configure" - - Select your compiler - - It will warn about missing stuff, ignore that at this point. (later don't) - - Make sure the configuration is as follows - (note that the versions may differ for you): - ----------------- - BUILD_CLIENT [X] - BUILD_SERVER [ ] - CMAKE_BUILD_TYPE Release - CMAKE_INSTALL_PREFIX DIR/minetest-install - IRRLICHT_SOURCE_DIR DIR/irrlicht-1.7.1 - RUN_IN_PLACE [X] - WARN_ALL [ ] - ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll - ZLIB_INCLUDE_DIR DIR/zlib-1.2.5 - ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib - ----------------- - - Hit "Configure" - - Hit "Generate" - If using MSVC: - - Open the generated minetest.sln - - The project defaults to the "Debug" configuration. Make very sure to - select "Release", unless you want to debug some stuff (it's slower) - - Build the ALL_BUILD project - - Build the INSTALL project - - You should now have a working game with the executable in - DIR/minetest-install/bin/minetest.exe - - Additionally you may create a zip package by building the PACKAGE - project. - If using MinGW: - - Using the command line, browse to the build directory and run 'make' - (or mingw32-make or whatever it happens to be) - - You should now have a working game with the executable in - DIR/minetest/bin/minetest.exe - -License of Minetest-c55 ------------------------ - -Minetest-c55 -Copyright (C) 2010-2011 celeron55, Perttu Ahola - -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. - -Irrlicht ---------------- - -This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/ - - The Irrlicht Engine License - -Copyright © 2002-2005 Nikolaus Gebhardt - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute -it freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you - must not claim that you wrote the original software. If you use - this software in a product, an acknowledgment in the product - documentation would be appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must - not be misrepresented as being the original software. - 3. This notice may not be removed or altered from any source - distribution. - - -JThread ---------------- - -This program uses the JThread library. License for JThread follows: - -Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com) - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -IN THE SOFTWARE. - - diff --git a/genmap.py b/genmap.py deleted file mode 100755 index a60509403..000000000 --- a/genmap.py +++ /dev/null @@ -1,271 +0,0 @@ -#!/usr/bin/python2 - -# This is an example script that generates some valid map data. - -import struct -import random -import os -import sys -import zlib -import array -from pnoise import pnoise - -# Old directory format: -# world/sectors/XXXXZZZZ/YYYY -# XXXX,YYYY,ZZZZ = coordinates in hexadecimal -# fffe = -2 -# ffff = -1 -# 0000 = 0 -# 0001 = 1 -# -# New directory format: -# world/sectors2/XXX/ZZZ/YYYY -# XXX,YYYY,ZZZ = coordinates in hexadecimal -# fffe = -2 -# ffff = -1 -# 0000 = 0 -# 0001 = 1 -# ffe = -2 -# fff = -1 -# 000 = 0 -# 001 = 1 -# -# For more proper file format documentation, refer to mapformat.txt -# For node type documentation, refer to mapnode.h -# NodeMetadata documentation is not complete, refer to nodemeta.cpp -# - -# Seed for generating terrain -SEED = 0 - -# 0=old, 1=new -SECTOR_DIR_FORMAT = 1 - -mapdir = "world" - -def to4h(i): - s = ""; - s += '{0:1x}'.format((i>>12) & 0x000f) - s += '{0:1x}'.format((i>>8) & 0x000f) - s += '{0:1x}'.format((i>>4) & 0x000f) - s += '{0:1x}'.format((i>>0) & 0x000f) - return s - -def to3h(i): - s = ""; - s += '{0:1x}'.format((i>>8) & 0x000f) - s += '{0:1x}'.format((i>>4) & 0x000f) - s += '{0:1x}'.format((i>>0) & 0x000f) - return s - -def get_sector_dir(px, pz): - global SECTOR_DIR_FORMAT - if SECTOR_DIR_FORMAT == 0: - return "/sectors/"+to4h(px)+to4h(pz) - elif SECTOR_DIR_FORMAT == 1: - return "/sectors2/"+to3h(px)+"/"+to3h(pz) - else: - assert(0) - -def getrand_air_stone(): - i = random.randrange(0,2) - if i==0: - return 0 - return 254 - -# 3-dimensional vector (position) -class v3: - def __init__(self, x=0, y=0, z=0): - self.X = x - self.Y = y - self.Z = z - -class NodeMeta: - def __init__(self, type_id, data): - self.type_id = type_id - self.data = data - -class StaticObject: - def __init__(self): - self.type_id = 0 - self.data = "" - -def ser_u16(i): - return chr((i>>8)&0xff) + chr((i>>0)&0xff) -def ser_u32(i): - return (chr((i>>24)&0xff) + chr((i>>16)&0xff) - + chr((i>>8)&0xff) + chr((i>>0)&0xff)) - -# A 16x16x16 chunk of map -class MapBlock: - def __init__(self): - self.content = array.array('B') - self.param1 = array.array('B') - self.param2 = array.array('B') - for i in range(16*16*16): - # Initialize to air - self.content.append(254) - # Full light on sunlight, none when no sunlight - self.param1.append(15) - # No additional parameters - self.param2.append(0) - - # key = v3 pos - # value = NodeMeta - self.nodemeta = {} - - # key = v3 pos - # value = StaticObject - self.static_objects = {} - - def set_content(self, v3, b): - self.content[v3.Z*16*16+v3.Y*16+v3.X] = b - def set_param1(self, v3, b): - self.param1[v3.Z*16*16+v3.Y*16+v3.X] = b - def set_param2(self, v3, b): - self.param2[v3.Z*16*16+v3.Y*16+v3.X] = b - - # Get data for serialization. Returns a string. - def serialize_data(self): - s = "" - for i in range(16*16*16): - s += chr(self.content[i]) - for i in range(16*16*16): - s += chr(self.param1[i]) - for i in range(16*16*16): - s += chr(self.param2[i]) - return s - - def serialize_nodemeta(self): - s = "" - s += ser_u16(1) - s += ser_u16(len(self.nodemeta)) - for pos, meta in self.nodemeta.items(): - pos_i = pos.Z*16*16 + pos.Y*16 + pos.X - s += ser_u16(pos_i) - s += ser_u16(meta.type_id) - s += ser_u16(len(meta.data)) - s += meta.data - return s - - def serialize_staticobj(self): - s = "" - s += chr(0) - s += ser_u16(len(self.static_objects)) - for pos, obj in self.static_objects.items(): - pos_i = pos.Z*16*16 + pos.Y*16 + pos.X - s += ser_s32(pos.X*1000) - s += ser_s32(pos.Y*1000) - s += ser_s32(pos.Z*1000) - s += ser_u16(obj.type_id) - s += ser_u16(len(obj.data)) - s += obj.data - return s - -def writeblock(mapdir, px,py,pz, block): - - sectordir = mapdir + get_sector_dir(px, pz); - - try: - os.makedirs(sectordir) - except OSError: - pass - - path = sectordir+"/"+to4h(py) - - print("writing block file "+path) - - f = open(sectordir+"/"+to4h(py), "wb") - - if f == None: - return - - # version - version = 17 - f.write(struct.pack('B', version)) - - # flags - # 0x01=is_undg, 0x02=dn_diff, 0x04=lighting_expired - flags = 0 + 0x02 + 0x04 - f.write(struct.pack('B', flags)) - - # data - c_obj = zlib.compressobj() - c_obj.compress(block.serialize_data()) - f.write(struct.pack('BB', 0x78, 0x9c)) # zlib magic number - f.write(c_obj.flush()) - - # node metadata - c_obj = zlib.compressobj() - c_obj.compress(block.serialize_nodemeta()) - f.write(struct.pack('BB', 0x78, 0x9c)) # zlib magic number - f.write(c_obj.flush()) - - # mapblockobject count - f.write(ser_u16(0)) - - # static objects - f.write(block.serialize_staticobj()) - - # timestamp - f.write(ser_u32(0xffffffff)) - - f.close() - -for z0 in range(-1,3): - for x0 in range(-1,3): - for y0 in range(-1,3): - print("generating block "+str(x0)+","+str(y0)+","+str(z0)) - #v3 blockp = v3(x0,y0,z0) - - # Create a MapBlock - block = MapBlock() - - # Generate stuff in it - for z in range(0,16): - for x in range(0,16): - h = 20.0*pnoise((x0*16+x)/100.,(z0*16+z)/100.,SEED+0) - h += 5.0*pnoise((x0*16+x)/25.,(z0*16+z)/25.,SEED+0) - if pnoise((x0*16+x)/25.,(z0*16+z)/25.,SEED+92412) > 0.05: - h += 10 - #print("r="+str(r)) - # This enables comparison by == - h = int(h) - for y in range(0,16): - p = v3(x,y,z) - b = 254 - y1 = y0*16+y - if y1 <= h-3: - b = 0 #stone - elif y1 <= h and y1 <= 0: - b = 8 #mud - elif y1 == h: - b = 1 #grass - elif y1 < h: - b = 8 #mud - elif y1 <= 1: - b = 9 #water - - # Material content - block.set_content(p, b) - - # Place a sign at the center at surface level. - # Placing a sign means placing the sign node and - # adding node metadata to the mapblock. - if x == 8 and z == 8 and y0*16 <= h-1 and (y0+1)*16-1 > h: - p = v3(8,h+1-y0*16,8) - # 14 = Sign - content_type = 14 - block.set_content(p, content_type) - # This places the sign to the bottom of the cube. - # Working values: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20 - block.set_param2(p, 0x08) - # Then add metadata to hold the text of the sign - s = "Hello at sector ("+str(x0)+","+str(z0)+")" - meta = NodeMeta(content_type, ser_u16(len(s))+s) - block.nodemeta[p] = meta - - # Write it on disk - writeblock(mapdir, x0,y0,z0, block) - -#END diff --git a/makepackage_binary.sh b/makepackage_binary.sh deleted file mode 100755 index f00ec608c..000000000 --- a/makepackage_binary.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh - -PACKAGEDIR=../minetest-packages -PACKAGENAME=minetest-c55-binary-`date +%y%m%d%H%M%S` -PACKAGEPATH=$PACKAGEDIR/$PACKAGENAME - -mkdir -p $PACKAGEPATH -mkdir -p $PACKAGEPATH/bin -mkdir -p $PACKAGEPATH/data -mkdir -p $PACKAGEPATH/doc - -cp minetest.conf.example $PACKAGEPATH/ - -cp bin/minetest.exe $PACKAGEPATH/bin/ -cp bin/Irrlicht.dll $PACKAGEPATH/bin/ -cp bin/zlibwapi.dll $PACKAGEPATH/bin/ -#cp bin/test $PACKAGEPATH/bin/ -#cp bin/fasttest $PACKAGEPATH/bin/ -#cp bin/server $PACKAGEPATH/bin/ -#cp ../irrlicht/irrlicht-1.7.1/lib/Linux/libIrrlicht.a $PACKAGEPATH/bin/ -#cp ../jthread/jthread-1.2.1/src/.libs/libjthread-1.2.1.so $PACKAGEPATH/bin/ - -cp -r data/fontlucida.png $PACKAGEPATH/data/ -cp -r data/player.png $PACKAGEPATH/data/ -cp -r data/player_back.png $PACKAGEPATH/data/ -cp -r data/stone.png $PACKAGEPATH/data/ -cp -r data/grass.png $PACKAGEPATH/data/ -cp -r data/grass_footsteps.png $PACKAGEPATH/data/ -cp -r data/water.png $PACKAGEPATH/data/ -cp -r data/tree.png $PACKAGEPATH/data/ -cp -r data/leaves.png $PACKAGEPATH/data/ -cp -r data/mese.png $PACKAGEPATH/data/ -cp -r data/cloud.png $PACKAGEPATH/data/ -cp -r data/sign.png $PACKAGEPATH/data/ -cp -r data/sign_back.png $PACKAGEPATH/data/ -cp -r data/rat.png $PACKAGEPATH/data/ -cp -r data/mud.png $PACKAGEPATH/data/ -cp -r data/torch.png $PACKAGEPATH/data/ -cp -r data/torch_on_floor.png $PACKAGEPATH/data/ -cp -r data/torch_on_ceiling.png $PACKAGEPATH/data/ -cp -r data/tree_top.png $PACKAGEPATH/data/ -cp -r data/coalstone.png $PACKAGEPATH/data/ -cp -r data/crack.png $PACKAGEPATH/data/ -cp -r data/wood.png $PACKAGEPATH/data/ -cp -r data/stick.png $PACKAGEPATH/data/ -cp -r data/tool_wpick.png $PACKAGEPATH/data/ -cp -r data/tool_stpick.png $PACKAGEPATH/data/ -cp -r data/tool_mesepick.png $PACKAGEPATH/data/ -cp -r data/grass_side.png $PACKAGEPATH/data/ -cp -r data/lump_of_coal.png $PACKAGEPATH/data/ -cp -r data/lump_of_iron.png $PACKAGEPATH/data/ -cp -r data/mineral_coal.png $PACKAGEPATH/data/ -cp -r data/mineral_iron.png $PACKAGEPATH/data/ -cp -r data/sand.png $PACKAGEPATH/data/ - -#cp -r data/pauseMenu.gui $PACKAGEPATH/data/ - -cp -r doc/README.txt $PACKAGEPATH/doc/README.txt - -cd $PACKAGEDIR -rm $PACKAGENAME.zip -zip -r $PACKAGENAME.zip $PACKAGENAME - diff --git a/minetest.sln b/minetest.sln deleted file mode 100644 index d1f144cb7..000000000 --- a/minetest.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minetest", "minetest.vcproj", "{AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Debug|Win32.Build.0 = Debug|Win32 - {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Release|Win32.ActiveCfg = Release|Win32 - {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/minetest.vcproj b/minetest.vcproj deleted file mode 100644 index 8973c9a2c..000000000 --- a/minetest.vcproj +++ /dev/null @@ -1,424 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/old/Makefile.bak b/old/Makefile.bak new file mode 100644 index 000000000..8ba03f9bb --- /dev/null +++ b/old/Makefile.bak @@ -0,0 +1,90 @@ +# Makefile for Irrlicht Examples +# It's usually sufficient to change just the target name and source file list +# and be sure that CXX is set to a valid compiler +SOURCE_FILES = porting.cpp guiMessageMenu.cpp materials.cpp guiTextInputMenu.cpp guiInventoryMenu.cpp irrlichtwrapper.cpp guiPauseMenu.cpp defaultsettings.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp + +DEBUG_TARGET = debugtest +DEBUG_SOURCES = $(addprefix src/, $(SOURCE_FILES)) +DEBUG_BUILD_DIR = debugbuild +DEBUG_OBJECTS = $(addprefix $(DEBUG_BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o)) + +FAST_TARGET = fasttest +FAST_SOURCES = $(addprefix src/, $(SOURCE_FILES)) +FAST_BUILD_DIR = fastbuild +FAST_OBJECTS = $(addprefix $(FAST_BUILD_DIR)/, $(SOURCE_FILES:.cpp=.o)) + +SERVER_TARGET = server +SERVER_SOURCE_FILES = porting.cpp materials.cpp defaultsettings.cpp mapnode.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp servermain.cpp test.cpp +SERVER_SOURCES = $(addprefix src/, $(SERVER_SOURCE_FILES)) +SERVER_BUILD_DIR = serverbuild +SERVER_OBJECTS = $(addprefix $(SERVER_BUILD_DIR)/, $(SERVER_SOURCE_FILES:.cpp=.o)) + +IRRLICHTPATH = ../irrlicht/irrlicht-1.7.1 +JTHREADPATH = ../jthread/jthread-1.2.1 + + +all: fast + +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif + +debug: CXXFLAGS = -Wall -g -O1 +debug: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DDEBUG -DRUN_IN_PLACE +debug: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread -lz + +fast: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686 +fast: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DUNITTEST_DISABLE -DRUN_IN_PLACE +fast: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread -lz + +server: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686 +server: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DSERVER -DUNITTEST_DISABLE -DRUN_IN_PLACE +server: LDFLAGS = -L$(JTHREADPATH)/src/.libs -ljthread -lz -lpthread + +DEBUG_DESTPATH = bin/$(DEBUG_TARGET) +FAST_DESTPATH = bin/$(FAST_TARGET) +SERVER_DESTPATH = bin/$(SERVER_TARGET) + +# Build commands + +debug: $(DEBUG_BUILD_DIR) $(DEBUG_DESTPATH) +fast: $(FAST_BUILD_DIR) $(FAST_DESTPATH) +server: $(SERVER_BUILD_DIR) $(SERVER_DESTPATH) + +$(DEBUG_BUILD_DIR): + mkdir -p $(DEBUG_BUILD_DIR) +$(FAST_BUILD_DIR): + mkdir -p $(FAST_BUILD_DIR) +$(SERVER_BUILD_DIR): + mkdir -p $(SERVER_BUILD_DIR) + +$(DEBUG_DESTPATH): $(DEBUG_OBJECTS) + $(CXX) -o $@ $(DEBUG_OBJECTS) $(LDFLAGS) + +$(FAST_DESTPATH): $(FAST_OBJECTS) + $(CXX) -o $@ $(FAST_OBJECTS) $(LDFLAGS) + +$(SERVER_DESTPATH): $(SERVER_OBJECTS) + $(CXX) -o $@ $(SERVER_OBJECTS) $(LDFLAGS) + +$(DEBUG_BUILD_DIR)/%.o: src/%.cpp + $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) + +$(FAST_BUILD_DIR)/%.o: src/%.cpp + $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) + +$(SERVER_BUILD_DIR)/%.o: src/%.cpp + $(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS) + +clean: clean_debug clean_fast clean_server + +clean_debug: + @$(RM) $(DEBUG_OBJECTS) $(DEBUG_DESTPATH) + +clean_fast: + @$(RM) $(FAST_OBJECTS) $(FAST_DESTPATH) + +clean_server: + @$(RM) $(SERVER_OBJECTS) $(SERVER_DESTPATH) + +.PHONY: all all_win32 clean clean_debug clean_win32 clean_fast clean_server diff --git a/old/minetest.sln b/old/minetest.sln new file mode 100644 index 000000000..d1f144cb7 --- /dev/null +++ b/old/minetest.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minetest", "minetest.vcproj", "{AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Debug|Win32.ActiveCfg = Debug|Win32 + {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Debug|Win32.Build.0 = Debug|Win32 + {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Release|Win32.ActiveCfg = Release|Win32 + {AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/old/minetest.vcproj b/old/minetest.vcproj new file mode 100644 index 000000000..8973c9a2c --- /dev/null +++ b/old/minetest.vcproj @@ -0,0 +1,424 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pnoise.py b/pnoise.py deleted file mode 100644 index fcab5ac15..000000000 --- a/pnoise.py +++ /dev/null @@ -1,102 +0,0 @@ -# -# A python perlin noise implementation, from -# http://www.fundza.com/c4serious/noise/perlin/perlin.html -# -# This is used for testing how to create maps with a python script. -# - -import math -p = ( -151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103, -30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197, -62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20, -125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231, -83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102, -143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200, -196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226, -250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16, -58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70, -221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113, -224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144, -12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181, -199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236, -205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180, -151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103, -30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197, -62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20, -125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231, -83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102, -143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200, -196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226, -250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16, -58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70, -221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113, -224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144, -12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181, -199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236, -205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180) - -def lerp(t, a, b): - return a + t * (b - a) - -def fade(t): - return t * t * t * (t * (t * 6 - 15) + 10) - -def grad(hash, x, y, z): - h = hash & 15 - if h < 8: - u = x - else: - u = y - if h < 4: - v = y - elif h == 12 or h == 14: - v = x - else: - v = z - if h & 1 != 0: - u = -u - if h & 2 != 0: - v = -v - return u + v - -def pnoise(x, y, z): - global p - X = int(math.floor(x)) & 255 - Y = int(math.floor(y)) & 255 - Z = int(math.floor(z)) & 255 - x -= math.floor(x) - y -= math.floor(y) - z -= math.floor(z) - - u = fade(x) - v = fade(y) - w = fade(z) - - A = p[X] + Y - AA = p[A] + Z - AB = p[A + 1] + Z - B = p[X + 1] + Y - BA = p[B] + Z - BB = p[B + 1] + Z - - pAA = p[AA] - pAB = p[AB] - pBA = p[BA] - pBB = p[BB] - pAA1 = p[AA + 1] - pBA1 = p[BA + 1] - pAB1 = p[AB + 1] - pBB1 = p[BB + 1] - - gradAA = grad(pAA, x, y, z) - gradBA = grad(pBA, x-1, y, z) - gradAB = grad(pAB, x, y-1, z) - gradBB = grad(pBB, x-1, y-1, z) - gradAA1 = grad(pAA1,x, y, z-1) - gradBA1 = grad(pBA1,x-1, y, z-1) - gradAB1 = grad(pAB1,x, y-1, z-1) - gradBB1 = grad(pBB1,x-1, y-1, z-1) - return lerp(w, - lerp(v, lerp(u, gradAA, gradBA), lerp(u, gradAB, gradBB)), - lerp(v, lerp(u, gradAA1,gradBA1),lerp(u, gradAB1,gradBB1))) diff --git a/util/genmap.py b/util/genmap.py new file mode 100755 index 000000000..6b36269d5 --- /dev/null +++ b/util/genmap.py @@ -0,0 +1,271 @@ +#!/usr/bin/python2 + +# This is an example script that generates some valid map data. + +import struct +import random +import os +import sys +import zlib +import array +from pnoise import pnoise + +# Old directory format: +# world/sectors/XXXXZZZZ/YYYY +# XXXX,YYYY,ZZZZ = coordinates in hexadecimal +# fffe = -2 +# ffff = -1 +# 0000 = 0 +# 0001 = 1 +# +# New directory format: +# world/sectors2/XXX/ZZZ/YYYY +# XXX,YYYY,ZZZ = coordinates in hexadecimal +# fffe = -2 +# ffff = -1 +# 0000 = 0 +# 0001 = 1 +# ffe = -2 +# fff = -1 +# 000 = 0 +# 001 = 1 +# +# For more proper file format documentation, refer to mapformat.txt +# For node type documentation, refer to mapnode.h +# NodeMetadata documentation is not complete, refer to nodemeta.cpp +# + +# Seed for generating terrain +SEED = 0 + +# 0=old, 1=new +SECTOR_DIR_FORMAT = 1 + +mapdir = "../world" + +def to4h(i): + s = ""; + s += '{0:1x}'.format((i>>12) & 0x000f) + s += '{0:1x}'.format((i>>8) & 0x000f) + s += '{0:1x}'.format((i>>4) & 0x000f) + s += '{0:1x}'.format((i>>0) & 0x000f) + return s + +def to3h(i): + s = ""; + s += '{0:1x}'.format((i>>8) & 0x000f) + s += '{0:1x}'.format((i>>4) & 0x000f) + s += '{0:1x}'.format((i>>0) & 0x000f) + return s + +def get_sector_dir(px, pz): + global SECTOR_DIR_FORMAT + if SECTOR_DIR_FORMAT == 0: + return "/sectors/"+to4h(px)+to4h(pz) + elif SECTOR_DIR_FORMAT == 1: + return "/sectors2/"+to3h(px)+"/"+to3h(pz) + else: + assert(0) + +def getrand_air_stone(): + i = random.randrange(0,2) + if i==0: + return 0 + return 254 + +# 3-dimensional vector (position) +class v3: + def __init__(self, x=0, y=0, z=0): + self.X = x + self.Y = y + self.Z = z + +class NodeMeta: + def __init__(self, type_id, data): + self.type_id = type_id + self.data = data + +class StaticObject: + def __init__(self): + self.type_id = 0 + self.data = "" + +def ser_u16(i): + return chr((i>>8)&0xff) + chr((i>>0)&0xff) +def ser_u32(i): + return (chr((i>>24)&0xff) + chr((i>>16)&0xff) + + chr((i>>8)&0xff) + chr((i>>0)&0xff)) + +# A 16x16x16 chunk of map +class MapBlock: + def __init__(self): + self.content = array.array('B') + self.param1 = array.array('B') + self.param2 = array.array('B') + for i in range(16*16*16): + # Initialize to air + self.content.append(254) + # Full light on sunlight, none when no sunlight + self.param1.append(15) + # No additional parameters + self.param2.append(0) + + # key = v3 pos + # value = NodeMeta + self.nodemeta = {} + + # key = v3 pos + # value = StaticObject + self.static_objects = {} + + def set_content(self, v3, b): + self.content[v3.Z*16*16+v3.Y*16+v3.X] = b + def set_param1(self, v3, b): + self.param1[v3.Z*16*16+v3.Y*16+v3.X] = b + def set_param2(self, v3, b): + self.param2[v3.Z*16*16+v3.Y*16+v3.X] = b + + # Get data for serialization. Returns a string. + def serialize_data(self): + s = "" + for i in range(16*16*16): + s += chr(self.content[i]) + for i in range(16*16*16): + s += chr(self.param1[i]) + for i in range(16*16*16): + s += chr(self.param2[i]) + return s + + def serialize_nodemeta(self): + s = "" + s += ser_u16(1) + s += ser_u16(len(self.nodemeta)) + for pos, meta in self.nodemeta.items(): + pos_i = pos.Z*16*16 + pos.Y*16 + pos.X + s += ser_u16(pos_i) + s += ser_u16(meta.type_id) + s += ser_u16(len(meta.data)) + s += meta.data + return s + + def serialize_staticobj(self): + s = "" + s += chr(0) + s += ser_u16(len(self.static_objects)) + for pos, obj in self.static_objects.items(): + pos_i = pos.Z*16*16 + pos.Y*16 + pos.X + s += ser_s32(pos.X*1000) + s += ser_s32(pos.Y*1000) + s += ser_s32(pos.Z*1000) + s += ser_u16(obj.type_id) + s += ser_u16(len(obj.data)) + s += obj.data + return s + +def writeblock(mapdir, px,py,pz, block): + + sectordir = mapdir + get_sector_dir(px, pz); + + try: + os.makedirs(sectordir) + except OSError: + pass + + path = sectordir+"/"+to4h(py) + + print("writing block file "+path) + + f = open(sectordir+"/"+to4h(py), "wb") + + if f == None: + return + + # version + version = 17 + f.write(struct.pack('B', version)) + + # flags + # 0x01=is_undg, 0x02=dn_diff, 0x04=lighting_expired + flags = 0 + 0x02 + 0x04 + f.write(struct.pack('B', flags)) + + # data + c_obj = zlib.compressobj() + c_obj.compress(block.serialize_data()) + f.write(struct.pack('BB', 0x78, 0x9c)) # zlib magic number + f.write(c_obj.flush()) + + # node metadata + c_obj = zlib.compressobj() + c_obj.compress(block.serialize_nodemeta()) + f.write(struct.pack('BB', 0x78, 0x9c)) # zlib magic number + f.write(c_obj.flush()) + + # mapblockobject count + f.write(ser_u16(0)) + + # static objects + f.write(block.serialize_staticobj()) + + # timestamp + f.write(ser_u32(0xffffffff)) + + f.close() + +for z0 in range(-1,3): + for x0 in range(-1,3): + for y0 in range(-1,3): + print("generating block "+str(x0)+","+str(y0)+","+str(z0)) + #v3 blockp = v3(x0,y0,z0) + + # Create a MapBlock + block = MapBlock() + + # Generate stuff in it + for z in range(0,16): + for x in range(0,16): + h = 20.0*pnoise((x0*16+x)/100.,(z0*16+z)/100.,SEED+0) + h += 5.0*pnoise((x0*16+x)/25.,(z0*16+z)/25.,SEED+0) + if pnoise((x0*16+x)/25.,(z0*16+z)/25.,SEED+92412) > 0.05: + h += 10 + #print("r="+str(r)) + # This enables comparison by == + h = int(h) + for y in range(0,16): + p = v3(x,y,z) + b = 254 + y1 = y0*16+y + if y1 <= h-3: + b = 0 #stone + elif y1 <= h and y1 <= 0: + b = 8 #mud + elif y1 == h: + b = 1 #grass + elif y1 < h: + b = 8 #mud + elif y1 <= 1: + b = 9 #water + + # Material content + block.set_content(p, b) + + # Place a sign at the center at surface level. + # Placing a sign means placing the sign node and + # adding node metadata to the mapblock. + if x == 8 and z == 8 and y0*16 <= h-1 and (y0+1)*16-1 > h: + p = v3(8,h+1-y0*16,8) + # 14 = Sign + content_type = 14 + block.set_content(p, content_type) + # This places the sign to the bottom of the cube. + # Working values: 0x01, 0x02, 0x04, 0x08, 0x10, 0x20 + block.set_param2(p, 0x08) + # Then add metadata to hold the text of the sign + s = "Hello at sector ("+str(x0)+","+str(z0)+")" + meta = NodeMeta(content_type, ser_u16(len(s))+s) + block.nodemeta[p] = meta + + # Write it on disk + writeblock(mapdir, x0,y0,z0, block) + +#END diff --git a/util/pnoise.py b/util/pnoise.py new file mode 100644 index 000000000..fcab5ac15 --- /dev/null +++ b/util/pnoise.py @@ -0,0 +1,102 @@ +# +# A python perlin noise implementation, from +# http://www.fundza.com/c4serious/noise/perlin/perlin.html +# +# This is used for testing how to create maps with a python script. +# + +import math +p = ( +151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103, +30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197, +62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20, +125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231, +83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102, +143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200, +196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226, +250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16, +58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70, +221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113, +224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144, +12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181, +199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236, +205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180, +151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103, +30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197, +62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20, +125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231, +83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102, +143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200, +196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226, +250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16, +58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70, +221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113, +224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144, +12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181, +199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236, +205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180) + +def lerp(t, a, b): + return a + t * (b - a) + +def fade(t): + return t * t * t * (t * (t * 6 - 15) + 10) + +def grad(hash, x, y, z): + h = hash & 15 + if h < 8: + u = x + else: + u = y + if h < 4: + v = y + elif h == 12 or h == 14: + v = x + else: + v = z + if h & 1 != 0: + u = -u + if h & 2 != 0: + v = -v + return u + v + +def pnoise(x, y, z): + global p + X = int(math.floor(x)) & 255 + Y = int(math.floor(y)) & 255 + Z = int(math.floor(z)) & 255 + x -= math.floor(x) + y -= math.floor(y) + z -= math.floor(z) + + u = fade(x) + v = fade(y) + w = fade(z) + + A = p[X] + Y + AA = p[A] + Z + AB = p[A + 1] + Z + B = p[X + 1] + Y + BA = p[B] + Z + BB = p[B + 1] + Z + + pAA = p[AA] + pAB = p[AB] + pBA = p[BA] + pBB = p[BB] + pAA1 = p[AA + 1] + pBA1 = p[BA + 1] + pAB1 = p[AB + 1] + pBB1 = p[BB + 1] + + gradAA = grad(pAA, x, y, z) + gradBA = grad(pBA, x-1, y, z) + gradAB = grad(pAB, x, y-1, z) + gradBB = grad(pBB, x-1, y-1, z) + gradAA1 = grad(pAA1,x, y, z-1) + gradBA1 = grad(pBA1,x-1, y, z-1) + gradAB1 = grad(pAB1,x, y-1, z-1) + gradBB1 = grad(pBB1,x-1, y-1, z-1) + return lerp(w, + lerp(v, lerp(u, gradAA, gradBA), lerp(u, gradAB, gradBB)), + lerp(v, lerp(u, gradAA1,gradBA1),lerp(u, gradAB1,gradBB1))) -- cgit v1.2.3 From fb6ac9a1a6b68e87665a9e1692295230ebcef8db Mon Sep 17 00:00:00 2001 From: Sebastian Rühl Date: Sun, 26 Jun 2011 12:52:03 +0200 Subject: small fix --- doc/README.txt | 238 +++++++++++++++++++ makepackage_binary.sh | 63 +++++ src/guiKeyChangeMenu.cpp | 598 +++++++++++++++++++++++++++++++++++++++++++++++ src/guiKeyChangeMenu.h | 133 +++++++++++ 4 files changed, 1032 insertions(+) create mode 100644 doc/README.txt create mode 100755 makepackage_binary.sh create mode 100644 src/guiKeyChangeMenu.cpp create mode 100644 src/guiKeyChangeMenu.h (limited to 'doc') diff --git a/doc/README.txt b/doc/README.txt new file mode 100644 index 000000000..645e2a560 --- /dev/null +++ b/doc/README.txt @@ -0,0 +1,238 @@ +Minetest-c55 +--------------- +An InfiniMiner/Minecraft inspired game. +Copyright (c) 2010-2011 Perttu Ahola + +Further documentation: +---------------------- +- Website: http://celeron.55.lt/~celeron55/minetest/ +- Wiki: http://celeron.55.lt/~celeron55/minetest/wiki/ +- Forum: http://celeron.55.lt/~celeron55/minetest/forum/ + +This is a development version: +------------------------------ +- Don't expect it to work as well as a finished game will. +- Please report any bugs to me. That way I can fix them to the next release. + - debug.txt is useful when the game crashes. + +Controls: +--------- +- See the in-game pause menu +- Settable in the configuration file, see the section below. + +Map directory: +-------------- +- Map is stored in a directory, which can be removed to generate a new map. +- There is a command-line option for it: --map-dir +- For a RUN_IN_PLACE build, it is located in: + ../map +- Otherwise something like this: + Windows: C:\Documents and Settings\user\Application Data\minetest\map + Linux: ~/.minetest/map + OS X: ~/Library/Application Support/minetest/map + +Configuration file: +------------------- +- An optional configuration file can be used. See minetest.conf.example. +- Path to file can be passed as a parameter to the executable: + --config +- Defaults: + - If built with -DRUN_IN_PLACE=1: + ../minetest.conf + ../../minetest.conf + - Otherwise something like this: + Windows: C:\Documents and Settings\user\Application Data\minetest\minetest.conf + Linux: ~/.minetest/minetest.conf + OS X: ~/Library/Application Support/minetest.conf + +Command-line options: +--------------------- +- Use --help + +Compiling on GNU/Linux: +----------------------- + +Install dependencies. Here's an example for Debian/Ubuntu: +$ apt-get install build-essential libirrlicht-dev cmake libbz2-dev libpng12-dev libjpeg8-dev libxxf86vm-dev libgl1-mesa-dev + +Download source, extract (this is the URL to the latest of source repository, which might not work at all times): +$ wget https://bitbucket.org/celeron55/minetest/get/tip.tar.gz +$ tar xf tip.tar.gz +$ cd minetest + +Build a version that runs directly from the source directory: +$ cmake . -DRUN_IN_PLACE=1 +$ make -j2 + +Run it: +$ cd bin +$ ./minetest + +- Use cmake . -LH to see all CMake options and their current state +- If you want to install it system-wide (or are making a distribution package), you will want to use -DRUN_IN_PLACE=0 +- You can build a bare server or a bare client by specifying -DBUILD_CLIENT=0 or -DBUILD_SERVER=0 +- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE= + - Note that the Debug build is considerably slower + +Compiling on Windows: +--------------------- + +- You need: + * CMake: + http://www.cmake.org/cmake/resources/software.html + * MinGW or Visual Studio + http://www.mingw.org/ + http://msdn.microsoft.com/en-us/vstudio/default + * Irrlicht SDK 1.7: + http://irrlicht.sourceforge.net/downloads.html + * Zlib headers (zlib125.zip) + http://www.winimage.com/zLibDll/index.html + * Zlib library (zlibwapi.lib and zlibwapi.dll from zlib125dll.zip): + http://www.winimage.com/zLibDll/index.html + * And, of course, Minetest-c55: + http://celeron.55.lt/~celeron55/minetest/download +- Steps: + - Select a directory called DIR hereafter in which you will operate. + - Make sure you have CMake and a compiler installed. + - Download all the other stuff to DIR and extract them into there. All those + packages contain a nice base directory in them, which should end up being + the direct subdirectories of DIR. + - You will end up with a directory structure like this (+=dir, -=file): + ----------------- + + DIR + - zlib-1.2.5.tar.gz + - zlib125dll.zip + - irrlicht-1.7.1.zip + - 110214175330.zip (or whatever, this is the minetest source) + + zlib-1.2.5 + - zlib.h + + win32 + ... + + zlib125dll + - readme.txt + + dll32 + ... + + irrlicht-1.7.1 + + lib + + include + ... + + minetest + + src + + doc + - CMakeLists.txt + ... + ----------------- + - Start up the CMake GUI + - Select "Browse Source..." and select DIR/minetest + - Now, if using MSVC: + - Select "Browse Build..." and select DIR/minetest-build + - Else if using MinGW: + - Select "Browse Build..." and select DIR/minetest + - Select "Configure" + - Select your compiler + - It will warn about missing stuff, ignore that at this point. (later don't) + - Make sure the configuration is as follows + (note that the versions may differ for you): + ----------------- + BUILD_CLIENT [X] + BUILD_SERVER [ ] + CMAKE_BUILD_TYPE Release + CMAKE_INSTALL_PREFIX DIR/minetest-install + IRRLICHT_SOURCE_DIR DIR/irrlicht-1.7.1 + RUN_IN_PLACE [X] + WARN_ALL [ ] + ZLIB_DLL DIR/zlib125dll/dll32/zlibwapi.dll + ZLIB_INCLUDE_DIR DIR/zlib-1.2.5 + ZLIB_LIBRARIES DIR/zlib125dll/dll32/zlibwapi.lib + ----------------- + - Hit "Configure" + - Hit "Generate" + If using MSVC: + - Open the generated minetest.sln + - The project defaults to the "Debug" configuration. Make very sure to + select "Release", unless you want to debug some stuff (it's slower) + - Build the ALL_BUILD project + - Build the INSTALL project + - You should now have a working game with the executable in + DIR/minetest-install/bin/minetest.exe + - Additionally you may create a zip package by building the PACKAGE + project. + If using MinGW: + - Using the command line, browse to the build directory and run 'make' + (or mingw32-make or whatever it happens to be) + - You should now have a working game with the executable in + DIR/minetest/bin/minetest.exe + +License of Minetest-c55 +----------------------- + +Minetest-c55 +Copyright (C) 2010-2011 celeron55, Perttu Ahola + +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. + +Irrlicht +--------------- + +This program uses the Irrlicht Engine. http://irrlicht.sourceforge.net/ + + The Irrlicht Engine License + +Copyright © 2002-2005 Nikolaus Gebhardt + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute +it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you use + this software in a product, an acknowledgment in the product + documentation would be appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + 3. This notice may not be removed or altered from any source + distribution. + + +JThread +--------------- + +This program uses the JThread library. License for JThread follows: + +Copyright (c) 2000-2006 Jori Liesenborgs (jori.liesenborgs@gmail.com) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. + + diff --git a/makepackage_binary.sh b/makepackage_binary.sh new file mode 100755 index 000000000..f00ec608c --- /dev/null +++ b/makepackage_binary.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +PACKAGEDIR=../minetest-packages +PACKAGENAME=minetest-c55-binary-`date +%y%m%d%H%M%S` +PACKAGEPATH=$PACKAGEDIR/$PACKAGENAME + +mkdir -p $PACKAGEPATH +mkdir -p $PACKAGEPATH/bin +mkdir -p $PACKAGEPATH/data +mkdir -p $PACKAGEPATH/doc + +cp minetest.conf.example $PACKAGEPATH/ + +cp bin/minetest.exe $PACKAGEPATH/bin/ +cp bin/Irrlicht.dll $PACKAGEPATH/bin/ +cp bin/zlibwapi.dll $PACKAGEPATH/bin/ +#cp bin/test $PACKAGEPATH/bin/ +#cp bin/fasttest $PACKAGEPATH/bin/ +#cp bin/server $PACKAGEPATH/bin/ +#cp ../irrlicht/irrlicht-1.7.1/lib/Linux/libIrrlicht.a $PACKAGEPATH/bin/ +#cp ../jthread/jthread-1.2.1/src/.libs/libjthread-1.2.1.so $PACKAGEPATH/bin/ + +cp -r data/fontlucida.png $PACKAGEPATH/data/ +cp -r data/player.png $PACKAGEPATH/data/ +cp -r data/player_back.png $PACKAGEPATH/data/ +cp -r data/stone.png $PACKAGEPATH/data/ +cp -r data/grass.png $PACKAGEPATH/data/ +cp -r data/grass_footsteps.png $PACKAGEPATH/data/ +cp -r data/water.png $PACKAGEPATH/data/ +cp -r data/tree.png $PACKAGEPATH/data/ +cp -r data/leaves.png $PACKAGEPATH/data/ +cp -r data/mese.png $PACKAGEPATH/data/ +cp -r data/cloud.png $PACKAGEPATH/data/ +cp -r data/sign.png $PACKAGEPATH/data/ +cp -r data/sign_back.png $PACKAGEPATH/data/ +cp -r data/rat.png $PACKAGEPATH/data/ +cp -r data/mud.png $PACKAGEPATH/data/ +cp -r data/torch.png $PACKAGEPATH/data/ +cp -r data/torch_on_floor.png $PACKAGEPATH/data/ +cp -r data/torch_on_ceiling.png $PACKAGEPATH/data/ +cp -r data/tree_top.png $PACKAGEPATH/data/ +cp -r data/coalstone.png $PACKAGEPATH/data/ +cp -r data/crack.png $PACKAGEPATH/data/ +cp -r data/wood.png $PACKAGEPATH/data/ +cp -r data/stick.png $PACKAGEPATH/data/ +cp -r data/tool_wpick.png $PACKAGEPATH/data/ +cp -r data/tool_stpick.png $PACKAGEPATH/data/ +cp -r data/tool_mesepick.png $PACKAGEPATH/data/ +cp -r data/grass_side.png $PACKAGEPATH/data/ +cp -r data/lump_of_coal.png $PACKAGEPATH/data/ +cp -r data/lump_of_iron.png $PACKAGEPATH/data/ +cp -r data/mineral_coal.png $PACKAGEPATH/data/ +cp -r data/mineral_iron.png $PACKAGEPATH/data/ +cp -r data/sand.png $PACKAGEPATH/data/ + +#cp -r data/pauseMenu.gui $PACKAGEPATH/data/ + +cp -r doc/README.txt $PACKAGEPATH/doc/README.txt + +cd $PACKAGEDIR +rm $PACKAGENAME.zip +zip -r $PACKAGENAME.zip $PACKAGENAME + diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp new file mode 100644 index 000000000..3e594aeca --- /dev/null +++ b/src/guiKeyChangeMenu.cpp @@ -0,0 +1,598 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + 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. + */ + +#include "guiKeyChangeMenu.h" +#include "debug.h" +#include "serialization.h" +#include "keycode.h" +#include "main.h" +#include + +GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env, + gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) : + GUIModalMenu(env, parent, id, menumgr) +{ + activeKey = -1; + init_keys(); +} + +GUIKeyChangeMenu::~GUIKeyChangeMenu() +{ + removeChildren(); +} + +void GUIKeyChangeMenu::removeChildren() +{ + const core::list &children = getChildren(); + core::list children_copy; + for (core::list::ConstIterator i = children.begin(); i + != children.end(); i++) + { + children_copy.push_back(*i); + } + for (core::list::Iterator i = children_copy.begin(); i + != children_copy.end(); i++) + { + (*i)->remove(); + } +} + +void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) +{ + /* + Remove stuff + */ + removeChildren(); + + /* + Calculate new sizes and positions + */ + + v2s32 size(620, 430); + + core::rect < s32 > rect(screensize.X / 2 - size.X / 2, + screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, + screensize.Y / 2 + size.Y / 2); + + DesiredRect = rect; + recalculateAbsolutePosition(false); + + v2s32 topleft(0, 0); + + { + core::rect < s32 > rect(0, 0, 125, 20); + rect += topleft + v2s32(25, 3); + const wchar_t *text = L"KEYBINDINGS"; + //gui::IGUIStaticText *t = + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + v2s32 offset(25, 40); + // buttons + + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Forward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->forward = Environment->addButton(rect, this, + GUI_ID_KEY_FORWARD_BUTTON, + narrow_to_wide(KeyNames[key_forward]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Backward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->backward = Environment->addButton(rect, this, + GUI_ID_KEY_BACKWARD_BUTTON, + narrow_to_wide(KeyNames[key_backward]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Left"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, + narrow_to_wide(KeyNames[key_left]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Right"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->right = Environment->addButton(rect, this, + GUI_ID_KEY_RIGHT_BUTTON, + narrow_to_wide(KeyNames[key_right]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Use"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, + narrow_to_wide(KeyNames[key_use]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Sneak"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->sneak = Environment->addButton(rect, this, + GUI_ID_KEY_SNEAK_BUTTON, + narrow_to_wide(KeyNames[key_sneak]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Jump"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, + narrow_to_wide(KeyNames[key_jump]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Inventory"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->inventory = Environment->addButton(rect, this, + GUI_ID_KEY_INVENTORY_BUTTON, + narrow_to_wide(KeyNames[key_inventory]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Chat"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, + narrow_to_wide(KeyNames[key_chat]).c_str()); + } + + //next col + offset = v2s32(250, 40); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fly"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, + narrow_to_wide(KeyNames[key_fly]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fast"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, + narrow_to_wide(KeyNames[key_fast]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Range select"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->range = Environment->addButton(rect, this, + GUI_ID_KEY_RANGE_BUTTON, + narrow_to_wide(KeyNames[key_range]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Print stacks"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, + narrow_to_wide(KeyNames[key_dump]).c_str()); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, L"Save"); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, L"Cancel"); + } +} + +void GUIKeyChangeMenu::drawMenu() +{ + gui::IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + video::IVideoDriver* driver = Environment->getVideoDriver(); + + video::SColor bgcolor(140, 0, 0, 0); + + { + core::rect < s32 > rect(0, 0, 620, 620); + rect += AbsoluteRect.UpperLeftCorner; + driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect); + } + + gui::IGUIElement::draw(); +} + +bool GUIKeyChangeMenu::acceptInput() +{ + g_settings.set("keymap_forward", keycode_to_keyname(key_forward)); + g_settings.set("keymap_backward", keycode_to_keyname(key_backward)); + g_settings.set("keymap_left", keycode_to_keyname(key_left)); + g_settings.set("keymap_right", keycode_to_keyname(key_right)); + g_settings.set("keymap_jump", keycode_to_keyname(key_jump)); + g_settings.set("keymap_sneak", keycode_to_keyname(key_sneak)); + g_settings.set("keymap_inventory", keycode_to_keyname(key_inventory)); + g_settings.set("keymap_chat", keycode_to_keyname(key_chat)); + g_settings.set("keymap_rangeselect", keycode_to_keyname(key_range)); + g_settings.set("keymap_freemove", keycode_to_keyname(key_fly)); + g_settings.set("keymap_fastmove", keycode_to_keyname(key_fast)); + g_settings.set("keymap_special1", keycode_to_keyname(key_use)); + g_settings.set("keymap_print_debug_stacks", keycode_to_keyname(key_dump)); + //clearKeyCache(); Y U NO SCOPE?! + return true; +} +void GUIKeyChangeMenu::init_keys() +{ + key_forward = getKeySetting("keymap_forward"); + key_backward = getKeySetting("keymap_backward"); + key_left = getKeySetting("keymap_left"); + key_right = getKeySetting("keymap_right"); + key_jump = getKeySetting("keymap_jump"); + key_sneak = getKeySetting("keymap_sneak"); + key_inventory = getKeySetting("keymap_inventory"); + key_chat = getKeySetting("keymap_chat"); + key_range = getKeySetting("keymap_rangeselect"); + key_fly = getKeySetting("keymap_freemove"); + key_fast = getKeySetting("keymap_fastmove"); + key_use = getKeySetting("keymap_special1"); + key_dump = getKeySetting("keymap_print_debug_stacks"); +} + +bool GUIKeyChangeMenu::resetMenu() +{ + if (activeKey >= 0) + { + switch (activeKey) + { + case GUI_ID_KEY_FORWARD_BUTTON: + this->forward->setText( + narrow_to_wide(KeyNames[key_forward]).c_str()); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + this->backward->setText( + narrow_to_wide(KeyNames[key_backward]).c_str()); + break; + case GUI_ID_KEY_LEFT_BUTTON: + this->left->setText(narrow_to_wide(KeyNames[key_left]).c_str()); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + this->right->setText(narrow_to_wide(KeyNames[key_right]).c_str()); + break; + case GUI_ID_KEY_JUMP_BUTTON: + this->jump->setText(narrow_to_wide(KeyNames[key_jump]).c_str()); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + this->sneak->setText(narrow_to_wide(KeyNames[key_sneak]).c_str()); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + this->inventory->setText( + narrow_to_wide(KeyNames[key_inventory]).c_str()); + break; + case GUI_ID_KEY_CHAT_BUTTON: + this->chat->setText(narrow_to_wide(KeyNames[key_chat]).c_str()); + break; + case GUI_ID_KEY_RANGE_BUTTON: + this->range->setText(narrow_to_wide(KeyNames[key_range]).c_str()); + break; + case GUI_ID_KEY_FLY_BUTTON: + this->fly->setText(narrow_to_wide(KeyNames[key_fly]).c_str()); + break; + case GUI_ID_KEY_FAST_BUTTON: + this->fast->setText(narrow_to_wide(KeyNames[key_fast]).c_str()); + break; + case GUI_ID_KEY_USE_BUTTON: + this->use->setText(narrow_to_wide(KeyNames[key_use]).c_str()); + break; + case GUI_ID_KEY_DUMP_BUTTON: + this->dump->setText(narrow_to_wide(KeyNames[key_dump]).c_str()); + break; + } + activeKey = -1; + return false; + } + return true; +} +bool GUIKeyChangeMenu::OnEvent(const SEvent& event) +{ + if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 + && event.KeyInput.PressedDown) + { + if (activeKey == GUI_ID_KEY_FORWARD_BUTTON) + { + this->forward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_forward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON) + { + this->backward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_backward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_LEFT_BUTTON) + { + this->left->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_left = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON) + { + this->right->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_right = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_JUMP_BUTTON) + { + this->jump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_jump = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON) + { + this->sneak->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_sneak = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON) + { + this->inventory->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_inventory = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_CHAT_BUTTON) + { + this->chat->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_chat = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RANGE_BUTTON) + { + this->range->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_range = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FLY_BUTTON) + { + this->fly->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fly = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FAST_BUTTON) + { + this->fast->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fast = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_USE_BUTTON) + { + this->use->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_use = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_DUMP_BUTTON) + { + this->dump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_dump = event.KeyInput.Key; + } + + activeKey = -1; + return true; + } + if (event.EventType == EET_GUI_EVENT) + { + if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST + && isVisible()) + { + if (!canTakeFocus(event.GUIEvent.Element)) + { + dstream << "GUIMainMenu: Not allowing focus change." + << std::endl; + // Returning true disables focus change + return true; + } + } + if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) + { + switch (event.GUIEvent.Caller->getID()) + { + case GUI_ID_BACK_BUTTON: //back + acceptInput(); + quitMenu(); + return true; + case GUI_ID_ABORT_BUTTON: //abort + quitMenu(); + return true; + case GUI_ID_KEY_FORWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->forward->setText(L"press Key"); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->backward->setText(L"press Key"); + break; + case GUI_ID_KEY_LEFT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->left->setText(L"press Key"); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->right->setText(L"press Key"); + break; + case GUI_ID_KEY_USE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->use->setText(L"press Key"); + break; + case GUI_ID_KEY_FLY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fly->setText(L"press Key"); + break; + case GUI_ID_KEY_FAST_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fast->setText(L"press Key"); + break; + case GUI_ID_KEY_JUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->jump->setText(L"press Key"); + break; + case GUI_ID_KEY_CHAT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->chat->setText(L"press Key"); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->sneak->setText(L"press Key"); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->inventory->setText(L"press Key"); + break; + case GUI_ID_KEY_DUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->dump->setText(L"press Key"); + break; + case GUI_ID_KEY_RANGE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->range->setText(L"press Key"); + break; + } + //Buttons + + } + } + return Parent ? Parent->OnEvent(event) : false; +} + diff --git a/src/guiKeyChangeMenu.h b/src/guiKeyChangeMenu.h new file mode 100644 index 000000000..389ce7aee --- /dev/null +++ b/src/guiKeyChangeMenu.h @@ -0,0 +1,133 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + 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 GUIKEYCHANGEMENU_HEADER +#define GUIKEYCHANGEMENU_HEADER + +#include "common_irrlicht.h" +#include "utility.h" +#include "modalMenu.h" +#include "client.h" +#include + +static const char *KeyNames[] = + { "-", "Left Button", "Right Button", "Cancel", "Middle Button", "X Button 1", + "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-", + "-", "Shift", "Control", "Menu", "Pause", "Capital", "Kana", "-", + "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert", + "Accept", "Mode Change", "Space", "Priot", "Next", "End", "Home", + "Left", "Up", "Right", "Down", "Select", "Print", "Execute", + "Snapshot", "Insert", "Delete", "Help", "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C", + "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", + "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Left Windows", + "Right Windows", "Apps", "-", "Sleep", "Numpad 0", "Numpad 1", + "Numpad 2", "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", + "Numpad 8", "Numpad 9", "Numpad *", "Numpad +", "Numpad /", "Numpad -", + "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", + "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", + "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-", + "-", "-", "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "Left Shift", "Right Shight", + "Left Control", "Right Control", "Left Menu", "Right Menu", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel", + "ExSel", "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" }; + enum + { + GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR, + //buttons + GUI_ID_KEY_FORWARD_BUTTON, + GUI_ID_KEY_BACKWARD_BUTTON, + GUI_ID_KEY_LEFT_BUTTON, + GUI_ID_KEY_RIGHT_BUTTON, + GUI_ID_KEY_USE_BUTTON, + GUI_ID_KEY_FLY_BUTTON, + GUI_ID_KEY_FAST_BUTTON, + GUI_ID_KEY_JUMP_BUTTON, + GUI_ID_KEY_CHAT_BUTTON, + GUI_ID_KEY_SNEAK_BUTTON, + GUI_ID_KEY_INVENTORY_BUTTON, + GUI_ID_KEY_DUMP_BUTTON, + GUI_ID_KEY_RANGE_BUTTON + }; + +class GUIKeyChangeMenu: public GUIModalMenu +{ +public: + GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, + s32 id, IMenuManager *menumgr); + ~GUIKeyChangeMenu(); + + void removeChildren(); + /* + Remove and re-add (or reposition) stuff + */ + void regenerateGui(v2u32 screensize); + + void drawMenu(); + + bool acceptInput(); + + bool OnEvent(const SEvent& event); + +private: + + void init_keys(); + + bool resetMenu(); + + gui::IGUIButton *forward; + gui::IGUIButton *backward; + gui::IGUIButton *left; + gui::IGUIButton *right; + gui::IGUIButton *use; + gui::IGUIButton *sneak; + gui::IGUIButton *jump; + gui::IGUIButton *inventory; + gui::IGUIButton *fly; + gui::IGUIButton *fast; + gui::IGUIButton *range; + gui::IGUIButton *dump; + gui::IGUIButton *chat; + + u32 activeKey; + u32 key_forward; + u32 key_backward; + u32 key_left; + u32 key_right; + u32 key_use; + u32 key_sneak; + u32 key_jump; + u32 key_inventory; + u32 key_fly; + u32 key_fast; + u32 key_range; + u32 key_chat; + u32 key_dump; +}; + +#endif + -- cgit v1.2.3