Very big update! MultiCraft 1.1 | Part 1/3

Joystick.
environment.cpp improve (thanks @Bremaweb)
Improving the management interface.
The new font.
Settings to improve performance.
Improvements ellementov size on larger phones.
A lot of small fixes and improvements.
This commit is contained in:
Maksim Gamarnik 2016-02-07 03:11:12 +02:00
parent 4327fab167
commit 1ac7f0dbc5
8 changed files with 128 additions and 131 deletions

View File

@ -27,13 +27,13 @@ VERSION_PATCH := $(shell cat $(ROOT)/../../CMakeLists.txt | \
ANDROID_VERSION_CODE = 1
################################################################################
# toolchain config for arm new processors
# toolchain config for ARMv7
################################################################################
TARGET_HOST = arm-linux
TARGET_ABI = armeabi-v7a
TARGET_LIBDIR = armeabi-v7a
TARGET_TOOLCHAIN = arm-linux-androideabi-
TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -O3
TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -Ofast
TARGET_CXXFLAGS_ADDON = $(TARGET_CFLAGS_ADDON)
TARGET_ARCH = armv7
CROSS_PREFIX = arm-linux-androideabi-
@ -839,4 +839,4 @@ manifest :
clean_manifest :
rm -rf ${ROOT}/AndroidManifest.xml
clean : clean_apk clean_assets
clean : clean_apk clean_assets

View File

@ -80,7 +80,7 @@ LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
ifndef NDEBUG
LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer
else
LOCAL_CFLAGS += -fexpensive-optimizations -O3
LOCAL_CFLAGS += -O3
endif
ifdef GPROF

View File

@ -391,6 +391,7 @@ void RemoteClient::SentBlock(v3s16 p)
void RemoteClient::SetBlockNotSent(v3s16 p)
{
m_nearest_unsent_d = 0;
m_nothing_to_send_pause_timer = 0.1;
if(m_blocks_sending.find(p) != m_blocks_sending.end())
m_blocks_sending.erase(p);
@ -401,6 +402,7 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
{
m_nearest_unsent_d = 0;
m_nothing_to_send_pause_timer=0.1;
for(std::map<v3s16, MapBlock*>::iterator
i = blocks.begin();

View File

@ -129,14 +129,14 @@ void set_default_settings(Settings *settings)
settings->setDefault("view_bobbing_amount", "1.0");
settings->setDefault("fall_bobbing_amount", "1.0");
settings->setDefault("enable_3d_clouds", "true");
settings->setDefault("cloud_height", "120");
settings->setDefault("cloud_height", "180");
settings->setDefault("cloud_radius", "12");
settings->setDefault("menu_clouds", "false");
settings->setDefault("opaque_water", "false");
settings->setDefault("console_color", "(0,0,0)");
settings->setDefault("console_alpha", "200");
settings->setDefault("selectionbox_color", "(0,0,0)");
settings->setDefault("enable_node_highlighting", "false");
settings->setDefault("enable_node_highlighting", "true");
settings->setDefault("crosshair_color", "(255,255,255)");
settings->setDefault("crosshair_alpha", "255");
settings->setDefault("hud_scaling", "1.0");
@ -150,7 +150,6 @@ void set_default_settings(Settings *settings)
settings->setDefault("selectionbox_width","2");
settings->setDefault("hud_hotbar_max_width","1.0");
settings->setDefault("enable_local_map_saving", "false");
settings->setDefault("screen_dpi", "72");
settings->setDefault("mip_map", "false");
settings->setDefault("anisotropic_filter", "false");
@ -201,7 +200,7 @@ void set_default_settings(Settings *settings)
#if USE_FREETYPE
settings->setDefault("freetype", "true");
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "liberationsans.ttf"));
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "basis33.ttf"));
settings->setDefault("font_shadow", "1");
settings->setDefault("font_shadow_alpha", "128");
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "liberationmono.ttf"));
@ -234,7 +233,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("max_packets_per_iteration","1024");
settings->setDefault("port", "30000");
settings->setDefault("bind_address", "");
settings->setDefault("default_game", "MultiCraft_game");
settings->setDefault("default_game", "default");
settings->setDefault("motd", "");
settings->setDefault("max_users", "15");
settings->setDefault("strict_protocol_version_checking", "false");
@ -285,7 +284,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("emergequeue_limit_total", "256");
settings->setDefault("emergequeue_limit_diskonly", "32");
settings->setDefault("emergequeue_limit_generate", "32");
settings->setDefault("num_emerge_threads", "1");
settings->setDefault("num_emerge_threads", "2");
settings->setDefault("secure.enable_security", "false");
settings->setDefault("secure.trusted_mods", "");
@ -340,26 +339,32 @@ void set_default_settings(Settings *settings)
settings->setDefault("TMPFolder","/sdcard/tmp/");
settings->setDefault("touchscreen_threshold","20");
settings->setDefault("smooth_lighting", "false");
settings->setDefault("emergequeue_limit_diskonly", "4");
settings->setDefault("emergequeue_limit_generate", "4");
settings->setDefault("emergequeue_limit_diskonly", "8");
settings->setDefault("emergequeue_limit_generate", "8");
settings->setDefault("max_block_generate_distance", "3");
settings->setDefault("preload_item_visuals", "false");
settings->setDefault("viewing_range_nodes_max", "50");
settings->setDefault("viewing_range_nodes_min", "5");
settings->setDefault("enable_node_highlighting", "true");
settings->setDefault("inventory_image_hack", "true");
settings->setDefault("mouse_sensitivity", "0.05");
settings->setDefault("enable_3d_clouds", "false");
settings->setDefault("wanted_fps", "25");
settings->setDefault("fps_max", "35");
settings->setDefault("pause_fps_max", "10");
float x_inches = ((double) porting::getDisplaySize().X /
(160 * porting::getDisplayDensity()));
if (x_inches < 4.5) {
settings->setDefault("hud_scaling", "0.7");
}
settings->setDefault("max_objects_per_block", "32");
settings->setDefault("sqlite_synchronous", "1");
settings->setDefault("screen_dpi", "72");
settings->setDefault("gui_scaling", "1.1");
settings->setDefault("curl_verify_cert","false");
//check for device with small screen
float x_inches = ((double) porting::getDisplaySize().X /
(160 * porting::getDisplayDensity()));
if (x_inches < 3.5) {
settings->setDefault("hud_scaling", "0.6");
}
else if (x_inches < 5) {
settings->setDefault("hud_scaling", "0.7");
}
#endif
}

View File

@ -1114,12 +1114,16 @@ void ServerEnvironment::step(float dtime)
/*
Mess around in active blocks
*/
const float abm_interval = 1.0;
if(m_active_blocks_nodemetadata_interval.step(dtime, 1.0))
{
ScopeProfiler sp(g_profiler, "SEnv: mess in act. blocks avg /1s", SPT_AVG);
float dtime = 1.0;
// Initialize handling of ActiveBlockModifiers
ABMHandler abmhandler(m_abms, abm_interval, this, true);
for(std::set<v3s16>::iterator
i = m_active_blocks.m_list.begin();
i != m_active_blocks.m_list.end(); ++i)
@ -1138,6 +1142,9 @@ void ServerEnvironment::step(float dtime)
// Set current time as timestamp
block->setTimestampNoChangedFlag(m_game_time);
abmhandler.apply(block);
// If time has changed much from the one on disk,
// set block to be saved when it is unloaded
if(block->getTimestamp() > block->getDiskTimestamp() + 60)
@ -1161,50 +1168,6 @@ void ServerEnvironment::step(float dtime)
}
}
const float abm_interval = 1.0;
if(m_active_block_modifier_interval.step(dtime, abm_interval))
do{ // breakable
if(m_active_block_interval_overload_skip > 0){
ScopeProfiler sp(g_profiler, "SEnv: ABM overload skips");
m_active_block_interval_overload_skip--;
break;
}
ScopeProfiler sp(g_profiler, "SEnv: modify in blocks avg /1s", SPT_AVG);
TimeTaker timer("modify in active blocks");
// Initialize handling of ActiveBlockModifiers
ABMHandler abmhandler(m_abms, abm_interval, this, true);
for(std::set<v3s16>::iterator
i = m_active_blocks.m_list.begin();
i != m_active_blocks.m_list.end(); ++i)
{
v3s16 p = *i;
/*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
<<") being handled"<<std::endl;*/
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
if(block == NULL)
continue;
// Set current time as timestamp
block->setTimestampNoChangedFlag(m_game_time);
/* Handle ActiveBlockModifiers */
abmhandler.apply(block);
}
u32 time_ms = timer.stop(true);
u32 max_time_ms = 200;
if(time_ms > max_time_ms){
warningstream<<"active block modifiers took "
<<time_ms<<"ms (longer than "
<<max_time_ms<<"ms)"<<std::endl;
m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1;
}
}while(0);
/*
Step script environment (run global on_step())
*/
@ -1677,7 +1640,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
<<" objects)"<<std::endl;
bool large_amount = (block->m_static_objects.m_stored.size() > g_settings->getU16("max_objects_per_block"));
if (large_amount) {
errorstream<<"suspiciously large amount of objects detected: "
verbosestream<<"suspiciously large amount of objects detected: "
<<block->m_static_objects.m_stored.size()<<" in "
<<PP(block->getPos())
<<"; removing all of them."<<std::endl;

View File

@ -1035,7 +1035,7 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
#ifdef __ANDROID__
# define SIZE_TAG "size[11,5.5]"
# define PAUSE_MENU_SIZE_TAG "size[6,3.5]"
# define PAUSE_MENU_SIZE_TAG "size[5,3.5]"
# define PAUSE_MENU_BUTTON_LEFT 1.5
#else
# define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
@ -1124,23 +1124,23 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
std::ostringstream os;
os << FORMSPEC_VERSION_STRING << PAUSE_MENU_SIZE_TAG
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
<< "button_exit[1," << (ypos++) << ";3,0.5;btn_continue;"
<< strgettext("Continue") << "]";
if (!singleplayermode) {
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;"
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_change_password;"
<< strgettext("Change Password") << "]";
}
#ifndef __ANDROID__
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_sound;"
<< strgettext("Sound Volume") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_key_config;"
<< strgettext("Change Keys") << "]";
#endif
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_exit_menu;"
<< strgettext("Exit to Menu") << "]";
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_exit_os;"
<< strgettext("Close game") << "]"
#ifndef __ANDROID__
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
@ -2809,7 +2809,7 @@ void Game::openConsole()
void Game::toggleFreeMove(float *statustext_time)
{
static const wchar_t *msg[] = { L"free_move disabled", L"free_move enabled" };
static const wchar_t *msg[] = { L"Fly mode disabled", L"Fly mode enabled" };
bool free_move = !g_settings->getBool("free_move");
g_settings->set("free_move", bool_to_cstr(free_move));
@ -2830,7 +2830,7 @@ void Game::toggleFreeMoveAlt(float *statustext_time, float *jump_timer)
void Game::toggleFast(float *statustext_time)
{
static const wchar_t *msg[] = { L"fast_move disabled", L"fast_move enabled" };
static const wchar_t *msg[] = { L"Fast move disabled", L"Fast move enabled" };
bool fast_move = !g_settings->getBool("fast_move");
g_settings->set("fast_move", bool_to_cstr(fast_move));

View File

@ -40,41 +40,57 @@ using namespace irr::core;
extern Settings *g_settings;
const char *touchgui_button_imagenames[] = {
"up_arrow.png",
"down_arrow.png",
"left_arrow.png",
"right_arrow.png",
"inventory_btn.png",
"drop_btn.png",
"jump_btn.png",
"up_one.png",
"up_two.png",
"up_three.png",
"down_one.png",
"down_two.png",
"down_three.png",
"left.png",
"right.png",
"inventory.png",
"drop.png",
"jump.png",
"down.png",
#ifdef ENABLE_ANDROID_NOCLIP
/*#ifdef ENABLE_ANDROID_NOCLIP
"fly_btn.png",
"noclip_btn.png",
#endif
#endif*/
// "minimap_btn.png",
"debug_btn.png",
"chat_btn.png",
// "camera_btn.png",
"rangeview_btn.png"
// "debug_btn.png",
"chat.png",
// "camera.png",
"rangeview.png"
};
static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
{
std::string key = "";
switch (id) {
case forward_id:
case forward_one:
key = "forward";
break;
case forward_two:
key = "forward";
break;
case forward_three:
key = "forward";
break;
case backward_one:
key = "backward";
break;
case backward_two:
key = "backward";
break;
case backward_three:
key = "backward";
break;
case left_id:
key = "left";
break;
case right_id:
key = "right";
break;
case backward_id:
key = "backward";
break;
case inventory_id:
key = "inventory";
break;
@ -87,7 +103,7 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
case crunch_id:
key = "sneak";
break;
#ifdef ENABLE_ANDROID_NOCLIP
/*#ifdef ENABLE_ANDROID_NOCLIP
case fly_id:
key = "freemove";
break;
@ -98,16 +114,16 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
key = "fast";
break;
#endif
/* case minimap_id:
case minimap_id:
key = "minimap";
break;*/
break;
case debug_id:
key = "toggle_debug";
break;
break;*/
case chat_id:
key = "chat";
break;
/* case camera_id:
/*case camera_id:
key = "camera_mode";
break;*/
case range_id:
@ -177,7 +193,7 @@ void TouchScreenGUI::initButton(touch_gui_button_id id, rect<s32> button_rect,
}
static int getMaxControlPadSize(float density) {
return 235 * density * g_settings->getFloat("hud_scaling");
return 220 * density * g_settings->getFloat("hud_scaling");
}
int TouchScreenGUI::getGuiButtonSize()
@ -192,18 +208,16 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
{
assert(tsrc != 0);
const u32 spacing = 7;
u32 control_pad_size =
MYMIN((2 * m_screensize.Y + spacing * 2) / 3,
MYMIN((2 * m_screensize.Y) / 3,
getMaxControlPadSize(porting::getDisplayDensity()));
u32 button_size = getGuiButtonSize();
m_visible = true;
m_texturesource = tsrc;
m_control_pad_rect = rect<s32>(
spacing, m_screensize.Y - control_pad_size - spacing,
spacing + control_pad_size, m_screensize.Y - spacing);
0, m_screensize.Y - control_pad_size,
0 + control_pad_size, m_screensize.Y);
/*
draw control pad
@ -211,46 +225,55 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
1 4 7
2 5 8
*/
int number = 0;
for (int y = 0; y < 3; ++y)
for (int x = 0; x < 3; ++x, ++number) {
v2s32 tl;
tl.X = y * (button_size + spacing) + spacing;
tl.Y = m_screensize.Y - (button_size + spacing) * (3 - x);
tl.X = y * button_size;
tl.Y = m_screensize.Y - button_size * (3 - x);
rect<s32> button_rect(tl.X, tl.Y, tl.X + button_size, tl.Y + button_size);
touch_gui_button_id id = after_last_element_id;
std::wstring caption;
switch (number) {
case 0:
id = forward_one;
caption = L"^";
break;
case 3:
id = forward_two;
caption = L"^";
break;
case 6:
id = forward_three;
caption = L"^";
break;
case 1:
id = left_id;
caption = L"<";
break;
case 2:
break;
case 3:
id = forward_id;
caption = L"^";
break;
case 4:
id = jump_id;
caption = L"x";
break;
case 5:
id = backward_id;
case 2:
id = backward_one;
caption = L"v";
break;
case 6:
case 5:
id = backward_two;
caption = L"v";
break;
case 8:
id = backward_three;
caption = L"v";
break;
case 7:
id = right_id;
caption = L">";
break;
case 8:
break;
}
if (id != after_last_element_id) {
@ -262,28 +285,28 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
initButton(inventory_id,
rect<s32>(m_screensize.X-(button_size),
m_screensize.Y - (button_size),
m_screensize.X-(0.0 * button_size),
m_screensize.X,
m_screensize.Y),
L"inv", true);
/* init drop button */
initButton(drop_id,
rect<s32>(0,
m_screensize.Y - (0.5*button_size),
(0.5*button_size),
m_screensize.Y),
L"drop", true);
rect<s32>(m_screensize.X-(0.75*button_size),
m_screensize.Y-(3.5*button_size),
m_screensize.X,
m_screensize.Y-(2.75*button_size)),
L"drop", true);
/* init crunch button */
initButton(crunch_id,
rect<s32>(m_screensize.X-(2.2*button_size),
m_screensize.Y - (0.5*button_size),
m_screensize.Y-(0.5*button_size),
m_screensize.X-(1.2*button_size),
m_screensize.Y),
L"H",false);
#ifdef ENABLE_ANDROID_NOCLIP
/* init fly button */
/*#ifdef ENABLE_ANDROID_NOCLIP
// init fly button
initButton(fly_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (3.25*button_size),
@ -291,21 +314,21 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
m_screensize.Y - (button_size*2.5)),
L"fly", false, SLOW_BUTTON_REPEAT);
/* init noclip button */
// init noclip button
initButton(noclip_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (4.75*button_size),
m_screensize.X,
m_screensize.Y - (button_size*4)),
L"clip", false, SLOW_BUTTON_REPEAT);
/* init fast button */
// init fast button
initButton(fast_id,
rect<s32>(m_screensize.X - (0.75*button_size),
m_screensize.Y - (4*button_size),
m_screensize.X,
m_screensize.Y - (button_size*3.25)),
L"fast", false, SLOW_BUTTON_REPEAT);
#endif
#endif*/
/* init minimap button
initButton(minimap_id,
rect<s32>(m_screensize.X - (0.75*button_size),
@ -313,13 +336,13 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
m_screensize.X,
m_screensize.Y - (button_size*3.25)),
L"minimap", false, SLOW_BUTTON_REPEAT);*/
#ifndef NDEBUG
/*#ifndef NDEBUG
/* init debug button */
initButton(debug_id,
/*initButton(debug_id,
rect<s32>(m_screensize.X - (0.75*button_size), 0.75*button_size,
m_screensize.X, 1.5*button_size),
L"dbg", false, SLOW_BUTTON_REPEAT);
#endif
#endif*/
/* init chat button */
initButton(chat_id,

View File

@ -36,8 +36,12 @@ using namespace irr::core;
using namespace irr::gui;
typedef enum {
forward_id = 0,
backward_id,
forward_one = 0,
forward_two,
forward_three,
backward_one,
backward_two,
backward_three,
left_id,
right_id,
inventory_id,
@ -50,7 +54,7 @@ typedef enum {
fast_id,
#endif
// minimap_id,
debug_id,
// debug_id,
chat_id,
// camera_id,
range_id,