forked from oerkki/voxelands
slightly modified MavJS MacOSX patch
This commit is contained in:
parent
8ac3bac5c6
commit
554ad1c1bf
|
@ -107,11 +107,11 @@ elseif(APPLE)
|
|||
# see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
|
||||
#
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
|
||||
set(CPACK_PACKAGE_ICON "")
|
||||
set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/voxelands.icns)
|
||||
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_BUNDLE_ICON "")
|
||||
set(CPACK_BUNDLE_PLIST "")
|
||||
set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
|
||||
set(CPACK_BUNDLE_ICON ${CPACK_PACKAGE_ICON})
|
||||
set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/Info.plist)
|
||||
set(CPACK_BUNDLE_STARTUP_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug/voxelands)
|
||||
set(CPACK_GENERATOR "Bundle")
|
||||
else()
|
||||
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
|
||||
|
|
15
README.txt
15
README.txt
|
@ -88,6 +88,21 @@ $ ./voxelands
|
|||
- You can select between Release and Debug build by -DCMAKE_BUILD_TYPE=<Debug or Release>
|
||||
- Debug build is slower, but gives much more useful output in a debugger
|
||||
|
||||
Compiling on Mac OS X
|
||||
---------------------
|
||||
- You need:
|
||||
* XCode 5 - https://developer.apple.com/xcode/downloads/
|
||||
* XCode commandline tools - https://developer.apple.com/downloads/
|
||||
* homebrew - http://brew.sh/
|
||||
|
||||
- Steps:
|
||||
* Install dependencies
|
||||
- brew install jpeg-turbo irrlicht
|
||||
* make XCode project for client only
|
||||
- cmake -DJPEG_INCLUDE_LIBRARY=/usr/local/Cellar/jpeg-turbo/<version>/include -DJPEG_LIBRARY=/usr/local/Cellar/jpeg-turbo/<version>lib/libturbojpeg.a -DBUILD_SERVER=0 -DRUN_IN_PLACE=0 -G Xcode .
|
||||
* build XCode project from commandline (If you're using the GUI, make sure to select "package" as build target)
|
||||
- xcodebuild -project voxelands.xcodeproj -target package
|
||||
|
||||
Compiling on Windows:
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>voxelands</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>voxelands.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>darkrose.voxelands</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>voxelands</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>GIT_VERSION</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>x86_64</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>GIT_VERSION</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.games</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication"/>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<menu title="AMainMenu" systemMenu="main" id="29">
|
||||
<items>
|
||||
<menuItem title="Voxelands" id="56">
|
||||
<menu key="submenu" title="Voxelands" systemMenu="apple" id="57">
|
||||
<items>
|
||||
<menuItem title="Services" id="131">
|
||||
<menu key="submenu" title="Services" systemMenu="services" id="130"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="144">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Voxelands" keyEquivalent="h" id="134">
|
||||
<connections>
|
||||
<action selector="hide:" target="-1" id="367"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Others" keyEquivalent="h" id="145">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="hideOtherApplications:" target="-1" id="368"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Show All" id="150">
|
||||
<connections>
|
||||
<action selector="unhideAllApplications:" target="-1" id="370"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="149">
|
||||
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
|
||||
</menuItem>
|
||||
<menuItem title="Quit Voxelands" keyEquivalent="q" id="136">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-3" id="449"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="Voxelands" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="371">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="663" width="248" height="87"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
|
||||
<view key="contentView" id="372">
|
||||
<rect key="frame" x="0.0" y="0.0" width="248" height="87"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" id="535">
|
||||
<rect key="frame" x="17" y="16" width="214" height="51"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" controlSize="mini" sendsActionOnEndEditing="YES" title="Irrlicht needs this window on Mac OS X to receive keyboard input! Just ignore it." id="536">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
</view>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
|
Binary file not shown.
|
@ -103,12 +103,15 @@ else()
|
|||
FIND_LIBRARY(CARBON_LIB Carbon)
|
||||
FIND_LIBRARY(COCOA_LIB Cocoa)
|
||||
FIND_LIBRARY(IOKIT_LIB IOKit)
|
||||
FIND_LIBRARY(COREFOUNDATION_LIB CoreFoundation)
|
||||
mark_as_advanced(
|
||||
CARBON_LIB
|
||||
COCOA_LIB
|
||||
IOKIT_LIB
|
||||
COREFOUNDATION_LIB
|
||||
)
|
||||
SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
|
||||
SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB} ${COREFOUNDATION_LIB})
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa")
|
||||
endif(APPLE)
|
||||
endif(BUILD_CLIENT)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
@ -315,8 +318,8 @@ else()
|
|||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE)
|
||||
set(ARCH i386)
|
||||
set(CMAKE_OSX_ARCHITECTURES x86_64 FORCE)
|
||||
set(ARCH x86_64)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
|
||||
|
@ -397,6 +400,31 @@ if(BUILD_CLIENT)
|
|||
endif()
|
||||
endif(USE_GETTEXT)
|
||||
endif()
|
||||
if(APPLE)
|
||||
# TODO: install Irrlicht.framework into app bundle!
|
||||
# it should be in Contents/Resources/Frameworks/Irrlicht.framework
|
||||
|
||||
# Compile .xib files
|
||||
# should be in Contents/Resources/MainMenu.nib at the end
|
||||
set (VoxelandsMac_XIBS
|
||||
MainMenu
|
||||
)
|
||||
# Make sure the 'Resources' Directory is correctly created before we build
|
||||
add_custom_command (TARGET ${PROJECT_NAME} PRE_BUILD
|
||||
COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/Contents/Resources)
|
||||
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
|
||||
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
|
||||
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
|
||||
endif()
|
||||
# Compile the .xib files using the 'ibtool' program with the destination being the app package
|
||||
foreach(xib ${VoxelandsMac_XIBS})
|
||||
add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
|
||||
--compile ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/Contents/Resources/${xib}.nib
|
||||
${CMAKE_SOURCE_DIR}/misc/mac/${xib}.xib
|
||||
COMMENT "Compiling ${CMAKE_SOURCE_DIR}/${xib}.xib")
|
||||
endforeach()
|
||||
endif(APPLE)
|
||||
endif(BUILD_CLIENT)
|
||||
|
||||
if(BUILD_SERVER)
|
||||
|
|
|
@ -2000,9 +2000,9 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id)
|
|||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata* meta = getNodeMetadata(p);
|
||||
if(meta)
|
||||
return meta->getInventory();
|
||||
|
|
|
@ -63,6 +63,8 @@ typedef core::vector2d<f32> v2f32;
|
|||
|
||||
typedef core::aabbox3d<f32> aabb3f;
|
||||
|
||||
// irrlicht 1.8+ has it's own irr::u64
|
||||
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
|
||||
#ifdef _MSC_VER
|
||||
// Windows
|
||||
typedef unsigned long long u64;
|
||||
|
@ -70,7 +72,7 @@ typedef core::aabbox3d<f32> aabb3f;
|
|||
// Posix
|
||||
#include <stdint.h>
|
||||
typedef uint64_t u64;
|
||||
//typedef unsigned long long u64;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -171,13 +171,13 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
if(type == "invsize" || type == "size")
|
||||
{
|
||||
v2f invsize;
|
||||
invsize.X = stof(f.next(","));
|
||||
invsize.X = mystof(f.next(","));
|
||||
if(type == "size")
|
||||
{
|
||||
invsize.Y = stof(f.next("]"));
|
||||
invsize.Y = mystof(f.next("]"));
|
||||
}
|
||||
else{
|
||||
invsize.Y = stof(f.next(";"));
|
||||
invsize.Y = mystof(f.next(";"));
|
||||
errorstream<<"WARNING: invsize is deprecated, use size"<<std::endl;
|
||||
f.next("]");
|
||||
}
|
||||
|
@ -211,11 +211,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
loc.deSerialize(name);
|
||||
std::string listname = f.next(";");
|
||||
v2s32 pos = basepos;
|
||||
pos.X += stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += stof(f.next(";")) * (float)spacing.Y;
|
||||
pos.X += mystof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += mystof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = stoi(f.next(","));
|
||||
geom.Y = stoi(f.next(";"));
|
||||
geom.X = mystoi(f.next(","));
|
||||
geom.Y = mystoi(f.next(";"));
|
||||
infostream<<"list inv="<<name<<", listname="<<listname
|
||||
<<", pos=("<<pos.X<<","<<pos.Y<<")"
|
||||
<<", geom=("<<geom.X<<","<<geom.Y<<")"
|
||||
|
@ -228,11 +228,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
else if(type == "image")
|
||||
{
|
||||
v2s32 pos = basepos;
|
||||
pos.X += stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += stof(f.next(";")) * (float)spacing.Y;
|
||||
pos.X += mystof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += mystof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = stof(f.next(",")) * (float)imgsize.X;
|
||||
geom.Y = stof(f.next(";")) * (float)imgsize.Y;
|
||||
geom.X = mystof(f.next(",")) * (float)imgsize.X;
|
||||
geom.Y = mystof(f.next(";")) * (float)imgsize.Y;
|
||||
std::string name = f.next("]");
|
||||
infostream<<"image name="<<name
|
||||
<<", pos=("<<pos.X<<","<<pos.Y<<")"
|
||||
|
@ -275,17 +275,17 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
else
|
||||
{
|
||||
v2s32 pos;
|
||||
pos.X = stof(fname.substr(0,fname.find(","))) * (float)spacing.X;
|
||||
pos.Y = stof(fname.substr(fname.find(",")+1)) * (float)spacing.Y;
|
||||
pos.X = mystof(fname.substr(0,fname.find(","))) * (float)spacing.X;
|
||||
pos.Y = mystof(fname.substr(fname.find(",")+1)) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = (stof(flabel.substr(0,flabel.find(","))) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
if (stof(flabel.substr(flabel.find(",")+1)) > 1.0) {
|
||||
geom.Y = (stof(flabel.substr(flabel.find(",")+1)) * (float)spacing.Y)-(spacing.Y-imgsize.Y);
|
||||
geom.X = (mystof(flabel.substr(0,flabel.find(","))) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
if (mystof(flabel.substr(flabel.find(",")+1)) > 1.0) {
|
||||
geom.Y = (mystof(flabel.substr(flabel.find(",")+1)) * (float)spacing.Y)-(spacing.Y-imgsize.Y);
|
||||
multi = true;
|
||||
}else{
|
||||
geom.Y = 30;
|
||||
}
|
||||
pos.Y += ((stof(flabel.substr(flabel.find(",")+1)) * (float)imgsize.Y)/2)-15;
|
||||
pos.Y += ((mystof(flabel.substr(flabel.find(",")+1)) * (float)imgsize.Y)/2)-15;
|
||||
|
||||
rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
|
||||
|
||||
|
@ -360,8 +360,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
else if(type == "label")
|
||||
{
|
||||
v2s32 pos;
|
||||
pos.X = stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = stof(f.next(";")) * (float)spacing.Y;
|
||||
pos.X = mystof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = mystof(f.next(";")) * (float)spacing.Y;
|
||||
|
||||
rect = core::rect<s32>(pos.X, pos.Y+((imgsize.Y/2)-15), pos.X+300, pos.Y+((imgsize.Y/2)+15));
|
||||
|
||||
|
@ -381,11 +381,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
else if(type == "button" || type == "button_exit")
|
||||
{
|
||||
v2s32 pos;
|
||||
pos.X = stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = stof(f.next(";")) * (float)spacing.Y;
|
||||
pos.X = mystof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = mystof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = (stof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
pos.Y += (stof(f.next(";")) * (float)imgsize.Y)/2;
|
||||
geom.X = (mystof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
pos.Y += (mystof(f.next(";")) * (float)imgsize.Y)/2;
|
||||
|
||||
rect = core::rect<s32>(pos.X, pos.Y-15, pos.X+geom.X, pos.Y+15);
|
||||
|
||||
|
@ -409,11 +409,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
else if(type == "image_button" || type == "image_button_exit")
|
||||
{
|
||||
v2s32 pos;
|
||||
pos.X = stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = stof(f.next(";")) * (float)spacing.Y;
|
||||
pos.X = mystof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y = mystof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = (stof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
geom.Y = (stof(f.next(";")) * (float)spacing.Y)-(spacing.Y-imgsize.Y);
|
||||
geom.X = (mystof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X);
|
||||
geom.Y = (mystof(f.next(";")) * (float)spacing.Y)-(spacing.Y-imgsize.Y);
|
||||
|
||||
rect = core::rect<s32>(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y);
|
||||
|
||||
|
|
|
@ -1004,9 +1004,9 @@ void InventoryLocation::deSerialize(std::istream &is)
|
|||
std::string pos;
|
||||
std::getline(is, pos, '\n');
|
||||
Strfnd fn(pos);
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
}else{
|
||||
infostream<<"Unknown InventoryLocation type=\""<<tname<<"\""<<std::endl;
|
||||
throw SerializationError("Unknown InventoryLocation type");
|
||||
|
|
|
@ -617,21 +617,21 @@ struct IMoveAction : public InventoryAction
|
|||
std::string ts;
|
||||
|
||||
std::getline(is, ts, ' ');
|
||||
count = stoi(ts);
|
||||
count = mystoi(ts);
|
||||
|
||||
std::getline(is, from_inv, ' ');
|
||||
|
||||
std::getline(is, from_list, ' ');
|
||||
|
||||
std::getline(is, ts, ' ');
|
||||
from_i = stoi(ts);
|
||||
from_i = mystoi(ts);
|
||||
|
||||
std::getline(is, to_inv, ' ');
|
||||
|
||||
std::getline(is, to_list, ' ');
|
||||
|
||||
std::getline(is, ts, ' ');
|
||||
to_i = stoi(ts);
|
||||
to_i = mystoi(ts);
|
||||
}
|
||||
|
||||
u16 getType() const
|
||||
|
|
|
@ -1261,7 +1261,7 @@ int main(int argc, char *argv[])
|
|||
//infostream<<"Main: password hash: '"<<password<<"'"<<std::endl;
|
||||
|
||||
address = wide_to_narrow(menudata.address);
|
||||
int newport = stoi(wide_to_narrow(menudata.port));
|
||||
int newport = mywstoi(menudata.port);
|
||||
if(newport != 0)
|
||||
port = newport;
|
||||
g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
|
||||
|
|
|
@ -274,7 +274,7 @@ void initializePaths()
|
|||
{
|
||||
dstream<<"Bundle resource path: "<<path<<std::endl;
|
||||
//chdir(path);
|
||||
path_data = std::string(path) + "/data";
|
||||
path_data = std::string(path) + "/share/" + PROJECT_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4236,9 +4236,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
|
@ -4261,9 +4261,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if (meta) {
|
||||
if (meta->typeId() == CONTENT_LOCKABLE_CHEST) {
|
||||
|
@ -4611,9 +4611,9 @@ Inventory* Server::getInventory(InventoryContext *c, std::string id)
|
|||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
if(meta)
|
||||
return meta->getInventory();
|
||||
|
@ -4642,9 +4642,9 @@ void Server::inventoryModified(InventoryContext *c, std::string id)
|
|||
if(id0 == "nodemeta")
|
||||
{
|
||||
v3s16 p;
|
||||
p.X = stoi(fn.next(","));
|
||||
p.Y = stoi(fn.next(","));
|
||||
p.Z = stoi(fn.next(","));
|
||||
p.X = mystoi(fn.next(","));
|
||||
p.Y = mystoi(fn.next(","));
|
||||
p.Z = mystoi(fn.next(","));
|
||||
v3s16 blockpos = getNodeBlockPos(p);
|
||||
|
||||
NodeMetadata *meta = m_env.getMap().getNodeMetadata(p);
|
||||
|
|
|
@ -140,7 +140,7 @@ void cmd_time(std::wostringstream &os,
|
|||
return;
|
||||
}
|
||||
|
||||
u32 time = stoi(wide_to_narrow(ctx->parms[1]));
|
||||
u32 time = mystoi(wide_to_narrow(ctx->parms[1]));
|
||||
ctx->server->setTimeOfDay(time);
|
||||
os<<L"-!- time_of_day changed.";
|
||||
|
||||
|
@ -222,7 +222,7 @@ void cmd_teleport(std::wostringstream &os,
|
|||
return;
|
||||
}
|
||||
|
||||
v3f dest(stoi(coords[0])*10, stoi(coords[1])*10, stoi(coords[2])*10);
|
||||
v3f dest(mywstoi(coords[0])*10, mywstoi(coords[1])*10, mywstoi(coords[2])*10);
|
||||
|
||||
actionstream<<ctx->player->getName()<<" teleports from "
|
||||
<<PP(ctx->player->getPosition()/BS)<<" to "
|
||||
|
|
|
@ -453,12 +453,12 @@ public:
|
|||
|
||||
float getFloat(std::string name)
|
||||
{
|
||||
return stof(get(name));
|
||||
return mystof(get(name));
|
||||
}
|
||||
|
||||
u16 getU16(std::string name)
|
||||
{
|
||||
return stoi(get(name), 0, 65535);
|
||||
return mystoi(get(name), 0, 65535);
|
||||
}
|
||||
|
||||
u16 getU16Ask(std::string name, std::string question, u16 def)
|
||||
|
@ -476,17 +476,17 @@ public:
|
|||
if(s == "")
|
||||
return def;
|
||||
|
||||
return stoi(s, 0, 65535);
|
||||
return mystoi(s, 0, 65535);
|
||||
}
|
||||
|
||||
s16 getS16(std::string name)
|
||||
{
|
||||
return stoi(get(name), -32768, 32767);
|
||||
return mystoi(get(name), -32768, 32767);
|
||||
}
|
||||
|
||||
s32 getS32(std::string name)
|
||||
{
|
||||
return stoi(get(name));
|
||||
return mystoi(get(name));
|
||||
}
|
||||
|
||||
v3f getV3F(std::string name)
|
||||
|
@ -494,9 +494,9 @@ public:
|
|||
v3f value;
|
||||
Strfnd f(get(name));
|
||||
f.next("(");
|
||||
value.X = stof(f.next(","));
|
||||
value.Y = stof(f.next(","));
|
||||
value.Z = stof(f.next(")"));
|
||||
value.X = mystof(f.next(","));
|
||||
value.Y = mystof(f.next(","));
|
||||
value.Z = mystof(f.next(")"));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -505,8 +505,8 @@ public:
|
|||
v2f value;
|
||||
Strfnd f(get(name));
|
||||
f.next("(");
|
||||
value.X = stof(f.next(","));
|
||||
value.Y = stof(f.next(")"));
|
||||
value.X = mystof(f.next(","));
|
||||
value.Y = mystof(f.next(")"));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ with this program; ifnot, write to the Free Software Foundation, Inc.,
|
|||
#elif defined(__APPLE__)
|
||||
#include <OpenAL/al.h>
|
||||
#include <OpenAL/alc.h>
|
||||
#include <OpenAL/alext.h>
|
||||
#else
|
||||
#include <AL/al.h>
|
||||
#include <AL/alc.h>
|
||||
|
|
30
src/tile.cpp
30
src/tile.cpp
|
@ -801,7 +801,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
}
|
||||
|
||||
// Crack image number
|
||||
u16 progression = stoi(part_of_name.substr(6));
|
||||
u16 progression = mystoi(part_of_name.substr(6));
|
||||
|
||||
// Size of the base image
|
||||
core::dimension2d<u32> dim_base = baseimg->getDimension();
|
||||
|
@ -886,15 +886,15 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
{
|
||||
Strfnd sf(part_of_name);
|
||||
sf.next(":");
|
||||
u32 w0 = stoi(sf.next("x"));
|
||||
u32 h0 = stoi(sf.next(":"));
|
||||
u32 w0 = mystoi(sf.next("x"));
|
||||
u32 h0 = mystoi(sf.next(":"));
|
||||
infostream<<"combined w="<<w0<<" h="<<h0<<std::endl;
|
||||
core::dimension2d<u32> dim(w0,h0);
|
||||
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
|
||||
while(sf.atend() == false)
|
||||
{
|
||||
u32 x = stoi(sf.next(","));
|
||||
u32 y = stoi(sf.next("="));
|
||||
u32 x = mystoi(sf.next(","));
|
||||
u32 y = mystoi(sf.next("="));
|
||||
std::string filename = sf.next(":");
|
||||
infostream<<"Adding \""<<filename
|
||||
<<"\" to combined ("<<x<<","<<y<<")"
|
||||
|
@ -937,7 +937,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
return false;
|
||||
}
|
||||
|
||||
float value = stof(part_of_name.substr(12));
|
||||
float value = mystof(part_of_name.substr(12));
|
||||
make_progressbar(value, baseimg);
|
||||
}
|
||||
/*
|
||||
|
@ -1005,9 +1005,9 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
}
|
||||
|
||||
Strfnd sf(part_of_name.substr(11));
|
||||
u32 r1 = stoi(sf.next(","));
|
||||
u32 g1 = stoi(sf.next(","));
|
||||
u32 b1 = stoi(sf.next(":"));
|
||||
u32 r1 = mystoi(sf.next(","));
|
||||
u32 g1 = mystoi(sf.next(","));
|
||||
u32 b1 = mystoi(sf.next(":"));
|
||||
std::string filename = sf.next("");
|
||||
|
||||
std::string path = getTexturePath(filename.c_str());
|
||||
|
@ -1061,12 +1061,12 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
|
|||
}
|
||||
|
||||
Strfnd sf(part_of_name.substr(12));
|
||||
u32 r1 = stoi(sf.next(","));
|
||||
u32 g1 = stoi(sf.next(","));
|
||||
u32 b1 = stoi(sf.next(";"));
|
||||
u32 r2 = stoi(sf.next(","));
|
||||
u32 g2 = stoi(sf.next(","));
|
||||
u32 b2 = stoi(sf.next(":"));
|
||||
u32 r1 = mystoi(sf.next(","));
|
||||
u32 g1 = mystoi(sf.next(","));
|
||||
u32 b1 = mystoi(sf.next(";"));
|
||||
u32 r2 = mystoi(sf.next(","));
|
||||
u32 g2 = mystoi(sf.next(","));
|
||||
u32 b2 = mystoi(sf.next(":"));
|
||||
std::string filename = sf.next("");
|
||||
|
||||
std::string path = getTexturePath(filename.c_str());
|
||||
|
|
|
@ -904,9 +904,11 @@ inline bool is_yes(const std::string &s)
|
|||
return false;
|
||||
}
|
||||
|
||||
inline s32 stoi(const std::string &s, s32 min, s32 max)
|
||||
inline s32 mystoi(const std::string &s, s32 min=0, s32 max=0)
|
||||
{
|
||||
s32 i = atoi(s.c_str());
|
||||
if (min == max)
|
||||
return i;
|
||||
if(i < min)
|
||||
i = min;
|
||||
if(i > max)
|
||||
|
@ -914,21 +916,19 @@ inline s32 stoi(const std::string &s, s32 min, s32 max)
|
|||
return i;
|
||||
}
|
||||
|
||||
|
||||
// MSVC2010 includes it's own versions of these
|
||||
#if !defined(_MSC_VER) || _MSC_VER < 1600
|
||||
|
||||
inline s32 stoi(std::string s)
|
||||
inline s32 mywstoi(const std::wstring &s, s32 min=0, s32 max=0)
|
||||
{
|
||||
return atoi(s.c_str());
|
||||
s32 i = atoi(wide_to_narrow(s).c_str());
|
||||
if (min == max)
|
||||
return i;
|
||||
if(i < min)
|
||||
i = min;
|
||||
if(i > max)
|
||||
i = max;
|
||||
return i;
|
||||
}
|
||||
|
||||
inline s32 stoi(std::wstring s)
|
||||
{
|
||||
return atoi(wide_to_narrow(s).c_str());
|
||||
}
|
||||
|
||||
inline float stof(std::string s)
|
||||
inline float mystof(std::string s)
|
||||
{
|
||||
float f;
|
||||
std::istringstream ss(s);
|
||||
|
@ -936,8 +936,6 @@ inline float stof(std::string s)
|
|||
return f;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline std::string itos(s32 i)
|
||||
{
|
||||
std::ostringstream o;
|
||||
|
|
Loading…
Reference in New Issue