summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-07-01 12:15:38 +0200
committerkrzys-h <krzys_h@interia.pl>2014-07-01 12:16:32 +0200
commitd9fee8b2adad613cf8c10d153cd5cd7b261b7863 (patch)
treef6b71cc2daa719c10c1ce31cf738e1c6ec934a73
parent0f2adf05fd2b2b38c2b84aa8d72b3fd756dcfcd4 (diff)
parent1835d2ae580525603308206f7b8e6b4552b3ca0f (diff)
downloadcolobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.gz
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.tar.bz2
colobot-d9fee8b2adad613cf8c10d153cd5cd7b261b7863.zip
Release 0.1.3-alpha
-rw-r--r--.gitignore3
-rw-r--r--CMakeLists.txt48
-rw-r--r--INSTALL.md13
-rw-r--r--README.md4
m---------data0
-rw-r--r--desktop/CMakeLists.txt8
-rw-r--r--desktop/colobot.icobin353118 -> 370070 bytes
-rw-r--r--desktop/colobot.svg538
-rw-r--r--lib/clipboard/CMakeLists.txt2
-rw-r--r--po/colobot.pot14
-rw-r--r--po/de.po24
-rw-r--r--po/fr.po19
-rw-r--r--po/pl.po26
-rw-r--r--po/ru.po18
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/app/app.cpp184
-rw-r--r--src/app/app.h29
-rw-r--r--src/app/gamedata.cpp136
-rw-r--r--src/app/gamedata.h66
-rw-r--r--src/app/pausemanager.cpp94
-rw-r--r--src/app/pausemanager.h62
-rw-r--r--src/common/config.h.cmake2
-rw-r--r--src/common/event.cpp1
-rw-r--r--src/common/event.h1
-rw-r--r--src/common/global.h280
-rw-r--r--src/common/image.cpp41
-rw-r--r--src/common/image.h6
-rw-r--r--src/common/logger.cpp4
-rw-r--r--src/common/misc.cpp33
-rw-r--r--src/common/misc.h1
-rw-r--r--src/common/profile.cpp16
-rw-r--r--src/common/restext.cpp40
-rw-r--r--src/common/restext.h5
-rw-r--r--src/common/stringutils.cpp35
-rw-r--r--src/common/stringutils.h11
-rw-r--r--src/graphics/core/device.h3
-rw-r--r--src/graphics/core/vertex.h4
-rw-r--r--src/graphics/engine/camera.cpp3
-rw-r--r--src/graphics/engine/engine.cpp60
-rw-r--r--src/graphics/engine/engine.h10
-rw-r--r--src/graphics/engine/modelmanager.cpp20
-rw-r--r--src/graphics/engine/modelmanager.h17
-rw-r--r--src/graphics/engine/terrain.cpp65
-rw-r--r--src/graphics/engine/terrain.h4
-rw-r--r--src/graphics/engine/text.cpp15
-rw-r--r--src/graphics/opengl/gldevice.cpp13
-rw-r--r--src/graphics/opengl/gldevice.h2
-rw-r--r--src/object/auto/auto.cpp2
-rw-r--r--src/object/auto/autobase.cpp103
-rw-r--r--src/object/auto/autobase.h2
-rw-r--r--src/object/brain.cpp32
-rw-r--r--src/object/object.cpp86
-rw-r--r--src/object/object.h467
-rw-r--r--src/object/objman.cpp65
-rw-r--r--src/object/objman.h6
-rw-r--r--src/object/robotmain.cpp642
-rw-r--r--src/object/robotmain.h29
-rw-r--r--src/object/task/taskbuild.cpp3
-rw-r--r--src/object/task/taskgoto.cpp4
-rw-r--r--src/object/task/taskgungoal.cpp24
-rw-r--r--src/object/task/taskgungoal.h2
-rw-r--r--src/object/task/taskrecover.cpp4
-rw-r--r--src/object/task/taskterraform.cpp23
-rw-r--r--src/physics/physics.cpp68
-rw-r--r--src/physics/physics.h16
-rw-r--r--src/script/cbottoken.cpp12
-rw-r--r--src/script/cmdtoken.cpp255
-rw-r--r--src/script/cmdtoken.h7
-rw-r--r--src/script/script.cpp377
-rw-r--r--src/script/script.h11
-rw-r--r--src/sound/oalsound/alsound.cpp387
-rw-r--r--src/sound/oalsound/alsound.h42
-rw-r--r--src/sound/oalsound/buffer.cpp2
-rw-r--r--src/sound/oalsound/channel.cpp58
-rw-r--r--src/sound/oalsound/channel.h9
-rw-r--r--src/sound/sound.cpp47
-rw-r--r--src/sound/sound.h62
-rw-r--r--src/ui/button.cpp7
-rw-r--r--src/ui/check.cpp7
-rw-r--r--src/ui/color.cpp41
-rw-r--r--src/ui/control.cpp30
-rw-r--r--src/ui/control.h2
-rw-r--r--src/ui/displayinfo.cpp101
-rw-r--r--src/ui/displayinfo.h19
-rw-r--r--src/ui/displaytext.cpp8
-rw-r--r--src/ui/edit.cpp26
-rw-r--r--src/ui/group.cpp7
-rw-r--r--src/ui/image.cpp7
-rw-r--r--src/ui/key.cpp28
-rw-r--r--src/ui/maindialog.cpp511
-rw-r--r--src/ui/maindialog.h33
-rw-r--r--src/ui/mainshort.cpp8
-rw-r--r--src/ui/studio.cpp67
-rw-r--r--src/ui/studio.h13
-rw-r--r--src/ui/window.cpp15
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/envs/opengl/light_test.cpp4
-rw-r--r--test/envs/opengl/transform_test.cpp4
-rw-r--r--test/unit/CMakeLists.txt4
-rw-r--r--test/unit/graphics/core/device_mock.h2
-rw-r--r--test/unit/ui/CMakeLists.txt3
-rw-r--r--test/unit/ui/edit_test.cpp23
-rw-r--r--test/unit/ui/mocks/text_mock.h16
-rw-r--r--test/unit/ui/stubs/app_stub.cpp10
-rw-r--r--test/unit/ui/stubs/restext_stub.cpp2
-rwxr-xr-xtools/check-levels.sh9
106 files changed, 2978 insertions, 2862 deletions
diff --git a/.gitignore b/.gitignore
index 122663d..6a031c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,6 @@ Makefile
# Ignore KDevelop files
.kdev4
*.kdev4
+
+# Ignore gedit temp files
+*~
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e793b6a..d40a1b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ project(colobot C CXX)
set(COLOBOT_VERSION_CODENAME "Gold")
set(COLOBOT_VERSION_MAJOR 0)
set(COLOBOT_VERSION_MINOR 1)
-set(COLOBOT_VERSION_REVISION 2)
+set(COLOBOT_VERSION_REVISION 3)
# Used on official releases
set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
@@ -21,15 +21,24 @@ set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
#set(COLOBOT_VERSION_UNRELEASED "+alpha")
# Append git characteristics to version
-if(DEFINED COLOBOT_VERSION_UNRELEASED AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
- find_package(Git)
- execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
- OUTPUT_VARIABLE GIT_BRANCH
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
- OUTPUT_VARIABLE GIT_REVISION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
+if(DEFINED COLOBOT_VERSION_UNRELEASED)
+ if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
+ find_package(Git)
+ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE GIT_BRANCH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE GIT_REVISION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(COLOBOT_VERSION_UNRELEASED "${COLOBOT_VERSION_UNRELEASED}-git-${GIT_BRANCH}~r${GIT_REVISION}")
+ set(COLOBOT_VERSION_DISPLAY "git-${GIT_BRANCH}~r${GIT_REVISION}")
+ else()
+ set(COLOBOT_VERSION_DISPLAY "${COLOBOT_VERSION_CODENAME}-${COLOBOT_VERSION_UNRELEASED}")
+ endif()
+else()
+ set(COLOBOT_VERSION_DISPLAY "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_RELEASE_CODENAME}")
endif()
set(COLOBOT_VERSION_FULL "${COLOBOT_VERSION_MAJOR}.${COLOBOT_VERSION_MINOR}.${COLOBOT_VERSION_REVISION}${COLOBOT_VERSION_UNRELEASED}${COLOBOT_VERSION_RELEASE_CODENAME}")
@@ -42,6 +51,7 @@ message(STATUS "Building Colobot \"${COLOBOT_VERSION_CODENAME}\" (${COLOBOT_VERS
if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
message(STATUS "Build for Windows system")
set(PLATFORM_WINDOWS 1)
+ set(PLATFORM_GNU 0)
set(PLATFORM_LINUX 0)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 0)
@@ -52,15 +62,27 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
message(STATUS "Build for Linux system")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 1)
+ set(PLATFORM_GNU 1)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_linux.cpp")
+elseif("${CMAKE_SYSTEM_NAME}" MATCHES "kFreeBSD" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "GNU")
+ message(STATUS "Build for kFreeBSD system")
+ set(PLATFORM_WINDOWS 0)
+ set(PLATFORM_LINUX 0)
+ set(PLATFORM_GNU 1)
+ set(PLATFORM_MACOSX 0)
+ set(PLATFORM_OTHER 0)
+
+ # Platform-dependent implementation of system.h
+ set(SYSTEM_CPP_MODULE "system_other.cpp")
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
message(STATUS "Build for Mac OSX system")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0)
+ set(PLATFORM_GNU 0)
set(PLATFORM_MACOSX 1)
set(PLATFORM_OTHER 0)
@@ -72,6 +94,7 @@ else()
message(STATUS "Build for other system")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0)
+ set(PLATFORM_GNU 0)
set(PLATFORM_MACOSX 0)
set(PLATFORM_OTHER 1)
@@ -123,6 +146,9 @@ set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast ${CXX11_FLAGS}
set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
+# Flags for gtest
+set(COLOBOT_GTEST_CXX_FLAGS "-pthread")
+
# Asserts can be enabled/disabled regardless of build type
option(ASSERTS "Enable assert()s" ON)
@@ -226,7 +252,7 @@ include("${colobot_SOURCE_DIR}/cmake/msys.cmake")
##
# Clipboard support needs X11 libraries
##
-if(PLATFORM_LINUX OR PLATFORM_MACOSX)
+if(PLATFORM_GNU OR PLATFORM_MACOSX)
find_package(X11 REQUIRED)
if(PLATFORM_MACOSX)
# Add the includes for X11
diff --git a/INSTALL.md b/INSTALL.md
index 0ff56f1..81037c5 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -117,12 +117,23 @@ You will need:
* OpenAL (OpenAL-Soft) >= 1.13
* po4a >= 0.45 (to generate translated data files)
+On Ubuntu (and probably any other Debian-based system), you can use the following command to install all required packages:
+```
+ $ apt-get install build-essential cmake libsdl1.2debian libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libsdl-ttf2.0-0 libsdl-ttf2.0-dev libsdl-mixer1.2 libsdl-mixer1.2-dev libsndfile1-dev libvorbis-dev libogg-dev libpng12-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev git
+```
+
Make sure you install the packages along with header files (often distributed in separate *-dev packages). If you miss any requirements,
CMake should warn you.
-To compile colobot, run your favorite shell and change the directory to where you downloaded colobot source files:
+To compile colobot, run your favorite shell and download colobot source files:
```
+ $ git clone https://github.com/colobot/colobot.git /path/to/colobot/sources
$ cd /path/to/colobot/sources
+ $ git submodule update --init
+```
+If you want to compile development branch, change the first command to:
+```
+ $ git clone -b dev https://github.com/colobot/colobot.git /path/to/colobot/sources
```
It is recommended that you create a build directory:
```
diff --git a/README.md b/README.md
index c67b755..7961e90 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ This is official repository for the open-source Colobot project developed by Pol
The source code contained here was released by Epsitec -- the original creator of the game -- on open source (GPLv3) license. The code was given and the rights granted specifically to PPC community in March 2012. Since then, we have been developing the game further.
-More information for developers (in English) can be found on the [developer wiki](http://colobot.info/w/Dev:Main_Page) or (in Polish) [our forum](http://colobot.info/forum/). However, the freshest source of information is our IRC channels (see below).
+More information for developers (in English) can be found on the [developer wiki](http://colobot.info/wiki/Dev:Main_Page) or (in Polish) [our forum](http://colobot.info/forum/). However, the freshest source of information is our IRC channels (see below).
This repository contains only the source code of the project. The game requires also data files which are now provided as git submodule and are hosted in [separate repository](https://github.com/colobot/colobot-data).
@@ -54,7 +54,7 @@ To jest oficjalne repozytorium z kodem projektu open-source Colobot rozwijanego
Kod źródłowy zawarty tutaj został wydany przez Epsitec -- oryginalnego twórcę gry -- na otwartej licencji (GPLv3). Kod został wydany i prawa nadane specjalnie dla społeczności PPC w marcu 2012. Od tamtej pory, zajmowaliśmy się dalszym rozwojem gry.
-Więcej informacji dla developerów projektu (po angielsku) można znaleźć na [wiki dla developerów](htt://colobot.info/w/Dev:Main_Page) lub (po polsku) na [naszym forum](http://colobot.info/forum/). Jednak źródłem najświeższych informacji są nasze kanały IRC (patrz niżej).
+Więcej informacji dla developerów projektu (po angielsku) można znaleźć na [wiki dla developerów](htt://colobot.info/wiki/Dev:Main_Page) lub (po polsku) na [naszym forum](http://colobot.info/forum/). Jednak źródłem najświeższych informacji są nasze kanały IRC (patrz niżej).
To repozytorium zawiera jedynie kod źródłowy projektu. Gra wymaga jeszcze plików danych, które są teraz udostępniane jako submoduł gita i hostowane w [osobnym repozytorium]((https://github.com/colobot/colobot-data).
diff --git a/data b/data
-Subproject 456ab4d4806ffe9aad93b7046f1b8074501f28f
+Subproject beff41878d617640c21035c66ea9ddb2e82e658
diff --git a/desktop/CMakeLists.txt b/desktop/CMakeLists.txt
index 9fa0c5e..87c8a4b 100644
--- a/desktop/CMakeLists.txt
+++ b/desktop/CMakeLists.txt
@@ -4,7 +4,7 @@ set(COLOBOT_ICON_FILE colobot.svg)
# Render SVG icon in various sizes
find_program(RSVG_CONVERT rsvg-convert)
-if(RSVG_CONVERT AND (PLATFORM_LINUX OR PLATFORM_MACOSX))
+if(RSVG_CONVERT AND (PLATFORM_GNU OR PLATFORM_MACOSX))
add_custom_target(png-icons ALL)
foreach(PNGSIZE 512 256 128 48 32 16)
add_custom_command(
@@ -15,7 +15,7 @@ if(RSVG_CONVERT AND (PLATFORM_LINUX OR PLATFORM_MACOSX))
add_custom_target(png-icon-${PNGSIZE} ALL DEPENDS ${PNGSIZE}/colobot.png)
add_dependencies(png-icons png-icon-${PNGSIZE})
- if(PLATFORM_LINUX)
+ if(PLATFORM_GNU)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGSIZE}/colobot.png
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/${PNGSIZE}x${PNGSIZE}/apps/
@@ -37,7 +37,7 @@ if(RSVG_CONVERT AND (PLATFORM_LINUX OR PLATFORM_MACOSX))
endif()
-if(PLATFORM_LINUX)
+if(PLATFORM_GNU)
# Install Desktop Entry file
set(COLOBOT_DESKTOP_FILE colobot.desktop)
add_custom_command(
@@ -112,7 +112,7 @@ if(PLATFORM_LINUX)
endforeach()
endif()
endif()
-endif(PLATFORM_LINUX)
+endif(PLATFORM_GNU)
if(PLATFORM_MACOSX)
configure_file(Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
diff --git a/desktop/colobot.ico b/desktop/colobot.ico
index 54ab418..e71b6d1 100644
--- a/desktop/colobot.ico
+++ b/desktop/colobot.ico
Binary files differ
diff --git a/desktop/colobot.svg b/desktop/colobot.svg
index ef5949f..c514d6b 100644
--- a/desktop/colobot.svg
+++ b/desktop/colobot.svg
@@ -8,232 +8,394 @@
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="32"
+ height="32"
+ id="svg2"
version="1.1"
- width="48"
- height="48"
- id="colobot-logo"
- style="enable-background:new">
- <title
- id="title3020">Colobot icon</title>
- <metadata
- id="metadata3061">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title>Colobot icon</dc:title>
- <dc:date>2012-12-27</dc:date>
- <dc:rights>
- <cc:Agent>
- <dc:title></dc:title>
- </cc:Agent>
- </dc:rights>
- <dc:creator>
- <cc:Agent>
- <dc:title>Polish Portal of Colobot</dc:title>
- </cc:Agent>
- </dc:creator>
- <cc:license
- rdf:resource="http://www.gnu.org/licenses/gpl-3.0-standalone.html" />
- <dc:description>Three spheres symbolizing planets.</dc:description>
- <dc:contributor>
- <cc:Agent>
- <dc:title>Didier Raboud &lt;odyx@debian.org&gt;</dc:title>
- </cc:Agent>
- </dc:contributor>
- </cc:Work>
- </rdf:RDF>
- </metadata>
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="colobot_gold_icon.svg">
<defs
- id="defs3059">
+ id="defs4">
<linearGradient
- id="linearGradient4108">
+ inkscape:collect="always"
+ id="linearGradient3992">
<stop
- id="stop4110"
- style="stop-color:#008000;stop-opacity:1"
- offset="0" />
+ style="stop-color:#f5c700;stop-opacity:1;"
+ offset="0"
+ id="stop3994" />
<stop
- id="stop4112"
style="stop-color:#000000;stop-opacity:1"
- offset="1" />
+ offset="1"
+ id="stop3996" />
</linearGradient>
<linearGradient
- id="linearGradient4096">
+ inkscape:collect="always"
+ id="linearGradient3984">
<stop
- id="stop4098"
- style="stop-color:#00ff00;stop-opacity:1"
- offset="0" />
+ style="stop-color:#f5c700;stop-opacity:1;"
+ offset="0"
+ id="stop3986" />
<stop
- id="stop4100"
- style="stop-color:#00ff00;stop-opacity:0"
- offset="1" />
+ style="stop-color:#000000;stop-opacity:1"
+ offset="1"
+ id="stop3988" />
</linearGradient>
<linearGradient
- id="linearGradient4108-5">
+ inkscape:collect="always"
+ id="linearGradient3971">
<stop
- id="stop4110-2"
- style="stop-color:#000080;stop-opacity:1"
- offset="0" />
+ style="stop-color:#f5c700;stop-opacity:1;"
+ offset="0"
+ id="stop3973" />
<stop
- id="stop4112-8"
style="stop-color:#000000;stop-opacity:1"
- offset="1" />
+ offset="1"
+ id="stop3975" />
</linearGradient>
<linearGradient
- id="linearGradient4096-0">
+ inkscape:collect="always"
+ id="linearGradient3963">
<stop
- id="stop4098-3"
- style="stop-color:#0000ff;stop-opacity:1"
- offset="0" />
+ style="stop-color:#000000;stop-opacity:1"
+ offset="0"
+ id="stop3965" />
<stop
- id="stop4100-0"
- style="stop-color:#0000ff;stop-opacity:0"
- offset="1" />
+ style="stop-color:#7f6400;stop-opacity:0;"
+ offset="1"
+ id="stop3967" />
</linearGradient>
<linearGradient
- id="linearGradient4108-5-2">
+ inkscape:collect="always"
+ id="linearGradient3945">
<stop
- id="stop4110-2-3"
- style="stop-color:#500000;stop-opacity:1"
- offset="0" />
+ style="stop-color:#f5c700;stop-opacity:1;"
+ offset="0"
+ id="stop3947" />
<stop
- id="stop4112-8-6"
style="stop-color:#000000;stop-opacity:1"
- offset="1" />
+ offset="1"
+ id="stop3949" />
</linearGradient>
<linearGradient
- id="linearGradient4096-0-3">
+ inkscape:collect="always"
+ id="linearGradient3929">
<stop
- id="stop4098-3-7"
- style="stop-color:#ff0000;stop-opacity:1"
- offset="0" />
+ style="stop-color:#1a1500;stop-opacity:1"
+ offset="0"
+ id="stop3931" />
<stop
- id="stop4100-0-3"
- style="stop-color:#ff0000;stop-opacity:0"
- offset="1" />
+ style="stop-color:#d7ae00;stop-opacity:1"
+ offset="1"
+ id="stop3933" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3900"
+ inkscape:collect="always">
+ <stop
+ id="stop3902"
+ offset="0"
+ style="stop-color:#ffd332;stop-opacity:1" />
+ <stop
+ id="stop3904"
+ offset="1"
+ style="stop-color:#000000;stop-opacity:1" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient3875">
+ <stop
+ style="stop-color:#ffd438;stop-opacity:1"
+ offset="0"
+ id="stop3877" />
+ <stop
+ style="stop-color:#000000;stop-opacity:1"
+ offset="1"
+ id="stop3879" />
</linearGradient>
<radialGradient
- cx="54.8265"
- cy="57.607162"
- r="56.05489"
- fx="54.8265"
- fy="57.607162"
- id="radialGradient4416"
- xlink:href="#linearGradient4108-5-2"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
- <radialGradient
- cx="63.5"
- cy="37.5"
- r="32"
- fx="63.5"
- fy="37.5"
- id="radialGradient4418"
- xlink:href="#linearGradient4096-0-3"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
- <radialGradient
- cx="54.8265"
- cy="57.607162"
- r="56.05489"
- fx="54.8265"
- fy="57.607162"
- id="radialGradient4420"
- xlink:href="#linearGradient4108"
- gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
- <radialGradient
- cx="63.5"
- cy="37.5"
- r="32"
- fx="63.5"
- fy="37.5"
- id="radialGradient4422"
- xlink:href="#linearGradient4096"
+ inkscape:collect="always"
+ xlink:href="#linearGradient3900"
+ id="radialGradient3881"
+ cx="17.855946"
+ cy="25.094042"
+ fx="17.855946"
+ fy="25.094042"
+ r="0.99545348"
gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
+ gradientTransform="matrix(2.3589521,0,0,2.3589521,-24.265377,-34.101604)" />
<radialGradient
- cx="54.8265"
- cy="57.607162"
- r="56.05489"
- fx="54.8265"
- fy="57.607162"
- id="radialGradient4424"
- xlink:href="#linearGradient4108-5"
+ inkscape:collect="always"
+ xlink:href="#linearGradient3875"
+ id="radialGradient3891"
+ cx="17.855946"
+ cy="25.094042"
+ fx="17.855946"
+ fy="25.094042"
+ r="0.99545348"
gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(0.02726606,1.3911392,-1.8797791,0.03684323,176.62558,-41.562143)" />
- <radialGradient
- cx="63.5"
- cy="37.5"
- r="32"
- fx="63.5"
- fy="37.5"
- id="radialGradient4426"
- xlink:href="#linearGradient4096-0"
+ gradientTransform="matrix(2.4704161,0,0,2.4704161,-26.255671,-36.898686)" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3929"
+ id="linearGradient3939"
+ x1="3.3806913"
+ y1="1040.2177"
+ x2="24.976213"
+ y2="1037.3557"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3929"
+ id="linearGradient3943"
gradientUnits="userSpaceOnUse"
- gradientTransform="matrix(1,0,0,0.796875,6.7936132,3.6927801)" />
+ x1="3.3806913"
+ y1="1040.2177"
+ x2="24.976213"
+ y2="1037.3557"
+ gradientTransform="matrix(1,0,0,-1,3.746111e-8,2073.851)" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3945"
+ id="linearGradient3951"
+ x1="21.963614"
+ y1="1036.9344"
+ x2="27.312754"
+ y2="1039.2969"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3963"
+ id="linearGradient3969"
+ x1="6.533155"
+ y1="11.615763"
+ x2="6.4043641"
+ y2="17.009403"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3971"
+ id="linearGradient3977"
+ x1="-616.87164"
+ y1="820.93103"
+ x2="-625.89124"
+ y2="820.48627"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3984"
+ id="linearGradient3990"
+ x1="5.9375"
+ y1="13.84375"
+ x2="6.0625"
+ y2="19.5625"
+ gradientUnits="userSpaceOnUse" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3992"
+ id="linearGradient3998"
+ x1="10.5"
+ y1="22.125"
+ x2="7.1875"
+ y2="29.4375"
+ gradientUnits="userSpaceOnUse" />
+ <filter
+ inkscape:collect="always"
+ id="filter4138"
+ x="-0.1131677"
+ width="1.2263354"
+ y="-0.096803329"
+ height="1.1936067">
+ <feGaussianBlur
+ inkscape:collect="always"
+ stdDeviation="1.1726717"
+ id="feGaussianBlur4140" />
+ </filter>
</defs>
- <path
- d="m 35.001373,17.978157 a 17.137194,11.839104 0 1 1 -34.27438587,0 17.137194,11.839104 0 1 1 34.27438587,0 z"
- id="path3068"
- style="opacity:0;color:#000000;fill:#800000;fill-opacity:1;fill-rule:nonzero;stroke:#ff0000;stroke-width:1.45397186;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:11.63177575, 11.63177575;stroke-dashoffset:11.63177575;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1"
+ inkscape:cx="12"
+ inkscape:cy="17.760377"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1280"
+ inkscape:window-height="977"
+ inkscape:window-x="-4"
+ inkscape:window-y="-4"
+ inkscape:window-maximized="1" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
<g
- transform="matrix(1.4527314,0,0,1.4552231,61.790796,7.2674667)"
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
id="layer1"
- style="display:inline">
+ transform="translate(0,-1020.3622)">
<g
- transform="translate(-64.376292,0)"
- id="g4403">
- <g
- transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,78.136911,8.9624182)"
- id="g4122-3-7"
- style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none;display:inline">
- <g
- transform="translate(-232.5787,-246.03551)"
- id="g4259-8">
- <path
- d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
- id="path1873-0-2"
- style="fill:url(#radialGradient4416);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
- <path
- d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
- id="path2814-0-8"
- style="fill:url(#radialGradient4418);fill-opacity:1;fill-rule:nonzero;stroke:none" />
- </g>
- </g>
- <g
- transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,15.374404,17.677401)"
- id="g4122"
- style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none">
- <path
- d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
- id="path1873"
- style="fill:url(#radialGradient4420);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
- <path
- d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
- id="path2814"
- style="fill:url(#radialGradient4422);fill-opacity:1;fill-rule:nonzero;stroke:none" />
- </g>
- <g
- transform="matrix(0.1151419,-0.11259991,0.11259991,0.1151419,57.006572,14.417637)"
- id="g4122-3"
- style="stroke-width:6.52155399;stroke-miterlimit:4;stroke-dasharray:none;display:inline">
- <g
- transform="translate(-136.63091,-98.230764)"
- id="g4259">
- <path
- d="m 128.20539,62.567638 c 0,29.922729 -24.25716,54.179892 -54.179886,54.179892 -29.922729,0 -54.179893,-24.257163 -54.179893,-54.179892 0,-29.922729 24.257164,-54.1798929 54.179893,-54.1798929 29.922726,0 54.179886,24.2571639 54.179886,54.1798929 z"
- id="path1873-0"
- style="fill:url(#radialGradient4424);fill-opacity:1;fill-rule:nonzero;stroke:#808000;stroke-width:4.65700197;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
- <path
- d="m 102.29361,33.575593 c 0,14.083261 -14.326885,25.5 -31.999997,25.5 -17.673112,0 -32,-11.416739 -32,-25.5 0,-14.083261 14.326888,-25.4999999 32,-25.4999999 17.673112,0 31.999997,11.4167389 31.999997,25.4999999 z"
- id="path2814-0"
- style="fill:url(#radialGradient4426);fill-opacity:1;fill-rule:nonzero;stroke:none" />
- </g>
- </g>
+ id="g4088"
+ style="fill:#000000;fill-opacity:1;stroke:none;filter:url(#filter4138)">
+ <path
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ d="M 8.3125 15.125 L 4.3125 15.125 L 4.3125 20.125 L 11.71875 24.03125 L 10.75 19.1875 L 8.3125 17.9375 L 8.3125 15.125 z "
+ id="path4090"
+ transform="translate(0,1020.3622)" />
+ <path
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ d="M 3.9375 15.125 L 4.0625 15.125 L 4.3125 15.125 L 8.3125 15.125 L 10.0625 15.125 L 11.5 11.9375 L 4.0625 11.9375 L 3.9375 11.9375 C 3.1182867 12.0035 2.46875 12.69505 2.46875 13.53125 C 2.46875 14.36735 3.1182867 15.0592 3.9375 15.125 z M 4.25 12.46875 C 4.8128073 12.46875 5.28125 12.9372 5.28125 13.5 C 5.28125 14.0628 4.8128073 14.5 4.25 14.5 C 3.6871927 14.5 3.25 14.0628 3.25 13.5 C 3.25 12.9372 3.6871927 12.46875 4.25 12.46875 z "
+ id="path4092"
+ transform="translate(0,1020.3622)" />
+ <path
+ inkscape:connector-curvature="0"
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ d="m 21.222081,1029.5776 0,3.0313 0,0.2187 c 0.05354,0.5299 0.305986,1.0093 0.6875,1.3438 l -1.34375,3.4062 c 0,0 -0.678869,0.2275 -0.8125,0.5313 -0.133631,0.304 -2.5625,5.6875 -2.5625,5.6875 l 3,1.3125 c 0,0 2.236477,-5.6023 2.34375,-6.0313 0.107269,-0.4291 -0.21875,-0.9687 -0.21875,-0.9687 l 1.34375,-3.4688 c 0.855075,-0.1805 1.502987,-0.9233 1.59375,-1.8125 0.007,-0.069 0.03125,-0.148 0.03125,-0.2187 0,-0.1408 -0.0041,-0.2736 -0.03125,-0.4063 l 0,-2.625 -4.03125,0 z m 2.0625,1.7188 c 0.704607,0 1.25,0.5766 1.25,1.2812 0,0.7046 -0.545393,1.25 -1.25,1.25 -0.704607,0 -1.28125,-0.5454 -1.28125,-1.25 0,-0.7046 0.576643,-1.2812 1.28125,-1.2812 z"
+ id="path4094" />
+ <path
+ style="fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1"
+ d="m 16.099107,1038.143 -6.7434222,0 c 0.5910647,7.0352 6.2969722,12.6107 13.4868442,12.6107 1.164025,0 2.196222,-0.3756 3.276465,-0.6478 l 1.219149,-7.8483 c -1.221328,1.0535 -2.756012,1.7525 -4.495614,1.7525 -3.456847,0 -6.192613,-2.5667 -6.743422,-5.8671 z"
+ id="path4096"
+ inkscape:connector-curvature="0" />
+ <rect
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ id="rect4098"
+ width="7.6608934"
+ height="3.4132693"
+ x="-618.29755"
+ y="819.28662"
+ transform="matrix(0.79194971,-0.61058633,0.61058633,0.79194971,0,0)" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path4100"
+ d="m 16.099107,1035.708 -6.7434222,0 c 0.5910652,-7.0352 6.2969722,-12.6107 13.4868442,-12.6107 1.164025,0 2.196222,0.3756 3.276465,0.6478 l 1.219149,7.8483 c -1.221328,-1.0535 -2.756012,-1.7525 -4.495614,-1.7525 -3.456847,0 -6.192613,2.5667 -6.743422,5.8671 z"
+ style="fill:#000000;fill-opacity:1;stroke:none;stroke-opacity:1" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ id="path4102"
+ sodipodi:cx="17.855946"
+ sodipodi:cy="25.094042"
+ sodipodi:rx="0.99545348"
+ sodipodi:ry="0.99545348"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ transform="matrix(1.5745242,0,0,1.5745242,-9.9475945,1006.505)" />
+ <path
+ transform="matrix(2.375,0,0,2.375,-28.844818,972.79257)"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ sodipodi:ry="0.99545348"
+ sodipodi:rx="0.99545348"
+ sodipodi:cy="25.094042"
+ sodipodi:cx="17.855946"
+ id="path4104"
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ id="path4106"
+ sodipodi:cx="17.855946"
+ sodipodi:cy="25.094042"
+ sodipodi:rx="0.99545348"
+ sodipodi:ry="0.99545348"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ transform="matrix(1.7120874,0,0,1.7120874,-17.007887,989.42773)" />
+ <rect
+ style="fill:#000000;fill-opacity:1;stroke:none"
+ id="rect4108"
+ width="3.9995728"
+ height="4.5299025"
+ x="4.3089318"
+ y="15.095729"
+ transform="translate(0,1020.3622)" />
+ </g>
+ <g
+ id="g4000">
+ <path
+ transform="translate(0,1020.3622)"
+ id="path3982"
+ d="M 8.3125 15.125 L 4.3125 15.125 L 4.3125 20.125 L 11.71875 24.03125 L 10.75 19.1875 L 8.3125 17.9375 L 8.3125 15.125 z "
+ style="fill:url(#linearGradient3998);fill-opacity:1;stroke:none" />
+ <path
+ transform="translate(0,1020.3622)"
+ id="path3838"
+ d="M 3.9375 15.125 L 4.0625 15.125 L 4.3125 15.125 L 8.3125 15.125 L 10.0625 15.125 L 11.5 11.9375 L 4.0625 11.9375 L 3.9375 11.9375 C 3.1182867 12.0035 2.46875 12.69505 2.46875 13.53125 C 2.46875 14.36735 3.1182867 15.0592 3.9375 15.125 z M 4.25 12.46875 C 4.8128073 12.46875 5.28125 12.9372 5.28125 13.5 C 5.28125 14.0628 4.8128073 14.5 4.25 14.5 C 3.6871927 14.5 3.25 14.0628 3.25 13.5 C 3.25 12.9372 3.6871927 12.46875 4.25 12.46875 z "
+ style="fill:url(#linearGradient3990);fill-opacity:1;stroke:none" />
+ <path
+ id="path3846"
+ d="m 21.222081,1029.5776 0,3.0313 0,0.2187 c 0.05354,0.5299 0.305986,1.0093 0.6875,1.3438 l -1.34375,3.4062 c 0,0 -0.678869,0.2275 -0.8125,0.5313 -0.133631,0.304 -2.5625,5.6875 -2.5625,5.6875 l 3,1.3125 c 0,0 2.236477,-5.6023 2.34375,-6.0313 0.107269,-0.4291 -0.21875,-0.9687 -0.21875,-0.9687 l 1.34375,-3.4688 c 0.855075,-0.1805 1.502987,-0.9233 1.59375,-1.8125 0.007,-0.069 0.03125,-0.148 0.03125,-0.2187 0,-0.1408 -0.0041,-0.2736 -0.03125,-0.4063 l 0,-2.625 -4.03125,0 z m 2.0625,1.7188 c 0.704607,0 1.25,0.5766 1.25,1.2812 0,0.7046 -0.545393,1.25 -1.25,1.25 -0.704607,0 -1.28125,-0.5454 -1.28125,-1.25 0,-0.7046 0.576643,-1.2812 1.28125,-1.2812 z"
+ style="fill:url(#linearGradient3951);fill-opacity:1;stroke:none"
+ inkscape:connector-curvature="0" />
+ <path
+ inkscape:connector-curvature="0"
+ id="path3836"
+ d="m 16.099107,1038.143 -6.7434222,0 c 0.5910647,7.0352 6.2969722,12.6107 13.4868442,12.6107 1.164025,0 2.196222,-0.3756 3.276465,-0.6478 l 1.219149,-7.8483 c -1.221328,1.0535 -2.756012,1.7525 -4.495614,1.7525 -3.456847,0 -6.192613,-2.5667 -6.743422,-5.8671 z"
+ style="fill:#f5c700;fill-opacity:1;stroke:url(#linearGradient3939);stroke-opacity:1" />
+ <rect
+ transform="matrix(0.79194971,-0.61058633,0.61058633,0.79194971,0,0)"
+ y="819.28662"
+ x="-618.29755"
+ height="3.4132693"
+ width="7.6608934"
+ id="rect3852"
+ style="fill:url(#linearGradient3977);fill-opacity:1;stroke:none" />
+ <path
+ style="fill:#f5c700;fill-opacity:1;stroke:url(#linearGradient3943);stroke-opacity:1"
+ d="m 16.099107,1035.708 -6.7434222,0 c 0.5910652,-7.0352 6.2969722,-12.6107 13.4868442,-12.6107 1.164025,0 2.196222,0.3756 3.276465,0.6478 l 1.219149,7.8483 c -1.221328,-1.0535 -2.756012,-1.7525 -4.495614,-1.7525 -3.456847,0 -6.192613,2.5667 -6.743422,5.8671 z"
+ id="path3941"
+ inkscape:connector-curvature="0" />
+ <path
+ transform="matrix(1.5745242,0,0,1.5745242,-9.9475945,1006.505)"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ sodipodi:ry="0.99545348"
+ sodipodi:rx="0.99545348"
+ sodipodi:cy="25.094042"
+ sodipodi:cx="17.855946"
+ id="path3860"
+ style="fill:url(#radialGradient3881);fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <path
+ sodipodi:type="arc"
+ style="fill:url(#radialGradient3891);fill-opacity:1;stroke:none"
+ id="path3862"
+ sodipodi:cx="17.855946"
+ sodipodi:cy="25.094042"
+ sodipodi:rx="0.99545348"
+ sodipodi:ry="0.99545348"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ transform="matrix(2.375,0,0,2.375,-28.844818,972.79257)" />
+ <path
+ transform="matrix(1.7120874,0,0,1.7120874,-17.007887,989.42773)"
+ d="m 18.851399,25.094042 c 0,0.549774 -0.44568,0.995453 -0.995453,0.995453 -0.549774,0 -0.995454,-0.445679 -0.995454,-0.995453 0,-0.549774 0.44568,-0.995454 0.995454,-0.995454 0.549773,0 0.995453,0.44568 0.995453,0.995454 z"
+ sodipodi:ry="0.99545348"
+ sodipodi:rx="0.99545348"
+ sodipodi:cy="25.094042"
+ sodipodi:cx="17.855946"
+ id="path3883"
+ style="fill:#f5c700;fill-opacity:1;stroke:none"
+ sodipodi:type="arc" />
+ <rect
+ transform="translate(0,1020.3622)"
+ y="15.095729"
+ x="4.3089318"
+ height="4.5299025"
+ width="3.9995728"
+ id="rect3961"
+ style="fill:url(#linearGradient3969);fill-opacity:1;stroke:none" />
</g>
</g>
</svg>
-
diff --git a/lib/clipboard/CMakeLists.txt b/lib/clipboard/CMakeLists.txt
index a189ec4..7999cc1 100644
--- a/lib/clipboard/CMakeLists.txt
+++ b/lib/clipboard/CMakeLists.txt
@@ -7,8 +7,6 @@ add_definitions(-DLIB_COMPILE=1)
if(PLATFORM_WINDOWS)
set(CLIPBOARD_SRC src/clipboardWin32.c)
-elseif(PLATFORM_LINUX)
- set(CLIPBOARD_SRC src/clipboardX11.c)
else()
set(CLIPBOARD_SRC src/clipboardX11.c)
endif()
diff --git a/po/colobot.pot b/po/colobot.pot
index 8ce386f..f062658 100644
--- a/po/colobot.pot
+++ b/po/colobot.pot
@@ -53,6 +53,9 @@ msgstr ""
msgid "COLOBOT"
msgstr ""
+msgid "COLOBOT: Gold Edition"
+msgstr ""
+
msgid "Programming exercises"
msgstr ""
@@ -68,9 +71,6 @@ msgstr ""
msgid "User levels"
msgstr ""
-msgid "Prototypes"
-msgstr ""
-
msgid "Options"
msgstr ""
@@ -110,9 +110,6 @@ msgstr ""
msgid " Missions on this level:"
msgstr ""
-msgid " Prototypes on this planet:"
-msgstr ""
-
msgid " Free game on this chapter:"
msgstr ""
@@ -276,10 +273,7 @@ msgstr ""
msgid "User\\User levels"
msgstr ""
-msgid "Proto\\Prototypes under development"
-msgstr ""
-
-msgid "New player\\Choose player's name"
+msgid "Change player\\Change player"
msgstr ""
msgid "Options\\Preferences"
diff --git a/po/de.po b/po/de.po
index d0943ab..93a1d7b 100644
--- a/po/de.po
+++ b/po/de.po
@@ -39,9 +39,6 @@ msgstr " Liste der Missionen des Planeten:"
msgid " Planets:"
msgstr " Liste der Planeten:"
-msgid " Prototypes on this planet:"
-msgstr " Liste der Prototypen des Planeten:"
-
msgid " Resolution:"
msgstr " Auflösung:"
@@ -88,15 +85,12 @@ msgstr "3D-Geräusche\\Orten der Geräusche im Raum"
msgid "<< Back \\Back to the previous screen"
msgstr "<< Zurück \\Zurück zum Hauptmenü"
-#, fuzzy
msgid "<<< Sorry; mission failed >>>"
msgstr "<<< Mission gescheitert >>>"
-#, fuzzy
msgid "<<< Well done; mission accomplished >>>"
msgstr "<<< Bravo, Mission vollendet >>>"
-#, fuzzy
msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\""
msgstr ""
"Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder "
@@ -314,6 +308,9 @@ msgstr "Knopf %1"
msgid "COLOBOT"
msgstr "COLOBOT"
+msgid "COLOBOT: Gold Edition"
+msgstr "COLOBOT: Gold Edition"
+
msgid "Calling an unknown function"
msgstr "Die aufgerufene Funktion existiert nicht"
@@ -338,7 +335,6 @@ msgstr "Kamera links"
msgid "Camera to right"
msgstr "Kamera rechts"
-#, fuzzy
msgid "Can not create this; there are too many objects"
msgstr "Kein neues Objekt kann erstellt werden (zu viele vorhanden)"
@@ -363,6 +359,9 @@ msgstr "Challenges\\Herausforderungen"
msgid "Change camera\\Switches between onboard camera and following camera"
msgstr "Andere Kamera\\Sichtpunkt einstellen"
+msgid "Change player\\Change player"
+msgstr "Anderer Spieler\\Spielername ändern"
+
msgid "Checkpoint"
msgstr "Checkpoint"
@@ -699,7 +698,6 @@ msgstr "Falscher Batterietyp"
msgid "Incorrect index type"
msgstr "Falscher Typ für einen Index"
-#, fuzzy
msgid "Infected by a virus; temporarily out of order"
msgstr "Von Virus infiziert, zeitweise außer Betrieb"
@@ -847,9 +845,6 @@ msgstr "Neu ..."
msgid "New bot available"
msgstr "Neuer Roboter verfügbar"
-msgid "New player\\Choose player's name"
-msgstr "Anderer Spieler\\Spielername ändern"
-
msgid "Next"
msgstr "Nächster"
@@ -1114,12 +1109,6 @@ msgstr "Hilfe CBOT-Sprache\\Hilfe über die Programmiersprache CBOT"
msgid "Programs dispatched by Houston"
msgstr "Von Houston übermittelte Programme"
-msgid "Proto\\Prototypes under development"
-msgstr "Proto\\In Entwicklung befindliche Prototypen"
-
-msgid "Prototypes"
-msgstr "Prototypen"
-
msgid "Public required"
msgstr "Hier muss das Wort \"public\" stehen"
@@ -2053,4 +2042,3 @@ msgstr "www.epsitec.com"
#~ msgid "Zoom"
#~ msgstr "Zoom"
-
diff --git a/po/fr.po b/po/fr.po
index 343458d..e6be922 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -44,9 +44,6 @@ msgstr " Liste des missions du chapitre :"
msgid " Planets:"
msgstr " Liste des planètes :"
-msgid " Prototypes on this planet:"
-msgstr " Liste des prototypes du chapitre :"
-
msgid " Resolution:"
msgstr " Résolutions :"
@@ -315,6 +312,9 @@ msgstr "Bouton %1"
msgid "COLOBOT"
msgstr "COLOBOT"
+msgid "COLOBOT: Gold Edition"
+msgstr "COLOBOT: Gold Edition"
+
msgid "Calling an unknown function"
msgstr "Appel d'une fonction inexistante"
@@ -363,6 +363,9 @@ msgstr "Défis\\Défis de programmation"
msgid "Change camera\\Switches between onboard camera and following camera"
msgstr "Changement de caméra\\Autre de point de vue"
+msgid "Change player\\Change player"
+msgstr "Autre joueur\\Choix du nom du joueur"
+
msgid "Checkpoint"
msgstr "Indicateur"
@@ -848,9 +851,6 @@ msgstr "Nouveau ..."
msgid "New bot available"
msgstr "Nouveau robot disponible"
-msgid "New player\\Choose player's name"
-msgstr "Autre joueur\\Choix du nom du joueur"
-
msgid "Next"
msgstr "Suivant"
@@ -1115,12 +1115,6 @@ msgstr "Instructions programmation\\Explication sur la programmation"
msgid "Programs dispatched by Houston"
msgstr "Programmes envoyés par Houston"
-msgid "Proto\\Prototypes under development"
-msgstr "Proto\\Prototypes en cours d'élaboration"
-
-msgid "Prototypes"
-msgstr "Prototypes"
-
msgid "Public required"
msgstr "Public requis"
@@ -2055,4 +2049,3 @@ msgstr "www.epsitec.com"
#~ msgid "Zoom"
#~ msgstr "Zoom"
-
diff --git a/po/pl.po b/po/pl.po
index 4cbfe60..0b13dbb 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -26,7 +26,7 @@ msgid " Exercises in the chapter:"
msgstr " Ćwiczenia w tym rozdziale:"
msgid " Free game on this chapter:"
-msgstr " Prototypy na tej planecie:"
+msgstr " Swobodna gra na tej planecie:"
msgid " Free game on this planet:"
msgstr " Swobodna gra na tej planecie:"
@@ -40,9 +40,6 @@ msgstr " Misje na tej planecie:"
msgid " Planets:"
msgstr " Planety:"
-msgid " Prototypes on this planet:"
-msgstr " Prototypy na tej planecie:"
-
msgid " Resolution:"
msgstr " Rozdzielczość:"
@@ -89,15 +86,12 @@ msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
msgid "<< Back \\Back to the previous screen"
msgstr "<< Wstecz \\Wraca do poprzedniego ekranu"
-#, fuzzy
msgid "<<< Sorry; mission failed >>>"
msgstr "<<< Niestety, misja nie powiodła się >>>"
-#, fuzzy
msgid "<<< Well done; mission accomplished >>>"
msgstr "<<< Dobra robota, misja wypełniona >>>"
-#, fuzzy
msgid "A label must be followed by \"for\"; \"while\"; \"do\" or \"switch\""
msgstr "Po etykiecie musi wystąpić \"for\", \"while\", \"do\" lub \"switch\""
@@ -316,6 +310,9 @@ msgstr "Przycisk %1"
msgid "COLOBOT"
msgstr "COLOBOT"
+msgid "COLOBOT: Gold Edition"
+msgstr "COLOBOT: Gold Edition"
+
msgid "Calling an unknown function"
msgstr "Odwołanie do nieznanej funkcji"
@@ -340,7 +337,6 @@ msgstr "Camera to left"
msgid "Camera to right"
msgstr "Camera to right"
-#, fuzzy
msgid "Can not create this; there are too many objects"
msgstr "Nie można tego utworzyć, za dużo obiektów"
@@ -365,6 +361,9 @@ msgstr "Wyzwania\\Wyzwania programistyczne"
msgid "Change camera\\Switches between onboard camera and following camera"
msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą"
+msgid "Change player\\Change player"
+msgstr "Zmień gracza\\Zmień gracza"
+
msgid "Checkpoint"
msgstr "Punkt kontrolny"
@@ -702,7 +701,6 @@ msgstr "Nieodpowiedni rodzaj ogniw"
msgid "Incorrect index type"
msgstr "Nieprawidłowy typ indeksu"
-#, fuzzy
msgid "Infected by a virus; temporarily out of order"
msgstr "Zainfekowane wirusem, chwilowo niesprawne"
@@ -852,9 +850,6 @@ msgstr "Nowy ..."
msgid "New bot available"
msgstr "Dostępny nowy robot"
-msgid "New player\\Choose player's name"
-msgstr "Nowy gracz\\Wybierz imię gracza"
-
msgid "Next"
msgstr "Następny"
@@ -1121,12 +1116,6 @@ msgstr "Podręcznik programowania\\Dostarcza szczegółową pomoc w programowani
msgid "Programs dispatched by Houston"
msgstr "Program dostarczony z Houston"
-msgid "Proto\\Prototypes under development"
-msgstr "Prototypy\\Prototypy w trakcie rozwijania"
-
-msgid "Prototypes"
-msgstr "Prototypy"
-
msgid "Public required"
msgstr "Wymagany publiczny"
@@ -2063,4 +2052,3 @@ msgstr "www.epsitec.com"
#~ msgid "Zoom"
#~ msgstr "Powiększenie"
-
diff --git a/po/ru.po b/po/ru.po
index 012395a..22f84a8 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -49,9 +49,6 @@ msgstr "Миссии на этой планете:"
msgid " Planets:"
msgstr " Планеты:"
-msgid " Prototypes on this planet:"
-msgstr "Прототипы на этой планете:"
-
msgid " Resolution:"
msgstr " Разрешение:"
@@ -318,6 +315,9 @@ msgstr "Кнопка %1"
msgid "COLOBOT"
msgstr "КОЛОБОТ"
+msgid "COLOBOT: Gold Edition"
+msgstr ""
+
msgid "Calling an unknown function"
msgstr "Вызов неизвестной функции"
@@ -366,6 +366,9 @@ msgstr "Задания\\Практика программирования"
msgid "Change camera\\Switches between onboard camera and following camera"
msgstr "Изменить вид\\Переключение между бортовой камерой и следящей камерой"
+msgid "Change player\\Change player"
+msgstr "Новый игрок\\Выберите имя для игрока"
+
msgid "Checkpoint"
msgstr "Контрольная точка"
@@ -849,9 +852,6 @@ msgstr "Новый ..."
msgid "New bot available"
msgstr "Доступен новый бот"
-msgid "New player\\Choose player's name"
-msgstr "Новый игрок\\Выберите имя для игрока"
-
msgid "Next"
msgstr "Следующий"
@@ -1119,12 +1119,6 @@ msgstr ""
msgid "Programs dispatched by Houston"
msgstr "Программы переданные с Хьюстона"
-msgid "Proto\\Prototypes under development"
-msgstr "Прототипы\\Прототипы в стадии разработки"
-
-msgid "Prototypes"
-msgstr "Прототипы"
-
msgid "Public required"
msgstr "Требуется общественное"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ef59973..12171f3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,6 +28,8 @@ if(MXE) # MXE requires special treatment
elseif(PLATFORM_WINDOWS)
# because it isn't included in standard linking libraries
set(PLATFORM_LIBS "-lintl")
+elseif(PLATFORM_GNU)
+ set(PLATFORM_LIBS "-lX11")
elseif(PLATFORM_LINUX)
# for clock_gettime
set(PLATFORM_LIBS "-lrt -lX11")
@@ -59,7 +61,9 @@ endif()
# Source files
set(SOURCES
app/app.cpp
+app/gamedata.cpp
app/main.cpp
+app/pausemanager.cpp
app/system.cpp
app/${SYSTEM_CPP_MODULE}
app/system_other.cpp
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 4484e2a..8b310c9 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -19,6 +19,7 @@
#include "app/app.h"
+#include "app/gamedata.h"
#include "app/system.h"
#include "common/logger.h"
@@ -100,6 +101,7 @@ CApplication::CApplication()
m_objMan = new CObjectManager();
m_eventQueue = new CEventQueue();
m_profile = new CProfile();
+ m_gameData = new CGameData();
m_engine = nullptr;
m_device = nullptr;
@@ -112,7 +114,7 @@ CApplication::CApplication()
m_debugModes = 0;
m_customDataPath = false;
- m_windowTitle = "COLOBOT";
+ m_windowTitle = "COLOBOT GOLD";
m_simulationSuspended = false;
@@ -149,29 +151,17 @@ CApplication::CApplication()
m_dataPath = GetSystemUtils()->GetDataPath();
m_langPath = GetSystemUtils()->GetLangPath();
- m_texPackPath = "";
m_runSceneName = "";
m_runSceneRank = 0;
+
+ m_sceneTest = false;
m_language = LANGUAGE_ENV;
m_lowCPU = true;
m_protoMode = false;
-
- for (int i = 0; i < DIR_MAX; ++i)
- m_standardDataDirs[i] = nullptr;
-
- m_standardDataDirs[DIR_AI] = "ai";
- m_standardDataDirs[DIR_FONT] = "fonts";
- m_standardDataDirs[DIR_HELP] = "help";
- m_standardDataDirs[DIR_ICON] = "icons";
- m_standardDataDirs[DIR_LEVEL] = "levels";
- m_standardDataDirs[DIR_MODEL] = "models";
- m_standardDataDirs[DIR_MUSIC] = "music";
- m_standardDataDirs[DIR_SOUND] = "sounds";
- m_standardDataDirs[DIR_TEXTURE] = "textures";
}
CApplication::~CApplication()
@@ -190,6 +180,9 @@ CApplication::~CApplication()
delete m_iMan;
m_iMan = nullptr;
+
+ delete m_gameData;
+ m_gameData = nullptr;
GetSystemUtils()->DestroyTimeStamp(m_baseTimeStamp);
GetSystemUtils()->DestroyTimeStamp(m_curTimeStamp);
@@ -210,12 +203,6 @@ CEventQueue* CApplication::GetEventQueue()
CSoundInterface* CApplication::GetSound()
{
return m_sound;
-
- for (int i = 0; i < PCNT_MAX; ++i)
- {
- GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][0]);
- GetSystemUtils()->DestroyTimeStamp(m_performanceCounters[i][1]);
- }
}
ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
@@ -225,13 +212,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
OPT_HELP = 1,
OPT_DEBUG,
OPT_RUNSCENE,
+ OPT_SCENETEST,
OPT_LOGLEVEL,
OPT_LANGUAGE,
OPT_DATADIR,
+ OPT_MOD,
OPT_LANGDIR,
- OPT_TEXPACK,
- OPT_VBO,
- OPT_PROTO
+ OPT_VBO
};
option options[] =
@@ -239,13 +226,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{ "help", no_argument, nullptr, OPT_HELP },
{ "debug", required_argument, nullptr, OPT_DEBUG },
{ "runscene", required_argument, nullptr, OPT_RUNSCENE },
+ { "scenetest", no_argument, nullptr, OPT_SCENETEST },
{ "loglevel", required_argument, nullptr, OPT_LOGLEVEL },
{ "language", required_argument, nullptr, OPT_LANGUAGE },
{ "datadir", required_argument, nullptr, OPT_DATADIR },
+ { "mod", required_argument, nullptr, OPT_MOD },
{ "langdir", required_argument, nullptr, OPT_LANGDIR },
- { "texpack", required_argument, nullptr, OPT_TEXPACK },
{ "vbo", required_argument, nullptr, OPT_VBO },
- { "proto", no_argument, nullptr, OPT_PROTO },
{ nullptr, 0, nullptr, 0}
};
@@ -279,13 +266,13 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
GetLogger()->Message(" -help this help\n");
GetLogger()->Message(" -debug modes enable debug modes (more info printed in logs; see code for reference of modes)\n");
GetLogger()->Message(" -runscene sceneNNN run given scene on start\n");
+ GetLogger()->Message(" -scenetest win every mission right after it's loaded\n");
GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl, ru)\n");
GetLogger()->Message(" -datadir path set custom data directory path\n");
+ GetLogger()->Message(" -mod path run mod\n");
GetLogger()->Message(" -langdir path set custom language directory path\n");
- GetLogger()->Message(" -texpack path set path to custom texture pack\n");
GetLogger()->Message(" -vbo mode set OpenGL VBO mode (one of: auto, enable, disable)\n");
- GetLogger()->Message(" -proto show prototype levels\n");
return PARSE_ARGS_HELP;
}
case OPT_DEBUG:
@@ -316,6 +303,11 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
GetLogger()->Info("Running scene '%s%d' on start\n", m_runSceneName.c_str(), m_runSceneRank);
break;
}
+ case OPT_SCENETEST:
+ {
+ m_sceneTest = true;
+ break;
+ }
case OPT_LOGLEVEL:
{
LogLevel logLevel;
@@ -346,19 +338,19 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{
m_dataPath = optarg;
m_customDataPath = true;
- GetLogger()->Info("Using custom datadir or running mod: '%s'\n", m_dataPath.c_str());
+ GetLogger()->Info("Using datadir: '%s'\n", optarg);
break;
}
- case OPT_LANGDIR:
+ case OPT_MOD:
{
- m_langPath = optarg;
- GetLogger()->Info("Using custom language dir: '%s'\n", m_langPath.c_str());
+ m_gameData->AddMod(std::string(optarg));
+ GetLogger()->Info("Running mod from path: '%s'\n", optarg);
break;
}
- case OPT_TEXPACK:
+ case OPT_LANGDIR:
{
- m_texPackPath = optarg;
- GetLogger()->Info("Using texturepack: '%s'\n", m_texPackPath.c_str());
+ m_langPath = optarg;
+ GetLogger()->Info("Using language dir: '%s'\n", m_langPath.c_str());
break;
}
case OPT_VBO:
@@ -379,11 +371,6 @@ ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
break;
}
- case OPT_PROTO:
- {
- m_protoMode = true;
- break;
- }
default:
assert(false); // should never get here
}
@@ -420,11 +407,19 @@ bool CApplication::Create()
m_exitCode = 1;
return false;
}
-
-#if !defined(PLATFORM_MACOSX)
- // On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
- GetProfile().SetLocalProfileString("Resources", "Data", m_dataPath);
-#endif
+
+ m_gameData->SetDataDir(std::string(m_dataPath));
+ m_gameData->Init();
+
+ if (GetProfile().GetLocalProfileString("Language", "Lang", path)) {
+ Language language;
+ if (ParseLanguage(path, language)) {
+ m_language = language;
+ GetLogger()->Info("Setting language '%s' from ini file\n", path.c_str());
+ } else {
+ GetLogger()->Error("Invalid language '%s' in ini file\n", path.c_str());
+ }
+ }
SetLanguage(m_language);
@@ -436,36 +431,9 @@ bool CApplication::Create()
m_sound = new CSoundInterface();
#endif
- m_sound->Create(true);
-
-#if !defined(PLATFORM_MACOSX)
- // On Mac OSX, the bundle can potentially change place, it doesn't make sense to cache it to the configuration file
-
- // Cache sound files
- if (defaultValues)
- {
- GetProfile().SetLocalProfileString("Resources", "Sound", GetDataSubdirPath(DIR_SOUND));
- GetProfile().SetLocalProfileString("Resources", "Music", GetDataSubdirPath(DIR_MUSIC));
- }
-#endif
-
- if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Sound", path))
- {
- m_sound->CacheAll(path);
- }
- else
- {
- m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
- }
-
- if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Music", path))
- {
- m_sound->AddMusicFiles(path);
- }
- else
- {
- m_sound->AddMusicFiles(GetDataSubdirPath(DIR_MUSIC));
- }
+ m_sound->Create();
+ m_sound->CacheAll();
+ m_sound->AddMusicFiles();
GetLogger()->Info("CApplication created successfully\n");
@@ -962,15 +930,15 @@ int CApplication::Run()
{
LogEvent(event);
- StartPerformanceCounter(PCNT_UPDATE_ENGINE);
- m_engine->FrameUpdate();
- StopPerformanceCounter(PCNT_UPDATE_ENGINE);
-
m_sound->FrameMove(m_relTime);
StartPerformanceCounter(PCNT_UPDATE_GAME);
m_robotMain->ProcessEvent(event);
StopPerformanceCounter(PCNT_UPDATE_GAME);
+
+ StartPerformanceCounter(PCNT_UPDATE_ENGINE);
+ m_engine->FrameUpdate();
+ StopPerformanceCounter(PCNT_UPDATE_ENGINE);
}
StopPerformanceCounter(PCNT_UPDATE_ALL);
@@ -1608,59 +1576,6 @@ bool CApplication::GetJoystickEnabled() const
return m_joystickEnabled;
}
-std::string CApplication::GetDataDirPath() const
-{
- return m_dataPath;
-}
-
-std::string CApplication::GetDataSubdirPath(DataDir stdDir) const
-{
- int index = static_cast<int>(stdDir);
- assert(index >= 0 && index < DIR_MAX);
- std::stringstream str;
- str << m_dataPath;
- str << "/";
- str << m_standardDataDirs[index];
- return str.str();
-}
-
-std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath) const
-{
- int index = static_cast<int>(stdDir);
- assert(index >= 0 && index < DIR_MAX);
- std::stringstream str;
- str << m_dataPath;
- str << "/";
- str << m_standardDataDirs[index];
- if (stdDir == DIR_HELP)
- {
- str << "/";
- str << GetLanguageChar();
- }
- str << "/";
- str << subpath;
- return str.str();
-}
-
-std::string CApplication::GetTexPackFilePath(const std::string& textureName) const
-{
- std::stringstream str;
-
- if (! m_texPackPath.empty())
- {
- str << m_texPackPath;
- str << "/";
- str << textureName;
- if (! boost::filesystem::exists(str.str()))
- {
- GetLogger()->Trace("Texture '%s' not in texpack\n", textureName.c_str());
- str.str("");
- }
- }
-
- return str.str();
-}
-
Language CApplication::GetLanguage() const
{
return m_language;
@@ -1868,8 +1783,7 @@ void CApplication::UpdatePerformanceCountersData()
}
}
-bool CApplication::GetProtoMode() const
+bool CApplication::GetSceneTestMode()
{
- return m_protoMode;
+ return m_sceneTest;
}
-
diff --git a/src/app/app.h b/src/app/app.h
index 6b02f67..86a757f 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -42,6 +42,7 @@ class CInstanceManager;
class CEventQueue;
class CRobotMain;
class CSoundInterface;
+class CGameData;
namespace Gfx {
class CModelManager;
@@ -328,18 +329,6 @@ public:
static bool ParseDebugModes(const std::string& str, int& debugModes);
//@}
- //! Returns the full path to data directory
- std::string GetDataDirPath() const;
-
- //! Returns the full path to a standard dir in data directory
- std::string GetDataSubdirPath(DataDir stdDir) const;
-
- //! Returns the full path to a file in data directory given standard dir and subpath
- std::string GetDataFilePath(DataDir stdDir, const std::string &subpath) const;
-
- //! Returns the full path to a file in texture pack directory
- std::string GetTexPackFilePath(const std::string& textureName) const;
-
//! Management of language
//@{
Language GetLanguage() const;
@@ -360,8 +349,8 @@ public:
void StopPerformanceCounter(PerformanceCounter counter);
float GetPerformanceCounterData(PerformanceCounter counter) const;
//@}
-
- bool GetProtoMode() const;
+
+ bool GetSceneTestMode();
protected:
//! Creates the window's SDL_Surface
@@ -413,6 +402,8 @@ protected:
CRobotMain* m_robotMain;
//! Profile (INI) reader/writer
CProfile* m_profile;
+ //! Game data
+ CGameData* m_gameData;
//! Code to return at exit
int m_exitCode;
@@ -485,17 +476,15 @@ protected:
//! Path to directory with language files
std::string m_langPath;
-
- //! Path to directory with user texture pack
- std::string m_texPackPath;
-
+
//@{
//! Scene to run on startup
std::string m_runSceneName;
int m_runSceneRank;
//@}
-
- const char* m_standardDataDirs[DIR_MAX];
+
+ //! Scene test mode
+ bool m_sceneTest;
//! Application language
Language m_language;
diff --git a/src/app/gamedata.cpp b/src/app/gamedata.cpp
new file mode 100644
index 0000000..ceeb7b3
--- /dev/null
+++ b/src/app/gamedata.cpp
@@ -0,0 +1,136 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+#include "app/gamedata.h"
+
+
+#include "app/app.h"
+
+#include <boost/filesystem.hpp>
+
+template<> CGameData* CSingleton<CGameData>::m_instance = nullptr;
+
+CGameData::CGameData()
+{
+ m_dataDirSet = false;
+
+ for (int i = 0; i < DIR_MAX; ++i)
+ m_standardDataDirs[i] = nullptr;
+
+ m_standardDataDirs[DIR_AI] = "ai";
+ m_standardDataDirs[DIR_FONT] = "fonts";
+ m_standardDataDirs[DIR_HELP] = "help";
+ m_standardDataDirs[DIR_ICON] = "icons";
+ m_standardDataDirs[DIR_LEVEL] = "levels";
+ m_standardDataDirs[DIR_MODEL] = "models";
+ m_standardDataDirs[DIR_MUSIC] = "music";
+ m_standardDataDirs[DIR_SOUND] = "sounds";
+ m_standardDataDirs[DIR_TEXTURE] = "textures";
+}
+
+CGameData::~CGameData()
+{
+}
+
+void CGameData::SetDataDir(std::string path)
+{
+ assert(!m_dataDirSet);
+ m_dataDirSet = true;
+
+ m_dataDirs.insert(m_dataDirs.begin(), path);
+}
+
+void CGameData::AddMod(std::string path)
+{
+ m_dataDirs.push_back(path);
+}
+
+void CGameData::Init()
+{
+ std::string out = "Using datadirs: ";
+ bool first = true;
+ for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
+ if(!first) out += ", ";
+ first = false;
+ out += *rit;
+ }
+ out += "\n";
+ CLogger::GetInstancePointer()->Info(out.c_str());
+}
+
+std::string CGameData::GetFilePath(DataDir dir, const std::string& subpath)
+{
+ int index = static_cast<int>(dir);
+ assert(index >= 0 && index < DIR_MAX);
+
+ for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
+ std::stringstream str;
+
+ if ( subpath.find("save") == std::string::npos ){ // if its NOT a path to a savefile screenshot
+ str << *rit;
+ str << "/";
+ str << m_standardDataDirs[index];
+
+ if (dir == DIR_HELP)
+ {
+ str << "/";
+ str << CApplication::GetInstancePointer()->GetLanguageChar();
+ }
+ str << "/";
+ }
+
+ str << subpath;
+
+ boost::filesystem::path path(str.str());
+ if(boost::filesystem::exists(path))
+ {
+ return str.str();
+ }
+ }
+
+ if(m_dataDirs.size() > 0) {
+ std::stringstream str;
+ if ( subpath.find("save") == std::string::npos ){ // if its NOT a path to a savefile screenshot
+ str << m_dataDirs[0];
+ str << "/";
+ str << m_standardDataDirs[index];
+
+ if (dir == DIR_HELP)
+ {
+ str << "/";
+ str << CApplication::GetInstancePointer()->GetLanguageChar();
+ }
+ str << "/";
+ }
+ str << subpath;
+ return str.str();
+ }
+
+ return subpath;
+}
+
+std::string CGameData::GetDataPath(const std::string &subpath)
+{
+ for(std::vector<std::string>::reverse_iterator rit = m_dataDirs.rbegin(); rit != m_dataDirs.rend(); ++rit) {
+ std::string path = *rit + "/" + subpath;
+ boost::filesystem::path boostPath(path);
+ if(boost::filesystem::exists(boostPath))
+ {
+ return path;
+ }
+ }
+ return m_dataDirs[0] + "/" + subpath;
+}
diff --git a/src/app/gamedata.h b/src/app/gamedata.h
new file mode 100644
index 0000000..b7536a2
--- /dev/null
+++ b/src/app/gamedata.h
@@ -0,0 +1,66 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2014, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+/**
+ * \file app/gamedata.h
+ * \brief Game data
+ */
+
+#pragma once
+
+#include "common/singleton.h"
+
+#include <string>
+#include <vector>
+
+/**
+ * \enum DataDir
+ * \brief Directories in data directory
+ */
+enum DataDir
+{
+ DIR_AI, //! < ai scripts
+ DIR_FONT, //! < fonts
+ DIR_HELP, //! < help files
+ DIR_ICON, //! < icons & images
+ DIR_LEVEL, //! < levels
+ DIR_MODEL, //! < models
+ DIR_MUSIC, //! < music
+ DIR_SOUND, //! < sounds
+ DIR_TEXTURE, //! < textures
+
+ DIR_MAX //! < number of dirs
+};
+
+class CGameData : public CSingleton<CGameData>
+{
+public:
+ CGameData();
+ ~CGameData();
+
+ void Init();
+ void SetDataDir(std::string path);
+ void AddMod(std::string path);
+
+ std::string GetFilePath(DataDir dir, const std::string &subpath);
+ std::string GetDataPath(const std::string &subpath);
+
+private:
+ bool m_dataDirSet;
+ std::vector<std::string> m_dataDirs;
+ const char* m_standardDataDirs[DIR_MAX];
+};
+
diff --git a/src/app/pausemanager.cpp b/src/app/pausemanager.cpp
new file mode 100644
index 0000000..d357bba
--- /dev/null
+++ b/src/app/pausemanager.cpp
@@ -0,0 +1,94 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+#include "app/app.h"
+#include "app/pausemanager.h"
+
+#include "common/logger.h"
+
+#include "object/robotmain.h"
+
+
+template<> CPauseManager* CSingleton<CPauseManager>::m_instance = nullptr;
+
+
+CPauseManager::CPauseManager()
+{
+ m_sound = CApplication::GetInstancePointer()->GetSound();
+
+ m_pause = PAUSE_NONE;
+}
+
+CPauseManager::~CPauseManager()
+{
+ m_sound = nullptr;
+}
+
+void CPauseManager::SetPause(PauseType pause)
+{
+ if(pause != PAUSE_NONE) {
+ if(m_pause != pause) {
+ CLogger::GetInstancePointer()->Info("Game paused - %s\n", GetPauseName(pause).c_str());
+ CRobotMain::GetInstancePointer()->StartPauseMusic(pause);
+ }
+
+ m_pause = pause;
+ } else
+ ClearPause();
+}
+
+void CPauseManager::ClearPause()
+{
+ if(m_pause != PAUSE_NONE) {
+ CLogger::GetInstancePointer()->Info("Game resumed\n");
+ m_sound->StopPauseMusic();
+ }
+
+ m_pause = PAUSE_NONE;
+}
+
+bool CPauseManager::GetPause()
+{
+ return m_pause != PAUSE_NONE;
+}
+
+bool CPauseManager::GetPause(PauseType pause)
+{
+ return m_pause == pause;
+}
+
+PauseType CPauseManager::GetPauseType()
+{
+ return m_pause;
+}
+
+std::string CPauseManager::GetPauseName(PauseType pause)
+{
+ switch(pause)
+ {
+ case PAUSE_NONE: return "None";
+ case PAUSE_USER: return "User";
+ case PAUSE_SATCOM: return "SatCom";
+ case PAUSE_SATCOMMOVIE: return "SatCom opening animation";
+ case PAUSE_DIALOG: return "Dialog";
+ case PAUSE_EDITOR: return "CBot editor";
+ case PAUSE_VISIT: return "Visit";
+ case PAUSE_CHEAT: return "Cheat console";
+ case PAUSE_PHOTO: return "Photo mode";
+ default: assert(false); // Should never happen
+ }
+}
diff --git a/src/app/pausemanager.h b/src/app/pausemanager.h
new file mode 100644
index 0000000..fefc4a5
--- /dev/null
+++ b/src/app/pausemanager.h
@@ -0,0 +1,62 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+/**
+ * \file app/pausemanager.h
+ * \brief Management of pause modes
+ */
+#pragma once
+
+#include "common/singleton.h"
+#include "sound/sound.h"
+
+#include <string>
+
+
+enum PauseType {
+ PAUSE_NONE = 0,
+ PAUSE_USER,
+ PAUSE_SATCOM,
+ PAUSE_SATCOMMOVIE,
+ PAUSE_DIALOG,
+ PAUSE_EDITOR,
+ PAUSE_VISIT,
+ PAUSE_CHEAT,
+ PAUSE_PHOTO
+};
+
+class CPauseManager : public CSingleton<CPauseManager>
+{
+public:
+ CPauseManager();
+ ~CPauseManager();
+
+ void SetPause(PauseType pause);
+ void ClearPause();
+ bool GetPause();
+ bool GetPause(PauseType pause);
+ PauseType GetPauseType();
+
+private:
+ std::string GetPauseName(PauseType pause);
+
+private:
+ CSoundInterface* m_sound;
+
+ PauseType m_pause;
+};
+
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 63cd93b..98ccefe 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -3,6 +3,7 @@
// Macros set by CMake
#cmakedefine PLATFORM_WINDOWS @PLATFORM_WINDOWS@
#cmakedefine PLATFORM_LINUX @PLATFORM_LINUX@
+#cmakedefine PLATFORM_GNU @PLATFORM_GNU@
#cmakedefine PLATFORM_MACOSX @PLATFORM_MACOSX@
#cmakedefine PLATFORM_OTHER @PLATFORM_OTHER@
@@ -26,6 +27,7 @@
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@"
#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@"
+#define COLOBOT_VERSION_DISPLAY "@COLOBOT_VERSION_DISPLAY@"
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 7acac77..9dc3943 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -161,7 +161,6 @@ void InitializeEventTypeTexts()
EVENT_TYPE_TEXT[EVENT_INTERFACE_DEFI] = "EVENT_INTERFACE_DEFI";
EVENT_TYPE_TEXT[EVENT_INTERFACE_MISSION] = "EVENT_INTERFACE_MISSION";
EVENT_TYPE_TEXT[EVENT_INTERFACE_FREE] = "EVENT_INTERFACE_FREE";
- EVENT_TYPE_TEXT[EVENT_INTERFACE_PROTO] = "EVENT_INTERFACE_PROTO";
EVENT_TYPE_TEXT[EVENT_INTERFACE_NAME] = "EVENT_INTERFACE_NAME";
EVENT_TYPE_TEXT[EVENT_INTERFACE_SETUP] = "EVENT_INTERFACE_SETUP";
EVENT_TYPE_TEXT[EVENT_INTERFACE_QUIT] = "EVENT_INTERFACE_QUIT";
diff --git a/src/common/event.h b/src/common/event.h
index 9405660..c5eb615 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -184,7 +184,6 @@ enum EventType
EVENT_INTERFACE_DEFI = 401,
EVENT_INTERFACE_MISSION = 402,
EVENT_INTERFACE_FREE = 403,
- EVENT_INTERFACE_PROTO = 404,
EVENT_INTERFACE_NAME = 405,
EVENT_INTERFACE_SETUP = 406,
EVENT_INTERFACE_QUIT = 407,
diff --git a/src/common/global.h b/src/common/global.h
index da62bac..4049bdc 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -28,137 +28,138 @@
*/
enum Error
{
- ERR_OK = 0, //! < ok
- ERR_GENERIC = 1, //! < any error
- ERR_CONTINUE = 2, //! < continues
- ERR_STOP = 3, //! < stops
- ERR_CMD = 4, //! < unknown command
- ERR_MANIP_VEH = 100, //! < inappropriate vehicle
- ERR_MANIP_FLY = 101, //! < impossible in flight
- ERR_MANIP_BUSY = 102, //! < taking: hands already occupied
- ERR_MANIP_NIL = 103, //! < taking: nothing has to take
- ERR_MANIP_MOTOR = 105, //! < busy: impossible to move
- ERR_MANIP_OCC = 106, //! < busy: location already occupied
- ERR_MANIP_FRIEND = 107, //! < no other vehicle
- ERR_MANIP_RADIO = 108, //! < impossible because radioactive
- ERR_MANIP_WATER = 109, //! < not possible under water
- ERR_MANIP_EMPTY = 110, //! < nothing to deposit
- ERR_BUILD_FLY = 120, //! < not possible in flight
- ERR_BUILD_WATER = 121, //! < not possible under water
- ERR_BUILD_ENERGY = 122, //! < not enough energy
- ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far)
- ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close)
- ERR_BUILD_METALINEX = 125, //! < lack of metal
- ERR_BUILD_FLAT = 126, //! < not enough flat ground
- ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space
- ERR_BUILD_BUSY = 128, //! < location occupied
- ERR_BUILD_BASE = 129, //! < too close to the rocket
- ERR_BUILD_NARROW = 130, //! < buildings too close
- ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
- ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission
- ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object
- ERR_SEARCH_FLY = 140, //! < not possible in flight
- ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
- ERR_SEARCH_MOTOR = 142, //! < impossible in movement
- ERR_TERRA_VEH = 150, //! < inappropriate vehicle
- ERR_TERRA_ENERGY = 151, //! < not enough energy
- ERR_TERRA_FLOOR = 152, //! < inappropriate ground
- ERR_TERRA_BUILDING = 153, //! < building too close
- ERR_TERRA_OBJECT = 154, //! < object too close
- ERR_FIRE_VEH = 160, //! < inappropriate vehicle
- ERR_FIRE_ENERGY = 161, //! < not enough energy
- ERR_FIRE_FLY = 162, //! < not possible in flight
- ERR_RECOVER_VEH = 170, //! < inappropriate vehicle
- ERR_RECOVER_ENERGY = 171, //! < not enough energy
- ERR_RECOVER_NULL = 172, //! < lack of ruin
- ERR_CONVERT_EMPTY = 180, //! < no stone was transformed
- ERR_SHIELD_VEH = 190, //! < inappropriate vehicle
- ERR_SHIELD_ENERGY = 191, //! < not enough energy
- ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible
- ERR_FIND_IMPOSSIBLE = 201, //! < find impossible
- ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible
- ERR_GOTO_ITER = 211, //! < goto too complicated
- ERR_GOTO_BUSY = 212, //! < goto destination occupied
- ERR_DERRICK_NULL = 300, //! < no ore underground
- ERR_STATION_NULL = 301, //! < no energy underground
- ERR_TOWER_POWER = 310, //! < no battery
- ERR_TOWER_ENERGY = 311, //! < more energy
- ERR_RESEARCH_POWER = 320, //! < no battery
- ERR_RESEARCH_ENERGY = 321, //! < more energy
- ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery
- ERR_RESEARCH_ALREADY = 323, //! < research already done
- ERR_ENERGY_NULL = 330, //! < no energy underground
- ERR_ENERGY_LOW = 331, //! < not enough energy
- ERR_ENERGY_EMPTY = 332, //! < lack of metal
- ERR_ENERGY_BAD = 333, //! < transforms only the metal
- ERR_BASE_DLOCK = 340, //! < doors locked
- ERR_BASE_DHUMAN = 341, //! < you must be on spaceship
- ERR_LABO_NULL = 350, //! < nothing to analyze
- ERR_LABO_BAD = 351, //! < analyzes only organic ball
- ERR_LABO_ALREADY = 352, //! < analysis already made
- ERR_NUCLEAR_NULL = 360, //! < no energy underground
- ERR_NUCLEAR_LOW = 361, //! < not enough energy
- ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium
- ERR_NUCLEAR_BAD = 363, //! < transforms only uranium
- ERR_FACTORY_NULL = 370, //! < no metal
- ERR_FACTORY_NEAR = 371, //! < vehicle too close
- ERR_RESET_NEAR = 380, //! < vehicle too close
- ERR_INFO_NULL = 390, //! < no information terminal
- ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
- ERR_BAT_VIRUS = 401, //! < building infected by a virus
- ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy
- ERR_WRONG_OBJ = 420, //! < inappropriate vehicle
- ERR_VEH_POWER = 500, //! < no battery
- ERR_VEH_ENERGY = 501, //! < more energy
- ERR_FLAG_FLY = 510, //! < impossible in flight
- ERR_FLAG_WATER = 511, //! < impossible during swimming
- ERR_FLAG_MOTOR = 512, //! < impossible in movement
- ERR_FLAG_BUSY = 513, //! < taking: already creating flag
- ERR_FLAG_CREATE = 514, //! < too many flags
- ERR_FLAG_PROXY = 515, //! < too close
- ERR_FLAG_DELETE = 516, //! < nothing to remove
- ERR_MISSION_NOTERM = 600, //! < Mission not completed
- ERR_DELETEMOBILE = 700, //! < vehicle destroyed
- ERR_DELETEBUILDING = 701, //! < building destroyed
- ERR_TOOMANY = 702, //! < too many objects
- ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing
- ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited
+ ERR_OK = 0, //! < ok
+ ERR_GENERIC = 1, //! < any error
+ ERR_CONTINUE = 2, //! < continues
+ ERR_STOP = 3, //! < stops
+ ERR_CMD = 4, //! < unknown command
+ ERR_MANIP_VEH = 100, //! < inappropriate vehicle
+ ERR_MANIP_FLY = 101, //! < impossible in flight
+ ERR_MANIP_BUSY = 102, //! < taking: hands already occupied
+ ERR_MANIP_NIL = 103, //! < taking: nothing has to take
+ ERR_MANIP_MOTOR = 105, //! < busy: impossible to move
+ ERR_MANIP_OCC = 106, //! < busy: location already occupied
+ ERR_MANIP_FRIEND = 107, //! < no other vehicle
+ ERR_MANIP_RADIO = 108, //! < impossible because radioactive
+ ERR_MANIP_WATER = 109, //! < not possible under water
+ ERR_MANIP_EMPTY = 110, //! < nothing to deposit
+ ERR_BUILD_FLY = 120, //! < not possible in flight
+ ERR_BUILD_WATER = 121, //! < not possible under water
+ ERR_BUILD_ENERGY = 122, //! < not enough energy
+ ERR_BUILD_METALAWAY = 123, //! < lack of metal (too far)
+ ERR_BUILD_METALNEAR = 124, //! < lack of metal (too close)
+ ERR_BUILD_METALINEX = 125, //! < lack of metal
+ ERR_BUILD_FLAT = 126, //! < not enough flat ground
+ ERR_BUILD_FLATLIT = 127, //! < not enough flat ground space
+ ERR_BUILD_BUSY = 128, //! < location occupied
+ ERR_BUILD_BASE = 129, //! < too close to the rocket
+ ERR_BUILD_NARROW = 130, //! < buildings too close
+ ERR_BUILD_MOTOR = 131, //! < built: not possible in movement
+ ERR_BUILD_DISABLED = 132, //! < built: can not produce this object in this mission
+ ERR_BUILD_RESEARCH = 133, //! < built: can not produce not researched object
+ ERR_SEARCH_FLY = 140, //! < not possible in flight
+ ERR_SEARCH_VEH = 141, //! < inappropriate vehicle
+ ERR_SEARCH_MOTOR = 142, //! < impossible in movement
+ ERR_TERRA_VEH = 150, //! < inappropriate vehicle
+ ERR_TERRA_ENERGY = 151, //! < not enough energy
+ ERR_TERRA_FLOOR = 152, //! < inappropriate ground
+ ERR_TERRA_BUILDING = 153, //! < building too close
+ ERR_TERRA_OBJECT = 154, //! < object too close
+ ERR_FIRE_VEH = 160, //! < inappropriate vehicle
+ ERR_FIRE_ENERGY = 161, //! < not enough energy
+ ERR_FIRE_FLY = 162, //! < not possible in flight
+ ERR_RECOVER_VEH = 170, //! < inappropriate vehicle
+ ERR_RECOVER_ENERGY = 171, //! < not enough energy
+ ERR_RECOVER_NULL = 172, //! < lack of ruin
+ ERR_CONVERT_EMPTY = 180, //! < no stone was transformed
+ ERR_SHIELD_VEH = 190, //! < inappropriate vehicle
+ ERR_SHIELD_ENERGY = 191, //! < not enough energy
+ ERR_MOVE_IMPOSSIBLE = 200, //! < move impossible
+ ERR_FIND_IMPOSSIBLE = 201, //! < find impossible
+ ERR_GOTO_IMPOSSIBLE = 210, //! < goto impossible
+ ERR_GOTO_ITER = 211, //! < goto too complicated
+ ERR_GOTO_BUSY = 212, //! < goto destination occupied
+ ERR_DERRICK_NULL = 300, //! < no ore underground
+ ERR_STATION_NULL = 301, //! < no energy underground
+ ERR_TOWER_POWER = 310, //! < no battery
+ ERR_TOWER_ENERGY = 311, //! < more energy
+ ERR_RESEARCH_POWER = 320, //! < no battery
+ ERR_RESEARCH_ENERGY = 321, //! < more energy
+ ERR_RESEARCH_TYPE = 322, //! < the wrong type of battery
+ ERR_RESEARCH_ALREADY = 323, //! < research already done
+ ERR_ENERGY_NULL = 330, //! < no energy underground
+ ERR_ENERGY_LOW = 331, //! < not enough energy
+ ERR_ENERGY_EMPTY = 332, //! < lack of metal
+ ERR_ENERGY_BAD = 333, //! < transforms only the metal
+ ERR_BASE_DLOCK = 340, //! < doors locked
+ ERR_BASE_DHUMAN = 341, //! < you must be on spaceship
+ ERR_LABO_NULL = 350, //! < nothing to analyze
+ ERR_LABO_BAD = 351, //! < analyzes only organic ball
+ ERR_LABO_ALREADY = 352, //! < analysis already made
+ ERR_NUCLEAR_NULL = 360, //! < no energy underground
+ ERR_NUCLEAR_LOW = 361, //! < not enough energy
+ ERR_NUCLEAR_EMPTY = 362, //! < lack of uranium
+ ERR_NUCLEAR_BAD = 363, //! < transforms only uranium
+ ERR_FACTORY_NULL = 370, //! < no metal
+ ERR_FACTORY_NEAR = 371, //! < vehicle too close
+ ERR_RESET_NEAR = 380, //! < vehicle too close
+ ERR_INFO_NULL = 390, //! < no information terminal
+ ERR_VEH_VIRUS = 400, //! < vehicle infected by a virus
+ ERR_BAT_VIRUS = 401, //! < building infected by a virus
+ ERR_DESTROY_NOTFOUND = 410, //! < not found anything to destroy
+ ERR_WRONG_OBJ = 420, //! < inappropriate vehicle
+ ERR_VEH_POWER = 500, //! < no battery
+ ERR_VEH_ENERGY = 501, //! < more energy
+ ERR_FLAG_FLY = 510, //! < impossible in flight
+ ERR_FLAG_WATER = 511, //! < impossible during swimming
+ ERR_FLAG_MOTOR = 512, //! < impossible in movement
+ ERR_FLAG_BUSY = 513, //! < taking: already creating flag
+ ERR_FLAG_CREATE = 514, //! < too many flags
+ ERR_FLAG_PROXY = 515, //! < too close
+ ERR_FLAG_DELETE = 516, //! < nothing to remove
+ ERR_MISSION_NOTERM = 600, //! < Mission not completed
+ ERR_DELETEMOBILE = 700, //! < vehicle destroyed
+ ERR_DELETEBUILDING = 701, //! < building destroyed
+ ERR_TOOMANY = 702, //! < too many objects
+ ERR_OBLIGATORYTOKEN = 800, //! < compulsory instruction missing
+ ERR_PROHIBITEDTOKEN = 801, //! < instruction prohibited
+ ERR_AIM_IMPOSSIBLE = 900, //! < cannot aim at specified angle(s)
- INFO_FIRST = 10000, //! < first information
- INFO_BUILD = 10001, //! < construction builded
- INFO_CONVERT = 10002, //! < metal available
- INFO_RESEARCH = 10003, //! < search ended
- INFO_FACTORY = 10004, //! < vehicle manufactured
- INFO_LABO = 10005, //! < analysis ended
- INFO_ENERGY = 10006, //! < battery available
- INFO_NUCLEAR = 10007, //! < nuclear battery available
- INFO_FINDING = 10008, //! < nuclear battery available
- INFO_MARKPOWER = 10020, //! < location for station found
- INFO_MARKURANIUM = 10021, //! < location for derrick found
- INFO_MARKSTONE = 10022, //! < location for derrick found
- INFO_MARKKEYa = 10023, //! < location for derrick found
- INFO_MARKKEYb = 10024, //! < location for derrick found
- INFO_MARKKEYc = 10025, //! < location for derrick found
- INFO_MARKKEYd = 10026, //! < location for derrick found
- INFO_RESEARCHTANK = 10030, //! < research ended
- INFO_RESEARCHFLY = 10031, //! < research ended
- INFO_RESEARCHTHUMP = 10032, //! < research ended
- INFO_RESEARCHCANON = 10033, //! < research ended
- INFO_RESEARCHTOWER = 10034, //! < research ended
- INFO_RESEARCHPHAZER = 10035, //! < research ended
- INFO_RESEARCHSHIELD = 10036, //! < research ended
- INFO_RESEARCHATOMIC = 10037, //! < research ended
- INFO_WIN = 10040, //! < win
- INFO_LOST = 10041, //! < lost
- INFO_LOSTq = 10042, //! < lost immediately
- INFO_WRITEOK = 10043, //! < record done
- INFO_DELETEPATH = 10050, //! < way mark deleted
- INFO_DELETEMOTHER = 10100, //! < insect killed
- INFO_DELETEANT = 10101, //! < insect killed
- INFO_DELETEBEE = 10102, //! < insect killed
- INFO_DELETEWORM = 10103, //! < insect killed
- INFO_DELETESPIDER = 10104, //! < insect killed
- INFO_BEGINSATCOM = 10105, //! < use your SatCom
+ INFO_FIRST = 10000, //! < first information
+ INFO_BUILD = 10001, //! < construction builded
+ INFO_CONVERT = 10002, //! < metal available
+ INFO_RESEARCH = 10003, //! < search ended
+ INFO_FACTORY = 10004, //! < vehicle manufactured
+ INFO_LABO = 10005, //! < analysis ended
+ INFO_ENERGY = 10006, //! < battery available
+ INFO_NUCLEAR = 10007, //! < nuclear battery available
+ INFO_FINDING = 10008, //! < nuclear battery available
+ INFO_MARKPOWER = 10020, //! < location for station found
+ INFO_MARKURANIUM = 10021, //! < location for derrick found
+ INFO_MARKSTONE = 10022, //! < location for derrick found
+ INFO_MARKKEYa = 10023, //! < location for derrick found
+ INFO_MARKKEYb = 10024, //! < location for derrick found
+ INFO_MARKKEYc = 10025, //! < location for derrick found
+ INFO_MARKKEYd = 10026, //! < location for derrick found
+ INFO_RESEARCHTANK = 10030, //! < research ended
+ INFO_RESEARCHFLY = 10031, //! < research ended
+ INFO_RESEARCHTHUMP = 10032, //! < research ended
+ INFO_RESEARCHCANON = 10033, //! < research ended
+ INFO_RESEARCHTOWER = 10034, //! < research ended
+ INFO_RESEARCHPHAZER = 10035, //! < research ended
+ INFO_RESEARCHSHIELD = 10036, //! < research ended
+ INFO_RESEARCHATOMIC = 10037, //! < research ended
+ INFO_WIN = 10040, //! < win
+ INFO_LOST = 10041, //! < lost
+ INFO_LOSTq = 10042, //! < lost immediately
+ INFO_WRITEOK = 10043, //! < record done
+ INFO_DELETEPATH = 10050, //! < way mark deleted
+ INFO_DELETEMOTHER = 10100, //! < insect killed
+ INFO_DELETEANT = 10101, //! < insect killed
+ INFO_DELETEBEE = 10102, //! < insect killed
+ INFO_DELETEWORM = 10103, //! < insect killed
+ INFO_DELETESPIDER = 10104, //! < insect killed
+ INFO_BEGINSATCOM = 10105, //! < use your SatCom
ERR_MAX //! < number of values
};
@@ -177,25 +178,6 @@ enum Language
LANGUAGE_RUSSIAN = 4
};
-/**
- * \enum DataDir
- * \brief Directories in data directory
- */
-enum DataDir
-{
- DIR_AI, //! < ai scripts
- DIR_FONT, //! < fonts
- DIR_HELP, //! < help files
- DIR_ICON, //! < icons & images
- DIR_LEVEL, //! < levels
- DIR_MODEL, //! < models
- DIR_MUSIC, //! < music
- DIR_SOUND, //! < sounds
- DIR_TEXTURE, //! < textures
-
- DIR_MAX //! < number of dirs
-};
-
/**
* \enum BuildType
diff --git a/src/common/image.cpp b/src/common/image.cpp
index 8a876e3..e3d1ef7 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -418,3 +418,44 @@ bool CImage::SavePNG(const std::string& fileName)
return true;
}
+void CImage::SetDataPixels(void *pixels){
+
+ Uint8* srcPixels = static_cast<Uint8*> (pixels);
+ Uint8* resultPixels = static_cast<Uint8*> (m_data->surface->pixels);
+
+ Uint32 pitch = m_data->surface->pitch;
+
+ for(int line = 0; line < m_data->surface->h; ++line) {
+ Uint32 pos = line * pitch;
+ memcpy(&resultPixels[pos], &srcPixels[pos], pitch);
+ }
+}
+
+void CImage::flipVertically(){
+
+ SDL_Surface* result = SDL_CreateRGBSurface( m_data->surface->flags,
+ m_data->surface->w,
+ m_data->surface->h,
+ m_data->surface->format->BytesPerPixel * 8,
+ m_data->surface->format->Rmask,
+ m_data->surface->format->Gmask,
+ m_data->surface->format->Bmask,
+ m_data->surface->format->Amask);
+
+ assert(result != nullptr);
+
+ Uint8* srcPixels = static_cast<Uint8*> (m_data->surface->pixels);
+ Uint8* resultPixels = static_cast<Uint8*> (result->pixels);
+
+ Uint32 pitch = m_data->surface->pitch;
+ Uint32 pxLength = pitch*m_data->surface->h;
+
+ for(int line = 0; line < m_data->surface->h; ++line) {
+ Uint32 pos = line * pitch;
+ memcpy(&resultPixels[pos], &srcPixels[(pxLength-pos)-pitch], pitch);
+ }
+
+ SDL_FreeSurface(m_data->surface);
+
+ m_data->surface = result;
+} \ No newline at end of file
diff --git a/src/common/image.h b/src/common/image.h
index 31dab2d..b93f2f9 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -109,6 +109,12 @@ public:
//! Returns the last error
std::string GetError();
+ //! Flips the image vertically
+ void flipVertically();
+
+ //! sets/replaces the pixels from the surface
+ void SetDataPixels(void *pixels);
+
private:
//! Blit to new RGBA surface with given size
void BlitToNewRGBASurface(int width, int height);
diff --git a/src/common/logger.cpp b/src/common/logger.cpp
index a02854d..7fc8fb0 100644
--- a/src/common/logger.cpp
+++ b/src/common/logger.cpp
@@ -26,7 +26,11 @@ template<> CLogger* CSingleton<CLogger>::m_instance = nullptr;
CLogger::CLogger()
{
m_file = NULL;
+ #if DEV_BUILD
+ m_logLevel = LOG_DEBUG;
+ #else
m_logLevel = LOG_INFO;
+ #endif
}
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index b96abca..92c3e9a 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -192,18 +192,6 @@ void TimeToAscii(time_t time, char *buffer)
year = when.tm_year+1900;
if ( year < 2000 ) year -= 1900;
else year -= 2000;
-/* TODO
-#if _FRENCH
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
- when.tm_hour, when.tm_min);
-#endif
-#if _GERMAN | _WG
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
- when.tm_hour, when.tm_min);
-#endif
-#if _ENGLISH*/
char format[10];
int hour;
@@ -222,12 +210,23 @@ void TimeToAscii(time_t time, char *buffer)
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d %s",
when.tm_mon+1, when.tm_mday, year,
hour, when.tm_min, format);
-/*#endif
-#if _POLISH
- sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
- when.tm_mday, when.tm_mon+1, year,
+}
+
+// Converting time to string.
+
+void TimeToAsciiClean(time_t time, char *buffer)
+{
+ struct tm when;
+ int year;
+
+ when = *localtime(&time);
+ year = when.tm_year+1900;
+ if ( year < 2000 ) year -= 1900;
+ else year -= 2000;
+
+ sprintf(buffer, "%.2d%.2d%.2d%.2d%.2d",
+ year, when.tm_mon+1, when.tm_mday,
when.tm_hour, when.tm_min);
-#endif*/
}
// Copy a list of numbered files into the temporary folder.
diff --git a/src/common/misc.h b/src/common/misc.h
index bcebf76..3c147b1 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -28,6 +28,7 @@ extern char GetToUpper(char letter);
extern char GetToLower(char letter);
extern void TimeToAscii(time_t time, char *buffer);
+extern void TimeToAsciiClean(time_t time, char *buffer);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
extern void AddExt(char* filename, const char* ext);
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 77c70c3..ee3e873 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -91,7 +91,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std::
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -106,7 +106,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std::
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -122,7 +122,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -137,7 +137,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -153,7 +153,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -168,7 +168,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
return false;
}
return true;
@@ -178,7 +178,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, std::string key)
{
std::vector< std::string > ret_list;
- boost::regex re(key + "[0-9]*"); //we want to match all key followed my any number
+ boost::regex re(key + "[0-9]*"); //we want to match all key followed by any number
try
{
@@ -192,7 +192,7 @@ std::vector< std::string > CProfile::GetLocalProfileSection(std::string section,
}
catch (std::exception & e)
{
- GetLogger()->Error("Error on parsing profile: %s\n", e.what());
+ GetLogger()->Info("Error on parsing profile: %s\n", e.what());
}
return ret_list;
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index d61fa63..b63160d 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -56,14 +56,13 @@ void InitializeRestext()
stringsText[RT_KEY_OR] = " or ";
stringsText[RT_TITLE_BASE] = "COLOBOT";
- stringsText[RT_TITLE_INIT] = "COLOBOT";
+ stringsText[RT_TITLE_INIT] = "COLOBOT: Gold Edition";
stringsText[RT_TITLE_TRAINER] = "Programming exercises";
stringsText[RT_TITLE_DEFI] = "Challenges";
stringsText[RT_TITLE_MISSION] = "Missions";
stringsText[RT_TITLE_FREE] = "Free game";
stringsText[RT_TITLE_TEEN] = "Free game";
stringsText[RT_TITLE_USER] = "User levels";
- stringsText[RT_TITLE_PROTO] = "Prototypes";
stringsText[RT_TITLE_SETUP] = "Options";
stringsText[RT_TITLE_NAME] = "Player's name";
stringsText[RT_TITLE_PERSO] = "Customize your appearance";
@@ -75,14 +74,12 @@ void InitializeRestext()
stringsText[RT_PLAY_CHAPm] = " Planets:";
stringsText[RT_PLAY_CHAPf] = " Planets:";
stringsText[RT_PLAY_CHAPu] = " User levels:";
- stringsText[RT_PLAY_CHAPp] = " Planets:";
stringsText[RT_PLAY_CHAPte] = " Chapters:";
stringsText[RT_PLAY_LISTt] = " Exercises in the chapter:";
stringsText[RT_PLAY_LISTd] = " Challenges in the chapter:";
stringsText[RT_PLAY_LISTm] = " Missions on this planet:";
stringsText[RT_PLAY_LISTf] = " Free game on this planet:";
stringsText[RT_PLAY_LISTu] = " Missions on this level:";
- stringsText[RT_PLAY_LISTp] = " Prototypes on this planet:";
stringsText[RT_PLAY_LISTk] = " Free game on this chapter:";
stringsText[RT_PLAY_RESUME] = " Summary:";
@@ -155,8 +152,7 @@ void InitializeRestext()
stringsEvent[EVENT_INTERFACE_FREE] = "Free game\\Free game without a specific goal";
stringsEvent[EVENT_INTERFACE_TEEN] = "Free game\\Free game without a specific goal";
stringsEvent[EVENT_INTERFACE_USER] = "User\\User levels";
- stringsEvent[EVENT_INTERFACE_PROTO] = "Proto\\Prototypes under development";
- stringsEvent[EVENT_INTERFACE_NAME] = "New player\\Choose player's name";
+ stringsEvent[EVENT_INTERFACE_NAME] = "Change player\\Change player";
stringsEvent[EVENT_INTERFACE_SETUP] = "Options\\Preferences";
stringsEvent[EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning";
stringsEvent[EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ";
@@ -776,9 +772,7 @@ static KeyDesc keyTable[22] =
bool SearchKey(const char *cmd, InputSlot &key)
{
- int i;
-
- for ( i=0 ; i<22 ; i++ )
+ for (int i = 0; i < 22 ;i++)
{
if ( strstr(cmd, keyTable[i].name) == cmd )
{
@@ -791,14 +785,11 @@ bool SearchKey(const char *cmd, InputSlot &key)
// Replaces the commands "\key name;" in a text.
-static void PutKeyName(char* dst, const char* src)
+static void PutKeyName(std::string& dst, const char* src)
{
- InputSlot key;
- char name[50];
- int s, d, n;
- unsigned int res;
+ dst.clear();
- s = d = 0;
+ int s = 0;
while ( src[s] != 0 )
{
if ( src[s+0] == '\\' &&
@@ -807,18 +798,16 @@ static void PutKeyName(char* dst, const char* src)
src[s+3] == 'y' &&
src[s+4] == ' ' )
{
+ InputSlot key;
if ( SearchKey(src+s+5, key) )
{
- res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
+ unsigned int res = CRobotMain::GetInstancePointer()->GetInputBinding(key).primary;
if (res != KEY_INVALID)
{
- if ( GetResource(RES_KEY, res, name) )
+ std::string keyName;
+ if ( GetResource(RES_KEY, res, keyName) )
{
- n = 0;
- while ( name[n] != 0 )
- {
- dst[d++] = name[n++];
- }
+ dst.append(keyName);
while ( src[s++] != ';' );
continue;
}
@@ -826,9 +815,8 @@ static void PutKeyName(char* dst, const char* src)
}
}
- dst[d++] = src[s++];
+ dst.append(1, src[s++]);
}
- dst[d++] = 0;
}
// Returns the translated text of a resource that needs key substitution
@@ -905,13 +893,13 @@ static const char* GetResourceBase(ResType type, int num)
// Returns the text of a resource.
-bool GetResource(ResType type, int num, char* text)
+bool GetResource(ResType type, int num, std::string& text)
{
const char *tmpl = GetResourceBase(type, num);
if (!tmpl)
{
- text[0] = 0;
+ text.clear();
return false;
}
diff --git a/src/common/restext.h b/src/common/restext.h
index e4659e2..cde7203 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -66,7 +66,6 @@ enum ResTextType
RT_TITLE_DEFI = 43,
RT_TITLE_MISSION = 44,
RT_TITLE_FREE = 45,
- RT_TITLE_PROTO = 46,
RT_TITLE_SETUP = 47,
RT_TITLE_NAME = 48,
RT_TITLE_PERSO = 49,
@@ -79,12 +78,10 @@ enum ResTextType
RT_PLAY_CHAPd = 61,
RT_PLAY_CHAPm = 62,
RT_PLAY_CHAPf = 63,
- RT_PLAY_CHAPp = 64,
RT_PLAY_LISTt = 65,
RT_PLAY_LISTd = 66,
RT_PLAY_LISTm = 67,
RT_PLAY_LISTf = 68,
- RT_PLAY_LISTp = 69,
RT_PLAY_RESUME = 70,
RT_PLAY_CHAPu = 71,
RT_PLAY_LISTu = 72,
@@ -157,5 +154,5 @@ void InitializeRestext();
void SetGlobalGamerName(std::string name);
bool SearchKey(const char *cmd, InputSlot& slot);
-bool GetResource(ResType type, int num, char* text);
+bool GetResource(ResType type, int num, std::string& text);
diff --git a/src/common/stringutils.cpp b/src/common/stringutils.cpp
index 953abba..03a0f0b 100644
--- a/src/common/stringutils.cpp
+++ b/src/common/stringutils.cpp
@@ -17,6 +17,41 @@
#include "common/stringutils.h"
+#include <cstdarg>
+#include <cstdio>
+#include <vector>
+
+
+static std::string VFormat(const char *fmt, va_list ap)
+{
+ size_t size = 1024;
+ char stackbuf[1024];
+ std::vector<char> dynamicbuf;
+ char *buf = &stackbuf[0];
+
+ while (1)
+ {
+ int needed = vsnprintf (buf, size, fmt, ap);
+
+ if (needed <= static_cast<int>(size) && needed >= 0)
+ {
+ return std::string(buf, static_cast<size_t>(needed));
+ }
+
+ size = (needed > 0) ? (needed+1) : (size*2);
+ dynamicbuf.resize(size);
+ buf = &dynamicbuf[0];
+ }
+}
+
+std::string StrUtils::Format(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ std::string buf = VFormat(fmt, ap);
+ va_end(ap);
+ return buf;
+}
std::string StrUtils::Replace(const std::string &str, const std::string &oldStr, const std::string &newStr)
{
diff --git a/src/common/stringutils.h b/src/common/stringutils.h
index c60bfb0..e80163a 100644
--- a/src/common/stringutils.h
+++ b/src/common/stringutils.h
@@ -31,11 +31,11 @@ namespace StrUtils {
/** If given, \a ok is set to true/false on success/failure.
Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. ToString\<int\> */
template<class T>
-std::string ToString(T value, bool *ok = NULL)
+std::string ToString(T value, bool *ok = nullptr)
{
std::ostringstream s;
s << value;
- if (ok != NULL)
+ if (ok != nullptr)
*ok = !s.fail();
return s.str();
}
@@ -44,17 +44,20 @@ std::string ToString(T value, bool *ok = NULL)
/** If given, \a ok is set to true/false on success/failure.
Warning: To avoid unnecessary problems, *always* give full template qualifier e.g. FromString\<int\> */
template<class T>
-T FromString(const std::string &str, bool *ok = NULL)
+T FromString(const std::string &str, bool *ok = nullptr)
{
std::istringstream s;
s.str(str);
T value;
s >> value;
- if (ok != NULL)
+ if (ok != nullptr)
*ok = !s.fail();
return value;
}
+//! Replacement for sprintf()
+std::string Format(const char *fmt, ...);
+
//! Returns a string with every occurence of \a oldStr in \a str replaced to \a newStr
std::string Replace(const std::string &str, const std::string &oldStr, const std::string &newStr);
diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h
index 4c1189c..a896104 100644
--- a/src/graphics/core/device.h
+++ b/src/graphics/core/device.h
@@ -400,6 +400,9 @@ public:
virtual void SetFillMode(FillMode mode) = 0;
//! Returns the current fill mode
virtual FillMode GetFillMode() = 0;
+
+ //! Returns the pixels of the entire screen
+ virtual void* GetFrameBufferPixels()const = 0;
};
diff --git a/src/graphics/core/vertex.h b/src/graphics/core/vertex.h
index c3a657a..ca68352 100644
--- a/src/graphics/core/vertex.h
+++ b/src/graphics/core/vertex.h
@@ -82,7 +82,9 @@ struct VertexCol
Math::Vector coord;
Color color;
- explicit VertexCol(Math::Vector aCoord = Math::Vector(),
+ VertexCol() = default;
+
+ explicit VertexCol(Math::Vector aCoord,
Color aColor = Color())
: coord(aCoord), color(aColor) {}
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
index f0c379c..fedc70a 100644
--- a/src/graphics/engine/camera.cpp
+++ b/src/graphics/engine/camera.cpp
@@ -593,9 +593,6 @@ void CCamera::EffectFrame(const Event &event)
dist = Math::Norm((dist - 100.f) / 100.0f);
force *= 1.0f-dist;
-#if _TEEN
- force *= 2.0f;
-#endif
m_effectOffset *= force;
if (m_effectProgress >= 1.0f)
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 5cf7b23..e0861d2 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -19,6 +19,7 @@
#include "graphics/engine/engine.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/image.h"
#include "common/key.h"
@@ -63,6 +64,7 @@ CEngine::CEngine(CApplication *app)
m_planet = nullptr;
m_sound = nullptr;
m_terrain = nullptr;
+ m_pause = nullptr;
m_showStats = false;
@@ -80,7 +82,6 @@ CEngine::CEngine(CApplication *app)
m_fogStart[1] = 0.75f;
m_waterAddColor = Color(0.0f, 0.0f, 0.0f, 0.0f);
- m_pause = false;
m_render = true;
m_movieLock = false;
m_shadowVisible = true;
@@ -179,6 +180,7 @@ CEngine::~CEngine()
m_lightning = nullptr;
m_planet = nullptr;
m_terrain = nullptr;
+ m_pause = nullptr;
GetSystemUtils()->DestroyTimeStamp(m_lastFrameTime);
m_lastFrameTime = nullptr;
@@ -252,6 +254,7 @@ bool CEngine::Create()
m_cloud = new CCloud(this);
m_lightning = new CLightning(this);
m_planet = new CPlanet(this);
+ m_pause = new CPauseManager();
m_lightMan->SetDevice(m_device);
m_particle->SetDevice(m_device);
@@ -421,19 +424,25 @@ void CEngine::FrameUpdate()
bool CEngine::WriteScreenShot(const std::string& fileName, int width, int height)
{
- // TODO write screenshot: not very important for now
- GetLogger()->Trace("CEngine::WriteSceenShot(): stub!\n");
- return true;
-}
+ void *pixels = m_device->GetFrameBufferPixels();
+ CImage img({width,height});
-void CEngine::SetPause(bool pause)
-{
- m_pause = pause;
+ img.SetDataPixels(pixels);
+ img.flipVertically();
+
+ if ( img.SavePNG(fileName.c_str()) ){
+ GetLogger()->Info("Save SceenShot Saved Successfully!\n");
+ return true;
+ }
+ else{
+ GetLogger()->Error("%s!\n",img.GetError().c_str());
+ return false;
+ }
}
bool CEngine::GetPause()
{
- return m_pause;
+ return m_pause->GetPause();
}
void CEngine::SetMovieLock(bool lock)
@@ -2249,33 +2258,12 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
if (image == nullptr)
{
- bool loadedFromTexPack = false;
-
- std::string texPackName = m_app->GetTexPackFilePath(texName);
- if (! texPackName.empty())
- {
- if (img.Load(texPackName))
- {
- loadedFromTexPack = true;
- }
- else
- {
- std::string error = img.GetError();
- GetLogger()->Error("Couldn't load texture '%s' from texpack: %s, blacklisting the texpack path\n",
- texName.c_str(), error.c_str());
- m_texBlacklist.insert(texPackName);
- }
- }
-
- if (!loadedFromTexPack)
+ if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
{
- if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName)))
- {
- std::string error = img.GetError();
- GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
- m_texBlacklist.insert(texName);
- return Texture(); // invalid texture
- }
+ std::string error = img.GetError();
+ GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
+ m_texBlacklist.insert(texName);
+ return Texture(); // invalid texture
}
image = &img;
@@ -2438,7 +2426,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
CImage img;
- if (! img.Load(m_app->GetDataFilePath(DIR_TEXTURE, texName)))
+ if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
{
std::string error = img.GetError();
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 5ecde8f..d56bf38 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -24,6 +24,7 @@
#include "app/system.h"
+#include "app/pausemanager.h"
#include "common/event.h"
#include "common/singleton.h"
@@ -734,11 +735,8 @@ public:
bool WriteScreenShot(const std::string& fileName, int width, int height);
- //@{
- //! Management of game pause mode
- void SetPause(bool pause);
+ //! Get pause mode
TEST_VIRTUAL bool GetPause();
- //@}
//@{
//! Management of lock for the duration of movie sequence
@@ -1288,6 +1286,7 @@ protected:
CLightning* m_lightning;
CPlanet* m_planet;
CTerrain* m_terrain;
+ CPauseManager* m_pause;
//! Last encountered error
std::string m_error;
@@ -1300,9 +1299,6 @@ protected:
//! Whether to show stats (FPS, etc)
bool m_showStats;
std::string m_fpsText;
-
- //! Pause mode
- bool m_pause;
//! Rendering enabled?
bool m_render;
//! Lock for duration of movie?
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
index abc8c6c..0c0fb98 100644
--- a/src/graphics/engine/modelmanager.cpp
+++ b/src/graphics/engine/modelmanager.cpp
@@ -1,6 +1,24 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012-2014, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
#include "graphics/engine/modelmanager.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/logger.h"
@@ -30,7 +48,7 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
modelFile.SetPrintDebugInfo(true);
- std::string filePath = CApplication::GetInstance().GetDataFilePath(DIR_MODEL, fileName);
+ std::string filePath = CGameData::GetInstancePointer()->GetFilePath(DIR_MODEL, fileName);
if (!modelFile.ReadModel(filePath))
{
diff --git a/src/graphics/engine/modelmanager.h b/src/graphics/engine/modelmanager.h
index 9d50b97..ee5fc27 100644
--- a/src/graphics/engine/modelmanager.h
+++ b/src/graphics/engine/modelmanager.h
@@ -1,3 +1,20 @@
+// * This file is part of the COLOBOT source code
+// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012-2014, Polish Portal of Colobot (PPC)
+// *
+// * This program is free software: you can redistribute it and/or modify
+// * it under the terms of the GNU General Public License as published by
+// * the Free Software Foundation, either version 3 of the License, or
+// * (at your option) any later version.
+// *
+// * This program is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// * GNU General Public License for more details.
+// *
+// * You should have received a copy of the GNU General Public License
+// * along with this program. If not, see http://www.gnu.org/licenses/.
+
#pragma once
#include "common/singleton.h"
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 4b5384e..5f37cd8 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -19,6 +19,7 @@
#include "graphics/engine/terrain.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
@@ -189,7 +190,7 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point
bool CTerrain::LoadResources(const std::string& fileName)
{
CImage img;
- std::string path = CApplication::GetInstance().GetDataFilePath(DIR_TEXTURE, fileName);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
if (! img.Load(path))
{
GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str());
@@ -286,7 +287,7 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief,
m_scaleRelief = scaleRelief;
CImage img;
- std::string path = CApplication::GetInstance().GetDataFilePath(DIR_TEXTURE, fileName);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
if (! img.Load(path))
{
GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str());
@@ -331,6 +332,66 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief,
return true;
}
+bool CTerrain::RandomizeRelief()
+{
+ // Perlin noise
+ // Based on Python implementation by Marek Rogalski (mafik)
+ // http://amt2014.pl/archiwum/perlin.py
+
+ int size = (m_mosaicCount*m_brickCount)+1;
+ const int ilosc_oktaw = 6;
+
+ float* oktawy[ilosc_oktaw];
+ for(int i=0; i<ilosc_oktaw; i++)
+ {
+ int pxCount = static_cast<int>(pow(2, (i+1)*2));
+ oktawy[i] = new float[pxCount];
+ for(int j=0; j<pxCount; j++)
+ {
+ oktawy[i][j] = Math::Rand();
+ }
+ }
+
+ for(int y2=0; y2 < size; y2++)
+ {
+ float y = static_cast<float>(y2) / size;
+ for(int x2=0; x2 < size; x2++)
+ {
+ float x = static_cast<float>(x2) / size;
+
+ float wart = 0;
+ for(int i=0; i<ilosc_oktaw; i++)
+ {
+ int rozmiar_oktawy = sqrt(static_cast<int>(pow(2, (i+1)*2)));
+ double xi, yi, a, b;
+ a = modf(x * (rozmiar_oktawy-1), &xi);
+ b = modf(y * (rozmiar_oktawy-1), &yi);
+ /*int xi = floor(x * (rozmiar_oktawy-1));
+ int yi = floor(y * (rozmiar_oktawy-1));
+ float a = (x * (rozmiar_oktawy-1)) - xi;
+ float b = (y * (rozmiar_oktawy-1)) - yi;*/
+ //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", xi, yi, a, b);
+
+ float lg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi)];
+ float pg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi + 1)];
+ float ld = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi)];
+ float pd = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi + 1)];
+ //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", lg, pg, ld, pd);
+
+ float g = pg * a + lg * (1-a);
+ float d = pd * a + ld * (1-a);
+ float res = d * b + g * (1-b);
+ wart += res;
+ }
+
+ wart /= ilosc_oktaw;
+
+ m_relief[x2+y2*size] = wart * 255.0f;
+ }
+ }
+ return true;
+}
+
bool CTerrain::AddReliefPoint(Math::Vector pos, float scaleRelief)
{
float dim = (m_mosaicCount*m_brickCount*m_brickSize)/2.0f;
diff --git a/src/graphics/engine/terrain.h b/src/graphics/engine/terrain.h
index e618691..75a8975 100644
--- a/src/graphics/engine/terrain.h
+++ b/src/graphics/engine/terrain.h
@@ -212,7 +212,7 @@ struct FlyingLimit
* where relief data is specifically adjusted to level space to allow
* construction of buildings.
*
- * Undergound resources can be supplied by loading them from image like relief data.
+ * Underground resources can be supplied by loading them from image like relief data.
*
* Terrain also specifies flying limits for player: one global level and possible
* additional spherical restrictions.
@@ -243,6 +243,8 @@ public:
void FlushRelief();
//! Load relief from image
bool LoadRelief(const std::string& fileName, float scaleRelief, bool adjustBorder);
+ //! Load ramdomized relief
+ bool RandomizeRelief();
//! Load resources from image
bool LoadResources(const std::string& fileName);
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index ffd2eb2..8fd01b7 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -19,6 +19,7 @@
#include "graphics/engine/text.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
@@ -333,7 +334,7 @@ float CText::GetStringWidth(std::string text, FontType font, float size)
// Skip special chars
for (char& c : text)
{
- if (c < 32)
+ if (c < 32 && c >= 0)
c = ':';
}
@@ -351,7 +352,7 @@ float CText::GetCharWidth(UTF8Char ch, FontType font, float size, float offset)
if (font == FONT_BUTTON) return 0.0f;
int width = 1;
- if (ch.c1 < 32)
+ if (ch.c1 < 32 && ch.c1 >= 0)
{
if (ch.c1 == '\t')
width = m_tabSize;
@@ -646,7 +647,13 @@ void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::itera
DrawCharAndAdjustPos(ch, font, size, pos, color);
- fmtIndex++;
+ // increment fmtIndex for each byte in multibyte character
+ if ( ch.c1 != 0 )
+ fmtIndex++;
+ if ( ch.c2 != 0 )
+ fmtIndex++;
+ if ( ch.c3 != 0 )
+ fmtIndex++;
}
if (eol != 0)
@@ -859,7 +866,7 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size)
return m_lastCachedFont;
}
- std::string path = CApplication::GetInstance().GetDataFilePath(DIR_FONT, mf->fileName);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName);
m_lastCachedFont = new CachedFont();
m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize);
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index 9f64fab..b42f29d 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -1791,6 +1791,19 @@ FillMode CGLDevice::GetFillMode()
return FILL_POINT;
}
+void* CGLDevice::GetFrameBufferPixels()const{
+
+ GLubyte* pixels = new GLubyte [4 * m_config.size.x * m_config.size.y];
+
+ glReadPixels(0, 0, m_config.size.x, m_config.size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ unsigned int* p = static_cast<unsigned int*> ( static_cast<void*>(pixels) );
+
+ for (int i = 0; i < m_config.size.x * m_config.size.y; ++i)
+ p[i] |= 0xFF000000;
+
+ return static_cast<void*>(p);
+}
} // namespace Gfx
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index c648161..267ee73 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -188,6 +188,8 @@ public:
virtual void SetFillMode(FillMode mode) ;
virtual FillMode GetFillMode();
+ virtual void* GetFrameBufferPixels()const;
+
private:
//! Updates internal modelview matrix
void UpdateModelviewMatrix();
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 0aeaa0a..9e593a9 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -175,7 +175,6 @@ bool CAuto::CreateInterface(bool bSelect)
Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
- char name[100];
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != nullptr )
@@ -195,6 +194,7 @@ bool CAuto::CreateInterface(bool bSelect)
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
+ std::string name;
m_object->GetTooltipName(name);
pos.x = 0.0f;
pos.y = 64.0f/480.0f;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 6d61bc2..af6c6e0 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -121,7 +121,6 @@ bool CAutoBase::EventProcess(const Event &event)
CObject* pObj;
Math::Vector pos, speed, vibCir, iPos;
Math::Point dim, p;
- Error err;
float angle, dist, time, h, len, vSpeed;
int i, max;
@@ -313,50 +312,7 @@ begin:
if ( event.type == EVENT_OBJECT_BTAKEOFF )
{
- err = CheckCloseDoor();
- if ( err != ERR_OK )
- {
- m_main->DisplayError(err, m_object);
- return false;
- }
-
- err = m_main->CheckEndMission(false);
- if ( err != ERR_OK )
- {
- m_main->DisplayError(err, m_object);
- return false;
- }
-
- FreezeCargo(true); // freeze whole cargo
- m_main->SetMovieLock(true); // blocks everything until the end
- m_main->DeselectAll();
-
- newEvent.type = EVENT_UPDINTERFACE;
- m_eventQueue->AddEvent(newEvent);
-
- m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
-
- pos = m_pos;
- pos.x -= 110.0f;
- m_terrain->AdjustToFloor(pos);
- pos.y += 10.0f;
- m_camera->SetScriptEye(pos);
- m_posSound = pos;
-
- pos = m_object->GetPosition(0);
- pos.y += 50.0f;
- m_camera->SetScriptLookat(pos);
-
- m_engine->SetFocus(1.0f);
-
- m_soundChannel = m_sound->Play(SOUND_MANIP, m_posSound, 0.3f, 1.5f, true);
- m_sound->AddEnvelope(m_soundChannel, 0.3f, 1.5f, BASE_DOOR_TIME2, SOPER_CONTINUE);
- m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 0.5f, SOPER_STOP);
-
- m_phase = ABP_CLOSE2;
- m_progress = 0.0f;
- m_speed = 1.0f/BASE_DOOR_TIME2;
- return true;
+ return TakeOff(true);
}
if ( event.type != EVENT_FRAME ) return true;
@@ -1400,11 +1356,7 @@ void CAutoBase::BeginTransit()
}
else
{
-#if _DEMO
- m_bgBack = "back46b.png"; // paintings
-#else
m_bgBack = "back46.png"; // paintings
-#endif
}
m_engine->SetFogStart(0.9f); // hardly any fog
@@ -1444,3 +1396,56 @@ void CAutoBase::EndTransit()
m_main->StartMusic();
}
+Error CAutoBase::TakeOff(bool printMsg)
+{
+
+ Event newEvent;
+ Math::Vector pos;
+ Error err;
+
+ err = CheckCloseDoor();
+ if ( err != ERR_OK )
+ {
+ if(printMsg) m_main->DisplayError(err, m_object);
+ return err;
+ }
+
+ err = m_main->CheckEndMission(false);
+ if ( err != ERR_OK )
+ {
+ if(printMsg) m_main->DisplayError(err, m_object);
+ return err;
+ }
+
+ FreezeCargo(true); // freeze whole cargo
+ m_main->SetMovieLock(true); // blocks everything until the end
+ m_main->DeselectAll();
+
+ newEvent.type = EVENT_UPDINTERFACE;
+ m_eventQueue->AddEvent(newEvent);
+
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
+
+ pos = m_pos;
+ pos.x -= 110.0f;
+ m_terrain->AdjustToFloor(pos);
+ pos.y += 10.0f;
+ m_camera->SetScriptEye(pos);
+ m_posSound = pos;
+
+ pos = m_object->GetPosition(0);
+ pos.y += 50.0f;
+ m_camera->SetScriptLookat(pos);
+
+ m_engine->SetFocus(1.0f);
+
+ m_soundChannel = m_sound->Play(SOUND_MANIP, m_posSound, 0.3f, 1.5f, true);
+ m_sound->AddEnvelope(m_soundChannel, 0.3f, 1.5f, BASE_DOOR_TIME2, SOPER_CONTINUE);
+ m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 0.5f, SOPER_STOP);
+
+ m_phase = ABP_CLOSE2;
+ m_progress = 0.0f;
+ m_speed = 1.0f/BASE_DOOR_TIME2;
+ return ERR_OK;
+}
+
diff --git a/src/object/auto/autobase.h b/src/object/auto/autobase.h
index 422f340..967e43d 100644
--- a/src/object/auto/autobase.h
+++ b/src/object/auto/autobase.h
@@ -77,6 +77,8 @@ public:
Error GetError();
bool CreateInterface(bool bSelect);
+
+ Error TakeOff(bool printMsg);
protected:
void UpdateInterface();
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 1b1565a..4bd8742 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -1238,7 +1238,6 @@ bool CBrain::CreateInterface(bool bSelect)
Ui::CLabel* pl;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
- char name[100];
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
@@ -1259,13 +1258,14 @@ bool CBrain::CreateInterface(bool bSelect)
pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
- m_object->GetTooltipName(name);
+ std::string tooltipLabel;
+ m_object->GetTooltipName(tooltipLabel);
pos.x = 0.0f;
pos.y = 64.0f/480.0f;
ddim.x = 540.0f/640.0f;
if ( !m_main->GetShowMap() ) ddim.x = 640.0f/640.0f;
ddim.y = 16.0f/480.0f;
- pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, name);
+ pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, tooltipLabel);
dim.x = 33.0f/640.0f;
dim.y = 33.0f/480.0f;
@@ -1674,8 +1674,10 @@ bool CBrain::CreateInterface(bool bSelect)
pos.y = oy+sy*1.2f;
ddim.x = dim.x*2.2f;
ddim.y = dim.y*0.4f;
- GetResource(RES_TEXT, RT_INTERFACE_REC, name);
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
+
+ std::string recordLabel;
+ GetResource(RES_TEXT, RT_INTERFACE_REC, recordLabel);
+ pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, recordLabel);
pl->SetFontSize(9.0f);
pos.x = ox+sx*7.0f;
@@ -1787,9 +1789,6 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = ox+sx*13.4f;
pos.y = oy+sy*0;
-#if _TEEN
- pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
-#else
if ( m_object->GetTrainer() ) // Training?
{
pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
@@ -1798,7 +1797,6 @@ bool CBrain::CreateInterface(bool bSelect)
{
pw->CreateButton(pos, dim, 10, EVENT_OBJECT_DESELECT);
}
-#endif
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
@@ -2457,17 +2455,10 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
char name[100];
char title[100];
int i;
- bool bSoluce;
pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
if ( pl == 0 ) return;
-#if _SCHOOL
- bSoluce = m_main->GetSoluce4();
-#else
- bSoluce = true;
-#endif
-
for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
{
sprintf(name, "%d", i+1);
@@ -2475,10 +2466,6 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
if ( m_script[i] != 0 )
{
m_script[i]->GetTitle(title);
- if ( !bSoluce && i == 3 )
- {
- title[0] = 0;
- }
if ( title[0] != 0 )
{
sprintf(name, "%d: %s", i+1, title);
@@ -2488,11 +2475,6 @@ void CBrain::UpdateScript(Ui::CWindow *pw)
pl->SetItemName(i, name);
}
- if ( !bSoluce )
- {
- pl->SetEnable(3, false);
- }
-
pl->SetSelect(m_selScript);
pl->ShowSelect(true);
}
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 5a709e6..3c225d0 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -276,6 +276,7 @@ CObject::CObject()
m_lastVirusParticle = 0.0f;
m_totalDesectList = 0;
m_bLock = false;
+ m_bIgnoreBuildCheck = false;
m_bExplo = false;
m_bCargo = false;
m_bBurn = false;
@@ -6781,7 +6782,7 @@ float CObject::GetParam()
// Management of the mode "blocked" of an object.
// For example, a cube of titanium is blocked while it is used to make something,
-//or a vehicle is blocked as its construction is not finished.
+// or a vehicle is blocked as its construction is not finished.
void CObject::SetLock(bool bLock)
{
@@ -6793,6 +6794,18 @@ bool CObject::GetLock()
return m_bLock;
}
+// Ignore checks in build() function
+
+void CObject::SetIgnoreBuildCheck(bool bIgnoreBuildCheck)
+{
+ m_bIgnoreBuildCheck = bIgnoreBuildCheck;
+}
+
+bool CObject::GetIgnoreBuildCheck()
+{
+ return m_bIgnoreBuildCheck;
+}
+
// Management of the mode "current explosion" of an object.
// An object in this mode is not saving.
@@ -7263,10 +7276,10 @@ int CObject::GetDefRank()
// Getes the object name for the tooltip.
-bool CObject::GetTooltipName(char* name)
+bool CObject::GetTooltipName(std::string& name)
{
GetResource(RES_OBJECT, m_type, name);
- return ( name[0] != 0 );
+ return !name.empty();
}
@@ -7390,3 +7403,70 @@ void CObject::SetTraceWidth(float width)
mv->SetTraceWidth(width);
}
+DriveType CObject::GetDriveFromObject(ObjectType type)
+{
+ switch(type) {
+ case OBJECT_MOBILEwt:
+ case OBJECT_MOBILEwa:
+ case OBJECT_MOBILEwc:
+ case OBJECT_MOBILEwi:
+ case OBJECT_MOBILEws:
+ return DRIVE_WHEELED;
+
+ case OBJECT_MOBILEtt:
+ case OBJECT_MOBILEta:
+ case OBJECT_MOBILEtc:
+ case OBJECT_MOBILEti:
+ case OBJECT_MOBILEts:
+ return DRIVE_TRACKED;
+
+ case OBJECT_MOBILEft:
+ case OBJECT_MOBILEfa:
+ case OBJECT_MOBILEfc:
+ case OBJECT_MOBILEfi:
+ case OBJECT_MOBILEfs:
+ return DRIVE_WINGED;
+
+ case OBJECT_MOBILEit:
+ case OBJECT_MOBILEia:
+ case OBJECT_MOBILEic:
+ case OBJECT_MOBILEii:
+ case OBJECT_MOBILEis:
+ return DRIVE_LEGGED;
+
+ default:
+ return DRIVE_OTHER;
+ }
+}
+
+ToolType CObject::GetToolFromObject(ObjectType type)
+{
+ switch(type) {
+ case OBJECT_MOBILEwa:
+ case OBJECT_MOBILEta:
+ case OBJECT_MOBILEfa:
+ case OBJECT_MOBILEia:
+ return TOOL_GRABBER;
+
+ case OBJECT_MOBILEws:
+ case OBJECT_MOBILEts:
+ case OBJECT_MOBILEfs:
+ case OBJECT_MOBILEis:
+ return TOOL_SNIFFER;
+
+ case OBJECT_MOBILEwc:
+ case OBJECT_MOBILEtc:
+ case OBJECT_MOBILEfc:
+ case OBJECT_MOBILEic:
+ return TOOL_SHOOTER;
+
+ case OBJECT_MOBILEwi:
+ case OBJECT_MOBILEti:
+ case OBJECT_MOBILEfi:
+ case OBJECT_MOBILEii:
+ return TOOL_ORGASHOOTER;
+
+ default:
+ return TOOL_OTHER;
+ }
+}
diff --git a/src/object/object.h b/src/object/object.h
index e8b83d9..0e469f2 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -47,245 +47,207 @@ enum ObjectType
{
OBJECT_NULL = 0, //! < object destroyed
OBJECT_FIX = 1, //! < stationary scenery
- OBJECT_PORTICO = 2, //! < gantry
- OBJECT_BASE = 3, //! < great main base
- OBJECT_DERRICK = 4, //! < derrick set
- OBJECT_FACTORY = 5, //! < factory set
- OBJECT_STATION = 6, //! < recharging station
- OBJECT_CONVERT = 7, //! < converter station
- OBJECT_REPAIR = 8, //! < reparation
- OBJECT_TOWER = 9, //! < defense tower
- OBJECT_NEST = 10, //! < nest
- OBJECT_RESEARCH = 11, //! < research center
- OBJECT_RADAR = 12, //! < radar
- OBJECT_ENERGY = 13, //! < energy factory
- OBJECT_LABO = 14, //! < analytical laboratory for insect
- OBJECT_NUCLEAR = 15, //! < nuclear power plant
- OBJECT_START = 16, //! < starting
- OBJECT_END = 17, //! < finish
- OBJECT_INFO = 18, //! < information terminal
- OBJECT_PARA = 19, //! < lightning conductor
- OBJECT_TARGET1 = 20, //! < gate target
- OBJECT_TARGET2 = 21, //! < center target
- OBJECT_SAFE = 22, //! < safe
- OBJECT_HUSTON = 23, //! < control centre
- OBJECT_DESTROYER = 24, //! < destroyer
- OBJECT_FRET = 30, //! < transportable
- OBJECT_STONE = 31, //! < stone
- OBJECT_URANIUM = 32, //! < uranium
- OBJECT_METAL = 33, //! < metal
- OBJECT_POWER = 34, //! < normal battery
- OBJECT_ATOMIC = 35, //! < atomic battery
- OBJECT_BULLET = 36, //! < bullet
- OBJECT_BBOX = 37, //! < black-box
- OBJECT_TNT = 38, //! < box of TNT
- OBJECT_SCRAP1 = 40, //! < metal waste
- OBJECT_SCRAP2 = 41, //! < metal waste
- OBJECT_SCRAP3 = 42, //! < metal waste
- OBJECT_SCRAP4 = 43, //! < plastic waste
- OBJECT_SCRAP5 = 44, //! < plastic waste
- OBJECT_MARKPOWER = 50, //! < mark underground energy source
- OBJECT_MARKSTONE = 51, //! < mark underground ore
- OBJECT_MARKURANIUM = 52, //! < mark underground uranium
- OBJECT_MARKKEYa = 53, //! < mark underground key
- OBJECT_MARKKEYb = 54, //! < mark underground key
- OBJECT_MARKKEYc = 55, //! < mark underground key
- OBJECT_MARKKEYd = 56, //! < mark underground key
- OBJECT_BOMB = 60, //! < bomb
- OBJECT_WINFIRE = 61, //! < fireworks
- OBJECT_SHOW = 62, //! < shows a place
- OBJECT_BAG = 63, //! < survival bag
- OBJECT_PLANT0 = 70, //! < plant 0
- OBJECT_PLANT1 = 71, //! < plant 1
- OBJECT_PLANT2 = 72, //! < plant 2
- OBJECT_PLANT3 = 73, //! < plant 3
- OBJECT_PLANT4 = 74, //! < plant 4
- OBJECT_PLANT5 = 75, //! < plant 5
- OBJECT_PLANT6 = 76, //! < plant 6
- OBJECT_PLANT7 = 77, //! < plant 7
- OBJECT_PLANT8 = 78, //! < plant 8
- OBJECT_PLANT9 = 79, //! < plant 9
- OBJECT_PLANT10 = 80, //! < plant 10
- OBJECT_PLANT11 = 81, //! < plant 11
- OBJECT_PLANT12 = 82, //! < plant 12
- OBJECT_PLANT13 = 83, //! < plant 13
- OBJECT_PLANT14 = 84, //! < plant 14
- OBJECT_PLANT15 = 85, //! < plant 15
- OBJECT_PLANT16 = 86, //! < plant 16
- OBJECT_PLANT17 = 87, //! < plant 17
- OBJECT_PLANT18 = 88, //! < plant 18
- OBJECT_PLANT19 = 89, //! < plant 19
- OBJECT_TREE0 = 90, //! < tree 0
- OBJECT_TREE1 = 91, //! < tree 1
- OBJECT_TREE2 = 92, //! < tree 2
- OBJECT_TREE3 = 93, //! < tree 3
- OBJECT_TREE4 = 94, //! < tree 4
- OBJECT_TREE5 = 95, //! < tree 5
- OBJECT_TREE6 = 96, //! < tree 6
- OBJECT_TREE7 = 97, //! < tree 7
- OBJECT_TREE8 = 98, //! < tree 8
- OBJECT_TREE9 = 99, //! < tree 9
- OBJECT_MOBILEwt = 100, //! < wheel-trainer
- OBJECT_MOBILEtt = 101, //! < track-trainer
- OBJECT_MOBILEft = 102, //! < fly-trainer
- OBJECT_MOBILEit = 103, //! < insect-trainer
- OBJECT_MOBILEwa = 110, //! < wheel-arm
- OBJECT_MOBILEta = 111, //! < track-arm
- OBJECT_MOBILEfa = 112, //! < fly-arm
- OBJECT_MOBILEia = 113, //! < insect-arm
- OBJECT_MOBILEwc = 120, //! < wheel-cannon
- OBJECT_MOBILEtc = 121, //! < track-cannon
- OBJECT_MOBILEfc = 122, //! < fly-cannon
- OBJECT_MOBILEic = 123, //! < insect-cannon
- OBJECT_MOBILEwi = 130, //! < wheel-insect-cannon
- OBJECT_MOBILEti = 131, //! < track-insect-cannon
- OBJECT_MOBILEfi = 132, //! < fly-insect-cannon
- OBJECT_MOBILEii = 133, //! < insect-insect-cannon
- OBJECT_MOBILEws = 140, //! < wheel-search
- OBJECT_MOBILEts = 141, //! < track-search
- OBJECT_MOBILEfs = 142, //! < fly-search
- OBJECT_MOBILEis = 143, //! < insect-search
- OBJECT_MOBILErt = 200, //! < roller-terraform
- OBJECT_MOBILErc = 201, //! < roller-canon
- OBJECT_MOBILErr = 202, //! < roller-recover
- OBJECT_MOBILErs = 203, //! < roller-shield
- OBJECT_MOBILEsa = 210, //! < submarine
- OBJECT_MOBILEtg = 211, //! < training target
- OBJECT_MOBILEdr = 212, //! < robot drawing
- OBJECT_CONTROLLER = 213, //! < mission controller
- OBJECT_WAYPOINT = 250, //! < waypoint
- OBJECT_FLAGb = 260, //! < blue flag
- OBJECT_FLAGr = 261, //! < red flag
- OBJECT_FLAGg = 262, //! < green flag
- OBJECT_FLAGy = 263, //! < yellow flag
- OBJECT_FLAGv = 264, //! < violet flag
- OBJECT_KEYa = 270, //! < key a
- OBJECT_KEYb = 271, //! < key b
- OBJECT_KEYc = 272, //! < key c
- OBJECT_KEYd = 273, //! < key d
- OBJECT_HUMAN = 300, //! < human
- OBJECT_TOTO = 301, //! < toto
- OBJECT_TECH = 302, //! < technician
- OBJECT_BARRIER0 = 400, //! < barrier
- OBJECT_BARRIER1 = 401, //! < barrier
- OBJECT_BARRIER2 = 402, //! < barrier
- OBJECT_BARRIER3 = 403, //! < barrier
- OBJECT_BARRIER4 = 404, //! < barrier
- OBJECT_MOTHER = 500, //! < insect queen
- OBJECT_EGG = 501, //! < egg
- OBJECT_ANT = 502, //! < ant
- OBJECT_SPIDER = 503, //! < spider
- OBJECT_BEE = 504, //! < bee
- OBJECT_WORM = 505, //! < worm
- OBJECT_RUINmobilew1 = 600, //! < ruin 1
- OBJECT_RUINmobilew2 = 601, //! < ruin 1
- OBJECT_RUINmobilet1 = 602, //! < ruin 2
- OBJECT_RUINmobilet2 = 603, //! < ruin 2
- OBJECT_RUINmobiler1 = 604, //! < ruin 3
- OBJECT_RUINmobiler2 = 605, //! < ruin 3
- OBJECT_RUINfactory = 606, //! < ruin 4
- OBJECT_RUINdoor = 607, //! < ruin 5
- OBJECT_RUINsupport = 608, //! < ruin 6
- OBJECT_RUINradar = 609, //! < ruin 7
- OBJECT_RUINconvert = 610, //! < ruin 8
- OBJECT_RUINbase = 611, //! < ruin 9
- OBJECT_RUINhead = 612, //! < ruin 10
- OBJECT_TEEN0 = 620, //! < toy
- OBJECT_TEEN1 = 621, //! < toy
- OBJECT_TEEN2 = 622, //! < toy
- OBJECT_TEEN3 = 623, //! < toy
- OBJECT_TEEN4 = 624, //! < toy
- OBJECT_TEEN5 = 625, //! < toy
- OBJECT_TEEN6 = 626, //! < toy
- OBJECT_TEEN7 = 627, //! < toy
- OBJECT_TEEN8 = 628, //! < toy
- OBJECT_TEEN9 = 629, //! < toy
- OBJECT_TEEN10 = 630, //! < toy
- OBJECT_TEEN11 = 631, //! < toy
- OBJECT_TEEN12 = 632, //! < toy
- OBJECT_TEEN13 = 633, //! < toy
- OBJECT_TEEN14 = 634, //! < toy
- OBJECT_TEEN15 = 635, //! < toy
- OBJECT_TEEN16 = 636, //! < toy
- OBJECT_TEEN17 = 637, //! < toy
- OBJECT_TEEN18 = 638, //! < toy
- OBJECT_TEEN19 = 639, //! < toy
- OBJECT_TEEN20 = 640, //! < toy
- OBJECT_TEEN21 = 641, //! < toy
- OBJECT_TEEN22 = 642, //! < toy
- OBJECT_TEEN23 = 643, //! < toy
- OBJECT_TEEN24 = 644, //! < toy
- OBJECT_TEEN25 = 645, //! < toy
- OBJECT_TEEN26 = 646, //! < toy
- OBJECT_TEEN27 = 647, //! < toy
- OBJECT_TEEN28 = 648, //! < toy
- OBJECT_TEEN29 = 649, //! < toy
- OBJECT_TEEN30 = 650, //! < toy
- OBJECT_TEEN31 = 651, //! < toy
- OBJECT_TEEN32 = 652, //! < toy
- OBJECT_TEEN33 = 653, //! < toy
- OBJECT_TEEN34 = 654, //! < toy
- OBJECT_TEEN35 = 655, //! < toy
- OBJECT_TEEN36 = 656, //! < toy
- OBJECT_TEEN37 = 657, //! < toy
- OBJECT_TEEN38 = 658, //! < toy
- OBJECT_TEEN39 = 659, //! < toy
- OBJECT_TEEN40 = 660, //! < toy
- OBJECT_TEEN41 = 661, //! < toy
- OBJECT_TEEN42 = 662, //! < toy
- OBJECT_TEEN43 = 663, //! < toy
- OBJECT_TEEN44 = 664, //! < toy
- OBJECT_TEEN45 = 665, //! < toy
- OBJECT_TEEN46 = 666, //! < toy
- OBJECT_TEEN47 = 667, //! < toy
- OBJECT_TEEN48 = 668, //! < toy
- OBJECT_TEEN49 = 669, //! < toy
- OBJECT_QUARTZ0 = 700, //! < crystal 0
- OBJECT_QUARTZ1 = 701, //! < crystal 1
- OBJECT_QUARTZ2 = 702, //! < crystal 2
- OBJECT_QUARTZ3 = 703, //! < crystal 3
- OBJECT_QUARTZ4 = 704, //! < crystal 4
- OBJECT_QUARTZ5 = 705, //! < crystal 5
- OBJECT_QUARTZ6 = 706, //! < crystal 6
- OBJECT_QUARTZ7 = 707, //! < crystal 7
- OBJECT_QUARTZ8 = 708, //! < crystal 8
- OBJECT_QUARTZ9 = 709, //! < crystal 9
- OBJECT_ROOT0 = 710, //! < root 0
- OBJECT_ROOT1 = 711, //! < root 1
- OBJECT_ROOT2 = 712, //! < root 2
- OBJECT_ROOT3 = 713, //! < root 3
- OBJECT_ROOT4 = 714, //! < root 4
- OBJECT_ROOT5 = 715, //! < root 5
- OBJECT_ROOT6 = 716, //! < root 6
- OBJECT_ROOT7 = 717, //! < root 7
- OBJECT_ROOT8 = 718, //! < root 8
- OBJECT_ROOT9 = 719, //! < root 9
- OBJECT_SEAWEED0 = 720, //! < seaweed 0
- OBJECT_SEAWEED1 = 721, //! < seaweed 1
- OBJECT_SEAWEED2 = 722, //! < seaweed 2
- OBJECT_SEAWEED3 = 723, //! < seaweed 3
- OBJECT_SEAWEED4 = 724, //! < seaweed 4
- OBJECT_SEAWEED5 = 725, //! < seaweed 5
- OBJECT_SEAWEED6 = 726, //! < seaweed 6
- OBJECT_SEAWEED7 = 727, //! < seaweed 7
- OBJECT_SEAWEED8 = 728, //! < seaweed 8
- OBJECT_SEAWEED9 = 729, //! < seaweed 9
- OBJECT_MUSHROOM0 = 730, //! < mushroom 0
- OBJECT_MUSHROOM1 = 731, //! < mushroom 1
- OBJECT_MUSHROOM2 = 732, //! < mushroom 2
- OBJECT_MUSHROOM3 = 733, //! < mushroom 3
- OBJECT_MUSHROOM4 = 734, //! < mushroom 4
- OBJECT_MUSHROOM5 = 735, //! < mushroom 5
- OBJECT_MUSHROOM6 = 736, //! < mushroom 6
- OBJECT_MUSHROOM7 = 737, //! < mushroom 7
- OBJECT_MUSHROOM8 = 738, //! < mushroom 8
- OBJECT_MUSHROOM9 = 739, //! < mushroom 9
- OBJECT_APOLLO1 = 900, //! < apollo lem
- OBJECT_APOLLO2 = 901, //! < apollo jeep
- OBJECT_APOLLO3 = 902, //! < apollo flag
- OBJECT_APOLLO4 = 903, //! < apollo module
- OBJECT_APOLLO5 = 904, //! < apollo antenna
- OBJECT_HOME1 = 910, //! < home 1
+ OBJECT_PORTICO = 2, //! < Portico
+ OBJECT_BASE = 3, //! < SpaceShip
+ OBJECT_DERRICK = 4, //! < Derrick
+ OBJECT_FACTORY = 5, //! < BotFactory
+ OBJECT_STATION = 6, //! < PowerStation
+ OBJECT_CONVERT = 7, //! < Converter
+ OBJECT_REPAIR = 8, //! < RepairStation
+ OBJECT_TOWER = 9, //! < DefenseTower
+ OBJECT_NEST = 10, //! < AlienNest
+ OBJECT_RESEARCH = 11, //! < ResearchCenter
+ OBJECT_RADAR = 12, //! < RadarStation
+ OBJECT_ENERGY = 13, //! < PowerPlant
+ OBJECT_LABO = 14, //! < AutoLab
+ OBJECT_NUCLEAR = 15, //! < NuclearPlant
+ OBJECT_START = 16, //! < StartArea
+ OBJECT_END = 17, //! < EndArea
+ OBJECT_INFO = 18, //! < ExchangePost
+ OBJECT_PARA = 19, //! < PowerCaptor
+ OBJECT_TARGET1 = 20, //! < Target1 (gate)
+ OBJECT_TARGET2 = 21, //! < Target2 (center)
+ OBJECT_SAFE = 22, //! < Vault
+ OBJECT_HUSTON = 23, //! < Houston
+ OBJECT_DESTROYER = 24, //! < Destroyer
+ OBJECT_FRET = 30, //! < transportable (unused)
+ OBJECT_STONE = 31, //! < TitaniumOre
+ OBJECT_URANIUM = 32, //! < UraniumOre
+ OBJECT_METAL = 33, //! < Titanium
+ OBJECT_POWER = 34, //! < PowerCell
+ OBJECT_ATOMIC = 35, //! < NuclearCell
+ OBJECT_BULLET = 36, //! < OrgaMatter
+ OBJECT_BBOX = 37, //! < BlackBox
+ OBJECT_TNT = 38, //! < TNT
+ OBJECT_SCRAP1 = 40, //! < Scrap1 (metal)
+ OBJECT_SCRAP2 = 41, //! < Scrap2 (metal)
+ OBJECT_SCRAP3 = 42, //! < Scrap3 (metal)
+ OBJECT_SCRAP4 = 43, //! < Scrap4 (plastic)
+ OBJECT_SCRAP5 = 44, //! < Scrap5 (plastic)
+ OBJECT_MARKPOWER = 50, //! < PowerSpot
+ OBJECT_MARKSTONE = 51, //! < TitaniumSpot
+ OBJECT_MARKURANIUM = 52, //! < UraniumSpot
+ OBJECT_MARKKEYa = 53, //! < KeyASpot
+ OBJECT_MARKKEYb = 54, //! < KeyBSpot
+ OBJECT_MARKKEYc = 55, //! < KeyCSpot
+ OBJECT_MARKKEYd = 56, //! < KeyDSpot
+ OBJECT_BOMB = 60, //! < Mine
+ OBJECT_WINFIRE = 61, //! < Firework
+ OBJECT_SHOW = 62, //! < arrow above object (Visit)
+ OBJECT_BAG = 63, //! < Bag
+ OBJECT_PLANT0 = 70, //! < Greenery0
+ OBJECT_PLANT1 = 71, //! < Greenery1
+ OBJECT_PLANT2 = 72, //! < Greenery2
+ OBJECT_PLANT3 = 73, //! < Greenery3
+ OBJECT_PLANT4 = 74, //! < Greenery4
+ OBJECT_PLANT5 = 75, //! < Greenery5
+ OBJECT_PLANT6 = 76, //! < Greenery6
+ OBJECT_PLANT7 = 77, //! < Greenery7
+ OBJECT_PLANT8 = 78, //! < Greenery8
+ OBJECT_PLANT9 = 79, //! < Greenery9
+ OBJECT_PLANT10 = 80, //! < Greenery10
+ OBJECT_PLANT11 = 81, //! < Greenery11
+ OBJECT_PLANT12 = 82, //! < Greenery12
+ OBJECT_PLANT13 = 83, //! < Greenery13
+ OBJECT_PLANT14 = 84, //! < Greenery14
+ OBJECT_PLANT15 = 85, //! < Greenery15
+ OBJECT_PLANT16 = 86, //! < Greenery16
+ OBJECT_PLANT17 = 87, //! < Greenery17
+ OBJECT_PLANT18 = 88, //! < Greenery18
+ OBJECT_PLANT19 = 89, //! < Greenery19
+ OBJECT_TREE0 = 90, //! < Tree0
+ OBJECT_TREE1 = 91, //! < Tree1
+ OBJECT_TREE2 = 92, //! < Tree2
+ OBJECT_TREE3 = 93, //! < Tree3
+ OBJECT_TREE4 = 94, //! < Tree4
+ OBJECT_TREE5 = 95, //! < Tree5
+ OBJECT_MOBILEwt = 100, //! < PracticeBot
+ OBJECT_MOBILEtt = 101, //! < track-trainer (unused)
+ OBJECT_MOBILEft = 102, //! < fly-trainer (unused)
+ OBJECT_MOBILEit = 103, //! < insect-trainer (unused)
+ OBJECT_MOBILEwa = 110, //! < WheeledGrabber
+ OBJECT_MOBILEta = 111, //! < TrackedGrabber
+ OBJECT_MOBILEfa = 112, //! < WingedGrabber
+ OBJECT_MOBILEia = 113, //! < LeggedGrabber
+ OBJECT_MOBILEwc = 120, //! < WheeledShooter
+ OBJECT_MOBILEtc = 121, //! < TrackedShooter
+ OBJECT_MOBILEfc = 122, //! < WingedShooter
+ OBJECT_MOBILEic = 123, //! < LeggedShooter
+ OBJECT_MOBILEwi = 130, //! < WheeledOrgaShooter
+ OBJECT_MOBILEti = 131, //! < TrackedOrgaShooter
+ OBJECT_MOBILEfi = 132, //! < WingedOrgaShooter
+ OBJECT_MOBILEii = 133, //! < LeggedOrgaShooter
+ OBJECT_MOBILEws = 140, //! < WheeledSniffer
+ OBJECT_MOBILEts = 141, //! < TrackedSniffer
+ OBJECT_MOBILEfs = 142, //! < WingedSniffer
+ OBJECT_MOBILEis = 143, //! < LeggedSniffer
+ OBJECT_MOBILErt = 200, //! < Thumper
+ OBJECT_MOBILErc = 201, //! < PhazerShooter
+ OBJECT_MOBILErr = 202, //! < Recycler
+ OBJECT_MOBILErs = 203, //! < Shielder
+ OBJECT_MOBILEsa = 210, //! < Subber
+ OBJECT_MOBILEtg = 211, //! < TargetBot
+ OBJECT_MOBILEdr = 212, //! < Scribbler
+ OBJECT_CONTROLLER = 213, //! < MissionController
+ OBJECT_WAYPOINT = 250, //! < WayPoint
+ OBJECT_FLAGb = 260, //! < BlueFlag
+ OBJECT_FLAGr = 261, //! < RedFlag
+ OBJECT_FLAGg = 262, //! < GreenFlag
+ OBJECT_FLAGy = 263, //! < YellowFlag
+ OBJECT_FLAGv = 264, //! < VioletFlag
+ OBJECT_KEYa = 270, //! < KeyA
+ OBJECT_KEYb = 271, //! < KeyB
+ OBJECT_KEYc = 272, //! < KeyC
+ OBJECT_KEYd = 273, //! < KeyD
+ OBJECT_HUMAN = 300, //! < Me
+ OBJECT_TOTO = 301, //! < Robby (toto)
+ OBJECT_TECH = 302, //! < Tech
+ OBJECT_BARRIER0 = 400, //! < Barrier0
+ OBJECT_BARRIER1 = 401, //! < Barrier1
+ OBJECT_BARRIER2 = 402, //! < Barrier2
+ OBJECT_BARRIER3 = 403, //! < Barrier3
+ OBJECT_MOTHER = 500, //! < AlienQueen
+ OBJECT_EGG = 501, //! < AlienEgg
+ OBJECT_ANT = 502, //! < AlienAnt
+ OBJECT_SPIDER = 503, //! < AlienSpider
+ OBJECT_BEE = 504, //! < AlienWasp
+ OBJECT_WORM = 505, //! < AlienWorm
+ OBJECT_RUINmobilew1 = 600, //! < WreckBotw1
+ OBJECT_RUINmobilew2 = 601, //! < WreckBotw2
+ OBJECT_RUINmobilet1 = 602, //! < WreckBott1
+ OBJECT_RUINmobilet2 = 603, //! < WreckBott2
+ OBJECT_RUINmobiler1 = 604, //! < WreckBotr1
+ OBJECT_RUINmobiler2 = 605, //! < WreckBotr2
+ OBJECT_RUINfactory = 606, //! < RuinBotFactory
+ OBJECT_RUINdoor = 607, //! < RuinDoor
+ OBJECT_RUINsupport = 608, //! < RuinSupport
+ OBJECT_RUINradar = 609, //! < RuinRadar
+ OBJECT_RUINconvert = 610, //! < RuinConvert
+ OBJECT_RUINbase = 611, //! < RuinBaseCamp
+ OBJECT_RUINhead = 612, //! < RuinHeadCamp
+ OBJECT_TEEN0 = 620, //! < Teen0
+ OBJECT_TEEN1 = 621, //! < Teen1
+ OBJECT_TEEN2 = 622, //! < Teen2
+ OBJECT_TEEN3 = 623, //! < Teen3
+ OBJECT_TEEN4 = 624, //! < Teen4
+ OBJECT_TEEN5 = 625, //! < Teen5
+ OBJECT_TEEN6 = 626, //! < Teen6
+ OBJECT_TEEN7 = 627, //! < Teen7
+ OBJECT_TEEN8 = 628, //! < Teen8
+ OBJECT_TEEN9 = 629, //! < Teen9
+ OBJECT_TEEN10 = 630, //! < Teen10
+ OBJECT_TEEN11 = 631, //! < Teen11
+ OBJECT_TEEN12 = 632, //! < Teen12
+ OBJECT_TEEN13 = 633, //! < Teen13
+ OBJECT_TEEN14 = 634, //! < Teen14
+ OBJECT_TEEN15 = 635, //! < Teen15
+ OBJECT_TEEN16 = 636, //! < Teen16
+ OBJECT_TEEN17 = 637, //! < Teen17
+ OBJECT_TEEN18 = 638, //! < Teen18
+ OBJECT_TEEN19 = 639, //! < Teen19
+ OBJECT_TEEN20 = 640, //! < Teen20
+ OBJECT_TEEN21 = 641, //! < Teen21
+ OBJECT_TEEN22 = 642, //! < Teen22
+ OBJECT_TEEN23 = 643, //! < Teen23
+ OBJECT_TEEN24 = 644, //! < Teen24
+ OBJECT_TEEN25 = 645, //! < Teen25
+ OBJECT_TEEN26 = 646, //! < Teen26
+ OBJECT_TEEN27 = 647, //! < Teen27
+ OBJECT_TEEN28 = 648, //! < Teen28
+ OBJECT_TEEN29 = 649, //! < Teen29
+ OBJECT_TEEN30 = 650, //! < Teen30
+ OBJECT_TEEN31 = 651, //! < Teen31
+ OBJECT_TEEN32 = 652, //! < Teen32
+ OBJECT_TEEN33 = 653, //! < Teen33
+ OBJECT_TEEN34 = 654, //! < Stone (Teen34)
+ OBJECT_TEEN35 = 655, //! < Teen35
+ OBJECT_TEEN36 = 656, //! < Teen36
+ OBJECT_TEEN37 = 657, //! < Teen37
+ OBJECT_TEEN38 = 658, //! < Teen38
+ OBJECT_TEEN39 = 659, //! < Teen39
+ OBJECT_TEEN40 = 660, //! < Teen40
+ OBJECT_TEEN41 = 661, //! < Teen41
+ OBJECT_TEEN42 = 662, //! < Teen42
+ OBJECT_TEEN43 = 663, //! < Teen43
+ OBJECT_TEEN44 = 664, //! < Teen44
+ OBJECT_QUARTZ0 = 700, //! < Quartz0
+ OBJECT_QUARTZ1 = 701, //! < Quartz1
+ OBJECT_QUARTZ2 = 702, //! < Quartz2
+ OBJECT_QUARTZ3 = 703, //! < Quartz3
+ OBJECT_ROOT0 = 710, //! < MegaStalk0
+ OBJECT_ROOT1 = 711, //! < MegaStalk1
+ OBJECT_ROOT2 = 712, //! < MegaStalk2
+ OBJECT_ROOT3 = 713, //! < MegaStalk3
+ OBJECT_ROOT4 = 714, //! < MegaStalk4
+ OBJECT_ROOT5 = 715, //! < MegaStalk5
+ OBJECT_MUSHROOM1 = 731, //! < Mushroom1
+ OBJECT_MUSHROOM2 = 732, //! < Mushroom2
+ OBJECT_APOLLO1 = 900, //! < ApolloLEM
+ OBJECT_APOLLO2 = 901, //! < ApolloJeep
+ OBJECT_APOLLO3 = 902, //! < ApolloFlag
+ OBJECT_APOLLO4 = 903, //! < ApolloModule
+ OBJECT_APOLLO5 = 904, //! < ApolloAntenna
+ OBJECT_HOME1 = 910, //! < Home
OBJECT_MAX = 1000 //! < number of values
};
@@ -311,6 +273,24 @@ enum ObjectMaterial
OM_MINERAL = 5, // stone
};
+enum DriveType
+{
+ DRIVE_OTHER = 0,
+ DRIVE_WHEELED,
+ DRIVE_TRACKED,
+ DRIVE_WINGED,
+ DRIVE_LEGGED,
+};
+
+enum ToolType
+{
+ TOOL_OTHER = 0,
+ TOOL_GRABBER,
+ TOOL_SNIFFER,
+ TOOL_SHOOTER,
+ TOOL_ORGASHOOTER,
+};
+
struct ObjectPart
{
char bUsed;
@@ -602,6 +582,9 @@ public:
void SetParam(float value);
float GetParam();
+
+ void SetIgnoreBuildCheck(bool bIgnoreBuildCheck);
+ bool GetIgnoreBuildCheck();
void SetExplo(bool bExplo);
bool GetExplo();
@@ -639,7 +622,7 @@ public:
void SetDefRank(int rank);
int GetDefRank();
- bool GetTooltipName(char* name);
+ bool GetTooltipName(std::string& name);
void AddDeselList(CObject* pObj);
CObject* SubDeselList();
@@ -659,6 +642,9 @@ public:
void SetTraceWidth(float width);
std::string GetModelDirName();
+
+ static DriveType GetDriveFromObject(ObjectType type);
+ static ToolType GetToolFromObject(ObjectType type);
protected:
bool EventFrame(const Event &event);
@@ -737,6 +723,7 @@ protected:
bool m_bTrainer; // drive vehicle (without remote)
bool m_bToy; // toy key
bool m_bManual; // manual control (Scribbler)
+ bool m_bIgnoreBuildCheck;
bool m_bFixed;
bool m_bClip;
bool m_bShowLimit;
diff --git a/src/object/objman.cpp b/src/object/objman.cpp
index e4102b8..b0bac1a 100644
--- a/src/object/objman.cpp
+++ b/src/object/objman.cpp
@@ -30,7 +30,7 @@ CObjectManager::CObjectManager()
{
m_table[i] = nullptr;
}
- usedCount = 0;
+ m_usedCount = 0;
}
CObjectManager::~CObjectManager()
@@ -39,16 +39,16 @@ CObjectManager::~CObjectManager()
bool CObjectManager::AddInstance(CObject* instance)
{
- if (usedCount >= MAX_OBJECTS) return false;
+ if (m_usedCount >= MAX_OBJECTS) return false;
m_table[instance->GetID()] = instance;
- usedCount++;
+ m_usedCount++;
return true;
}
bool CObjectManager::DeleteInstance(CObject* instance)
{
- for (int i = 0; i < usedCount; i++)
+ for (int i = 0; i < m_usedCount; i++)
{
if (m_table[i] == instance)
m_table[i] = nullptr;
@@ -63,10 +63,9 @@ CObject* CObjectManager::SearchInstance(int id)
return m_table[id];
}
-CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom, float height,
- ObjectType type, float power,
- bool trainer, bool toy,
- int option)
+CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType type,
+ float power, float zoom, float height,
+ bool trainer, bool toy, int option)
{
CObject* object = nullptr;
@@ -161,8 +160,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
if ( type == OBJECT_BARRIER0 ||
type == OBJECT_BARRIER1 ||
type == OBJECT_BARRIER2 ||
- type == OBJECT_BARRIER3 ||
- type == OBJECT_BARRIER4 )
+ type == OBJECT_BARRIER3 )
{
object = new CObject();
object->CreateBarrier(pos, angle, height, type);
@@ -193,26 +191,14 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
type == OBJECT_TREE2 ||
type == OBJECT_TREE3 ||
type == OBJECT_TREE4 ||
- type == OBJECT_TREE5 ||
- type == OBJECT_TREE6 ||
- type == OBJECT_TREE7 ||
- type == OBJECT_TREE8 ||
- type == OBJECT_TREE9 )
+ type == OBJECT_TREE5 )
{
object = new CObject();
object->CreatePlant(pos, angle, height, type);
}
else
- if ( type == OBJECT_MUSHROOM0 ||
- type == OBJECT_MUSHROOM1 ||
- type == OBJECT_MUSHROOM2 ||
- type == OBJECT_MUSHROOM3 ||
- type == OBJECT_MUSHROOM4 ||
- type == OBJECT_MUSHROOM5 ||
- type == OBJECT_MUSHROOM6 ||
- type == OBJECT_MUSHROOM7 ||
- type == OBJECT_MUSHROOM8 ||
- type == OBJECT_MUSHROOM9 )
+ if ( type == OBJECT_MUSHROOM1 ||
+ type == OBJECT_MUSHROOM2 )
{
object = new CObject();
object->CreateMushroom(pos, angle, height, type);
@@ -262,12 +248,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
type == OBJECT_TEEN41 ||
type == OBJECT_TEEN42 ||
type == OBJECT_TEEN43 ||
- type == OBJECT_TEEN44 ||
- type == OBJECT_TEEN45 ||
- type == OBJECT_TEEN46 ||
- type == OBJECT_TEEN47 ||
- type == OBJECT_TEEN48 ||
- type == OBJECT_TEEN49 )
+ type == OBJECT_TEEN44 )
{
object = new CObject();
object->SetOption(option);
@@ -277,13 +258,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
if ( type == OBJECT_QUARTZ0 ||
type == OBJECT_QUARTZ1 ||
type == OBJECT_QUARTZ2 ||
- type == OBJECT_QUARTZ3 ||
- type == OBJECT_QUARTZ4 ||
- type == OBJECT_QUARTZ5 ||
- type == OBJECT_QUARTZ6 ||
- type == OBJECT_QUARTZ7 ||
- type == OBJECT_QUARTZ8 ||
- type == OBJECT_QUARTZ9 )
+ type == OBJECT_QUARTZ3 )
{
object = new CObject();
object->CreateQuartz(pos, angle, height, type);
@@ -294,11 +269,7 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
type == OBJECT_ROOT2 ||
type == OBJECT_ROOT3 ||
type == OBJECT_ROOT4 ||
- type == OBJECT_ROOT5 ||
- type == OBJECT_ROOT6 ||
- type == OBJECT_ROOT7 ||
- type == OBJECT_ROOT8 ||
- type == OBJECT_ROOT9 )
+ type == OBJECT_ROOT5 )
{
object = new CObject();
object->CreateRoot(pos, angle, height, type);
@@ -387,3 +358,11 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, float zoom,
return object;
}
+void CObjectManager::Flush()
+{
+ for (int i = 0; i < MAX_OBJECTS; i++)
+ {
+ m_table[i] = nullptr;
+ }
+ m_usedCount = 0;
+}
diff --git a/src/object/objman.h b/src/object/objman.h
index 3087383..390587b 100644
--- a/src/object/objman.h
+++ b/src/object/objman.h
@@ -44,10 +44,12 @@ public:
//! Seeks for an object
CObject* SearchInstance(int id);
//! Creates an object
- CObject* CreateObject(Math::Vector pos, float angle, float zoom, float height, ObjectType type, float power, bool trainer, bool toy, int option);
+ CObject* CreateObject(Math::Vector pos, float angle, ObjectType type, float power = -1.f, float zoom = 1.f, float height = 0.f, bool trainer = false, bool toy = false, int option = 0);
+ //! Removes all objects
+ void Flush();
protected:
CObject* m_table[MAX_OBJECTS];
- int usedCount;
+ int m_usedCount;
};
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 26fa827..76c234d 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -20,6 +20,7 @@
#include "CBot/CBotDll.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/event.h"
#include "common/global.h"
@@ -81,6 +82,9 @@
#include <iomanip>
+#include <boost/regex.hpp>
+
+
template<> CRobotMain* CSingleton<CRobotMain>::m_instance = nullptr;
@@ -618,6 +622,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_cloud = m_engine->GetCloud();
m_lightning = m_engine->GetLightning();
m_planet = m_engine->GetPlanet();
+ m_pause = CPauseManager::GetInstancePointer();
m_interface = new Ui::CInterface();
m_terrain = new Gfx::CTerrain();
@@ -643,6 +648,10 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_visitArrow = 0;
m_audioTrack = "";
m_audioRepeat = true;
+ m_satcomTrack = "";
+ m_satcomRepeat = true;
+ m_editorTrack = "";
+ m_editorRepeat = true;
m_delayWriteMessage = 0;
m_selectObject = 0;
m_infoUsed = 0;
@@ -663,7 +672,6 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_satComLock = false;
m_editLock = false;
m_editFull = false;
- m_pause = false;
m_hilite = false;
m_freePhoto = false;
m_showPos = false;
@@ -690,12 +698,14 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
m_movieInfoIndex = -1;
m_tooltipPos = Math::Point(0.0f, 0.0f);
- m_tooltipName[0] = 0;
+ m_tooltipName.clear();
m_tooltipTime = 0.0f;
m_endingWinRank = 0;
m_endingLostRank = 0;
m_winTerminate = false;
+
+ m_exitAfterMission = false;
m_joystickDeadzone = 0.2f;
SetDefaultInputBindings();
@@ -881,6 +891,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
bc->AddFunction("busy", CScript::rBusy, CScript::cBusy);
bc->AddFunction("factory", CScript::rFactory, CScript::cFactory);
bc->AddFunction("research", CScript::rResearch, CScript::cClassOneFloat);
+ bc->AddFunction("takeoff", CScript::rTakeOff, CScript::cClassNull);
bc->AddFunction("destroy", CScript::rDestroy, CScript::cClassNull);
// Initializes the class FILE.
@@ -944,6 +955,7 @@ Ui::CDisplayText* CRobotMain::GetDisplayText()
void CRobotMain::LoadSceneOnStart(const std::string& name, int rank)
{
+ m_exitAfterMission = true;
// TODO: fix this ugly dependency :(
m_dialog->SetSceneName(name.c_str());
m_dialog->SetSceneRank(rank);
@@ -987,22 +999,27 @@ void CRobotMain::SetDefaultInputBindings()
m_inputBindings[INPUT_SLOT_RIGHT ].primary = KEY(RIGHT);
m_inputBindings[INPUT_SLOT_UP ].primary = KEY(UP);
m_inputBindings[INPUT_SLOT_DOWN ].primary = KEY(DOWN);
+ m_inputBindings[INPUT_SLOT_LEFT ].secondary = KEY(a);
+ m_inputBindings[INPUT_SLOT_RIGHT ].secondary = KEY(d);
+ m_inputBindings[INPUT_SLOT_UP ].secondary = KEY(w);
+ m_inputBindings[INPUT_SLOT_DOWN ].secondary = KEY(s);
m_inputBindings[INPUT_SLOT_GUP ].primary = VIRTUAL_KMOD(SHIFT);
m_inputBindings[INPUT_SLOT_GDOWN ].primary = VIRTUAL_KMOD(CTRL);
m_inputBindings[INPUT_SLOT_CAMERA ].primary = KEY(SPACE);
- m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
+// m_inputBindings[INPUT_SLOT_CAMERA ].secondary = VIRTUAL_JOY(2);
m_inputBindings[INPUT_SLOT_DESEL ].primary = KEY(KP0);
- m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
+// m_inputBindings[INPUT_SLOT_DESEL ].secondary = VIRTUAL_JOY(6);
m_inputBindings[INPUT_SLOT_ACTION ].primary = KEY(RETURN);
- m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
+// m_inputBindings[INPUT_SLOT_ACTION ].secondary = VIRTUAL_JOY(1);
+ m_inputBindings[INPUT_SLOT_ACTION ].secondary = KEY(e);
m_inputBindings[INPUT_SLOT_NEAR ].primary = KEY(KP_PLUS);
- m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
+// m_inputBindings[INPUT_SLOT_NEAR ].secondary = VIRTUAL_JOY(5);
m_inputBindings[INPUT_SLOT_AWAY ].primary = KEY(KP_MINUS);
- m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
+// m_inputBindings[INPUT_SLOT_AWAY ].secondary = VIRTUAL_JOY(4);
m_inputBindings[INPUT_SLOT_NEXT ].primary = KEY(TAB);
- m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
+// m_inputBindings[INPUT_SLOT_NEXT ].secondary = VIRTUAL_JOY(3);
m_inputBindings[INPUT_SLOT_HUMAN ].primary = KEY(HOME);
- m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
+// m_inputBindings[INPUT_SLOT_HUMAN ].secondary = VIRTUAL_JOY(7);
m_inputBindings[INPUT_SLOT_QUIT ].primary = KEY(ESCAPE);
m_inputBindings[INPUT_SLOT_HELP ].primary = KEY(F1);
m_inputBindings[INPUT_SLOT_PROG ].primary = KEY(F2);
@@ -1063,12 +1080,9 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_phase == PHASE_SIMUL) // ends a simulation?
{
SaveAllScript();
- m_sound->StopMusic();
+ m_sound->StopMusic(0.0f);
m_camera->SetControllingObject(0);
-/* TODO: #if _SCHOOL
- if ( true )
-#else*/
if (m_gameTime > 10.0f) // did you play at least 10 seconds?
{
int rank = m_dialog->GetSceneRank();
@@ -1101,7 +1115,7 @@ void CRobotMain::ChangePhase(Phase phase)
m_resetCreate = false;
m_engine->SetMovieLock(m_movieLock);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
FlushDisplayInfo();
m_engine->SetRankView(0);
m_terrain->FlushRelief();
@@ -1139,6 +1153,8 @@ void CRobotMain::ChangePhase(Phase phase)
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
Math::Point dim, pos;
@@ -1153,12 +1169,6 @@ void CRobotMain::ChangePhase(Phase phase)
m_cmdEdit = false; // hidden for now
// Creates the speedometer.
-/* TODO: #if _TEEN
- dim.x = 30.0f/640.0f;
- dim.y = 20.0f/480.0f;
- pos.x = 4.0f/640.0f;
- pos.y = 454.0f/480.0f;
-#else*/
dim.x = 30.0f/640.0f;
dim.y = 20.0f/480.0f;
pos.x = 4.0f/640.0f;
@@ -1217,7 +1227,7 @@ void CRobotMain::ChangePhase(Phase phase)
m_infoFilename[SATCOM_HUSTON][0] != 0)
StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions
- m_sound->StopMusic();
+ m_sound->StopMusic(0.0f);
if (!m_base || loading) StartMusic();
}
@@ -1230,10 +1240,6 @@ void CRobotMain::ChangePhase(Phase phase)
}
else
{
-/* TODO: #if _TEEN
- m_winTerminate = (m_endingWinRank == 900);
- m_dialog->SetSceneName("teenw");
-#else*/
m_winTerminate = (m_endingWinRank == 904);
m_dialog->SetSceneName("win");
@@ -1247,16 +1253,6 @@ void CRobotMain::ChangePhase(Phase phase)
if (m_winTerminate)
{
-/* TODO: #if _TEEN
- pos.x = ox+sx*3; pos.y = oy+sy*1;
- ddim.x = dim.x*15; ddim.y = dim.y*2;
- pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
- pe->SetFontType(FONT_COLOBOT);
- pe->SetEditCap(false);
- pe->SetHiliteCap(false);
- pe->ReadText("help/teenw.txt");
-#else*/
-
pos.x = ox+sx*3; pos.y = oy+sy*0.2f;
ddim.x = dim.x*15; ddim.y = dim.y*3.0f;
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
@@ -1376,7 +1372,7 @@ bool CRobotMain::ProcessEvent(Event &event)
MainMovieType type = m_movie->GetStopType();
if (type == MM_SATCOMopen)
{
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
SelectObject(m_infoObject, false); // hands over the command buttons
m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
@@ -1408,7 +1404,7 @@ bool CRobotMain::ProcessEvent(Event &event)
if (pe == nullptr) return false;
pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true);
- if (m_phase == PHASE_SIMUL) ChangePause(true);
+ if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_CHEAT);
m_cmdEdit = true;
return false;
}
@@ -1421,7 +1417,7 @@ bool CRobotMain::ProcessEvent(Event &event)
pe->GetText(cmd, 50);
pe->SetText("");
pe->ClearState(Ui::STATE_VISIBLE);
- if (m_phase == PHASE_SIMUL) ChangePause(false);
+ if (m_phase == PHASE_SIMUL) ChangePause(PAUSE_NONE);
ExecuteCmd(cmd);
m_cmdEdit = false;
return false;
@@ -1551,7 +1547,7 @@ bool CRobotMain::ProcessEvent(Event &event)
m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
!m_movie->IsExist())
{
- ChangePause(!m_engine->GetPause());
+ ChangePause(m_pause->GetPause(PAUSE_USER) ? PAUSE_NONE : PAUSE_USER);
}
}
if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).primary ||
@@ -1741,10 +1737,14 @@ bool CRobotMain::ProcessEvent(Event &event)
case EVENT_WIN:
ChangePhase(PHASE_WIN);
+ if(m_exitAfterMission)
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
break;
case EVENT_LOST:
ChangePhase(PHASE_LOST);
+ if(m_exitAfterMission)
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
break;
default:
@@ -1781,6 +1781,7 @@ bool CRobotMain::ProcessEvent(Event &event)
ChangePhase(PHASE_INIT);
else
ChangePhase(PHASE_TERM);
+
break;
default:
@@ -1875,12 +1876,12 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (m_freePhoto)
{
m_camera->SetType(Gfx::CAM_TYPE_FREE);
- ChangePause(true);
+ ChangePause(PAUSE_PHOTO);
}
else
{
m_camera->SetType(Gfx::CAM_TYPE_BACK);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
}
return;
}
@@ -1891,7 +1892,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
if (m_freePhoto)
{
m_camera->SetType(Gfx::CAM_TYPE_FREE);
- ChangePause(true);
+ ChangePause(PAUSE_PHOTO);
DeselectAll(); // removes the control buttons
m_map->ShowMap(false);
m_displayText->HideText(true);
@@ -1899,7 +1900,7 @@ void CRobotMain::ExecuteCmd(char *cmd)
else
{
m_camera->SetType(Gfx::CAM_TYPE_BACK);
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
}
@@ -2082,9 +2083,6 @@ void CRobotMain::ExecuteCmd(char *cmd)
return;
}
-/* TODO: #if _TEEN
- if (strcmp(cmd, "allteens") == 0)
-#else*/
if (strcmp(cmd, "allmission") == 0)
{
m_showAll = !m_showAll;
@@ -2158,7 +2156,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
{
m_movieInfoIndex = index;
m_movie->Start(MM_SATCOMopen, 2.5f);
- ChangePause(true);
+ ChangePause(PAUSE_SATCOMMOVIE);
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
return;
@@ -2168,7 +2166,7 @@ void CRobotMain::StartDisplayInfo(int index, bool movie)
if (m_movie->IsExist())
{
m_movie->Stop();
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
SelectObject(m_infoObject, false); // hands over the command buttons
m_displayText->HideText(false);
}
@@ -2445,7 +2443,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
}
Math::Vector goal = m_displayText->GetVisitGoal(event);
- m_visitArrow = CreateObject(goal, 0.0f, 1.0f, 10.0f, OBJECT_SHOW, false, false, 0);
+ m_visitArrow = CObjectManager::GetInstancePointer()->CreateObject(goal, 0.0f, OBJECT_SHOW, -1.0f, 1.0f, 10.0f);
m_visitPos = m_visitArrow->GetPosition(0);
m_visitPosArrow = m_visitPos;
@@ -2460,7 +2458,7 @@ void CRobotMain::StartDisplayVisit(EventType event)
m_camera->StartVisit(m_displayText->GetVisitGoal(event),
m_displayText->GetVisitDist(event));
m_displayText->SetVisit(event);
- ChangePause(true);
+ ChangePause(PAUSE_VISIT);
}
//! Move the arrow to visit
@@ -2514,7 +2512,7 @@ void CRobotMain::StopDisplayVisit()
m_camera->StopVisit();
m_displayText->ClearVisit();
- ChangePause(false);
+ ChangePause(PAUSE_NONE);
if (m_visitObject != 0)
{
SelectObject(m_visitObject, false); // gives the command buttons
@@ -2612,7 +2610,7 @@ bool CRobotMain::SelectObject(CObject* obj, bool displayError)
if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
StopDisplayVisit();
- if (m_movieLock || m_editLock || m_pause) return false;
+ if (m_movieLock || m_editLock || m_pause->GetPause()) return false;
if (m_movie->IsExist()) return false;
if (obj == nullptr || !IsSelectable(obj)) return false;
@@ -3025,7 +3023,7 @@ bool CRobotMain::DeleteObject()
void CRobotMain::HiliteClear()
{
ClearTooltip();
- m_tooltipName[0] = 0; // really removes the tooltip
+ m_tooltipName.clear(); // really removes the tooltip
if (!m_hilite) return;
@@ -3059,11 +3057,11 @@ void CRobotMain::HiliteObject(Math::Point pos)
CObject* obj = m_short->DetectShort(pos);
- std::string nameStr;
- if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, nameStr))
+ std::string interfaceTooltipName;
+ if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, interfaceTooltipName))
{
m_tooltipPos = pos;
- strcpy(m_tooltipName, nameStr.c_str());
+ m_tooltipName = interfaceTooltipName;
m_tooltipTime = 0.0f;
if (obj == nullptr) return;
}
@@ -3086,13 +3084,13 @@ void CRobotMain::HiliteObject(Math::Point pos)
}
}
- char name[100];
if (obj != nullptr)
{
- if (m_dialog->GetTooltip() && obj->GetTooltipName(name))
+ std::string objectTooltipName;
+ if (m_dialog->GetTooltip() && obj->GetTooltipName(objectTooltipName))
{
m_tooltipPos = pos;
- strcpy(m_tooltipName, name);
+ m_tooltipName = objectTooltipName;
m_tooltipTime = 0.0f;
}
@@ -3117,15 +3115,14 @@ void CRobotMain::HiliteFrame(float rTime)
ClearTooltip();
- if (m_tooltipTime >= 0.2f &&
- m_tooltipName[0] != 0)
+ if (m_tooltipTime >= 0.2f && !m_tooltipName.empty())
{
CreateTooltip(m_tooltipPos, m_tooltipName);
}
}
//! Creates a tooltip
-void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
+void CRobotMain::CreateTooltip(Math::Point pos, const std::string& text)
{
Math::Point corner;
corner.x = pos.x+0.022f;
@@ -3515,7 +3512,7 @@ bool CRobotMain::EventFrame(const Event &event)
}
// Moves edition indicator.
- if (m_editLock || m_pause) // edition in progress?
+ if (m_editLock || m_pause->GetPause()) // edition in progress?
{
Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
if (pc != nullptr)
@@ -3856,6 +3853,8 @@ void CRobotMain::ScenePerso()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
@@ -3903,6 +3902,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->FlushMaterials();
m_audioTrack = "";
m_audioRepeat = true;
+ m_satcomTrack = "";
+ m_satcomRepeat = true;
+ m_editorTrack = "";
+ m_editorRepeat = true;
m_displayText->SetDelay(1.0f);
m_displayText->SetEnable(true);
m_immediatSatCom = false;
@@ -3949,7 +3952,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->BuildResumeName(m_title, base, rank);
m_dialog->BuildResumeName(m_resume, base, rank);
- GetResource(RES_TEXT, RT_SCRIPT_NEW, m_scriptName);
+ std::string scriptNameStr;
+ GetResource(RES_TEXT, RT_SCRIPT_NEW, scriptNameStr);
+ strcpy(m_scriptName, scriptNameStr.c_str());
m_scriptFile[0] = 0;
m_beginObject = false;
@@ -4006,8 +4011,10 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
}
}
- if (Cmd(line, "MissionFile") && !resetObject)
+ if (Cmd(line, "MissionFile") && !resetObject) {
m_version = OpInt(line, "version", 1);
+ continue;
+ }
// TODO: Fallback to an non-localized entry
sprintf(op, "Title.%c", m_app->GetLanguageChar());
@@ -4031,9 +4038,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
continue;
}
- if (Cmd(line, "Title")) continue; // Ignore
- if (Cmd(line, "Resume")) continue; // Ignore
- if (Cmd(line, "ScriptName")) continue; // Ignore
+ static const boost::regex titleCmdRe("Title\\.[A-Z]");
+ static const boost::regex resumeCmdRe("Resume\\.[A-Z]");
+ static const boost::regex scriptNameCmdRe("ScriptName\\.[A-Z]");
+
+ if (boost::regex_match(GetCmd(line), titleCmdRe)) continue; // Ignore
+ if (boost::regex_match(GetCmd(line), resumeCmdRe)) continue; // Ignore
+ if (boost::regex_match(GetCmd(line), scriptNameCmdRe)) continue; // Ignore
+
if (Cmd(line, "ScriptFile") && !resetObject)
{
@@ -4044,18 +4056,19 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Instructions") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_HUSTON], path.c_str());
m_immediatSatCom = OpInt(line, "immediat", 0);
if (m_version >= 2) m_beginSatCom = m_lockedSatCom = OpInt(line, "lock", 0);
+ if (m_app->GetSceneTestMode()) m_immediatSatCom = false;
continue;
}
if (Cmd(line, "Satellite") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_SAT], path.c_str());
continue;
}
@@ -4063,7 +4076,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "Loading") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_LOADING], path.c_str());
continue;
}
@@ -4071,14 +4084,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "HelpFile") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_PROG], path.c_str());
continue;
}
if (Cmd(line, "SoluceFile") && !resetObject)
{
OpString(line, "name", name);
- std::string path = m_app->GetDataFilePath(DIR_HELP, name);
+ std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_HELP, name);
strcpy(m_infoFilename[SATCOM_SOLUCE], path.c_str());
continue;
}
@@ -4109,12 +4122,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (i < 10)
{
m_audioChange[i].pos = OpPos(line, "pos")*g_unit;
- m_audioChange[i].dist = OpFloat(line, "dist", 8.0f)*g_unit;
+ m_audioChange[i].dist = OpFloat(line, "dist", 1000.0f)*g_unit;
m_audioChange[i].type = OpTypeObject(line, "type", OBJECT_NULL);
m_audioChange[i].min = OpInt(line, "min", 1);
m_audioChange[i].max = OpInt(line, "max", 9999);
- m_audioChange[i].powermin = OpInt(line, "powermin", -1);
- m_audioChange[i].powermax = OpInt(line, "powermax", 100);
+ m_audioChange[i].powermin = OpFloat(line, "powermin", -1);
+ m_audioChange[i].powermax = OpFloat(line, "powermax", 100);
+ m_audioChange[i].tool = OpTool(line, "tool");
+ m_audioChange[i].drive = OpDrive(line, "drive");
OpString(line, "filename", m_audioChange[i].music);
m_audioChange[i].repeat = OpInt(line, "repeat", 1);
m_audioChange[i].changed = false;
@@ -4135,15 +4150,27 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
filenameStr << "music" << std::setfill('0') << std::setw(3) << trackid << ".ogg";
m_audioTrack = filenameStr.str();
}
+ m_audioRepeat = OpInt(line, "repeat", 1);
}
else
{
char trackname[100];
- OpString(line, "filename", trackname);
+
+ OpString(line, "main", trackname);
m_audioTrack = trackname;
+ m_audioRepeat = OpInt(line, "mainRepeat", 1);
+
+ OpString(line, "satcom", trackname);
+ m_satcomTrack = trackname;
+ m_satcomRepeat = OpInt(line, "satcomRepeat", 1);
+
+ OpString(line, "editor", trackname);
+ m_editorTrack = trackname;
+ m_editorRepeat = OpInt(line, "editorRepeat", 1);
}
- m_audioRepeat = OpInt(line, "repeat", 1);
if (m_audioTrack != "") m_sound->CacheMusic(m_audioTrack);
+ if (m_satcomTrack != "") m_sound->CacheMusic(m_satcomTrack);
+ if (m_editorTrack != "") m_sound->CacheMusic(m_editorTrack);
continue;
}
@@ -4325,6 +4352,12 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_terrain->LoadRelief(name, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1));
continue;
}
+
+ if (Cmd(line, "TerrainRandomRelief") && !resetObject)
+ {
+ m_terrain->RandomizeRelief();
+ continue;
+ }
if (Cmd(line, "TerrainResource") && !resetObject)
{
@@ -4539,15 +4572,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (Cmd(line, "MissionController") && read[0] == 0 && m_version >= 2)
{
- /* TODO: ???
- if (!m_beginObject)
- {
- GetLogger()->Error("Syntax error in file '%s' (line %d): MissionController before BeginObject\n", filename, lineNum);
- continue;
- }*/
-
- m_controller = CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 1.0f, 0.0f, OBJECT_CONTROLLER, 100.0f, false, false, 0);
+ m_controller = CObjectManager::GetInstancePointer()->CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, OBJECT_CONTROLLER, 100.0f);
m_controller->SetMagnifyDamage(100.0f);
+ m_controller->SetIgnoreBuildCheck(true);
CBrain* brain = m_controller->GetBrain();
if (brain != nullptr)
{
@@ -4577,11 +4604,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
(type >= OBJECT_PLANT0 &&
type <= OBJECT_PLANT19 ) ||
(type >= OBJECT_TREE0 &&
- type <= OBJECT_TREE9 ) ||
+ type <= OBJECT_TREE5 ) ||
(type >= OBJECT_TEEN0 &&
- type <= OBJECT_TEEN49 ) ||
+ type <= OBJECT_TEEN44 ) ||
(type >= OBJECT_QUARTZ0 &&
- type <= OBJECT_QUARTZ9 ) ||
+ type <= OBJECT_QUARTZ3 ) ||
(type >= OBJECT_ROOT0 &&
type <= OBJECT_ROOT4 ) ) // not ROOT5!
{
@@ -4605,15 +4632,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
Math::Vector pos = OpPos(line, "pos")*g_unit;
float dirAngle = OpFloat(line, "dir", 0.0f)*Math::PI;
- bool trainer = OpInt(line, "trainer", 0);
- CObject* obj = CreateObject(pos, dirAngle,
- OpFloat(line, "z", 1.0f),
- OpFloat(line, "h", 0.0f),
+ bool trainer;
+ CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(
+ pos, dirAngle,
type,
OpFloat(line, "power", 1.0f),
- trainer,
+ OpFloat(line, "z", 1.0f),
+ OpFloat(line, "h", 0.0f),
+ trainer = OpInt(line, "trainer", 0),
OpInt(line, "toy", 0),
OpInt(line, "option", 0));
+
+ if (m_fixScene && type == OBJECT_HUMAN)
+ {
+ CMotion* motion = obj->GetMotion();
+ if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
+ if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
+ }
if (obj != nullptr)
{
@@ -4667,6 +4702,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
bool selectable = OpInt(line, "selectable", 1);
obj->SetSelectable(selectable);
+ obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
obj->SetEnable(OpInt(line, "enable", 1));
obj->SetProxyActivate(OpInt(line, "proxyActivate", 0));
obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
@@ -4709,9 +4745,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{
sprintf(op, "script%d", i+1); // script1..script10
OpString(line, op, name);
-/* TODO: #if _SCHOOL
- if ( !m_dialog->GetSoluce4() && i == 3 ) continue;
-#endif*/
if (name[0] != 0)
brain->SetScriptName(i, name);
@@ -4910,19 +4943,23 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (i < 10)
{
m_endTake[i].pos = OpPos(line, "pos")*g_unit;
- m_endTake[i].dist = OpFloat(line, "dist", 8.0f)*g_unit;
+ m_endTake[i].dist = OpFloat(line, "dist", (m_version < 2 ? 8.0f : 100.0f))*g_unit;
m_endTake[i].type = OpTypeObject(line, "type", OBJECT_NULL);
m_endTake[i].min = OpInt(line, "min", 1);
m_endTake[i].max = OpInt(line, "max", 9999);
if (m_version >= 2)
{
- m_endTake[i].powermin = OpInt(line, "powermin", -1);
- m_endTake[i].powermax = OpInt(line, "powermax", 100);
+ m_endTake[i].powermin = OpFloat(line, "powermin", -1);
+ m_endTake[i].powermax = OpFloat(line, "powermax", 100);
+ m_endTake[i].tool = OpTool(line, "tool");
+ m_endTake[i].drive = OpDrive(line, "drive");
}
else
{
m_endTake[i].powermin = -1;
m_endTake[i].powermax = 100;
+ m_endTake[i].tool = TOOL_OTHER;
+ m_endTake[i].drive = DRIVE_OTHER;
}
m_endTake[i].lost = OpInt(line, "lost", -1);
m_endTake[i].immediat = OpInt(line, "immediat", 0);
@@ -5074,339 +5111,9 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_dialog->SetStackRead("");
RestoreNumericLocale();
-}
-
-//! Creates an object of decoration mobile or stationary
-CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, float height,
- ObjectType type, float power,
- bool trainer, bool toy,
- int option)
-{
- CObject* object = nullptr;
-
- if ( type == OBJECT_NULL ) return nullptr;
-
- if ( type == OBJECT_HUMAN ||
- type == OBJECT_TECH )
- {
- trainer = false; // necessarily
- }
-
- if ( type == OBJECT_PORTICO ||
- type == OBJECT_BASE ||
- type == OBJECT_DERRICK ||
- type == OBJECT_FACTORY ||
- type == OBJECT_STATION ||
- type == OBJECT_CONVERT ||
- type == OBJECT_REPAIR ||
- type == OBJECT_DESTROYER||
- type == OBJECT_TOWER ||
- type == OBJECT_NEST ||
- type == OBJECT_RESEARCH ||
- type == OBJECT_RADAR ||
- type == OBJECT_INFO ||
- type == OBJECT_ENERGY ||
- type == OBJECT_LABO ||
- type == OBJECT_NUCLEAR ||
- type == OBJECT_PARA ||
- type == OBJECT_SAFE ||
- type == OBJECT_HUSTON ||
- type == OBJECT_TARGET1 ||
- type == OBJECT_TARGET2 ||
- type == OBJECT_START ||
- type == OBJECT_END )
- {
- object = new CObject();
- object->CreateBuilding(pos, angle, height, type, power);
-
- CAuto* automat = object->GetAuto();
- if (automat != nullptr)
- {
- automat->Init();
- }
- }
- else
- if ( type == OBJECT_FRET ||
- type == OBJECT_STONE ||
- type == OBJECT_URANIUM ||
- type == OBJECT_METAL ||
- type == OBJECT_POWER ||
- type == OBJECT_ATOMIC ||
- type == OBJECT_BULLET ||
- type == OBJECT_BBOX ||
- type == OBJECT_KEYa ||
- type == OBJECT_KEYb ||
- type == OBJECT_KEYc ||
- type == OBJECT_KEYd ||
- type == OBJECT_TNT ||
- type == OBJECT_SCRAP1 ||
- type == OBJECT_SCRAP2 ||
- type == OBJECT_SCRAP3 ||
- type == OBJECT_SCRAP4 ||
- type == OBJECT_SCRAP5 ||
- type == OBJECT_BOMB ||
- type == OBJECT_WAYPOINT ||
- type == OBJECT_SHOW ||
- type == OBJECT_WINFIRE ||
- type == OBJECT_BAG ||
- type == OBJECT_MARKPOWER ||
- type == OBJECT_MARKSTONE ||
- type == OBJECT_MARKURANIUM ||
- type == OBJECT_MARKKEYa ||
- type == OBJECT_MARKKEYb ||
- type == OBJECT_MARKKEYc ||
- type == OBJECT_MARKKEYd ||
- type == OBJECT_EGG )
- {
- object = new CObject();
- object->CreateResource(pos, angle, type, power);
- }
- else
- if ( type == OBJECT_FLAGb ||
- type == OBJECT_FLAGr ||
- type == OBJECT_FLAGg ||
- type == OBJECT_FLAGy ||
- type == OBJECT_FLAGv )
- {
- object = new CObject();
- object->CreateFlag(pos, angle, type);
- }
- else
- if ( type == OBJECT_BARRIER0 ||
- type == OBJECT_BARRIER1 ||
- type == OBJECT_BARRIER2 ||
- type == OBJECT_BARRIER3 ||
- type == OBJECT_BARRIER4 )
- {
- object = new CObject();
- object->CreateBarrier(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_PLANT0 ||
- type == OBJECT_PLANT1 ||
- type == OBJECT_PLANT2 ||
- type == OBJECT_PLANT3 ||
- type == OBJECT_PLANT4 ||
- type == OBJECT_PLANT5 ||
- type == OBJECT_PLANT6 ||
- type == OBJECT_PLANT7 ||
- type == OBJECT_PLANT8 ||
- type == OBJECT_PLANT9 ||
- type == OBJECT_PLANT10 ||
- type == OBJECT_PLANT11 ||
- type == OBJECT_PLANT12 ||
- type == OBJECT_PLANT13 ||
- type == OBJECT_PLANT14 ||
- type == OBJECT_PLANT15 ||
- type == OBJECT_PLANT16 ||
- type == OBJECT_PLANT17 ||
- type == OBJECT_PLANT18 ||
- type == OBJECT_PLANT19 ||
- type == OBJECT_TREE0 ||
- type == OBJECT_TREE1 ||
- type == OBJECT_TREE2 ||
- type == OBJECT_TREE3 ||
- type == OBJECT_TREE4 ||
- type == OBJECT_TREE5 ||
- type == OBJECT_TREE6 ||
- type == OBJECT_TREE7 ||
- type == OBJECT_TREE8 ||
- type == OBJECT_TREE9 )
- {
- object = new CObject();
- object->CreatePlant(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_MUSHROOM0 ||
- type == OBJECT_MUSHROOM1 ||
- type == OBJECT_MUSHROOM2 ||
- type == OBJECT_MUSHROOM3 ||
- type == OBJECT_MUSHROOM4 ||
- type == OBJECT_MUSHROOM5 ||
- type == OBJECT_MUSHROOM6 ||
- type == OBJECT_MUSHROOM7 ||
- type == OBJECT_MUSHROOM8 ||
- type == OBJECT_MUSHROOM9 )
- {
- object = new CObject();
- object->CreateMushroom(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_TEEN0 ||
- type == OBJECT_TEEN1 ||
- type == OBJECT_TEEN2 ||
- type == OBJECT_TEEN3 ||
- type == OBJECT_TEEN4 ||
- type == OBJECT_TEEN5 ||
- type == OBJECT_TEEN6 ||
- type == OBJECT_TEEN7 ||
- type == OBJECT_TEEN8 ||
- type == OBJECT_TEEN9 ||
- type == OBJECT_TEEN10 ||
- type == OBJECT_TEEN11 ||
- type == OBJECT_TEEN12 ||
- type == OBJECT_TEEN13 ||
- type == OBJECT_TEEN14 ||
- type == OBJECT_TEEN15 ||
- type == OBJECT_TEEN16 ||
- type == OBJECT_TEEN17 ||
- type == OBJECT_TEEN18 ||
- type == OBJECT_TEEN19 ||
- type == OBJECT_TEEN20 ||
- type == OBJECT_TEEN21 ||
- type == OBJECT_TEEN22 ||
- type == OBJECT_TEEN23 ||
- type == OBJECT_TEEN24 ||
- type == OBJECT_TEEN25 ||
- type == OBJECT_TEEN26 ||
- type == OBJECT_TEEN27 ||
- type == OBJECT_TEEN28 ||
- type == OBJECT_TEEN29 ||
- type == OBJECT_TEEN30 ||
- type == OBJECT_TEEN31 ||
- type == OBJECT_TEEN32 ||
- type == OBJECT_TEEN33 ||
- type == OBJECT_TEEN34 ||
- type == OBJECT_TEEN35 ||
- type == OBJECT_TEEN36 ||
- type == OBJECT_TEEN37 ||
- type == OBJECT_TEEN38 ||
- type == OBJECT_TEEN39 ||
- type == OBJECT_TEEN40 ||
- type == OBJECT_TEEN41 ||
- type == OBJECT_TEEN42 ||
- type == OBJECT_TEEN43 ||
- type == OBJECT_TEEN44 ||
- type == OBJECT_TEEN45 ||
- type == OBJECT_TEEN46 ||
- type == OBJECT_TEEN47 ||
- type == OBJECT_TEEN48 ||
- type == OBJECT_TEEN49 )
- {
- object = new CObject();
- object->SetOption(option);
- object->CreateTeen(pos, angle, zoom, height, type);
- }
- else
- if ( type == OBJECT_QUARTZ0 ||
- type == OBJECT_QUARTZ1 ||
- type == OBJECT_QUARTZ2 ||
- type == OBJECT_QUARTZ3 ||
- type == OBJECT_QUARTZ4 ||
- type == OBJECT_QUARTZ5 ||
- type == OBJECT_QUARTZ6 ||
- type == OBJECT_QUARTZ7 ||
- type == OBJECT_QUARTZ8 ||
- type == OBJECT_QUARTZ9 )
- {
- object = new CObject();
- object->CreateQuartz(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_ROOT0 ||
- type == OBJECT_ROOT1 ||
- type == OBJECT_ROOT2 ||
- type == OBJECT_ROOT3 ||
- type == OBJECT_ROOT4 ||
- type == OBJECT_ROOT5 ||
- type == OBJECT_ROOT6 ||
- type == OBJECT_ROOT7 ||
- type == OBJECT_ROOT8 ||
- type == OBJECT_ROOT9 )
- {
- object = new CObject();
- object->CreateRoot(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_HOME1 )
- {
- object = new CObject();
- object->CreateHome(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_RUINmobilew1 ||
- type == OBJECT_RUINmobilew2 ||
- type == OBJECT_RUINmobilet1 ||
- type == OBJECT_RUINmobilet2 ||
- type == OBJECT_RUINmobiler1 ||
- type == OBJECT_RUINmobiler2 ||
- type == OBJECT_RUINfactory ||
- type == OBJECT_RUINdoor ||
- type == OBJECT_RUINsupport ||
- type == OBJECT_RUINradar ||
- type == OBJECT_RUINconvert ||
- type == OBJECT_RUINbase ||
- type == OBJECT_RUINhead )
- {
- object = new CObject();
- object->CreateRuin(pos, angle, height, type);
- }
- else
- if ( type == OBJECT_APOLLO1 ||
- type == OBJECT_APOLLO3 ||
- type == OBJECT_APOLLO4 ||
- type == OBJECT_APOLLO5 )
- {
- object = new CObject();
- object->CreateApollo(pos, angle, type);
- }
- else
- if ( type == OBJECT_MOTHER ||
- type == OBJECT_ANT ||
- type == OBJECT_SPIDER ||
- type == OBJECT_BEE ||
- type == OBJECT_WORM )
- {
- object = new CObject();
- object->CreateInsect(pos, angle, type); // no eggs
- }
- else
- if ( type == OBJECT_HUMAN ||
- type == OBJECT_TECH ||
- type == OBJECT_TOTO ||
- type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEii ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEis ||
- type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs ||
- type == OBJECT_MOBILEsa ||
- type == OBJECT_MOBILEtg ||
- type == OBJECT_MOBILEft ||
- type == OBJECT_MOBILEtt ||
- type == OBJECT_MOBILEwt ||
- type == OBJECT_MOBILEit ||
- type == OBJECT_MOBILEdr ||
- type == OBJECT_APOLLO2 ||
- type == OBJECT_CONTROLLER )
- {
- object = new CObject();
- object->SetOption(option);
- object->CreateVehicle(pos, angle, type, power, trainer, toy);
- }
-
- if (m_fixScene && type == OBJECT_HUMAN)
- {
- CMotion* motion = object->GetMotion();
- if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
- if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
- }
-
- return object;
+
+ if(m_app->GetSceneTestMode())
+ m_eventQueue->AddEvent(Event(EVENT_WIN));
}
//! Creates a directional light
@@ -6014,7 +5721,9 @@ void CRobotMain::CompileScript(bool soluce)
char* name = brain->GetScriptName(j);
if (name[0] != 0)
{
- brain->ReadProgram(j, name);
+ if(! brain->ReadProgram(j, name)) {
+ CLogger::GetInstancePointer()->Error("Unable to read script from file \"%s\"\n", name);
+ }
if (!brain->GetCompile(j)) nbError++;
}
}
@@ -6339,6 +6048,9 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
sprintf(name, " trainer=%d", obj->GetTrainer());
strcat(line, name);
+
+ sprintf(name, " ignoreBuildCheck=%d", obj->GetIgnoreBuildCheck());
+ strcat(line, name);
sprintf(name, " option=%d", obj->GetOption());
strcat(line, name);
@@ -6496,10 +6208,11 @@ CObject* CRobotMain::IOReadObject(char *line, const char* filename, int objRank)
int toy = OpInt(line, "toy", 0);
int option = OpInt(line, "option", 0);
- CObject* obj = CreateObject(pos, dir.y, 1.0f, 0.0f, type, 0.0f, trainer, toy, option);
+ CObject* obj = CObjectManager::GetInstancePointer()->CreateObject(pos, dir.y, type, 0.0f, 1.0f, 0.0f, trainer, toy, option);
obj->SetDefRank(objRank);
obj->SetPosition(0, pos);
obj->SetAngle(0, dir);
+ obj->SetIgnoreBuildCheck(OpInt(line, "ignoreBuildCheck", 0));
obj->SetID(id);
if (g_id < id) g_id = id;
@@ -6858,6 +6571,8 @@ void CRobotMain::ResetCreate()
iMan->Flush(CLASS_PHYSICS);
iMan->Flush(CLASS_BRAIN);
iMan->Flush(CLASS_PYRO);
+
+ CObjectManager::GetInstancePointer()->Flush();
m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
@@ -6912,8 +6627,13 @@ void CRobotMain::UpdateAudio(bool frame)
{
type = OBJECT_SCRAP1;
}
+
+ ToolType tool = CObject::GetToolFromObject(type);
+ DriveType drive = CObject::GetDriveFromObject(type);
+ if (m_audioChange[t].tool != TOOL_OTHER) if(tool != m_audioChange[t].tool) continue;
+ if (m_audioChange[t].drive != DRIVE_OTHER) if(drive != m_audioChange[t].drive) continue;
- if (type != m_audioChange[t].type) continue;
+ if (m_audioChange[t].tool == TOOL_OTHER && m_audioChange[t].drive == DRIVE_OTHER) if (type != m_audioChange[t].type) continue;
float energyLevel = -1;
CObject* power = obj->GetPower();
@@ -6922,7 +6642,8 @@ void CRobotMain::UpdateAudio(bool frame)
energyLevel = power->GetEnergy();
if (power->GetType() == OBJECT_ATOMIC) energyLevel *= 100;
}
- if (energyLevel < m_audioChange[t].powermin || energyLevel > m_audioChange[t].powermax) continue;
+ if (energyLevel < m_audioChange[t].powermin || energyLevel > m_audioChange[t].powermax)
+ continue;
if (obj->GetTruck() == 0)
oPos = obj->GetPosition(0);
@@ -6938,8 +6659,7 @@ void CRobotMain::UpdateAudio(bool frame)
if (nb >= m_audioChange[t].min &&
nb <= m_audioChange[t].max)
{
- CLogger::GetInstancePointer()->Debug("Changing music...\n");
- m_sound->StopMusic();
+ CLogger::GetInstancePointer()->Info("Changing music to \"%s\"\n", m_audioChange[t].music);
m_sound->PlayMusic(std::string(m_audioChange[t].music), m_audioChange[t].repeat);
m_audioChange[t].changed = true;
}
@@ -7017,7 +6737,12 @@ Error CRobotMain::CheckEndMission(bool frame)
type = OBJECT_SCRAP1;
}
- if (type != m_endTake[t].type) continue;
+ ToolType tool = CObject::GetToolFromObject(type);
+ DriveType drive = CObject::GetDriveFromObject(type);
+ if (m_endTake[t].tool != TOOL_OTHER) if(tool != m_endTake[t].tool) continue;
+ if (m_endTake[t].drive != DRIVE_OTHER) if(drive != m_endTake[t].drive) continue;
+
+ if (m_endTake[t].tool == TOOL_OTHER && m_endTake[t].drive == DRIVE_OTHER) if (type != m_endTake[t].type) continue;
float energyLevel = -1;
CObject* power = obj->GetPower();
@@ -7318,14 +7043,16 @@ float CRobotMain::GetPersoAngle()
//! Changes on the pause mode
-void CRobotMain::ChangePause(bool pause)
+void CRobotMain::ChangePause(PauseType pause)
{
- m_pause = pause;
- m_engine->SetPause(m_pause);
+ if(pause != PAUSE_NONE)
+ m_pause->SetPause(pause);
+ else
+ m_pause->ClearPause();
- m_sound->MuteAll(m_pause);
+ m_sound->MuteAll(m_pause->GetPause());
CreateShortcuts();
- if (m_pause) HiliteClear();
+ if (m_pause->GetPause()) HiliteClear();
}
@@ -7495,8 +7222,27 @@ void CRobotMain::StartMusic()
CLogger::GetInstancePointer()->Debug("Starting music...\n");
if (m_audioTrack != "")
{
- m_sound->StopMusic();
- m_sound->PlayMusic(m_audioTrack, m_audioRepeat);
+ m_sound->PlayMusic(m_audioTrack, m_audioRepeat, 0.0f);
+ }
+}
+
+//! Starts pause music
+void CRobotMain::StartPauseMusic(PauseType pause)
+{
+ switch(pause) {
+ case PAUSE_EDITOR:
+ if(m_editorTrack != "")
+ m_sound->PlayPauseMusic(m_editorTrack, m_editorRepeat);
+ break;
+
+ case PAUSE_SATCOM:
+ if(m_satcomTrack != "")
+ m_sound->PlayPauseMusic(m_satcomTrack, m_satcomRepeat);
+ break;
+
+ default:
+ // Don't change music
+ break;
}
}
@@ -7504,7 +7250,7 @@ void CRobotMain::StartMusic()
void CRobotMain::ClearInterface()
{
HiliteClear(); // removes setting evidence
- m_tooltipName[0] = 0; // really removes the tooltip
+ m_tooltipName.clear(); // really removes the tooltip
}
void CRobotMain::SetNumericLocale()
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 035698c..71ad455 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -30,6 +30,8 @@
#include "object/object.h"
#include "object/mainmovie.h"
+#include "app/pausemanager.h"
+
#include <stdio.h>
enum Phase
@@ -44,7 +46,6 @@ enum Phase
PHASE_FREE,
PHASE_TEEN,
PHASE_USER,
- PHASE_PROTO,
PHASE_LOADING,
PHASE_SIMUL,
PHASE_MODEL,
@@ -104,6 +105,8 @@ struct EndTake
int lost; // lost if <=
float powermin; // wins if energy cell >=
float powermax; // wins if energy cell <=
+ ToolType tool;
+ DriveType drive;
bool immediat;
char message[100];
};
@@ -117,6 +120,8 @@ struct AudioChange
int max; // change if <
float powermin; // change if energy cell >=
float powermax; // change if energy cell <=
+ ToolType tool;
+ DriveType drive;
char music[100];
bool repeat;
bool changed;
@@ -250,7 +255,7 @@ public:
void SetTracePrecision(float factor);
float GetTracePrecision();
- void ChangePause(bool pause);
+ void ChangePause(PauseType pause);
void SetSpeed(float speed);
float GetSpeed();
@@ -335,6 +340,7 @@ public:
float GetPersoAngle();
void StartMusic();
+ void StartPauseMusic(PauseType pause);
void ClearInterface();
void ChangeColor();
@@ -391,14 +397,11 @@ protected:
void CreateScene(bool soluce, bool fixScene, bool resetObject);
Math::Vector LookatPoint(Math::Vector eye, float angleH, float angleV, float length);
- CObject* CreateObject(Math::Vector pos, float angle, float zoom,
- float height, ObjectType type, float power=1.0f,
- bool trainer=false, bool toy=false, int option=0);
int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
- void CreateTooltip(Math::Point pos, const char* text);
+ void CreateTooltip(Math::Point pos, const std::string& text);
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
void ChangeCamera();
@@ -440,6 +443,7 @@ protected:
Ui::CDisplayText* m_displayText;
Ui::CDisplayInfo* m_displayInfo;
CSoundInterface* m_sound;
+ CPauseManager* m_pause;
//! Bindings for user inputs
InputBinding m_inputBindings[INPUT_SLOT_MAX];
@@ -471,15 +475,19 @@ protected:
bool m_showSoluce;
bool m_showAll;
bool m_cheatRadar;
- bool m_audioRepeat;
bool m_shortCut;
std::string m_audioTrack;
+ bool m_audioRepeat;
+ std::string m_satcomTrack;
+ bool m_satcomRepeat;
+ std::string m_editorTrack;
+ bool m_editorRepeat;
int m_delayWriteMessage;
int m_movieInfoIndex;
CObject* m_controller;
- //Level Checker flags
+ // Level Checker flags
bool m_beginObject;
bool m_terrainGenerate;
bool m_terrainInitTextures;
@@ -495,7 +503,6 @@ protected:
bool m_satComLock; // call of SatCom is possible?
bool m_editLock; // edition in progress?
bool m_editFull; // edition in full screen?
- bool m_pause; // simulation paused
bool m_hilite;
bool m_trainerPilot; // remote trainer?
bool m_suspend;
@@ -506,7 +513,7 @@ protected:
char m_mapFilename[100];
Math::Point m_tooltipPos;
- char m_tooltipName[100];
+ std::string m_tooltipName;
float m_tooltipTime;
char m_infoFilename[SATCOM_MAX][100]; // names of text files
@@ -522,6 +529,8 @@ protected:
int m_endingWinRank;
int m_endingLostRank;
bool m_winTerminate;
+
+ bool m_exitAfterMission;
float m_fontSize;
Math::Point m_windowPos;
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 4a62a4a..4dfd6fb 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -100,6 +100,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
if ( m_type == OBJECT_PARA ) m_buildingHeight = 68.0f;
if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f;
if ( m_type == OBJECT_DESTROYER) m_buildingHeight = 35.0f;
+ if ( m_type == OBJECT_HUSTON ) m_buildingHeight = 45.0f;
m_buildingHeight *= 0.25f;
m_buildingPos = m_building->GetPosition(0);
@@ -574,7 +575,7 @@ Error CTaskBuild::FlatFloor()
if ( m_type == OBJECT_PARA ) radius = 20.0f;
if ( m_type == OBJECT_INFO ) radius = 5.0f;
if ( m_type == OBJECT_DESTROYER) radius = 20.0f;
- if ( radius == 0.0f ) return ERR_GENERIC;
+ //if ( radius == 0.0f ) return ERR_GENERIC;
center = m_metal->GetPosition(0);
angle = m_terrain->GetFineSlope(center);
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index 01ff38b..8070d13 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -1559,8 +1559,8 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
oType == OBJECT_BOMB ||
(oType >= OBJECT_PLANT0 &&
oType <= OBJECT_PLANT19 ) ||
- (oType >= OBJECT_MUSHROOM0 &&
- oType <= OBJECT_MUSHROOM9 ) ) continue;
+ (oType >= OBJECT_MUSHROOM1 &&
+ oType <= OBJECT_MUSHROOM2 ) ) continue;
}
addi = add;
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index 3373610..c9c8d30 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -26,6 +26,7 @@
CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object)
{
+ m_aimImpossible = false;
}
// Object's destructor.
@@ -116,6 +117,12 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
m_progress = 0.0f;
+ // direction was constrainted, hence resulting in impossible move
+ if (dirV != m_finalDirV || dirH != m_finalDirH)
+ {
+ m_aimImpossible = true;
+ }
+
return ERR_OK;
}
@@ -126,12 +133,25 @@ Error CTaskGunGoal::IsEnded()
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_initialDirV == m_finalDirV &&
- m_initialDirH == m_finalDirH ) return ERR_STOP;
- if ( m_progress < 1.0f ) return ERR_CONTINUE;
+ m_initialDirH == m_finalDirH )
+ {
+ if ( m_aimImpossible )
+ return ERR_AIM_IMPOSSIBLE;
+ else
+ return ERR_STOP;
+ }
+
+ if ( m_progress < 1.0f ) return ERR_CONTINUE;
m_object->SetGunGoalV(m_finalDirV);
m_object->SetGunGoalH(m_finalDirH);
Abort();
+
+ if ( m_aimImpossible )
+ {
+ return ERR_AIM_IMPOSSIBLE;
+ }
+
return ERR_STOP;
}
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index c6f010b..9fc509d 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -44,5 +44,7 @@ protected:
float m_finalDirV; // direction to reach
float m_initialDirH; // initial direction
float m_finalDirH; // direction to reach
+
+ bool m_aimImpossible; // set to true if impossible aim was set
};
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index af84099..d8bbafd 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -105,9 +105,11 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( power != 0 )
{
energy = power->GetEnergy();
- power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed);
+ energy -= event.rTime * ENERGY_RECOVER / power->GetCapacity() * m_speed;
+ power->SetEnergy(energy);
}
+
speed.x = (Math::Rand()-0.5f)*0.1f*m_progress;
speed.y = (Math::Rand()-0.5f)*0.1f*m_progress;
speed.z = (Math::Rand()-0.5f)*0.1f*m_progress;
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 096e5de..61ff045 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -76,15 +76,9 @@ bool CTaskTerraform::EventProcess(const Event &event)
{
if ( m_soundChannel == -1 )
{
-#if _TEEN
- m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
- m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 1.5f, SOPER_CONTINUE);
- m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
-#else
m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
-#endif
}
dir.x = 0.0f;
@@ -109,11 +103,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
if ( m_phase == TTP_DOWN )
{
pos.x = 9.0f;
-#if _TEEN
- pos.y = 4.0f-m_progress*4.0f;
-#else
pos.y = 4.0f-m_progress*5.8f;
-#endif
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -121,11 +111,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
if ( m_phase == TTP_UP )
{
pos.x = 9.0f;
-#if _TEEN
- pos.y = 4.0f-(1.0f-m_progress)*4.0f;
-#else
pos.y = 4.0f-(1.0f-m_progress)*5.8f;
-#endif
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -230,11 +216,7 @@ Error CTaskTerraform::Start()
m_phase = TTP_CHARGE;
m_progress = 0.0f;
-#if _TEEN
- m_speed = 1.0f/1.5f;
-#else
m_speed = 1.0f/4.0f;
-#endif
m_time = 0.0f;
m_bError = false; // ok
@@ -261,9 +243,6 @@ Error CTaskTerraform::IsEnded()
if ( m_phase == TTP_CHARGE )
{
-#if _TEEN
- Terraform(); // changes the terrain.
-#endif
m_phase = TTP_DOWN;
m_speed = 1.0f/0.2f;
@@ -272,9 +251,7 @@ Error CTaskTerraform::IsEnded()
if ( m_phase == TTP_DOWN )
{
-#if !_TEEN
Terraform(); // changes the terrain.
-#endif
m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetZoom(0, 1.0f);
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index 2c5f95e..a3aaa28 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -107,6 +107,9 @@ CPhysics::CPhysics(CObject* object)
m_bFreeze = false;
m_bForceUpdate = true;
m_bLowLevel = false;
+ m_fallingHeight = 0.0f;
+ m_minFallingHeight = 20.0f;
+ m_fallDamageFraction = 0.007f;
memset(&m_linMotion, 0, sizeof(Motion));
memset(&m_cirMotion, 0,sizeof(Motion));
@@ -786,6 +789,10 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
type = m_object->GetType();
+ if(std::isnan(m_motorSpeed.x)) m_motorSpeed.x = 0.f;
+ if(std::isnan(m_motorSpeed.y)) m_motorSpeed.y = 0.f;
+ if(std::isnan(m_motorSpeed.z)) m_motorSpeed.z = 0.f;
+
motorSpeed = m_motorSpeed;
if ( type == OBJECT_MOTHER ||
@@ -847,6 +854,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
else
{
motorSpeed.y = -1.0f; // grave
+ SetFalling();
}
SetMotor(false);
}
@@ -911,6 +919,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
if ( m_reactorRange == 0.0f ) // reactor tilt?
{
motorSpeed.y = -1.0f; // grave
+ SetFalling();
}
}
@@ -1509,6 +1518,7 @@ bool CPhysics::EventFrame(const Event &event)
if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
{
h *= 0.5f;
+ m_fallingHeight = 0.0f; // can't fall underwater
}
#endif
//? m_linMotion.terrainSpeed.x = -tAngle.z*m_linMotion.terrainForce.x*h;
@@ -1601,6 +1611,13 @@ bool CPhysics::EventFrame(const Event &event)
MotorParticle(m_time, event.rTime);
SoundMotor(event.rTime);
+ if ( m_bLand && m_fallingHeight != 0.0f ) // if fell
+ {
+ float force = (m_fallingHeight - m_object->GetPosition(0).y) * m_fallDamageFraction;
+ m_object->ExploObject(EXPLO_BOUM, force);
+ m_fallingHeight = 0.0f;
+ }
+
m_bForceUpdate = false;
return true;
@@ -2561,19 +2578,13 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
oType == OBJECT_KEYd ||
oType == OBJECT_TNT ||
(oType >= OBJECT_PLANT0 && oType <= OBJECT_PLANT19 ) ||
- (oType >= OBJECT_MUSHROOM0 && oType <= OBJECT_MUSHROOM9) ) continue;
+ (oType >= OBJECT_MUSHROOM1 && oType <= OBJECT_MUSHROOM2) ) continue;
}
-#if _TEEN
- if ( oType == OBJECT_WAYPOINT &&
- pObj->GetEnable() &&
- !m_object->GetResetBusy() ) // driving vehicle?
-#else
if ( oType == OBJECT_WAYPOINT &&
pObj->GetEnable() &&
!m_object->GetResetBusy() &&
m_object->GetTrainer() ) // driving vehicle?
-#endif
{
oPos = pObj->GetPosition(0);
distance = Math::DistanceProjected(oPos, iPos);
@@ -2979,15 +2990,15 @@ void CPhysics::FrameParticle(float aTime, float rTime)
{
Math::Vector pos;
CObject* power;
- float energy, intensity;
+ float energy/*, intensity*/;
int effectLight;
- bool bFlash;
+ //bool bFlash;
m_restBreakParticle -= rTime;
if ( aTime-m_lastPowerParticle < m_engine->ParticleAdapt(0.05f) ) return;
m_lastPowerParticle = aTime;
- bFlash = false;
+ //bFlash = false;
energy = 0.0f;
power = m_object->GetPower();
@@ -3001,7 +3012,7 @@ void CPhysics::FrameParticle(float aTime, float rTime)
if ( energy > m_lastEnergy ) // recharge?
{
PowerParticle(1.0f, false);
- bFlash = true;
+ //bFlash = true;
}
if ( energy == 0.0f || m_lastEnergy == 0.0f )
@@ -3015,7 +3026,7 @@ void CPhysics::FrameParticle(float aTime, float rTime)
if ( m_restBreakParticle > 0.0f )
{
PowerParticle(m_restBreakParticle/2.5f, (energy == 0));
- bFlash = true;
+ //bFlash = true;
}
effectLight = m_object->GetEffectLight();
@@ -3881,3 +3892,36 @@ Error CPhysics::GetError()
return ERR_OK;
}
+void CPhysics::SetFalling()
+{
+ if (m_fallingHeight == 0.0f && m_floorHeight >= m_minFallingHeight)
+ m_fallingHeight = m_object->GetPosition(0).y;
+}
+
+float CPhysics::GetFallingHeight()
+{
+ return m_fallingHeight;
+}
+
+void CPhysics::SetMinFallingHeight(float value)
+{
+ if (value < 0.0f) return;
+ m_minFallingHeight = value;
+}
+
+float CPhysics::GetMinFallingHeight()
+{
+ return m_minFallingHeight;
+}
+
+void CPhysics::SetFallDamageFraction(float value)
+{
+ if (value < 0.0f) return;
+ m_fallDamageFraction = value;
+}
+
+float CPhysics::GetFallDamageFraction()
+{
+ return m_fallDamageFraction;
+}
+
diff --git a/src/physics/physics.h b/src/physics/physics.h
index 834d7b8..fea5601 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -165,6 +165,14 @@ public:
void CreateInterface(bool bSelect);
Error GetError();
+ float GetFallingHeight();
+
+ void SetMinFallingHeight(float value);
+ float GetMinFallingHeight();
+
+ void SetFallDamageFraction(float value);
+ float GetFallDamageFraction();
+
protected:
bool EventFrame(const Event &event);
void WaterFrame(float aTime, float rTime);
@@ -191,6 +199,7 @@ protected:
void MotorParticle(float aTime, float rTime);
void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
void WheelParticle(int color, float width);
+ void SetFalling();
protected:
Gfx::CEngine* m_engine;
@@ -240,13 +249,16 @@ protected:
float m_restBreakParticle;
float m_floorLevel; // ground level
float m_floorHeight; // height above the ground
- int m_soundChannel;
- int m_soundChannelSlide;
+ int m_soundChannel;
+ int m_soundChannelSlide;
float m_soundTimePshhh;
float m_soundTimeJostle;
float m_soundTimeBoum;
bool m_bSoundSlow;
bool m_bForceUpdate;
bool m_bLowLevel;
+ float m_fallingHeight;
+ float m_fallDamageFraction;
+ float m_minFallingHeight;
};
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 505228e..81219df 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -253,10 +253,11 @@ std::string GetHelpFilename(const char *token)
if ( strcmp(token, "getresearchenable" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresen.txt");
if ( strcmp(token, "getresearchdone" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/getresdo.txt");
if ( strcmp(token, "retobject" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/retobj.txt");
- if ( strcmp(token, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
- if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt");
- if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
+ if ( strcmp(token, "progfunc" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
+ if ( strcmp(token, "busy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/busy.txt");
+ if ( strcmp(token, "takeoff" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/takeoff.txt");
if ( strcmp(token, "research" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/research.txt");
+ if ( strcmp(token, "factory" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/factory.txt");
if ( strcmp(token, "destroy" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/destroy.txt");
if ( strcmp(token, "search" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/search.txt");
if ( strcmp(token, "radar" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/radar.txt");
@@ -333,6 +334,7 @@ std::string GetHelpFilename(const char *token)
if ( strcmp(token, "penup" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penup.txt");
if ( strcmp(token, "pencolor" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/pencolor.txt");
if ( strcmp(token, "penwidth" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/penwidth.txt");
+ if ( strcmp(token, "camerafocus" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/camerafocus.txt");
if ( strcmp(token, "extern" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/extern.txt");
if ( strcmp(token, "class" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/class.txt");
if ( strcmp(token, "static" ) == 0 ) return std::string("help/") + CApplication::GetInstancePointer()->GetLanguageChar() + std::string("/cbot/static.txt");
@@ -384,6 +386,7 @@ bool IsFunction(const char *token)
if ( strcmp(token, "busy" ) == 0 ) return true;
if ( strcmp(token, "factory" ) == 0 ) return true;
if ( strcmp(token, "research" ) == 0 ) return true;
+ if ( strcmp(token, "takeoff" ) == 0 ) return true;
if ( strcmp(token, "destroy" ) == 0 ) return true;
if ( strcmp(token, "search" ) == 0 ) return true;
if ( strcmp(token, "radar" ) == 0 ) return true;
@@ -439,6 +442,7 @@ bool IsFunction(const char *token)
if ( strcmp(token, "penup" ) == 0 ) return true;
if ( strcmp(token, "pencolor" ) == 0 ) return true;
if ( strcmp(token, "penwidth" ) == 0 ) return true;
+ if ( strcmp(token, "camerafocus" ) == 0 ) return true;
if ( strcmp(token, "sizeof" ) == 0 ) return true;
return false;
}
@@ -477,6 +481,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "busy" ) == 0 ) return "object.busy ( );";
if ( strcmp(token, "factory" ) == 0 ) return "object.factory ( cat, program );";
if ( strcmp(token, "research" ) == 0 ) return "object.research ( type );";
+ if ( strcmp(token, "takeoff" ) == 0 ) return "object.takeoff ( );";
if ( strcmp(token, "destroy" ) == 0 ) return "object.destroy ( );";
if ( strcmp(token, "search" ) == 0 ) return "search ( );";
if ( strcmp(token, "radar" ) == 0 ) return "radar ( cat, angle, focus, min, max, sens );";
@@ -532,6 +537,7 @@ const char* GetHelpText(const char *token)
if ( strcmp(token, "penup" ) == 0 ) return "penup ( );";
if ( strcmp(token, "pencolor" ) == 0 ) return "pencolor ( color );";
if ( strcmp(token, "penwidth" ) == 0 ) return "penwidth ( width );";
+ if ( strcmp(token, "camerafocus") == 0 ) return "camerafocus ( object );";
return "";
}
diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp
index 69df68b..6393505 100644
--- a/src/script/cmdtoken.cpp
+++ b/src/script/cmdtoken.cpp
@@ -35,6 +35,16 @@ char* SkipSpace(char *line)
return line;
}
+std::string GetCmd(char* line)
+{
+ line = SkipSpace(line);
+
+ int len = 0;
+ for(char* x = line; *x != 0 && *x != ' ' && *x != '\t' && *x != '\n'; x++, len++);
+
+ return std::string(line, len);
+}
+
// Checks if a line contains a command.
bool Cmd(char *line, const char *token)
@@ -42,8 +52,15 @@ bool Cmd(char *line, const char *token)
char* p;
line = SkipSpace(line);
+
p = strstr(line, token);
- return ( p == line ); // command at the beginning?
+ if(p != line) return false; // command at the beginning?
+
+ unsigned int len = 0;
+ for(char* x = p; *x != 0 && *x != ' ' && *x != '\t' && *x != '\n'; x++, len++);
+ if(len != strlen(token)) return false; // ends with space?
+
+ return true;
}
// Seeking an operator.
@@ -238,16 +255,6 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
if ( Cmd(p, "Mine" ) ) return OBJECT_BOMB;
if ( Cmd(p, "Firework" ) ) return OBJECT_WINFIRE;
if ( Cmd(p, "Bag" ) ) return OBJECT_BAG;
- if ( Cmd(p, "Greenery10" ) ) return OBJECT_PLANT10;
- if ( Cmd(p, "Greenery11" ) ) return OBJECT_PLANT11;
- if ( Cmd(p, "Greenery12" ) ) return OBJECT_PLANT12;
- if ( Cmd(p, "Greenery13" ) ) return OBJECT_PLANT13;
- if ( Cmd(p, "Greenery14" ) ) return OBJECT_PLANT14;
- if ( Cmd(p, "Greenery15" ) ) return OBJECT_PLANT15;
- if ( Cmd(p, "Greenery16" ) ) return OBJECT_PLANT16;
- if ( Cmd(p, "Greenery17" ) ) return OBJECT_PLANT17;
- if ( Cmd(p, "Greenery18" ) ) return OBJECT_PLANT18;
- if ( Cmd(p, "Greenery19" ) ) return OBJECT_PLANT19;
if ( Cmd(p, "Greenery0" ) ) return OBJECT_PLANT0;
if ( Cmd(p, "Greenery1" ) ) return OBJECT_PLANT1;
if ( Cmd(p, "Greenery2" ) ) return OBJECT_PLANT2;
@@ -258,26 +265,24 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
if ( Cmd(p, "Greenery7" ) ) return OBJECT_PLANT7;
if ( Cmd(p, "Greenery8" ) ) return OBJECT_PLANT8;
if ( Cmd(p, "Greenery9" ) ) return OBJECT_PLANT9;
+ if ( Cmd(p, "Greenery10" ) ) return OBJECT_PLANT10;
+ if ( Cmd(p, "Greenery11" ) ) return OBJECT_PLANT11;
+ if ( Cmd(p, "Greenery12" ) ) return OBJECT_PLANT12;
+ if ( Cmd(p, "Greenery13" ) ) return OBJECT_PLANT13;
+ if ( Cmd(p, "Greenery14" ) ) return OBJECT_PLANT14;
+ if ( Cmd(p, "Greenery15" ) ) return OBJECT_PLANT15;
+ if ( Cmd(p, "Greenery16" ) ) return OBJECT_PLANT16;
+ if ( Cmd(p, "Greenery17" ) ) return OBJECT_PLANT17;
+ if ( Cmd(p, "Greenery18" ) ) return OBJECT_PLANT18;
+ if ( Cmd(p, "Greenery19" ) ) return OBJECT_PLANT19;
if ( Cmd(p, "Tree0" ) ) return OBJECT_TREE0;
if ( Cmd(p, "Tree1" ) ) return OBJECT_TREE1;
if ( Cmd(p, "Tree2" ) ) return OBJECT_TREE2;
if ( Cmd(p, "Tree3" ) ) return OBJECT_TREE3;
if ( Cmd(p, "Tree4" ) ) return OBJECT_TREE4;
if ( Cmd(p, "Tree5" ) ) return OBJECT_TREE5;
- if ( Cmd(p, "Tree6" ) ) return OBJECT_TREE6;
- if ( Cmd(p, "Tree7" ) ) return OBJECT_TREE7;
- if ( Cmd(p, "Tree8" ) ) return OBJECT_TREE8;
- if ( Cmd(p, "Tree9" ) ) return OBJECT_TREE9;
- if ( Cmd(p, "Mushroom0" ) ) return OBJECT_MUSHROOM0;
if ( Cmd(p, "Mushroom1" ) ) return OBJECT_MUSHROOM1;
if ( Cmd(p, "Mushroom2" ) ) return OBJECT_MUSHROOM2;
- if ( Cmd(p, "Mushroom3" ) ) return OBJECT_MUSHROOM3;
- if ( Cmd(p, "Mushroom4" ) ) return OBJECT_MUSHROOM4;
- if ( Cmd(p, "Mushroom5" ) ) return OBJECT_MUSHROOM5;
- if ( Cmd(p, "Mushroom6" ) ) return OBJECT_MUSHROOM6;
- if ( Cmd(p, "Mushroom7" ) ) return OBJECT_MUSHROOM7;
- if ( Cmd(p, "Mushroom8" ) ) return OBJECT_MUSHROOM8;
- if ( Cmd(p, "Mushroom9" ) ) return OBJECT_MUSHROOM9;
if ( Cmd(p, "Home" ) ) return OBJECT_HOME1;
if ( Cmd(p, "Derrick" ) ) return OBJECT_DERRICK;
if ( Cmd(p, "BotFactory" ) ) return OBJECT_FACTORY;
@@ -323,47 +328,6 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
if ( Cmd(p, "Barrier1" ) ) return OBJECT_BARRIER1;
if ( Cmd(p, "Barrier2" ) ) return OBJECT_BARRIER2;
if ( Cmd(p, "Barrier3" ) ) return OBJECT_BARRIER3;
- if ( Cmd(p, "Barrier4" ) ) return OBJECT_BARRIER4;
- if ( Cmd(p, "Teen40" ) ) return OBJECT_TEEN40;
- if ( Cmd(p, "Teen41" ) ) return OBJECT_TEEN41;
- if ( Cmd(p, "Teen42" ) ) return OBJECT_TEEN42;
- if ( Cmd(p, "Teen43" ) ) return OBJECT_TEEN43;
- if ( Cmd(p, "Teen44" ) ) return OBJECT_TEEN44;
- if ( Cmd(p, "Teen45" ) ) return OBJECT_TEEN45;
- if ( Cmd(p, "Teen46" ) ) return OBJECT_TEEN46;
- if ( Cmd(p, "Teen47" ) ) return OBJECT_TEEN47;
- if ( Cmd(p, "Teen48" ) ) return OBJECT_TEEN48;
- if ( Cmd(p, "Teen49" ) ) return OBJECT_TEEN49;
- if ( Cmd(p, "Teen30" ) ) return OBJECT_TEEN30;
- if ( Cmd(p, "Teen31" ) ) return OBJECT_TEEN31;
- if ( Cmd(p, "Teen32" ) ) return OBJECT_TEEN32;
- if ( Cmd(p, "Teen33" ) ) return OBJECT_TEEN33;
- if ( Cmd(p, "Stone" ) ) return OBJECT_TEEN34;
- if ( Cmd(p, "Teen35" ) ) return OBJECT_TEEN35;
- if ( Cmd(p, "Teen36" ) ) return OBJECT_TEEN36;
- if ( Cmd(p, "Teen37" ) ) return OBJECT_TEEN37;
- if ( Cmd(p, "Teen38" ) ) return OBJECT_TEEN38;
- if ( Cmd(p, "Teen39" ) ) return OBJECT_TEEN39;
- if ( Cmd(p, "Teen20" ) ) return OBJECT_TEEN20;
- if ( Cmd(p, "Teen21" ) ) return OBJECT_TEEN21;
- if ( Cmd(p, "Teen22" ) ) return OBJECT_TEEN22;
- if ( Cmd(p, "Teen23" ) ) return OBJECT_TEEN23;
- if ( Cmd(p, "Teen24" ) ) return OBJECT_TEEN24;
- if ( Cmd(p, "Teen25" ) ) return OBJECT_TEEN25;
- if ( Cmd(p, "Teen26" ) ) return OBJECT_TEEN26;
- if ( Cmd(p, "Teen27" ) ) return OBJECT_TEEN27;
- if ( Cmd(p, "Teen28" ) ) return OBJECT_TEEN28;
- if ( Cmd(p, "Teen29" ) ) return OBJECT_TEEN29;
- if ( Cmd(p, "Teen10" ) ) return OBJECT_TEEN10;
- if ( Cmd(p, "Teen11" ) ) return OBJECT_TEEN11;
- if ( Cmd(p, "Teen12" ) ) return OBJECT_TEEN12;
- if ( Cmd(p, "Teen13" ) ) return OBJECT_TEEN13;
- if ( Cmd(p, "Teen14" ) ) return OBJECT_TEEN14;
- if ( Cmd(p, "Teen15" ) ) return OBJECT_TEEN15;
- if ( Cmd(p, "Teen16" ) ) return OBJECT_TEEN16;
- if ( Cmd(p, "Teen17" ) ) return OBJECT_TEEN17;
- if ( Cmd(p, "Teen18" ) ) return OBJECT_TEEN18;
- if ( Cmd(p, "Teen19" ) ) return OBJECT_TEEN19;
if ( Cmd(p, "Teen0" ) ) return OBJECT_TEEN0;
if ( Cmd(p, "Teen1" ) ) return OBJECT_TEEN1;
if ( Cmd(p, "Teen2" ) ) return OBJECT_TEEN2;
@@ -374,26 +338,51 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
if ( Cmd(p, "Teen7" ) ) return OBJECT_TEEN7;
if ( Cmd(p, "Teen8" ) ) return OBJECT_TEEN8;
if ( Cmd(p, "Teen9" ) ) return OBJECT_TEEN9;
+ if ( Cmd(p, "Teen10" ) ) return OBJECT_TEEN10;
+ if ( Cmd(p, "Teen11" ) ) return OBJECT_TEEN11;
+ if ( Cmd(p, "Teen12" ) ) return OBJECT_TEEN12;
+ if ( Cmd(p, "Teen13" ) ) return OBJECT_TEEN13;
+ if ( Cmd(p, "Teen14" ) ) return OBJECT_TEEN14;
+ if ( Cmd(p, "Teen15" ) ) return OBJECT_TEEN15;
+ if ( Cmd(p, "Teen16" ) ) return OBJECT_TEEN16;
+ if ( Cmd(p, "Teen17" ) ) return OBJECT_TEEN17;
+ if ( Cmd(p, "Teen18" ) ) return OBJECT_TEEN18;
+ if ( Cmd(p, "Teen19" ) ) return OBJECT_TEEN19;
+ if ( Cmd(p, "Teen20" ) ) return OBJECT_TEEN20;
+ if ( Cmd(p, "Teen21" ) ) return OBJECT_TEEN21;
+ if ( Cmd(p, "Teen22" ) ) return OBJECT_TEEN22;
+ if ( Cmd(p, "Teen23" ) ) return OBJECT_TEEN23;
+ if ( Cmd(p, "Teen24" ) ) return OBJECT_TEEN24;
+ if ( Cmd(p, "Teen25" ) ) return OBJECT_TEEN25;
+ if ( Cmd(p, "Teen26" ) ) return OBJECT_TEEN26;
+ if ( Cmd(p, "Teen27" ) ) return OBJECT_TEEN27;
+ if ( Cmd(p, "Teen28" ) ) return OBJECT_TEEN28;
+ if ( Cmd(p, "Teen29" ) ) return OBJECT_TEEN29;
+ if ( Cmd(p, "Teen30" ) ) return OBJECT_TEEN30;
+ if ( Cmd(p, "Teen31" ) ) return OBJECT_TEEN31;
+ if ( Cmd(p, "Teen32" ) ) return OBJECT_TEEN32;
+ if ( Cmd(p, "Teen33" ) ) return OBJECT_TEEN33;
+ if ( Cmd(p, "Stone" ) ) return OBJECT_TEEN34;
+ if ( Cmd(p, "Teen35" ) ) return OBJECT_TEEN35;
+ if ( Cmd(p, "Teen36" ) ) return OBJECT_TEEN36;
+ if ( Cmd(p, "Teen37" ) ) return OBJECT_TEEN37;
+ if ( Cmd(p, "Teen38" ) ) return OBJECT_TEEN38;
+ if ( Cmd(p, "Teen39" ) ) return OBJECT_TEEN39;
+ if ( Cmd(p, "Teen40" ) ) return OBJECT_TEEN40;
+ if ( Cmd(p, "Teen41" ) ) return OBJECT_TEEN41;
+ if ( Cmd(p, "Teen42" ) ) return OBJECT_TEEN42;
+ if ( Cmd(p, "Teen43" ) ) return OBJECT_TEEN43;
+ if ( Cmd(p, "Teen44" ) ) return OBJECT_TEEN44;
if ( Cmd(p, "Quartz0" ) ) return OBJECT_QUARTZ0;
if ( Cmd(p, "Quartz1" ) ) return OBJECT_QUARTZ1;
if ( Cmd(p, "Quartz2" ) ) return OBJECT_QUARTZ2;
if ( Cmd(p, "Quartz3" ) ) return OBJECT_QUARTZ3;
- if ( Cmd(p, "Quartz4" ) ) return OBJECT_QUARTZ4;
- if ( Cmd(p, "Quartz5" ) ) return OBJECT_QUARTZ5;
- if ( Cmd(p, "Quartz6" ) ) return OBJECT_QUARTZ6;
- if ( Cmd(p, "Quartz7" ) ) return OBJECT_QUARTZ7;
- if ( Cmd(p, "Quartz8" ) ) return OBJECT_QUARTZ8;
- if ( Cmd(p, "Quartz9" ) ) return OBJECT_QUARTZ9;
if ( Cmd(p, "MegaStalk0" ) ) return OBJECT_ROOT0;
if ( Cmd(p, "MegaStalk1" ) ) return OBJECT_ROOT1;
if ( Cmd(p, "MegaStalk2" ) ) return OBJECT_ROOT2;
if ( Cmd(p, "MegaStalk3" ) ) return OBJECT_ROOT3;
if ( Cmd(p, "MegaStalk4" ) ) return OBJECT_ROOT4;
if ( Cmd(p, "MegaStalk5" ) ) return OBJECT_ROOT5;
- if ( Cmd(p, "MegaStalk6" ) ) return OBJECT_ROOT6;
- if ( Cmd(p, "MegaStalk7" ) ) return OBJECT_ROOT7;
- if ( Cmd(p, "MegaStalk8" ) ) return OBJECT_ROOT8;
- if ( Cmd(p, "MegaStalk9" ) ) return OBJECT_ROOT9;
if ( Cmd(p, "ApolloLEM" ) ) return OBJECT_APOLLO1;
if ( Cmd(p, "ApolloJeep" ) ) return OBJECT_APOLLO2;
if ( Cmd(p, "ApolloFlag" ) ) return OBJECT_APOLLO3;
@@ -438,11 +427,7 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_MOBILEdr ) return "Scribbler";
if ( type == OBJECT_MARKPOWER ) return "PowerSpot";
if ( type == OBJECT_MARKSTONE ) return "TitaniumSpot";
-#if _GERMAN | _WG
- if ( type == OBJECT_MARKURANIUM ) return "PlatinumSpot";
-#else
if ( type == OBJECT_MARKURANIUM ) return "UraniumSpot";
-#endif
if ( type == OBJECT_MARKKEYa ) return "KeyASpot";
if ( type == OBJECT_MARKKEYb ) return "KeyBSpot";
if ( type == OBJECT_MARKKEYc ) return "KeyCSpot";
@@ -454,17 +439,9 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_FLAGy ) return "YellowFlag";
if ( type == OBJECT_FLAGv ) return "VioletFlag";
if ( type == OBJECT_POWER ) return "PowerCell";
-#if _GERMAN | _WG
- if ( type == OBJECT_ATOMIC ) return "FuelCell";
-#else
if ( type == OBJECT_ATOMIC ) return "NuclearCell";
-#endif
if ( type == OBJECT_STONE ) return "TitaniumOre";
-#if _GERMAN | _WG
- if ( type == OBJECT_URANIUM ) return "PlatinumOre";
-#else
if ( type == OBJECT_URANIUM ) return "UraniumOre";
-#endif
if ( type == OBJECT_METAL ) return "Titanium";
if ( type == OBJECT_BULLET ) return "OrgaMatter";
if ( type == OBJECT_BBOX ) return "BlackBox";
@@ -507,20 +484,8 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_TREE3 ) return "Tree3";
if ( type == OBJECT_TREE4 ) return "Tree4";
if ( type == OBJECT_TREE5 ) return "Tree5";
- if ( type == OBJECT_TREE6 ) return "Tree6";
- if ( type == OBJECT_TREE7 ) return "Tree7";
- if ( type == OBJECT_TREE8 ) return "Tree8";
- if ( type == OBJECT_TREE9 ) return "Tree9";
- if ( type == OBJECT_MUSHROOM0 ) return "Mushroom0";
if ( type == OBJECT_MUSHROOM1 ) return "Mushroom1";
if ( type == OBJECT_MUSHROOM2 ) return "Mushroom2";
- if ( type == OBJECT_MUSHROOM3 ) return "Mushroom3";
- if ( type == OBJECT_MUSHROOM4 ) return "Mushroom4";
- if ( type == OBJECT_MUSHROOM5 ) return "Mushroom5";
- if ( type == OBJECT_MUSHROOM6 ) return "Mushroom6";
- if ( type == OBJECT_MUSHROOM7 ) return "Mushroom7";
- if ( type == OBJECT_MUSHROOM8 ) return "Mushroom8";
- if ( type == OBJECT_MUSHROOM9 ) return "Mushroom9";
if ( type == OBJECT_HOME1 ) return "Home";
if ( type == OBJECT_DERRICK ) return "Derrick";
if ( type == OBJECT_FACTORY ) return "BotFactory";
@@ -535,11 +500,7 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_INFO ) return "ExchangePost";
if ( type == OBJECT_ENERGY ) return "PowerPlant";
if ( type == OBJECT_LABO ) return "AutoLab";
-#if _GERMAN | _WG
- if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant";
-#else
if ( type == OBJECT_NUCLEAR ) return "NuclearPlant";
-#endif
if ( type == OBJECT_PARA ) return "PowerCaptor";
if ( type == OBJECT_SAFE ) return "Vault";
if ( type == OBJECT_HUSTON ) return "Houston";
@@ -570,7 +531,6 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_BARRIER1 ) return "Barrier1";
if ( type == OBJECT_BARRIER2 ) return "Barrier2";
if ( type == OBJECT_BARRIER3 ) return "Barrier3";
- if ( type == OBJECT_BARRIER4 ) return "Barrier4";
if ( type == OBJECT_TEEN0 ) return "Teen0";
if ( type == OBJECT_TEEN1 ) return "Teen1";
if ( type == OBJECT_TEEN2 ) return "Teen2";
@@ -616,31 +576,16 @@ const char* GetTypeObject(ObjectType type)
if ( type == OBJECT_TEEN42 ) return "Teen42";
if ( type == OBJECT_TEEN43 ) return "Teen43";
if ( type == OBJECT_TEEN44 ) return "Teen44";
- if ( type == OBJECT_TEEN45 ) return "Teen45";
- if ( type == OBJECT_TEEN46 ) return "Teen46";
- if ( type == OBJECT_TEEN47 ) return "Teen47";
- if ( type == OBJECT_TEEN48 ) return "Teen48";
- if ( type == OBJECT_TEEN49 ) return "Teen49";
if ( type == OBJECT_QUARTZ0 ) return "Quartz0";
if ( type == OBJECT_QUARTZ1 ) return "Quartz1";
if ( type == OBJECT_QUARTZ2 ) return "Quartz2";
if ( type == OBJECT_QUARTZ3 ) return "Quartz3";
- if ( type == OBJECT_QUARTZ4 ) return "Quartz4";
- if ( type == OBJECT_QUARTZ5 ) return "Quartz5";
- if ( type == OBJECT_QUARTZ6 ) return "Quartz6";
- if ( type == OBJECT_QUARTZ7 ) return "Quartz7";
- if ( type == OBJECT_QUARTZ8 ) return "Quartz8";
- if ( type == OBJECT_QUARTZ9 ) return "Quartz9";
if ( type == OBJECT_ROOT0 ) return "MegaStalk0";
if ( type == OBJECT_ROOT1 ) return "MegaStalk1";
if ( type == OBJECT_ROOT2 ) return "MegaStalk2";
if ( type == OBJECT_ROOT3 ) return "MegaStalk3";
if ( type == OBJECT_ROOT4 ) return "MegaStalk4";
if ( type == OBJECT_ROOT5 ) return "MegaStalk5";
- if ( type == OBJECT_ROOT6 ) return "MegaStalk6";
- if ( type == OBJECT_ROOT7 ) return "MegaStalk7";
- if ( type == OBJECT_ROOT8 ) return "MegaStalk8";
- if ( type == OBJECT_ROOT9 ) return "MegaStalk9";
if ( type == OBJECT_APOLLO1 ) return "ApolloLEM";
if ( type == OBJECT_APOLLO2 ) return "ApolloJeep";
if ( type == OBJECT_APOLLO3 ) return "ApolloFlag";
@@ -800,6 +745,62 @@ const char* GetCamera(Gfx::CameraType type)
return "BACK";
}
+// Returns the type of drive.
+
+DriveType GetDrive(char *line, int rank)
+{
+ char* p;
+
+ p = SearchArg(line, rank);
+ if ( *p == 0 ) return DRIVE_OTHER;
+
+ if ( Cmd(p, "Wheeled" ) ) return DRIVE_WHEELED;
+ if ( Cmd(p, "Tracked" ) ) return DRIVE_TRACKED;
+ if ( Cmd(p, "Winged" ) ) return DRIVE_WINGED;
+ if ( Cmd(p, "Legged" ) ) return DRIVE_LEGGED;
+
+ return DRIVE_OTHER;
+}
+
+// Returns the name of a drive.
+
+const char* GetDrive(DriveType type)
+{
+ if ( type == DRIVE_WHEELED ) return "Wheeled";
+ if ( type == DRIVE_TRACKED ) return "Tracked";
+ if ( type == DRIVE_WINGED ) return "Winged";
+ if ( type == DRIVE_LEGGED ) return "Legged";
+ return "Other";
+}
+
+// Returns the type of tool.
+
+ToolType GetTool(char *line, int rank)
+{
+ char* p;
+
+ p = SearchArg(line, rank);
+ if ( *p == 0 ) return TOOL_OTHER;
+
+ if ( Cmd(p, "Grabber" ) ) return TOOL_GRABBER;
+ if ( Cmd(p, "Sniffer" ) ) return TOOL_SNIFFER;
+ if ( Cmd(p, "Shooter" ) ) return TOOL_SHOOTER;
+ if ( Cmd(p, "OrgaShooter" ) ) return TOOL_ORGASHOOTER;
+
+ return TOOL_OTHER;
+}
+
+// Returns the name of a tool.
+
+const char* GetTool(ToolType type)
+{
+ if ( type == TOOL_GRABBER ) return "Grabber";
+ if ( type == TOOL_SNIFFER ) return "Sniffer";
+ if ( type == TOOL_SHOOTER ) return "Shooter";
+ if ( type == TOOL_ORGASHOOTER ) return "OrgaShooter";
+ return "Other";
+}
+
// Returns an integer.
int OpInt(char *line, const char *op, int def)
@@ -887,6 +888,24 @@ Gfx::CameraType OpCamera(char *line, const char *op)
return GetCamera(line, 0);
}
+// Returns the type of drive.
+
+DriveType OpDrive(char *line, const char *op)
+{
+ line = SearchOp(line, op);
+ if ( *line == 0 ) return DRIVE_OTHER;
+ return GetDrive(line, 0);
+}
+
+// Returns the type of tool.
+
+ToolType OpTool(char *line, const char *op)
+{
+ line = SearchOp(line, op);
+ if ( *line == 0 ) return TOOL_OTHER;
+ return GetTool(line, 0);
+}
+
// Returns the type of a building.
int OpBuild(char *line, const char *op)
diff --git a/src/script/cmdtoken.h b/src/script/cmdtoken.h
index fe831f1..8a423c5 100644
--- a/src/script/cmdtoken.h
+++ b/src/script/cmdtoken.h
@@ -30,6 +30,7 @@
// Procedures.
+extern std::string GetCmd(char* line);
extern bool Cmd(char *line, const char *token);
extern char* SearchOp(char *line, const char *op);
@@ -45,6 +46,10 @@ extern int GetResearch(char *line, int rank);
extern Gfx::PyroType GetPyro(char *line, int rank);
extern Gfx::CameraType GetCamera(char *line, int rank);
extern const char* GetCamera(Gfx::CameraType type);
+extern DriveType GetDrive(char *line, int rank);
+extern const char* GetDrive(DriveType type);
+extern ToolType GetTool(char *line, int rank);
+extern const char* GetTool(ToolType type);
extern int OpInt(char *line, const char *op, int def);
extern float OpFloat(char *line, const char *op, float def);
@@ -55,6 +60,8 @@ extern Gfx::EngineObjectType OpTypeTerrain(char *line, const char *op, Gfx::Engi
extern int OpResearch(char *line, const char *op);
extern Gfx::PyroType OpPyro(char *line, const char *op);
extern Gfx::CameraType OpCamera(char *line, const char *op);
+extern DriveType OpDrive(char *line, const char *op);
+extern ToolType OpTool(char *line, const char *op);
extern int OpBuild(char *line, const char *op);
extern Math::Vector OpPos(char *line, const char *op);
extern Math::Vector OpDir(char *line, const char *op);
diff --git a/src/script/script.cpp b/src/script/script.cpp
index ca6ce25..2299fbf 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -18,10 +18,12 @@
#include "script/script.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "common/global.h"
#include "common/iman.h"
#include "common/restext.h"
+#include "common/stringutils.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
@@ -37,6 +39,7 @@
#include "object/auto/auto.h"
#include "object/auto/autofactory.h"
+#include "object/auto/autobase.h"
#include "physics/physics.h"
@@ -678,10 +681,23 @@ bool CScript::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& e
classVars = classVars->GetNext(); // "id"
int rank = classVars->GetValInt();
CObject* factory = CObjectManager::GetInstancePointer()->SearchInstance(rank);
- CAutoFactory* automat = static_cast<CAutoFactory*>(factory->GetAuto());
+ if (factory == nullptr) {
+ exception = ERR_GENERIC;
+ result->SetValInt(ERR_GENERIC);
+ CLogger::GetInstancePointer()->Error("in object.factory() - factory is nullptr");
+ return false;
+ }
if ( thisType == OBJECT_FACTORY )
{
+ CAutoFactory* automat = static_cast<CAutoFactory*>(factory->GetAuto());
+ if(automat == nullptr) {
+ exception = ERR_GENERIC;
+ result->SetValInt(ERR_GENERIC);
+ CLogger::GetInstancePointer()->Error("in object.factory() - automat is nullptr");
+ return false;
+ }
+
bool bEnable = false;
if ( type == OBJECT_MOBILEwa )
@@ -900,6 +916,54 @@ bool CScript::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int&
return true;
}
+// Instruction "object.takeoff()"
+
+bool CScript::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception)
+{
+ Error err;
+
+ exception = 0;
+
+ CBotVar* classVars = thisclass->GetItemList(); // "category"
+ ObjectType thisType = static_cast<ObjectType>(classVars->GetValInt());
+ classVars = classVars->GetNext(); // "position"
+ classVars = classVars->GetNext(); // "orientation"
+ classVars = classVars->GetNext(); // "pitch"
+ classVars = classVars->GetNext(); // "roll"
+ classVars = classVars->GetNext(); // "energyLevel"
+ classVars = classVars->GetNext(); // "shieldLevel"
+ classVars = classVars->GetNext(); // "temperature"
+ classVars = classVars->GetNext(); // "altitude"
+ classVars = classVars->GetNext(); // "lifeTime"
+ classVars = classVars->GetNext(); // "material"
+ classVars = classVars->GetNext(); // "energyCell"
+ classVars = classVars->GetNext(); // "load"
+ classVars = classVars->GetNext(); // "id"
+ int rank = classVars->GetValInt();
+ CObject* center = CObjectManager::GetInstancePointer()->SearchInstance(rank);
+ CAuto* automat = center->GetAuto();
+
+ if ( thisType == OBJECT_BASE )
+ {
+ err = (static_cast<CAutoBase*>(automat))->TakeOff(false);
+ } else
+ err = ERR_WRONG_OBJ;
+
+ if ( err != ERR_OK )
+ {
+ result->SetValInt(err); // return error
+//TODO: if ( script->m_errMode == ERM_STOP )
+ if( true )
+ {
+ exception = err;
+ return false;
+ }
+ return true;
+ }
+
+ return true;
+}
+
// Compilation of the instruction "delete(rank[, exploType[, force]])".
CBotTypResult CScript::cDelete(CBotVar* &var, void* user)
@@ -1330,7 +1394,7 @@ bool CScript::Process(CScript* script, CBotVar* result, int &exception)
if ( err == ERR_STOP ) err = ERR_OK;
result->SetValInt(err); // indicates the error or ok
- if ( err != ERR_OK && script->m_errMode == ERM_STOP )
+ if ( ShouldProcessStop(err, script->m_errMode) )
{
exception = err;
return false;
@@ -1344,6 +1408,21 @@ bool CScript::Process(CScript* script, CBotVar* result, int &exception)
}
+// Returns true if error code means real error and exception must be thrown
+
+bool CScript::ShouldProcessStop(Error err, int errMode)
+{
+ // aim impossible - not a real error
+ if ( err == ERR_AIM_IMPOSSIBLE )
+ return false;
+
+ if ( err != ERR_OK && errMode == ERM_STOP )
+ return true;
+
+ return false;
+}
+
+
// Compilation of the instruction "detect(type)".
CBotTypResult CScript::cDetect(CBotVar* &var, void* user)
@@ -1576,7 +1655,7 @@ CBotTypResult CScript::cCanBuild(CBotVar* &var, void* user)
return CBotTypResult(CBotTypBoolean);
}
-// Instruction "canbuid ( category );"
+// Instruction "canbuild ( category );"
// returns true if this building can be built
bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
@@ -1602,7 +1681,7 @@ bool CScript::rCanBuild(CBotVar* var, CBotVar* result, int& exception, void* use
(category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER)))
{
- //if we want to build not researched one
+ // if we want to build not researched one
if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) ||
(category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC))
)
@@ -1646,7 +1725,7 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
}
else
{
- category = static_cast<ObjectType>(var->GetValInt()); //get category parameter
+ category = static_cast<ObjectType>(var->GetValInt()); // get category parameter
if ( (category == OBJECT_DERRICK && (g_build & BUILD_DERRICK)) ||
(category == OBJECT_FACTORY && (g_build & BUILD_FACTORY)) ||
(category == OBJECT_STATION && (g_build & BUILD_STATION)) ||
@@ -1663,7 +1742,7 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
(category == OBJECT_DESTROYER && (g_build & BUILD_DESTROYER)))
{
- //if we want to build not researched one
+ // if we want to build not researched one
if ( (category == OBJECT_TOWER && !(g_researchDone & RESEARCH_TOWER)) ||
(category == OBJECT_NUCLEAR && !(g_researchDone & RESEARCH_ATOMIC))
)
@@ -1676,8 +1755,11 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
}
}
+
+ if (pThis->GetIgnoreBuildCheck())
+ err = ERR_OK;
- if (err == ERR_OK && script->m_primaryTask == 0) //if we can build and no task is present
+ if (err == ERR_OK && script->m_primaryTask == 0) // if we can build and no task is present
{
script->m_primaryTask = new CTaskManager(script->m_object);
err = script->m_primaryTask->StartTaskBuild(category);
@@ -1688,9 +1770,9 @@ bool CScript::rBuild(CBotVar* var, CBotVar* result, int& exception, void* user)
script->m_primaryTask = 0;
}
}
- //When script is waiting for finishing this task, it sets ERR_OK, and continues executing Process
- //without creating new task. I think, there was a problem with previous version in release configuration
- //It did not init error variable in this situation, and code tried to use variable with trash inside
+ // When script is waiting for finishing this task, it sets ERR_OK, and continues executing Process
+ // without creating new task. I think, there was a problem with previous version in release configuration
+ // It did not init error variable in this situation, and code tried to use variable with trash inside
}
if ( err != ERR_OK )
@@ -1820,52 +1902,10 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
}
}
- if ( type == OBJECT_FRET ||
- type == OBJECT_STONE ||
- type == OBJECT_URANIUM ||
- type == OBJECT_METAL ||
- type == OBJECT_POWER ||
- type == OBJECT_ATOMIC ||
- type == OBJECT_BULLET ||
- type == OBJECT_BBOX ||
- type == OBJECT_KEYa ||
- type == OBJECT_KEYb ||
- type == OBJECT_KEYc ||
- type == OBJECT_KEYd ||
- type == OBJECT_TNT ||
- type == OBJECT_SCRAP1 ||
- type == OBJECT_SCRAP2 ||
- type == OBJECT_SCRAP3 ||
- type == OBJECT_SCRAP4 ||
- type == OBJECT_SCRAP5 ||
- type == OBJECT_BOMB ||
- type == OBJECT_WAYPOINT ||
- type == OBJECT_SHOW ||
- type == OBJECT_WINFIRE ||
- type == OBJECT_BAG ||
- type == OBJECT_MARKPOWER ||
- type == OBJECT_MARKSTONE ||
- type == OBJECT_MARKURANIUM ||
- type == OBJECT_MARKKEYa ||
- type == OBJECT_MARKKEYb ||
- type == OBJECT_MARKKEYc ||
- type == OBJECT_MARKKEYd ||
- type == OBJECT_EGG )
- {
- object = new CObject();
- if ( !object->CreateResource(pos, angle, type) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->SetActivity(false);
- }
- else if ( type == OBJECT_MOTHER ||
- type == OBJECT_ANT ||
- type == OBJECT_SPIDER ||
- type == OBJECT_BEE ||
- type == OBJECT_WORM )
+ if ( type == OBJECT_ANT ||
+ type == OBJECT_SPIDER ||
+ type == OBJECT_BEE ||
+ type == OBJECT_WORM )
{
CObject* egg;
@@ -1883,117 +1923,16 @@ bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user
delete egg;
}
object->SetActivity(false);
- }
- else if ( type == OBJECT_PORTICO ||
- type == OBJECT_BASE ||
- type == OBJECT_DERRICK ||
- type == OBJECT_FACTORY ||
- type == OBJECT_STATION ||
- type == OBJECT_CONVERT ||
- type == OBJECT_REPAIR ||
- type == OBJECT_DESTROYER||
- type == OBJECT_TOWER ||
- type == OBJECT_NEST ||
- type == OBJECT_RESEARCH ||
- type == OBJECT_RADAR ||
- type == OBJECT_INFO ||
- type == OBJECT_ENERGY ||
- type == OBJECT_LABO ||
- type == OBJECT_NUCLEAR ||
- type == OBJECT_PARA ||
- type == OBJECT_SAFE ||
- type == OBJECT_HUSTON ||
- type == OBJECT_TARGET1 ||
- type == OBJECT_TARGET2 ||
- type == OBJECT_START ||
- type == OBJECT_END )
- {
- object = new CObject();
- if ( !object->CreateBuilding(pos, angle, 0, type) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->SetActivity(false);
- script->m_main->CreateShortcuts();
- }
- else if ( type == OBJECT_FLAGb ||
- type == OBJECT_FLAGr ||
- type == OBJECT_FLAGg ||
- type == OBJECT_FLAGy ||
- type == OBJECT_FLAGv )
- {
- object = new CObject();
- if ( !object->CreateFlag(pos, angle, type) )
+ } else {
+ if ((type == OBJECT_POWER || type == OBJECT_ATOMIC) && power == -1.0f) power = 1.0f;
+ object = CObjectManager::GetInstancePointer()->CreateObject(pos, angle, type, power);
+ if ( object == nullptr )
{
- delete object;
result->SetValInt(1); // error
return true;
}
- object->SetActivity(false);
- }
- else if ( type == OBJECT_HUMAN ||
- type == OBJECT_TECH ||
- type == OBJECT_TOTO ||
- type == OBJECT_MOBILEfa ||
- type == OBJECT_MOBILEta ||
- type == OBJECT_MOBILEwa ||
- type == OBJECT_MOBILEia ||
- type == OBJECT_MOBILEfc ||
- type == OBJECT_MOBILEtc ||
- type == OBJECT_MOBILEwc ||
- type == OBJECT_MOBILEic ||
- type == OBJECT_MOBILEfi ||
- type == OBJECT_MOBILEti ||
- type == OBJECT_MOBILEwi ||
- type == OBJECT_MOBILEii ||
- type == OBJECT_MOBILEfs ||
- type == OBJECT_MOBILEts ||
- type == OBJECT_MOBILEws ||
- type == OBJECT_MOBILEis ||
- type == OBJECT_MOBILErt ||
- type == OBJECT_MOBILErc ||
- type == OBJECT_MOBILErr ||
- type == OBJECT_MOBILErs ||
- type == OBJECT_MOBILEsa ||
- type == OBJECT_MOBILEtg ||
- type == OBJECT_MOBILEft ||
- type == OBJECT_MOBILEtt ||
- type == OBJECT_MOBILEwt ||
- type == OBJECT_MOBILEit ||
- type == OBJECT_MOBILEdr ||
- type == OBJECT_APOLLO2 )
- {
- object = new CObject();
- if ( !object->CreateVehicle(pos, angle, type, power, false, false) )
- {
- delete object;
- result->SetValInt(1); // error
- return true;
- }
- object->UpdateMapping();
- object->SetRange(30.0f);
- object->SetZoom(0, 1.0f);
- CPhysics* physics = object->GetPhysics();
- if ( physics != 0 )
- {
- physics->SetFreeze(false); // can move
- }
- object->SetLock(false); // vehicle useable
- // SetManual will affect bot speed
- if (type == OBJECT_MOBILEdr)
- {
- object->SetManual(true);
- }
- object->SetActivity(true);
script->m_main->CreateShortcuts();
}
- else
- {
- result->SetValInt(1); // impossible
- return true;
- }
if (name[0] != 0)
{
@@ -2923,7 +2862,6 @@ bool CScript::rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
CBotTypResult CScript::cFire(CBotVar* &var, void* user)
{
-#if 0
CObject* pThis = static_cast<CObject *>(user);
ObjectType type;
@@ -2931,23 +2869,25 @@ CBotTypResult CScript::cFire(CBotVar* &var, void* user)
if ( type == OBJECT_ANT )
{
- return cOnePoint(var, user);
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ CBotTypResult ret = cPoint(var, user);
+ if ( ret.GetType() != 0 ) return ret;
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
}
else if ( type == OBJECT_SPIDER )
{
- return cNull(var, user);
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
}
else
{
- if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GetNext();
- if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
- return CBotTypResult(CBotTypFloat);
+ if ( var != 0 )
+ {
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
+ if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
+ }
}
-#else
return CBotTypResult(CBotTypFloat);
-#endif
}
// Instruction "fire(delay)".
@@ -2983,6 +2923,7 @@ bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
{
if ( var == 0 ) delay = 0.0f;
else delay = var->GetValFloat();
+ if ( delay < 0.0f ) delay = -delay;
err = script->m_primaryTask->StartTaskFire(delay);
}
@@ -3031,7 +2972,11 @@ bool CScript::rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
var = var->GetNext();
var == 0 ? y=0.0f : y=var->GetValFloat();
err = script->m_primaryTask->StartTaskGunGoal(x*Math::PI/180.0f, y*Math::PI/180.0f);
- if ( err != ERR_OK )
+ if ( err == ERR_AIM_IMPOSSIBLE )
+ {
+ result->SetValInt(err); // shows the error
+ }
+ else if ( err != ERR_OK )
{
delete script->m_primaryTask;
script->m_primaryTask = 0;
@@ -3488,6 +3433,47 @@ bool CScript::rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* use
return true;
}
+// Compilation of the instruction with one object parameter
+
+CBotTypResult CScript::cOneObject(CBotVar* &var, void* user)
+{
+ if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
+ var = var->GetNext();
+ if ( var == 0 ) return CBotTypResult(CBotTypFloat);
+
+ return CBotTypResult(CBotErrOverParam);
+}
+
+// Instruction "camerafocus(object)".
+
+bool CScript::rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user)
+{
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+
+ CBotVar* classVars = var->GetItemList(); // "category"
+ classVars = classVars->GetNext(); // "position"
+ classVars = classVars->GetNext(); // "orientation"
+ classVars = classVars->GetNext(); // "pitch"
+ classVars = classVars->GetNext(); // "roll"
+ classVars = classVars->GetNext(); // "energyLevel"
+ classVars = classVars->GetNext(); // "shieldLevel"
+ classVars = classVars->GetNext(); // "temperature"
+ classVars = classVars->GetNext(); // "altitude"
+ classVars = classVars->GetNext(); // "lifeTime"
+ classVars = classVars->GetNext(); // "material"
+ classVars = classVars->GetNext(); // "energyCell"
+ classVars = classVars->GetNext(); // "load"
+ classVars = classVars->GetNext(); // "id"
+ int rank = classVars->GetValInt();
+ CObject* object = CObjectManager::GetInstancePointer()->SearchInstance(rank);
+
+ script->m_main->SelectObject(object, false);
+
+ result->SetValInt(ERR_OK);
+ exception = ERR_OK;
+ return true;
+}
+
// Object's constructor.
@@ -3504,6 +3490,7 @@ CScript::CScript(CObject* object, CTaskManager** secondaryTask)
m_secondaryTask = secondaryTask;
m_interface = m_main->GetInterface();
+ m_pause = CPauseManager::GetInstancePointer();
m_ipf = CBOT_IPF;
m_errMode = ERM_STOP;
@@ -3587,6 +3574,8 @@ void CScript::InitFonctions()
CBotProgram::AddFunction("penup", rPenUp, CScript::cNull);
CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat);
CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat);
+
+ CBotProgram::AddFunction("camerafocus", rCameraFocus, CScript::cOneObject);
CBotProgram::AddFunction("canbuild", rCanBuild, CScript::cCanBuild);
CBotProgram::AddFunction("build", rBuild, CScript::cOneFloat);
@@ -3898,16 +3887,16 @@ bool CScript::Continue(const Event &event)
if ( m_error != 0 && m_errMode == ERM_STOP )
{
- char s[100];
+ std::string s;
GetError(s);
- m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR);
}
- m_engine->SetPause(true); // gives pause
+ m_pause->SetPause(PAUSE_EDITOR); // gives pause
return true;
}
if ( !m_bContinue )
{
- m_engine->SetPause(true); // gives pause
+ m_pause->SetPause(PAUSE_EDITOR); // gives pause
}
}
@@ -3931,9 +3920,9 @@ bool CScript::Continue(const Event &event)
if ( m_error != 0 && m_errMode == ERM_STOP )
{
- char s[100];
+ std::string s;
GetError(s);
- m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
@@ -3950,9 +3939,9 @@ bool CScript::Step(const Event &event)
if ( !m_bRun ) return true;
if ( !m_bStepMode ) return false;
- m_engine->SetPause(false);
+ // ??? m_engine->SetPause(false);
// TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
- m_engine->SetPause(true);
+ // ??? m_engine->SetPause(true);
m_event = event;
@@ -3973,16 +3962,16 @@ bool CScript::Step(const Event &event)
if ( m_error != 0 && m_errMode == ERM_STOP )
{
- char s[100];
+ std::string s;
GetError(s);
- m_main->GetDisplayText()->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
+ m_main->GetDisplayText()->DisplayText(s.c_str(), m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
if ( m_bContinue ) // instuction "move", "goto", etc. ?
{
- m_engine->SetPause(false); // removes the pause
+ m_pause->ClearPause(); // removes the pause
}
return false;
}
@@ -4347,27 +4336,27 @@ int CScript::GetError()
// Returns the text of the error.
-void CScript::GetError(char* buffer)
+void CScript::GetError(std::string& error)
{
if ( m_error == 0 )
{
- buffer[0] = 0;
+ error.clear();
}
else
{
if ( m_error == ERR_OBLIGATORYTOKEN )
{
- char s[100];
+ std::string s;
GetResource(RES_ERR, m_error, s);
- sprintf(buffer, s, m_token);
+ error = StrUtils::Format(s.c_str(), m_token);
}
else if ( m_error < 1000 )
{
- GetResource(RES_ERR, m_error, buffer);
+ GetResource(RES_ERR, m_error, error);
}
else
{
- GetResource(RES_CBOT, m_error, buffer);
+ GetResource(RES_CBOT, m_error, error);
}
}
}
@@ -4385,7 +4374,9 @@ void CScript::New(Ui::CEdit* edit, const char* name)
char *sf;
int cursor1, cursor2, len, i, j;
- GetResource(RES_TEXT, RT_SCRIPT_NEW, res);
+ std::string resStr;
+ GetResource(RES_TEXT, RT_SCRIPT_NEW, resStr);
+ strcpy(res, resStr.c_str());
if ( name[0] == 0 ) strcpy(text, res);
else strcpy(text, name);
@@ -4418,7 +4409,7 @@ void CScript::New(Ui::CEdit* edit, const char* name)
sf = m_main->GetScriptFile();
if ( sf[0] != 0 ) // Load an empty program specific?
{
- std::string filename = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, sf);
+ std::string filename = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, sf);
file = fopen(filename.c_str(), "rb");
if ( file != NULL )
{
@@ -4512,7 +4503,7 @@ bool CScript::ReadScript(const char* filename)
if ( strchr(filename, '/') == 0 ) //we're reading non user script
{
- name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
+ name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
}
else
{
@@ -4546,7 +4537,7 @@ bool CScript::WriteScript(const char* filename)
if ( strchr(filename, '/') == 0 ) //we're writing non user script
{
- name = CApplication::GetInstancePointer()->GetDataFilePath(DIR_AI, filename);
+ name = CGameData::GetInstancePointer()->GetFilePath(DIR_AI, filename);
}
else
{
diff --git a/src/script/script.h b/src/script/script.h
index 7fd5555..fb44342 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -24,6 +24,10 @@
#include "common/event.h"
+#include "common/global.h"
+
+#include "app/pausemanager.h"
+
#include "CBot/CBotDll.h"
#include <stdio.h>
@@ -74,7 +78,7 @@ public:
bool IntroduceVirus();
int GetError();
- void GetError(char* buffer);
+ void GetError(std::string& error);
void New(Ui::CEdit* edit, const char* name);
bool SendScript(const char* text);
@@ -126,6 +130,7 @@ private:
static CBotTypResult cPenDown(CBotVar* &var, void* user);
static CBotTypResult cOnePoint(CBotVar* &var, void* user);
static CBotTypResult cPoint(CBotVar* &var, void* user);
+ static CBotTypResult cOneObject(CBotVar* &var, void* user);
static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
@@ -190,6 +195,7 @@ private:
static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rCameraFocus(CBotVar* var, CBotVar* result, int& exception, void* user);
public:
static CBotTypResult cBusy(CBotVar* thisclass, CBotVar* &var);
@@ -200,10 +206,12 @@ public:
static bool rBusy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
+ static bool rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
static bool rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* result, int& exception);
private:
static bool Process(CScript* script, CBotVar* result, int &exception);
+ static bool ShouldProcessStop(Error err, int errMode);
static CObject* SearchInfo(CScript* script, CObject* object, float power);
protected:
@@ -216,6 +224,7 @@ protected:
CTaskManager* m_primaryTask;
CTaskManager** m_secondaryTask;
CObject* m_object;
+ CPauseManager* m_pause;
int m_ipf; // number of instructions/second
int m_errMode; // what to do in case of error
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 992b8b2..8afbdd2 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -18,6 +18,8 @@
#include "sound/oalsound/alsound.h"
+#include "app/gamedata.h"
+
#include <algorithm>
#include <iomanip>
@@ -26,12 +28,14 @@
ALSound::ALSound()
{
m_enabled = false;
- m_3D = false;
m_audioVolume = 1.0f;
m_musicVolume = 1.0f;
m_currentMusic = nullptr;
m_eye.LoadZero();
m_lookat.LoadZero();
+ m_previousMusic.fadeTime = 0.0f;
+ m_previousMusic.music = nullptr;
+ m_channels_limit = 2048;
}
@@ -58,6 +62,16 @@ void ALSound::CleanUp()
{
delete m_currentMusic;
}
+
+ for (auto item : m_oldMusic)
+ {
+ delete item.music;
+ }
+
+ if (m_previousMusic.music)
+ {
+ delete m_previousMusic.music;
+ }
for (auto item : m_sounds)
{
@@ -77,7 +91,7 @@ void ALSound::CleanUp()
}
-bool ALSound::Create(bool b3D)
+bool ALSound::Create()
{
CleanUp();
@@ -102,32 +116,12 @@ bool ALSound::Create(bool b3D)
alListenerf(AL_GAIN, m_audioVolume);
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
- m_currentMusic = new Channel();
GetLogger()->Info("Done.\n");
m_enabled = true;
return true;
}
-void ALSound::SetSound3D(bool bMode)
-{
- m_3D = bMode;
-}
-
-
-bool ALSound::GetSound3D()
-{
- return m_3D;
-}
-
-
-bool ALSound::GetSound3DCap()
-{
- // TODO stub! need to be implemented
- return true;
-}
-
-
bool ALSound::GetEnable()
{
return m_enabled;
@@ -168,10 +162,10 @@ int ALSound::GetMusicVolume()
}
-bool ALSound::Cache(Sound sound, std::string filename)
+bool ALSound::Cache(Sound sound, const std::string &filename)
{
Buffer *buffer = new Buffer();
- if (buffer->LoadFromFile(filename, sound))
+ if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_SOUND, filename), sound))
{
m_sounds[sound] = buffer;
return true;
@@ -179,14 +173,12 @@ bool ALSound::Cache(Sound sound, std::string filename)
return false;
}
-bool ALSound::CacheMusic(std::string filename)
+bool ALSound::CacheMusic(const std::string &filename)
{
if (m_music.find(filename) == m_music.end())
{
Buffer *buffer = new Buffer();
- std::stringstream file;
- file << m_soundPath << "/" << filename;
- if (buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
+ if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename), static_cast<Sound>(-1)))
{
m_music[filename] = buffer;
return true;
@@ -252,11 +244,16 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
for (auto it : m_channels)
{
if (it.second->IsPlaying())
+ {
continue;
+ }
if (it.second->GetSoundType() != sound)
+ {
continue;
+ }
it.second->SetPriority(priority);
+ it.second->Reset();
channel = it.first;
bAlreadyLoaded = it.second->IsLoaded();
return true;
@@ -270,6 +267,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
if (chn->IsReady())
{
chn->SetPriority(priority);
+ chn->Reset();
m_channels[1] = chn;
channel = 1;
bAlreadyLoaded = false;
@@ -280,8 +278,8 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
return false;
}
- // Seeks a channel completely free.
- if (m_channels.size() < 64)
+ // Assigns new channel within limit
+ if (m_channels.size() < m_channels_limit)
{
auto it = m_channels.end();
it--;
@@ -295,13 +293,14 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
if (chn->IsReady())
{
chn->SetPriority(priority);
+ chn->Reset();
m_channels[++i] = chn;
channel = i;
bAlreadyLoaded = false;
return true;
}
delete chn;
- GetLogger()->Warn("Could not open additional channel to play sound!\n");
+ GetLogger()->Debug("Could not open additional channel to play sound!\n");
}
}
}
@@ -313,6 +312,7 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
{
GetLogger()->Debug("Sound channel with lower priority will be reused.\n");
channel = it.first;
+ it.second->Reset();
return true;
}
if (it.second->GetPriority() <= priority)
@@ -322,11 +322,12 @@ bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded)
if (lowerOrEqual != -1)
{
channel = lowerOrEqual;
+ m_channels[channel]->Reset();
GetLogger()->Debug("Sound channel with lower or equal priority will be reused.\n");
return true;
}
- GetLogger()->Warn("Could not find free buffer to use.\n");
+ GetLogger()->Debug("Could not find free buffer to use.\n");
return false;
}
@@ -337,7 +338,7 @@ int ALSound::Play(Sound sound, float amplitude, float frequency, bool bLoop)
}
-int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequency, bool bLoop)
+int ALSound::Play(Sound sound, const Math::Vector &pos, float amplitude, float frequency, bool bLoop)
{
if (!m_enabled)
{
@@ -345,14 +346,16 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
}
if (m_sounds.find(sound) == m_sounds.end())
{
- GetLogger()->Warn("Sound %d was not loaded!\n", sound);
+ GetLogger()->Debug("Sound %d was not loaded!\n", sound);
return -1;
}
int channel;
bool bAlreadyLoaded = false;
if (!SearchFreeBuffer(sound, channel, bAlreadyLoaded))
+ {
return -1;
+ }
if (!bAlreadyLoaded)
{
@@ -363,15 +366,8 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
}
}
- Position(channel, pos);
- if (!m_3D)
- {
- ComputeVolumePan2D(channel, pos);
- }
- else
- {
- m_channels[channel]->SetVolumeAtrib(1.0f);
- }
+ m_channels[channel]->SetPosition(pos);
+ m_channels[channel]->SetVolumeAtrib(1.0f);
// setting initial values
m_channels[channel]->SetStartAmplitude(amplitude);
@@ -381,15 +377,26 @@ int ALSound::Play(Sound sound, Math::Vector pos, float amplitude, float frequenc
m_channels[channel]->SetFrequency(frequency);
m_channels[channel]->SetVolume(powf(amplitude * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume);
m_channels[channel]->SetLoop(bLoop);
- m_channels[channel]->Play();
- return channel;
+ if (!m_channels[channel]->Play())
+ {
+ m_channels_limit = m_channels.size() - 1;
+ GetLogger()->Debug("Changing channel limit to %u.\n", m_channels_limit);
+ auto it = m_channels.find(channel);
+ Channel *ch = it->second;
+ m_channels.erase(it);
+ delete ch;
+
+ return -1;
+ }
+
+ return channel | ((m_channels[channel]->GetId() & 0xffff) << 16);
}
bool ALSound::FlushEnvelope(int channel)
{
- if (m_channels.find(channel) == m_channels.end())
+ if (!CheckChannel(channel))
{
return false;
}
@@ -401,10 +408,7 @@ bool ALSound::FlushEnvelope(int channel)
bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
{
- if (!m_enabled)
- return false;
-
- if (m_channels.find(channel) == m_channels.end())
+ if (!CheckChannel(channel))
{
return false;
}
@@ -421,40 +425,21 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t
}
-bool ALSound::Position(int channel, Math::Vector pos)
+bool ALSound::Position(int channel, const Math::Vector &pos)
{
- if (!m_enabled)
- return false;
-
- if (m_channels.find(channel) == m_channels.end())
+ if (!CheckChannel(channel))
{
return false;
}
- if (m_3D)
- {
- m_channels[channel]->SetPan(pos);
- }
- else
- {
- ComputeVolumePan2D(channel, pos);
-
- if (!m_channels[channel]->HasEnvelope())
- {
- float volume = m_channels[channel]->GetStartAmplitude();
- m_channels[channel]->SetVolume(powf(volume * m_channels[channel]->GetVolumeAtrib(), 0.2f) * m_audioVolume);
- }
- }
+ m_channels[channel]->SetPosition(pos);
return true;
}
bool ALSound::Frequency(int channel, float frequency)
{
- if (!m_enabled)
- return false;
-
- if (m_channels.find(channel) == m_channels.end())
+ if (!CheckChannel(channel))
{
return false;
}
@@ -466,10 +451,7 @@ bool ALSound::Frequency(int channel, float frequency)
bool ALSound::Stop(int channel)
{
- if (!m_enabled)
- return false;
-
- if (m_channels.find(channel) == m_channels.end())
+ if (!CheckChannel(channel))
{
return false;
}
@@ -484,7 +466,9 @@ bool ALSound::Stop(int channel)
bool ALSound::StopAll()
{
if (!m_enabled)
+ {
return false;
+ }
for (auto channel : m_channels)
{
@@ -499,7 +483,9 @@ bool ALSound::StopAll()
bool ALSound::MuteAll(bool bMute)
{
if (!m_enabled)
+ {
return false;
+ }
for (auto it : m_channels)
{
@@ -509,14 +495,6 @@ bool ALSound::MuteAll(bool bMute)
}
}
- if (bMute)
- {
- m_currentMusic->SetVolume(0.0f);
- }
- else
- {
- m_currentMusic->SetVolume(m_musicVolume);
- }
return true;
}
@@ -524,7 +502,9 @@ bool ALSound::MuteAll(bool bMute)
void ALSound::FrameMove(float delta)
{
if (!m_enabled)
+ {
return;
+ }
float progress;
float volume, frequency;
@@ -534,7 +514,6 @@ void ALSound::FrameMove(float delta)
{
continue;
}
-
if (it.second->IsMuted())
{
it.second->SetVolume(0.0f);
@@ -582,79 +561,117 @@ void ALSound::FrameMove(float delta)
}
}
}
+
+ std::list<OldMusic> toRemove;
+
+ for (auto& it : m_oldMusic)
+ {
+ if (it.currentTime >= it.fadeTime)
+ {
+ delete it.music;
+ toRemove.push_back(it);
+ }
+ else
+ {
+ it.currentTime += delta;
+ it.music->SetVolume(((it.fadeTime-it.currentTime) / it.fadeTime) * m_musicVolume);
+ }
+ }
+
+ if (m_previousMusic.fadeTime > 0.0f) {
+ if (m_previousMusic.currentTime >= m_previousMusic.fadeTime)
+ {
+ m_previousMusic.music->Pause();
+ }
+ else
+ {
+ m_previousMusic.currentTime += delta;
+ m_previousMusic.music->SetVolume(((m_previousMusic.fadeTime-m_previousMusic.currentTime) / m_previousMusic.fadeTime) * m_musicVolume);
+ }
+ }
+
+ for (auto it : toRemove)
+ m_oldMusic.remove(it);
}
-void ALSound::SetListener(Math::Vector eye, Math::Vector lookat)
+void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
{
m_eye = eye;
m_lookat = lookat;
- if (m_3D)
- {
- float orientation[] = {lookat.x, lookat.y, lookat.z, 0.f, 1.f, 0.f};
- alListener3f(AL_POSITION, eye.x, eye.y, eye.z);
- alListenerfv(AL_ORIENTATION, orientation);
- }
- else
- {
- float orientation[] = {0.0f, 0.0f, 0.0f, 0.f, 1.f, 0.f};
- alListener3f(AL_POSITION, 0.0f, 0.0f, 0.0f);
- alListenerfv(AL_ORIENTATION, orientation);
+ Math::Vector forward = lookat - eye;
+ forward.Normalize();
+ float orientation[] = {forward.x, forward.y, forward.z, 0.f, -1.0f, 0.0f};
- // recalculate sound position
- for (auto it : m_channels)
- {
- if (it.second->IsPlaying())
- {
- Math::Vector pos = it.second->GetPosition();
- ComputeVolumePan2D(it.first, pos);
-
- if (!it.second->HasEnvelope())
- {
- float volume = it.second->GetStartAmplitude();
- it.second->SetVolume(powf(volume * it.second->GetVolumeAtrib(), 0.2f) * m_audioVolume);
- }
- }
- }
- }
+ alListener3f(AL_POSITION, eye.x, eye.y, eye.z);
+ alListenerfv(AL_ORIENTATION, orientation);
}
-bool ALSound::PlayMusic(int rank, bool bRepeat)
+
+bool ALSound::PlayMusic(int rank, bool bRepeat, float fadeTime)
{
std::stringstream filename;
filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg";
- return PlayMusic(filename.str(), bRepeat);
+ return PlayMusic(filename.str(), bRepeat, fadeTime);
+}
+
+
+bool operator<(const OldMusic & l, const OldMusic & r)
+{
+ return l.currentTime < r.currentTime;
+}
+
+
+bool operator==(const OldMusic & l, const OldMusic & r)
+{
+ return l.currentTime == r.currentTime;
}
-bool ALSound::PlayMusic(std::string filename, bool bRepeat)
+
+bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTime)
{
if (!m_enabled)
{
return false;
}
- std::stringstream file;
- file << m_soundPath << "/" << filename;
+ std::string file = CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename);
+ Buffer *buffer;
// check if we have music in cache
if (m_music.find(filename) == m_music.end())
{
- GetLogger()->Warn("Music %s was not cached!\n", filename.c_str());
- if (!boost::filesystem::exists(file.str()))
+ GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
+ if (!boost::filesystem::exists(file))
{
- GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str());
+ GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
return false;
}
- Buffer *buffer = new Buffer();
- buffer->LoadFromFile(file.str(), static_cast<Sound>(-1));
- m_currentMusic->SetBuffer(buffer);
+
+ buffer = new Buffer();
+ if (!buffer->LoadFromFile(file, static_cast<Sound>(-1)))
+ {
+ return false;
+ }
+ m_music[filename] = buffer;
}
else
{
GetLogger()->Debug("Music loaded from cache\n");
- m_currentMusic->SetBuffer(m_music[filename]);
+ buffer = m_music[filename];
+ }
+
+ if (m_currentMusic)
+ {
+ OldMusic old;
+ old.music = m_currentMusic;
+ old.fadeTime = fadeTime;
+ old.currentTime = 0.0f;
+ m_oldMusic.push_back(old);
}
+ m_currentMusic = new Channel();
+ m_currentMusic->SetBuffer(buffer);
m_currentMusic->SetVolume(m_musicVolume);
m_currentMusic->SetLoop(bRepeat);
m_currentMusic->Play();
@@ -663,6 +680,55 @@ bool ALSound::PlayMusic(std::string filename, bool bRepeat)
}
+bool ALSound::PlayPauseMusic(const std::string &filename, bool repeat)
+{
+ if (m_previousMusic.fadeTime > 0.0f)
+ {
+ if(m_currentMusic)
+ {
+ OldMusic old;
+ old.music = m_currentMusic;
+ old.fadeTime = 2.0f;
+ old.currentTime = 0.0f;
+ m_oldMusic.push_back(old);
+ m_currentMusic = nullptr;
+ }
+ }
+ else
+ {
+ if (m_currentMusic)
+ {
+ m_previousMusic.music = m_currentMusic;
+ m_previousMusic.fadeTime = 2.0f;
+ m_previousMusic.currentTime = 0.0f;
+ m_currentMusic = nullptr;
+ }
+ }
+ return PlayMusic(filename, repeat);
+}
+
+
+void ALSound::StopPauseMusic()
+{
+ if (m_previousMusic.fadeTime > 0.0f)
+ {
+ StopMusic();
+
+ m_currentMusic = m_previousMusic.music;
+ m_previousMusic.music = nullptr;
+ if(m_currentMusic != nullptr)
+ {
+ m_currentMusic->SetVolume(m_musicVolume);
+ if(m_previousMusic.currentTime >= m_previousMusic.fadeTime)
+ {
+ m_currentMusic->Play();
+ }
+ }
+ m_previousMusic.fadeTime = 0.0f;
+ }
+}
+
+
bool ALSound::RestartMusic()
{
if (!m_enabled || !m_currentMusic)
@@ -675,14 +741,21 @@ bool ALSound::RestartMusic()
return true;
}
-void ALSound::StopMusic()
+
+void ALSound::StopMusic(float fadeTime)
{
if (!m_enabled || !m_currentMusic)
{
return;
}
- SuspendMusic();
+ OldMusic old;
+ old.music = m_currentMusic;
+ old.fadeTime = fadeTime;
+ old.currentTime = 0.0f;
+ m_oldMusic.push_back(old);
+
+ m_currentMusic = nullptr;
}
@@ -708,64 +781,30 @@ void ALSound::SuspendMusic()
}
-void ALSound::ComputeVolumePan2D(int channel, Math::Vector &pos)
+bool ALSound::CheckChannel(int &channel)
{
- float dist, a, g;
- m_channels[channel]->SetPosition(pos);
+ int id = (channel >> 16) & 0xffff;
+ channel &= 0xffff;
- if (VectorsEqual(pos, m_eye))
+ if (!m_enabled)
{
- m_channels[channel]->SetVolumeAtrib(1.0f); // maximum volume
- m_channels[channel]->SetPan(Math::Vector()); // at the center
- return;
+ return false;
}
- dist = Distance(pos, m_eye);
- if ( dist >= 110.0f ) // very far?
- {
- m_channels[channel]->SetVolumeAtrib(0.0f); // silence
- m_channels[channel]->SetPan(Math::Vector()); // at the center
- return;
- }
- else if ( dist <= 10.0f ) // very close?
+ if (m_channels.find(channel) == m_channels.end())
{
- m_channels[channel]->SetVolumeAtrib(1.0f); // maximum volume
- m_channels[channel]->SetPan(Math::Vector()); // at the center
- return;
+ return false;
}
- m_channels[channel]->SetVolumeAtrib(1.0f - ((dist - 10.0f) / 100.0f));
- Math::Vector one = Math::Vector(1.0f, 0.0f, 0.0f);
- float angle_a = Angle(Math::Vector(m_lookat.x - m_eye.x, m_lookat.z - m_eye.z, 0.0f), one);
- float angle_g = Angle(Math::Vector(pos.x - m_eye.x, pos.z - m_eye.z, 0.0f), one);
-
- a = fmodf(angle_a, Math::PI * 2.0f);
- g = fmodf(angle_g, Math::PI * 2.0f);
-
- if ( a < 0.0f )
+ if (m_audioVolume == 0)
{
- a += Math::PI * 2.0f;
- }
- if ( g < 0.0f )
- {
- g += Math::PI * 2.0f;
+ return false;
}
- if ( a < g )
+ if (m_channels[channel]->GetId() != id)
{
- if (a + Math::PI * 2.0f - g < g - a )
- {
- a += Math::PI * 2.0f;
- }
- }
- else
- {
- if ( g + Math::PI * 2.0f - a < a - g )
- {
- g += Math::PI * 2.0f;
- }
+ return false;
}
- m_channels[channel]->SetPan( Math::Vector(0.0f, 0.0f, sinf(g - a)) );
+ return true;
}
-
diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index cd44ae9..bb9bf28 100644
--- a/src/sound/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -31,73 +31,75 @@
#include <map>
#include <string>
+#include <list>
#include <al.h>
+struct OldMusic {
+ Channel* music;
+ float fadeTime;
+ float currentTime;
+};
+
class ALSound : public CSoundInterface
{
public:
ALSound();
~ALSound();
- bool Create(bool b3D);
- bool Cache(Sound, std::string);
- bool CacheMusic(std::string);
+ bool Create();
+ bool Cache(Sound, const std::string &);
+ bool CacheMusic(const std::string &);
bool GetEnable();
- void SetSound3D(bool bMode);
- bool GetSound3D();
- bool GetSound3DCap();
-
void SetAudioVolume(int volume);
int GetAudioVolume();
void SetMusicVolume(int volume);
int GetMusicVolume();
- void SetListener(Math::Vector eye, Math::Vector lookat);
+ void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
void FrameMove(float rTime);
int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
- int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
+ int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
bool FlushEnvelope(int channel);
bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper);
- bool Position(int channel, Math::Vector pos);
+ bool Position(int channel, const Math::Vector &pos);
bool Frequency(int channel, float frequency);
bool Stop(int channel);
bool StopAll();
bool MuteAll(bool bMute);
- bool PlayMusic(int rank, bool bRepeat);
- bool PlayMusic(std::string filename, bool bRepeat);
+ bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f);
+ bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f);
bool RestartMusic();
void SuspendMusic();
- void StopMusic();
+ void StopMusic(float fadeTime=2.0f);
bool IsPlayingMusic();
+ bool PlayPauseMusic(const std::string &filename, bool repeat);
+ void StopPauseMusic();
- // plugin interface
- std::string PluginName();
- int PluginVersion();
- void InstallPlugin();
- bool UninstallPlugin(std::string &);
+ bool CheckChannel(int &channel);
private:
void CleanUp();
int GetPriority(Sound);
bool SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded);
- void ComputeVolumePan2D(int channel, Math::Vector &pos);
bool m_enabled;
- bool m_3D;
float m_audioVolume;
float m_musicVolume;
+ unsigned int m_channels_limit;
ALCdevice* m_device;
ALCcontext* m_context;
std::map<Sound, Buffer*> m_sounds;
std::map<std::string, Buffer*> m_music;
std::map<int, Channel*> m_channels;
Channel *m_currentMusic;
+ std::list<OldMusic> m_oldMusic;
+ OldMusic m_previousMusic;
Math::Vector m_eye;
Math::Vector m_lookat;
};
diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp
index 0047f91..b27029c 100644
--- a/src/sound/oalsound/buffer.cpp
+++ b/src/sound/oalsound/buffer.cpp
@@ -32,7 +32,7 @@ Buffer::~Buffer()
{
alDeleteBuffers(1, &m_buffer);
if (alCheck())
- GetLogger()->Warn("Failed to unload buffer. Code %d\n", alGetCode());
+ GetLogger()->Debug("Failed to unload buffer. Code %d\n", alGetCode());
}
}
diff --git a/src/sound/oalsound/channel.cpp b/src/sound/oalsound/channel.cpp
index 4d89df5..7021c2f 100644
--- a/src/sound/oalsound/channel.cpp
+++ b/src/sound/oalsound/channel.cpp
@@ -23,7 +23,7 @@ Channel::Channel()
if (alCheck())
{
- GetLogger()->Warn("Failed to create sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Failed to create sound source. Code: %d\n", alGetCode());
m_ready = false;
}
else
@@ -40,6 +40,7 @@ Channel::Channel()
m_startFrequency = 0.0f;
m_changeFrequency = 0.0f;
m_volume = 0.0f;
+ m_id = 0;
}
@@ -51,7 +52,7 @@ Channel::~Channel()
alSourcei(m_source, AL_BUFFER, 0);
alDeleteSources(1, &m_source);
if (alCheck())
- GetLogger()->Warn("Failed to delete sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Failed to delete sound source. Code: %d\n", alGetCode());
}
}
@@ -69,38 +70,41 @@ bool Channel::Play()
alSourcePlay(m_source);
if (alCheck())
{
- GetLogger()->Warn("Could not play audio sound source. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not play audio sound source. Code: %d\n", alGetCode());
}
return true;
}
-
-bool Channel::SetPan(Math::Vector pos)
+bool Channel::Pause()
{
- if (!m_ready || m_buffer == nullptr)
+ if(!m_ready || !IsPlaying())
{
return false;
}
-
- alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z);
+
+ alSourcePause(m_source);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound position. Code: %d\n", alGetCode());
- return false;
+ GetLogger()->Debug("Could not pause audio sound source. Code: %d\n", alGetCode());
}
return true;
}
-void Channel::SetPosition(Math::Vector pos)
+bool Channel::SetPosition(const Math::Vector &pos)
{
- m_position = pos;
-}
-
+ if (!m_ready || m_buffer == nullptr)
+ {
+ return false;
+ }
-Math::Vector Channel::GetPosition()
-{
- return m_position;
+ alSource3f(m_source, AL_POSITION, pos.x, pos.y, pos.z);
+ if (alCheck())
+ {
+ GetLogger()->Debug("Could not set sound position. Code: %d\n", alGetCode());
+ return false;
+ }
+ return true;
}
@@ -114,7 +118,7 @@ bool Channel::SetFrequency(float freq)
alSourcef(m_source, AL_PITCH, freq);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode());
+ GetLogger()->Debug("Could not set sound pitch to '%f'. Code: %d\n", freq, alGetCode());
return false;
}
return true;
@@ -132,7 +136,7 @@ float Channel::GetFrequency()
alGetSourcef(m_source, AL_PITCH, &freq);
if (alCheck())
{
- GetLogger()->Warn("Could not get sound pitch. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not get sound pitch. Code: %d\n", alGetCode());
return 0;
}
@@ -150,7 +154,7 @@ bool Channel::SetVolume(float vol)
alSourcef(m_source, AL_GAIN, vol);
if (alCheck())
{
- GetLogger()->Warn("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
+ GetLogger()->Debug("Could not set sound volume to '%f'. Code: %d\n", vol, alGetCode());
return false;
}
return true;
@@ -168,7 +172,7 @@ float Channel::GetVolume()
alGetSourcef(m_source, AL_GAIN, &vol);
if (alCheck())
{
- GetLogger()->Warn("Could not get sound volume. Code: %d\n", alGetCode());
+ GetLogger()->Debug("Could not get sound volume. Code: %d\n", alGetCode());
return 0;
}
@@ -431,3 +435,15 @@ bool Channel::IsMuted()
return m_mute;
}
+
+void Channel::Reset()
+{
+ m_id++;
+}
+
+
+int Channel::GetId()
+{
+ return m_id;
+}
+
diff --git a/src/sound/oalsound/channel.h b/src/sound/oalsound/channel.h
index 2930f26..1d988c9 100644
--- a/src/sound/oalsound/channel.h
+++ b/src/sound/oalsound/channel.h
@@ -50,11 +50,10 @@ public:
~Channel();
bool Play();
+ bool Pause();
bool Stop();
- bool SetPan(Math::Vector);
- void SetPosition(Math::Vector);
- Math::Vector GetPosition();
+ bool SetPosition(const Math::Vector &);
bool SetFrequency(float);
float GetFrequency();
@@ -98,11 +97,15 @@ public:
void Mute(bool);
bool IsMuted();
+ void Reset();
+ int GetId();
+
private:
Buffer *m_buffer;
ALuint m_source;
int m_priority;
+ int m_id;
float m_startAmplitude;
float m_startFrequency;
float m_changeFrequency;
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index d392612..9cae1fd 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -36,37 +36,36 @@ CSoundInterface::~CSoundInterface()
{
}
-bool CSoundInterface::Create(bool b3D)
+bool CSoundInterface::Create()
{
return true;
}
-void CSoundInterface::CacheAll(std::string path)
+void CSoundInterface::CacheAll()
{
for ( int i = 1; i < SOUND_MAX; i++ )
{
std::stringstream filename;
- filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
+ filename << "sound" << std::setfill('0') << std::setw(3) << i << ".wav";
if ( !Cache(static_cast<Sound>(i), filename.str()) )
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
}
}
-void CSoundInterface::AddMusicFiles(std::string path)
+void CSoundInterface::AddMusicFiles()
{
- m_soundPath = path;
CacheMusic("Intro1.ogg");
CacheMusic("Intro2.ogg");
CacheMusic("music010.ogg");
CacheMusic("music011.ogg");
}
-bool CSoundInterface::Cache(Sound bSound, std::string bFile)
+bool CSoundInterface::Cache(Sound bSound, const std::string &bFile)
{
return true;
}
-bool CSoundInterface::CacheMusic(std::string bFile)
+bool CSoundInterface::CacheMusic(const std::string &bFile)
{
return true;
}
@@ -76,20 +75,6 @@ bool CSoundInterface::GetEnable()
return true;
}
-void CSoundInterface::SetSound3D(bool bMode)
-{
-}
-
-bool CSoundInterface::GetSound3D()
-{
- return true;
-}
-
-bool CSoundInterface::GetSound3DCap()
-{
- return true;
-}
-
void CSoundInterface::SetAudioVolume(int volume)
{
}
@@ -108,7 +93,7 @@ int CSoundInterface::GetMusicVolume()
return 0;
}
-void CSoundInterface::SetListener(Math::Vector eye, Math::Vector lookat)
+void CSoundInterface::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
{
}
@@ -121,7 +106,7 @@ int CSoundInterface::Play(Sound sound, float amplitude, float frequency, bool bL
return 0;
}
-int CSoundInterface::Play(Sound sound, Math::Vector pos, float amplitude, float frequency, bool bLoop)
+int CSoundInterface::Play(Sound sound, const Math::Vector &pos, float amplitude, float frequency, bool bLoop)
{
return 0;
}
@@ -136,7 +121,7 @@ bool CSoundInterface::AddEnvelope(int channel, float amplitude, float frequency,
return true;
}
-bool CSoundInterface::Position(int channel, Math::Vector pos)
+bool CSoundInterface::Position(int channel, const Math::Vector &pos)
{
return true;
}
@@ -161,12 +146,12 @@ bool CSoundInterface::MuteAll(bool bMute)
return true;
}
-bool CSoundInterface::PlayMusic(int rank, bool bRepeat)
+bool CSoundInterface::PlayMusic(int rank, bool bRepeat, float fadeTime)
{
return true;
}
-bool CSoundInterface::PlayMusic(std::string filename, bool bRepeat)
+bool CSoundInterface::PlayMusic(const std::string &filename, bool bRepeat, float fadeTime)
{
return true;
}
@@ -180,7 +165,7 @@ void CSoundInterface::SuspendMusic()
{
}
-void CSoundInterface::StopMusic()
+void CSoundInterface::StopMusic(float fadeTime)
{
}
@@ -189,3 +174,11 @@ bool CSoundInterface::IsPlayingMusic()
return true;
}
+bool CSoundInterface::PlayPauseMusic(const std::string &filename, bool repeat)
+{
+ return true;
+}
+
+void CSoundInterface::StopPauseMusic()
+{
+}
diff --git a/src/sound/sound.h b/src/sound/sound.h
index 9ccc1b6..22a5ee2 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -153,17 +153,16 @@ public:
virtual ~CSoundInterface();
/** Function to initialize sound device
- * \param b3D - enable support for 3D sound
*/
- virtual bool Create(bool b3D);
+ virtual bool Create();
/** Function called to cache all sound effect files.
* Function calls \link CSoundInterface::Cache() \endlink for each file
*/
- void CacheAll(std::string path);
+ void CacheAll();
/** Function called to add all music files to list */
- void AddMusicFiles(std::string path);
+ void AddMusicFiles();
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
@@ -171,35 +170,20 @@ public:
* \param bFile - file to load
* \return return true on success
*/
- virtual bool Cache(Sound bSound, std::string bFile);
+ virtual bool Cache(Sound bSound, const std::string &bFile);
/** Function called to cache music file.
* This function is called by CRobotMain for each file used in the mission.
* \param bFile - file to load
* \return return true on success
*/
- virtual bool CacheMusic(std::string bFile);
+ virtual bool CacheMusic(const std::string &bFile);
/** Return if plugin is enabled
* \return return true if plugin is enabled
*/
virtual bool GetEnable();
- /** Change sound mode to 2D/3D
- * \param bMode - true to enable 3D sound
- */
- virtual void SetSound3D(bool bMode);
-
- /** Return if we use 3D sound
- * \return true if we have 3D sound enabled
- */
- virtual bool GetSound3D();
-
- /** Return if we have 3D sound capable card
- * \return true for 3D sound support
- */
- virtual bool GetSound3DCap();
-
/** Change global sound volume
* \param volume - range from 0 to MAXVOLUME
*/
@@ -224,7 +208,7 @@ public:
* \param eye - position of listener
* \param lookat - direction listener is looking at
*/
- virtual void SetListener(Math::Vector eye, Math::Vector lookat);
+ virtual void SetListener(const Math::Vector &eye, const Math::Vector &lookat);
/** Update data each frame
* \param rTime - time since last update
@@ -248,7 +232,7 @@ public:
* \param bLoop - loop sound
* \return identifier of channel that sound will be played on
*/
- virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
+ virtual int Play(Sound sound, const Math::Vector &pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false);
/** Remove all operations that would be made on sound in channel.
* \param channel - channel to work on
@@ -271,7 +255,7 @@ public:
* \param pos - new positino of a sound
* \return return true on success
*/
- virtual bool Position(int channel, Math::Vector pos);
+ virtual bool Position(int channel, const Math::Vector &pos);
/** Set sound frequency
* \param channel - channel to work on
@@ -300,38 +284,48 @@ public:
/** Start playing music
* \param rank - track number
* \param bRepeat - repeat playing
+ * \param fadeTime - time of transition between music
* \return return true on success
*/
- virtual bool PlayMusic(int rank, bool bRepeat);
+ virtual bool PlayMusic(int rank, bool bRepeat, float fadeTime=2.0f);
/** Start playing music
* \param filename - name of file to play
* \param bRepeat - repeat playing
+ * \param fadeTime - time of transition between music
* \return return true on success
*/
- virtual bool PlayMusic(std::string filename, bool bRepeat);
+ virtual bool PlayMusic(const std::string &filename, bool bRepeat, float fadeTime=2.0f);
/** Restart music
- * @return return true on success
+ * \return return true on success
*/
virtual bool RestartMusic();
- /** Susspend paying music
- * \return return true on success
+ /** Susspend playing music
+ * \return nothing
*/
virtual void SuspendMusic();
/** Stop playing music
- * \return return true on success
+ * \return nothing
*/
- virtual void StopMusic();
+ virtual void StopMusic(float fadeTime=2.0f);
/** Check if music if playing
* \return return true if music is playing
*/
virtual bool IsPlayingMusic();
-
-protected:
- std::string m_soundPath;
+
+ /** Start playing pause music
+ * \param filename - name of file to play
+ * \return return true on success
+ */
+ virtual bool PlayPauseMusic(const std::string &filename, bool repeat);
+
+ /** Stop playing pause music and return to the mission music
+ * \return nothing
+ */
+ virtual void StopPauseMusic();
};
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index 348382d..810d365 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -60,12 +60,7 @@ bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventType event
if ( icon == -1 )
{
- char name[100];
- char* p;
-
- GetResource(RES_EVENT, eventType, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
+ std::string name = GetResourceName(eventType);
SetName(name);
}
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index 362c930..6a92554 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -47,16 +47,11 @@ CCheck::~CCheck()
bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- char name[100];
- char* p;
-
if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventType);
- GetResource(RES_EVENT, eventType, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
+ std::string name = GetResourceName(eventType);
SetName(name);
return true;
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 623ff89..d1dc746 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -64,12 +64,7 @@ bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventType eventT
if ( icon == -1 )
{
- char name[100];
- char* p;
-
- GetResource(RES_EVENT, eventType, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
+ std::string name = GetResourceName(eventType);
SetName(name);
}
@@ -146,38 +141,7 @@ void CColor::Draw()
m_engine->SetTexture("button1.png");
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
CControl::Draw();
-
-#if _TEEN
-// color = GetColor(m_color);
- color = GetColor();
-
- m_engine->SetTexture(""); // no texture
- m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
-
- device = m_engine->GetDevice();
-
- p1.x = m_pos.x + (4.0f / 640.0f);
- p1.y = m_pos.y + (4.0f / 480.0f);
- p2.x = m_pos.x + m_dim.x - (4.0f / 640.0f);
- p2.y = m_pos.y + m_dim.y - (4.0f / 480.0f);
- vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
-
- p1.x = m_pos.x + (5.0f / 640.0f);
- p1.y = m_pos.y + (5.0f / 480.0f);
- p2.x = m_pos.x + m_dim.x - (5.0f / 640.0f);
- p2.y = m_pos.y + m_dim.y - (5.0f / 480.0f);
- vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
- vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
- device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
-
- m_engine->AddStatisticTriangle(4);
-#else
+
p1.x = m_pos.x + (3.0f / 640.0f);
p1.y = m_pos.y + (3.0f / 480.0f);
p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f);
@@ -196,7 +160,6 @@ void CColor::Draw()
device = m_engine->GetDevice();
device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
-#endif
}
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index bed84dd..4e64ee9 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -57,9 +57,6 @@ CControl::~CControl()
bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- char text[200];
- std::string str_text;
-
if ( eventType == EVENT_NULL )
eventType = GetUniqueEventType();
@@ -72,17 +69,17 @@ bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType even
pos.y = m_pos.y + m_dim.y;
GlintCreate(pos);
+ std::string text;
GetResource(RES_EVENT, m_eventType, text);
- str_text = std::string(text);
- auto p = str_text.find("\\");
- if ( p == std::string::npos )
+ auto p = text.find("\\");
+ if (p == std::string::npos)
{
if ( icon != -1 )
- m_tooltip = str_text;
+ m_tooltip = text;
}
else
{
- m_tooltip = str_text.substr(p + 1);
+ m_tooltip = text.substr(p + 1);
}
return true;
@@ -509,11 +506,7 @@ void CControl::Draw()
if ( icon >= 192 )
{
icon -= 192;
-#if _POLISH
- m_engine->SetTexture("textp.png");
-#else
m_engine->SetTexture("text.png");
-#endif
m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else if ( icon >= 128 )
@@ -837,5 +830,18 @@ bool CControl::Detect(Math::Point pos)
pos.y <= m_pos.y + m_dim.y );
}
+std::string CControl::GetResourceName(EventType eventType)
+{
+ std::string name;
+ GetResource(RES_EVENT, eventType, name);
+ auto index = name.find('\\');
+ if (index != std::string::npos)
+ {
+ name = name.substr(0, index);
+ }
+ return name;
+}
+
+
}
diff --git a/src/ui/control.h b/src/ui/control.h
index aee7d1c..1ca07cf 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -112,6 +112,8 @@ protected:
void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
virtual bool Detect(Math::Point pos);
+ std::string GetResourceName(EventType eventType);
+
protected:
Gfx::CEngine* m_engine;
Gfx::CParticle* m_particle;
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 3aa3d73..e7748ae 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -23,6 +23,7 @@
#include "common/iman.h"
#include "common/misc.h"
#include "common/restext.h"
+#include "common/stringutils.h"
#include "graphics/core/light.h"
#include "graphics/engine/engine.h"
@@ -58,6 +59,7 @@ CDisplayInfo::CDisplayInfo()
m_main = CRobotMain::GetInstancePointer();
m_interface = m_main->GetInterface();
m_camera = m_main->GetCamera();
+ m_pause = CPauseManager::GetInstancePointer();
m_bInfoMaximized = true;
m_bInfoMinimized = false;
@@ -329,13 +331,13 @@ void CDisplayInfo::HyperUpdate()
void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluce)
{
- Gfx::Light light;
+ Gfx::Light light;
Math::Point pos, dim;
Ui::CWindow* pw;
Ui::CEdit* edit;
Ui::CButton* button;
Ui::CSlider* slider;
- CMotionToto* toto;
+ CMotionToto* toto;
m_index = index;
m_bSoluce = bSoluce;
@@ -354,8 +356,8 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
m_main->SetEditLock(true, false);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->GetPause();
- m_engine->SetPause(true);
+ m_bInitPause = m_pause->GetPauseType();
+ m_pause->SetPause(PAUSE_SATCOM);
m_infoCamera = m_camera->GetType();
m_camera->SetType(Gfx::CAM_TYPE_INFO);
@@ -388,13 +390,7 @@ void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluc
button = pw->CreateButton(pos, dim, 128+57, EVENT_SATCOM_HUSTON);
button->SetState(STATE_SHADOW);
-#if _TEEN
-#if !_ENGLISH
- button = pw->CreateButton(pos, dim, 46, EVENT_SATCOM_SAT);
-#endif
-#else
button = pw->CreateButton(pos, dim, 128+58, EVENT_SATCOM_SAT);
-#endif
button->SetState(STATE_SHADOW);
//? button = pw->CreateButton(pos, dim, 128+59, EVENT_SATCOM_OBJECT);
//? button->SetState(STATE_SHADOW);
@@ -838,7 +834,7 @@ void CDisplayInfo::StopDisplayInfo()
}
else
{
- if ( !m_bInitPause ) m_engine->SetPause(false);
+ m_pause->SetPause(m_bInitPause);
m_main->SetEditLock(false, false);
}
m_camera->SetType(m_infoCamera);
@@ -971,31 +967,41 @@ void ObjectAdd(ObjectList list[], ObjectType type)
void ObjectWrite(FILE* file, ObjectList list[], int i)
{
- char line[100];
- char res[100];
- char* p;
+ std::string line;
if ( list[i].total < 10 )
{
- sprintf(line, "\\c; %dx \\n;\\l;", list[i].total);
+ line = StrUtils::Format("\\c; %dx \\n;\\l;", list[i].total);
}
else
{
- sprintf(line, "\\c;%dx \\n;\\l;", list[i].total);
+ line = StrUtils::Format("\\c;%dx \\n;\\l;", list[i].total);
}
+ std::string res;
GetResource(RES_OBJECT, list[i].type, res);
- if ( res[0] == 0 ) return;
- strcat(line, res);
-
- strcat(line, "\\u ");
- p = const_cast<char*>(GetHelpFilename(list[i].type).c_str());
- if ( p[0] == 0 ) return;
- strcat(line, p+7); // skip "help\?\"
- p = strstr(line, ".txt");
- if ( p != 0 ) *p = 0;
- strcat(line, ";\n");
- fputs(line, file);
+ if (res.empty())
+ return;
+
+ line += res;
+
+ line += "\\u ";
+
+ std::string helpFilename = GetHelpFilename(list[i].type);
+ if (helpFilename.empty())
+ return;
+
+ line += helpFilename.substr(7); // skip "help\?\"
+
+ auto pos = line.find(".txt");
+ if (pos != std::string::npos)
+ {
+ line = line.substr(0, pos);
+ }
+
+ line += ";\n";
+
+ fputs(line.c_str(), file);
}
// Creates the file containing the list of objects.
@@ -1006,7 +1012,7 @@ void CDisplayInfo::CreateObjectsFile()
CObject* pObj;
ObjectType type;
ObjectList list[200];
- char line[100];
+ std::string line;
int i;
bool bRadar, bAtLeast;
@@ -1038,7 +1044,7 @@ void CDisplayInfo::CreateObjectsFile()
if ( bRadar )
{
GetResource(RES_TEXT, RT_SATCOM_LIST, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
bAtLeast = false;
for ( i=0 ; i<200 ; i++ )
{
@@ -1054,13 +1060,12 @@ void CDisplayInfo::CreateObjectsFile()
if ( !bAtLeast )
{
GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
- strcpy(line, "\n");
- fputs(line, file);
+ fputs("\n", file);
GetResource(RES_TEXT, RT_SATCOM_BOT, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
bAtLeast = false;
for ( i=0 ; i<200 ; i++ )
{
@@ -1101,13 +1106,12 @@ void CDisplayInfo::CreateObjectsFile()
if ( !bAtLeast )
{
GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
- strcpy(line, "\n");
- fputs(line, file);
+ fputs("\n", file);
GetResource(RES_TEXT, RT_SATCOM_BUILDING, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
bAtLeast = false;
for ( i=0 ; i<200 ; i++ )
{
@@ -1142,13 +1146,12 @@ void CDisplayInfo::CreateObjectsFile()
if ( !bAtLeast )
{
GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
- strcpy(line, "\n");
- fputs(line, file);
+ fputs("\n", file);
GetResource(RES_TEXT, RT_SATCOM_FRET, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
bAtLeast = false;
for ( i=0 ; i<200 ; i++ )
{
@@ -1170,13 +1173,12 @@ void CDisplayInfo::CreateObjectsFile()
if ( !bAtLeast )
{
GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
- strcpy(line, "\n");
- fputs(line, file);
+ fputs("\n", file);
GetResource(RES_TEXT, RT_SATCOM_ALIEN, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
bAtLeast = false;
for ( i=0 ; i<200 ; i++ )
{
@@ -1195,19 +1197,18 @@ void CDisplayInfo::CreateObjectsFile()
if ( !bAtLeast )
{
GetResource(RES_TEXT, RT_SATCOM_NULL, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
}
else
{
GetResource(RES_TEXT, RT_SATCOM_ERROR1, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
GetResource(RES_TEXT, RT_SATCOM_ERROR2, line);
- fputs(line, file);
+ fputs(line.c_str(), file);
}
- strcpy(line, "\n");
- fputs(line, file);
+ fputs("\n", file);
fclose(file);
}
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index eea50b7..891551b 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -25,6 +25,8 @@
#include "graphics/engine/camera.h"
+#include "app/pausemanager.h"
+
class CRobotMain;
class CObject;
class CEventQueue;
@@ -67,13 +69,14 @@ protected:
void CreateObjectsFile();
protected:
- Gfx::CEngine* m_engine;
- CEventQueue* m_event;
- CRobotMain* m_main;
- Gfx::CCamera* m_camera;
- CInterface* m_interface;
- Gfx::CParticle* m_particle;
- Gfx::CLightManager* m_light;
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CInterface* m_interface;
+ Gfx::CParticle* m_particle;
+ Gfx::CLightManager* m_light;
+ CPauseManager* m_pause;
bool m_bInfoMaximized;
bool m_bInfoMinimized;
@@ -88,7 +91,7 @@ protected:
Math::Point m_infoFinalDim;
int m_lightSuppl;
bool m_bEditLock;
- bool m_bInitPause;
+ PauseType m_bInitPause;
bool m_bSoluce;
CObject* m_toto;
};
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index d88674a..5b3144d 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -127,9 +127,6 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time)
void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
float dist, float time)
{
- TextType type;
- char text[100];
-
if ( err == ERR_OK ) return;
#if 0
@@ -148,7 +145,7 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
type = TT_WARNING;
}
#else
- type = TT_WARNING;
+ TextType type = TT_WARNING;
if ( err >= INFO_FIRST )
{
type = TT_INFO;
@@ -164,8 +161,9 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
}
#endif
+ std::string text;
GetResource(RES_ERR, err, text);
- DisplayText(text, goal, height, dist, time, type);
+ DisplayText(text.c_str(), goal, height, dist, time, type);
}
// Displays text.
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index a187688..e2df62b 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -19,6 +19,7 @@
#include "ui/edit.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "clipboard/clipboard.h"
@@ -1224,11 +1225,7 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
Math::Point uv1, uv2;
float dp;
-#if _POLISH
- m_engine->SetTexture("textp.png");
-#else
m_engine->SetTexture("text.png");
-#endif
m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = (16.0f/256.0f)*(icon%16);
@@ -1462,11 +1459,14 @@ bool CEdit::ReadText(std::string filename, int addSize)
std::string path = filename;
if (!fs::exists(path))
{
- path = CApplication::GetInstancePointer()->GetDataDirPath() + "/" + filename;
+ path = CGameData::GetInstancePointer()->GetDataPath(filename);
}
file = fopen(fs::path(path).make_preferred().string().c_str(), "rb");
- if ( file == NULL ) return false;
+ if ( file == NULL ) {
+ CLogger::GetInstancePointer()->Error("Unable to read text from file \"%s\"\n", path.c_str());
+ return false;
+ }
fseek(file, 0, SEEK_END);
len = ftell(file);
@@ -1669,12 +1669,14 @@ bool CEdit::ReadText(std::string filename, int addSize)
buffer[i+6] == 'n' &&
buffer[i+7] == ' ' )
{
+ /* TODO: \button X; isn't working. Issue #232
if ( m_bSoluce || !bInSoluce )
{
m_text[j] = GetValueParam(buffer+i+8, 0);
m_format[j] = font|Gfx::FONT_BUTTON;
j ++;
}
+ */
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
else if ( //m_format.size() > 0 &&
@@ -1798,8 +1800,10 @@ bool CEdit::ReadText(std::string filename, int addSize)
res = main->GetInputBinding(slot).primary;
if ( res != 0 )
{
- if ( GetResource(RES_KEY, res, iName) )
+ std::string iNameStr;
+ if ( GetResource(RES_KEY, res, iNameStr) )
{
+ strcpy(iName, iNameStr.c_str());
m_text[j] = ' ';
m_format[j] = font;
j ++;
@@ -1817,9 +1821,13 @@ bool CEdit::ReadText(std::string filename, int addSize)
res = main->GetInputBinding(slot).secondary;
if ( res != 0 )
{
- if ( GetResource(RES_KEY, res, iName) )
+ if ( GetResource(RES_KEY, res, iNameStr) )
{
- GetResource(RES_TEXT, RT_KEY_OR, text);
+ strcpy(iName, iNameStr.c_str());
+
+ std::string textStr;
+ GetResource(RES_TEXT, RT_KEY_OR, textStr);
+ strcpy(text, textStr.c_str());
n = 0;
while ( text[n] != 0 )
{
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index 908ac19..64495e0 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -52,12 +52,7 @@ bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventType eventT
if ( icon == -1 )
{
- char name[100];
- char* p;
-
- GetResource(RES_EVENT, eventType, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
+ std::string name = GetResourceName(eventType);
SetName(name);
}
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index 9a14789..8f9b5ca 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -58,12 +58,7 @@ bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventType eventT
if ( icon == -1 )
{
- char name[100];
- char* p;
-
- GetResource(RES_EVENT, eventType, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
+ std::string name = GetResourceName(eventType);
SetName(name);
}
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index 1f8cff5..aacc8d8 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -19,16 +19,19 @@
#include "ui/key.h"
#include "common/global.h"
+#include "common/stringutils.h"
#include <cstring>
namespace Ui {
-void GetKeyName(char* name, unsigned int key)
+static void GetKeyName(std::string& name, unsigned int key)
{
if (!GetResource(RES_KEY, key, name))
- sprintf(name, "Code %d", key);
+ {
+ name = StrUtils::Format("Code %d", key);
+ }
}
@@ -51,9 +54,9 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg
CControl::Create(pos, dim, icon, eventMsg);
- char name[100];
+ std::string name;
GetResource(RES_EVENT, eventMsg, name);
- SetName(std::string(name));
+ SetName(name);
return true;
}
@@ -176,19 +179,24 @@ void CKey::Draw()
float h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
- char text[100];
- GetKeyName(text, m_binding.primary);
+ std::string keyName;
+ GetKeyName(keyName, m_binding.primary);
if (m_binding.secondary != KEY_INVALID)
{
- GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text));
- GetKeyName(text+strlen(text), m_binding.secondary);
+ std::string orText;
+ GetResource(RES_TEXT, RT_KEY_OR, orText);
+ keyName.append(orText);
+
+ std::string secondaryKeyName;
+ GetKeyName(secondaryKeyName, m_binding.secondary);
+ keyName.append(secondaryKeyName);
}
Math::Point pos;
pos.x = m_pos.x + m_dim.x * 0.5f;
pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h;
- m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0);
+ m_engine->GetText()->DrawText(keyName, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0);
m_dim = iDim;
@@ -199,7 +207,7 @@ void CKey::Draw()
pos.x = m_pos.x + (214.0f / 640.0f);
pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h;
- m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
void CKey::SetBinding(InputBinding b)
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 407f8da..11f8f4a 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -18,15 +18,17 @@
#include "ui/maindialog.h"
#include "app/app.h"
+#include "app/gamedata.h"
#include "app/system.h"
+#include "common/config.h"
#include "common/global.h"
#include "common/event.h"
#include "common/logger.h"
#include "common/misc.h"
#include "common/profile.h"
#include "common/restext.h"
-#include "common/logger.h"
+#include "common/stringutils.h"
#include "object/robotmain.h"
@@ -52,6 +54,7 @@
#include <string.h>
#include <sstream>
#include <iomanip>
+#include <vector>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
@@ -118,6 +121,7 @@ CMainDialog::CMainDialog()
m_camera = m_main->GetCamera();
m_engine = Gfx::CEngine::GetInstancePointer();
m_particle = m_engine->GetParticle();
+ m_pause = CPauseManager::GetInstancePointer();
m_phase = PHASE_NAME;
m_phaseSetup = PHASE_SETUPg;
@@ -153,9 +157,6 @@ CMainDialog::CMainDialog()
m_bMovies = true;
m_bNiceReset = true;
m_bHimselfDamage = true;
-/* TODO: #if _TEEN
- m_bCameraScroll = false;
-#else*/
m_bCameraScroll = true;
m_bCameraInvertX = false;
@@ -215,7 +216,7 @@ void CMainDialog::ChangePhase(Phase phase)
CImage* pi;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
- char name[100];
+ std::string name;
char* gamer;
int res, i, j;
@@ -243,9 +244,6 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = 0.10f;
ddim.x = 0.30f;
ddim.y = 0.80f;
- /* TODO: #if _TEEN
- pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5);
-#else*/
pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5);
GetResource(RES_TEXT, RT_TITLE_INIT, name);
@@ -261,22 +259,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.30f;
ddim.y = 0.30f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
-
- /* TODO: #if _SCHOOL
- ddim.x = 0.20f;
- ddim.y = dim.y*2.4f;
- pos.x = 0.40f;
- pos.y = oy+sy*7.9f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // orange
- pg->SetState(STATE_SHADOW);
- pos.y = oy+sy*3.9f;
- pg = pw->CreateGroup(pos, ddim, 25, EVENT_LABEL1); // orange
- pg->SetState(STATE_SHADOW);
- ddim.y = dim.y*1.2f;
- pos.y = oy+sy*1.9f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red
- pg->SetState(STATE_SHADOW);
-#else */
+
ddim.x = 0.20f;
ddim.y = dim.y*2.4f;
pos.x = 0.40f;
@@ -296,26 +279,7 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = oy+sy*1.9f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red
pg->SetState(STATE_SHADOW);
-
- /* TODO: #if _SCHOOL
- ddim.x = 0.18f;
- ddim.y = dim.y*1;
- pos.x = 0.41f;
- pos.y = oy+sy*9.1f;
- pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_TRAINER);
- pb->SetState(STATE_SHADOW);
-
- pos.y = oy+sy*8.0f;
-#if _TEEN
-pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_TEEN);
-#else
-pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_DEFI);
-#endif
-#if _CEEBOTDEMO
-pb->ClearState(STATE_ENABLE);
-#endif
-pb->SetState(STATE_SHADOW);
-#else */
+
ddim.x = 0.18f;
ddim.y = dim.y*1;
pos.x = 0.41f;
@@ -351,30 +315,22 @@ pb->SetState(STATE_SHADOW);
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_QUIT);
pb->SetState(STATE_SHADOW);
- // TODO: #if !_DEMO & !_SCHOOL
+ #if DEV_BUILD
if ( m_accessEnable && m_accessUser )
{
pos.x = 447.0f/640.0f;
pos.y = 313.0f/480.0f;
ddim.x = 0.09f;
- /*#if _POLISH
- pos.x -= 5.0f/640.0f;
- ddim.x += 10.0f/640.0f;
-#endif*/
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_USER);
pb->SetState(STATE_SHADOW);
}
- // #endif
+ #endif
- // TODO: remove?
- if (m_app->GetProtoMode())
- {
- pos.x = 139.0f/640.0f;
- pos.y = 313.0f/480.0f;
- ddim.x = 0.09f;
- pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_PROTO);
- pb->SetState(STATE_SHADOW);
- }
+ /*pos.x = 139.0f/640.0f;
+ pos.y = 313.0f/480.0f;
+ ddim.x = 0.09f;
+ pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_PROTO);
+ pb->SetState(STATE_SHADOW);*/
pos.x = 0.40f;
ddim.x = 0.20f;
@@ -406,19 +362,6 @@ pb->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_TITLE_NAME, name);
pw->SetName(name);
- /* TODO: #if _NEWLOOK
- pos.x = 80.0f/640.0f;
- pos.y = 93.0f/480.0f;
- ddim.x = 285.0f/640.0f;
- ddim.y = 266.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 372.0f/640.0f;
- ddim.x = 188.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif*/
-
pos.x = 0.10f;
pos.y = 0.40f;
ddim.x = 0.50f;
@@ -458,10 +401,10 @@ pb->SetState(STATE_SHADOW);
}
else
{
- strcpy(name, gamer);
+ name = gamer;
}
- pe->SetText(name);
- pe->SetCursor(strlen(name), 0);
+ pe->SetText(name.c_str());
+ pe->SetCursor(name.length(), 0);
pe->SetFocus(true);
pos.x = 380.0f/640.0f;
@@ -526,15 +469,6 @@ pb->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_TITLE_PERSO, name);
pw->SetName(name);
- /* TODO: #if _NEWLOOK
- pos.x = 95.0f/640.0f;
- pos.y = 66.0f/480.0f;
- ddim.x = 443.0f/640.0f;
- ddim.y = 42.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif*/
-
pos.x = 0.10f;
pos.y = 0.40f;
ddim.x = 0.50f;
@@ -770,15 +704,13 @@ pb->SetState(STATE_SHADOW);
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
if ( m_phase == PHASE_TRAINER ) m_index = 0;
if ( m_phase == PHASE_DEFI ) m_index = 1;
if ( m_phase == PHASE_MISSION ) m_index = 2;
if ( m_phase == PHASE_FREE ) m_index = 3;
if ( m_phase == PHASE_USER ) m_index = 4;
- if ( m_phase == PHASE_PROTO ) m_index = 5;
if ( m_phase == PHASE_TEEN ) m_index = 6;
if ( m_phase == PHASE_FREE )
@@ -794,7 +726,6 @@ pb->SetState(STATE_SHADOW);
if ( m_phase == PHASE_FREE ) strcpy(m_sceneName, "free");
if ( m_phase == PHASE_TEEN ) strcpy(m_sceneName, "teen");
if ( m_phase == PHASE_USER ) strcpy(m_sceneName, "user");
- if ( m_phase == PHASE_PROTO ) strcpy(m_sceneName, "proto");
ReadGamerInfo();
@@ -810,33 +741,9 @@ pb->SetState(STATE_SHADOW);
if ( m_phase == PHASE_FREE ) res = RT_TITLE_FREE;
if ( m_phase == PHASE_TEEN ) res = RT_TITLE_TEEN;
if ( m_phase == PHASE_USER ) res = RT_TITLE_USER;
- if ( m_phase == PHASE_PROTO ) res = RT_TITLE_PROTO;
GetResource(RES_TEXT, res, name);
pw->SetName(name);
- /* TODO: #if _NEWLOOK
- pos.x = 100.0f/640.0f;
- pos.y = 226.0f/480.0f;
- ddim.x = 216.0f/640.0f;
- ddim.y = 160.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 322.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // cyan
- pg->SetState(STATE_SHADOW);
-
- pos.x = 100.0f/640.0f;
- pos.y = 122.0f/480.0f;
- ddim.x = 438.0f/640.0f;
- ddim.y = 98.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 25, EVENT_LABEL1); // green
- pg->SetState(STATE_SHADOW);
- pos.y = 66.0f/480.0f;
- ddim.y = 42.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif */
-
pos.x = 0.10f;
pos.y = 0.40f;
ddim.x = 0.50f;
@@ -859,7 +766,6 @@ pb->SetState(STATE_SHADOW);
if ( m_phase == PHASE_FREE ) res = RT_PLAY_CHAPf;
if ( m_phase == PHASE_TEEN ) res = RT_PLAY_CHAPte;
if ( m_phase == PHASE_USER ) res = RT_PLAY_CHAPu;
- if ( m_phase == PHASE_PROTO ) res = RT_PLAY_CHAPp;
GetResource(RES_TEXT, res, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
@@ -883,7 +789,6 @@ pb->SetState(STATE_SHADOW);
if ( m_phase == PHASE_FREE ) res = RT_PLAY_LISTf;
if ( m_phase == PHASE_TEEN ) res = RT_PLAY_LISTk;
if ( m_phase == PHASE_USER ) res = RT_PLAY_LISTu;
- if ( m_phase == PHASE_PROTO ) res = RT_PLAY_LISTp;
GetResource(RES_TEXT, res, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
@@ -1049,80 +954,6 @@ pb->SetState(STATE_SHADOW);
ddim.y = 0.05f;
pw->CreateGroup(pos, ddim, 3, EVENT_NULL); // transparent -> gray
- /* TODO: #if _NEWLOOK
- if ( m_phase == PHASE_SETUPd || // setup/display ?
- m_phase == PHASE_SETUPds )
- {
- pos.x = 100.0f/640.0f;
- pos.y = 130.0f/480.0f;
- ddim.x = 216.0f/640.0f;
- ddim.y = 212.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 324.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // cyan
- pg->SetState(STATE_SHADOW);
- }
- if ( m_phase == PHASE_SETUPg || // setup/graphic ?
- m_phase == PHASE_SETUPgs )
- {
- pos.x = 100.0f/640.0f;
- pos.y = 130.0f/480.0f;
- ddim.x = 174.0f/640.0f;
- ddim.y = 212.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 282.0f/640.0f;
- ddim.x = 258.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // cyan
- pg->SetState(STATE_SHADOW);
- }
- if ( m_phase == PHASE_SETUPp || // setup/game ?
- m_phase == PHASE_SETUPps )
- {
- pos.x = 100.0f/640.0f;
- pos.y = 130.0f/480.0f;
- ddim.x = 226.0f/640.0f;
- ddim.y = 212.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 334.0f/640.0f;
- ddim.x = 206.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // cyan
- pg->SetState(STATE_SHADOW);
- }
- if ( m_phase == PHASE_SETUPc || // setup/command ?
- m_phase == PHASE_SETUPcs )
- {
- pos.x = 100.0f/640.0f;
- pos.y = 125.0f/480.0f;
- ddim.x = 440.0f/640.0f;
- ddim.y = 222.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- }
- if ( m_phase == PHASE_SETUPs || // setup/sound ?
- m_phase == PHASE_SETUPss )
- {
- pos.x = 100.0f/640.0f;
- pos.y = 130.0f/480.0f;
- ddim.x = 216.0f/640.0f;
- ddim.y = 212.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 23, EVENT_LABEL1); // blue
- pg->SetState(STATE_SHADOW);
- pos.x = 324.0f/640.0f;
- pg = pw->CreateGroup(pos, ddim, 24, EVENT_LABEL1); // cyan
- pg->SetState(STATE_SHADOW);
- }
-
- pos.x = 100.0f/640.0f;
- pos.y = 66.0f/480.0f;
- ddim.x = 440.0f/640.0f;
- ddim.y = 42.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif */
-
ddim.x = 0.78f/5-0.01f;
ddim.y = 0.06f;
pos.x = 0.115f;
@@ -1353,10 +1184,7 @@ pb->SetState(STATE_SHADOW);
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
- /* TODO: #if _POLISH
- ddim.x += 20.0f/640.0f;
- pos.x -= 20.0f/640.0f*3.0f;
-#endif*/
+
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_MIN);
pb->SetState(STATE_SHADOW);
pos.x += ddim.x;
@@ -1379,13 +1207,7 @@ pb->SetState(STATE_SHADOW);
//? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOTO);
//? pc->SetState(STATE_SHADOW);
//? pos.y -= 0.048f;
- /*TODO: #if _SCHOOL
-#if _EDU
-pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SOLUCE4);
-pc->SetState(STATE_SHADOW);
-pos.y -= 0.048f;
-#endif
-#else*/
+
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
@@ -1507,7 +1329,6 @@ pos.y -= 0.048f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
- // TODO: #if (_FULL | _NET) & _SOUNDTRACKS
pos.x = ox+sx*3;
pos.y = 0.40f;
ddim.x = dim.x*4.0f;
@@ -1520,14 +1341,6 @@ pos.y -= 0.048f;
GetResource(RES_EVENT, EVENT_INTERFACE_VOLMUSIC, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
- // #endif
-
- ddim.x = dim.x*6;
- ddim.y = dim.y*0.5f;
- pos.x = ox+sx*10;
- pos.y = 0.55f;
- pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SOUND3D);
- pc->SetState(STATE_SHADOW);
ddim.x = dim.x*3;
ddim.y = dim.y*1;
@@ -1565,15 +1378,6 @@ pos.y -= 0.048f;
ddim.y = 0.50f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
- /* TODO: #if _NEWLOOK
- pos.x = 100.0f/640.0f;
- pos.y = 66.0f/480.0f;
- ddim.x = 438.0f/640.0f;
- ddim.y = 42.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif */
-
pos.x = 290.0f/640.0f;
ddim.x = 245.0f/640.0f;
@@ -1649,15 +1453,6 @@ pos.y -= 0.048f;
ddim.y = 0.50f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
- /* TODO: #if _NEWLOOK
- pos.x = 100.0f/640.0f;
- pos.y = 66.0f/480.0f;
- ddim.x = 438.0f/640.0f;
- ddim.y = 42.0f/480.0f;
- pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
- pg->SetState(STATE_SHADOW);
-#endif*/
-
pos.x = 290.0f/640.0f;
ddim.x = 245.0f/640.0f;
@@ -1717,9 +1512,6 @@ pos.y -= 0.048f;
pos.y = 0.10f;
ddim.x = 0.30f;
ddim.y = 0.80f;
- /*TODO: #if _TEEN
- pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5);
-#else*/
pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5);
pw->SetName(" ");
@@ -1828,7 +1620,6 @@ pos.y -= 0.048f;
ddim.y = 0.0f;
pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);
- // TODO: #if _FULL | _NET
pos.x = 80.0f/640.0f;
pos.y = 240.0f/480.0f;
ddim.x = 490.0f/640.0f;
@@ -1841,54 +1632,6 @@ pos.y -= 0.048f;
pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
pe->ReadText(std::string("help/") + m_app->GetLanguageChar() + std::string("/authors.txt"));
- // #endif
- /* TODO: #if _SCHOOL
- #if _CEEBOTDEMO
- pos.x = 80.0f/640.0f;
- pos.y = 210.0f/480.0f;
- ddim.x = 490.0f/640.0f;
- ddim.y = 150.0f/480.0f;
- #else
- pos.x = 80.0f/640.0f;
- pos.y = 200.0f/480.0f;
- ddim.x = 490.0f/640.0f;
- ddim.y = 150.0f/480.0f;
- #endif
- pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
- pe->SetGenericMode(true);
- pe->SetEditCap(false);
- pe->SetHighlightCap(false);
- pe->SetFontType(Gfx::FONT_COURIER);
- pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- pe->ReadText("help/authors.txt");*/
-
- /* #if _DEMO
- //? pos.x = 80.0f/640.0f;
- //? pos.y = 240.0f/480.0f;
- //? ddim.x = 490.0f/640.0f;
- //? ddim.y = 110.0f/480.0f;
- //? pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
- //? pe->SetGenericMode(true);
- //? pe->SetEditCap(false);
- //? pe->SetHiliteCap(false);
- //? pe->SetFontType(Gfx::FONT_COURIER);
- //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- //? pe->ReadText("help/demo.txt");
-
- //? pos.x = 80.0f/640.0f;
- //? pos.y = 140.0f/480.0f;
- //? ddim.x = 490.0f/640.0f;
- //? ddim.y = 100.0f/480.0f;
- //? pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT2);
- //? pe->SetGenericMode(true);
- //? pe->SetEditCap(false);
- //? pe->SetHiliteCap(false);
- //? pe->SetFontType(Gfx::FONT_COURIER);
- //? pe->SetFontSize(Gfx::FONT_SIZE_SMALL);
- //? pe->ReadText("help/authors.txt");
-#endif */
-
- // TODO: #if !_DEMO
pos.x = 40.0f/640.0f;
pos.y = 83.0f/480.0f;
ddim.x = 246.0f/640.0f;
@@ -1918,23 +1661,13 @@ pos.y -= 0.048f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(Gfx::FONT_SIZE_SMALL);
- // #endif
-
- /* TODO: #if _DEMO
- pos.x = 481.0f/640.0f;
- pos.y = 51.0f/480.0f;
- ddim.x = 30.0f/640.0f;
- ddim.y = 30.0f/480.0f;
- pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT);
- pb->SetState(STATE_SHADOW);
-#else */
+
pos.x = 306.0f/640.0f;
pos.y = 17.0f/480.0f;
ddim.x = 30.0f/640.0f;
ddim.y = 30.0f/480.0f;
pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT);
pb->SetState(STATE_SHADOW);
- // #endif
m_engine->SetBackground("generico.png",
Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
@@ -1953,7 +1686,6 @@ pos.y -= 0.048f;
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO ||
m_phase == PHASE_SETUPd ||
m_phase == PHASE_SETUPg ||
m_phase == PHASE_SETUPp ||
@@ -1962,26 +1694,12 @@ pos.y -= 0.048f;
m_phase == PHASE_READ ||
m_phase == PHASE_LOADING )
{
- /*TODO: #if _SCHOOL
-#if _TEEN
-pos.x = 50.0f/640.0f;
-pos.y = 430.0f/480.0f;
-ddim.x = 200.0f/640.0f;
-ddim.y = 10.0f/480.0f;
-#else
-pos.x = 450.0f/640.0f;
-pos.y = 0.0f/480.0f;
-ddim.x = 170.0f/640.0f;
-ddim.y = 9.0f/480.0f;
-#endif
-#else */
pos.x = 540.0f/640.0f;
pos.y = 9.0f/480.0f;
ddim.x = 90.0f/640.0f;
ddim.y = 10.0f/480.0f;
- //#endif
//GetResource(RES_TEXT, RT_VERSION_ID, name);
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, __DATE__);
+ pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, COLOBOT_VERSION_DISPLAY);
pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(9.0f);
}
@@ -2087,9 +1805,10 @@ bool CMainDialog::EventProcess(const Event &event)
{
m_shotDelay --;
if ( m_shotDelay == 0 )
- {
- m_engine->WriteScreenShot(m_shotName, 320, 240);
- //? m_engine->WriteScreenShot(m_shotName, 160, 120);
+ {
+ Math::IntPoint windowSize = m_engine->GetWindowSize();
+
+ m_engine->WriteScreenShot(m_shotName, windowSize.x, windowSize.y);
}
}
@@ -2237,10 +1956,6 @@ bool CMainDialog::EventProcess(const Event &event)
m_main->ChangePhase(PHASE_USER);
break;
- case EVENT_INTERFACE_PROTO:
- m_main->ChangePhase(PHASE_PROTO);
- break;
-
case EVENT_INTERFACE_SETUP:
m_main->ChangePhase(m_phaseSetup);
break;
@@ -2444,8 +2159,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
@@ -2464,8 +2178,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
switch( event.type )
{
@@ -2492,11 +2205,6 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_PLAY:
- if ( m_phase == PHASE_PROTO && m_chap[m_index] == 0 && m_sel[m_index] == 0 )
- {
- m_main->ChangePhase(PHASE_MODEL);
- break;
- }
m_sceneRank = (m_chap[m_index]+1)*100+(m_sel[m_index]+1);
m_phaseTerm = m_phase;
m_main->ChangePhase(PHASE_LOADING);
@@ -2888,7 +2596,7 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_KDEF:
- m_app->ResetKeyStates();
+ m_main->SetDefaultInputBindings();
UpdateKey();
break;
@@ -2913,12 +2621,6 @@ bool CMainDialog::EventProcess(const Event &event)
ChangeSetupButtons();
break;
- case EVENT_INTERFACE_SOUND3D:
- m_sound->SetSound3D(!m_sound->GetSound3D());
- ChangeSetupButtons();
- UpdateSetupButtons();
- break;
-
case EVENT_INTERFACE_SILENT:
m_sound->SetAudioVolume(0);
m_sound->SetMusicVolume(0);
@@ -3119,8 +2821,7 @@ void CMainDialog::GlintMove()
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl));
if ( pg != 0 )
@@ -3256,8 +2957,6 @@ Math::Vector SoundRand()
void CMainDialog::FrameParticle(float rTime)
{
- /* TODO: #if _NEWLOOK
-#else */
Math::Vector pos, speed;
Math::Point dim;
float *pParti, *pGlint;
@@ -3348,7 +3047,6 @@ void CMainDialog::FrameParticle(float rTime)
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO ||
m_phase == PHASE_SETUPd ||
m_phase == PHASE_SETUPg ||
m_phase == PHASE_SETUPp ||
@@ -3620,7 +3318,7 @@ void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank)
{
rankStream << std::setfill('0') << std::setw(3) << rank;
filename = base + rankStream.str() + ".txt";
- filename = CApplication::GetInstance().GetDataFilePath(DIR_LEVEL, filename);
+ filename = CGameData::GetInstancePointer()->GetFilePath(DIR_LEVEL, filename);
}
}
@@ -4019,7 +3717,7 @@ void CMainDialog::UpdatePerso()
CColor* pc;
CSlider* ps;
Gfx::Color color;
- char name[100];
+ std::string name;
int i;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
@@ -4366,8 +4064,8 @@ void CMainDialog::IOReadName()
}
time(&now);
- TimeToAscii(now, line);
- sprintf(name, "%s %d - %s", resume, m_sel[m_index]+1, line);
+ TimeToAsciiClean(now, line);
+ sprintf(name, "%s - %s %d", line, resume, m_sel[m_index]+1);
pe->SetText(name);
pe->SetCursor(strlen(name), 0);
pe->SetFocus(true);
@@ -4383,7 +4081,7 @@ void CMainDialog::IOReadList()
char line[500];
char name[100];
int i;
- fs::directory_iterator end_iter;
+ std::vector<fs::path> v;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
@@ -4397,12 +4095,14 @@ void CMainDialog::IOReadList()
if (fs::exists(saveDir) && fs::is_directory(saveDir))
{
- for( fs::directory_iterator dir_iter(saveDir) ; dir_iter != end_iter ; ++dir_iter)
+ copy(fs::directory_iterator(saveDir), fs::directory_iterator(), back_inserter(v));
+ std::sort(v.begin(), v.end());
+ for( std::vector<fs::path>::iterator iter = v.begin(); iter != v.end(); ++iter)
{
- if ( fs::is_directory(dir_iter->status()) && fs::exists(dir_iter->path() / "data.sav") )
+ if ( fs::is_directory(*iter) && fs::exists(*iter / "data.sav") )
{
- file = fopen((dir_iter->path() / "data.sav").make_preferred().string().c_str(), "r");
+ file = fopen((*iter / "data.sav").make_preferred().string().c_str(), "r");
if ( file == NULL ) continue;
while ( fgets(line, 500, file) != NULL )
@@ -4426,7 +4126,7 @@ void CMainDialog::IOReadList()
fclose(file);
pl->SetItemName(m_saveList.size(), name);
- m_saveList.push_back(dir_iter->path());
+ m_saveList.push_back(*iter);
}
}
}
@@ -4434,8 +4134,9 @@ void CMainDialog::IOReadList()
// invalid index
if ( m_phase == PHASE_WRITE || m_phase == PHASE_WRITEs )
{
- GetResource(RES_TEXT, RT_IO_NEW, name);
- pl->SetItemName(m_saveList.size(), name);
+ std::string nameStr;
+ GetResource(RES_TEXT, RT_IO_NEW, nameStr);
+ pl->SetItemName(m_saveList.size(), nameStr.c_str());
}
pl->SetSelect(m_saveList.size());
@@ -4694,8 +4395,7 @@ void CMainDialog::AllMissionUpdate()
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
UpdateSceneChap(m_chap[m_index]);
UpdateSceneList(m_chap[m_index], m_sel[m_index]);
@@ -4793,17 +4493,6 @@ void CMainDialog::UpdateSceneChap(int &chap)
{
for ( j=0 ; j<9 ; j++ )
{
-/* TODO: #if _SCHOOL
- if ( m_phase == PHASE_MISSION ) break;
- if ( m_phase == PHASE_FREE ) break;
-#if _CEEBOTDEMO
- if ( m_phase == PHASE_TRAINER && j >= 2 ) break;
-#endif
-#endif
-#if _DEMO
- if ( m_phase == PHASE_MISSION && j >= 4 ) break;
- if ( m_phase == PHASE_TRAINER && j >= 1 ) break;
-#endif */
BuildSceneName(fileName, m_sceneName, (j+1)*100);
file = fopen(fileName.c_str(), "r");
if ( file == NULL ) break;
@@ -4848,14 +4537,6 @@ void CMainDialog::UpdateSceneChap(int &chap)
break;
}
-/* TODO: #if _TEEN
- if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed )
- {
- j ++;
- break;
- }
-#endif*/
-
if ( m_phase == PHASE_FREE && j == m_accessChap )
{
j ++;
@@ -4899,21 +4580,6 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
for ( j=0 ; j<99 ; j++ )
{
-/* TODO: #if _SCHOOL
- if ( m_phase == PHASE_MISSION ) break;
- if ( m_phase == PHASE_FREE ) break;
-#if _CEEBOTDEMO
-#if _TEEN
- if ( m_phase == PHASE_TRAINER && j >= 5 ) break;
-#else
- if ( m_phase == PHASE_TRAINER && j >= 3 ) break;
-#endif
-#endif
-#endif
-#if _DEMO
- if ( m_phase == PHASE_MISSION && j >= 3 ) break;
- if ( m_phase == PHASE_TRAINER && j >= 5 ) break;
-#endif */
BuildSceneName(fileName, m_sceneName, (chap+1)*100+(j+1));
file = fopen(fileName.c_str(), "r");
if ( file == NULL ) break;
@@ -4957,14 +4623,6 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
j ++;
break;
}
-
-/* TODO: #if _TEEN
- if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed )
- {
- j ++;
- break;
- }
-#endif*/
}
BuildSceneName(fileName, m_sceneName, (chap+1)*100+(j+1));
@@ -4998,8 +4656,7 @@ void CMainDialog::ShowSoluceUpdate()
m_phase == PHASE_MISSION ||
m_phase == PHASE_FREE ||
m_phase == PHASE_TEEN ||
- m_phase == PHASE_USER ||
- m_phase == PHASE_PROTO )
+ m_phase == PHASE_USER )
{
m_bSceneSoluce = false;
@@ -5456,13 +5113,6 @@ void CMainDialog::UpdateSetupButtons()
value = static_cast<float>(m_sound->GetMusicVolume());
ps->SetVisibleValue(value);
}
-
- pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D));
- if ( pc != 0 )
- {
- pc->SetState(STATE_CHECK, m_sound->GetSound3D());
- pc->SetState(STATE_ENABLE, m_sound->GetSound3DCap());
- }
}
// Updates the engine function of the buttons after the setup phase.
@@ -5564,7 +5214,6 @@ void CMainDialog::SetupMemorize()
GetProfile().SetLocalProfileInt("Setup", "TotoMode", m_engine->GetTotoMode());
GetProfile().SetLocalProfileInt("Setup", "AudioVolume", m_sound->GetAudioVolume());
GetProfile().SetLocalProfileInt("Setup", "MusicVolume", m_sound->GetMusicVolume());
- GetProfile().SetLocalProfileInt("Setup", "Sound3D", m_sound->GetSound3D());
GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode());
GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue());
@@ -5601,21 +5250,7 @@ void CMainDialog::SetupMemorize()
GetProfile().SetLocalProfileString("Setup", "KeyMap", key.str());
-#if _NET
- if ( m_accessEnable )
- {
- iValue = m_accessMission;
- SetLocalProfileInt("Setup", "AccessMission", iValue);
-
- iValue = m_accessUser;
- SetLocalProfileInt("Setup", "AccessUser", iValue);
- }
-#endif
-
GetProfile().SetLocalProfileInt("Setup", "DeleteGamer", m_bDeleteGamer);
-
- // TODO: write graphic engine profile
- //m_engine->WriteProfile();
}
// Remember all the settings.
@@ -5802,11 +5437,6 @@ void CMainDialog::SetupRecall()
m_sound->SetMusicVolume(iValue);
}
- if ( GetProfile().GetLocalProfileInt("Setup", "Sound3D", iValue) )
- {
- m_sound->SetSound3D(iValue == 1);
- }
-
if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
{
m_engine->SetEditIndentMode(iValue);
@@ -5830,21 +5460,6 @@ void CMainDialog::SetupRecall()
}
}
-#if _NET
- if ( m_accessEnable )
- {
- if ( GetProfile().GetLocalProfileInt("Setup", "AccessMission", iValue) )
- {
- m_accessMission = iValue;
- }
-
- if ( GetProfile().GetLocalProfileInt("Setup", "AccessUser", iValue) )
- {
- m_accessUser = iValue;
- }
- }
-#endif
-
if ( GetProfile().GetLocalProfileInt("Setup", "DeleteGamer", iValue) )
{
m_bDeleteGamer = iValue;
@@ -6026,7 +5641,7 @@ void CMainDialog::StartAbort()
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
- char name[100];
+ std::string name;
StartDialog(Math::Point(0.3f, 0.8f), true, false, false);
m_bDialogDelete = false;
@@ -6047,10 +5662,6 @@ void CMainDialog::StartAbort()
pos.x = 0.40f;
dim.x = 0.20f;
-/* TODO: #if _POLISH
- pos.x -= 7.0f/640.0f;
- dim.x += 14.0f/640.0f;
-#endif*/
dim.y = 32.0f/480.0f;
pos.y = 0.74f;
@@ -6105,7 +5716,7 @@ void CMainDialog::StartDeleteObject()
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
- char name[100];
+ std::string name;
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
@@ -6139,21 +5750,22 @@ void CMainDialog::StartDeleteGame(char *gamer)
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
- char name[100];
- char text[100];
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
- if ( pw == 0 ) return;
+ if (pw == nullptr)
+ return;
+
+ std::string name;
pos.x = 0.00f;
pos.y = 0.50f;
dim.x = 1.00f;
dim.y = 0.05f;
GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
- sprintf(text, name, gamer);
+ std::string text = StrUtils::Format(name.c_str(), gamer);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, text);
pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
@@ -6175,12 +5787,14 @@ void CMainDialog::StartQuit()
CWindow* pw;
CButton* pb;
Math::Point pos, dim;
- char name[100];
StartDialog(Math::Point(0.6f, 0.3f), false, true, true);
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
- if ( pw == 0 ) return;
+ if (pw == nullptr)
+ return;
+
+ std::string name;
pos.x = 0.00f;
pos.y = 0.50f;
@@ -6208,7 +5822,6 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance
CWindow* pw;
CButton* pb;
Math::Point pos, ddim;
- char name[100];
StartSuspend();
@@ -6247,6 +5860,8 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance
m_bDialogFire = bFire;
+ std::string name;
+
pos.x = (1.0f-dim.x)/2.0f;
pos.y = (1.0f-dim.y)/2.0f;
pw = m_interface->CreateWindows(pos, dim, bFire?12:8, EVENT_WINDOW9);
@@ -6442,8 +6057,8 @@ void CMainDialog::StartSuspend()
{
m_sound->MuteAll(true);
m_main->ClearInterface();
- m_bInitPause = m_engine->GetPause();
- m_engine->SetPause(true);
+ m_bInitPause = m_pause->GetPauseType();
+ m_pause->SetPause(PAUSE_DIALOG);
m_engine->SetOverFront(false); // over flat behind
m_main->CreateShortcuts();
m_main->StartSuspend();
@@ -6457,7 +6072,7 @@ void CMainDialog::StopSuspend()
{
m_sound->MuteAll(false);
m_main->ClearInterface();
- if ( !m_bInitPause ) m_engine->SetPause(false);
+ m_pause->SetPause(m_bInitPause);
m_engine->SetOverFront(true); // over flat front
m_main->CreateShortcuts();
m_main->StopSuspend();
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index 96aff2a..444a568 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -23,6 +23,8 @@
#include "object/robotmain.h"
+#include "app/pausemanager.h"
+
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
@@ -186,6 +188,7 @@ protected:
Gfx::CParticle* m_particle;
Gfx::CCamera* m_camera;
CSoundInterface* m_sound;
+ CPauseManager* m_pause;
Phase m_phase; // copy of CRobotMain
Phase m_phaseSetup; // tab selected
@@ -242,26 +245,26 @@ protected:
bool m_bCameraInvertY; // for CCamera
bool m_bEffect; // for CCamera
- Math::Point m_glintMouse;
- float m_glintTime;
+ Math::Point m_glintMouse;
+ float m_glintTime;
- int m_loadingCounter;
+ int m_loadingCounter;
- bool m_bDialog; // this dialogue?
- bool m_bDialogFire; // setting on fire?
- bool m_bDialogDelete;
- Math::Point m_dialogPos;
- Math::Point m_dialogDim;
- float m_dialogParti;
- float m_dialogTime;
- bool m_bInitPause;
+ bool m_bDialog; // this dialogue?
+ bool m_bDialogFire; // setting on fire?
+ bool m_bDialogDelete;
+ Math::Point m_dialogPos;
+ Math::Point m_dialogDim;
+ float m_dialogParti;
+ float m_dialogTime;
+ PauseType m_bInitPause;
Gfx::CameraType m_initCamera;
- int m_partiPhase[10];
- float m_partiTime[10];
- Math::Point m_partiPos[10];
+ int m_partiPhase[10];
+ float m_partiTime[10];
+ Math::Point m_partiPos[10];
- SceneInfo m_sceneInfo[MAXSCENE];
+ SceneInfo m_sceneInfo[MAXSCENE];
std::vector<fs::path> m_saveList;
};
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index d33482c..f6dce4b 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -97,7 +97,6 @@ bool CMainShort::CreateShortcuts()
ObjectType type;
Math::Point pos, dim;
int i, rank, icon;
- char name[100];
if ( m_main->GetFixScene() ) return false;
@@ -208,10 +207,11 @@ bool CMainShort::CreateShortcuts()
m_shortcuts[rank] = pObj;
pc = m_interface->SearchControl(table_sc_em[rank]);
- if ( pc != 0 )
+ if ( pc != nullptr )
{
- pObj->GetTooltipName(name);
- pc->SetTooltip(name);
+ std::string tooltipName;
+ pObj->GetTooltipName(tooltipName);
+ pc->SetTooltip(tooltipName);
}
rank ++;
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index e44a465..f83704e 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -71,6 +71,7 @@ CStudio::CStudio()
m_main = CRobotMain::GetInstancePointer();
m_interface = m_main->GetInterface();
m_camera = m_main->GetCamera();
+ m_pause = CPauseManager::GetInstancePointer();
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -97,7 +98,6 @@ bool CStudio::EventProcess(const Event &event)
CWindow* pw;
CEdit* edit;
CSlider* slider;
- char res[100];
if ( m_dialog != SD_NULL ) // dialogue exists?
{
@@ -184,17 +184,17 @@ bool CStudio::EventProcess(const Event &event)
if ( event.type == EVENT_STUDIO_COMPILE ) // compile?
{
- char buffer[100];
-
if ( m_script->GetScript(edit) ) // compile
{
+ std::string res;
GetResource(RES_TEXT, RT_STUDIO_COMPOK, res);
SetInfoText(res, false);
}
else
{
- m_script->GetError(buffer);
- SetInfoText(buffer, false);
+ std::string error;
+ m_script->GetError(error);
+ SetInfoText(error, false);
}
}
@@ -218,9 +218,9 @@ bool CStudio::EventProcess(const Event &event)
}
else
{
- char buffer[100];
- m_script->GetError(buffer);
- SetInfoText(buffer, false);
+ std::string error;
+ m_script->GetError(error);
+ SetInfoText(error, false);
}
}
}
@@ -344,7 +344,6 @@ bool CStudio::EventFrame(const Event &event)
CList* list;
float time;
int cursor1, cursor2, iCursor1, iCursor2;
- char res[100];
m_time += event.rTime;
m_fixInfoTextTime -= event.rTime;
@@ -363,6 +362,7 @@ bool CStudio::EventFrame(const Event &event)
m_bRunning = false;
UpdateFlux(); // stop
AdjustEditScript();
+ std::string res;
GetResource(RES_TEXT, RT_STUDIO_PROGSTOP, res);
SetInfoText(res, false);
@@ -558,14 +558,13 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank)
CButton* button;
CSlider* slider;
CList* list;
- char res[100];
m_script = script;
m_rank = rank;
m_main->SetEditLock(true, true);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->GetPause();
+ m_bInitPause = m_pause->GetPauseType();
m_main->SetSpeed(1.0f);
m_editCamera = m_camera->GetType();
m_camera->SetType(Gfx::CAM_TYPE_EDIT);
@@ -575,28 +574,33 @@ void CStudio::StartEditScript(CScript *script, std::string name, int rank)
m_script->SetStepMode(!m_bRealTime);
button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT));
- if ( button != 0 )
- {
+ if (button != nullptr)
button->ClearState(STATE_VISIBLE);
- }
pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos();
dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim();
pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3);
- if ( pw == nullptr ) return;
+ if (pw == nullptr)
+ return;
+
pw->SetState(STATE_SHADOW);
pw->SetRedim(true); // before SetName!
pw->SetMovable(true);
pw->SetClosable(true);
+
+ std::string res;
GetResource(RES_TEXT, RT_STUDIO_TITLE, res);
pw->SetName(res);
+
pw->SetMinDim(Math::Point(0.49f, 0.50f));
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
m_main->SetEditFull(m_bEditMaximized);
edit = pw->CreateEdit(pos, dim, 0, EVENT_STUDIO_EDIT);
- if ( edit == 0 ) return;
+ if (edit == nullptr)
+ return;
+
edit->SetState(STATE_SHADOW);
edit->SetInsideScroll(false);
//? if ( m_bRunning ) edit->SetEdit(false);
@@ -851,7 +855,6 @@ bool CStudio::StopEditScript(bool bCancel)
CWindow* pw;
CEdit* edit;
CButton* button;
- char buffer[100];
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw == nullptr ) return false;
@@ -863,8 +866,9 @@ bool CStudio::StopEditScript(bool bCancel)
{
if ( !m_script->GetScript(edit) ) // compile
{
- m_script->GetError(buffer);
- SetInfoText(buffer, false);
+ std::string error;
+ m_script->GetError(error);
+ SetInfoText(error, false);
return false;
}
}
@@ -879,7 +883,7 @@ bool CStudio::StopEditScript(bool bCancel)
button->SetState(STATE_VISIBLE);
}
- if ( !m_bInitPause ) m_engine->SetPause(false);
+ m_pause->SetPause(m_bInitPause);
m_sound->MuteAll(false);
m_main->SetEditLock(false, true);
m_camera->SetType(m_editCamera);
@@ -892,8 +896,6 @@ bool CStudio::StopEditScript(bool bCancel)
void CStudio::SetInfoText(std::string text, bool bClickable)
{
- char res[100];
-
if ( bClickable && m_fixInfoTextTime > 0.0f ) return;
if ( !bClickable ) m_fixInfoTextTime = 8.0f;
@@ -911,6 +913,7 @@ void CStudio::SetInfoText(std::string text, bool bClickable)
if ( bClickable )
{
+ std::string res;
GetResource(RES_TEXT, RT_STUDIO_LISTTT, res);
list->SetTooltip(res);
list->SetState(STATE_ENABLE);
@@ -952,22 +955,22 @@ void CStudio::UpdateFlux()
#if 1
if ( m_bRealTime ) // run?
{
- m_engine->SetPause(false);
+ m_pause->ClearPause();
m_sound->MuteAll(false);
}
else // step by step?
{
- m_engine->SetPause(true);
+ m_pause->SetPause(PAUSE_EDITOR);
m_sound->MuteAll(true);
}
#else
- m_engine->SetPause(false);
+ m_pause->ClearPause();
m_sound->MuteAll(false);
#endif
}
else // stop?
{
- m_engine->SetPause(true);
+ m_pause->SetPause(PAUSE_EDITOR);
m_sound->MuteAll(true);
}
}
@@ -1029,7 +1032,7 @@ void CStudio::StartDialog(StudioDialog type)
CList* pli;
CEdit* pe;
Math::Point pos, dim;
- char name[100];
+ std::string name;
m_dialog = type;
@@ -1108,17 +1111,11 @@ void CStudio::StartDialog(StudioDialog type)
GetResource(RES_TEXT, RT_IO_PRIVATE, name);
pc->SetName(name);
pc->SetState(STATE_SHADOW);
-#if _POLISH
- pc->SetFontSize(8.0f);
-#endif
pc = pw->CreateCheck(pos, dim, 0, EVENT_DIALOG_CHECK2);
GetResource(RES_TEXT, RT_IO_PUBLIC, name);
pc->SetName(name);
pc->SetState(STATE_SHADOW);
-#if _POLISH
- pc->SetFontSize(8.0f);
-#endif
pb = pw->CreateButton(pos, dim, -1, EVENT_DIALOG_OK);
pb->SetState(STATE_SHADOW);
@@ -1476,8 +1473,6 @@ void CStudio::UpdateDialogPublic()
CWindow* pw;
CCheck* pc;
CLabel* pl;
- char name[100];
- //char text[MAX_FNAME+100];
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == nullptr ) return;
@@ -1497,7 +1492,7 @@ void CStudio::UpdateDialogPublic()
pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1));
if ( pl != 0 )
{
- GetResource(RES_TEXT, RT_IO_LIST, name);
+ // GetResource(RES_TEXT, RT_IO_LIST, name); // TODO: unused?
pl->SetName(SearchDirectory(false).c_str(), false);
}
}
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 1c14124..d1c6a51 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -22,6 +22,8 @@
#include "graphics/engine/camera.h"
+#include "app/pausemanager.h"
+
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
@@ -96,6 +98,7 @@ protected:
CSoundInterface* m_sound;
CInterface* m_interface;
CApplication* m_app;
+ CPauseManager* m_pause;
int m_rank;
CScript* m_script;
@@ -109,11 +112,11 @@ protected:
Math::Point m_editFinalPos;
Math::Point m_editFinalDim;
- float m_time;
- float m_fixInfoTextTime;
- bool m_bRunning;
- bool m_bRealTime;
- bool m_bInitPause;
+ float m_time;
+ float m_fixInfoTextTime;
+ bool m_bRunning;
+ bool m_bRealTime;
+ PauseType m_bInitPause;
std::string m_helpFilename;
StudioDialog m_dialog;
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 6e082e6..98e1e6c 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -788,7 +788,7 @@ bool CWindow::GetFixed()
void CWindow::AdjustButtons()
{
- char res[100];
+ std::string res;
if ( m_buttonFull != 0 )
{
@@ -796,13 +796,13 @@ void CWindow::AdjustButtons()
{
m_buttonFull->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonFull->SetTooltip(std::string(res));
+ m_buttonFull->SetTooltip(res);
}
else
{
m_buttonFull->SetIcon(52);
GetResource(RES_TEXT, RT_WINDOW_MAXIMIZED, res);
- m_buttonFull->SetTooltip(std::string(res));
+ m_buttonFull->SetTooltip(res);
}
}
@@ -812,13 +812,13 @@ void CWindow::AdjustButtons()
{
m_buttonReduce->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonReduce->SetTooltip(std::string(res));
+ m_buttonReduce->SetTooltip(res);
}
else
{
m_buttonReduce->SetIcon(51);
GetResource(RES_TEXT, RT_WINDOW_MINIMIZED, res);
- m_buttonReduce->SetTooltip(std::string(res));
+ m_buttonReduce->SetTooltip(res);
}
}
@@ -826,7 +826,7 @@ void CWindow::AdjustButtons()
{
m_buttonClose->SetIcon(11); // x
GetResource(RES_TEXT, RT_WINDOW_CLOSE, res);
- m_buttonClose->SetTooltip(std::string(res));
+ m_buttonClose->SetTooltip(res);
}
}
@@ -1536,8 +1536,6 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
void CWindow::DrawHach(Math::Point pos, Math::Point dim)
{
-#if _NEWLOOK
-#else
Math::Point ppos, ddim, uv1, uv2;
float dp, max, ndim;
bool bStop;
@@ -1575,7 +1573,6 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
ppos.x += ddim.x;
}
while ( !bStop );
-#endif
}
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2618698..e6c67d9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,5 @@
# Compile flags as defined in global CMakeLists
-set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${MXE_CFLAGS}")
+set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${MXE_CFLAGS} ${COLOBOT_GTEST_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
diff --git a/test/envs/opengl/light_test.cpp b/test/envs/opengl/light_test.cpp
index 227ca2a..5c5af7c 100644
--- a/test/envs/opengl/light_test.cpp
+++ b/test/envs/opengl/light_test.cpp
@@ -78,7 +78,7 @@ void Render(Gfx::CGLDevice *device)
worldMat.LoadIdentity();
device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
- Gfx::VertexCol line[2] = { Gfx::VertexCol() };
+ Gfx::VertexCol line[2] = {};
for (int x = -40; x <= 40; ++x)
{
@@ -103,7 +103,7 @@ void Render(Gfx::CGLDevice *device)
}
- Gfx::VertexCol quad[6] = { Gfx::VertexCol() };
+ Gfx::VertexCol quad[6] = {};
quad[0].coord = Math::Vector(-1.0f, -1.0f, 0.0f);
quad[1].coord = Math::Vector( 1.0f, -1.0f, 0.0f);
diff --git a/test/envs/opengl/transform_test.cpp b/test/envs/opengl/transform_test.cpp
index 58d8e9e..99ec9f0 100644
--- a/test/envs/opengl/transform_test.cpp
+++ b/test/envs/opengl/transform_test.cpp
@@ -73,7 +73,7 @@ void Render(Gfx::CGLDevice *device)
worldMat.LoadIdentity();
device->SetTransform(Gfx::TRANSFORM_WORLD, worldMat);
- Gfx::VertexCol line[2] = { Gfx::VertexCol() };
+ Gfx::VertexCol line[2] = {};
for (int x = -40; x <= 40; ++x)
{
@@ -98,7 +98,7 @@ void Render(Gfx::CGLDevice *device)
}
- Gfx::VertexCol quad[6] = { Gfx::VertexCol() };
+ Gfx::VertexCol quad[6] = {};
for (int i = 0; i < 6; ++i)
quad[i].color = Gfx::Color(1.0f, 1.0f, 0.0f);
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 38bffda..bdb5a67 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -6,6 +6,8 @@ if(MXE) # MXE requires special treatment
elseif(PLATFORM_WINDOWS)
# because it isn't included in standard linking libraries
set(PLATFORM_LIBS "-lintl")
+elseif(PLATFORM_GNU)
+ set(PLATFORM_LIBS "-lX11")
elseif(PLATFORM_LINUX)
# for clock_gettime
set(PLATFORM_LIBS "-lrt -lX11")
@@ -21,6 +23,8 @@ configure_file(${SRC_DIR}/common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/comm
# Code sources
set(COLOBOT_SOURCES
${SRC_DIR}/app/app.cpp
+${SRC_DIR}/app/gamedata.cpp
+${SRC_DIR}/app/pausemanager.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
diff --git a/test/unit/graphics/core/device_mock.h b/test/unit/graphics/core/device_mock.h
index 9e75daf..498239f 100644
--- a/test/unit/graphics/core/device_mock.h
+++ b/test/unit/graphics/core/device_mock.h
@@ -105,4 +105,6 @@ public:
MOCK_METHOD1(SetFillMode, void(Gfx::FillMode mode));
MOCK_METHOD0(GetFillMode, Gfx::FillMode());
+
+ MOCK_CONST_METHOD0(GetFrameBufferPixels, void*());
};
diff --git a/test/unit/ui/CMakeLists.txt b/test/unit/ui/CMakeLists.txt
index 8086967..7f7b2f8 100644
--- a/test/unit/ui/CMakeLists.txt
+++ b/test/unit/ui/CMakeLists.txt
@@ -10,8 +10,6 @@ ${CLIPBOARD_INCLUDE_DIR}
# Platform-dependent implementation of CSystemUtils
if(PLATFORM_WINDOWS)
-elseif(PLATFORM_LINUX)
- set(ADDITIONAL_LIB "-lX11")
elseif(PLATFORM_MACOSX)
set(ADDITIONAL_LIB "${X11_X11_LIB}")
else()
@@ -19,6 +17,7 @@ else()
endif()
add_executable(edit_test
+${SRC_DIR}/app/gamedata.cpp
${SRC_DIR}/app/system.cpp
${SRC_DIR}/app/${SYSTEM_CPP_MODULE}
${SRC_DIR}/app/system_other.cpp
diff --git a/test/unit/ui/edit_test.cpp b/test/unit/ui/edit_test.cpp
index 21af00f..34af013 100644
--- a/test/unit/ui/edit_test.cpp
+++ b/test/unit/ui/edit_test.cpp
@@ -1,4 +1,5 @@
#include "app/app.h"
+#include "app/gamedata.h"
#include "ui/edit.h"
@@ -14,6 +15,7 @@ class CEditTest : public testing::Test
public:
CEditTest()
: m_robotMain(nullptr)
+ , m_gameData(nullptr)
, m_engine(nullptr)
, m_edit(nullptr)
{}
@@ -21,21 +23,24 @@ public:
virtual void SetUp()
{
m_robotMain = new CRobotMain(&m_app, false);
-
+
+ m_gameData = new CGameData();
+
m_engine = new Gfx::CEngine(nullptr);
-
+
m_edit = new Ui::CEdit;
}
virtual void TearDown()
{
- delete m_robotMain;
- m_robotMain = nullptr;
- delete m_engine;
- m_engine = nullptr;
delete m_edit;
m_edit = nullptr;
-
+ delete m_engine;
+ m_engine = nullptr;
+ delete m_gameData;
+ m_gameData = nullptr;
+ delete m_robotMain;
+ m_robotMain = nullptr;
}
virtual ~CEditTest()
{
@@ -45,12 +50,14 @@ public:
protected:
CApplication m_app;
CRobotMain* m_robotMain;
+ CGameData * m_gameData;
Gfx::CEngine * m_engine;
Ui::CEdit * m_edit;
CLogger m_logger;
};
using ::testing::_;
+using ::testing::An;
using ::testing::Return;
TEST_F(CEditTest, WriteTest)
@@ -58,7 +65,7 @@ TEST_F(CEditTest, WriteTest)
ASSERT_TRUE(true);
CTextMock * text = dynamic_cast<CTextMock *>(m_engine->GetText());
EXPECT_CALL(*text, GetCharWidth(_, _, _, _)).WillRepeatedly(Return(1.0f));
- EXPECT_CALL(*text, GetStringWidth(_, _, _, _)).WillOnce(Return(1.0f));
+ EXPECT_CALL(*text, GetStringWidth(An<const std::string&>(), _, _, _)).WillOnce(Return(1.0f));
std::string filename = "test.file";
m_edit->SetMaxChar(Ui::EDITSTUDIOMAX);
m_edit->SetAutoIndent(true);
diff --git a/test/unit/ui/mocks/text_mock.h b/test/unit/ui/mocks/text_mock.h
index f38b977..b9af6d3 100644
--- a/test/unit/ui/mocks/text_mock.h
+++ b/test/unit/ui/mocks/text_mock.h
@@ -15,11 +15,21 @@ public:
{
};
- MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char, Gfx::FontType, float, float));
+ MOCK_METHOD4(GetCharWidth, float(Gfx::UTF8Char ch,
+ Gfx::FontType type,
+ float size,
+ float offset));
MOCK_METHOD4(GetStringWidth, float(const std::string &text,
std::vector<Gfx::FontMetaChar>::iterator format,
- std::vector<Gfx::FontMetaChar>::iterator end, float size));
- MOCK_METHOD3(GetStringWidth, float(const std::string &, Gfx::FontType, float));
+ std::vector<Gfx::FontMetaChar>::iterator end,
+ float size));
+ MOCK_METHOD3(GetStringWidth, float(std::string text,
+ Gfx::FontType font,
+ float size));
+ MOCK_METHOD4(GetStringWidth, float(Gfx::UTF8Char ch,
+ Gfx::FontType font,
+ float size,
+ float offset));
};
diff --git a/test/unit/ui/stubs/app_stub.cpp b/test/unit/ui/stubs/app_stub.cpp
index 960972f..95430d8 100644
--- a/test/unit/ui/stubs/app_stub.cpp
+++ b/test/unit/ui/stubs/app_stub.cpp
@@ -21,11 +21,6 @@ CApplication::~CApplication()
{
}
-std::string CApplication::GetDataFilePath(DataDir /* dataDir */, const std::string& subpath) const
-{
- return subpath;
-}
-
CSoundInterface* CApplication::GetSound()
{
return nullptr;
@@ -36,11 +31,6 @@ CEventQueue* CApplication::GetEventQueue()
return nullptr;
}
-std::string CApplication::GetDataDirPath() const
-{
- return "";
-}
-
Event CApplication::CreateUpdateEvent()
{
return Event(EVENT_NULL);
diff --git a/test/unit/ui/stubs/restext_stub.cpp b/test/unit/ui/stubs/restext_stub.cpp
index 004da19..fa47da6 100644
--- a/test/unit/ui/stubs/restext_stub.cpp
+++ b/test/unit/ui/stubs/restext_stub.cpp
@@ -1,6 +1,6 @@
#include "common/restext.h"
-bool GetResource(ResType /* type */, int /* num */, char* /* text */)
+bool GetResource(ResType /* type */, int /* num */, std::string& /* text */)
{
return true;
}
diff --git a/tools/check-levels.sh b/tools/check-levels.sh
new file mode 100755
index 0000000..22544fb
--- /dev/null
+++ b/tools/check-levels.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# Runs every level in scenetest mode
+
+levels=`ls /usr/local/share/games/colobot/levels | cut -d "." -f 1`
+for level in $levels; do
+ echo $level
+ colobot -runscene $level -scenetest -loglevel warn
+done