Initial files

nephele-craftmethods
Perttu Ahola 12 years ago
commit 4e249fb3fb
  1. 72
      Makefile
  2. BIN
      bin/Irrlicht.dll
  3. BIN
      data/fontlucida.png
  4. BIN
      data/grass.png
  5. BIN
      data/grass2.png
  6. BIN
      data/grass_footsteps.png
  7. BIN
      data/leaves.png
  8. BIN
      data/light.png
  9. BIN
      data/mese.png
  10. BIN
      data/player.png
  11. BIN
      data/player_back.png
  12. BIN
      data/rat.png
  13. BIN
      data/sign.png
  14. BIN
      data/sign_back.png
  15. BIN
      data/stone.png
  16. BIN
      data/stone_with_arrow.png
  17. BIN
      data/tf.jpg
  18. BIN
      data/tree.png
  19. BIN
      data/water.png
  20. BIN
      data/water_old.png
  21. 115
      doc/README.txt
  22. 41
      makepackage_binary.sh
  23. 44
      minetest.conf.example
  24. 20
      minetest.sln
  25. 358
      minetest.vcproj
  26. 1639
      src/client.cpp
  27. 272
      src/client.h
  28. 174
      src/clientserver.h
  29. 17
      src/common_irrlicht.h
  30. 1321
      src/connection.cpp
  31. 474
      src/connection.h
  32. 72
      src/constants.h
  33. 189
      src/debug.cpp
  34. 176
      src/debug.h
  35. 206
      src/environment.cpp
  36. 50
      src/environment.h
  37. 116
      src/exceptions.h
  38. 205
      src/filesys.cpp
  39. 27
      src/filesys.h
  40. 872
      src/heightmap.cpp
  41. 556
      src/heightmap.h
  42. 320
      src/inventory.cpp
  43. 195
      src/inventory.h
  44. 85
      src/light.cpp
  45. 54
      src/light.h
  46. 144
      src/loadstatus.h
  47. 2339
      src/main.cpp
  48. 50
      src/main.h
  49. 2854
      src/map.cpp
  50. 430
      src/map.h
  51. 698
      src/mapblock.cpp
  52. 404
      src/mapblock.h
  53. 641
      src/mapblockobject.cpp
  54. 892
      src/mapblockobject.h
  55. 280
      src/mapnode.h
  56. 652
      src/mapsector.cpp
  57. 318
      src/mapsector.h
  58. 358
      src/player.cpp
  59. 210
      src/player.h
  60. 15
      src/porting.h
  61. 77
      src/serialization.cpp
  62. 49
      src/serialization.h
  63. 2115
      src/server.cpp
  64. 388
      src/server.h
  65. 311
      src/socket.cpp
  66. 98
      src/socket.h
  67. 96
      src/strfnd.h
  68. 920
      src/test.cpp
  69. 7
      src/test.h
  70. 41
      src/utility.cpp
  71. 607
      src/utility.h

@ -0,0 +1,72 @@
# 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
TARGET = test
SOURCE_FILES = 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
SOURCES = $(addprefix src/, $(SOURCE_FILES))
OBJECTS = $(SOURCES:.cpp=.o)
FASTTARGET = fasttest
IRRLICHTPATH = ../irrlicht/irrlicht-1.7.1
JTHREADPATH = ../jthread/jthread-1.2.1
CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src
#CXXFLAGS = -O2 -ffast-math -Wall -fomit-frame-pointer -pipe
CXXFLAGS = -O2 -ffast-math -Wall -g
#CXXFLAGS = -O1 -ffast-math -Wall -g
#CXXFLAGS = -Wall -g -O0
#CXXFLAGS = -O3 -ffast-math -Wall
#CXXFLAGS = -O3 -ffast-math -Wall -g
#CXXFLAGS = -O2 -ffast-math -Wall -g
#FASTCXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=pentium3
FASTCXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686
#Default target
all: all_linux
ifeq ($(HOSTTYPE), x86_64)
LIBSELECT=64
endif
# Target specific settings
all_linux fast_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread
all_linux fast_linux clean_linux: SYSTEM=Linux
all_win32: LDFLAGS = -L$(IRRLICHTPATH)/lib/Win32-gcc -L$(JTHREADPATH)/Debug -lIrrlicht -lopengl32 -lm -ljthread
all_win32 clean_win32: SYSTEM=Win32-gcc
all_win32 clean_win32: SUF=.exe
# Name of the binary - only valid for targets which set SYSTEM
DESTPATH = bin/$(TARGET)$(SUF)
FASTDESTPATH = bin/$(FASTTARGET)$(SUF)
# Build commands
all_linux all_win32: $(DESTPATH)
fast_linux: $(FASTDESTPATH)
$(FASTDESTPATH): $(SOURCES)
$(CXX) -o $(FASTDESTPATH) $(SOURCES) $(CPPFLAGS) $(FASTCXXFLAGS) $(LDFLAGS) -DUNITTEST_DISABLE
$(DESTPATH): $(OBJECTS)
$(CXX) -o $@ $(OBJECTS) $(LDFLAGS)
.cpp.o:
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
clean: clean_linux clean_win32 clean_fast_linux
clean_linux clean_win32:
@$(RM) $(OBJECTS) $(DESTPATH)
clean_fast_linux:
@$(RM) $(FASTDESTPATH)
.PHONY: all all_win32 clean clean_linux clean_win32

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 835 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 B

@ -0,0 +1,115 @@
Minetest-c55
---------------
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.
Copyright (c) 2010 Perttu Ahola <celeron55@gmail.com>
An InfiniMiner/Minecraft inspired game.
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.
Server information:
- I usually have a server running at celer.oni.biz on port 30000
- If you want to run a server, I can list you on my website and in here.
Features, as of now:
- Almost Infinite Map (limited to +-31000 blocks in any direction at the moment)
- Minecraft alpha has a height restriction of 128 blocks
- Map Generator capable of taking advantage of the infinite map
Controls:
- WASD+mouse: Move
- Mouse L: Dig
- Mouse R: Place block
- Mouse Wheel: Change item
- F: Change item
- R: Toggle full view range
Configuration file:
- Can be passed as parameter to the executable.
- If not given as parameter, these are checked, in order:
../minetest.conf
../../minetest.conf
Running on Windows:
- The working directory should be ./bin
Running on GNU/Linux:
- fasttest is a linux binary compiled on a recent Arch Linux installation.
It should run on most recent GNU/Linux distributions.
- Browse to the game ./bin directory and type:
LD_LIBRARY_PATH=. ./fasttest
- If it doesn't work, use wine. I aim at 100% compatibility with wine.
COPYING (License of Minetest-c55):
- This version of the game is FREEWARE.
- You can play this version of the game without charge.
- You can redistribute this version of the game without charge, only with
these same license terms you are reading now, and provided that you give
proper information about who has made the game (me) and where to get the
original copy and new versions (http://celer.oni.biz/~celeron55/minetest).
- You are not allowed to sell this game for a price.
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.

@ -0,0 +1,41 @@
#!/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/test $PACKAGEPATH/bin/
cp bin/fasttest $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/light.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 doc/README.txt $PACKAGEPATH/doc/README.txt
cd $PACKAGEDIR
rm $PACKAGENAME.zip
zip -r $PACKAGENAME.zip $PACKAGENAME

@ -0,0 +1,44 @@
# This file is read by default from:
# ../minetest.conf
# ../../minetest.conf
# Any other path can be chosen by passing the path as a parameter
# to the program, eg. "minetest.exe ../minetest.conf.example"
dedicated_server =
# Client side stuff
wanted_fps = 30
fps_max = 60
viewing_range_nodes_max = 300
viewing_range_nodes_min = 20
screenW =
screenH =
host_game =
port = 30000
address = celer.oni.biz
name =
random_input = false
client_delete_unused_sectors_timeout = 1200
# Server side stuff
# - The possible generators are:
# (Indeed you can do all of them with only "power" 8))
# H=value:
# constant <value>
# H=slope.dot(pos):
# linear <height> <slope.X> <slope.Y>
# H=slope.dot(pos^power):
# power <height> <slope.X> <slope.Y> <power>
mapgen_heightmap_blocksize = 64
mapgen_height_randmax = constant 70.0
mapgen_height_randfactor = constant 0.6
mapgen_height_base = linear 0 80 0
mapgen_plants_amount = constant 1.0
creative_mode = false

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

@ -0,0 +1,358 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="minetest"
ProjectGUID="{AE3BF173-1D74-4294-AAB8-5A0ACDE9990D}"
RootNamespace="minetest"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="true"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;&quot;..\jthread\jthread-1.2.1\src&quot;;&quot;..\irrlicht\irrlicht-1.7.1\include&quot;"
PreprocessorDefinitions="WIN32"
EnableEnhancedInstructionSet="1"
FloatingPointModel="2"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib&quot;;&quot;..\jthread\jthread-1.2.1\Release&quot;;&quot;..\irrlicht\irrlicht-1.7.1\lib\Win32-visualstudio&quot;"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)\bin"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
UseOfMFC="0"
WholeProgramOptimization="3"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="&quot;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include&quot;;&quot;..\jthread\jthread-1.2.1\src&quot;;&quot;..\irrlicht\irrlicht-1.7.1\include&quot;"
PreprocessorDefinitions="WIN32;_HAS_ITERATOR_DEBUGGING=0,UNITTEST_DISABLE"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="1"
FloatingPointModel="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories="&quot;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib&quot;;&quot;..\jthread\jthread-1.2.1\Release&quot;;&quot;..\irrlicht\irrlicht-1.7.1\lib\Win32-visualstudio&quot;"
IgnoreDefaultLibraryNames="libcmtd.lib"
LinkTimeCodeGeneration="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\client.cpp"
>
</File>
<File
RelativePath=".\src\connection.cpp"
>
</File>
<File
RelativePath=".\src\debug.cpp"
>
</File>
<File
RelativePath=".\src\environment.cpp"
>
</File>
<File
RelativePath=".\src\filesys.cpp"
>
</File>
<File
RelativePath=".\src\heightmap.cpp"
>
</File>
<File
RelativePath=".\src\inventory.cpp"
>
</File>
<File
RelativePath=".\src\light.cpp"
>
</File>
<File
RelativePath=".\src\main.cpp"
>
</File>
<File
RelativePath=".\src\map.cpp"
>
</File>
<File
RelativePath=".\src\mapblock.cpp"
>
</File>
<File
RelativePath=".\src\mapblockobject.cpp"
>
</File>
<File
RelativePath=".\src\mapsector.cpp"
>
</File>
<File
RelativePath=".\src\player.cpp"
>
</File>
<File
RelativePath=".\src\serialization.cpp"
>
</File>
<File
RelativePath=".\src\server.cpp"
>
</File>
<File
RelativePath=".\src\socket.cpp"
>
</File>
<File
RelativePath=".\src\test.cpp"
>
</File>
<File
RelativePath=".\src\utility.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\client.h"
>
</File>
<File
RelativePath=".\src\clientserver.h"
>
</File>
<File
RelativePath=".\src\common_irrlicht.h"
>
</File>
<File
RelativePath=".\src\connection.h"
>
</File>
<File
RelativePath=".\src\constants.h"
>
</File>
<File
RelativePath=".\src\debug.h"
>
</File>
<File
RelativePath=".\src\environment.h"
>
</File>
<File
RelativePath=".\src\exceptions.h"
>
</File>
<File
RelativePath=".\src\heightmap.h"
>
</File>
<File
RelativePath=".\src\inventory.h"
>
</File>
<File
RelativePath=".\src\light.h"
>
</File>
<File
RelativePath=".\src\loadstatus.h"
>
</File>
<File
RelativePath=".\src\main.h"
>
</File>
<File
RelativePath=".\src\map.h"
>
</File>
<File
RelativePath=".\src\mapblock.h"
>
</File>
<File
RelativePath=".\src\mapnode.h"
>
</File>
<File
RelativePath=".\src\mapsector.h"
>
</File>
<File
RelativePath=".\src\player.h"
>
</File>
<File
RelativePath=".\src\serialization.h"
>
</File>
<File
RelativePath=".\src\server.h"
>
</File>
<File
RelativePath=".\src\socket.h"
>
</File>
<File
RelativePath=".\src\test.h"
>
</File>
<File
RelativePath=".\src\utility.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,272 @@
#ifndef CLIENT_HEADER
#define CLIENT_HEADER
#include "connection.h"
#include "environment.h"
#include "common_irrlicht.h"
#include "jmutex.h"
#include <ostream>
class ClientNotReadyException : public BaseException
{
public:
ClientNotReadyException(const char *s):
BaseException(s)
{}
};
class Client;
class ClientUpdateThread : public JThread
{
bool run;
JMutex run_mutex;
Client *m_client;
public:
ClientUpdateThread(Client *client) : JThread(), run(true), m_client(client)
{
run_mutex.Init();
}
void * Thread();
bool getRun()
{
run_mutex.Lock();
bool run_cached = run;
run_mutex.Unlock();
return run_cached;
}
void setRun(bool a_run)
{
run_mutex.Lock();
run = a_run;
run_mutex.Unlock();
}
};
struct IncomingPacket
{
IncomingPacket()
{
m_data = NULL;
m_datalen = 0;
m_refcount = NULL;
}
IncomingPacket(const IncomingPacket &a)
{
m_data = a.m_data;
m_datalen = a.m_datalen;
m_refcount = a.m_refcount;
if(m_refcount != NULL)
(*m_refcount)++;
}
IncomingPacket(u8 *data, u32 datalen)
{
m_data = new u8[datalen];
memcpy(m_data, data, datalen);
m_datalen = datalen;
m_refcount = new s32(1);
}
~IncomingPacket()
{
if(m_refcount != NULL){
assert(*m_refcount > 0);
(*m_refcount)--;
if(*m_refcount == 0){
if(m_data != NULL)
delete[] m_data;
}
}
}
/*IncomingPacket & operator=(IncomingPacket a)
{
m_data = a.m_data;
m_datalen = a.m_datalen;
m_refcount = a.m_refcount;
(*m_refcount)++;
return *this;
}*/
u8 *m_data;
u32 m_datalen;
s32 *m_refcount;
};
class LazyMeshUpdater
{
public:
LazyMeshUpdater(Environment *env)
{
m_env = env;
}
~LazyMeshUpdater()
{
/*
TODO: This could be optimized. It will currently
double-update some blocks.
*/
for(core::map<v3s16, bool>::Iterator
i = m_blocks.getIterator();
i.atEnd() == false; i++)
{
v3s16 p = i.getNode()->getKey();
m_env->getMap().updateMeshes(p);
}
m_blocks.clear();
}
void add(v3s16 p)
{
m_blocks.insert(p, true);
}
private:
Environment *m_env;
core::map<v3s16, bool> m_blocks;
};
class Client : public con::PeerHandler
{
public:
/*
NOTE: Every public method should be thread-safe
*/
Client(IrrlichtDevice *device, video::SMaterial *materials,
float delete_unused_sectors_timeout,
const char *playername);
~Client();
/*
The name of the local player should already be set when
calling this, as it is sent in the initialization.
*/
void connect(Address address);
/*
returns true when
m_con.Connected() == true
AND m_server_ser_ver != SER_FMT_VER_INVALID
throws con::PeerNotFoundException if connection has been deleted,
eg. timed out.
*/
bool connectedAndInitialized();
/*
Stuff that references the environment is valid only as
long as this is not called. (eg. Players)
If this throws a PeerNotFoundException, the connection has
timed out.
*/
void step(float dtime);
// Called from updater thread
// Returns dtime
float asyncStep();
void ProcessData(u8 *data, u32 datasize, u16 sender_peer_id);
// Returns true if something was received
bool AsyncProcessPacket(LazyMeshUpdater &mesh_updater);
bool AsyncProcessData();
void Send(u16 channelnum, SharedBuffer<u8> data, bool reliable);
//TODO: Remove
bool isFetchingBlocks();
// Pops out a packet from the packet queue
IncomingPacket getPacket();
/*void removeNode(v3s16 nodepos);
void addNodeFromInventory(v3s16 nodepos, u16 i);*/
void clickGround(u8 button, v3s16 nodepos_undersurface,
v3s16 nodepos_oversurface, u16 item);
void clickObject(u8 button, v3s16 blockpos, s16 id, u16 item);
void release(u8 button);
void sendSignText(v3s16 blockpos, s16 id, std::string text);
void updateCamera(v3f pos, v3f dir);
// Returns InvalidPositionException if not found
MapNode getNode(v3s16 p);
// Returns InvalidPositionException if not found
//f32 getGroundHeight(v2s16 p);
// Returns InvalidPositionException if not found
bool isNodeUnderground(v3s16 p);
// Note: The players should not be exposed outside
// Return value is valid until client is destroyed
//Player * getLocalPlayer();
// Return value is valid until step()
//core::list<Player*> getPlayers();
v3f getPlayerPosition();
void setPlayerControl(PlayerControl &control);
// Returns true if the inventory of the local player has been
// updated from the server. If it is true, it is set to false.
bool getLocalInventoryUpdated();
// Copies the inventory of the local player to parameter
void getLocalInventory(Inventory &dst);
// TODO: Functions for sending inventory editing commands to
// server
// Gets closest object pointed by the shootline
// Returns NULL if not found
MapBlockObject * getSelectedObject(
f32 max_d,
v3f from_pos_f_on_map,
core::line3d<f32> shootline_on_map
);
// Prints a line or two of info
void printDebugInfo(std::ostream &os);
private:
// Virtual methods from con::PeerHandler
void peerAdded(con::Peer *peer);
void deletingPeer(con::Peer *peer, bool timeout);
void ReceiveAll();
void Receive();
void sendPlayerPos();
// This sends the player's current name etc to the server
void sendPlayerInfo();
ClientUpdateThread m_thread;
// NOTE: If connection and environment are both to be locked,
// environment shall be locked first.
Environment m_env;
JMutex m_env_mutex;
con::Connection m_con;
JMutex m_con_mutex;
/*core::map<v3s16, float> m_fetchblock_history;
JMutex m_fetchblock_mutex;*/
core::list<IncomingPacket> m_incoming_queue;
JMutex m_incoming_queue_mutex;
IrrlichtDevice *m_device;
v3f camera_position;
v3f camera_direction;
// Server serialization version
u8 m_server_ser_ver;
float m_step_dtime;
JMutex m_step_dtime_mutex;
float m_delete_unused_sectors_timeout;
// This is behind m_env_mutex.
bool m_inventory_updated;
core::map<v3s16, bool> m_active_blocks;
};
#endif

@ -0,0 +1,174 @@
#ifndef CLIENTSERVER_HEADER
#define CLIENTSERVER_HEADER
#define PROTOCOL_ID 0x4f457403
enum ToClientCommand
{
TOCLIENT_INIT=0x10,
/*
Server's reply to TOSERVER_INIT.
Sent second after connected.
[0] u16 TOSERVER_INIT
[2] u8 deployed version
[3] v3s16 player's position + v3f(0,BS/2,0) floatToInt'd
*/
TOCLIENT_BLOCKDATA=0x20, //TODO: Multiple blocks
TOCLIENT_ADDNODE,
TOCLIENT_REMOVENODE,
TOCLIENT_PLAYERPOS,
/*
[0] u16 command
// Followed by an arbitary number of these:
// Number is determined from packet length.
[N] u16 peer_id
[N+2] v3s32 position*100
[N+2+12] v3s32 speed*100
[N+2+12+12] s32 pitch*100
[N+2+12+12+4] s32 yaw*100
*/
TOCLIENT_PLAYERINFO,
/*
[0] u16 command
// Followed by an arbitary number of these:
// Number is determined from packet length.
[N] u16 peer_id
[N] char[20] name
*/
TOCLIENT_OPT_BLOCK_NOT_FOUND, // Not used
TOCLIENT_SECTORMETA,
/*
[0] u16 command
[2] u8 sector count
[3...] v2s16 pos + sector metadata
*/
TOCLIENT_INVENTORY,
/*
[0] u16 command
[2] serialized inventory
*/
TOCLIENT_OBJECTDATA,
/*
Sent as unreliable.
u16 command
u16 number of player positions
for each player:
v3s32 position*100
v3s32 speed*100
s32 pitch*100
s32 yaw*100
u16 count of blocks
for each block:
v3s16 blockpos
block objects
*/
};
enum ToServerCommand
{
TOSERVER_INIT=0x10,
/*
Sent first after connected.
[0] u16 TOSERVER_INIT
[2] u8 SER_FMT_VER_HIGHEST
[3] u8[20] player_name
*/
TOSERVER_INIT2,
/*
Sent as an ACK for TOCLIENT_INIT.
After this, the server can send data.
[0] u16 TOSERVER_INIT2
*/
TOSERVER_GETBLOCK=0x20, // Not used
TOSERVER_ADDNODE, // Not used
TOSERVER_REMOVENODE, // deprecated
TOSERVER_PLAYERPOS,
/*
[0] u16 command
[2] v3s32 position*100
[2+12] v3s32 speed*100
[2+12+12] s32 pitch*100
[2+12+12+4] s32 yaw*100
*/
TOSERVER_GOTBLOCKS,
/*
[0] u16 command
[2] u8 count
[3] v3s16 pos_0
[3+6] v3s16 pos_1
...
*/
TOSERVER_DELETEDBLOCKS,
/*
[0] u16 command
[2] u8 count
[3] v3s16 pos_0
[3+6] v3s16 pos_1
...
*/
TOSERVER_ADDNODE_FROM_INVENTORY, // deprecated
/*
[0] u16 command
[2] v3s16 pos
[8] u16 i
*/
TOSERVER_CLICK_OBJECT,
/*
length: 13
[0] u16 command
[2] u8 button (0=left, 1=right)
[3] v3s16 blockpos
[9] s16 id
[11] u16 item
*/
TOSERVER_CLICK_GROUND,
/*
length: 17
[0] u16 command
[2] u8 button (0=left, 1=right)
[3] v3s16 nodepos_undersurface
[9] v3s16 nodepos_abovesurface
[15] u16 item
*/
TOSERVER_RELEASE,
/*
length: 3
[0] u16 command
[2] u8 button
*/
TOSERVER_SIGNTEXT,
/*
u16 command
v3s16 blockpos
s16 id
u16 textlen
textdata
*/
};
// Flags for TOSERVER_GETBLOCK
#define TOSERVER_GETBLOCK_FLAG_OPTIONAL (1<<0)
#endif

@ -0,0 +1,17 @@
#ifndef COMMON_IRRLICHT_HEADER
#define COMMON_IRRLICHT_HEADER
#include <irrlicht.h>
using namespace irr;
typedef core::vector3df v3f;
typedef core::vector3d<s16> v3s16;
typedef core::vector3d<s32> v3s32;
typedef core::vector2d<f32> v2f;
typedef core::vector2d<s16> v2s16;
typedef core::vector2d<s32> v2s32;
typedef core::vector2d<u32> v2u32;
typedef core::vector2d<f32> v2f32;
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,474 @@
#ifndef CONNECTION_HEADER
#define CONNECTION_HEADER
#include <iostream>
#include <fstream>
#include "debug.h"
#include "common_irrlicht.h"
#include "socket.h"
#include "utility.h"
#include "exceptions.h"
#include "constants.h"
namespace con
{
/*
Exceptions
*/
class NotFoundException : public BaseException
{
public:
NotFoundException(const char *s):
BaseException(s)
{}
};
class PeerNotFoundException : public BaseException
{
public:
PeerNotFoundException(const char *s):
BaseException(s)
{}
};
class ConnectionException : public BaseException
{
public:
ConnectionException(const char *s):
BaseException(s)
{}
};
/*class ThrottlingException : public BaseException
{
public:
ThrottlingException(const char *s):
BaseException(s)
{}
};*/
class InvalidIncomingDataException : public BaseException
{
public:
InvalidIncomingDataException(const char *s):
BaseException(s)
{}
};
class InvalidOutgoingDataException : public BaseException
{
public:
InvalidOutgoingDataException(const char *s):
BaseException(s)
{}
};
class NoIncomingDataException : public BaseException
{
public:
NoIncomingDataException(const char *s):
BaseException(s)
{}
};
class ProcessedSilentlyException : public BaseException
{
public:
ProcessedSilentlyException(const char *s):
BaseException(s)
{}
};
class GotSplitPacketException
{
SharedBuffer<u8> m_data;
public:
GotSplitPacketException(SharedBuffer<u8> data):
m_data(data)
{}
SharedBuffer<u8> getData()
{
return m_data;
}
};
inline u16 readPeerId(u8 *packetdata)
{
return readU16(&packetdata[4]);
}
inline u8 readChannel(u8 *packetdata)
{
return readU8(&packetdata[6]);
}
#define SEQNUM_MAX 65535
inline bool seqnum_higher(u16 higher, u16 lower)
{
if(lower > higher && lower - higher > SEQNUM_MAX/2){
return true;
}
return (higher > lower);
}
struct BufferedPacket
{
BufferedPacket(u8 *a_data, u32 a_size):
data(a_data, a_size), time(0.0), totaltime(0.0)
{}
BufferedPacket(u32 a_size):
data(a_size), time(0.0), totaltime(0.0)
{}
SharedBuffer<u8> data; // Data of the packet, including headers
float time; // Seconds from buffering the packet or re-sending
float totaltime; // Seconds from buffering the packet
Address address; // Sender or destination
};
// This adds the base headers to the data and makes a packet out of it
BufferedPacket makePacket(Address &address, u8 *data, u32 datasize,
u32 protocol_id, u16 sender_peer_id, u8 channel);
BufferedPacket makePacket(Address &address, SharedBuffer<u8> &data,
u32 protocol_id, u16 sender_peer_id, u8 channel);
// Add the TYPE_ORIGINAL header to the data
SharedBuffer<u8> makeOriginalPacket(
SharedBuffer<u8> data);
// Split data in chunks and add TYPE_SPLIT headers to them
core::list<SharedBuffer<u8> > makeSplitPacket(
SharedBuffer<u8> data,
u32 chunksize_max,
u16 seqnum);
// Depending on size, make a TYPE_ORIGINAL or TYPE_SPLIT packet
// Increments split_seqnum if a split packet is made
core::list<SharedBuffer<u8> > makeAutoSplitPacket(
SharedBuffer<u8> data,
u32 chunksize_max,
u16 &split_seqnum);
// Add the TYPE_RELIABLE header to the data
SharedBuffer<u8> makeReliablePacket(
SharedBuffer<u8> data,
u16 seqnum);
struct IncomingSplitPacket
{
IncomingSplitPacket()
{
time = 0.0;
reliable = false;
}
// Key is chunk number, value is data without headers
core::map<u16, SharedBuffer<u8> > chunks;
u32 chunk_count;
float time; // Seconds from adding
bool reliable; // If true, isn't deleted on timeout
bool allReceived()
{
return (chunks.size() == chunk_count);
}
};
/*
=== NOTES ===
A packet is sent through a channel to a peer with a basic header:
TODO: Should we have a receiver_peer_id also?
Header (7 bytes):
[0] u32 protocol_id
[4] u16 sender_peer_id
[6] u8 channel
sender_peer_id:
Unique to each peer.
value 0 is reserved for making new connections
value 1 is reserved for server
channel:
The lower the number, the higher the priority is.
Only channels 0, 1 and 2 exist.
*/
#define BASE_HEADER_SIZE 7
#define PEER_ID_NEW 0
#define PEER_ID_SERVER 1
#define CHANNEL_COUNT 3
/*
Packet types:
CONTROL: This is a packet used by the protocol.
- When this is processed, nothing is handed to the user.
Header (2 byte):
[0] u8 type
[1] u8 controltype
controltype and data description:
CONTROLTYPE_ACK
[2] u16 seqnum
CONTROLTYPE_SET_PEER_ID
[2] u16 peer_id_new
CONTROLTYPE_PING
- This can be sent in a reliable packet to get a reply
*/
#define TYPE_CONTROL 0
#define CONTROLTYPE_ACK 0
#define CONTROLTYPE_SET_PEER_ID 1
#define CONTROLTYPE_PING 2
/*
ORIGINAL: This is a plain packet with no control and no error
checking at all.
- When this is processed, it is directly handed to the user.
Header (1 byte):
[0] u8 type
*/
#define TYPE_ORIGINAL 1
#define ORIGINAL_HEADER_SIZE 1
/*
SPLIT: These are sequences of packets forming one bigger piece of
data.
- When processed and all the packet_nums 0...packet_count-1 are
present (this should be buffered), the resulting data shall be
directly handed to the user.
- If the data fails to come up in a reasonable time, the buffer shall
be silently discarded.
- These can be sent as-is or atop of a RELIABLE packet stream.
Header (7 bytes):
[0] u8 type
[1] u16 seqnum
[3] u16 chunk_count
[5] u16 chunk_num
*/
#define TYPE_SPLIT 2
/*
RELIABLE: Delivery of all RELIABLE packets shall be forced by ACKs,
and they shall be delivered in the same order as sent. This is done
with a buffer in the receiving and transmitting end.
- When this is processed, the contents of each packet is recursively
processed as packets.
Header (3 bytes):
[0] u8 type
[1] u16 seqnum
*/
#define TYPE_RELIABLE 3
#define RELIABLE_HEADER_SIZE 3
//#define SEQNUM_INITIAL 0x10
#define SEQNUM_INITIAL 65500
/*
A buffer which stores reliable packets and sorts them internally
for fast access to the smallest one.
*/
typedef core::list<BufferedPacket>::Iterator RPBSearchResult;
class ReliablePacketBuffer
{
public:
void print();
bool empty();
u32 size();
RPBSearchResult findPacket(u16 seqnum);
RPBSearchResult notFound();
u16 getFirstSeqnum();
BufferedPacket popFirst();
BufferedPacket popSeqnum(u16 seqnum);
void insert(BufferedPacket &p);
void incrementTimeouts(float dtime);
void resetTimedOuts(float timeout);
bool anyTotaltimeReached(float timeout);
core::list<BufferedPacket> getTimedOuts(float timeout);
private:
core::