mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Irrlicht support changes (#14383)
This commit is contained in:
parent
84dd812da4
commit
e3cc26cb7c
@ -198,11 +198,18 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
||||
while (m_rendering_engine->run() && !*kill &&
|
||||
!g_gamecallback->shutdown_requested) {
|
||||
// Set the window caption
|
||||
#if IRRLICHT_VERSION_MT_REVISION >= 15
|
||||
auto driver_name = m_rendering_engine->getVideoDriver()->getName();
|
||||
#else
|
||||
auto driver_name = wide_to_utf8(m_rendering_engine->getVideoDriver()->getName());
|
||||
#endif
|
||||
std::string caption = std::string(PROJECT_NAME_C) +
|
||||
" " + g_version_hash +
|
||||
" [" + gettext("Main Menu") + "]" +
|
||||
" [" + driver_name + "]";
|
||||
|
||||
m_rendering_engine->get_raw_device()->
|
||||
setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
|
||||
L" " + utf8_to_wide(g_version_hash) +
|
||||
L" [" + wstrgettext("Main Menu") + L"]" +
|
||||
L" [" + m_rendering_engine->getVideoDriver()->getName() + L"]" ).c_str());
|
||||
setWindowCaption(utf8_to_wide(caption).c_str());
|
||||
|
||||
try { // This is used for catching disconnects
|
||||
|
||||
|
@ -1551,18 +1551,20 @@ bool Game::createClient(const GameStartData &start_data)
|
||||
|
||||
/* Set window caption
|
||||
*/
|
||||
std::wstring str = utf8_to_wide(PROJECT_NAME_C);
|
||||
str += L" ";
|
||||
str += utf8_to_wide(g_version_hash);
|
||||
str += L" [";
|
||||
str += simple_singleplayer_mode ? wstrgettext("Singleplayer")
|
||||
: wstrgettext("Multiplayer");
|
||||
str += L"]";
|
||||
str += L" [";
|
||||
str += driver->getName();
|
||||
str += L"]";
|
||||
#if IRRLICHT_VERSION_MT_REVISION >= 15
|
||||
auto driver_name = driver->getName();
|
||||
#else
|
||||
auto driver_name = wide_to_utf8(driver->getName());
|
||||
#endif
|
||||
std::string str = std::string(PROJECT_NAME_C) +
|
||||
" " + g_version_hash + " [";
|
||||
str += simple_singleplayer_mode ? gettext("Singleplayer")
|
||||
: gettext("Multiplayer");
|
||||
str += "] [";
|
||||
str += driver_name;
|
||||
str += "]";
|
||||
|
||||
device->setWindowCaption(str.c_str());
|
||||
device->setWindowCaption(utf8_to_wide(str).c_str());
|
||||
|
||||
LocalPlayer *player = client->getEnv().getLocalPlayer();
|
||||
player->hurt_tilt_timer = 0;
|
||||
|
@ -240,37 +240,6 @@ CGUITTFont* CGUITTFont::createTTFont(IGUIEnvironment *env, const io::path& filen
|
||||
return font;
|
||||
}
|
||||
|
||||
CGUITTFont* CGUITTFont::createTTFont(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias, const bool transparency)
|
||||
{
|
||||
if (!c_libraryLoaded)
|
||||
{
|
||||
if (FT_Init_FreeType(&c_library))
|
||||
return 0;
|
||||
c_libraryLoaded = true;
|
||||
}
|
||||
|
||||
CGUITTFont* font = new CGUITTFont(device->getGUIEnvironment());
|
||||
font->Device = device;
|
||||
bool ret = font->load(filename, size, antialias, transparency);
|
||||
if (!ret)
|
||||
{
|
||||
font->drop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
CGUITTFont* CGUITTFont::create(IGUIEnvironment *env, const io::path& filename, const u32 size, const bool antialias, const bool transparency)
|
||||
{
|
||||
return CGUITTFont::createTTFont(env, filename, size, antialias, transparency);
|
||||
}
|
||||
|
||||
CGUITTFont* CGUITTFont::create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias, const bool transparency)
|
||||
{
|
||||
return CGUITTFont::createTTFont(device, filename, size, antialias, transparency);
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
//! Constructor.
|
||||
@ -304,6 +273,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
|
||||
|
||||
io::IFileSystem* filesystem = Environment->getFileSystem();
|
||||
irr::ILogger* logger = (Device != 0 ? Device->getLogger() : 0);
|
||||
// FIXME: this is always null ^
|
||||
this->size = size;
|
||||
this->filename = filename;
|
||||
|
||||
@ -314,7 +284,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
|
||||
|
||||
// Log.
|
||||
if (logger)
|
||||
logger->log(L"CGUITTFont", core::stringw(core::stringw(L"Creating new font: ") + core::stringw(filename) + L" " + core::stringc(size) + L"pt " + (antialias ? L"+antialias " : L"-antialias ") + (transparency ? L"+transparency" : L"-transparency")).c_str(), irr::ELL_INFORMATION);
|
||||
logger->log("CGUITTFont", (core::stringc(L"Creating new font: ") + filename + " " + core::stringc(size) + "pt " + (antialias ? "+antialias " : "-antialias ") + (transparency ? "+transparency" : "-transparency")).c_str(), irr::ELL_INFORMATION);
|
||||
|
||||
// Grab the face.
|
||||
SGUITTFace* face = 0;
|
||||
@ -330,7 +300,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
|
||||
io::IReadFile* file = filesystem->createAndOpenFile(filename);
|
||||
if (file == 0)
|
||||
{
|
||||
if (logger) logger->log(L"CGUITTFont", L"Failed to open the file.", irr::ELL_INFORMATION);
|
||||
if (logger) logger->log("CGUITTFont", "Failed to open the file.", irr::ELL_INFORMATION);
|
||||
|
||||
c_faces.erase(filename);
|
||||
delete face;
|
||||
@ -345,7 +315,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
|
||||
// Create the face.
|
||||
if (FT_New_Memory_Face(c_library, face->face_buffer, face->face_buffer_size, 0, &face->face))
|
||||
{
|
||||
if (logger) logger->log(L"CGUITTFont", L"FT_New_Memory_Face failed.", irr::ELL_INFORMATION);
|
||||
if (logger) logger->log("CGUITTFont", "FT_New_Memory_Face failed.", irr::ELL_INFORMATION);
|
||||
|
||||
c_faces.erase(filename);
|
||||
delete face;
|
||||
@ -357,7 +327,7 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
|
||||
{
|
||||
if (FT_New_Face(c_library, reinterpret_cast<const char*>(filename.c_str()), 0, &face->face))
|
||||
{
|
||||
if (logger) logger->log(L"CGUITTFont", L"FT_New_Face failed.", irr::ELL_INFORMATION);
|
||||
if (logger) logger->log("CGUITTFont", "FT_New_Face failed.", irr::ELL_INFORMATION);
|
||||
|
||||
c_faces.erase(filename);
|
||||
delete face;
|
||||
|
@ -229,9 +229,6 @@ namespace gui
|
||||
//! \param transparency set the use_transparency flag
|
||||
//! \return Returns a pointer to a CGUITTFont. Will return 0 if the font failed to load.
|
||||
static CGUITTFont* createTTFont(IGUIEnvironment *env, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true, const u32 shadow = 0, const u32 shadow_alpha = 255);
|
||||
static CGUITTFont* createTTFont(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
|
||||
static CGUITTFont* create(IGUIEnvironment *env, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
|
||||
static CGUITTFont* create(IrrlichtDevice *device, const io::path& filename, const u32 size, const bool antialias = true, const bool transparency = true);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CGUITTFont();
|
||||
|
@ -29,33 +29,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
using namespace irr;
|
||||
|
||||
namespace irr {
|
||||
#define S8_MIN INT8_MIN
|
||||
#define S16_MIN INT16_MIN
|
||||
#define S32_MIN INT32_MIN
|
||||
#define S64_MIN INT64_MIN
|
||||
|
||||
// Define missing constant for vector math with 16-bit numbers
|
||||
namespace core {
|
||||
template <typename T>
|
||||
inline T roundingError();
|
||||
#define S8_MAX INT8_MAX
|
||||
#define S16_MAX INT16_MAX
|
||||
#define S32_MAX INT32_MAX
|
||||
#define S64_MAX INT64_MAX
|
||||
|
||||
template <>
|
||||
inline s16 roundingError()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#define S8_MIN (-0x7F - 1)
|
||||
#define S16_MIN (-0x7FFF - 1)
|
||||
#define S32_MIN (-0x7FFFFFFF - 1)
|
||||
#define S64_MIN (-0x7FFFFFFFFFFFFFFF - 1)
|
||||
|
||||
#define S8_MAX 0x7F
|
||||
#define S16_MAX 0x7FFF
|
||||
#define S32_MAX 0x7FFFFFFF
|
||||
#define S64_MAX 0x7FFFFFFFFFFFFFFF
|
||||
|
||||
#define U8_MAX 0xFF
|
||||
#define U16_MAX 0xFFFF
|
||||
#define U32_MAX 0xFFFFFFFF
|
||||
#define U64_MAX 0xFFFFFFFFFFFFFFFF
|
||||
#define U8_MAX UINT8_MAX
|
||||
#define U16_MAX UINT16_MAX
|
||||
#define U32_MAX UINT32_MAX
|
||||
#define U64_MAX UINT64_MAX
|
||||
|
@ -234,8 +234,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#define SERVER_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
|
||||
|
||||
// Client's supported network protocol range
|
||||
// The minimal version depends on whether
|
||||
// send_pre_v25_init is enabled or not
|
||||
#define CLIENT_PROTOCOL_VERSION_MIN 37
|
||||
#define CLIENT_PROTOCOL_VERSION_MAX LATEST_PROTOCOL_VERSION
|
||||
|
||||
|
@ -963,7 +963,12 @@ int ModApiMainMenu::l_get_active_driver(lua_State *L)
|
||||
|
||||
int ModApiMainMenu::l_get_active_renderer(lua_State *L)
|
||||
{
|
||||
lua_pushstring(L, wide_to_utf8(RenderingEngine::get_video_driver()->getName()).c_str());
|
||||
#if IRRLICHT_VERSION_MT_REVISION >= 15
|
||||
lua_pushstring(L, RenderingEngine::get_video_driver()->getName());
|
||||
#else
|
||||
auto tmp = wide_to_utf8(RenderingEngine::get_video_driver()->getName());
|
||||
lua_pushstring(L, tmp.c_str());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -515,8 +515,9 @@ void PlayerSAO::setHP(s32 target_hp, const PlayerHPChangeReason &reason, bool fr
|
||||
return; // Nothing to do
|
||||
|
||||
s32 hp_change = m_env->getScriptIface()->on_player_hpchange(this, target_hp - (s32)m_hp, reason);
|
||||
hp_change = std::min<s32>(hp_change, U16_MAX); // Protect against overflow
|
||||
|
||||
s32 hp = (s32)m_hp + std::min(hp_change, U16_MAX); // Protection against s32 overflow
|
||||
s32 hp = (s32)m_hp + hp_change;
|
||||
hp = rangelim(hp, 0, U16_MAX);
|
||||
|
||||
if (hp > m_prop.hp_max)
|
||||
|
Loading…
Reference in New Issue
Block a user