Merge branch 'dev' into dev-cbot-factory

1164-fix
Fiftytwo 2020-06-16 20:07:03 +02:00
commit 5c0cfba8ae
653 changed files with 11026 additions and 4082 deletions

7
.gitignore vendored
View File

@ -38,3 +38,10 @@ CMakeLists.txt.user.*
# Ignore Visual Studio Code files # Ignore Visual Studio Code files
/.vscode /.vscode
# Ignore CLion files
/.idea
# Ignore Visual Studio files
/CMakeSettings.json
/.vs

View File

@ -13,7 +13,7 @@ project(colobot C CXX)
set(COLOBOT_VERSION_CODENAME "Gold") set(COLOBOT_VERSION_CODENAME "Gold")
set(COLOBOT_VERSION_MAJOR 0) set(COLOBOT_VERSION_MAJOR 0)
set(COLOBOT_VERSION_MINOR 1) set(COLOBOT_VERSION_MINOR 1)
set(COLOBOT_VERSION_REVISION 11) set(COLOBOT_VERSION_REVISION 12)
# Used on official releases # Used on official releases
#set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha") #set(COLOBOT_VERSION_RELEASE_CODENAME "-alpha")
@ -60,6 +60,7 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
set(PLATFORM_GNU 0) set(PLATFORM_GNU 0)
set(PLATFORM_LINUX 0) set(PLATFORM_LINUX 0)
set(PLATFORM_MACOSX 0) set(PLATFORM_MACOSX 0)
set(PLATFORM_FREEBSD 0)
set(PLATFORM_OTHER 0) set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h # Platform-dependent implementation of system.h
@ -71,6 +72,7 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(PLATFORM_LINUX 1) set(PLATFORM_LINUX 1)
set(PLATFORM_GNU 1) set(PLATFORM_GNU 1)
set(PLATFORM_MACOSX 0) set(PLATFORM_MACOSX 0)
set(PLATFORM_FREEBSD 0)
set(PLATFORM_OTHER 0) set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h # Platform-dependent implementation of system.h
@ -82,6 +84,7 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "kFreeBSD" OR "${CMAKE_SYSTEM_NAME}" STREQ
set(PLATFORM_LINUX 0) set(PLATFORM_LINUX 0)
set(PLATFORM_GNU 1) set(PLATFORM_GNU 1)
set(PLATFORM_MACOSX 0) set(PLATFORM_MACOSX 0)
set(PLATFORM_FREEBSD 0)
set(PLATFORM_OTHER 0) set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h # Platform-dependent implementation of system.h
@ -94,18 +97,35 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(PLATFORM_GNU 0) set(PLATFORM_GNU 0)
set(PLATFORM_MACOSX 1) set(PLATFORM_MACOSX 1)
set(PLATFORM_OTHER 0) set(PLATFORM_OTHER 0)
set(PLATFORM_FREEBSD 0)
# Platform-dependent implementation of system.h # Platform-dependent implementation of system.h
set(SYSTEM_CPP_MODULE "system_macosx.cpp") set(SYSTEM_CPP_MODULE "system_macosx.cpp")
set(SYSTEM_H_MODULE "system_macosx.h") set(SYSTEM_H_MODULE "system_macosx.h")
# To avoid CMake warning # To avoid CMake warning
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
message(STATUS "Build for FreeBSD system")
set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0)
set(PLATFORM_GNU 0)
set(PLATFORM_MACOSX 0)
set(PLATFORM_FREEBSD 1)
set(PLATFORM_OTHER 0)
# Platform-dependent implementation of system.h
# On FreeBSD we can use *_other
set(SYSTEM_CPP_MODULE "system_other.cpp")
set(SYSTEM_H_MODULE "system_other.h")
# To avoid CMake warning
set(CMAKE_MACOSX_RPATH 1)
else() else()
message(STATUS "Build for other system") message(STATUS "Build for other system")
set(PLATFORM_WINDOWS 0) set(PLATFORM_WINDOWS 0)
set(PLATFORM_LINUX 0) set(PLATFORM_LINUX 0)
set(PLATFORM_GNU 0) set(PLATFORM_GNU 0)
set(PLATFORM_MACOSX 0) set(PLATFORM_MACOSX 0)
set(PLATFORM_FREEBSD 0)
set(PLATFORM_OTHER 1) set(PLATFORM_OTHER 1)
# Platform-dependent implementation of system.h # Platform-dependent implementation of system.h
@ -124,6 +144,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# Include cmake directory with some additional scripts # Include cmake directory with some additional scripts
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# MSVC needs different flags if linking statically
option(MSVC_STATIC "Link statically when using MSVC" OFF)
# Compiler detection # Compiler detection
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
@ -132,8 +155,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "Detected GCC version 4.7+") message(STATUS "Detected GCC version 4.7+")
set(NORMAL_CXX_FLAGS "-std=gnu++11 -Wall -Werror -Wold-style-cast -pedantic-errors") set(NORMAL_CXX_FLAGS "-std=gnu++11 -Wall -Werror -Wold-style-cast -pedantic-errors -Wmissing-declarations")
set(NORMAL_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-error=deprecated-declarations") # updated version of physfs is not available on some platforms so we keep using deprecated functions, see #958 set(NORMAL_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-error=deprecated-declarations") # updated version of physfs is not available on some platforms so we keep using deprecated functions, see #958
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
set(NORMAL_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wsuggest-override")
endif()
set(RELEASE_CXX_FLAGS "-O2") set(RELEASE_CXX_FLAGS "-O2")
set(DEBUG_CXX_FLAGS "-g -O0") set(DEBUG_CXX_FLAGS "-g -O0")
set(TEST_CXX_FLAGS "-pthread") set(TEST_CXX_FLAGS "-pthread")
@ -145,7 +173,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Detected Clang version 3.1+") message(STATUS "Detected Clang version 3.1+")
set(NORMAL_CXX_FLAGS "-std=c++11 -Wall -Werror -Wold-style-cast -pedantic-errors") if (${PLATFORM_FREEBSD})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=bfd")
endif()
set(NORMAL_CXX_FLAGS "-std=c++11 -Wall -Werror -Wold-style-cast -pedantic-errors -Wmissing-prototypes")
set(NORMAL_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-error=deprecated-declarations") # updated version of physfs is not available on some platforms so we keep using deprecated functions, see #958 set(NORMAL_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-error=deprecated-declarations") # updated version of physfs is not available on some platforms so we keep using deprecated functions, see #958
set(RELEASE_CXX_FLAGS "-O2") set(RELEASE_CXX_FLAGS "-O2")
set(DEBUG_CXX_FLAGS "-g -O0") set(DEBUG_CXX_FLAGS "-g -O0")
@ -155,14 +187,19 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
message(STATUS "Detected MSVC compiler") message(STATUS "Detected MSVC compiler")
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
set(RELEASE_CXX_FLAGS "/MD") if(MSVC_STATIC)
set(DEBUG_CXX_FLAGS "/MDd /ZI") set(RELEASE_CXX_FLAGS "/MT /Ox")
set(DEBUG_CXX_FLAGS "/MTd /ZI")
else(MSVC_STATIC)
set(RELEASE_CXX_FLAGS "/MD /Ox")
set(DEBUG_CXX_FLAGS "/MDd /ZI")
endif()
set(TEST_CXX_FLAGS "") set(TEST_CXX_FLAGS "")
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG) add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
# Needed for Debug information (it's set to "No" by default for some reason) # Needed for Debug information (it's set to "No" by default for some reason)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:LIBCMT")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG") set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
else() else()
message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.") message(FATAL_ERROR "Your C++ compiler doesn't seem to be supported.")
endif() endif()
@ -191,11 +228,17 @@ option(DEV_BUILD "Enable development build (enables some debugging tools, local
# Official build - changes text on the crash screen # Official build - changes text on the crash screen
# PLEASE DO NOT USE ON UNOFFICIAL BUILDS. Thanks. # PLEASE DO NOT USE ON UNOFFICIAL BUILDS. Thanks.
option(OFFICIAL_BUILD "Official build (changes crash screen text)" OFF) option(OFFICIAL_COLOBOT_BUILD "Official build (changes crash screen text)" OFF)
# Portable build - load all data from current directory # Hardcode relative paths instead of absolute paths
option(USE_RELATIVE_PATHS "Generate relative paths from absolute paths" OFF)
# Portable build - load all data from the base directory
option(PORTABLE "Portable build" OFF) option(PORTABLE "Portable build" OFF)
# Portable saves - suitable for e.g. putting the whole game on external storage and moving your saves with it
option(PORTABLE_SAVES "Portable saves" OFF)
# Building tests can be enabled/disabled # Building tests can be enabled/disabled
option(TESTS "Build tests" OFF) option(TESTS "Build tests" OFF)
@ -307,6 +350,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CBOT_STATIC 1) # only this works for some reason set(CBOT_STATIC 1) # only this works for some reason
set(WINGETOPT 1) # use wingetopt library set(WINGETOPT 1) # use wingetopt library
# Hide console in release builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_WIN32_EXECUTABLE 1)
endif()
endif() endif()
## ##
@ -345,21 +393,19 @@ endif()
## ##
# Installation paths defined before compiling sources # Installation paths defined before compiling sources
if(PLATFORM_WINDOWS) if(PORTABLE OR (PLATFORM_WINDOWS AND MXE))
if(MXE) set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory")
# We need to use STRING because PATH doesn't accept relative paths set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory")
set(COLOBOT_INSTALL_BIN_DIR ./ CACHE STRING "Colobot binary directory") set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory")
set(COLOBOT_INSTALL_LIB_DIR ./ CACHE STRING "Colobot libraries directory") set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory")
set(COLOBOT_INSTALL_DATA_DIR ./data CACHE STRING "Colobot shared data directory") set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
set(COLOBOT_INSTALL_I18N_DIR ./lang CACHE STRING "Colobot translations directory") set(USE_RELATIVE_PATHS ON)
set(COLOBOT_INSTALL_DOC_DIR ./doc CACHE STRING "Colobot documentation directory") elseif(PLATFORM_WINDOWS)
else() set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory")
set(COLOBOT_INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot binary directory") set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory")
set(COLOBOT_INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/ CACHE PATH "Colobot libraries directory") set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory")
set(COLOBOT_INSTALL_DATA_DIR ${CMAKE_INSTALL_PREFIX}/data CACHE PATH "Colobot shared data directory") set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory")
set(COLOBOT_INSTALL_I18N_DIR ${CMAKE_INSTALL_PREFIX}/lang CACHE PATH "Colobot translations directory") set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/doc CACHE PATH "Colobot documentation directory")
endif()
elseif(PLATFORM_MACOSX) elseif(PLATFORM_MACOSX)
set(COLOBOT_INSTALL_BIN_DIR ../MacOS CACHE STRING "Colobot binary directory") set(COLOBOT_INSTALL_BIN_DIR ../MacOS CACHE STRING "Colobot binary directory")
set(COLOBOT_INSTALL_LIB_DIR ../MacOS CACHE STRING "Colobot libraries directory") set(COLOBOT_INSTALL_LIB_DIR ../MacOS CACHE STRING "Colobot libraries directory")
@ -374,6 +420,18 @@ else()
set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/share/doc/colobot CACHE PATH "Colobot documentation directory") set(COLOBOT_INSTALL_DOC_DIR ${CMAKE_INSTALL_PREFIX}/share/doc/colobot CACHE PATH "Colobot documentation directory")
endif() endif()
# Generate relative paths from absolute paths
if(USE_RELATIVE_PATHS)
message(STATUS "Generating relative paths")
file(RELATIVE_PATH COLOBOT_DATA_DIR ${COLOBOT_INSTALL_BIN_DIR} ${COLOBOT_INSTALL_DATA_DIR})
file(RELATIVE_PATH COLOBOT_I18N_DIR ${COLOBOT_INSTALL_BIN_DIR} ${COLOBOT_INSTALL_I18N_DIR})
add_definitions(-DUSE_RELATIVE_PATHS)
else()
set(COLOBOT_DATA_DIR ${COLOBOT_INSTALL_DATA_DIR})
set(COLOBOT_I18N_DIR ${COLOBOT_INSTALL_I18N_DIR})
endif()
# Subdirectory with sources # Subdirectory with sources
add_subdirectory(src) add_subdirectory(src)

View File

@ -71,7 +71,7 @@ You will need:
On Ubuntu (and probably any other Debian-based system), you can use the following command to install all required packages: 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 libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng12-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev libphysfs-dev gettext git po4a vorbis-tools $ apt-get install build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev libphysfs-dev gettext git po4a vorbis-tools
``` ```
Make sure you install the packages along with header files (often distributed in separate *-dev packages). If you miss any requirements, Make sure you install the packages along with header files (often distributed in separate *-dev packages). If you miss any requirements,

362
Jenkinsfile vendored
View File

@ -1,71 +1,297 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
if (env.BRANCH_NAME.startsWith('PR-')) {
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactNumToKeepStr: '1']]]) pipeline {
} else { agent none
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '20']]]) options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '20'))
}
stages {
stage('Check pull request target') {
when { changeRequest() }
steps {
script {
if (env.CHANGE_TARGET == 'master') {
throw "This pull request targets the wrong branch. Please reopen the pull request targetting the dev branch."
}
}
}
}
stage('Build') {
parallel {
stage('Build Windows') {
agent {
docker { image 'krzysh/colobot-build:latest' }
}
steps {
sh 'mkdir -p build/windows'
dir('build/windows') {
sh '''
# FIXME: without -lsetupapi linking sdl2 fails
rm -rf *
/opt/mxe/usr/bin/i686-w64-mingw32.static-cmake \
-DCMAKE_CXX_STANDARD_LIBRARIES="-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lsetupapi" \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=0 ../..
make
rm -rf install
DESTDIR=. make install
'''
}
}
post {
success {
sh 'rm -f windows-debug.zip'
zip zipFile: 'windows-debug.zip', archive: true, dir: 'build/windows/install'
}
}
}
stage('Build Linux') {
agent {
docker { image 'krzysh/colobot-build:latest' }
}
steps {
sh 'mkdir -p build/linux'
dir('build/linux') {
sh '''
rm -rf *
cmake \
-DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 ../..
make
rm -rf install
DESTDIR=. make install
patchelf --set-rpath '.' install/colobot
'''
}
}
post {
success {
sh 'rm -f linux-debug.zip'
dir('build/linux') {
sh '''
# Clean up
rm -rf squashfs-root
rm -rf colobot.AppDir
rm -rf appimage
rm -f Colobot-x86_64.AppImage
# Download app image tool
wget -N https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
./linuxdeploy-x86_64.AppImage --appimage-extract
# Create AppImage
NO_STRIP=1 ./squashfs-root/AppRun -e colobot --output appimage --appdir colobot.AppDir -d desktop/colobot.desktop -i ../../desktop/colobot.svg
#rename AppImage file to avoid "No such file or directory" errors
find . -maxdepth 1 -type f -name '*AppImage' -name 'Colobot*' -exec sh -c 'x="{}"; mv "$x" "Colobot-x86_64.AppImage"' \\;
chmod +x Colobot-x86_64.AppImage
# Prepare folder for zip
mkdir -p appimage
cp -rp install/data appimage/data
cp -rp install/lang appimage/lang
cp -p Colobot-x86_64.AppImage appimage/colobot
'''
}
zip zipFile: 'linux-debug.zip', archive: true, dir: 'build/linux/appimage'
}
}
}
}
}
stage('Generate docs') {
agent {
docker { image 'krzysh/colobot-build:latest' }
}
steps {
dir('build/linux') {
sh 'make doc'
}
}
post {
success {
publishHTML([reportName: 'Doxygen', reportDir: 'build/linux/doc/html', reportFiles: 'index.html', reportTitles: '', allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false])
}
}
}
stage('Run tests') {
agent {
docker { image 'krzysh/colobot-build:latest' }
}
steps {
dir('build/linux') {
sh './colobot_ut --gtest_output=xml:gtestresults.xml || true'
}
step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '0'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/linux/gtestresults.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])
}
// TODO: Maybe run Windows tests using wine as well?
}
stage('Run colobot-lint') {
agent {
label 'colobot-build'
}
environment {
CC = '/usr/lib/llvm-3.6/bin/clang'
CXX = '/usr/lib/llvm-3.6/bin/clang++'
CLANG_PREFIX = '/usr/lib/llvm-3.6'
}
steps {
copyArtifacts filter: 'build/colobot-lint,build/html_report.tar.gz,Tools/count_errors.py', fingerprintArtifacts: true, projectName: 'colobot/colobot-lint/master', selector: lastSuccessful(), target: 'colobot-lint'
sh 'chmod +x colobot-lint/Tools/count_errors.py' // TODO: ???
sh 'mkdir -p build/lint'
dir('build/lint') {
// The cd is required here because /var/lib/jenkins is a symlink and colobot-lint breaks otherwise...
sh 'cd $WORKSPACE/build/lint; cmake -DCOLOBOT_LINT_BUILD=1 -DTESTS=1 -DTOOLS=1 -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $WORKSPACE'
sh '''#!/bin/bash
set -e +x
# Run colobot-lint
COLOBOT_DIR="$WORKSPACE"
COLOBOT_BUILD_DIR="$WORKSPACE/build/lint"
COLOBOT_LINT_BUILD_DIR="$WORKSPACE/colobot-lint/build"
COLOBOT_LINT_REPORT_FILE="$WORKSPACE/build/lint/colobot_lint_report.xml"
# CLANG_PREFIX="/usr/lib/llvm-3.6" # Set in top-level environment block
cd "$COLOBOT_LINT_BUILD_DIR"
chmod +x ./colobot-lint
# Workaround for Clang not finding system headers
rm -rf bin/
mkdir -p bin
mv ./colobot-lint ./bin/
rm -f ./lib
ln -s ${CLANG_PREFIX}/lib ./lib
echo "Running colobot-lint"
find "$WORKSPACE" \\( -wholename "$COLOBOT_DIR/src/*.cpp" \
-or -wholename "$COLOBOT_DIR/test/unit/*.cpp" \
-or -wholename "$COLOBOT_BUILD_DIR/fake_header_sources/src/*.cpp" \
-or -wholename "$COLOBOT_BUILD_DIR/fake_header_sources/test/unit/*.cpp" \\) \
-exec ./bin/colobot-lint \
-verbose \
-output-format xml \
-output-file "$COLOBOT_LINT_REPORT_FILE" \
-p "$COLOBOT_BUILD_DIR" \
-project-local-include-path "$COLOBOT_DIR/src" -project-local-include-path "$COLOBOT_BUILD_DIR/src" \
-license-template-file "$COLOBOT_DIR/LICENSE-HEADER.txt" \
{} +
'''
sh '''#!/bin/bash
set -e +x
# Generate HTML report
COLOBOT_LINT_BUILD_DIR="$WORKSPACE/colobot-lint/build"
COLBOT_LINT_REPORT_FILE="$WORKSPACE/build/lint/colobot_lint_report.xml"
HTML_REPORT_DIR="$WORKSPACE/build/lint/html_report"
echo "Generating HTML report"
cd "$COLOBOT_LINT_BUILD_DIR"
rm -rf HtmlReport/
tar -zxf html_report.tar.gz
HtmlReport/generate.py --xml-report "$COLBOT_LINT_REPORT_FILE" --output-dir "$HTML_REPORT_DIR"
'''
script {
retcode = sh script: '''#!/bin/bash
set -e +x
# Update stable/unstable build status
ret=0
COLOBOT_LINT_REPORT_FILE="$WORKSPACE/build/lint/colobot_lint_report.xml"
COLOBOT_LINT_DIR="$WORKSPACE/colobot-lint"
OVERALL_STABLE_RULES=(
"class naming"
"code block placement"
"compile error"
# "compile warning"
# "enum naming"
# "function naming"
"header file not self-contained"
# "implicit bool cast"
# "include style"
# "inconsistent declaration parameter name"
"license header"
# "naked delete"
# "naked new"
# "old style function"
"old-style null pointer"
# "possible forward declaration"
"undefined function"
# "uninitialized field"
# "uninitialized local variable"
# "unused forward declaration"
# "variable naming"
"whitespace"
)
echo "Checking rule stability (overall)"
for ((i = 0; i < ${#OVERALL_STABLE_RULES[@]}; i++)); do
rule="${OVERALL_STABLE_RULES[$i]}"
count="$("$COLOBOT_LINT_DIR/Tools/count_errors.py" --rule-filter="$rule" --xml-report-file "$COLOBOT_LINT_REPORT_FILE")"
if [ "$count" != "0" ]; then
echo "UNSTABLE RULE: $rule ($count occurences)"
ret=1
fi
done
STABLE_RULES_WITHOUT_CBOT=(
"class naming"
"code block placement"
"compile error"
"compile warning"
# "enum naming"
# "function naming"
"header file not self-contained"
# "implicit bool cast"
"include style"
"inconsistent declaration parameter name"
"license header"
"naked delete"
"naked new"
# "old style function"
"old-style null pointer"
# "possible forward declaration"
"undefined function"
"uninitialized field"
# "uninitialized local variable"
"unused forward declaration"
# "variable naming"
"whitespace"
)
echo "Checking rule stability (without CBOT)"
for ((i = 0; i < ${#STABLE_RULES_WITHOUT_CBOT[@]}; i++)); do
rule="${STABLE_RULES_WITHOUT_CBOT[$i]}"
count="$("$COLOBOT_LINT_DIR/Tools/count_errors.py" --rule-filter="$rule" --file-filter="-.*CBot.*" --xml-report-file "$COLOBOT_LINT_REPORT_FILE")"
if [ "$count" != "0" ]; then
echo "UNSTABLE RULE: $rule (without CBOT, $count occurences)"
ret=1
fi
done
exit $ret
''', returnStatus: true
if (retcode != 0) {
currentBuild.result = 'UNSTABLE'
}
}
}
publishCppcheck pattern: 'build/lint/colobot_lint_report.xml'
publishHTML([reportName: 'Colobot-lint HTML report', reportDir: 'build/lint/html_report', reportFiles: 'index.html', reportTitles: '', allowMissing: false, alwaysLinkToLastBuild: true, keepAll: true])
}
}
}
} }
if (env.CHANGE_TARGET == 'master') {
error("This pull request targets the wrong branch. Please reopen the pull request targetting the dev branch.")
}
node('master') {
stage('Pull changes') {
checkout scm
}
stage('Build Windows') {
sh 'mkdir -p build/windows'
dir('build/windows') {
sh '''
cmake \
-DCMAKE_INSTALL_PREFIX=/install \
-DCMAKE_TOOLCHAIN_FILE=/opt/mxe/usr/i686-w64-mingw32.static/share/cmake/mxe-conf.cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=0 ../..
make
rm -rf install
DESTDIR=. make install
'''
}
sh 'rm -f windows-debug.zip'
zip zipFile: 'windows-debug.zip', archive: true, dir: 'build/windows/install'
}
stage('Build Linux') {
sh 'mkdir -p build/linux'
dir('build/linux') {
sh '''
cmake \
-DCMAKE_INSTALL_PREFIX=/install -DCOLOBOT_INSTALL_BIN_DIR=/install -DCOLOBOT_INSTALL_LIB_DIR=/install -DCOLOBOT_INSTALL_DATA_DIR=/install/data -DCOLOBOT_INSTALL_I18N_DIR=/install/lang -DCMAKE_SKIP_INSTALL_RPATH=ON \
-DBOOST_STATIC=ON -DGLEW_STATIC=ON -DGLEW_LIBRARY=/usr/lib64/libGLEW.a \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=0 ../..
make
rm -rf install
DESTDIR=. make install
patchelf --set-rpath '.' install/colobot
'''
}
sh 'rm -f linux-debug.zip'
zip zipFile: 'linux-debug.zip', archive: true, dir: 'build/linux/install'
}
stage('Doxygen') {
dir('build/linux') {
sh 'make doc'
}
publishHTML target: [$class: 'HtmlPublisherTarget', reportName: 'Doxygen', reportDir: 'build/linux/doc/html', reportFiles: 'index.html']
}
stage('Run tests') {
dir('build/linux') {
sh './colobot_ut --gtest_output=xml:gtestresults.xml || true'
}
step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '0'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'GoogleTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/linux/gtestresults.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])
}
// Clean workspace after building pull requests
// to save disk space on the Jenkins host
if (env.BRANCH_NAME.startsWith('PR-')) {
cleanWs()
}
}

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -30,6 +30,7 @@ On some Linux distributions there are also distribution packages available:
* Debian Sid (unstable): http://packages.debian.org/sid/colobot * Debian Sid (unstable): http://packages.debian.org/sid/colobot
* Arch Linux (AUR): https://aur.archlinux.org/packages/colobot-gold * Arch Linux (AUR): https://aur.archlinux.org/packages/colobot-gold
* openSUSE: http://software.opensuse.org/download.html?project=games&package=colobot * openSUSE: http://software.opensuse.org/download.html?project=games&package=colobot
* Fedora: https://src.fedoraproject.org/rpms/colobot
## Compiling and running the game ## Compiling and running the game

View File

@ -5,7 +5,7 @@
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h) FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile) SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1)
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH) FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)

View File

@ -7,7 +7,7 @@ IF (WIN32)
FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h FIND_PATH( PHYSFS_INCLUDE_PATH physfs.h
DOC "The directory where physfs.h resides") DOC "The directory where physfs.h resides")
FIND_LIBRARY( PHYSFS_LIBRARY FIND_LIBRARY( PHYSFS_LIBRARY
NAMES physfs NAMES physfs physfs-static
PATHS /mingw/lib PATHS /mingw/lib
DOC "The PhysFS library") DOC "The PhysFS library")
ELSE (WIN32) ELSE (WIN32)

2
data

@ -1 +1 @@
Subproject commit bab2d994d3602f70774257d5b2125b41e6aca926 Subproject commit d1c52c9cdb763ed127e89e51b0c921f85d8760b6

View File

@ -70,26 +70,18 @@ if(PLATFORM_GNU)
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications/
) )
# Install appdata
install(
FILES info.colobot.Colobot.appdata.xml
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/metainfo/
)
# Install Icon # Install Icon
install( install(
FILES ${COLOBOT_ICON_FILE} FILES ${COLOBOT_ICON_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps/
) )
# Translate translatable material
find_program(PO4A po4a)
if(NOT PO4A)
message(WARNING "po4a not found; desktop and manpage files will not be translated")
endif()
if(PO4A)
add_custom_target(desktop_po4a
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(desktopfile desktop_po4a)
endif()
# Create manpage from pod-formatted file # Create manpage from pod-formatted file
find_program(POD2MAN pod2man) find_program(POD2MAN pod2man)
if(NOT POD2MAN) if(NOT POD2MAN)
@ -127,11 +119,30 @@ if(PLATFORM_GNU)
# Create the english manpage # Create the english manpage
podman(PODFILE colobot.pod) podman(PODFILE colobot.pod)
# Translate translatable material
find_program(PO4A po4a)
if(NOT PO4A)
message(WARNING "po4a not found; desktop and manpage files will not be translated")
endif()
if(PO4A) if(PO4A)
# Translate the manpage to other languages # Translate the manpage to other languages
add_dependencies(man desktop_po4a)
file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po) file(GLOB LINGUAS_PO RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po/ ${CMAKE_CURRENT_SOURCE_DIR}/po/*.po)
string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO}) string(REGEX REPLACE ".po$" "" LINGUAS ${LINGUAS_PO})
set(PO4A_OUTPUTS)
foreach(LOCALE ${LINGUAS})
list(APPEND PO4A_OUTPUTS ${CMAKE_CURRENT_SOURCE_DIR}/lang/${LOCALE}/colobot.pod)
endforeach()
add_custom_command(
OUTPUT ${PO4A_OUTPUTS}
COMMAND ${PO4A} po4a.cfg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(desktop_po4a DEPENDS ${PO4A_OUTPUTS})
add_dependencies(man desktop_po4a)
add_dependencies(desktopfile desktop_po4a)
foreach(LOCALE ${LINGUAS}) foreach(LOCALE ${LINGUAS})
podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE}) podman(PODFILE lang/${LOCALE}/colobot.pod LOCALE ${LOCALE})
add_dependencies(man${PM_LOCALE} desktop_po4a) add_dependencies(man${PM_LOCALE} desktop_po4a)
@ -145,7 +156,12 @@ if(PLATFORM_MACOSX)
endif(PLATFORM_MACOSX) endif(PLATFORM_MACOSX)
if(PLATFORM_WINDOWS) if(PLATFORM_WINDOWS)
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0") if(COLOBOT_VERSION_REVISION MATCHES "([0-9]+)\\.([0-9]+)")
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1,\\2" COLOBOT_VERSION_REVISION_COMMA "${COLOBOT_VERSION_REVISION}")
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION_COMMA}")
else()
set(COLOBOT_VERSION_4COMMAS "${COLOBOT_VERSION_MAJOR},${COLOBOT_VERSION_MINOR},${COLOBOT_VERSION_REVISION},0")
endif()
configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc) configure_file(colobot.rc.cmake ${CMAKE_CURRENT_BINARY_DIR}/colobot.rc)
endif(PLATFORM_WINDOWS) endif(PLATFORM_WINDOWS)

View File

@ -1,4 +1,4 @@
Name="Colobot" Name="Colobot"
GenericName="Game to learn programming" GenericName="Game to learn programming"
Comment="Colonize with bots" Comment="Colonize with bots"
Keywords="robots;3d;space;astronaut;java;c++" Keywords="robots;3d;space;astronaut;java;c++;"

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<component>
<id>info.colobot.Colobot</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0</project_license>
<developer_name>TerranovaTeam</developer_name>
<update_contact>contact@colobot.info</update_contact>
<name>Colobot</name>
<summary>Colonize with bots</summary>
<description>
<p>Colobot (Colonize with Bots) is an educational game aiming to teach programming through entertainment. You are playing as an astronaut on a journey with robot helpers to find a planet for colonization. It features 3D real-time graphics and a C++ and Java-like, object-oriented language, CBOT, which can be used to program the robots available in the game.</p>
</description>
<launchable type="desktop-id">colobot.desktop</launchable>
<screenshots>
<screenshot type="default">
<caption>Alpha 0.1.5</caption>
<image type="source" height="600" width="800">https://colobot.info/wordpress/wp-content/uploads/alpha-0.1.5.png</image>
</screenshot>
</screenshots>
<url type="homepage">https://colobot.info/</url>
<url type="bugtracker">https://github.com/colobot/colobot/issues</url>
<url type="help">http://colobot.info/forum/</url>
<url type="donation">https://colobot.info/donate/</url>
<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">moderate</content_attribute>
<content_attribute id="violence-fantasy">moderate</content_attribute>
<content_attribute id="violence-bloodshed">mild</content_attribute>
</content_rating>
<releases>
<release date="2018-04-10" version="0.1.11.1"/>
</releases>
</component>

View File

@ -37,7 +37,7 @@ msgstr ""
#. type: Keywords= #. type: Keywords=
#: colobot.ini:4 #: colobot.ini:4
#, no-wrap #, no-wrap
msgid "robots;3d;space;astronaut;java;c++" msgid "robots;3d;space;astronaut;java;c++;"
msgstr "" msgstr ""
#. type: =head1 #. type: =head1

View File

@ -3,18 +3,20 @@
# This file is distributed under the same license as the Colobot package. # This file is distributed under the same license as the Colobot package.
# #
# Didier Raboud <odyx@debian.org>, 2012, 2016. # Didier Raboud <odyx@debian.org>, 2012, 2016.
# B-CE <.>, 2019.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: colobot 0.1.7\n" "Project-Id-Version: colobot 0.1.12\n"
"POT-Creation-Date: 2016-03-30 13:45+0200\n" "POT-Creation-Date: 2016-03-30 13:45+0200\n"
"PO-Revision-Date: 2016-03-30 13:49+0100\n" "PO-Revision-Date: 2019-06-01 09:43+0200\n"
"Last-Translator: Didier Raboud <odyx@debian.org>\n" "Last-Translator: BCE <.>\n"
"Language-Team: French <kde-i18n-doc@kde.org>\n"
"Language: fr\n" "Language: fr\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Lokalize 2.0\n" "X-Generator: Lokalize 18.12.3\n"
#. type: Name= #. type: Name=
#: colobot.ini:1 #: colobot.ini:1
@ -32,13 +34,13 @@ msgstr "Apprentissage de la programmation par le jeu"
#: colobot.ini:3 #: colobot.ini:3
#, no-wrap #, no-wrap
msgid "Colonize with bots" msgid "Colonize with bots"
msgstr "Colonise avec des roBots" msgstr "COlonise avec des roBOTs"
#. type: Keywords= #. type: Keywords=
#: colobot.ini:4 #: colobot.ini:4
#, no-wrap #, no-wrap
msgid "robots;3d;space;astronaut;java;c++" msgid "robots;3d;space;astronaut;java;c++;"
msgstr "robots;3d;espace;astronaute;cosmonaute;java;c++" msgstr "robots;3d;espace;astronaute;cosmonaute;java;c++;programmation;jeux"
#. type: =head1 #. type: =head1
#: colobot.pod:3 #: colobot.pod:3
@ -74,12 +76,12 @@ msgid ""
"real-time graphics and a C++ and Java-like, object-oriented language, CBOT, " "real-time graphics and a C++ and Java-like, object-oriented language, CBOT, "
"which can be used to program the robots available in the game." "which can be used to program the robots available in the game."
msgstr "" msgstr ""
"Colobot (Colonise avec des roBots) est un jeu éducatif visant à " "Colobot (Colonise avec des roBots) est un jeu éducatif visant "
"l'enseignement de la programmation par le jeu. Vous jouez un astronaute en " "à l'enseignement de la programmation par le jeu. Vous jouez un astronaute en "
"voyage avec des robots à la recherche d'une planète à coloniser. Son " "voyage avec des robots à la recherche d'une planète à coloniser. Son "
"interface est en trois-dimensions et en temps réel; le language utilisé " "interface est en trois-dimensions et en temps réel. Le langage utilisé "
"(CBOT) ressemble au C++ et à Java et peut être utilisé pour programmer les " "(CBOT), orienté objet , ressemble au C++ et à Java. Il peut être utilisé "
"robots disponibles dans le jeu." "pour programmer les robots disponibles dans le jeu."
#. type: =head1 #. type: =head1
#: colobot.pod:19 #: colobot.pod:19
@ -208,9 +210,9 @@ msgid ""
"Enable debug mode (more info printed in logs). Possible values are as " "Enable debug mode (more info printed in logs). Possible values are as "
"follows, as well as any comma-separated combination" "follows, as well as any comma-separated combination"
msgstr "" msgstr ""
"Active le mode de I<debug> (plus d'informations dans les logs). Les valeurs" "Active le mode de I<debug> (plus d'informations dans les logs). "
" possibles sont les suivantes, ainsi que toute combinaison séparée par des" "Les valeurs possibles sont les suivantes, "
" virgules" "ainsi que toute combinaison séparée par des virgules"
#. type: =item #. type: =item
#: colobot.pod:81 #: colobot.pod:81
@ -260,7 +262,7 @@ msgstr "models"
#. type: textblock #. type: textblock
#: colobot.pod:99 #: colobot.pod:99
msgid "Models-related debugging" msgid "Models-related debugging"
msgstr "Debug pour les modèles" msgstr "Débug pour les modèles"
#. type: =item #. type: =item
#: colobot.pod:101 #: colobot.pod:101
@ -270,7 +272,7 @@ msgstr "all"
#. type: textblock #. type: textblock
#: colobot.pod:103 #: colobot.pod:103
msgid "All above debugging statements" msgid "All above debugging statements"
msgstr "Tout les messages de debug ci-dessus" msgstr "Tous les messages de debug ci-dessus"
#. type: =item #. type: =item
#: colobot.pod:107 #: colobot.pod:107
@ -280,9 +282,7 @@ msgstr "B<-headless>"
#. type: textblock #. type: textblock
#: colobot.pod:109 #: colobot.pod:109
msgid "Run in headless mode - disables graphics, sound and user interaction" msgid "Run in headless mode - disables graphics, sound and user interaction"
msgstr "" msgstr "Lance en mode I<headless> - désactive les graphiques, sons et interactions utilisateurs"
"Lance en mode I<headless> - désactive les graphiques, sons et interactions"
" utilisateurs"
#. type: =item #. type: =item
#: colobot.pod:111 #: colobot.pod:111
@ -292,7 +292,7 @@ msgstr "B<-runscene> I<scenecodename>"
#. type: textblock #. type: textblock
#: colobot.pod:113 #: colobot.pod:113
msgid "Run given scene on start (skip menus)" msgid "Run given scene on start (skip menus)"
msgstr "Lance une scène donnée au lancement (saute les menus)" msgstr "Démarre directement une scène (saute les menus)"
#. type: =item #. type: =item
#: colobot.pod:115 #: colobot.pod:115
@ -317,7 +317,7 @@ msgstr "LC_MESSAGES"
#. type: textblock #. type: textblock
#: colobot.pod:127 #: colobot.pod:127
msgid "Used to determine the runtime language." msgid "Used to determine the runtime language."
msgstr "Utilisé pour déterminer la langue au lancement" msgstr "Utilisé pour déterminer la langue au lancement."
#. type: =head1 #. type: =head1
#: colobot.pod:131 #: colobot.pod:131

View File

@ -266,6 +266,10 @@ msgstr ""
msgid "The battle has ended" msgid "The battle has ended"
msgstr "" msgstr ""
#, c-format
msgid "Time: %s"
msgstr ""
#, c-format #, c-format
msgid "%s: %d pts" msgid "%s: %d pts"
msgstr "" msgstr ""
@ -447,6 +451,9 @@ msgstr ""
msgid "Shadow resolution\\Higher means better range and quality, but slower" msgid "Shadow resolution\\Higher means better range and quality, but slower"
msgstr "" msgstr ""
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
msgstr ""
msgid "Standard controls\\Standard key functions" msgid "Standard controls\\Standard key functions"
msgstr "" msgstr ""
@ -810,6 +817,18 @@ msgstr ""
msgid "Build a legged sniffer" msgid "Build a legged sniffer"
msgstr "" msgstr ""
msgid "Build a winged builder"
msgstr ""
msgid "Build a tracked builder"
msgstr ""
msgid "Build a wheeled builder"
msgstr ""
msgid "Build a legged builder"
msgstr ""
msgid "Build a thumper" msgid "Build a thumper"
msgstr "" msgstr ""
@ -825,6 +844,9 @@ msgstr ""
msgid "Build a subber" msgid "Build a subber"
msgstr "" msgstr ""
msgid "Build a target bot"
msgstr ""
msgid "Run research program for tracked bots" msgid "Run research program for tracked bots"
msgstr "" msgstr ""
@ -855,6 +877,12 @@ msgstr ""
msgid "Run research program for orga shooter" msgid "Run research program for orga shooter"
msgstr "" msgstr ""
msgid "Run research program for builder"
msgstr ""
msgid "Run research program for target bot"
msgstr ""
msgid "Return to start" msgid "Return to start"
msgstr "" msgstr ""
@ -870,6 +898,9 @@ msgstr ""
msgid "Explode (\\key action;)" msgid "Explode (\\key action;)"
msgstr "" msgstr ""
msgid "Build (\\key action;)"
msgstr ""
msgid "Recycle (\\key action;)" msgid "Recycle (\\key action;)"
msgstr "" msgstr ""
@ -1248,6 +1279,18 @@ msgstr ""
msgid "Legged grabber" msgid "Legged grabber"
msgstr "" msgstr ""
msgid "Winged builder"
msgstr ""
msgid "Tracked builder"
msgstr ""
msgid "Wheeled builder"
msgstr ""
msgid "Legged builder"
msgstr ""
msgid "Winged shooter" msgid "Winged shooter"
msgstr "" msgstr ""
@ -1464,7 +1507,7 @@ msgstr ""
msgid "Nothing to analyze" msgid "Nothing to analyze"
msgstr "" msgstr ""
msgid "Analyzes only organic matter" msgid "Inappropriate sample"
msgstr "" msgstr ""
msgid "Analysis already performed" msgid "Analysis already performed"
@ -1563,6 +1606,9 @@ msgstr ""
msgid "Plans for nuclear power plant available" msgid "Plans for nuclear power plant available"
msgstr "" msgstr ""
msgid "Plans for builder available"
msgstr ""
msgid "New bot available" msgid "New bot available"
msgstr "" msgstr ""
@ -1788,6 +1834,12 @@ msgstr ""
msgid "Invalid universal character name" msgid "Invalid universal character name"
msgstr "" msgstr ""
msgid "Empty character constant"
msgstr ""
msgid "Duplicate label in switch"
msgstr ""
msgid "Dividing by zero" msgid "Dividing by zero"
msgstr "" msgstr ""

1872
po/cs.po Normal file

File diff suppressed because it is too large Load Diff

View File

@ -490,6 +490,9 @@ msgstr "Sinkt (\\key gdown;)"
msgid "Drawer bot" msgid "Drawer bot"
msgstr "Zeichner" msgstr "Zeichner"
msgid "Duplicate label in switch"
msgstr ""
msgid "Dust\\Dust and dirt on bots and buildings" msgid "Dust\\Dust and dirt on bots and buildings"
msgstr "Schmutz\\Schmutz auf Robotern und Bauten" msgstr "Schmutz\\Schmutz auf Robotern und Bauten"
@ -508,6 +511,9 @@ msgstr "Gewähltes Programm bearbeiten"
msgid "Egg" msgid "Egg"
msgstr "Ei" msgstr "Ei"
msgid "Empty character constant"
msgstr ""
msgid "End of block missing" msgid "End of block missing"
msgstr "Es fehlt eine geschlossene geschweifte Klammer \"}\" (Ende des Blocks)" msgstr "Es fehlt eine geschlossene geschweifte Klammer \"}\" (Ende des Blocks)"
@ -1563,6 +1569,10 @@ msgstr "Stampfen (\\key action;)"
msgid "Thumper" msgid "Thumper"
msgstr "Stampfer" msgstr "Stampfer"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium" msgid "Titanium"
msgstr "Titan" msgstr "Titan"
@ -1677,6 +1687,9 @@ msgstr "Der Wert dieser Variable wurde nicht definiert"
msgid "Vault" msgid "Vault"
msgstr "Bunker" msgstr "Bunker"
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
msgstr ""
msgid "Violet flag" msgid "Violet flag"
msgstr "Violette Fahne" msgstr "Violette Fahne"

400
po/fr.po

File diff suppressed because it is too large Load Diff

View File

@ -365,7 +365,7 @@ msgid "Checkpoint"
msgstr "Punkt kontrolny" msgstr "Punkt kontrolny"
msgid "Class name expected" msgid "Class name expected"
msgstr "" msgstr "Oczekiwano nazwy klasy"
msgid "Climb\\Increases the power of the jet" msgid "Climb\\Increases the power of the jet"
msgstr "W górę\\Zwiększa moc silnika" msgstr "W górę\\Zwiększa moc silnika"
@ -488,6 +488,9 @@ msgstr "Dół (\\key gdown;)"
msgid "Drawer bot" msgid "Drawer bot"
msgstr "Robot rysownik" msgstr "Robot rysownik"
msgid "Duplicate label in switch"
msgstr ""
msgid "Dust\\Dust and dirt on bots and buildings" msgid "Dust\\Dust and dirt on bots and buildings"
msgstr "Kurz\\Kurz i bród na robotach i budynkach" msgstr "Kurz\\Kurz i bród na robotach i budynkach"
@ -506,6 +509,9 @@ msgstr "Edytuj zaznaczony program"
msgid "Egg" msgid "Egg"
msgstr "Jajo" msgstr "Jajo"
msgid "Empty character constant"
msgstr ""
msgid "End of block missing" msgid "End of block missing"
msgstr "Brak końca bloku" msgstr "Brak końca bloku"
@ -628,7 +634,7 @@ msgid "Function name missing"
msgstr "Brakująca nazwa funkcji" msgstr "Brakująca nazwa funkcji"
msgid "Function needs return type \"void\"" msgid "Function needs return type \"void\""
msgstr "" msgstr "Funkcja potrzebuje typu zwracanego \"void\""
msgid "Game speed" msgid "Game speed"
msgstr "Prędkość gry" msgstr "Prędkość gry"
@ -679,7 +685,7 @@ msgid "Help balloons\\Explain the function of the buttons"
msgstr "Dymki pomocy\\Wyjaśnia funkcje przycisków" msgstr "Dymki pomocy\\Wyjaśnia funkcje przycisków"
msgid "Hex value out of range" msgid "Hex value out of range"
msgstr "" msgstr "Wartość heksadecymalna poza zakresem"
msgid "Higher speed\\Doubles speed" msgid "Higher speed\\Doubles speed"
msgstr "Zwiększ prędkość\\Podwaja prędkość" msgstr "Zwiększ prędkość\\Podwaja prędkość"
@ -859,10 +865,10 @@ msgid "Mipmap level\\Mipmap level"
msgstr "Poziom mipmap\\Poziom mipmap" msgstr "Poziom mipmap\\Poziom mipmap"
msgid "Missing end quote" msgid "Missing end quote"
msgstr "" msgstr "Brak cudzysłowu zamykającego"
msgid "Missing hex digits after escape sequence" msgid "Missing hex digits after escape sequence"
msgstr "" msgstr "Brak cyfr heksadecymalnych po znaku ucieczki"
msgid "Mission name" msgid "Mission name"
msgstr "Nazwa misji" msgstr "Nazwa misji"
@ -964,7 +970,7 @@ msgid "No userlevels installed!"
msgstr "Brak zainstalowanych poziomów użytkownika!" msgstr "Brak zainstalowanych poziomów użytkownika!"
msgid "Non-void function needs \"return;\"" msgid "Non-void function needs \"return;\""
msgstr "" msgstr "Funkcja zwracająca typ inny, niż \"void\", wymaga \"return;\""
msgid "Normal size" msgid "Normal size"
msgstr "Normalna wielkość" msgstr "Normalna wielkość"
@ -1027,7 +1033,7 @@ msgid "Object too close"
msgstr "Obiekt za blisko" msgstr "Obiekt za blisko"
msgid "Octal value out of range" msgid "Octal value out of range"
msgstr "" msgstr "Wartość ósemkowa poza zakresem"
msgid "One step" msgid "One step"
msgstr "Jeden krok" msgstr "Jeden krok"
@ -1072,7 +1078,7 @@ msgid "Paste (Ctrl+V)"
msgstr "Wklej (Ctrl+V)" msgstr "Wklej (Ctrl+V)"
msgid "Pause blur\\Blur the background on the pause screen" msgid "Pause blur\\Blur the background on the pause screen"
msgstr "" msgstr "Rozmyta pauza\\Rozmyj tło na ekranie pauzy"
msgid "Pause in background\\Pause the game when the window is unfocused" msgid "Pause in background\\Pause the game when the window is unfocused"
msgstr "Wstrzymaj w tle\\Wstrzymaj grę gdy okno stanie się nieaktywne" msgstr "Wstrzymaj w tle\\Wstrzymaj grę gdy okno stanie się nieaktywne"
@ -1534,7 +1540,7 @@ msgid "This object is not a member of a class"
msgstr "Ten obiekt nie jest członkiem klasy" msgstr "Ten obiekt nie jest członkiem klasy"
msgid "This parameter needs a default value" msgid "This parameter needs a default value"
msgstr "" msgstr "Ten parametr wymaga podania domyślnej wartości"
msgid "This program is read-only, clone it to edit" msgid "This program is read-only, clone it to edit"
msgstr "Ten program jest tylko do odczytu, skopiuj go, aby edytować" msgstr "Ten program jest tylko do odczytu, skopiuj go, aby edytować"
@ -1545,6 +1551,10 @@ msgstr "Uderz (\\key action;)"
msgid "Thumper" msgid "Thumper"
msgstr "Uderzacz" msgstr "Uderzacz"
#, c-format
msgid "Time: %s"
msgstr "Czas: %s"
msgid "Titanium" msgid "Titanium"
msgstr "Tytan" msgstr "Tytan"
@ -1659,6 +1669,9 @@ msgstr "Zmienna nie została zainicjalizowana"
msgid "Vault" msgid "Vault"
msgstr "Skrytka" msgstr "Skrytka"
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
msgstr "Synchronizacja pionowa\\Ogranicza ilość klatek na sekundę do wartości odświeżania ekranu"
msgid "Violet flag" msgid "Violet flag"
msgstr "Fioletowa flaga" msgstr "Fioletowa flaga"

2055
po/pt.po Normal file

File diff suppressed because it is too large Load Diff

View File

@ -496,6 +496,9 @@ msgstr "Вниз (\\key gdown;)"
msgid "Drawer bot" msgid "Drawer bot"
msgstr "Рисовальщик" msgstr "Рисовальщик"
msgid "Duplicate label in switch"
msgstr ""
msgid "Dust\\Dust and dirt on bots and buildings" msgid "Dust\\Dust and dirt on bots and buildings"
msgstr "Пыль\\Пыль и грязь на ботах и зданиях" msgstr "Пыль\\Пыль и грязь на ботах и зданиях"
@ -514,6 +517,9 @@ msgstr "Изменить выбранную программу"
msgid "Egg" msgid "Egg"
msgstr "Яйцо" msgstr "Яйцо"
msgid "Empty character constant"
msgstr ""
msgid "End of block missing" msgid "End of block missing"
msgstr "Отсутствует конец блока" msgstr "Отсутствует конец блока"
@ -1576,6 +1582,10 @@ msgstr "Удар (\\key action;)"
msgid "Thumper" msgid "Thumper"
msgstr "Ударник" msgstr "Ударник"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium" msgid "Titanium"
msgstr "Титан" msgstr "Титан"
@ -1690,6 +1700,9 @@ msgstr "Переменная не инициализирована"
msgid "Vault" msgid "Vault"
msgstr "Хранилище" msgstr "Хранилище"
msgid "Vertical Synchronization\\Limits the number of frames per second to display frequency"
msgstr ""
msgid "Violet flag" msgid "Violet flag"
msgstr "Фиолетовый флаг" msgstr "Фиолетовый флаг"

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -36,7 +36,6 @@
#include "CBot/CBotCStack.h" #include "CBot/CBotCStack.h"
#include "CBot/CBotDefParam.h" #include "CBot/CBotDefParam.h"
#include "CBot/CBotUtils.h" #include "CBot/CBotUtils.h"
#include "CBot/CBotFileUtils.h"
#include <algorithm> #include <algorithm>
@ -192,7 +191,7 @@ bool CBotClass::AddItem(CBotVar* pVar)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotClass::GetName() const std::string& CBotClass::GetName()
{ {
return m_name; return m_name;
} }
@ -364,69 +363,70 @@ void CBotClass::RestoreMethode(long& nIdent,
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool CBotClass::SaveStaticState(FILE* pf) bool CBotClass::SaveStaticState(std::ostream &ostr)
{ {
if (!WriteWord( pf, CBOTVERSION*2)) return false; if (!WriteLong(ostr, CBOTVERSION*2)) return false;
// saves the state of static variables in classes // saves the state of static variables in classes
for (CBotClass* p : m_publicClasses) for (CBotClass* p : m_publicClasses)
{ {
if (!WriteWord( pf, 1 )) return false; if (!WriteWord(ostr, 1)) return false;
// save the name of the class // save the name of the class
if (!WriteString( pf, p->GetName() )) return false; if (!WriteString(ostr, p->GetName())) return false;
CBotVar* pv = p->GetVar(); CBotVar* pv = p->GetVar();
while( pv != nullptr ) while( pv != nullptr )
{ {
if ( pv->IsStatic() ) if ( pv->IsStatic() )
{ {
if (!WriteWord( pf, 1 )) return false; if (!WriteWord(ostr, 1)) return false;
if (!WriteString( pf, pv->GetName() )) return false; if (!WriteString(ostr, pv->GetName())) return false;
if ( !pv->Save0State(pf) ) return false; // common header if (!pv->Save0State(ostr)) return false; // common header
if ( !pv->Save1State(pf) ) return false; // saves as the child class if (!pv->Save1State(ostr)) return false; // saves as the child class
if ( !WriteWord( pf, 0 ) ) return false; if (!WriteWord(ostr, 0)) return false;
} }
pv = pv->GetNext(); pv = pv->GetNext();
} }
if (!WriteWord( pf, 0 )) return false; if (!WriteWord(ostr, 0)) return false;
} }
if (!WriteWord( pf, 0 )) return false; if (!WriteWord(ostr, 0)) return false;
return true; return true;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool CBotClass::RestoreStaticState(FILE* pf) bool CBotClass::RestoreStaticState(std::istream &istr)
{ {
std::string ClassName, VarName; std::string ClassName, VarName;
CBotClass* pClass; CBotClass* pClass;
unsigned short w; unsigned short w;
if (!ReadWord( pf, w )) return false; long version;
if ( w != CBOTVERSION*2 ) return false; if (!ReadLong(istr, version)) return false;
if (version != CBOTVERSION*2) return false;
while (true) while (true)
{ {
if (!ReadWord( pf, w )) return false; if (!ReadWord(istr, w)) return false;
if ( w == 0 ) return true; if ( w == 0 ) return true;
if (!ReadString( pf, ClassName )) return false; if (!ReadString(istr, ClassName)) return false;
pClass = Find(ClassName); pClass = Find(ClassName);
while (true) while (true)
{ {
if (!ReadWord( pf, w )) return false; if (!ReadWord(istr, w)) return false;
if ( w == 0 ) break; if ( w == 0 ) break;
CBotVar* pVar = nullptr; CBotVar* pVar = nullptr;
CBotVar* pv = nullptr; CBotVar* pv = nullptr;
if (!ReadString( pf, VarName )) return false; if (!ReadString(istr, VarName)) return false;
if ( pClass != nullptr ) pVar = pClass->GetItem(VarName); if ( pClass != nullptr ) pVar = pClass->GetItem(VarName);
if (!CBotVar::RestoreState(pf, pv)) return false; // the temp variable if (!CBotVar::RestoreState(istr, pv)) return false; // the temp variable
if ( pVar != nullptr ) pVar->Copy(pv); if ( pVar != nullptr ) pVar->Copy(pv);
delete pv; delete pv;

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -173,7 +173,7 @@ public:
* \brief GetName Gives the name of the class. * \brief GetName Gives the name of the class.
* \return * \return
*/ */
std::string GetName(); const std::string& GetName();
/*! /*!
* \brief GetParent Gives the parent class (or nullptr). * \brief GetParent Gives the parent class (or nullptr).
@ -331,18 +331,18 @@ public:
static void ClearPublic(); static void ClearPublic();
/*! /*!
* \brief SaveStaticState * \brief Save all static variables from each public class
* \param pf * \param ostr Output stream
* \return * \return true on success
*/ */
static bool SaveStaticState(FILE* pf); static bool SaveStaticState(std::ostream &ostr);
/*! /*!
* \brief RestoreStaticState * \brief Restore all static variables in each public class
* \param pf * \param istr Input stream
* \return * \return true on success
*/ */
static bool RestoreStaticState(FILE* pf); static bool RestoreStaticState(std::istream &istr);
/** /**
* \brief Request a lock on this class (for "synchronized" keyword) * \brief Request a lock on this class (for "synchronized" keyword)

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -23,6 +23,7 @@
#include "CBot/CBotInstr/CBotFunction.h" #include "CBot/CBotInstr/CBotFunction.h"
#include "CBot/CBotInstr/CBotInstrCall.h" #include "CBot/CBotInstr/CBotInstrCall.h"
#include <functional>
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -173,14 +173,34 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
{ {
switch (p->m_type.GetType()) switch (p->m_type.GetType())
{ {
case CBotTypByte:
newvar->SetValByte(pVar->GetValByte());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypShort:
newvar->SetValShort(pVar->GetValShort());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypChar:
newvar->SetValChar(pVar->GetValChar());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypInt: case CBotTypInt:
newvar->SetValInt(pVar->GetValInt()); newvar->SetValInt(pVar->GetValInt());
newvar->SetInit(pVar->GetInit()); // copy nan newvar->SetInit(pVar->GetInit()); // copy nan
break; break;
case CBotTypLong:
newvar->SetValLong(pVar->GetValLong());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypFloat: case CBotTypFloat:
newvar->SetValFloat(pVar->GetValFloat()); newvar->SetValFloat(pVar->GetValFloat());
newvar->SetInit(pVar->GetInit()); // copy nan newvar->SetInit(pVar->GetInit()); // copy nan
break; break;
case CBotTypDouble:
newvar->SetValDouble(pVar->GetValDouble());
newvar->SetInit(pVar->GetInit()); // copy nan
break;
case CBotTypString: case CBotTypString:
newvar->SetValString(pVar->GetValString()); newvar->SetValString(pVar->GetValString());
break; break;

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -35,13 +35,13 @@ namespace CBot
enum CBotType enum CBotType
{ {
CBotTypVoid = 0, //!< void CBotTypVoid = 0, //!< void
CBotTypByte = 1, //!< byte (NOT IMPLEMENTED) CBotTypByte = 1, //!< byte
CBotTypShort = 2, //!< short (NOT IMPLEMENTED) CBotTypShort = 2, //!< short
CBotTypChar = 3, //!< char (NOT IMPLEMENTED) CBotTypChar = 3, //!< char
CBotTypInt = 4, //!< int CBotTypInt = 4, //!< int
CBotTypLong = 5, //!< long (NOT IMPLEMENTED) CBotTypLong = 5, //!< long
CBotTypFloat = 6, //!< float CBotTypFloat = 6, //!< float
CBotTypDouble = 7, //!< double (NOT IMPLEMENTED) CBotTypDouble = 7, //!< double
CBotTypBoolean = 8, //!< bool CBotTypBoolean = 8, //!< bool
CBotTypString = 9, //!< string CBotTypString = 9, //!< string
@ -106,6 +106,11 @@ enum TokenId
ID_STRING, ID_STRING,
ID_VOID, ID_VOID,
ID_BOOL, ID_BOOL,
ID_BYTE,
ID_SHORT,
ID_CHAR,
ID_LONG,
ID_DOUBLE,
TokenKeyVal = 2200, //!< keywords that represent values (true, false, null, nan) TokenKeyVal = 2200, //!< keywords that represent values (true, false, null, nan)
ID_TRUE = 2200, ID_TRUE = 2200,
@ -177,7 +182,8 @@ enum TokenType
TokenTypNum = 2, //!< number TokenTypNum = 2, //!< number
TokenTypString = 3, //!< string TokenTypString = 3, //!< string
TokenTypVar = 4, //!< a variable name TokenTypVar = 4, //!< a variable name
TokenTypDef = 5 //!< value according DefineNum TokenTypDef = 5, //!< value according DefineNum
TokenTypChar = 6, //!< character literal
}; };
/** /**
@ -247,6 +253,8 @@ enum CBotError : int
CBotErrHexDigits = 5052, //!< missing hex digits after escape sequence CBotErrHexDigits = 5052, //!< missing hex digits after escape sequence
CBotErrHexRange = 5053, //!< hex value out of range CBotErrHexRange = 5053, //!< hex value out of range
CBotErrUnicodeName = 5054, //!< invalid universal character name CBotErrUnicodeName = 5054, //!< invalid universal character name
CBotErrCharEmpty = 5055, //!< empty character constant
CBotErrRedefCase = 5056, //!< duplicate label in switch
// Runtime errors // Runtime errors
CBotErrZeroDiv = 6000, //!< division by zero CBotErrZeroDiv = 6000, //!< division by zero

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -21,129 +21,285 @@
#include "CBot/CBotClass.h" #include "CBot/CBotClass.h"
#include "CBot/CBotEnums.h" #include "CBot/CBotEnums.h"
#include "CBot/CBotUtils.h"
namespace CBot namespace CBot
{ {
template<typename T>
// file management static bool WriteBinary(std::ostream &ostr, T value, unsigned padTo = 0)
// necessary because it is not possible to do the fopen in the main program
// fwrite and fread in a dll or using the FILE * returned.
////////////////////////////////////////////////////////////////////////////////
FILE* fOpen(const char* name, const char* mode)
{ {
return fopen(name, mode); unsigned char chr;
} unsigned count = 1;
while (value > 127) // unsigned LEB128
////////////////////////////////////////////////////////////////////////////////
int fClose(FILE* filehandle)
{
return fclose(filehandle);
}
////////////////////////////////////////////////////////////////////////////////
std::size_t fWrite(const void *buffer,
std::size_t elemsize,
std::size_t length,
FILE* filehandle)
{
return fwrite(buffer, elemsize, length, filehandle);
}
////////////////////////////////////////////////////////////////////////////////
std::size_t fRead(void *buffer,
std::size_t elemsize,
std::size_t length,
FILE* filehandle)
{
return fread(buffer, elemsize, length, filehandle);
}
////////////////////////////////////////////////////////////////////////////////
bool ReadWord(FILE* pf, unsigned short& w)
{
size_t lg;
lg = fread(&w, sizeof( unsigned short ), 1, pf );
return (lg == 1);
}
////////////////////////////////////////////////////////////////////////////////
bool ReadFloat(FILE* pf, float& w)
{
size_t lg;
lg = fread(&w, sizeof( float ), 1, pf );
return (lg == 1);
}
////////////////////////////////////////////////////////////////////////////////
bool WriteLong(FILE* pf, long w)
{
size_t lg;
lg = fwrite(&w, sizeof( long ), 1, pf );
return (lg == 1);
}
////////////////////////////////////////////////////////////////////////////////
bool ReadLong(FILE* pf, long& w)
{
size_t lg;
lg = fread(&w, sizeof( long ), 1, pf );
return (lg == 1);
}
////////////////////////////////////////////////////////////////////////////////
bool ReadString(FILE* pf, std::string& s)
{
unsigned short w;
char buf[1000];
size_t lg1, lg2;
if (!ReadWord(pf, w)) return false;
lg1 = w;
lg2 = fread(buf, 1, lg1, pf );
buf[lg2] = 0;
s = buf;
return (lg1 == lg2);
}
////////////////////////////////////////////////////////////////////////////////
bool WriteType(FILE* pf, const CBotTypResult &type)
{
int typ = type.GetType();
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
if ( !WriteWord(pf, typ) ) return false;
if ( typ == CBotTypClass )
{ {
CBotClass* p = type.GetClass(); ++count;
if ( !WriteString(pf, p->GetName()) ) return false; chr = (value & 0x7F) | 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
value >>= 7;
} }
if ( type.Eq( CBotTypArrayBody ) || chr = value & 0x7F;
type.Eq( CBotTypArrayPointer ) ) if (count < padTo) chr |= 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
if (count < padTo)
{ {
if ( !WriteWord(pf, type.GetLimite()) ) return false; while (++count < padTo)
if ( !WriteType(pf, type.GetTypElem()) ) return false; if (!(ostr << '\x80')) return false;
if (!(ostr << '\x00')) return false;
} }
return true; return true;
} }
//////////////////////////////////////////////////////////////////////////////// template<typename T>
bool ReadType(FILE* pf, CBotTypResult &type) static bool ReadBinary(std::istream &istr, T &value)
{
value = 0;
unsigned char chr;
unsigned shift = 0;
while (true) // unsigned LEB128
{
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
if (shift < sizeof(T) * 8 - 1)
value |= static_cast<T>(chr & 0x7F) << shift;
shift += 7;
if ((chr & 0x80) == 0) break;
}
return true;
}
template<typename T>
static bool WriteSignedBinary(std::ostream &ostr, T value, unsigned padTo = 0)
{
signed char sign = value >> (8 * sizeof(T) - 1);
unsigned count = 0;
while (true) // signed LEB128
{
++count;
unsigned char chr = value & 0x7F;
value >>= 7;
if (!(value != sign || ((chr ^ sign) & 0x40) != 0))
{
if (count < padTo) chr |= 0x80;
if (!ostr.write(reinterpret_cast<char*>(&chr), 1)) return false;
break;
}
chr |= 0x80;
if (!ostr.put(chr)) return false;
}
if (count < padTo)
{
char chr = (sign < 0) ? 0x7F : 0x00;
while (++count < padTo)
if (!ostr.put(chr | 0x80)) return false;
if (!ostr.put(chr)) return false;
}
return true;
}
template<typename T>
static bool ReadSignedBinary(std::istream &istr, T &value)
{
value = 0;
unsigned char chr;
unsigned shift = 0;
while (true) // signed LEB128
{
if (!istr.read(reinterpret_cast<char*>(&chr), 1)) return false;
if (shift < sizeof(T) * 8 - 1)
value |= (static_cast<T>(chr & 0x7F) << shift);
shift += 7;
if ((chr & 0x80) == 0) break;
}
if (shift >= 8 * sizeof(T) - 1) shift = 8 * sizeof(T) - 1;
if ((chr & 0x40) != 0)
value |= static_cast<T>(-1) << shift;
return true;
}
bool WriteWord(std::ostream &ostr, unsigned short w)
{
return WriteBinary<unsigned short>(ostr, w);
}
bool ReadWord(std::istream &istr, unsigned short &w)
{
return ReadBinary<unsigned short>(istr, w);
}
bool WriteByte(std::ostream &ostr, char c)
{
if (!ostr.put(c)) return false;
return true;
}
bool ReadByte(std::istream &istr, char& c)
{
if (!istr.get(c)) return false;
return true;
}
bool WriteShort(std::ostream &ostr, short s)
{
return WriteSignedBinary<short>(ostr, s);
}
bool ReadShort(std::istream &istr, short &s)
{
return ReadSignedBinary<short>(istr, s);
}
bool WriteUInt32(std::ostream &ostr, uint32_t i)
{
return WriteBinary<uint32_t>(ostr, i);
}
bool ReadUInt32(std::istream &istr, uint32_t &i)
{
return ReadBinary<uint32_t>(istr, i);
}
bool WriteInt(std::ostream &ostr, int i)
{
return WriteSignedBinary<int>(ostr, i);
}
bool ReadInt(std::istream &istr, int &i)
{
return ReadSignedBinary<int>(istr, i);
}
bool WriteLong(std::ostream &ostr, long l, unsigned padTo)
{
return WriteSignedBinary<long>(ostr, l, padTo);
}
bool ReadLong(std::istream &istr, long &l)
{
return ReadSignedBinary<long>(istr, l);
}
bool WriteFloat(std::ostream &ostr, float f)
{
union TypeConverter
{
float fValue;
unsigned int iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
u.fValue = f;
return WriteBinary<unsigned int>(ostr, u.iValue);
}
bool ReadFloat(std::istream &istr, float &f)
{
union TypeConverter
{
float fValue;
unsigned int iValue;
};
TypeConverter u;
u.fValue = 0.0f;
u.iValue = 0;
if (!ReadBinary<unsigned int>(istr, u.iValue)) return false;
f = u.fValue;
return true;
}
bool WriteDouble(std::ostream &ostr, double d)
{
union TypeConverter
{
double dValue;
unsigned long iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
u.dValue = d;
return WriteBinary<unsigned long>(ostr, u.iValue);
}
bool ReadDouble(std::istream &istr, double &d)
{
union TypeConverter
{
double dValue;
unsigned long iValue;
};
TypeConverter u;
u.dValue = 0.0;
u.iValue = 0;
if (!ReadBinary<unsigned long>(istr, u.iValue)) return false;
d = u.dValue;
return true;
}
bool WriteString(std::ostream &ostr, const std::string &s)
{
if (!WriteBinary<size_t>(ostr, s.size())) return false;
if (!ostr.write(&(s[0]), s.size())) return false;
return true;
}
bool ReadString(std::istream &istr, std::string &s)
{
size_t length = 0;
if (!ReadBinary<size_t>(istr, length)) return false;
s.resize(length);
if (length != 0)
{
if (!istr.read(&(s[0]), length)) return false;
}
return true;
}
bool WriteType(std::ostream &ostr, const CBotTypResult &type)
{
int typ = type.GetType();
if ( typ == CBotTypIntrinsic ) typ = CBotTypClass;
if ( !WriteWord(ostr, typ) ) return false;
if ( typ == CBotTypClass )
{
CBotClass* p = type.GetClass();
if (!WriteString(ostr, p->GetName())) return false;
}
if ( type.Eq( CBotTypArrayBody ) ||
type.Eq( CBotTypArrayPointer ) )
{
if (!WriteWord(ostr, type.GetLimite())) return false;
if (!WriteType(ostr, type.GetTypElem())) return false;
}
if ( type.Eq(CBotTypPointer) )
{
if (type.GetClass() != nullptr)
{
if (!WriteString(ostr, type.GetClass()->GetName())) return false;
}
else if (!WriteString(ostr, "")) return false;
}
return true;
}
bool ReadType(std::istream &istr, CBotTypResult &type)
{ {
unsigned short w, ww; unsigned short w, ww;
if ( !ReadWord(pf, w) ) return false; if (!ReadWord(istr, w)) return false;
type.SetType(w); type.SetType(w);
if ( type.Eq( CBotTypIntrinsic ) ) if ( type.Eq( CBotTypIntrinsic ) )
@ -154,7 +310,7 @@ bool ReadType(FILE* pf, CBotTypResult &type)
if ( type.Eq( CBotTypClass ) ) if ( type.Eq( CBotTypClass ) )
{ {
std::string s; std::string s;
if ( !ReadString(pf, s) ) return false; if (!ReadString(istr, s)) return false;
type = CBotTypResult( w, s ); type = CBotTypResult( w, s );
} }
@ -162,11 +318,45 @@ bool ReadType(FILE* pf, CBotTypResult &type)
type.Eq( CBotTypArrayBody ) ) type.Eq( CBotTypArrayBody ) )
{ {
CBotTypResult r; CBotTypResult r;
if ( !ReadWord(pf, ww) ) return false; if (!ReadWord(istr, ww)) return false;
if ( !ReadType(pf, r) ) return false; if (!ReadType(istr, r)) return false;
type = CBotTypResult( w, r ); type = CBotTypResult( w, r );
type.SetLimite(static_cast<short>(ww)); type.SetLimite(static_cast<short>(ww));
} }
if ( type.Eq(CBotTypPointer) )
{
std::string className;
if (!ReadString(istr, className)) return false;
type = CBotTypResult(w, className);
}
return true;
}
bool WriteStream(std::ostream &ostr, std::istream& istr)
{
if (!istr.seekg(0, istr.end)) return false;
auto size = istr.tellg();
if (size == 0) return WriteLong(ostr, 0);
if (!WriteLong(ostr, size)) return false;
if (!istr.seekg(0, istr.beg)) return false;
if (!(ostr << istr.rdbuf())) return false;
return true;
}
bool ReadStream(std::istream& istr, std::ostream &ostr)
{
long length;
if (!ReadLong(istr, length)) return false;
if (length == 0) return true;
while (length-- > 0)
{
if (!(ostr << istr.get())) return false;
}
return true; return true;
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -19,7 +19,7 @@
#pragma once #pragma once
#include <cstdio> #include <iostream>
#include <string> #include <string>
namespace CBot namespace CBot
@ -28,128 +28,189 @@ namespace CBot
class CBotVar; class CBotVar;
class CBotTypResult; class CBotTypResult;
///////////////////////////////////////////////////////////////////////////////
// routines for file management (* FILE)
/*! /*!
* \brief fOpen * \brief Save a linked list if variables
* \param name * \param ostr Output stream
* \param mode * \param pVar First variable in the list
* \return * \return true on success
*/ */
FILE* fOpen(const char* name, const char* mode); bool SaveVars(std::ostream &ostr, CBotVar* pVar);
/*!
* \brief fClose
* \param filehandle
* \return
*/
int fClose(FILE* filehandle);
/*!
* \brief fWrite
* \param buffer
* \param elemsize
* \param length
* \param filehandle
* \return
*/
std::size_t fWrite(const void *buffer,
std::size_t elemsize,
std::size_t length,
FILE* filehandle);
/*!
* \brief fRead
* \param buffer
* \param elemsize
* \param length
* \param filehandle
* \return
*/
std::size_t fRead(void *buffer,
std::size_t elemsize,
std::size_t length,
FILE* filehandle);
/*!
* \brief SaveVars
* \param pf
* \param pVar
* \return
*/
bool SaveVars(FILE* pf, CBotVar* pVar);
/*! /*!
* \brief WriteWord * \brief WriteWord
* \param pf * \param ostr Output stream
* \param w * \param w
* \return * \return true on success
*/ */
bool WriteWord(FILE* pf, unsigned short w); bool WriteWord(std::ostream &ostr, unsigned short w);
/*! /*!
* \brief ReadWord * \brief ReadWord
* \param pf * \param istr Input stream
* \param w * \param[out] w
* \return * \return true on success
*/ */
bool ReadWord(FILE* pf, unsigned short& w); bool ReadWord(std::istream &istr, unsigned short &w);
/*! /*!
* \brief ReadLong * \brief WriteByte
* \param pf * \param ostr Output stream
* \param w * \param c
* \return * \return true on success
*/ */
bool ReadLong(FILE* pf, long& w); bool WriteByte(std::ostream &ostr, char c);
/*! /*!
* \brief WriteFloat * \brief ReadByte
* \param pf * \param istr Input stream
* \param w * \param[out] c
* \return * \return true on success
*/ */
bool WriteFloat(FILE* pf, float w); bool ReadByte(std::istream &istr, char& c);
/*!
* \brief WriteShort
* \param ostr Output stream
* \param s
* \return true on success
*/
bool WriteShort(std::ostream &ostr, short s);
/*!
* \brief ReadShort
* \param istr Input stream
* \param[out] s
* \return true on success
*/
bool ReadShort(std::istream &istr, short &s);
/*!
* \brief WriteUInt32
* \param ostr Output stream
* \param i
* \return true on success
*/
bool WriteUInt32(std::ostream &ostr, uint32_t i);
/*!
* \brief ReadUInt32
* \param istr Input stream
* \param[out] i
* \return true on success
*/
bool ReadUInt32(std::istream &istr, uint32_t &i);
/*!
* \brief WriteInt
* \param ostr Output stream
* \param i
* \return true on success
*/
bool WriteInt(std::ostream &ostr, int i);
/*!
* \brief ReadInt
* \param istr Input stream
* \param[out] i
* \return true on success
*/
bool ReadInt(std::istream &istr, int &i);
/*! /*!
* \brief WriteLong * \brief WriteLong
* \param pf * \param ostr Output stream
* \param w * \param l
* \return * \param padTo minimum number of bytes to write
* \return true on success
*/ */
bool WriteLong(FILE* pf, long w); bool WriteLong(std::ostream &ostr, long l, unsigned padTo = 0);
/*!
* \brief ReadLong
* \param istr Input stream
* \param[out] l
* \return true on success
*/
bool ReadLong(std::istream &istr, long &l);
/*!
* \brief WriteFloat
* \param ostr Output stream
* \param f
* \return true on success
*/
bool WriteFloat(std::ostream &ostr, float f);
/*! /*!
* \brief ReadFloat * \brief ReadFloat
* \param pf * \param istr Input stream
* \param w * \param[out] f
* \return * \return true on success
*/ */
bool ReadFloat(FILE* pf, float& w); bool ReadFloat(std::istream &istr, float &f);
/*!
* \brief WriteDouble
* \param ostr Output stream
* \param d
* \return true on success
*/
bool WriteDouble(std::ostream &ostr, double d);
/*!
* \brief ReadDouble
* \param istr Input stream
* \param[out] d
* \return true on success
*/
bool ReadDouble(std::istream &istr, double &d);
/*!
* \brief WriteString
* \param ostr Output stream
* \param s
* \return true on success
*/
bool WriteString(std::ostream &ostr, const std::string &s);
/*! /*!
* \brief ReadString * \brief ReadString
* \param pf * \param istr Input stream
* \param s * \param[out] s
* \return * \return true on success
*/ */
bool ReadString(FILE* pf, std::string& s); bool ReadString(std::istream &istr, std::string &s);
/*! /*!
* \brief WriteType * \brief WriteType
* \param pf * \param ostr Output stream
* \param type * \param type
* \return * \return true on success
*/ */
bool WriteType(FILE* pf, const CBotTypResult &type); bool WriteType(std::ostream &ostr, const CBotTypResult &type);
/*! /*!
* \brief ReadType * \brief ReadType
* \param pf * \param istr Input stream
* \param type * \param[out] type
* \return * \return true on success
*/ */
bool ReadType(FILE* pf, CBotTypResult &type); bool ReadType(std::istream &istr, CBotTypResult &type);
/*!
* \brief WriteStream
* \param ostr Output stream
* \param istr Input stream
* \return true on success
*/
bool WriteStream(std::ostream &ostr, std::istream& istr);
/*!
* \brief ReadStream
* \param istr Input stream
* \param ostr Output stream
* \return true on success
*/
bool ReadStream(std::istream& istr, std::ostream &ostr);
} // namespace CBot } // namespace CBot

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -19,7 +19,7 @@
#include "CBot/CBotInstr/CBotCase.h" #include "CBot/CBotInstr/CBotCase.h"
#include "CBot/CBotInstr/CBotExprLitNum.h" #include "CBot/CBotInstr/CBotTwoOpExpr.h"
#include "CBot/CBotStack.h" #include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h" #include "CBot/CBotCStack.h"
@ -30,69 +30,107 @@ namespace CBot
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotCase::CBotCase() CBotCase::CBotCase()
{ {
m_value = nullptr; m_instr = nullptr;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotCase::~CBotCase() CBotCase::~CBotCase()
{ {
delete m_value; delete m_instr;
} }
//////////////////////////////////////////////////////////////////////////////// CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack, std::unordered_map<long, CBotInstr*>& labels)
CBotInstr* CBotCase::Compile(CBotToken* &p, CBotCStack* pStack)
{ {
CBotCase* inst = new CBotCase(); // creates the object
CBotToken* pp = p; // preserves at the ^ token (starting position) CBotToken* pp = p; // preserves at the ^ token (starting position)
inst->SetToken(p);
if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return nullptr; // should never happen if (!IsOfType(p, ID_CASE, ID_DEFAULT)) return nullptr; // should never happen
pStack->SetStartError(pp->GetStart());
if ( pp->GetType() == ID_CASE ) long labelValue = 0;
if (pp->GetType() == ID_CASE)
{ {
pp = p; CBotInstr* i = nullptr;
inst->m_value = CBotExprLitNum::Compile(p, pStack); if (nullptr != (i = CBotTwoOpExpr::Compile(p, pStack, nullptr, true)))
if (inst->m_value == nullptr )
{ {
pStack->SetError( CBotErrBadNum, pp ); if (pStack->GetType() <= CBotTypLong)
delete inst; {
return nullptr; CBotStack* pile = CBotStack::AllocateStack();
while ( !i->Execute(pile) );
labelValue = pile->GetVar()->GetValLong();
pile->Delete();
if (labels.count(labelValue) > 0)
{
pStack->SetError(CBotErrRedefCase, p->GetStart());
}
}
else
pStack->SetError(CBotErrBadNum, p->GetStart());
delete i;
} }
} else
if ( !IsOfType( p, ID_DOTS )) pStack->SetError(CBotErrBadNum, p->GetStart());
{
pStack->SetError( CBotErrNoDoubleDots, p->GetStart() );
delete inst;
return nullptr;
} }
return inst; if (pStack->IsOk() && IsOfType(p, ID_DOTS))
{
CBotCase* newCase = new CBotCase();
newCase->SetToken(pp);
if (pp->GetType() == ID_CASE)
labels[labelValue] = newCase;
return newCase;
}
pStack->SetError(CBotErrNoDoubleDots, p->GetStart());
return nullptr;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool CBotCase::Execute(CBotStack* &pj) bool CBotCase::Execute(CBotStack* &pj)
{ {
return true; // the "case" statement does nothing! if (m_instr == nullptr) return true;
CBotStack* pile = pj->AddStack(this, CBotStack::BlockVisibilityType::BLOCK);
int state = pile->GetState();
CBotInstr* p = m_instr;
while (state-- > 0) p = p->GetNext();
while (p != nullptr)
{
if (!p->Execute(pile)) return false;
pile->IncState();
p = p->GetNext();
}
pile->Delete();
return pj->IsOk();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CBotCase::RestoreState(CBotStack* &pj, bool bMain) void CBotCase::RestoreState(CBotStack* &pj, bool bMain)
{ {
} if (!bMain) return;
//////////////////////////////////////////////////////////////////////////////// CBotStack* pile = pj->RestoreStack(this);
bool CBotCase::CompCase(CBotStack* &pile, int val) if (pile == nullptr) return;
{
if (m_value == nullptr ) return true; // "default" case
while (!m_value->Execute(pile)); // puts the value on the correspondent stack (without interruption) CBotInstr* p = m_instr;
return (pile->GetVal() == val); // compared with the given value
int state = pile->GetState();
while (p != nullptr && state-- > 0)
{
p->RestoreState(pile, bMain);
p = p->GetNext();
}
if (p != nullptr) p->RestoreState(pile, bMain);
} }
std::map<std::string, CBotInstr*> CBotCase::GetDebugLinks() std::map<std::string, CBotInstr*> CBotCase::GetDebugLinks()
{ {
auto links = CBotInstr::GetDebugLinks(); auto links = CBotInstr::GetDebugLinks();
links["m_value"] = m_value; links["m_instr"] = m_instr;
return links; return links;
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -21,6 +21,8 @@
#include "CBot/CBotInstr/CBotInstr.h" #include "CBot/CBotInstr/CBotInstr.h"
#include <unordered_map>
namespace CBot namespace CBot
{ {
@ -42,7 +44,7 @@ public:
* \param pStack * \param pStack
* \return * \return
*/ */
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, std::unordered_map<long, CBotInstr*>& labels);
/*! /*!
* \brief Execute Execution of instruction "case". * \brief Execute Execution of instruction "case".
@ -58,22 +60,15 @@ public:
*/ */
void RestoreState(CBotStack* &pj, bool bMain) override; void RestoreState(CBotStack* &pj, bool bMain) override;
/*!
* \brief CompCase Routine to find the entry point of "case" corresponding
* to the value seen.
* \param pj
* \param val
* \return
*/
bool CompCase(CBotStack* &pj, int val) override;
protected: protected:
virtual const std::string GetDebugName() override { return "CBotCase"; } virtual const std::string GetDebugName() override { return "CBotCase"; }
virtual std::map<std::string, CBotInstr*> GetDebugLinks() override; virtual std::map<std::string, CBotInstr*> GetDebugLinks() override;
private: private:
//! Value to compare. //! List of instructions after case label
CBotInstr* m_value; CBotInstr* m_instr;
friend class CBotSwitch;
}; };
} // namespace CBot } // namespace CBot

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -140,7 +140,7 @@ CBotInstr* CBotDefClass::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass* p
if (typ == CBotErrUndefCall) if (typ == CBotErrUndefCall)
{ {
// si le constructeur n'existe pas // if the ctor don't exist
if (inst->m_parameters != nullptr) // with parameters if (inst->m_parameters != nullptr) // with parameters
{ {
pStk->SetError(CBotErrNoConstruct, vartoken); pStk->SetError(CBotErrNoConstruct, vartoken);

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -46,13 +46,22 @@ CBotDefFloat::~CBotDefFloat()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip, CBotTypResult vartype)
{ {
CBotToken* pp = cont ? nullptr : p; CBotToken* pp = cont ? nullptr : p;
if (!cont && !IsOfType(p, ID_FLOAT)) return nullptr; if (!cont)
{
switch (p->GetType())
{
case ID_FLOAT: vartype.SetType(CBotTypFloat ); break;
case ID_DOUBLE: vartype.SetType(CBotTypDouble); break;
default: return nullptr;
}
p = p->GetNext();
}
CBotDefFloat* inst = static_cast<CBotDefFloat*>(CompileArray(p, pStack, CBotTypFloat)); CBotDefFloat* inst = static_cast<CBotDefFloat*>(CompileArray(p, pStack, vartype));
if (inst != nullptr || !pStack->IsOk()) return inst; if (inst != nullptr || !pStack->IsOk()) return inst;
CBotCStack* pStk = pStack->TokenStack(pp); CBotCStack* pStk = pStack->TokenStack(pp);
@ -67,7 +76,7 @@ CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, b
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
{ {
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypFloat; (static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = vartype;
if (pStk->CheckVarLocal(vartoken)) // redefinition of a variable if (pStk->CheckVarLocal(vartoken)) // redefinition of a variable
{ {
pStk->SetStartError(vartoken->GetStart()); pStk->SetStartError(vartoken->GetStart());
@ -79,7 +88,7 @@ CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, b
{ {
delete inst; delete inst;
p = vartoken; p = vartoken;
inst = static_cast<CBotDefFloat*>(CBotDefArray::Compile(p, pStk, CBotTypFloat)); inst = static_cast<CBotDefFloat*>(CBotDefArray::Compile(p, pStk, vartype));
goto suite; // no assignment, variable already created goto suite; // no assignment, variable already created
} }
@ -103,7 +112,7 @@ CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, b
} }
} }
var = CBotVar::Create(*vartoken, CBotTypFloat); var = CBotVar::Create(*vartoken, vartype);
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
var->SetUniqNum( var->SetUniqNum(
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
@ -111,7 +120,7 @@ CBotInstr* CBotDefFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, b
suite: suite:
if (pStk->IsOk() && IsOfType(p, ID_COMMA)) if (pStk->IsOk() && IsOfType(p, ID_COMMA))
{ {
if (nullptr != ( inst->m_next2b = CBotDefFloat::Compile(p, pStk, true, noskip))) if (nullptr != ( inst->m_next2b = CBotDefFloat::Compile(p, pStk, true, noskip, vartype)))
{ {
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -41,7 +41,7 @@ public:
* \param noskip * \param noskip
* \return * \return
*/ */
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip=false, CBotTypResult vartype = CBotTypFloat);
/*! /*!
* \brief Execute Executes the definition of a real variable. * \brief Execute Executes the definition of a real variable.

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -47,13 +47,25 @@ CBotDefInt::~CBotDefInt()
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip) CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool noskip, CBotTypResult vartype)
{ {
CBotToken* pp = cont ? nullptr : p; // no repetition of the token "int" CBotToken* pp = cont ? nullptr : p; // no repetition of the token "int"
if (!cont && !IsOfType(p, ID_INT)) return nullptr; if (!cont)
{
switch (p->GetType())
{
case ID_BYTE: vartype.SetType(CBotTypByte ); break;
case ID_SHORT: vartype.SetType(CBotTypShort); break;
case ID_CHAR: vartype.SetType(CBotTypChar ); break;
case ID_INT: vartype.SetType(CBotTypInt ); break;
case ID_LONG: vartype.SetType(CBotTypLong ); break;
default: return nullptr;
}
p = p->GetNext();
}
CBotDefInt* inst = static_cast<CBotDefInt*>(CompileArray(p, pStack, CBotTypInt)); CBotDefInt* inst = static_cast<CBotDefInt*>(CompileArray(p, pStack, vartype));
if (inst != nullptr || !pStack->IsOk()) return inst; if (inst != nullptr || !pStack->IsOk()) return inst;
CBotCStack* pStk = pStack->TokenStack(pp); CBotCStack* pStk = pStack->TokenStack(pp);
@ -68,7 +80,7 @@ CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, boo
// determines the expression is valid for the item on the left side // determines the expression is valid for the item on the left side
if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk ))) if (nullptr != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
{ {
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypInt; (static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = vartype;
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
{ {
pStk->SetError(CBotErrRedefVar, vartoken); pStk->SetError(CBotErrRedefVar, vartoken);
@ -82,7 +94,7 @@ CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, boo
// compiles an array declaration // compiles an array declaration
CBotInstr* inst2 = CBotDefArray::Compile(p, pStk, CBotTypInt); CBotInstr* inst2 = CBotDefArray::Compile(p, pStk, vartype);
inst = static_cast<CBotDefInt*>(inst2); inst = static_cast<CBotDefInt*>(inst2);
goto suite; // no assignment, variable already created goto suite; // no assignment, variable already created
@ -108,7 +120,7 @@ CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, boo
} }
{ {
CBotVar* var = CBotVar::Create(*vartoken, CBotTypInt);// create the variable (evaluated after the assignment) CBotVar* var = CBotVar::Create(*vartoken, vartype); // create the variable (evaluated after the assignment)
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); // if initialized with assignment var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); // if initialized with assignment
var->SetUniqNum( //set it with a unique number var->SetUniqNum( //set it with a unique number
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
@ -117,7 +129,7 @@ CBotInstr* CBotDefInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, boo
suite: suite:
if (pStk->IsOk() && IsOfType(p, ID_COMMA)) // chained several definitions if (pStk->IsOk() && IsOfType(p, ID_COMMA)) // chained several definitions
{ {
if (nullptr != ( inst->m_next2b = CBotDefInt::Compile(p, pStk, true, noskip))) // compile next one if (nullptr != ( inst->m_next2b = CBotDefInt::Compile(p, pStk, true, noskip, vartype))) // compile next one
{ {
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -41,7 +41,7 @@ public:
* \param noskip * \param noskip
* \return * \return
*/ */
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool cont = false, bool noskip = false, CBotTypResult vartype = CBotTypInt);
/*! /*!
* \brief Execute Execute the definition of the integer variable. * \brief Execute Execute the definition of the integer variable.

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -57,7 +57,7 @@ CBotInstr* CBotDo::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(p); inst->SetToken(p);
if (!IsOfType(p, ID_DO)) return nullptr; // should never happen if (!IsOfType(p, ID_DO)) return nullptr; // should never happen
CBotCStack* pStk = pStack->TokenStack(pp); // un petit bout de pile svp CBotCStack* pStk = pStack->TokenStack(pp); // some space for a stack, plz
// looking for a statement block after the do // looking for a statement block after the do

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -0,0 +1,151 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#include "CBot/CBotInstr/CBotExprLitChar.h"
#include "CBot/CBotStack.h"
#include "CBot/CBotCStack.h"
#include "CBot/CBotVar/CBotVar.h"
namespace CBot
{
CBotExprLitChar::CBotExprLitChar()
{
}
CBotExprLitChar::~CBotExprLitChar()
{
}
CBotInstr* CBotExprLitChar::Compile(CBotToken* &p, CBotCStack* pStack)
{
CBotCStack* pStk = pStack->TokenStack();
const auto& s = p->GetString();
auto it = s.cbegin();
if (++it != s.cend())
{
if (*it != '\'') // not empty quotes ?
{
uint32_t valchar = 0;
int pos = p->GetStart() + 1;
if (*it != '\\') valchar = *(it++); // not escape sequence ?
else if (++it != s.cend())
{
pStk->SetStartError(pos++);
unsigned char c = *(it++);
if (c == '\"' || c == '\'' || c == '\\') valchar = c;
else if (c == 'a') valchar = '\a'; // alert bell
else if (c == 'b') valchar = '\b'; // backspace
else if (c == 'f') valchar = '\f'; // form feed
else if (c == 'n') valchar = '\n'; // new line
else if (c == 'r') valchar = '\r'; // carriage return
else if (c == 't') valchar = '\t'; // horizontal tab
else if (c == 'v') valchar = '\v'; // vertical tab
else if (c == 'u' || c == 'U') // unicode escape
{
if (it != s.cend())
{
std::string hex = "";
size_t maxlen = (c == 'u') ? 4 : 8;
for (size_t i = 0; i < maxlen; i++)
{
if (!CharInList(*it, "0123456789ABCDEFabcdef")) break;
++pos;
hex += *it;
if (++it == s.cend()) break;
}
if (maxlen == hex.length()) // unicode character
{
try
{
valchar = std::stoi(hex, nullptr, 16);
if (0x10FFFF < valchar || (0xD7FF < valchar && valchar < 0xE000))
pStk->SetError(CBotErrUnicodeName, pos + 1);
}
catch (const std::out_of_range& e)
{
pStk->SetError(CBotErrHexRange, pos + 1);
}
}
else
pStk->SetError(CBotErrHexDigits, pos + 1);
}
else
pStk->SetError(CBotErrHexDigits, pos + 1);
}
else
pStk->SetError(CBotErrBadEscape, pos + 1);
}
if (it == s.cend() || *it != '\'')
pStk->SetError(CBotErrEndQuote, p);
if (pStk->IsOk())
{
CBotExprLitChar* inst = new CBotExprLitChar();
inst->m_valchar = valchar;
inst->SetToken(p);
p = p->GetNext();
CBotVar* var = CBotVar::Create("", CBotTypChar);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
}
pStk->SetError(CBotErrCharEmpty, p);
}
pStk->SetError(CBotErrEndQuote, p);
return pStack->Return(nullptr, pStk);
}
bool CBotExprLitChar::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", CBotTypChar);
var->SetValChar(m_valchar);
pile->SetVar(var);
return pj->Return(pile);
}
void CBotExprLitChar::RestoreState(CBotStack* &pj, bool bMain)
{
if (bMain) pj->RestoreStack(this);
}
std::string CBotExprLitChar::GetDebugData()
{
return m_token.GetString();
}
} // namespace CBot

View File

@ -0,0 +1,60 @@
/*
* This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot
*
* 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://gnu.org/licenses
*/
#pragma once
#include "CBot/CBotInstr/CBotInstr.h"
namespace CBot
{
/**
* \brief A character literal
* \verbatim 'a', '\n', '\t', '\uFFFD', '\U0000FFFD', etc. \endverbatim
*/
class CBotExprLitChar : public CBotInstr
{
public:
CBotExprLitChar();
~CBotExprLitChar();
/*!
* \brief Compile a character literal
*/
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
/*!
* \brief Execute, returns the corresponding char.
*/
bool Execute(CBotStack* &pj) override;
/*!
* \brief RestoreState
*/
void RestoreState(CBotStack* &pj, bool bMain) override;
protected:
virtual const std::string GetDebugName() override { return "CBotExprLitChar"; }
virtual std::string GetDebugData() override;
private:
uint32_t m_valchar = 0;
};
} // namespace CBot

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -25,52 +25,85 @@
#include "CBot/CBotUtils.h" #include "CBot/CBotUtils.h"
#include <limits>
#include <sstream> #include <sstream>
namespace CBot namespace CBot
{ {
//////////////////////////////////////////////////////////////////////////////// template <>
CBotExprLitNum::CBotExprLitNum() CBotExprLitNum<int>::CBotExprLitNum(int val) : m_numtype(CBotTypInt), m_value(val)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// template <>
CBotExprLitNum::~CBotExprLitNum() CBotExprLitNum<long>::CBotExprLitNum(long val) : m_numtype(CBotTypLong), m_value(val)
{ {
} }
//////////////////////////////////////////////////////////////////////////////// template <>
CBotInstr* CBotExprLitNum::Compile(CBotToken* &p, CBotCStack* pStack) CBotExprLitNum<float>::CBotExprLitNum(float val) : m_numtype(CBotTypFloat), m_value(val)
{
}
template <>
CBotExprLitNum<double>::CBotExprLitNum(double val) : m_numtype(CBotTypDouble), m_value(val)
{
}
template <typename T>
CBotExprLitNum<T>::~CBotExprLitNum()
{
}
CBotInstr* CompileExprLitNum(CBotToken* &p, CBotCStack* pStack)
{ {
CBotCStack* pStk = pStack->TokenStack(); CBotCStack* pStk = pStack->TokenStack();
CBotExprLitNum* inst = new CBotExprLitNum(); const auto& s = p->GetString();
inst->SetToken(p); CBotInstr* inst = nullptr;
std::string s = p->GetString(); CBotType numtype = CBotTypInt;
inst->m_numtype = CBotTypInt;
if (p->GetType() == TokenTypDef) if (p->GetType() == TokenTypDef)
{ {
inst->m_valint = p->GetKeywordId(); inst = new CBotExprLitNum<int>(static_cast<int>(p->GetKeywordId()));
} }
else else
{ {
if (s.find('.') != std::string::npos || ( s.find('x') == std::string::npos && ( s.find_first_of("eE") != std::string::npos ) )) if (s.find('.') != std::string::npos || ( s.find('x') == std::string::npos && ( s.find_first_of("eE") != std::string::npos ) ))
{ {
inst->m_numtype = CBotTypFloat; double val = GetNumFloat(s);
inst->m_valfloat = GetNumFloat(s); if (val > static_cast<double>(std::numeric_limits<float>::max()))
{
numtype = CBotTypDouble;
inst = new CBotExprLitNum<double>(val);
}
else
{
numtype = CBotTypFloat;
inst = new CBotExprLitNum<float>(static_cast<float>(val));
}
} }
else else
{ {
inst->m_valint = GetNumInt(s); long val = GetNumInt(s);
if (val > std::numeric_limits<int>::max())
{
numtype = CBotTypLong;
inst = new CBotExprLitNum<long>(val);
}
else
{
inst = new CBotExprLitNum<int>(static_cast<int>(val));
}
} }
} }
inst->SetToken(p);
if (pStk->NextToken(p)) if (pStk->NextToken(p))
{ {
CBotVar* var = CBotVar::Create("", inst->m_numtype); CBotVar* var = CBotVar::Create("", numtype);
pStk->SetVar(var); pStk->SetVar(var);
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
@ -79,8 +112,48 @@ CBotInstr* CBotExprLitNum::Compile(CBotToken* &p, CBotCStack* pStack)
return pStack->Return(nullptr, pStk); return pStack->Return(nullptr, pStk);
} }
//////////////////////////////////////////////////////////////////////////////// CBotInstr* CompileSizeOf(CBotToken* &p, CBotCStack* pStack)
bool CBotExprLitNum::Execute(CBotStack* &pj) {
CBotToken* pp = p;
if (!IsOfType(p, TokenTypVar)) return nullptr;
if (pp->GetString() == "sizeof" && IsOfType(p, ID_OPENPAR))
{
CBotCStack* pStk = pStack->TokenStack();
int value;
if (IsOfType(p, ID_BYTE)) value = sizeof(signed char);
else if (IsOfType(p, ID_SHORT)) value = sizeof(short);
else if (IsOfType(p, ID_CHAR)) value = sizeof(uint32_t);
else if (IsOfType(p, ID_INT)) value = sizeof(int);
else if (IsOfType(p, ID_LONG)) value = sizeof(long);
else if (IsOfType(p, ID_FLOAT)) value = sizeof(float);
else if (IsOfType(p, ID_DOUBLE)) value = sizeof(double);
else
{
p = pp;
return pStack->Return(nullptr, pStk);
}
if (IsOfType(p, ID_CLOSEPAR))
{
auto inst = new CBotExprLitNum<int>(value);
inst->SetToken(pp);
CBotVar* var = CBotVar::Create("", CBotTypInt);
pStk->SetVar(var);
return pStack->Return(inst, pStk);
}
pStk->SetError(CBotErrClosePar, p->GetStart());
return pStack->Return(nullptr, pStk);
}
p = pp;
return nullptr;
}
template <typename T>
bool CBotExprLitNum<T>::Execute(CBotStack* &pj)
{ {
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
@ -88,39 +161,38 @@ bool CBotExprLitNum::Execute(CBotStack* &pj)
CBotVar* var = CBotVar::Create("", m_numtype); CBotVar* var = CBotVar::Create("", m_numtype);
std::string nombre ;
if (m_token.GetType() == TokenTypDef) if (m_token.GetType() == TokenTypDef)
{ {
nombre = m_token.GetString(); var->SetValInt(m_value, m_token.GetString());
} }
else
switch (m_numtype)
{ {
case CBotTypShort: *var = m_value;
case CBotTypInt:
var->SetValInt(m_valint, nombre);
break;
case CBotTypFloat:
var->SetValFloat(m_valfloat);
break;
default:
assert(false);
} }
pile->SetVar(var); // place on the stack pile->SetVar(var); // place on the stack
return pj->Return(pile); // it's ok return pj->Return(pile); // it's ok
} }
//////////////////////////////////////////////////////////////////////////////// template <typename T>
void CBotExprLitNum::RestoreState(CBotStack* &pj, bool bMain) void CBotExprLitNum<T>::RestoreState(CBotStack* &pj, bool bMain)
{ {
if (bMain) pj->RestoreStack(this); if (bMain) pj->RestoreStack(this);
} }
std::string CBotExprLitNum::GetDebugData() template <typename T>
std::string CBotExprLitNum<T>::GetDebugData()
{ {
std::stringstream ss; std::stringstream ss;
ss << "(" << (m_numtype == CBotTypFloat ? "float" : "int") << ") " << (m_numtype == CBotTypFloat ? m_valfloat : m_valint); switch (m_numtype)
{
case CBotTypInt : ss << "(int) "; break;
case CBotTypLong : ss << "(long) "; break;
case CBotTypFloat : ss << "(float) "; break;
case CBotTypDouble: ss << "(double) "; break;
default: assert(false);
}
ss << m_value;
return ss.str(); return ss.str();
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -24,25 +24,24 @@
namespace CBot namespace CBot
{ {
CBotInstr* CompileExprLitNum(CBotToken* &p, CBotCStack* pStack);
CBotInstr* CompileSizeOf(CBotToken* &p, CBotCStack* pStack);
/** /**
* \brief A number literal - 5, 1, 2.5, 3.75, etc. or a predefined numerical constant (see CBotToken::DefineNum()) * \brief A number literal - 5, 1, 2.5, 3.75, etc. or a predefined numerical constant (see CBotToken::DefineNum())
* *
* Can be of type ::CBotTypInt or ::CBotTypFloat * Can be of type ::CBotTypInt, ::CBotTypLong, ::CBotTypFloat, or ::CBotTypDouble
*/ */
template <typename T>
class CBotExprLitNum : public CBotInstr class CBotExprLitNum : public CBotInstr
{ {
public: public:
CBotExprLitNum(); // To keep linter happy, instead of = delete (see https://stackoverflow.com/a/37593094)
~CBotExprLitNum(); CBotExprLitNum(T val) { static_assert(sizeof(T) == 0, "Only specializations of CBotExprLitNum can be used"); };
/*! ~CBotExprLitNum();
* \brief Compile
* \param p
* \param pStack
* \return
*/
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
/*! /*!
* \brief Execute Execute, returns the corresponding number. * \brief Execute Execute, returns the corresponding number.
@ -65,10 +64,8 @@ protected:
private: private:
//! The type of number. //! The type of number.
CBotType m_numtype; CBotType m_numtype;
//! Value for an int. //! Value
long m_valint; T m_value;
//! Value for a float.
float m_valfloat;
}; };

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -24,6 +24,8 @@
#include "CBot/CBotVar/CBotVar.h" #include "CBot/CBotVar/CBotVar.h"
#include <stdexcept>
namespace CBot namespace CBot
{ {
@ -42,7 +44,7 @@ CBotInstr* CBotExprLitString::Compile(CBotToken* &p, CBotCStack* pStack)
{ {
CBotCStack* pStk = pStack->TokenStack(); CBotCStack* pStk = pStack->TokenStack();
std::string s = p->GetString(); const auto& s = p->GetString();
auto it = s.cbegin(); auto it = s.cbegin();
if (++it != s.cend()) if (++it != s.cend())
@ -51,7 +53,7 @@ CBotInstr* CBotExprLitString::Compile(CBotToken* &p, CBotCStack* pStack)
std::string valstring = ""; std::string valstring = "";
while (it != s.cend() && *it != '\"') while (it != s.cend() && *it != '\"')
{ {
pStk->SetStartError(++pos); ++pos;
if (*it != '\\') // not escape sequence ? if (*it != '\\') // not escape sequence ?
{ {
valstring += *(it++); valstring += *(it++);
@ -59,6 +61,7 @@ CBotInstr* CBotExprLitString::Compile(CBotToken* &p, CBotCStack* pStack)
} }
if (++it == s.cend()) break; if (++it == s.cend()) break;
pStk->SetStartError(pos);
if (CharInList(*it, "01234567")) // octal if (CharInList(*it, "01234567")) // octal
{ {

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -40,8 +40,7 @@ CBotExprUnaire::~CBotExprUnaire()
delete m_expr; delete m_expr;
} }
//////////////////////////////////////////////////////////////////////////////// CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack, bool bLiteral, bool bConstExpr)
CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack, bool bLiteral)
{ {
int op = p->GetType(); int op = p->GetType();
CBotToken* pp = p; CBotToken* pp = p;
@ -52,8 +51,10 @@ CBotInstr* CBotExprUnaire::Compile(CBotToken* &p, CBotCStack* pStack, bool bLite
CBotExprUnaire* inst = new CBotExprUnaire(); CBotExprUnaire* inst = new CBotExprUnaire();
inst->SetToken(pp); inst->SetToken(pp);
if (!bLiteral) inst->m_expr = CBotParExpr::Compile(p, pStk); if (bConstExpr || !bLiteral)
else inst->m_expr = CBotParExpr::CompileLitExpr(p, pStk); inst->m_expr = CBotParExpr::Compile(p, pStk, bConstExpr);
else
inst->m_expr = CBotParExpr::CompileLitExpr(p, pStk);
if (inst->m_expr != nullptr) if (inst->m_expr != nullptr)
{ {

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -40,7 +40,7 @@ public:
* \param bLiteral If true, compiles only literal expressions Ex: ~11, -4.0, !false, not true * \param bLiteral If true, compiles only literal expressions Ex: ~11, -4.0, !false, not true
* \return The compiled instruction or nullptr * \return The compiled instruction or nullptr
*/ */
static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLiteral = false); static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLiteral = false, bool bConstExpr = false);
/*! /*!
* \brief Execute * \brief Execute

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -67,7 +67,7 @@ CBotInstr* CBotFor::Compile(CBotToken* &p, CBotCStack* pStack)
return nullptr; return nullptr;
} }
CBotCStack* pStk = pStack->TokenStack(pp, true); // un petit bout de pile svp CBotCStack* pStk = pStack->TokenStack(pp, true); // some size for a stack, plz
// compiles instructions for initialization // compiles instructions for initialization
inst->m_init = CBotListExpression::Compile(p, pStk ); inst->m_init = CBotListExpression::Compile(p, pStk );

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -169,7 +169,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
func->m_token = d; func->m_token = d;
} }
// un nom de fonction est-il là ? // is there a function name here ?
if (IsOfType(p, TokenTypVar)) if (IsOfType(p, TokenTypVar))
{ {
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
@ -284,7 +284,7 @@ CBotFunction* CBotFunction::Compile1(CBotToken* &p, CBotCStack* pStack, CBotClas
func->m_token = d; func->m_token = d;
} }
// un nom de fonction est-il là ? // is there a function name here ?
if (IsOfType(p, TokenTypVar)) if (IsOfType(p, TokenTypVar))
{ {
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
@ -584,7 +584,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(const std::list<CBotFunction*>& lo
{ {
int i = 0; int i = 0;
int alpha = 0; // signature of parameters int alpha = 0; // signature of parameters
// parameters sont-ils compatibles ? // are parameters compatible ?
CBotDefParam* pv = pt->m_param; // list of expected parameters CBotDefParam* pv = pt->m_param; // list of expected parameters
CBotVar* pw = ppVars[i++]; // list of provided parameters CBotVar* pw = ppVars[i++]; // list of provided parameters
while ( pv != nullptr && (pw != nullptr || pv->HasDefault()) ) while ( pv != nullptr && (pw != nullptr || pv->HasDefault()) )
@ -996,7 +996,7 @@ bool CBotFunction::CheckParam(CBotDefParam* pParam)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string CBotFunction::GetName() const std::string& CBotFunction::GetName()
{ {
return m_token.GetString(); return m_token.GetString();
} }

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -207,7 +207,7 @@ public:
* \brief GetName * \brief GetName
* \return * \return
*/ */
std::string GetName(); const std::string& GetName();
/*! /*!
* \brief GetParams * \brief GetParams

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -208,10 +208,15 @@ CBotInstr* CBotInstr::Compile(CBotToken* &p, CBotCStack* pStack)
case ID_THROW: case ID_THROW:
return CBotThrow::Compile(p, pStack); return CBotThrow::Compile(p, pStack);
case ID_BYTE:
case ID_SHORT:
case ID_CHAR:
case ID_INT: case ID_INT:
case ID_LONG:
return CBotDefInt::Compile(p, pStack); return CBotDefInt::Compile(p, pStack);
case ID_FLOAT: case ID_FLOAT:
case ID_DOUBLE:
return CBotDefFloat::Compile(p, pStack); return CBotDefFloat::Compile(p, pStack);
case ID_STRING: case ID_STRING:
@ -312,13 +317,6 @@ void CBotInstr::RestoreStateVar(CBotStack* &pile, bool bMain)
assert(0); // dad do not know, see the girls assert(0); // dad do not know, see the girls
} }
////////////////////////////////////////////////////////////////////////////////
bool CBotInstr::CompCase(CBotStack* &pj, int val)
{
return false;
}
////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first) CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypResult type, bool first)
{ {
if (IsOfType(p, ID_OPBRK)) if (IsOfType(p, ID_OPBRK))

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
@ -191,17 +191,6 @@ public:
virtual void RestoreStateVar(CBotStack* &pile, virtual void RestoreStateVar(CBotStack* &pile,
bool bMain); bool bMain);
/**
* \brief CompCase This routine is defined only for the subclass CBotCase
* this allows to make the call on all instructions CompCase to see if it's
* a case to the desired value..
* \param pj
* \param val
* \return
*/
virtual bool CompCase(CBotStack* &pj,
int val);
/** /**
* \brief SetToken Set the token corresponding to the instruction. * \brief SetToken Set the token corresponding to the instruction.
* \param p * \param p

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

View File

@ -1,6 +1,6 @@
/* /*
* This file is part of the Colobot: Gold Edition source code * This file is part of the Colobot: Gold Edition source code
* Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam * Copyright (C) 2001-2018, Daniel Roux, EPSITEC SA & TerranovaTeam
* http://epsitec.ch; http://colobot.info; http://github.com/colobot * http://epsitec.ch; http://colobot.info; http://github.com/colobot
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify

Some files were not shown because too many files have changed in this diff Show More