Fix HUD not visible if below ground blacked out

This commit is contained in:
sapier 2014-06-12 23:38:34 +02:00
parent d7986da58c
commit c78aa7cf24
2 changed files with 102 additions and 100 deletions

View File

@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "main.h" // for g_settings #include "main.h" // for g_settings
#include "settings.h" #include "settings.h"
#include "clouds.h" #include "clouds.h"
#include "clientmap.h"
#include "util/timetaker.h" #include "util/timetaker.h"
typedef enum { typedef enum {
@ -458,6 +459,14 @@ void draw_scene(video::IVideoDriver* driver, scene::ISceneManager* smgr,
draw_plain(camera, show_hud, hud, hilightboxes, driver, draw_plain(camera, show_hud, hud, hilightboxes, driver,
draw_wield_tool, client, guienv); draw_wield_tool, client, guienv);
} }
/*
Post effects
*/
{
client.getEnv().getClientMap().renderPostFx(camera.getCameraMode());
}
//TODO how to make those 3d too //TODO how to make those 3d too
if (show_hud) if (show_hud)
{ {

View File

@ -319,7 +319,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
// That didn't work, try to find a pointed at node // That didn't work, try to find a pointed at node
v3s16 pos_i = floatToInt(player_position, BS); v3s16 pos_i = floatToInt(player_position, BS);
/*infostream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")" /*infostream<<"pos_i=("<<pos_i.X<<","<<pos_i.Y<<","<<pos_i.Z<<")"
@ -332,7 +332,7 @@ PointedThing getPointedThing(Client *client, v3f player_position,
s16 yend = pos_i.Y + 1 + (camera_direction.Y>0 ? a : 1); s16 yend = pos_i.Y + 1 + (camera_direction.Y>0 ? a : 1);
s16 zend = pos_i.Z + (camera_direction.Z>0 ? a : 1); s16 zend = pos_i.Z + (camera_direction.Z>0 ? a : 1);
s16 xend = pos_i.X + (camera_direction.X>0 ? a : 1); s16 xend = pos_i.X + (camera_direction.X>0 ? a : 1);
// Prevent signed number overflow // Prevent signed number overflow
if(yend==32767) if(yend==32767)
yend=32766; yend=32766;
@ -483,7 +483,7 @@ public:
while(m_log.size() > m_log_max_size) while(m_log.size() > m_log_max_size)
m_log.erase(m_log.begin()); m_log.erase(m_log.begin());
} }
void draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver, void draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
gui::IGUIFont* font) const gui::IGUIFont* font) const
{ {
@ -532,7 +532,7 @@ public:
s32 graphh = 50; s32 graphh = 50;
s32 textx = x_left + m_log_max_size + 15; s32 textx = x_left + m_log_max_size + 15;
s32 textx2 = textx + 200 - 15; s32 textx2 = textx + 200 - 15;
// Draw background // Draw background
/*{ /*{
u32 num_graphs = m_meta.size(); u32 num_graphs = m_meta.size();
@ -541,7 +541,7 @@ public:
video::SColor bgcolor(120,0,0,0); video::SColor bgcolor(120,0,0,0);
driver->draw2DRectangle(bgcolor, rect, NULL); driver->draw2DRectangle(bgcolor, rect, NULL);
}*/ }*/
s32 meta_i = 0; s32 meta_i = 0;
for(std::map<std::string, Meta>::const_iterator i = m_meta.begin(); for(std::map<std::string, Meta>::const_iterator i = m_meta.begin();
i != m_meta.end(); i++){ i != m_meta.end(); i++){
@ -627,7 +627,7 @@ class NodeDugEvent: public MtEvent
public: public:
v3s16 p; v3s16 p;
MapNode n; MapNode n;
NodeDugEvent(v3s16 p, MapNode n): NodeDugEvent(v3s16 p, MapNode n):
p(p), p(p),
n(n) n(n)
@ -800,7 +800,7 @@ public:
u32 daynight_ratio = m_client->getEnv().getDayNightRatio(); u32 daynight_ratio = m_client->getEnv().getDayNightRatio();
float daynight_ratio_f = (float)daynight_ratio / 1000.0; float daynight_ratio_f = (float)daynight_ratio / 1000.0;
services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1); services->setPixelShaderConstant("dayNightRatio", &daynight_ratio_f, 1);
u32 animation_timer = porting::getTimeMs() % 100000; u32 animation_timer = porting::getTimeMs() % 100000;
float animation_timer_f = (float)animation_timer / 100000.0; float animation_timer_f = (float)animation_timer / 100000.0;
services->setPixelShaderConstant("animationTimer", &animation_timer_f, 1); services->setPixelShaderConstant("animationTimer", &animation_timer_f, 1);
@ -1034,7 +1034,7 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec,
LocalFormspecHandler* txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU"); LocalFormspecHandler* txt_dst = new LocalFormspecHandler("MT_PAUSE_MENU");
create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device, fs_src, txt_dst); create_formspec_menu(cur_formspec, invmgr, gamedef, tsrc, device, fs_src, txt_dst);
if (singleplayermode) { if (singleplayermode) {
(*cur_formspec)->doPause = true; (*cur_formspec)->doPause = true;
} }
@ -1052,7 +1052,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
GUIFormSpecMenu* current_formspec = 0; GUIFormSpecMenu* current_formspec = 0;
video::IVideoDriver* driver = device->getVideoDriver(); video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
// Calculate text height using the font // Calculate text height using the font
u32 text_height = font->getDimension(L"Random test string").Height; u32 text_height = font->getDimension(L"Random test string").Height;
@ -1065,19 +1065,19 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
draw_load_screen(text, device, guienv, font, 0, 0); draw_load_screen(text, device, guienv, font, 0, 0);
delete[] text; delete[] text;
} }
// Create texture source // Create texture source
IWritableTextureSource *tsrc = createTextureSource(device); IWritableTextureSource *tsrc = createTextureSource(device);
// Create shader source // Create shader source
IWritableShaderSource *shsrc = createShaderSource(device); IWritableShaderSource *shsrc = createShaderSource(device);
// These will be filled by data received from the server // These will be filled by data received from the server
// Create item definition manager // Create item definition manager
IWritableItemDefManager *itemdef = createItemDefManager(); IWritableItemDefManager *itemdef = createItemDefManager();
// Create node definition manager // Create node definition manager
IWritableNodeDefManager *nodedef = createNodeDefManager(); IWritableNodeDefManager *nodedef = createNodeDefManager();
// Sound fetcher (useful when testing) // Sound fetcher (useful when testing)
GameOnDemandSoundFetcher soundfetcher; GameOnDemandSoundFetcher soundfetcher;
@ -1109,7 +1109,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
// Sound maker // Sound maker
SoundMaker soundmaker(sound, nodedef); SoundMaker soundmaker(sound, nodedef);
soundmaker.registerReceiver(&eventmgr); soundmaker.registerReceiver(&eventmgr);
// Add chat log output for errors to be shown in chat // Add chat log output for errors to be shown in chat
LogOutputBuffer chat_log_error_buf(LMT_ERROR); LogOutputBuffer chat_log_error_buf(LMT_ERROR);
@ -1158,7 +1158,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
} }
do{ // Client scope (breakable do-while(0)) do{ // Client scope (breakable do-while(0))
/* /*
Create client Create client
*/ */
@ -1169,9 +1169,9 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
delete[] text; delete[] text;
} }
infostream<<"Creating client"<<std::endl; infostream<<"Creating client"<<std::endl;
MapDrawControl draw_control; MapDrawControl draw_control;
{ {
wchar_t* text = wgettext("Resolving address..."); wchar_t* text = wgettext("Resolving address...");
draw_load_screen(text, device, guienv, font, 0, 75); draw_load_screen(text, device, guienv, font, 0, 75);
@ -1205,26 +1205,26 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
// Break out of client scope // Break out of client scope
break; break;
} }
/* /*
Create client Create client
*/ */
Client client(device, playername.c_str(), password, draw_control, Client client(device, playername.c_str(), password, draw_control,
tsrc, shsrc, itemdef, nodedef, sound, &eventmgr, tsrc, shsrc, itemdef, nodedef, sound, &eventmgr,
connect_address.isIPv6()); connect_address.isIPv6());
// Client acts as our GameDef // Client acts as our GameDef
IGameDef *gamedef = &client; IGameDef *gamedef = &client;
/* /*
Attempt to connect to the server Attempt to connect to the server
*/ */
infostream<<"Connecting to server at "; infostream<<"Connecting to server at ";
connect_address.print(&infostream); connect_address.print(&infostream);
infostream<<std::endl; infostream<<std::endl;
client.connect(connect_address); client.connect(connect_address);
/* /*
Wait for server to accept connection Wait for server to accept connection
*/ */
@ -1251,7 +1251,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
client.step(dtime); client.step(dtime);
if(server != NULL) if(server != NULL)
server->step(dtime); server->step(dtime);
// End condition // End condition
if(client.getState() == LC_Init){ if(client.getState() == LC_Init){
could_connect = true; could_connect = true;
@ -1269,14 +1269,14 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
infostream<<"Connect aborted [Escape]"<<std::endl; infostream<<"Connect aborted [Escape]"<<std::endl;
break; break;
} }
// Display status // Display status
{ {
wchar_t* text = wgettext("Connecting to server..."); wchar_t* text = wgettext("Connecting to server...");
draw_load_screen(text, device, guienv, font, dtime, 100); draw_load_screen(text, device, guienv, font, dtime, 100);
delete[] text; delete[] text;
} }
// On some computers framerate doesn't seem to be // On some computers framerate doesn't seem to be
// automatically limited // automatically limited
if (cloud_menu_background) { if (cloud_menu_background) {
@ -1306,7 +1306,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
} }
catch(con::PeerNotFoundException &e) catch(con::PeerNotFoundException &e)
{} {}
/* /*
Handle failure to connect Handle failure to connect
*/ */
@ -1318,7 +1318,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
// Break out of client scope // Break out of client scope
break; break;
} }
/* /*
Wait until content has been received Wait until content has been received
*/ */
@ -1345,7 +1345,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
client.step(dtime); client.step(dtime);
if(server != NULL) if(server != NULL)
server->step(dtime); server->step(dtime);
// End condition // End condition
if(client.mediaReceived() && if(client.mediaReceived() &&
client.itemdefReceived() && client.itemdefReceived() &&
@ -1370,7 +1370,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
infostream<<"Connect aborted [Escape]"<<std::endl; infostream<<"Connect aborted [Escape]"<<std::endl;
break; break;
} }
// Display status // Display status
int progress=0; int progress=0;
if (!client.itemdefReceived()) if (!client.itemdefReceived())
@ -1409,7 +1409,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
draw_load_screen(narrow_to_wide(message.str().c_str()), device, draw_load_screen(narrow_to_wide(message.str().c_str()), device,
guienv, font, dtime, progress); guienv, font, dtime, progress);
} }
// On some computers framerate doesn't seem to be // On some computers framerate doesn't seem to be
// automatically limited // automatically limited
if (cloud_menu_background) { if (cloud_menu_background) {
@ -1466,7 +1466,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Clouds Clouds
*/ */
Clouds *clouds = NULL; Clouds *clouds = NULL;
if(g_settings->getBool("enable_clouds")) if(g_settings->getBool("enable_clouds"))
{ {
@ -1481,7 +1481,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
sky = new Sky(smgr->getRootSceneNode(), smgr, -1); sky = new Sky(smgr->getRootSceneNode(), smgr, -1);
scene::ISceneNode* skybox = NULL; scene::ISceneNode* skybox = NULL;
/* /*
A copy of the local inventory A copy of the local inventory
*/ */
@ -1517,17 +1517,17 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
L"", L"",
core::rect<s32>(0,0,400,text_height*5+5) + v2s32(100,200), core::rect<s32>(0,0,400,text_height*5+5) + v2s32(100,200),
false, true); false, true);
// Status text (displays info when showing and hiding GUI stuff, etc.) // Status text (displays info when showing and hiding GUI stuff, etc.)
gui::IGUIStaticText *guitext_status = guienv->addStaticText( gui::IGUIStaticText *guitext_status = guienv->addStaticText(
L"<Status>", L"<Status>",
core::rect<s32>(0,0,0,0), core::rect<s32>(0,0,0,0),
false, false); false, false);
guitext_status->setVisible(false); guitext_status->setVisible(false);
std::wstring statustext; std::wstring statustext;
float statustext_time = 0; float statustext_time = 0;
// Chat text // Chat text
gui::IGUIStaticText *guitext_chat = guienv->addStaticText( gui::IGUIStaticText *guitext_chat = guienv->addStaticText(
L"", L"",
@ -1538,7 +1538,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
chat_backend.clearRecentChat(); chat_backend.clearRecentChat();
// Chat backend and console // Chat backend and console
GUIChatConsole *gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(), -1, &chat_backend, &client); GUIChatConsole *gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(), -1, &chat_backend, &client);
// Profiler text (size is updated when text is updated) // Profiler text (size is updated when text is updated)
gui::IGUIStaticText *guitext_profiler = guienv->addStaticText( gui::IGUIStaticText *guitext_profiler = guienv->addStaticText(
L"<Profiler>", L"<Profiler>",
@ -1547,16 +1547,16 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
guitext_profiler->setBackgroundColor(video::SColor(120,0,0,0)); guitext_profiler->setBackgroundColor(video::SColor(120,0,0,0));
guitext_profiler->setVisible(false); guitext_profiler->setVisible(false);
guitext_profiler->setWordWrap(true); guitext_profiler->setWordWrap(true);
/* /*
Some statistics are collected in these Some statistics are collected in these
*/ */
u32 drawtime = 0; u32 drawtime = 0;
u32 beginscenetime = 0; u32 beginscenetime = 0;
u32 endscenetime = 0; u32 endscenetime = 0;
float recent_turn_speed = 0.0; float recent_turn_speed = 0.0;
ProfilerGraph graph; ProfilerGraph graph;
// Initially clear the profiler // Initially clear the profiler
Profiler::GraphValues dummyvalues; Profiler::GraphValues dummyvalues;
@ -1624,7 +1624,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
LocalPlayer* player = client.getEnv().getLocalPlayer(); LocalPlayer* player = client.getEnv().getLocalPlayer();
player->hurt_tilt_timer = 0; player->hurt_tilt_timer = 0;
player->hurt_tilt_strength = 0; player->hurt_tilt_strength = 0;
/* /*
HUD object HUD object
*/ */
@ -1658,7 +1658,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
busytime_u32 = 0; busytime_u32 = 0;
busytime = busytime_u32 / 1000.0; busytime = busytime_u32 / 1000.0;
} }
g_profiler->graphAdd("mainloop_other", busytime - (float)drawtime/1000.0f); g_profiler->graphAdd("mainloop_other", busytime - (float)drawtime/1000.0f);
// Necessary for device->getTimer()->getTime() // Necessary for device->getTimer()->getTime()
@ -1673,7 +1673,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
g_settings->getFloat("pause_fps_max") : g_settings->getFloat("pause_fps_max") :
g_settings->getFloat("fps_max"); g_settings->getFloat("fps_max");
u32 frametime_min = 1000./fps_max; u32 frametime_min = 1000./fps_max;
if(busytime_u32 < frametime_min) if(busytime_u32 < frametime_min)
{ {
u32 sleeptime = frametime_min - busytime_u32; u32 sleeptime = frametime_min - busytime_u32;
@ -1689,7 +1689,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
Time difference calculation Time difference calculation
*/ */
f32 dtime; // in seconds f32 dtime; // in seconds
u32 time = device->getTimer()->getTime(); u32 time = device->getTimer()->getTime();
if(time > lasttime) if(time > lasttime)
dtime = (time - lasttime) / 1000.0; dtime = (time - lasttime) / 1000.0;
@ -1706,7 +1706,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
if(object_hit_delay_timer >= 0) if(object_hit_delay_timer >= 0)
object_hit_delay_timer -= dtime; object_hit_delay_timer -= dtime;
time_from_last_punch += dtime; time_from_last_punch += dtime;
g_profiler->add("Elapsed time", dtime); g_profiler->add("Elapsed time", dtime);
g_profiler->avg("FPS", 1./dtime); g_profiler->avg("FPS", 1./dtime);
@ -1735,7 +1735,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
jitter1_max = 0.0; jitter1_max = 0.0;
} }
} }
/* /*
Busytime average and jitter calculation Busytime average and jitter calculation
*/ */
@ -1743,7 +1743,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
static f32 busytime_avg1 = 0.0; static f32 busytime_avg1 = 0.0;
busytime_avg1 = busytime_avg1 * 0.98 + busytime * 0.02; busytime_avg1 = busytime_avg1 * 0.98 + busytime * 0.02;
f32 busytime_jitter1 = busytime - busytime_avg1; f32 busytime_jitter1 = busytime - busytime_avg1;
static f32 busytime_jitter1_max_sample = 0.0; static f32 busytime_jitter1_max_sample = 0.0;
static f32 busytime_jitter1_min_sample = 0.0; static f32 busytime_jitter1_min_sample = 0.0;
{ {
@ -1767,7 +1767,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Handle miscellaneous stuff Handle miscellaneous stuff
*/ */
if(client.accessDenied()) if(client.accessDenied())
{ {
error_message = L"Access denied. Reason: " error_message = L"Access denied. Reason: "
@ -1811,7 +1811,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
Random calculations Random calculations
*/ */
hud.resizeHotbar(); hud.resizeHotbar();
// Hilight boxes collected during the loop and displayed // Hilight boxes collected during the loop and displayed
std::vector<aabb3f> hilightboxes; std::vector<aabb3f> hilightboxes;
@ -1843,7 +1843,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Direct handling of user input Direct handling of user input
*/ */
// Reset input if window not active or some menu is active // Reset input if window not active or some menu is active
if(device->isWindowActive() == false if(device->isWindowActive() == false
|| noMenuActive() == false || noMenuActive() == false
@ -1880,7 +1880,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
{ {
infostream<<"the_game: " infostream<<"the_game: "
<<"Launching inventory"<<std::endl; <<"Launching inventory"<<std::endl;
PlayerInventoryFormSource* fs_src = new PlayerInventoryFormSource(&client); PlayerInventoryFormSource* fs_src = new PlayerInventoryFormSource(&client);
TextDest* txt_dst = new TextDestPlayerInventory(&client); TextDest* txt_dst = new TextDestPlayerInventory(&client);
@ -2113,7 +2113,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
+ itos(range_new)); + itos(range_new));
statustext_time = 0; statustext_time = 0;
} }
// Reset jump_timer // Reset jump_timer
if(!input->isKeyDown(getKeySetting("keymap_jump")) && reset_jump_timer) if(!input->isKeyDown(getKeySetting("keymap_jump")) && reset_jump_timer)
{ {
@ -2160,7 +2160,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
new_playeritem = max_item; new_playeritem = max_item;
} }
} }
// Item selection // Item selection
for(u16 i=0; i<10; i++) for(u16 i=0; i<10; i++)
{ {
@ -2210,7 +2210,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
Mouse and camera control Mouse and camera control
NOTE: Do this before client.setPlayerControl() to not cause a camera lag of one frame NOTE: Do this before client.setPlayerControl() to not cause a camera lag of one frame
*/ */
float turn_amount = 0; float turn_amount = 0;
if((device->isWindowActive() && noMenuActive()) || random_input) if((device->isWindowActive() && noMenuActive()) || random_input)
{ {
@ -2232,7 +2232,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
dy = -dy; dy = -dy;
} }
//infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl; //infostream<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
/*const float keyspeed = 500; /*const float keyspeed = 500;
if(input->isKeyDown(irr::KEY_UP)) if(input->isKeyDown(irr::KEY_UP))
dy -= dtime * keyspeed; dy -= dtime * keyspeed;
@ -2242,14 +2242,14 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
dx -= dtime * keyspeed; dx -= dtime * keyspeed;
if(input->isKeyDown(irr::KEY_RIGHT)) if(input->isKeyDown(irr::KEY_RIGHT))
dx += dtime * keyspeed;*/ dx += dtime * keyspeed;*/
float d = g_settings->getFloat("mouse_sensitivity"); float d = g_settings->getFloat("mouse_sensitivity");
d = rangelim(d, 0.01, 100.0); d = rangelim(d, 0.01, 100.0);
camera_yaw -= dx*d; camera_yaw -= dx*d;
camera_pitch += dy*d; camera_pitch += dy*d;
if(camera_pitch < -89.5) camera_pitch = -89.5; if(camera_pitch < -89.5) camera_pitch = -89.5;
if(camera_pitch > 89.5) camera_pitch = 89.5; if(camera_pitch > 89.5) camera_pitch = 89.5;
turn_amount = v2f(dx, dy).getLength() * d; turn_amount = v2f(dx, dy).getLength() * d;
} }
input->setMousePos((driver->getScreenSize().Width/2), input->setMousePos((driver->getScreenSize().Width/2),
@ -2442,7 +2442,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
delete event.hudadd.size; delete event.hudadd.size;
continue; continue;
} }
e = new HudElement; e = new HudElement;
e->type = (HudElementType)event.hudadd.type; e->type = (HudElementType)event.hudadd.type;
e->pos = *event.hudadd.pos; e->pos = *event.hudadd.pos;
@ -2456,7 +2456,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
e->offset = *event.hudadd.offset; e->offset = *event.hudadd.offset;
e->world_pos = *event.hudadd.world_pos; e->world_pos = *event.hudadd.world_pos;
e->size = *event.hudadd.size; e->size = *event.hudadd.size;
u32 new_id = player->addHud(e); u32 new_id = player->addHud(e);
//if this isn't true our huds aren't consistent //if this isn't true our huds aren't consistent
assert(new_id == id); assert(new_id == id);
@ -2487,7 +2487,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
delete event.hudchange.v2s32data; delete event.hudchange.v2s32data;
continue; continue;
} }
switch (event.hudchange.stat) { switch (event.hudchange.stat) {
case HUD_STAT_POS: case HUD_STAT_POS:
e->pos = *event.hudchange.v2fdata; e->pos = *event.hudchange.v2fdata;
@ -2523,7 +2523,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
e->size = *event.hudchange.v2s32data; e->size = *event.hudchange.v2s32data;
break; break;
} }
delete event.hudchange.v3fdata; delete event.hudchange.v3fdata;
delete event.hudchange.v2fdata; delete event.hudchange.v2fdata;
delete event.hudchange.sdata; delete event.hudchange.sdata;
@ -2569,7 +2569,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
} }
} }
} }
//TimeTaker //timer2("//timer2"); //TimeTaker //timer2("//timer2");
/* /*
@ -2590,7 +2590,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
playeritem.getDefinition(itemdef); playeritem.getDefinition(itemdef);
ToolCapabilities playeritem_toolcap = ToolCapabilities playeritem_toolcap =
playeritem.getToolCapabilities(itemdef); playeritem.getToolCapabilities(itemdef);
/* /*
Update camera Update camera
*/ */
@ -2625,7 +2625,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
v3s16 camera_offset = camera.getOffset(); v3s16 camera_offset = camera.getOffset();
bool camera_offset_changed = (camera_offset != old_camera_offset); bool camera_offset_changed = (camera_offset != old_camera_offset);
if(!disable_camera_update){ if(!disable_camera_update){
client.getEnv().getClientMap().updateCamera(camera_position, client.getEnv().getClientMap().updateCamera(camera_position,
camera_direction, camera_fov, camera_offset); camera_direction, camera_fov, camera_offset);
@ -2636,7 +2636,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
clouds->updateCameraOffset(camera_offset); clouds->updateCameraOffset(camera_offset);
} }
} }
// Update sound listener // Update sound listener
sound->updateListener(camera.getCameraNode()->getPosition()+intToFloat(camera_offset, BS), sound->updateListener(camera.getCameraNode()->getPosition()+intToFloat(camera_offset, BS),
v3f(0,0,0), // velocity v3f(0,0,0), // velocity
@ -2649,7 +2649,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
*/ */
{ {
soundmaker.step(dtime); soundmaker.step(dtime);
ClientMap &map = client.getEnv().getClientMap(); ClientMap &map = client.getEnv().getClientMap();
MapNode n = map.getNodeNoEx(player->getStandingNodePos()); MapNode n = map.getNodeNoEx(player->getStandingNodePos());
soundmaker.m_player_step_sound = nodedef->get(n).sound_footstep; soundmaker.m_player_step_sound = nodedef->get(n).sound_footstep;
@ -2658,9 +2658,9 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Calculate what block is the crosshair pointing to Calculate what block is the crosshair pointing to
*/ */
//u32 t1 = device->getTimer()->getRealTime(); //u32 t1 = device->getTimer()->getRealTime();
f32 d = playeritem_def.range; // max. distance f32 d = playeritem_def.range; // max. distance
f32 d_hand = itemdef->get("").range; f32 d_hand = itemdef->get("").range;
if(d < 0 && d_hand >= 0) if(d < 0 && d_hand >= 0)
@ -2754,7 +2754,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Check information text of node Check information text of node
*/ */
ClientMap &map = client.getEnv().getClientMap(); ClientMap &map = client.getEnv().getClientMap();
NodeMetadata *meta = map.getNodeMetadata(nodepos); NodeMetadata *meta = map.getNodeMetadata(nodepos);
if(meta){ if(meta){
@ -2766,11 +2766,11 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
infotext += narrow_to_wide(nodedef->get(n).name); infotext += narrow_to_wide(nodedef->get(n).name);
} }
} }
/* /*
Handle digging Handle digging
*/ */
if(nodig_delay_timer <= 0.0 && input->getLeftState() if(nodig_delay_timer <= 0.0 && input->getLeftState()
&& client.checkPrivilege("interact")) && client.checkPrivilege("interact"))
{ {
@ -2782,7 +2782,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
ldown_for_dig = true; ldown_for_dig = true;
} }
MapNode n = client.getEnv().getClientMap().getNode(nodepos); MapNode n = client.getEnv().getClientMap().getNode(nodepos);
// NOTE: Similar piece of code exists on the server side for // NOTE: Similar piece of code exists on the server side for
// cheat detection. // cheat detection.
// Get digging parameters // Get digging parameters
@ -2883,7 +2883,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
float mindelay = 0.15; float mindelay = 0.15;
if(nodig_delay_timer < mindelay) if(nodig_delay_timer < mindelay)
nodig_delay_timer = mindelay; nodig_delay_timer = mindelay;
// Send event to trigger sound // Send event to trigger sound
MtEvent *e = new NodeDugEvent(nodepos, wasnode); MtEvent *e = new NodeDugEvent(nodepos, wasnode);
gamedef->event()->put(e); gamedef->event()->put(e);
@ -2906,7 +2906,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
{ {
repeat_rightclick_timer = 0; repeat_rightclick_timer = 0;
infostream<<"Ground right-clicked"<<std::endl; infostream<<"Ground right-clicked"<<std::endl;
// Sign special case, at least until formspec is properly implemented. // Sign special case, at least until formspec is properly implemented.
// Deprecated? // Deprecated?
if(meta && meta->getString("formspec") == "hack:sign_text_input" if(meta && meta->getString("formspec") == "hack:sign_text_input"
@ -2914,7 +2914,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
&& !input->isKeyDown(getKeySetting("keymap_sneak"))) && !input->isKeyDown(getKeySetting("keymap_sneak")))
{ {
infostream<<"Launching metadata text input"<<std::endl; infostream<<"Launching metadata text input"<<std::endl;
// Get a new text for it // Get a new text for it
TextDest *dest = new TextDestNodeMetadata(nodepos, &client); TextDest *dest = new TextDestNodeMetadata(nodepos, &client);
@ -2933,7 +2933,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
InventoryLocation inventoryloc; InventoryLocation inventoryloc;
inventoryloc.setNodeMeta(nodepos); inventoryloc.setNodeMeta(nodepos);
NodeMetadataFormSource* fs_src = new NodeMetadataFormSource( NodeMetadataFormSource* fs_src = new NodeMetadataFormSource(
&client.getEnv().getClientMap(), nodepos); &client.getEnv().getClientMap(), nodepos);
TextDest* txt_dst = new TextDestNodeMetadata(nodepos, &client); TextDest* txt_dst = new TextDestNodeMetadata(nodepos, &client);
@ -3000,7 +3000,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
// Report direct punch // Report direct punch
v3f objpos = selected_object->getPosition(); v3f objpos = selected_object->getPosition();
v3f dir = (objpos - player_position).normalize(); v3f dir = (objpos - player_position).normalize();
bool disable_send = selected_object->directReportPunch( bool disable_send = selected_object->directReportPunch(
dir, &playeritem, time_from_last_punch); dir, &playeritem, time_from_last_punch);
time_from_last_punch = 0; time_from_last_punch = 0;
@ -3021,7 +3021,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
} }
pointed_old = pointed; pointed_old = pointed;
if(left_punch || input->getLeftClicked()) if(left_punch || input->getLeftClicked())
{ {
camera.setDigging(0); // left click animation camera.setDigging(0); // left click animation
@ -3032,7 +3032,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
input->resetLeftReleased(); input->resetLeftReleased();
input->resetRightReleased(); input->resetRightReleased();
/* /*
Calculate stuff for drawing Calculate stuff for drawing
*/ */
@ -3040,7 +3040,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Fog range Fog range
*/ */
if(draw_control.range_all) if(draw_control.range_all)
fog_range = 100000*BS; fog_range = 100000*BS;
else { else {
@ -3067,7 +3067,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
daynight_ratio, (int)(old_brightness*255.5), &sunlight_seen) daynight_ratio, (int)(old_brightness*255.5), &sunlight_seen)
/ 255.0; / 255.0;
} }
time_of_day = client.getEnv().getTimeOfDayF(); time_of_day = client.getEnv().getTimeOfDayF();
float maxsm = 0.05; float maxsm = 0.05;
if(fabs(time_of_day - time_of_day_smooth) > maxsm && if(fabs(time_of_day - time_of_day_smooth) > maxsm &&
@ -3081,11 +3081,11 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
else else
time_of_day_smooth = time_of_day_smooth * (1.0-todsm) time_of_day_smooth = time_of_day_smooth * (1.0-todsm)
+ time_of_day * todsm; + time_of_day * todsm;
sky->update(time_of_day_smooth, time_brightness, direct_brightness, sky->update(time_of_day_smooth, time_brightness, direct_brightness,
sunlight_seen,camera.getCameraMode(), player->getYaw(), sunlight_seen,camera.getCameraMode(), player->getYaw(),
player->getPitch()); player->getPitch());
video::SColor bgcolor = sky->getBgColor(); video::SColor bgcolor = sky->getBgColor();
video::SColor skycolor = sky->getSkyColor(); video::SColor skycolor = sky->getSkyColor();
@ -3102,18 +3102,18 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
clouds->setVisible(false); clouds->setVisible(false);
} }
} }
/* /*
Update particles Update particles
*/ */
allparticles_step(dtime); allparticles_step(dtime);
allparticlespawners_step(dtime, client.getEnv()); allparticlespawners_step(dtime, client.getEnv());
/* /*
Fog Fog
*/ */
if(g_settings->getBool("enable_fog") && !force_fog_off) if(g_settings->getBool("enable_fog") && !force_fog_off)
{ {
driver->setFog( driver->setFog(
@ -3144,7 +3144,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
*/ */
//TimeTaker guiupdatetimer("Gui updating"); //TimeTaker guiupdatetimer("Gui updating");
if(show_debug) if(show_debug)
{ {
static float drawtime_avg = 0; static float drawtime_avg = 0;
@ -3223,7 +3223,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
{ {
guitext2->setVisible(false); guitext2->setVisible(false);
} }
{ {
guitext_info->setText(infotext.c_str()); guitext_info->setText(infotext.c_str());
guitext_info->setVisible(show_hud && g_menumgr.menuCount() == 0); guitext_info->setVisible(show_hud && g_menumgr.menuCount() == 0);
@ -3269,7 +3269,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
guitext_status->enableOverrideColor(true); guitext_status->enableOverrideColor(true);
} }
} }
/* /*
Get chat messages from client Get chat messages from client
*/ */
@ -3314,7 +3314,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
/* /*
Inventory Inventory
*/ */
if(client.getPlayerItem() != new_playeritem) if(client.getPlayerItem() != new_playeritem)
{ {
client.selectPlayerItem(new_playeritem); client.selectPlayerItem(new_playeritem);
@ -3323,7 +3323,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
{ {
//infostream<<"Updating local inventory"<<std::endl; //infostream<<"Updating local inventory"<<std::endl;
client.getLocalInventory(local_inventory); client.getLocalInventory(local_inventory);
update_wielded_item_trigger = true; update_wielded_item_trigger = true;
} }
if(update_wielded_item_trigger) if(update_wielded_item_trigger)
@ -3360,17 +3360,10 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
beginscenetime = timer.stop(true); beginscenetime = timer.stop(true);
} }
draw_scene(driver, smgr, camera, client, player, hud, guienv, draw_scene(driver, smgr, camera, client, player, hud, guienv,
hilightboxes, screensize, skycolor, show_hud); hilightboxes, screensize, skycolor, show_hud);
/*
Post effects
*/
{
client.getEnv().getClientMap().renderPostFx(camera.getCameraMode());
}
/* /*
Profiler graph Profiler graph
*/ */
@ -3388,7 +3381,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
driver->draw2DRectangle(color, driver->draw2DRectangle(color,
core::rect<s32>(0,0,screensize.X,screensize.Y), core::rect<s32>(0,0,screensize.X,screensize.Y),
NULL); NULL);
damage_flash -= 100.0*dtime; damage_flash -= 100.0*dtime;
} }
@ -3436,7 +3429,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
if (sky) if (sky)
sky->drop(); sky->drop();
clear_particles(); clear_particles();
/* cleanup menus */ /* cleanup menus */
while (g_menumgr.menuCount() > 0) while (g_menumgr.menuCount() > 0)
{ {
@ -3486,7 +3479,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
} }
if(!sound_is_dummy) if(!sound_is_dummy)
delete sound; delete sound;