a mutex added to TempMods which hopefully fixes rare segfaults on client
parent
71948dbf96
commit
03d67af9e8
29
Makefile
29
Makefile
|
@ -26,18 +26,12 @@ CXXFLAGS = -O2 -ffast-math -Wall -g -pipe
|
||||||
#CXXFLAGS = -O1 -ffast-math -Wall -g
|
#CXXFLAGS = -O1 -ffast-math -Wall -g
|
||||||
#CXXFLAGS = -Wall -g -O0
|
#CXXFLAGS = -Wall -g -O0
|
||||||
|
|
||||||
#FAST_CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686
|
all: fast_linux
|
||||||
|
|
||||||
#Default target
|
|
||||||
|
|
||||||
all: all_linux
|
|
||||||
|
|
||||||
ifeq ($(HOSTTYPE), x86_64)
|
ifeq ($(HOSTTYPE), x86_64)
|
||||||
LIBSELECT=64
|
LIBSELECT=64
|
||||||
endif
|
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 -lz
|
all_linux fast_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L$(IRRLICHTPATH)/lib/Linux -L$(JTHREADPATH)/src/.libs -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -ljthread -lz
|
||||||
all_linux fast_linux: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src
|
all_linux fast_linux: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src
|
||||||
fast_linux server_linux: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686
|
fast_linux server_linux: CXXFLAGS = -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops -mtune=i686
|
||||||
|
@ -45,20 +39,13 @@ server_linux: LDFLAGS = -L$(JTHREADPATH)/src/.libs -ljthread -lz -lpthread
|
||||||
server_linux: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DSERVER
|
server_linux: CPPFLAGS = -I$(IRRLICHTPATH)/include -I/usr/X11R6/include -I$(JTHREADPATH)/src -DSERVER
|
||||||
all_linux fast_linux clean_linux: SYSTEM=Linux
|
all_linux fast_linux clean_linux: SYSTEM=Linux
|
||||||
|
|
||||||
# These are out of date
|
DESTPATH = bin/$(TARGET)
|
||||||
all_win32: LDFLAGS = -L$(IRRLICHTPATH)/lib/Win32-gcc -L$(JTHREADPATH)/Debug -lIrrlicht -lopengl32 -lm -ljthread
|
FAST_DESTPATH = bin/$(FAST_TARGET)
|
||||||
all_win32 clean_win32: SYSTEM=Win32-gcc
|
SERVER_DESTPATH = bin/$(SERVER_TARGET)
|
||||||
all_win32 clean_win32: SUF=.exe
|
|
||||||
|
|
||||||
# Name of the binary - only valid for targets which set SYSTEM
|
|
||||||
|
|
||||||
DESTPATH = bin/$(TARGET)$(SUF)
|
|
||||||
FAST_DESTPATH = bin/$(FAST_TARGET)$(SUF)
|
|
||||||
SERVER_DESTPATH = bin/$(SERVER_TARGET)$(SUF)
|
|
||||||
|
|
||||||
# Build commands
|
# Build commands
|
||||||
|
|
||||||
all_linux all_win32: $(BUILD_DIR) $(DESTPATH)
|
all_linux: $(BUILD_DIR) $(DESTPATH)
|
||||||
fast_linux: $(FAST_BUILD_DIR) $(FAST_DESTPATH)
|
fast_linux: $(FAST_BUILD_DIR) $(FAST_DESTPATH)
|
||||||
server_linux: $(SERVER_BUILD_DIR) $(SERVER_DESTPATH)
|
server_linux: $(SERVER_BUILD_DIR) $(SERVER_DESTPATH)
|
||||||
|
|
||||||
|
@ -87,13 +74,13 @@ $(FAST_BUILD_DIR)/%.o: src/%.cpp
|
||||||
$(SERVER_BUILD_DIR)/%.o: src/%.cpp
|
$(SERVER_BUILD_DIR)/%.o: src/%.cpp
|
||||||
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
|
$(CXX) -c -o $@ $< $(CPPFLAGS) $(CXXFLAGS)
|
||||||
|
|
||||||
clean: clean_linux clean_win32 clean_fast_linux clean_server_linux
|
clean: clean_linux clean_fast_linux clean_server_linux
|
||||||
|
|
||||||
clean_linux clean_win32:
|
clean_linux:
|
||||||
@$(RM) $(OBJECTS) $(DESTPATH)
|
@$(RM) $(OBJECTS) $(DESTPATH)
|
||||||
|
|
||||||
clean_fast_linux:
|
clean_fast_linux:
|
||||||
@$(RM) $(OBJECTS) $(FAST_DESTPATH)
|
@$(RM) $(FAST_OBJECTS) $(FAST_DESTPATH)
|
||||||
|
|
||||||
clean_server_linux:
|
clean_server_linux:
|
||||||
@$(RM) $(SERVER_OBJECTS) $(SERVER_DESTPATH)
|
@$(RM) $(SERVER_OBJECTS) $(SERVER_DESTPATH)
|
||||||
|
|
29
src/main.cpp
29
src/main.cpp
|
@ -91,6 +91,7 @@ SUGG: Implement a "Fast check queue" (a queue with a map for checking
|
||||||
|
|
||||||
SUGG: Signs could be done in the same way as torches. For this, blocks
|
SUGG: Signs could be done in the same way as torches. For this, blocks
|
||||||
need an additional metadata field for the texts
|
need an additional metadata field for the texts
|
||||||
|
- This is also needed for item container chests
|
||||||
|
|
||||||
SUGG: Precalculate lighting translation table at runtime (at startup)
|
SUGG: Precalculate lighting translation table at runtime (at startup)
|
||||||
|
|
||||||
|
@ -99,6 +100,15 @@ SUGG: A version number to blocks, which increments when the block is
|
||||||
- This can then be used to make sure the most recent version of
|
- This can then be used to make sure the most recent version of
|
||||||
a block has been sent to client
|
a block has been sent to client
|
||||||
|
|
||||||
|
SUGG: Make the amount of blocks sending to client and the total
|
||||||
|
amount of blocks dynamically limited. Transferring blocks is the
|
||||||
|
main network eater of this system, so it is the one that has
|
||||||
|
to be throttled so that RTTs stay low.
|
||||||
|
|
||||||
|
TODO: Untie client network operations from framerate
|
||||||
|
- Needs some input queues or something
|
||||||
|
- Not really necessary?
|
||||||
|
|
||||||
TODO: Combine MapBlock's face caches to so big pieces that VBO
|
TODO: Combine MapBlock's face caches to so big pieces that VBO
|
||||||
gets used
|
gets used
|
||||||
- That is >500 vertices
|
- That is >500 vertices
|
||||||
|
@ -106,11 +116,7 @@ TODO: Combine MapBlock's face caches to so big pieces that VBO
|
||||||
TODO: Better dungeons
|
TODO: Better dungeons
|
||||||
TODO: Cliffs, arcs
|
TODO: Cliffs, arcs
|
||||||
|
|
||||||
TODO: Menus
|
TODO: Startup and configuration menu
|
||||||
|
|
||||||
TODO: Moving players more smoothly. Calculate moving animation
|
|
||||||
in a way that doesn't make the player jump to the right place
|
|
||||||
immediately when the server sends a new position
|
|
||||||
|
|
||||||
TODO: There are some lighting-related todos and fixmes in
|
TODO: There are some lighting-related todos and fixmes in
|
||||||
ServerMap::emergeBlock
|
ServerMap::emergeBlock
|
||||||
|
@ -119,16 +125,10 @@ TODO: Proper handling of spawning place (try to find something that
|
||||||
is not in the middle of an ocean (some land to stand on at
|
is not in the middle of an ocean (some land to stand on at
|
||||||
least) and save it in map config.
|
least) and save it in map config.
|
||||||
|
|
||||||
TODO: Make the amount of blocks sending to client and the total
|
|
||||||
amount of blocks dynamically limited. Transferring blocks is the
|
|
||||||
main network eater of this system, so it is the one that has
|
|
||||||
to be throttled so that RTTs stay low.
|
|
||||||
|
|
||||||
TODO: Server to load starting inventory from disk
|
|
||||||
|
|
||||||
TODO: Players to only be hidden when the client quits.
|
TODO: Players to only be hidden when the client quits.
|
||||||
TODO: - Players to be saved on disk, with inventory
|
TODO: - Players to be saved on disk, with inventory
|
||||||
TODO: Players to be saved as text in map/players/<name>
|
TODO: Players to be saved as text in map/players/<name>
|
||||||
|
TODO: Player inventory to be saved on disk
|
||||||
|
|
||||||
TODO: Make fetching sector's blocks more efficient when rendering
|
TODO: Make fetching sector's blocks more efficient when rendering
|
||||||
sectors that have very large amounts of blocks (on client)
|
sectors that have very large amounts of blocks (on client)
|
||||||
|
@ -149,9 +149,6 @@ Block object server side:
|
||||||
TODO: Copy the text of the last picked sign to inventory in creative
|
TODO: Copy the text of the last picked sign to inventory in creative
|
||||||
mode
|
mode
|
||||||
|
|
||||||
TODO: Untie client network operations from framerate
|
|
||||||
- Needs some input queues or something
|
|
||||||
|
|
||||||
TODO: Get rid of GotSplitPacketException
|
TODO: Get rid of GotSplitPacketException
|
||||||
|
|
||||||
TODO: Check what goes wrong with caching map to disk (Kray)
|
TODO: Check what goes wrong with caching map to disk (Kray)
|
||||||
|
@ -168,7 +165,7 @@ TODO: Better handling of objects and mobs
|
||||||
- Make other players utilize the same framework
|
- Make other players utilize the same framework
|
||||||
|
|
||||||
TODO: Draw big amounts of torches better (that is, throw them in the
|
TODO: Draw big amounts of torches better (that is, throw them in the
|
||||||
same meshbuffer (can the meshcombiner class be used?))
|
same meshbuffer (can the meshcollector class be used?))
|
||||||
|
|
||||||
Doing now:
|
Doing now:
|
||||||
======================================================================
|
======================================================================
|
||||||
|
|
|
@ -47,6 +47,7 @@ MapBlock::MapBlock(NodeContainer *parent, v3s16 pos, bool dummy):
|
||||||
m_mesh_expired = false;
|
m_mesh_expired = false;
|
||||||
mesh_mutex.Init();
|
mesh_mutex.Init();
|
||||||
mesh = NULL;
|
mesh = NULL;
|
||||||
|
m_temp_mods_mutex.Init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,47 +585,52 @@ void MapBlock::updateMesh(u32 daynight_ratio)
|
||||||
|
|
||||||
NOTE: This is the slowest part of this method.
|
NOTE: This is the slowest part of this method.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
// Lock this, as m_temp_mods will be used directly
|
||||||
|
JMutexAutoLock lock(m_temp_mods_mutex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Go through every y,z and get top faces in rows of x+
|
Go through every y,z and get top faces in rows of x+
|
||||||
*/
|
*/
|
||||||
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
||||||
|
for(s16 z=0; z<MAP_BLOCKSIZE; z++){
|
||||||
|
updateFastFaceRow(daynight_ratio, posRelative_f,
|
||||||
|
v3s16(0,y,z), MAP_BLOCKSIZE,
|
||||||
|
v3s16(1,0,0), //dir
|
||||||
|
v3f (1,0,0),
|
||||||
|
v3s16(0,1,0), //face dir
|
||||||
|
v3f (0,1,0),
|
||||||
|
fastfaces_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Go through every x,y and get right faces in rows of z+
|
||||||
|
*/
|
||||||
|
for(s16 x=0; x<MAP_BLOCKSIZE; x++){
|
||||||
|
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
||||||
|
updateFastFaceRow(daynight_ratio, posRelative_f,
|
||||||
|
v3s16(x,y,0), MAP_BLOCKSIZE,
|
||||||
|
v3s16(0,0,1),
|
||||||
|
v3f (0,0,1),
|
||||||
|
v3s16(1,0,0),
|
||||||
|
v3f (1,0,0),
|
||||||
|
fastfaces_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Go through every y,z and get back faces in rows of x+
|
||||||
|
*/
|
||||||
for(s16 z=0; z<MAP_BLOCKSIZE; z++){
|
for(s16 z=0; z<MAP_BLOCKSIZE; z++){
|
||||||
updateFastFaceRow(daynight_ratio, posRelative_f,
|
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
||||||
v3s16(0,y,z), MAP_BLOCKSIZE,
|
updateFastFaceRow(daynight_ratio, posRelative_f,
|
||||||
v3s16(1,0,0), //dir
|
v3s16(0,y,z), MAP_BLOCKSIZE,
|
||||||
v3f (1,0,0),
|
v3s16(1,0,0),
|
||||||
v3s16(0,1,0), //face dir
|
v3f (1,0,0),
|
||||||
v3f (0,1,0),
|
v3s16(0,0,1),
|
||||||
fastfaces_new);
|
v3f (0,0,1),
|
||||||
}
|
fastfaces_new);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Go through every x,y and get right faces in rows of z+
|
|
||||||
*/
|
|
||||||
for(s16 x=0; x<MAP_BLOCKSIZE; x++){
|
|
||||||
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
|
||||||
updateFastFaceRow(daynight_ratio, posRelative_f,
|
|
||||||
v3s16(x,y,0), MAP_BLOCKSIZE,
|
|
||||||
v3s16(0,0,1),
|
|
||||||
v3f (0,0,1),
|
|
||||||
v3s16(1,0,0),
|
|
||||||
v3f (1,0,0),
|
|
||||||
fastfaces_new);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Go through every y,z and get back faces in rows of x+
|
|
||||||
*/
|
|
||||||
for(s16 z=0; z<MAP_BLOCKSIZE; z++){
|
|
||||||
for(s16 y=0; y<MAP_BLOCKSIZE; y++){
|
|
||||||
updateFastFaceRow(daynight_ratio, posRelative_f,
|
|
||||||
v3s16(0,y,z), MAP_BLOCKSIZE,
|
|
||||||
v3s16(1,0,0),
|
|
||||||
v3f (1,0,0),
|
|
||||||
v3s16(0,0,1),
|
|
||||||
v3f (0,0,1),
|
|
||||||
fastfaces_new);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,15 +399,30 @@ public:
|
||||||
<<", mod.type="<<mod.type
|
<<", mod.type="<<mod.type
|
||||||
<<", mod.param="<<mod.param
|
<<", mod.param="<<mod.param
|
||||||
<<std::endl;*/
|
<<std::endl;*/
|
||||||
|
JMutexAutoLock lock(m_temp_mods_mutex);
|
||||||
m_temp_mods[p] = mod;
|
m_temp_mods[p] = mod;
|
||||||
}
|
}
|
||||||
|
// Returns true if there was one
|
||||||
|
bool getTempMod(v3s16 p, struct NodeMod *mod)
|
||||||
|
{
|
||||||
|
JMutexAutoLock lock(m_temp_mods_mutex);
|
||||||
|
core::map<v3s16, NodeMod>::Node *n;
|
||||||
|
n = m_temp_mods.find(p);
|
||||||
|
if(n == NULL)
|
||||||
|
return false;
|
||||||
|
if(mod)
|
||||||
|
*mod = n->getValue();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void clearTempMod(v3s16 p)
|
void clearTempMod(v3s16 p)
|
||||||
{
|
{
|
||||||
|
JMutexAutoLock lock(m_temp_mods_mutex);
|
||||||
if(m_temp_mods.find(p))
|
if(m_temp_mods.find(p))
|
||||||
m_temp_mods.remove(p);
|
m_temp_mods.remove(p);
|
||||||
}
|
}
|
||||||
void clearTempMods()
|
void clearTempMods()
|
||||||
{
|
{
|
||||||
|
JMutexAutoLock lock(m_temp_mods_mutex);
|
||||||
m_temp_mods.clear();
|
m_temp_mods.clear();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -517,6 +532,7 @@ private:
|
||||||
// Temporary modifications to nodes
|
// Temporary modifications to nodes
|
||||||
// These are only used when drawing
|
// These are only used when drawing
|
||||||
core::map<v3s16, NodeMod> m_temp_mods;
|
core::map<v3s16, NodeMod> m_temp_mods;
|
||||||
|
JMutex m_temp_mods_mutex;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue