Compare commits

...

5 Commits

Author SHA1 Message Date
jachoo 4a8a542b35 Minor fixes 2011-11-22 18:40:24 +01:00
jachoo ad633e88d8 Bugfix & a small upgrade to block selecting 2011-11-20 01:52:36 +01:00
jachoo 54d47d2799 Small fix, upgrade to irrlicht 1.7.2 on windows 2011-11-20 01:12:31 +01:00
jachoo 05a6ea0996 Extended block selecting 2011-11-19 22:07:31 +01:00
jachoo e982d59385 Crouching (C key) 2011-11-19 19:03:39 +01:00
8 changed files with 137 additions and 29 deletions

View File

@ -305,8 +305,8 @@ if(MSVC)
# 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_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 /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
# Debug build doesn't catch exceptions by itself
# Add some optimizations because otherwise it's VERY slow

View File

@ -35,6 +35,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_right", "KEY_KEY_D");
settings->setDefault("keymap_jump", "KEY_SPACE");
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_special1", "KEY_KEY_E");
settings->setDefault("keymap_chat", "KEY_KEY_T");

View File

@ -296,14 +296,23 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
*/
void getPointedNode(Client *client, v3f player_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,
core::aabbox3d<f32> &nodehilightbox,
f32 d)
{
onlyFreeFound = false;
bool freeNodeFound = false;
f32 mindistance = BS * 1001;
f32 maxdistance = -BS * 1001;
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<<")"
<<std::endl;*/
@ -324,8 +333,8 @@ void getPointedNode(Client *client, v3f player_position,
try
{
n = client->getNode(v3s16(x,y,z));
if(content_pointable(n.getContent()) == false)
continue;
//if(content_pointable(n.getContent()) == false)
//continue;
}
catch(InvalidPositionException &e)
{
@ -625,25 +634,83 @@ void getPointedNode(Client *client, v3f player_position,
if(facebox.intersectsWithLine(shootline))
{
nodefound = true;
nodepos = np;
neighbourpos = np + dirs[i];
mindistance = distance;
if(content_pointable(n.getContent()) == true){
nodefound = true;
nodepos = np;
neighbourpos = np + dirs[i];
mindistance = distance;
//nodehilightbox = facebox;
//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(nodepos, BS);
nodebox.MinEdge += nodepos_f;
nodebox.MaxEdge += nodepos_f;
nodehilightbox = nodebox;
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(nodepos, BS);
nodebox.MinEdge += nodepos_f;
nodebox.MaxEdge += nodepos_f;
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
} // for dirs
} // regular block
} // for coords
if(!nodefound && freeNodeFound) nodefound = onlyFreeFound = true;
}
void update_skybox(video::IVideoDriver* driver,
@ -1558,7 +1625,8 @@ void the_game(
false,
false,
camera_pitch,
camera_yaw
camera_yaw,
false
);
client.setPlayerControl(control);
}
@ -1580,9 +1648,10 @@ void the_game(
input->isKeyDown(getKeySetting("keymap_right")),
input->isKeyDown(getKeySetting("keymap_jump")),
input->isKeyDown(getKeySetting("keymap_special1")),
input->isKeyDown(getKeySetting("keymap_sneak")),
input->isKeyDown(getKeySetting("keymap_sneak")) || input->isKeyDown(getKeySetting("keymap_crouch")),
camera_pitch,
camera_yaw
camera_yaw,
input->isKeyDown(getKeySetting("keymap_crouch"))
);
client.setPlayerControl(control);
}
@ -1766,13 +1835,14 @@ void the_game(
*/
bool nodefound = false;
bool onlyFreeNodeFound = false;
v3s16 nodepos;
v3s16 neighbourpos;
core::aabbox3d<f32> nodehilightbox;
getPointedNode(&client, player_position,
camera_direction, camera_position,
nodefound, shootline,
nodefound, onlyFreeNodeFound, shootline,
nodepos, neighbourpos,
nodehilightbox, d);
@ -1914,7 +1984,7 @@ void the_game(
{
nodig_delay_counter -= dtime;
}
else
else if(!onlyFreeNodeFound)
{
if(nodepos != nodepos_old)
{
@ -2432,7 +2502,17 @@ void the_game(
//timer3.stop();
//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");
smgr->drawAll();

View File

@ -75,9 +75,11 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
if(g_texturesource == NULL)
return;
//jFIXME: usunac to
//workaround for windows irrlicht bug (texture cubes drawn wrong)
#ifdef _WINDOWS
inventory_texture = g_texturesource->getTextureRaw("[noalpha:"+top+"^[forcesingle");
return;
#else
str_replace_char(top, '^', '&');
str_replace_char(left, '^', '&');
@ -91,6 +93,7 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
imgname_full += "{";
imgname_full += right;
inventory_texture = g_texturesource->getTextureRaw(imgname_full);
#endif
}
#endif

View File

@ -48,7 +48,8 @@ Player::Player():
m_pitch(0),
m_yaw(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;
updateName("<not set>");
@ -1019,6 +1020,22 @@ void LocalPlayer::applyControl(float dtime)
// Accelerate to target speed with maximum increment
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

View File

@ -76,7 +76,8 @@ public:
// This is at the height of the eyes of the current figure
// return v3f(0, BS+BS/2, 0);
// 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()
@ -196,6 +197,7 @@ protected:
f32 m_yaw;
v3f m_speed;
v3f m_position;
v3f m_eyeOffset;
public:
@ -336,6 +338,7 @@ struct PlayerControl
sneak = false;
pitch = 0;
yaw = 0;
crouch = false;
}
PlayerControl(
bool a_up,
@ -346,7 +349,8 @@ struct PlayerControl
bool a_aux1,
bool a_sneak,
float a_pitch,
float a_yaw
float a_yaw,
bool a_crouch
)
{
up = a_up;
@ -358,6 +362,7 @@ struct PlayerControl
sneak = a_sneak;
pitch = a_pitch;
yaw = a_yaw;
crouch = a_crouch;
}
bool up;
bool down;
@ -368,6 +373,7 @@ struct PlayerControl
bool sneak;
float pitch;
float yaw;
bool crouch;
};
class LocalPlayer : public Player

View File

@ -2952,7 +2952,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
u16 newowner=0;
// Only allow borderstone if player already belongs to some clan
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?)
if(!player->lastClan)
{ if(player->clanOwner)

View File

@ -823,7 +823,7 @@ inline std::vector<T> str_split(const T& str, const D& delimiter, int limit = 0)
{
std::vector<T> parts;
int pos = 0, lpos = 0;
typename T::size_type pos = 0, lpos = 0;
while( --limit && pos != T::npos ){
pos = str.find(delimiter,lpos);