Compare commits
5 Commits
9905999298
...
4a8a542b35
Author | SHA1 | Date |
---|---|---|
jachoo | 4a8a542b35 | |
jachoo | ad633e88d8 | |
jachoo | 54d47d2799 | |
jachoo | 05a6ea0996 | |
jachoo | e982d59385 |
|
@ -305,8 +305,8 @@ if(MSVC)
|
||||||
|
|
||||||
# EHa enables SEH exceptions (used for catching segfaults)
|
# EHa enables SEH exceptions (used for catching segfaults)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /O2 /Ob2 /Oi /Ot /Oy /GL /FD /MT /GS- /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
|
set(CMAKE_CXX_FLAGS_RELEASE "/EHa /O2 /Ob2 /Oi /Ot /Oy /GL /FD /MT /GS- /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
|
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
|
||||||
#set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
|
||||||
|
|
||||||
# Debug build doesn't catch exceptions by itself
|
# Debug build doesn't catch exceptions by itself
|
||||||
# Add some optimizations because otherwise it's VERY slow
|
# Add some optimizations because otherwise it's VERY slow
|
||||||
|
|
|
@ -35,6 +35,8 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("keymap_right", "KEY_KEY_D");
|
settings->setDefault("keymap_right", "KEY_KEY_D");
|
||||||
settings->setDefault("keymap_jump", "KEY_SPACE");
|
settings->setDefault("keymap_jump", "KEY_SPACE");
|
||||||
settings->setDefault("keymap_sneak", "KEY_LSHIFT");
|
settings->setDefault("keymap_sneak", "KEY_LSHIFT");
|
||||||
|
//settings->setDefault("keymap_crouch", "Left Control");
|
||||||
|
settings->setDefault("keymap_crouch", "KEY_KEY_C");
|
||||||
settings->setDefault("keymap_inventory", "KEY_KEY_I");
|
settings->setDefault("keymap_inventory", "KEY_KEY_I");
|
||||||
settings->setDefault("keymap_special1", "KEY_KEY_E");
|
settings->setDefault("keymap_special1", "KEY_KEY_E");
|
||||||
settings->setDefault("keymap_chat", "KEY_KEY_T");
|
settings->setDefault("keymap_chat", "KEY_KEY_T");
|
||||||
|
|
122
src/game.cpp
122
src/game.cpp
|
@ -296,14 +296,23 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
|
||||||
*/
|
*/
|
||||||
void getPointedNode(Client *client, v3f player_position,
|
void getPointedNode(Client *client, v3f player_position,
|
||||||
v3f camera_direction, v3f camera_position,
|
v3f camera_direction, v3f camera_position,
|
||||||
bool &nodefound, core::line3d<f32> shootline,
|
bool &nodefound, bool &onlyFreeFound, core::line3d<f32> shootline,
|
||||||
v3s16 &nodepos, v3s16 &neighbourpos,
|
v3s16 &nodepos, v3s16 &neighbourpos,
|
||||||
core::aabbox3d<f32> &nodehilightbox,
|
core::aabbox3d<f32> &nodehilightbox,
|
||||||
f32 d)
|
f32 d)
|
||||||
{
|
{
|
||||||
|
onlyFreeFound = false;
|
||||||
|
bool freeNodeFound = false;
|
||||||
|
|
||||||
f32 mindistance = BS * 1001;
|
f32 mindistance = BS * 1001;
|
||||||
|
f32 maxdistance = -BS * 1001;
|
||||||
|
|
||||||
v3s16 pos_i = floatToInt(player_position, BS);
|
v3s16 pos_i = floatToInt(player_position, BS);
|
||||||
|
//j@@@
|
||||||
|
v3s16 cam_i = floatToInt(camera_position, BS);
|
||||||
|
v3s16 camdir_i(camera_direction.X>=0?1:-1,
|
||||||
|
camera_direction.Y>=0?1:-1,
|
||||||
|
camera_direction.Z>=0?1:-1);
|
||||||
|
|
||||||
/*infostream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")"
|
/*infostream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")"
|
||||||
<<std::endl;*/
|
<<std::endl;*/
|
||||||
|
@ -324,8 +333,8 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
n = client->getNode(v3s16(x,y,z));
|
n = client->getNode(v3s16(x,y,z));
|
||||||
if(content_pointable(n.getContent()) == false)
|
//if(content_pointable(n.getContent()) == false)
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
catch(InvalidPositionException &e)
|
catch(InvalidPositionException &e)
|
||||||
{
|
{
|
||||||
|
@ -625,25 +634,83 @@ void getPointedNode(Client *client, v3f player_position,
|
||||||
|
|
||||||
if(facebox.intersectsWithLine(shootline))
|
if(facebox.intersectsWithLine(shootline))
|
||||||
{
|
{
|
||||||
nodefound = true;
|
if(content_pointable(n.getContent()) == true){
|
||||||
nodepos = np;
|
nodefound = true;
|
||||||
neighbourpos = np + dirs[i];
|
nodepos = np;
|
||||||
mindistance = distance;
|
neighbourpos = np + dirs[i];
|
||||||
|
mindistance = distance;
|
||||||
|
|
||||||
//nodehilightbox = facebox;
|
//nodehilightbox = facebox;
|
||||||
|
|
||||||
const float d = 0.502;
|
const float d = 0.502;
|
||||||
core::aabbox3d<f32> nodebox
|
core::aabbox3d<f32> nodebox
|
||||||
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
||||||
v3f nodepos_f = intToFloat(nodepos, BS);
|
v3f nodepos_f = intToFloat(nodepos, BS);
|
||||||
nodebox.MinEdge += nodepos_f;
|
nodebox.MinEdge += nodepos_f;
|
||||||
nodebox.MaxEdge += nodepos_f;
|
nodebox.MaxEdge += nodepos_f;
|
||||||
nodehilightbox = nodebox;
|
nodehilightbox = nodebox;
|
||||||
|
}else if( nodefound==false
|
||||||
|
&& distance < (BS*6)
|
||||||
|
&& np != pos_i
|
||||||
|
&& np != v3s16(pos_i.X,pos_i.Y+1,pos_i.Z)
|
||||||
|
&& content_features(n).buildable_to )
|
||||||
|
{
|
||||||
|
|
||||||
|
bool can_build = false;
|
||||||
|
v3s16 neigh_pos;
|
||||||
|
for(int i=0; i<6; i++)
|
||||||
|
{
|
||||||
|
//j@@@
|
||||||
|
const v3s16& npos = dirs[i];
|
||||||
|
v3s16 ap = np + npos;
|
||||||
|
try{
|
||||||
|
MapNode an = client->getNode(ap);
|
||||||
|
//check if we can `stick' to this node
|
||||||
|
if(!content_features(an).walkable) //FIXME: is this OK?
|
||||||
|
continue;
|
||||||
|
if( npos.X==camdir_i.X //is it same direction as camera?
|
||||||
|
|| npos.Y==camdir_i.Y
|
||||||
|
|| npos.Z==camdir_i.Z
|
||||||
|
|| (npos.X != 0 && cam_i.X == np.X) //is it the same axis as camera?
|
||||||
|
|| (npos.Y != 0 && cam_i.Y == np.Y)
|
||||||
|
|| (npos.Z != 0 && cam_i.Z == np.Z) )
|
||||||
|
{
|
||||||
|
can_build = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
can_build = true;
|
||||||
|
neigh_pos = ap;
|
||||||
|
//goto after_check_neighbor;
|
||||||
|
}catch(InvalidPositionException&){}
|
||||||
|
}
|
||||||
|
//after_check_neighbor:
|
||||||
|
if(can_build && distance > maxdistance){
|
||||||
|
|
||||||
|
maxdistance = distance;
|
||||||
|
|
||||||
|
//nodefound = true; //we can't do this here!
|
||||||
|
freeNodeFound = true; //instead, we set this and check at the end
|
||||||
|
nodepos = neigh_pos; //yes, these are swaped!
|
||||||
|
neighbourpos = np;
|
||||||
|
//mindistance = distance;
|
||||||
|
|
||||||
|
//nodehilightbox = facebox;
|
||||||
|
|
||||||
|
const float d = 0.502;
|
||||||
|
core::aabbox3d<f32> nodebox
|
||||||
|
(-BS*d, -BS*d, -BS*d, BS*d, BS*d, BS*d);
|
||||||
|
v3f nodepos_f = intToFloat(np, BS);
|
||||||
|
nodebox.MinEdge += nodepos_f;
|
||||||
|
nodebox.MaxEdge += nodepos_f;
|
||||||
|
nodehilightbox = nodebox;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // if distance < mindistance
|
} // if distance < mindistance
|
||||||
} // for dirs
|
} // for dirs
|
||||||
} // regular block
|
} // regular block
|
||||||
} // for coords
|
} // for coords
|
||||||
|
if(!nodefound && freeNodeFound) nodefound = onlyFreeFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_skybox(video::IVideoDriver* driver,
|
void update_skybox(video::IVideoDriver* driver,
|
||||||
|
@ -1558,7 +1625,8 @@ void the_game(
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
camera_pitch,
|
camera_pitch,
|
||||||
camera_yaw
|
camera_yaw,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
client.setPlayerControl(control);
|
client.setPlayerControl(control);
|
||||||
}
|
}
|
||||||
|
@ -1580,9 +1648,10 @@ void the_game(
|
||||||
input->isKeyDown(getKeySetting("keymap_right")),
|
input->isKeyDown(getKeySetting("keymap_right")),
|
||||||
input->isKeyDown(getKeySetting("keymap_jump")),
|
input->isKeyDown(getKeySetting("keymap_jump")),
|
||||||
input->isKeyDown(getKeySetting("keymap_special1")),
|
input->isKeyDown(getKeySetting("keymap_special1")),
|
||||||
input->isKeyDown(getKeySetting("keymap_sneak")),
|
input->isKeyDown(getKeySetting("keymap_sneak")) || input->isKeyDown(getKeySetting("keymap_crouch")),
|
||||||
camera_pitch,
|
camera_pitch,
|
||||||
camera_yaw
|
camera_yaw,
|
||||||
|
input->isKeyDown(getKeySetting("keymap_crouch"))
|
||||||
);
|
);
|
||||||
client.setPlayerControl(control);
|
client.setPlayerControl(control);
|
||||||
}
|
}
|
||||||
|
@ -1766,13 +1835,14 @@ void the_game(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool nodefound = false;
|
bool nodefound = false;
|
||||||
|
bool onlyFreeNodeFound = false;
|
||||||
v3s16 nodepos;
|
v3s16 nodepos;
|
||||||
v3s16 neighbourpos;
|
v3s16 neighbourpos;
|
||||||
core::aabbox3d<f32> nodehilightbox;
|
core::aabbox3d<f32> nodehilightbox;
|
||||||
|
|
||||||
getPointedNode(&client, player_position,
|
getPointedNode(&client, player_position,
|
||||||
camera_direction, camera_position,
|
camera_direction, camera_position,
|
||||||
nodefound, shootline,
|
nodefound, onlyFreeNodeFound, shootline,
|
||||||
nodepos, neighbourpos,
|
nodepos, neighbourpos,
|
||||||
nodehilightbox, d);
|
nodehilightbox, d);
|
||||||
|
|
||||||
|
@ -1914,7 +1984,7 @@ void the_game(
|
||||||
{
|
{
|
||||||
nodig_delay_counter -= dtime;
|
nodig_delay_counter -= dtime;
|
||||||
}
|
}
|
||||||
else
|
else if(!onlyFreeNodeFound)
|
||||||
{
|
{
|
||||||
if(nodepos != nodepos_old)
|
if(nodepos != nodepos_old)
|
||||||
{
|
{
|
||||||
|
@ -2432,7 +2502,17 @@ void the_game(
|
||||||
//timer3.stop();
|
//timer3.stop();
|
||||||
|
|
||||||
//infostream<<"smgr->drawAll()"<<std::endl;
|
//infostream<<"smgr->drawAll()"<<std::endl;
|
||||||
|
|
||||||
|
//j
|
||||||
|
/*driver->getOverrideMaterial().Material.Wireframe = true;
|
||||||
|
driver->getOverrideMaterial().EnableFlags=irr::video::EMF_WIREFRAME;
|
||||||
|
driver->getOverrideMaterial().EnablePasses =
|
||||||
|
irr::scene::ESNRP_SKY_BOX
|
||||||
|
+irr::scene::ESNRP_SOLID
|
||||||
|
+irr::scene::ESNRP_TRANSPARENT
|
||||||
|
+irr::scene::ESNRP_TRANSPARENT_EFFECT
|
||||||
|
+irr::scene::ESNRP_SHADOW
|
||||||
|
;*/
|
||||||
{
|
{
|
||||||
TimeTaker timer("smgr");
|
TimeTaker timer("smgr");
|
||||||
smgr->drawAll();
|
smgr->drawAll();
|
||||||
|
|
|
@ -75,9 +75,11 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
|
||||||
if(g_texturesource == NULL)
|
if(g_texturesource == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//jFIXME: usunac to
|
//workaround for windows irrlicht bug (texture cubes drawn wrong)
|
||||||
|
#ifdef _WINDOWS
|
||||||
inventory_texture = g_texturesource->getTextureRaw("[noalpha:"+top+"^[forcesingle");
|
inventory_texture = g_texturesource->getTextureRaw("[noalpha:"+top+"^[forcesingle");
|
||||||
return;
|
return;
|
||||||
|
#else
|
||||||
|
|
||||||
str_replace_char(top, '^', '&');
|
str_replace_char(top, '^', '&');
|
||||||
str_replace_char(left, '^', '&');
|
str_replace_char(left, '^', '&');
|
||||||
|
@ -91,6 +93,7 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
|
||||||
imgname_full += "{";
|
imgname_full += "{";
|
||||||
imgname_full += right;
|
imgname_full += right;
|
||||||
inventory_texture = g_texturesource->getTextureRaw(imgname_full);
|
inventory_texture = g_texturesource->getTextureRaw(imgname_full);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,8 @@ Player::Player():
|
||||||
m_pitch(0),
|
m_pitch(0),
|
||||||
m_yaw(0),
|
m_yaw(0),
|
||||||
m_speed(0,0,0),
|
m_speed(0,0,0),
|
||||||
m_position(0,0,0)
|
m_position(0,0,0),
|
||||||
|
m_eyeOffset(0,BS+(5*BS)/8,0)
|
||||||
{
|
{
|
||||||
lastTeleportPos.X=FLT_MAX;
|
lastTeleportPos.X=FLT_MAX;
|
||||||
updateName("<not set>");
|
updateName("<not set>");
|
||||||
|
@ -1019,6 +1020,22 @@ void LocalPlayer::applyControl(float dtime)
|
||||||
|
|
||||||
// Accelerate to target speed with maximum increment
|
// Accelerate to target speed with maximum increment
|
||||||
accelerate(speed, inc);
|
accelerate(speed, inc);
|
||||||
|
|
||||||
|
//j
|
||||||
|
static const f32 eyes_max = BS+(5*BS)/8;
|
||||||
|
static const f32 eyes_min = BS * 0.9f;
|
||||||
|
static const f32 eyes_delta = 10.f;
|
||||||
|
if(control.crouch){
|
||||||
|
//crouching
|
||||||
|
if(m_eyeOffset.Y > eyes_min + 0.01f)
|
||||||
|
m_eyeOffset.Y += (eyes_min-m_eyeOffset.Y) * eyes_delta * dtime;
|
||||||
|
else m_eyeOffset.Y = eyes_min;
|
||||||
|
}else{
|
||||||
|
//standing
|
||||||
|
if(m_eyeOffset.Y < eyes_max - 0.01f)
|
||||||
|
m_eyeOffset.Y += (eyes_max-m_eyeOffset.Y) * eyes_delta * dtime;
|
||||||
|
else m_eyeOffset.Y = eyes_max;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
10
src/player.h
10
src/player.h
|
@ -76,7 +76,8 @@ public:
|
||||||
// This is at the height of the eyes of the current figure
|
// This is at the height of the eyes of the current figure
|
||||||
// return v3f(0, BS+BS/2, 0);
|
// return v3f(0, BS+BS/2, 0);
|
||||||
// This is more like in minecraft
|
// This is more like in minecraft
|
||||||
return v3f(0,BS+(5*BS)/8,0);
|
//return v3f(0,BS+(5*BS)/8,0);
|
||||||
|
return m_eyeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
v3f getEyePosition()
|
v3f getEyePosition()
|
||||||
|
@ -196,6 +197,7 @@ protected:
|
||||||
f32 m_yaw;
|
f32 m_yaw;
|
||||||
v3f m_speed;
|
v3f m_speed;
|
||||||
v3f m_position;
|
v3f m_position;
|
||||||
|
v3f m_eyeOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -336,6 +338,7 @@ struct PlayerControl
|
||||||
sneak = false;
|
sneak = false;
|
||||||
pitch = 0;
|
pitch = 0;
|
||||||
yaw = 0;
|
yaw = 0;
|
||||||
|
crouch = false;
|
||||||
}
|
}
|
||||||
PlayerControl(
|
PlayerControl(
|
||||||
bool a_up,
|
bool a_up,
|
||||||
|
@ -346,7 +349,8 @@ struct PlayerControl
|
||||||
bool a_aux1,
|
bool a_aux1,
|
||||||
bool a_sneak,
|
bool a_sneak,
|
||||||
float a_pitch,
|
float a_pitch,
|
||||||
float a_yaw
|
float a_yaw,
|
||||||
|
bool a_crouch
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
up = a_up;
|
up = a_up;
|
||||||
|
@ -358,6 +362,7 @@ struct PlayerControl
|
||||||
sneak = a_sneak;
|
sneak = a_sneak;
|
||||||
pitch = a_pitch;
|
pitch = a_pitch;
|
||||||
yaw = a_yaw;
|
yaw = a_yaw;
|
||||||
|
crouch = a_crouch;
|
||||||
}
|
}
|
||||||
bool up;
|
bool up;
|
||||||
bool down;
|
bool down;
|
||||||
|
@ -368,6 +373,7 @@ struct PlayerControl
|
||||||
bool sneak;
|
bool sneak;
|
||||||
float pitch;
|
float pitch;
|
||||||
float yaw;
|
float yaw;
|
||||||
|
bool crouch;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LocalPlayer : public Player
|
class LocalPlayer : public Player
|
||||||
|
|
|
@ -2952,7 +2952,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
u16 newowner=0;
|
u16 newowner=0;
|
||||||
// Only allow borderstone if player already belongs to some clan
|
// Only allow borderstone if player already belongs to some clan
|
||||||
if(mitem->getMaterial() == CONTENT_BORDERSTONE)
|
if(mitem->getMaterial() == CONTENT_BORDERSTONE)
|
||||||
{ if(player->lastClan && player->clans.find(player->lastClan) == player->clans.end())
|
{ if(player->lastClan && !player->isClanMember(player->lastClan))
|
||||||
player->lastClan=0; // was invalid (no longer member?)
|
player->lastClan=0; // was invalid (no longer member?)
|
||||||
if(!player->lastClan)
|
if(!player->lastClan)
|
||||||
{ if(player->clanOwner)
|
{ if(player->clanOwner)
|
||||||
|
|
|
@ -823,7 +823,7 @@ inline std::vector<T> str_split(const T& str, const D& delimiter, int limit = 0)
|
||||||
{
|
{
|
||||||
std::vector<T> parts;
|
std::vector<T> parts;
|
||||||
|
|
||||||
int pos = 0, lpos = 0;
|
typename T::size_type pos = 0, lpos = 0;
|
||||||
|
|
||||||
while( --limit && pos != T::npos ){
|
while( --limit && pos != T::npos ){
|
||||||
pos = str.find(delimiter,lpos);
|
pos = str.find(delimiter,lpos);
|
||||||
|
|
Loading…
Reference in New Issue