Skip to content

Commit 7b74f04

Browse files
authoredMar 17, 2017
[CSM] Fix minimap problems (#5405)
This fixes issue #5404
1 parent 0891975 commit 7b74f04

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed
 

‎clientmods/preview/init.lua

+6-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ core.register_chatcommand("test_node", {
4949

5050
local function preview_minimap()
5151
local minimap = core.ui.minimap
52-
minimap:show()
5352
minimap:set_mode(4)
53+
minimap:show()
5454
minimap:set_pos({x=5, y=50, z=5})
5555
minimap:toggle_shape()
5656

@@ -61,9 +61,13 @@ end
6161

6262
core.after(2, function()
6363
print("[PREVIEW] loaded " .. modname .. " mod")
64-
preview_minimap()
6564
modstorage:set_string("current_mod", modname)
6665
print(modstorage:get_string("current_mod"))
66+
preview_minimap()
67+
end)
68+
69+
core.after(5, function()
70+
core.ui.minimap:show()
6771

6872
print("[PREVIEW] Day count: " .. core.get_day_count() ..
6973
" time of day " .. core.get_timeofday())

‎src/client.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ Client::Client(
224224
m_device(device),
225225
m_camera(NULL),
226226
m_minimap_disabled_by_server(false),
227-
m_minimap_shown_by_mod(false),
228227
m_server_ser_ver(SER_FMT_VER_INVALID),
229228
m_proto_ver(0),
230229
m_playeritem(0),
@@ -1933,11 +1932,7 @@ void Client::makeScreenshot(IrrlichtDevice *device)
19331932

19341933
bool Client::shouldShowMinimap() const
19351934
{
1936-
if (m_minimap_disabled_by_server) {
1937-
return false;
1938-
}
1939-
1940-
return m_minimap_shown_by_mod;
1935+
return !m_minimap_disabled_by_server;
19411936
}
19421937

19431938
// IGameDef interface

‎src/client.h

-2
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
532532
{ return m_camera; }
533533

534534
bool shouldShowMinimap() const;
535-
void setMinimapShownByMod(bool state) { m_minimap_shown_by_mod = state; }
536535

537536
// IGameDef interface
538537
virtual IItemDefManager* getItemDefManager();
@@ -634,7 +633,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
634633
Camera *m_camera;
635634
Minimap *m_minimap;
636635
bool m_minimap_disabled_by_server;
637-
bool m_minimap_shown_by_mod;
638636
// Server serialization version
639637
u8 m_server_ser_ver;
640638

‎src/game.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,7 @@ void Game::run()
17691769
updateProfilerGraphs(&graph);
17701770

17711771
// Update if minimap has been disabled by the server
1772-
flags.show_minimap = client->shouldShowMinimap();
1772+
flags.show_minimap &= client->shouldShowMinimap();
17731773
}
17741774
}
17751775

‎src/script/lua_api/l_minimap.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,21 @@ int LuaMinimap::l_toggle_shape(lua_State *L)
118118

119119
int LuaMinimap::l_show(lua_State *L)
120120
{
121-
Client *client = getClient(L);
122-
assert(client);
123-
client->setMinimapShownByMod(true);
121+
LuaMinimap *ref = checkobject(L, 1);
122+
Minimap *m = getobject(ref);
123+
124+
if (m->getMinimapMode() == MINIMAP_MODE_OFF)
125+
m->setMinimapMode(MINIMAP_MODE_SURFACEx1);
124126
return 1;
125127
}
126128

127129
int LuaMinimap::l_hide(lua_State *L)
128130
{
129-
Client *client = getClient(L);
130-
assert(client);
131-
client->setMinimapShownByMod(false);
131+
LuaMinimap *ref = checkobject(L, 1);
132+
Minimap *m = getobject(ref);
133+
134+
if (m->getMinimapMode() != MINIMAP_MODE_OFF)
135+
m->setMinimapMode(MINIMAP_MODE_OFF);
132136
return 1;
133137
}
134138

0 commit comments

Comments
 (0)
Please sign in to comment.