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 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