X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fclient.cpp;h=30280369f81f539c56ae5a56f5b858da0d093819;hb=8852333eb3042580592ade478e5def20f8ed5d4c;hp=50162b1e9822129be1ae1d668689de56fe4da26b;hpb=9370f5657a498c7fde00eddf4c8e78e8c3a42c7a;p=oweals%2Fminetest.git diff --git a/src/client.cpp b/src/client.cpp index 50162b1e9..30280369f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -47,10 +47,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include "util/serialize.h" #include "config.h" -#include "cmake_config_githash.h" #include "util/directiontables.h" #include "util/pointedthing.h" #include "version.h" +#include "drawscene.h" + +extern gui::IGUIEnvironment* guienv; /* QueuedMeshUpdate @@ -1787,9 +1789,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) v2f align = readV2F1000(is); v2f offset = readV2F1000(is); v3f world_pos; + v2s32 size; try{ world_pos = readV3F1000(is); }catch(SerializationError &e) {}; + try{ + size = readV2S32(is); + } catch(SerializationError &e) {}; ClientEvent event; event.type = CE_HUDADD; @@ -1805,6 +1811,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) event.hudadd.align = new v2f(align); event.hudadd.offset = new v2f(offset); event.hudadd.world_pos = new v3f(world_pos); + event.hudadd.size = new v2s32(size); m_client_event_queue.push_back(event); } else if(command == TOCLIENT_HUDRM) @@ -1825,6 +1832,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) v2f v2fdata; v3f v3fdata; u32 intdata = 0; + v2s32 v2s32data; std::string datastring((char *)&data[2], datasize - 2); std::istringstream is(datastring, std::ios_base::binary); @@ -1839,6 +1847,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) sdata = deSerializeString(is); else if (stat == HUD_STAT_WORLD_POS) v3fdata = readV3F1000(is); + else if (stat == HUD_STAT_SIZE ) + v2s32data = readV2S32(is); else intdata = readU32(is); @@ -1850,6 +1860,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id) event.hudchange.v3fdata = new v3f(v3fdata); event.hudchange.sdata = new std::string(sdata); event.hudchange.data = intdata; + event.hudchange.v2s32data = new v2s32(v2s32data); m_client_event_queue.push_back(event); } else if(command == TOCLIENT_HUD_SET_FLAGS) @@ -2073,8 +2084,10 @@ void Client::sendChatMessage(const std::wstring &message) // Write length size_t messagesize = message.size(); - assert(messagesize <= 0xFFFF); - writeU16(buf, (u16) (messagesize & 0xFF)); + if (messagesize > 0xFFFF) { + messagesize = 0xFFFF; + } + writeU16(buf, (u16) messagesize); os.write((char*)buf, 2); // Write string @@ -2183,8 +2196,8 @@ void Client::sendReady() writeU8(os,VERSION_PATCH_ORIG); writeU8(os,0); - writeU16(os,strlen(CMAKE_VERSION_GITHASH)); - os.write(CMAKE_VERSION_GITHASH,strlen(CMAKE_VERSION_GITHASH)); + writeU16(os,strlen(minetest_version_hash)); + os.write(minetest_version_hash,strlen(minetest_version_hash)); // Make data buffer std::string s = os.str(); @@ -2462,6 +2475,15 @@ int Client::getCrackLevel() return m_crack_level; } +void Client::setHighlighted(v3s16 pos, bool show_hud) +{ + m_show_hud = show_hud; + v3s16 old_highlighted_pos = m_highlighted_pos; + m_highlighted_pos = pos; + addUpdateMeshTaskForNode(old_highlighted_pos, false, true); + addUpdateMeshTaskForNode(m_highlighted_pos, false, true); +} + void Client::setCrack(int level, v3s16 pos) { int old_crack_level = m_crack_level; @@ -2534,22 +2556,23 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent) MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p); if(b == NULL) return; - + /* Create a task to update the mesh of the block */ - + MeshMakeData *data = new MeshMakeData(this); - + { //TimeTaker timer("data fill"); // Release: ~0ms // Debug: 1-6ms, avg=2ms data->fill(b); data->setCrack(m_crack_level, m_crack_pos); + data->setHighlighted(m_highlighted_pos, m_show_hud); data->setSmoothLighting(g_settings->getBool("smooth_lighting")); } - + // Add task to queue m_mesh_update_thread.m_queue_in.addBlock(p, data, ack_to_server, urgent); } @@ -2637,10 +2660,6 @@ float Client::mediaReceiveProgress() return 1.0; // downloader only exists when not yet done } -void draw_load_screen(const std::wstring &text, - IrrlichtDevice* device, gui::IGUIFont* font, - float dtime=0 ,int percent=0, bool clouds=true); - void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font) { infostream<<"Client::afterContentReceived() started"<updateAliases(m_itemdef); - // Update node textures + // Update node textures and assign shaders to each tile infostream<<"- Updating node textures"<updateTextures(m_tsrc); + m_nodedef->updateTextures(m_tsrc, m_shsrc); // Preload item textures and meshes if configured to if(g_settings->getBool("preload_item_visuals")) { verbosestream<<"Updating item textures and meshes"< names = m_itemdef->getAll(); size_t size = names.size(); size_t count = 0; @@ -2682,7 +2701,7 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font) count++; percent = count*100/size; if (count%50 == 0) // only update every 50 item - draw_load_screen(text,device,font,0,percent); + draw_load_screen(text, device, guienv, font, 0, percent); } delete[] text; }