From 1320d07068f25ff23ea27e120983c006f75bec24 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 12 Nov 2011 17:37:14 +0200 Subject: Scripting WIP: dynamic object stuff --- src/server.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 330ce21c2..08a26adc6 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2299,10 +2299,23 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) return; //TODO: Check that object is reasonably close + + // Get ServerRemotePlayer + ServerRemotePlayer *srp = (ServerRemotePlayer*)player; + + // Update wielded item + srp->wieldItem(item_i); - // Left click, pick object up (usually) + // Left click, pick/punch if(button == 0) { + actionstream<getName()<<" punches object " + <getId()<punch(srp); + +#if 0 /* Try creating inventory item */ @@ -2371,6 +2384,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) SendInventory(player->peer_id); } } +#endif } // Right click, do something with object if(button == 1) @@ -2378,18 +2392,16 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) actionstream<getName()<<" right clicks object " <getId()<hp; - // Do stuff - obj->rightClick(player); - - // Send back stuff - if(player->hp != oldhp) - { - SendPlayerHP(player); - } + obj->rightClick(srp); } + + /* + Update player state to client + */ + SendPlayerHP(player); + UpdateCrafting(player->peer_id); + SendInventory(player->peer_id); } else if(command == TOSERVER_GROUND_ACTION) { -- cgit v1.2.3