diff options
author | MirceaKitsune <sonichedgehog_hyperblast00@yahoo.com> | 2012-11-22 21:01:31 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-11-25 19:14:24 +0200 |
commit | 3d1c481f0bdf03b59871237d810685278e87613b (patch) | |
tree | fe49c10e926b1e452e4f98561a148e2f145c27e9 /src/server.cpp | |
parent | 756db8174aa6a05eb998cfcec8eb5127053c5ea9 (diff) | |
download | minetest-3d1c481f0bdf03b59871237d810685278e87613b.tar.gz minetest-3d1c481f0bdf03b59871237d810685278e87613b.tar.bz2 minetest-3d1c481f0bdf03b59871237d810685278e87613b.zip |
RealBadAngel's patch which allows the lua api to read pressed player keys. This should make it possible to change the player's animation based on what he is doing
Correct lua api version number
Always update animations and attachments after the entity is added to scene client side. Fixes animations not being applied in client initialization for some reason. Attachments should be re-tested now just to be safe.
Fix a segmentation fault caused by reaching materials that didn't exist in a loop for setting texture
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp index 1a401bb62..ac243a29c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2369,7 +2369,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(command == TOSERVER_PLAYERPOS) { - if(datasize < 2+12+12+4+4) + if(datasize < 2+12+12+4+4+4) return; u32 start = 0; @@ -2377,6 +2377,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) v3s32 ss = readV3S32(&data[start+2+12]); f32 pitch = (f32)readS32(&data[2+12+12]) / 100.0; f32 yaw = (f32)readS32(&data[2+12+12+4]) / 100.0; + u32 keyPressed = (u32)readU32(&data[2+12+12+4+4]); v3f position((f32)ps.X/100., (f32)ps.Y/100., (f32)ps.Z/100.); v3f speed((f32)ss.X/100., (f32)ss.Y/100., (f32)ss.Z/100.); pitch = wrapDegrees(pitch); @@ -2386,6 +2387,16 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) player->setSpeed(speed); player->setPitch(pitch); player->setYaw(yaw); + player->keyPressed=keyPressed; + player->control.up = (bool)(keyPressed&1); + player->control.down = (bool)(keyPressed&2); + player->control.left = (bool)(keyPressed&4); + player->control.right = (bool)(keyPressed&8); + player->control.jump = (bool)(keyPressed&16); + player->control.aux1 = (bool)(keyPressed&32); + player->control.sneak = (bool)(keyPressed&64); + player->control.LMB = (bool)(keyPressed&128); + player->control.RMB = (bool)(keyPressed&256); /*infostream<<"Server::ProcessData(): Moved player "<<peer_id<<" to " <<"("<<position.X<<","<<position.Y<<","<<position.Z<<")" @@ -3166,6 +3177,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) } } // action == 4 + /* Catch invalid actions |